6 if (!buf || len == 0)
return false;
7 for (
size_t i = 0; i < len; i++) {
8 if (buf[i] >=
'0' && buf[i] <=
'9')
continue;
9 if (buf[i] >=
'A' && buf[i] <=
'F')
continue;
10 if (buf[i] >=
'a' && buf[i] <=
'f')
continue;
18 if (!buf || len == 0)
return false;
19 for (
size_t i = 0; i < len; i++) {
20 if (buf[i] >=
'0' && buf[i] <=
'9')
continue;
28 if (!my_buf)
return false;
30 const char hex_pattern[] =
"0x";
31 size_t hex_pattern_len = strlen(hex_pattern);
33 const size_t len = strlen(my_buf);
34 if (len == 0)
return false;
36 if (len > hex_pattern_len) {
38 if (!
is_hex(my_buf + hex_pattern_len, len - hex_pattern_len))
return false;
47 if (!my_buf)
return false;
49 const size_t len = strlen(my_buf);
51 if (
is_dec(my_buf, len))
return true;
57 if (!my_buf)
return false;
59 const char hex_pattern[] =
"0x";
60 size_t hex_pattern_len = strlen(hex_pattern);
62 const size_t len = strlen(my_buf);
63 if (len == 0)
return 0;
66 const size_t min_length = 1;
67 if (len > hex_pattern_len) {
69 if (!
is_hex(my_buf + hex_pattern_len, min_length))
return 0;
72 ss << std::hex << my_buf;
77 if (!
is_dec(my_buf, min_length))
return 0;
80 ss << std::dec << my_buf;
86 CONSOLE_SCREEN_BUFFER_INFO info;
87 if (!GetConsoleScreenBufferInfo(hConsole, &info))
89 color = info.wAttributes;
95 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
99 FlushConsoleInputBuffer(hConsole);
100 SetConsoleTextAttribute(hConsole, color);
102 FlushConsoleInputBuffer(hConsole);
104 SetConsoleTextAttribute(hConsole, prev);
108 std::string&
ltrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r ")
110 str.erase(0, str.find_first_not_of(chars));
114 std::string&
rtrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r ")
116 str.erase(str.find_last_not_of(chars) + 1);
129 size_t end = s.find(delim);
130 while (end != std::string::npos)
132 std::string next_str = s.substr(start, end - start);
134 if (next_str.length() > 0) {
135 elements_list.insert(next_str);
137 start = end + delim.length();
138 end = s.find(delim, start);
140 std::string next_str = s.substr(start, end);
142 if (next_str.length() > 0) {
143 elements_list.insert(next_str);
145 return elements_list.size();
bool is_cstr_equal(char const *a, char const *b, const size_t max_len, bool ignoreCase=true)
long get_number(const char *my_buf)
bool is_dec(const char *buf, size_t len)
std::string & rtrim(std::string &str, const std::string &chars="\t\n\v\f\r ")
void print_in_color(int color, const std::string &text)
bool is_number(const char *my_buf)
std::string & ltrim(std::string &str, const std::string &chars="\t\n\v\f\r ")
bool get_console_color(HANDLE hConsole, int &color)
size_t strip_to_list(IN std::string s, IN std::string delim, OUT std::set< std::string > &elements_list)
bool is_hex(const char *buf, size_t len)
std::string & trim(std::string &str, const std::string &chars="\t\n\v\f\r ")
bool is_hex_with_prefix(const char *buf)
The set of utility functions used by the ParamKit.
The set of utility functions related with string processing, and finding similarity between strings.