12 #ifndef XPACE_MATCHSTRING_H 13 #define XPACE_MATCHSTRING_H 15 #include <unordered_map> 19 template <
typename FUNCTION>
36 template <
typename STR>
40 typedef typename STR::charType
CH;
43 typedef std::function<bool(int64)>
intFunc;
48 const STR& getNativeFormat
55 const String& getStringFormat
71 const String string_format;
80 std::vector<fchar> format;
82 std::unordered_map<CH, intFunc> int_funcs;
101 for (
auto f(fv.begin());
f != fv.end(); ++
f)
102 format.push_back(*
f);
118 format.push_back(*
f);
122 template <
typename STR>
129 for (
auto f(format.begin());
f != format.end(); ++
f)
136 return (found) ? (int_funcs[ch] = fn,
true) :
false;
139 template <
typename STR>
145 auto f(format.begin());
148 auto send(str.data + str.length);
156 while ((*scur !=
f->ch) && (scur != send))
160 if (!int_funcs.find(sub)->second(to_int64(s, scur)))
182 template <
typename STR>
203 (
reinterpret_cast<const char*
>(b), reinterpret_cast<char**>(&e), 10);
218 (
reinterpret_cast<const wchar_t*
>(b), reinterpret_cast<wchar_t**>(&e), 10);
MatchString(const String &fmt)
bool match(const STR str) const
bool add(const CH ch, intFunc fn)
A string, Unicode UTF-16 and reference-counted.
const utf16_t * toUtf16() const
std::function< bool(int64)> intFunc
Xpace project main namespace
utf8_t * toUtf8(utf8_t *buf, size_t bufLen) const
convert a String into a (null-terminated) UTF-8 string, writing it into a buffer