29 int value_index(
const string& val,
const string& strings,
int defValue = -1,
char delim =
';');
31 bool value_in_list(
const string& val,
const string& strings,
char delim =
';');
32 string::size_type
find_close_bracket(
const string&
s, string::size_type off,
char open_b =
'(',
char close_b =
')');
36 double t_strtod(
const char*
string,
char** endPtr =
nullptr);
39 template<
typename X,
typename A>
44 template<
typename X,
typename A,
typename... AA>
50 const T&
at(
const vector<T>& vec,
int index )
52 static T invalid_item;
54 return index >= 0 &&
index < (int)vec.size() ? vec[
index] : invalid_item;
56 template<
class Map,
class Key>
57 auto at(
const Map& map, Key key)
59 static typename Map::mapped_type invalid_value;
60 auto it =
map.find(key);
61 return it !=
map.end() ? it->second : invalid_value;
78 if (
count <= 0)
return;
85 vec.insert(vec.begin() +
index, x.begin(), x.end());
88 vector<T>&
operator+=(vector<T>& vec,
const vector<T>& x)
90 vec.insert(vec.end(), x.begin(), x.end());
93 template<
class C,
class T>
96 return std::find(coll.begin(), coll.end(), item) != coll.end();
98 inline bool contains(
const string& str,
const string& substr)
100 return str.find(substr) != string::npos;
102 template<
class C>
void sort(C& coll) { std::sort(coll.begin(), coll.end()); }
106 inline bool equal_i(
const string& s1,
const string& s2)
108 if (s1.size() != s2.size())
return false;
109 return t_strncasecmp(s1.c_str(), s2.c_str(), s1.size()) == 0;
111 inline bool match(
const string& str,
int index ,
const string& substr)
114 if (
index < 0)
return false;
115 return str.substr(
index, substr.size()) == substr;
117 inline bool match_i(
const string& str,
int index ,
const string& substr)
120 if (
index < 0)
return false;
121 return equal_i(str.substr(
index, substr.size()), substr);
124 bool is_number(
const string&
string,
bool allow_dot =
true);
129 return c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r' || c ==
'\f';
134 return (c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z');
140 return (c >=
'A' && c <=
'Z' ? c +
'a' -
'A' : c);
149 for (
char& c : str) c = (
char)
t_tolower(c);
155 return (c >=
'0' && c <=
'9');
160 return is_digit(ch) || (ch >=
'a' && ch <=
'f') || (ch >=
'A' && ch <=
'F');
168 return ch >= 0xD800 && ch < 0xE000;
173 int int_val = (int) val;
174 if(val - int_val >= 0.5)
183 int int_val = (int) val;
184 if(val - int_val >= 0.5)
191 inline float t_strtof(
const string& str,
char** endPtr =
nullptr)
193 return (
float)
t_strtod(str.c_str(), endPtr);
constexpr auto count() -> size_t
Definition core.h:1538
Definition background.h:12
line_height
Definition types.h:367
bool contains(const C &coll, const T &item)
Definition html.h:94
bool match(const string &str, int index, const string &substr)
Definition html.h:111
bool is_hex_digit(int ch)
Definition html.h:159
const auto is_letter
Definition html.h:136
bool match_i(const string &str, int index, const string &substr)
Definition html.h:117
int round_f(float val)
Definition html.h:171
int lowcase(int c)
Definition html.h:143
int t_isdigit(int c)
Definition html.h:153
float t_strtof(const string &str, char **endPtr=nullptr)
Definition html.h:191
const string whitespace
Definition html.h:25
bool value_in_list(const string &val, const string &strings, char delim=';')
Definition html.cpp:113
bool is_whitespace(int c)
Definition html.h:127
string & trim(string &s, const string &chars_to_trim=whitespace)
Definition html.cpp:7
const T & at(const vector< T > &vec, int index)
Definition html.h:50
int t_strncasecmp(const char *s1, const char *s2, size_t n)
Definition html.cpp:222
const auto is_digit
Definition html.h:157
bool equal_i(const string &s1, const string &s2)
Definition html.h:106
int baseline_align(int line_height, int line_base_line, int height, int baseline)
Definition html.h:196
vector< T > slice(const vector< T > &vec, int index, int count=-1)
Definition html.h:64
int t_tolower(int c)
Definition html.h:138
string::size_type find_close_bracket(const string &s, string::size_type off, char open_b='(', char close_b=')')
Definition html.cpp:43
void split_string(const string &str, string_vector &tokens, const string &delims=whitespace, const string &delims_preserve="", const string "e="\"")
Definition html.cpp:130
string index_value(int index, const string &strings, char delim=';')
Definition html.cpp:63
vector< T > & operator+=(vector< T > &vec, const vector< T > &x)
Definition html.h:88
int value_index(const string &val, const string &strings, int defValue=-1, char delim=';')
Definition html.cpp:76
string & lcase(string &s)
Definition html.cpp:34
string get_escaped_string(const string &in_str)
Definition html.cpp:241
std::vector< string > string_vector
Definition types.h:34
int digit_value(int ch)
Definition html.h:163
bool is_one_of(X x, A a)
Definition html.h:40
bool is_surrogate(int ch)
Definition html.h:167
void insert(vector< T > &vec, int index, const vector< T > &x)
Definition html.h:83
double t_strtod(const char *string, char **endPtr=nullptr)
Definition strtod.cpp:71
int round_d(double val)
Definition html.h:181
bool is_number(const string &string, bool allow_dot=true)
Definition html.cpp:299
int t_strcasecmp(const char *s1, const char *s2)
Definition html.cpp:205
void sort(C &coll)
Definition html.h:102
int t_isalpha(int c)
Definition html.h:132
void join_string(string &str, const string_vector &tokens, const string &delims)
Definition html.cpp:192
void remove(C &vec, int index, int count=1)
Definition html.h:70
s
Definition tag_strings.h:47
a
Definition tag_strings.h:43
map
Definition tag_strings.h:86