From 7e743b73433475df086fcec81be7b10c1d695a42 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Fri, 7 May 2021 02:18:07 +0300 Subject: initial --- src/util.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/util.h (limited to 'src/util.h') 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 +#include +#include + +bool is_numeric(const std::string& s); +bool is_date_valid(int y, int m, int d); + +template +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 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 -- cgit v1.2.3