aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-05-07 02:18:07 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-05-07 02:18:07 +0300
commit7e743b73433475df086fcec81be7b10c1d695a42 (patch)
tree1737c5f9bdad2a40f740e9a655e510641331b9e2 /src/util.h
initial
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..e9c3730
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: BSD-3-Clause
+
+#ifndef INVERTER_TOOLS_UTIL_H
+#define INVERTER_TOOLS_UTIL_H
+
+#include <string>
+#include <vector>
+#include <algorithm>
+
+bool is_numeric(const std::string& s);
+bool is_date_valid(int y, int m, int d);
+
+template <typename T, typename P>
+long index_of(T& haystack, P& needle)
+{
+ auto _it = std::find(haystack.begin(), haystack.end(), needle);
+ if (_it == haystack.end())
+ return -1;
+ return std::distance(haystack.begin(), _it);
+}
+
+std::vector<std::string> split(const std::string& s, char separator);
+unsigned stou(const std::string& s);
+unsigned short stouh(const std::string& s);
+
+bool string_has(std::string& s, char c);
+unsigned long hextoul(std::string& s);
+
+std::string demangle_type_name(const char* name);
+
+#endif //INVERTER_TOOLS_UTIL_H