33#pragma warning(disable: 4100)
36#define ENUM_FLAG_OPERATOR(T,X) \
37inline T operator X (const T lhs, const T rhs) { return static_cast<T>(static_cast<std::underlying_type_t<T>>(lhs) X static_cast<std::underlying_type_t<T>>(rhs)); } \
38inline T operator X (const T lhs, const std::underlying_type_t<T> rhs) { return static_cast<T>(static_cast<std::underlying_type_t<T>>(lhs) X rhs); } \
39inline T operator X (const std::underlying_type_t<T> lhs, const T rhs) { return static_cast<T>(lhs X static_cast<std::underlying_type_t<T>>(rhs)); } \
40inline T& operator X= (T& lhs, const T rhs) { return lhs = lhs X rhs; } \
41inline T& operator X= (T& lhs, const std::underlying_type_t<T> rhs) { return lhs = lhs X rhs; }
42#define ENUM_FLAGS(T, type) \
44inline T operator ~ (T t) { return (T) (~static_cast<std::underlying_type_t <T>>(t)); } \
45ENUM_FLAG_OPERATOR(T,|) \
46ENUM_FLAG_OPERATOR(T,^) \
47ENUM_FLAG_OPERATOR(T,&) \
57 constexpr int match_default = 0;
58 constexpr int match_case_insensitive = 0x1;
59 constexpr int match_multiline = 0x2;
68 basic_parser(_In_
const std::locale& locale = std::locale()) : m_locale(locale) {}
72 _In_reads_or_z_(end)
const T* text,
73 _In_
size_t start = 0,
74 _In_
size_t end = (
size_t)-1,
75 _In_
int flags = match_default)
77 for (
size_t i = start; i < end && text[i]; i++)
78 if (match(text, i, end, flags))
84 _In_reads_or_z_(end)
const T* text,
85 _In_
size_t start = 0,
86 _In_
size_t end = (
size_t)-1,
87 _In_
int flags = match_default) = 0;
89 template<
class _Traits,
class _Ax>
91 const std::basic_string<T, _Traits, _Ax>& text,
92 _In_
size_t start = 0,
93 _In_
size_t end = (
size_t)-1,
94 _In_
int flags = match_default)
96 return match(text.c_str(), start, std::min<size_t>(end, text.size()), flags);
99 virtual void invalidate()
107 const wchar_t* next_sgml_cp(_In_
const char* text, _In_
size_t start, _In_
size_t end, _Out_
size_t& chr_end, _Out_
wchar_t(&buf)[3])
109 if (text[start] ==
'&') {
111 const auto& ctype = std::use_facet<std::ctype<T>>(m_locale);
112 for (chr_end = start + 1;; chr_end++) {
113 if (chr_end >= end || text[chr_end] == 0) {
117 if (text[chr_end] ==
';') {
119 size_t n = chr_end - start - 1;
120 if (n >= 2 && text[start + 1] ==
'#') {
123 if (text[start + 2] ==
'x' || text[start + 2] ==
'X')
124 unicode = strtou32(text + start + 3, n - 2,
nullptr, 16);
126 unicode = strtou32(text + start + 2, n - 1,
nullptr, 10);
128 if (unicode < 0x10000) {
129 buf[0] = (wchar_t)unicode;
133 ucs4_to_surrogate_pair(buf, unicode);
137 buf[0] = (wchar_t)unicode;
143 const wchar_t* entity_w = sgml2uni(text + start + 1, n);
151 else if (text[chr_end] ==
'&' || ctype.is(ctype.space, text[chr_end])) {
157 buf[0] = text[start];
168 std::locale m_locale;
188 _In_reads_or_z_(end)
const T* text,
189 _In_
size_t start = 0,
190 _In_
size_t end = (
size_t)-1,
191 _In_
int flags = match_default)
193 assert(text || start >= end);
194 if (start < end && text[start]) {
222 _In_reads_or_z_(end)
const T* text,
223 _In_
size_t start = 0,
224 _In_
size_t end = (
size_t)-1,
225 _In_
int flags = match_default)
227 assert(text || start >= end);
228 if (start < end && text[start]) {
254 _In_reads_or_z_(end)
const char* text,
255 _In_
size_t start = 0,
256 _In_
size_t end = (
size_t)-1,
257 _In_
int flags = match_default)
259 assert(text || start >= end);
260 if (start < end && text[start]) {
261 if (text[start] ==
'&') {
263 const auto& ctype = std::use_facet<std::ctype<char>>(m_locale);
289 basic_cu(T chr,
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
296 _In_reads_or_z_(end)
const T* text,
297 _In_
size_t start = 0,
298 _In_
size_t end = (
size_t)-1,
299 _In_
int flags = match_default)
301 assert(text || start >= end);
302 if (start < end && text[start]) {
304 if (flags & match_case_insensitive) {
305 const auto& ctype = std::use_facet<std::ctype<T>>(m_locale);
306 r = ctype.tolower(text[start]) == ctype.tolower(m_chr);
309 r = text[start] == m_chr;
310 if (r && !m_invert || !r && m_invert) {
338 sgml_cp(
const char* chr,
size_t count = (
size_t)-1,
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
342 assert(chr || !count);
345 m_chr.assign(count ? next_sgml_cp(chr, 0, count, chr_end, buf) : L
"");
349 _In_reads_or_z_(end)
const char* text,
350 _In_
size_t start = 0,
351 _In_
size_t end = (
size_t)-1,
352 _In_
int flags = match_default)
354 assert(text || start >= end);
355 if (start < end && text[start]) {
357 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
358 bool r = ((flags & match_case_insensitive) ?
359 stdex::strnicmp(chr, (
size_t)-1, m_chr.c_str(), m_chr.size(), m_locale) :
360 stdex::strncmp(chr, (
size_t)-1, m_chr.c_str(), m_chr.size())) == 0;
361 if (r && !m_invert || !r && m_invert) {
382 basic_space_cu(
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
388 _In_reads_or_z_(end)
const T* text,
389 _In_
size_t start = 0,
390 _In_
size_t end = (
size_t)-1,
391 _In_
int flags = match_default)
393 assert(text || start >= end);
394 if (start < end && text[start]) {
396 ((flags & match_multiline) || !islbreak(text[start])) &&
397 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::space, text[start]);
398 if (r && !m_invert || !r && m_invert) {
425 sgml_space_cp(_In_
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
430 _In_reads_or_z_(end)
const char* text,
431 _In_
size_t start = 0,
432 _In_
size_t end = (
size_t)-1,
433 _In_
int flags = match_default)
435 assert(text || start >= end);
436 if (start < end && text[start]) {
438 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
439 const wchar_t* chr_end = chr + stdex::strlen(chr);
441 ((flags & match_multiline) || !islbreak(chr, (
size_t)-1)) &&
442 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::space, chr, chr_end) == chr_end;
443 if (r && !m_invert || !r && m_invert) {
461 basic_punct_cu(
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
467 _In_reads_or_z_(end)
const T* text,
468 _In_
size_t start = 0,
469 _In_
size_t end = (
size_t)-1,
470 _In_
int flags = match_default)
472 assert(text || start >= end);
473 if (start < end && text[start]) {
474 bool r = std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::punct, text[start]);
475 if (r && !m_invert || !r && m_invert) {
502 sgml_punct_cp(
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
507 _In_reads_or_z_(end)
const char* text,
508 _In_
size_t start = 0,
509 _In_
size_t end = (
size_t)-1,
510 _In_
int flags = match_default)
512 assert(text || start >= end);
513 if (start < end && text[start]) {
515 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
516 const wchar_t* chr_end = chr + stdex::strlen(chr);
517 bool r = std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::punct, chr, chr_end) == chr_end;
518 if (r && !m_invert || !r && m_invert) {
541 _In_reads_or_z_(end)
const T* text,
542 _In_
size_t start = 0,
543 _In_
size_t end = (
size_t)-1,
544 _In_
int flags = match_default)
546 assert(text || start >= end);
547 if (start < end && text[start]) {
549 ((flags & match_multiline) || !islbreak(text[start])) &&
550 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::space | std::ctype_base::punct, text[start]);
551 if (r && !m_invert || !r && m_invert) {
583 _In_reads_or_z_(end)
const char* text,
584 _In_
size_t start = 0,
585 _In_
size_t end = (
size_t)-1,
586 _In_
int flags = match_default)
588 assert(text || start >= end);
589 if (start < end && text[start]) {
591 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
592 const wchar_t* chr_end = chr + stdex::strlen(chr);
594 ((flags & match_multiline) || !islbreak(chr, (
size_t)-1)) &&
595 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::space | std::ctype_base::punct, chr, chr_end) == chr_end;
596 if (r && !m_invert || !r && m_invert) {
613 basic_bol(
bool invert =
false) : m_invert(invert) {}
616 _In_reads_or_z_(end)
const T* text,
617 _In_
size_t start = 0,
618 _In_
size_t end = (
size_t)-1,
619 _In_
int flags = match_default)
621 assert(text || start >= end);
622 bool r = start == 0 || start <= end && islbreak(text[start - 1]);
623 if (r && !m_invert || !r && m_invert) {
651 basic_eol(
bool invert =
false) : m_invert(invert) {}
654 _In_reads_or_z_(end)
const T* text,
655 _In_
size_t start = 0,
656 _In_
size_t end = (
size_t)-1,
657 _In_
int flags = match_default)
659 assert(text || start >= end);
660 bool r = islbreak(text[start]);
661 if (r && !m_invert || !r && m_invert) {
686 basic_set(
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
688 hit_offset((
size_t)-1),
693 _In_reads_or_z_(end)
const T* text,
694 _In_
size_t start = 0,
695 _In_
size_t end = (
size_t)-1,
696 _In_
int flags = match_default) = 0;
698 virtual void invalidate()
700 hit_offset = (size_t)-1;
719 _In_reads_or_z_(count)
const T* set,
720 _In_
size_t count = (
size_t)-1,
721 _In_
bool invert =
false,
722 _In_
const std::locale& locale = std::locale()) :
726 m_set.assign(set, set + stdex::strnlen(set, count));
730 _In_reads_or_z_(end)
const T* text,
731 _In_
size_t start = 0,
732 _In_
size_t end = (
size_t)-1,
733 _In_
int flags = match_default)
735 assert(text || start >= end);
736 if (start < end && text[start]) {
737 const T* set = m_set.c_str();
738 size_t r = (flags & match_case_insensitive) ?
739 stdex::strnichr(set, m_set.size(), text[start], m_locale) :
740 stdex::strnchr(set, m_set.size(), text[start]);
741 if (r != stdex::npos && !m_invert || r == stdex::npos && m_invert) {
747 hit_offset = (size_t)-1;
753 std::basic_string<T> m_set;
770 sgml_cp_set(
const char* set,
size_t count = (
size_t)-1,
bool invert =
false, _In_
const std::locale& locale = std::locale()) :
774 m_set = sgml2wstr(set, count);
778 _In_reads_or_z_(end)
const char* text,
779 _In_
size_t start = 0,
780 _In_
size_t end = (
size_t)-1,
781 _In_
int flags = match_default)
783 assert(text || start >= end);
784 if (start < end && text[start]) {
786 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
787 const wchar_t* set = m_set.c_str();
788 size_t r = (flags & match_case_insensitive) ?
789 stdex::strnistr(set, m_set.size(), chr, m_locale) :
790 stdex::strnstr(set, m_set.size(), chr);
791 if (r != stdex::npos && !m_invert || r == stdex::npos && m_invert) {
797 hit_offset = (size_t)-1;
814 _In_reads_or_z_(count)
const T* str,
815 _In_
size_t count = (
size_t)-1,
816 _In_
const std::locale& locale = std::locale()) :
818 m_str(str, str + stdex::strnlen(str, count))
822 _In_reads_or_z_(end)
const T* text,
823 _In_
size_t start = 0,
824 _In_
size_t end = (
size_t)-1,
825 _In_
int flags = match_default)
827 assert(text || start >= end);
830 n = std::min<size_t>(end - start, m);
831 bool r = ((flags & match_case_insensitive) ?
832 stdex::strnicmp(text + start, n, m_str.c_str(), m, m_locale) :
833 stdex::strncmp(text + start, n, m_str.c_str(), m)) == 0;
843 std::basic_string<T> m_str;
860 sgml_string(
const char* str,
size_t count = (
size_t)-1, _In_
const std::locale& locale = std::locale()) :
862 m_str(sgml2wstr(str, count))
866 _In_reads_or_z_(end)
const char* text,
867 _In_
size_t start = 0,
868 _In_
size_t end = (
size_t)-1,
869 _In_
int flags = match_default)
871 assert(text || start >= end);
872 const wchar_t* str = m_str.c_str();
873 const bool case_insensitive = flags & match_case_insensitive ? true :
false;
874 const auto& ctype = std::use_facet<std::ctype<wchar_t>>(m_locale);
886 for (; *chr; ++str, ++chr) {
888 (case_insensitive ? ctype.tolower(*str) != ctype.tolower(*chr) : *str != *chr))
916 _In_reads_or_z_(end)
const T* text,
917 _In_
size_t start = 0,
918 _In_
size_t end = (
size_t)-1,
919 _In_
int flags = match_default)
921 assert(text || start >= end);
923 for (
size_t i = 0; ; i++) {
942 std::shared_ptr<basic_parser<T>>
m_el;
970 _In_
const std::locale& locale = std::locale()) :
973 assert(el || !count);
974 m_collection.reserve(count);
975 for (
size_t i = 0; i < count; i++)
976 m_collection.push_back(el[i]);
981 _In_
const std::locale& locale = std::locale()) :
983 m_collection(std::move(collection))
986 virtual void invalidate()
988 for (
auto& el: m_collection)
994 std::vector<std::shared_ptr<basic_parser<T>>> m_collection;
1005 _In_count_(count)
const std::shared_ptr<
basic_parser<T>>* el =
nullptr,
1006 _In_
size_t count = 0,
1007 _In_
const std::locale& locale = std::locale()) :
1013 _In_
const std::locale& locale = std::locale()) :
1018 _In_reads_or_z_(end)
const T* text,
1019 _In_
size_t start = 0,
1020 _In_
size_t end = (
size_t)-1,
1021 _In_
int flags = match_default)
1023 assert(text || start >= end);
1025 for (
auto i = m_collection.begin(); i != m_collection.end(); ++i) {
1026 if (!(*i)->match(text,
interval.
end, end, flags)) {
1027 for (++i; i != m_collection.end(); ++i)
1057 hit_offset((
size_t)-1)
1062 _In_count_(count)
const std::shared_ptr<
basic_parser<T>>* el =
nullptr,
1063 _In_
size_t count = 0,
1064 _In_
const std::locale& locale = std::locale()) :
1066 hit_offset((
size_t)-1)
1071 _In_
const std::locale& locale = std::locale()) :
1073 hit_offset((
size_t)-1)
1077 _In_reads_or_z_(end)
const T* text,
1078 _In_
size_t start = 0,
1079 _In_
size_t end = (
size_t)-1,
1080 _In_
int flags = match_default)
1082 assert(text || start >= end);
1084 for (
auto i = m_collection.begin(); i != m_collection.end(); ++i, ++hit_offset) {
1085 if ((*i)->match(text, start, end, flags)) {
1087 for (++i; i != m_collection.end(); ++i)
1092 hit_offset = (size_t)-1;
1097 virtual void invalidate()
1099 hit_offset = (size_t)-1;
1119 template <
class T,
class T_parser = basic_
string<T>>
1124 _In_reads_(count)
const T* str_z =
nullptr,
1125 _In_
size_t count = 0,
1126 _In_
const std::locale& locale = std::locale()) :
1129 build(str_z, count);
1136 va_start(params, str);
1145 va_start(params, str);
1151 void build(_In_reads_(count)
const T* str_z, _In_
size_t count)
1153 assert(str_z || !count);
1158 offset < count && str_z[offset];
1159 offset += stdex::strnlen(str_z + offset, count - offset) + 1, ++n);
1160 m_collection.reserve(n);
1163 offset < count && str_z[offset];
1164 offset += stdex::strnlen(str_z + offset, count - offset) + 1)
1165 m_collection.push_back(std::move(std::make_shared<T_parser>(str_z + offset, count - offset, m_locale)));
1169 void build(_In_z_
const T* str, _In_ va_list params)
1173 m_collection.push_back(std::move(std::make_shared<T_parser>(str, (
size_t)-1, m_locale)));
1174 (p = va_arg(params,
const T*)) !=
nullptr;
1175 m_collection.push_back(std::move(std::make_shared<T_parser>(p, (
size_t)-1, m_locale))));
1196 _In_count_(count)
const std::shared_ptr<
basic_parser<T>>* el =
nullptr,
1197 _In_
size_t count = 0,
1198 _In_
const std::locale& locale = std::locale()) :
1204 _In_
const std::locale& locale = std::locale()) :
1209 _In_reads_or_z_(end)
const T* text,
1210 _In_
size_t start = 0,
1211 _In_
size_t end = (
size_t)-1,
1212 _In_
int flags = match_default)
1214 assert(text || start >= end);
1215 for (
auto& el: m_collection)
1217 if (match_recursively(text, start, end, flags)) {
1226 bool match_recursively(
1227 _In_reads_or_z_(end)
const T* text,
1228 _In_
size_t start = 0,
1229 _In_
size_t end = (
size_t)-1,
1230 _In_
int flags = match_default)
1232 bool all_matched =
true;
1233 for (
auto& el: m_collection) {
1234 if (!el->interval) {
1236 all_matched =
false;
1237 if (el->match(text, start, end, flags)) {
1239 if (match_recursively(text, el->interval.end, end, flags)) {
1271 basic_integer(_In_
const std::locale& locale = std::locale()) :
1276 virtual void invalidate()
1304 _In_
const std::locale& locale = std::locale()) :
1319 _In_reads_or_z_(end)
const T* text,
1320 _In_
size_t start = 0,
1321 _In_
size_t end = (
size_t)-1,
1322 _In_
int flags = match_default)
1324 assert(text || start >= end);
1327 if (m_digit_0->match(text,
interval.
end, end, flags)) { dig = 0;
interval.
end = m_digit_0->interval.end; }
1328 else if (m_digit_1->match(text,
interval.
end, end, flags)) { dig = 1;
interval.
end = m_digit_1->interval.end; }
1329 else if (m_digit_2->match(text,
interval.
end, end, flags)) { dig = 2;
interval.
end = m_digit_2->interval.end; }
1330 else if (m_digit_3->match(text,
interval.
end, end, flags)) { dig = 3;
interval.
end = m_digit_3->interval.end; }
1331 else if (m_digit_4->match(text,
interval.
end, end, flags)) { dig = 4;
interval.
end = m_digit_4->interval.end; }
1332 else if (m_digit_5->match(text,
interval.
end, end, flags)) { dig = 5;
interval.
end = m_digit_5->interval.end; }
1333 else if (m_digit_6->match(text,
interval.
end, end, flags)) { dig = 6;
interval.
end = m_digit_6->interval.end; }
1334 else if (m_digit_7->match(text,
interval.
end, end, flags)) { dig = 7;
interval.
end = m_digit_7->interval.end; }
1335 else if (m_digit_8->match(text,
interval.
end, end, flags)) { dig = 8;
interval.
end = m_digit_8->interval.end; }
1336 else if (m_digit_9->match(text,
interval.
end, end, flags)) { dig = 9;
interval.
end = m_digit_9->interval.end; }
1349 std::shared_ptr<basic_parser<T>>
1381 _In_
const std::locale& locale = std::locale()) :
1386 m_separator(separator)
1390 _In_reads_or_z_(end)
const T* text,
1391 _In_
size_t start = 0,
1392 _In_
size_t end = (
size_t)-1,
1393 _In_
int flags = match_default)
1395 assert(text || start >= end);
1396 if (m_digits->match(text, start, end, flags)) {
1398 value = m_digits->value;
1403 if (m_digits->interval.size() <= 3) {
1405 size_t hit_offset = (size_t)-1;
1406 while (m_separator->match(text,
interval.
end, end, flags) &&
1407 (hit_offset == (size_t)-1 || hit_offset == m_separator->hit_offset) &&
1408 m_digits->match(text, m_separator->interval.end, end, flags) &&
1409 m_digits->interval.size() == 3)
1416 hit_offset = m_separator->hit_offset;
1427 virtual void invalidate()
1439 std::shared_ptr<basic_integer10<T>> m_digits;
1440 std::shared_ptr<basic_set<T>> m_separator;
1476 _In_
const std::locale& locale = std::locale()) :
1488 m_digit_10(digit_10),
1489 m_digit_11(digit_11),
1490 m_digit_12(digit_12),
1491 m_digit_13(digit_13),
1492 m_digit_14(digit_14),
1493 m_digit_15(digit_15)
1497 _In_reads_or_z_(end)
const T* text,
1498 _In_
size_t start = 0,
1499 _In_
size_t end = (
size_t)-1,
1500 _In_
int flags = match_default)
1502 assert(text || start >= end);
1505 if (m_digit_0->match(text,
interval.
end, end, flags)) { dig = 0;
interval.
end = m_digit_0->interval.end; }
1506 else if (m_digit_1->match(text,
interval.
end, end, flags)) { dig = 1;
interval.
end = m_digit_1->interval.end; }
1507 else if (m_digit_2->match(text,
interval.
end, end, flags)) { dig = 2;
interval.
end = m_digit_2->interval.end; }
1508 else if (m_digit_3->match(text,
interval.
end, end, flags)) { dig = 3;
interval.
end = m_digit_3->interval.end; }
1509 else if (m_digit_4->match(text,
interval.
end, end, flags)) { dig = 4;
interval.
end = m_digit_4->interval.end; }
1510 else if (m_digit_5->match(text,
interval.
end, end, flags)) { dig = 5;
interval.
end = m_digit_5->interval.end; }
1511 else if (m_digit_6->match(text,
interval.
end, end, flags)) { dig = 6;
interval.
end = m_digit_6->interval.end; }
1512 else if (m_digit_7->match(text,
interval.
end, end, flags)) { dig = 7;
interval.
end = m_digit_7->interval.end; }
1513 else if (m_digit_8->match(text,
interval.
end, end, flags)) { dig = 8;
interval.
end = m_digit_8->interval.end; }
1514 else if (m_digit_9->match(text,
interval.
end, end, flags)) { dig = 9;
interval.
end = m_digit_9->interval.end; }
1515 else if (m_digit_10->match(text,
interval.
end, end, flags)) { dig = 10;
interval.
end = m_digit_10->interval.end; }
1516 else if (m_digit_11->match(text,
interval.
end, end, flags)) { dig = 11;
interval.
end = m_digit_11->interval.end; }
1517 else if (m_digit_12->match(text,
interval.
end, end, flags)) { dig = 12;
interval.
end = m_digit_12->interval.end; }
1518 else if (m_digit_13->match(text,
interval.
end, end, flags)) { dig = 13;
interval.
end = m_digit_13->interval.end; }
1519 else if (m_digit_14->match(text,
interval.
end, end, flags)) { dig = 14;
interval.
end = m_digit_14->interval.end; }
1520 else if (m_digit_15->match(text,
interval.
end, end, flags)) { dig = 15;
interval.
end = m_digit_15->interval.end; }
1533 std::shared_ptr<basic_parser<T>>
1578 _In_
const std::locale& locale = std::locale()) :
1582 m_digit_10(digit_10),
1583 m_digit_50(digit_50),
1584 m_digit_100(digit_100),
1585 m_digit_500(digit_500),
1586 m_digit_1000(digit_1000),
1587 m_digit_5000(digit_5000),
1588 m_digit_10000(digit_10000)
1592 _In_reads_or_z_(end)
const T* text,
1593 _In_
size_t start = 0,
1594 _In_
size_t end = (
size_t)-1,
1595 _In_
int flags = match_default)
1597 assert(text || start >= end);
1599 dig[5] = { (size_t)-1, (
size_t)-1, (size_t)-1, (
size_t)-1, (size_t)-1 },
1603 if (m_digit_1 && m_digit_1->match(text,
interval.
end, end, flags)) { dig[0] = 1; end2 = m_digit_1->interval.end; }
1604 else if (m_digit_5 && m_digit_5->match(text,
interval.
end, end, flags)) { dig[0] = 5; end2 = m_digit_5->interval.end; }
1605 else if (m_digit_10 && m_digit_10->match(text,
interval.
end, end, flags)) { dig[0] = 10; end2 = m_digit_10->interval.end; }
1606 else if (m_digit_50 && m_digit_50->match(text,
interval.
end, end, flags)) { dig[0] = 50; end2 = m_digit_50->interval.end; }
1607 else if (m_digit_100 && m_digit_100->match(text,
interval.
end, end, flags)) { dig[0] = 100; end2 = m_digit_100->interval.end; }
1608 else if (m_digit_500 && m_digit_500->match(text,
interval.
end, end, flags)) { dig[0] = 500; end2 = m_digit_500->interval.end; }
1609 else if (m_digit_1000 && m_digit_1000->match(text,
interval.
end, end, flags)) { dig[0] = 1000; end2 = m_digit_1000->interval.end; }
1610 else if (m_digit_5000 && m_digit_5000->match(text,
interval.
end, end, flags)) { dig[0] = 5000; end2 = m_digit_5000->interval.end; }
1611 else if (m_digit_10000 && m_digit_10000->match(text,
interval.
end, end, flags)) { dig[0] = 10000; end2 = m_digit_10000->interval.end; }
1615 if (dig[4] == (
size_t)-1) dig[4] = dig[0];
1617 if (dig[3] == dig[2] && dig[2] == dig[1] && dig[1] == dig[0] && dig[0] != dig[4]) {
1621 if (dig[0] <= dig[1]) {
1626 dig[1] == 1 && (dig[0] == 5 || dig[0] == 10) ||
1627 dig[1] == 10 && (dig[0] == 50 || dig[0] == 100) ||
1628 dig[1] == 100 && (dig[0] == 500 || dig[0] == 1000) ||
1629 dig[1] == 1000 && (dig[0] == 5000 || dig[0] == 10000))
1632 if (dig[2] < dig[0]) {
1656 std::shared_ptr<basic_parser<T>>
1688 _In_
const std::locale& locale = std::locale()) :
1690 numerator(_numerator),
1691 fraction_line(_fraction_line),
1692 denominator(_denominator)
1696 _In_reads_or_z_(end)
const T* text,
1697 _In_
size_t start = 0,
1698 _In_
size_t end = (
size_t)-1,
1699 _In_
int flags = match_default)
1701 assert(text || start >= end);
1702 if (numerator->match(text, start, end, flags) &&
1703 fraction_line->match(text, numerator->interval.end, end, flags) &&
1704 denominator->match(text, fraction_line->interval.end, end, flags))
1710 numerator->invalidate();
1711 fraction_line->invalidate();
1712 denominator->invalidate();
1717 virtual void invalidate()
1719 numerator->invalidate();
1720 fraction_line->invalidate();
1721 denominator->invalidate();
1726 std::shared_ptr<basic_parser<T>> numerator;
1727 std::shared_ptr<basic_parser<T>> fraction_line;
1728 std::shared_ptr<basic_parser<T>> denominator;
1752 _In_
const std::locale& locale = std::locale()) :
1755 separator(_separator),
1761 _In_reads_or_z_(end)
const T* text,
1762 _In_
size_t start = 0,
1763 _In_
size_t end = (
size_t)-1,
1764 _In_
int flags = match_default)
1766 assert(text || start >= end);
1774 const int space_match_flags = flags & ~match_multiline;
1775 for (; m_space->match(text,
interval.
end, end, space_match_flags);
interval.
end = m_space->interval.end);
1777 if (separator->match(text,
interval.
end, end, flags))
1782 for (; m_space->match(text,
interval.
end, end, space_match_flags);
interval.
end = m_space->interval.end);
1794 separator->invalidate();
1795 guest->invalidate();
1800 virtual void invalidate()
1803 separator->invalidate();
1804 guest->invalidate();
1809 std::shared_ptr<basic_parser<T>> home;
1810 std::shared_ptr<basic_parser<T>> separator;
1811 std::shared_ptr<basic_parser<T>> guest;
1814 std::shared_ptr<basic_parser<T>> m_space;
1838 _In_
const std::locale& locale = std::locale()) :
1847 _In_reads_or_z_(end)
const T* text,
1848 _In_
size_t start = 0,
1849 _In_
size_t end = (
size_t)-1,
1850 _In_
int flags = match_default)
1852 assert(text || start >= end);
1887 virtual void invalidate()
1926 _In_
const std::locale& locale = std::locale()) :
1937 _In_reads_or_z_(end)
const T* text,
1938 _In_
size_t start = 0,
1939 _In_
size_t end = (
size_t)-1,
1940 _In_
int flags = match_default)
1942 assert(text || start >= end);
1967 const int space_match_flags = flags & ~match_multiline;
1969 m_space->match(text,
integer->interval.end, end, space_match_flags))
2008 virtual void invalidate()
2026 std::shared_ptr<basic_parser<T>> m_space;
2056 _In_
const std::locale& locale = std::locale()) :
2068 value(std::numeric_limits<double>::quiet_NaN())
2072 _In_reads_or_z_(end)
const T* text,
2073 _In_
size_t start = 0,
2074 _In_
size_t end = (
size_t)-1,
2075 _In_
int flags = match_default)
2077 assert(text || start >= end);
2112 if (
integer->interval.empty() &&
2158 double e = (double)
exponent->value;
2161 value *= pow(10.0, e);
2168 virtual void invalidate()
2180 value = std::numeric_limits<double>::quiet_NaN();
2222 _In_
const std::locale& locale = std::locale()) :
2234 _In_reads_or_z_(end)
const T* text,
2235 _In_
size_t start = 0,
2236 _In_
size_t end = (
size_t)-1,
2237 _In_
int flags = match_default)
2239 assert(text || start >= end);
2286 if (
integer->interval.empty() &&
2305 virtual void invalidate()
2355 _In_
const std::locale& locale = std::locale()) :
2367 m_separator(separator)
2373 _In_reads_or_z_(end)
const T* text,
2374 _In_
size_t start = 0,
2375 _In_
size_t end = (
size_t)-1,
2376 _In_
int flags = match_default)
2378 assert(text || start >= end);
2383 for (i = 0; i < 4; i++) {
2385 if (m_separator->match(text,
interval.
end, end, flags))
2392 bool is_empty =
true;
2395 size_t dig, digit_end;
2396 if (m_digit_0->match(text,
interval.
end, end, flags)) { dig = 0; digit_end = m_digit_0->interval.end; }
2397 else if (m_digit_1->match(text,
interval.
end, end, flags)) { dig = 1; digit_end = m_digit_1->interval.end; }
2398 else if (m_digit_2->match(text,
interval.
end, end, flags)) { dig = 2; digit_end = m_digit_2->interval.end; }
2399 else if (m_digit_3->match(text,
interval.
end, end, flags)) { dig = 3; digit_end = m_digit_3->interval.end; }
2400 else if (m_digit_4->match(text,
interval.
end, end, flags)) { dig = 4; digit_end = m_digit_4->interval.end; }
2401 else if (m_digit_5->match(text,
interval.
end, end, flags)) { dig = 5; digit_end = m_digit_5->interval.end; }
2402 else if (m_digit_6->match(text,
interval.
end, end, flags)) { dig = 6; digit_end = m_digit_6->interval.end; }
2403 else if (m_digit_7->match(text,
interval.
end, end, flags)) { dig = 7; digit_end = m_digit_7->interval.end; }
2404 else if (m_digit_8->match(text,
interval.
end, end, flags)) { dig = 8; digit_end = m_digit_8->interval.end; }
2405 else if (m_digit_9->match(text,
interval.
end, end, flags)) { dig = 9; digit_end = m_digit_9->interval.end; }
2407 size_t x_n = x * 10 + dig;
2419 value.s_addr = (
value.s_addr << 8) | (uint8_t)x;
2441 virtual void invalidate()
2460 std::shared_ptr<basic_parser<T>>
2471 std::shared_ptr<basic_parser<T>> m_separator;
2493 _In_reads_or_z_(end)
const T* text,
2494 _In_
size_t start = 0,
2495 _In_
size_t end = (
size_t)-1,
2496 _In_
int flags = match_default)
2498 assert(text || start >= end);
2499 if (start < end && text[start]) {
2500 if (text[start] ==
'-' ||
2501 text[start] ==
'_' ||
2502 text[start] ==
':' ||
2503 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
2531 _In_reads_or_z_(end)
const char* text,
2532 _In_
size_t start = 0,
2533 _In_
size_t end = (
size_t)-1,
2534 _In_
int flags = match_default)
2536 assert(text || start >= end);
2537 if (start < end && text[start]) {
2539 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
2540 const wchar_t* chr_end = chr + stdex::strlen(chr);
2541 if ((chr[0] == L
'-' ||
2543 chr[0] == L
':') && chr[1] == 0 ||
2544 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
2580 _In_
const std::shared_ptr<
basic_parser<T>>& scope_id_separator =
nullptr,
2582 _In_
const std::locale& locale = std::locale()) :
2594 m_digit_10(digit_10),
2595 m_digit_11(digit_11),
2596 m_digit_12(digit_12),
2597 m_digit_13(digit_13),
2598 m_digit_14(digit_14),
2599 m_digit_15(digit_15),
2600 m_separator(separator),
2601 m_scope_id_separator(scope_id_separator),
2608 _In_reads_or_z_(end)
const T* text,
2609 _In_
size_t start = 0,
2610 _In_
size_t end = (
size_t)-1,
2611 _In_
int flags = match_default)
2613 assert(text || start >= end);
2617 size_t i, compaction_i = (size_t)-1, compaction_start = start;
2618 for (i = 0; i < 8; i++) {
2619 bool is_empty =
true;
2621 if (m_separator->match(text,
interval.
end, end, flags)) {
2622 if (m_separator->match(text, m_separator->interval.end, end, flags)) {
2624 if (compaction_i == (
size_t)-1) {
2627 compaction_start = m_separator->interval.start;
2652 size_t dig, digit_end;
2653 if (m_digit_0->match(text,
interval.
end, end, flags)) { dig = 0; digit_end = m_digit_0->interval.end; }
2654 else if (m_digit_1->match(text,
interval.
end, end, flags)) { dig = 1; digit_end = m_digit_1->interval.end; }
2655 else if (m_digit_2->match(text,
interval.
end, end, flags)) { dig = 2; digit_end = m_digit_2->interval.end; }
2656 else if (m_digit_3->match(text,
interval.
end, end, flags)) { dig = 3; digit_end = m_digit_3->interval.end; }
2657 else if (m_digit_4->match(text,
interval.
end, end, flags)) { dig = 4; digit_end = m_digit_4->interval.end; }
2658 else if (m_digit_5->match(text,
interval.
end, end, flags)) { dig = 5; digit_end = m_digit_5->interval.end; }
2659 else if (m_digit_6->match(text,
interval.
end, end, flags)) { dig = 6; digit_end = m_digit_6->interval.end; }
2660 else if (m_digit_7->match(text,
interval.
end, end, flags)) { dig = 7; digit_end = m_digit_7->interval.end; }
2661 else if (m_digit_8->match(text,
interval.
end, end, flags)) { dig = 8; digit_end = m_digit_8->interval.end; }
2662 else if (m_digit_9->match(text,
interval.
end, end, flags)) { dig = 9; digit_end = m_digit_9->interval.end; }
2663 else if (m_digit_10->match(text,
interval.
end, end, flags)) { dig = 10; digit_end = m_digit_10->interval.end; }
2664 else if (m_digit_11->match(text,
interval.
end, end, flags)) { dig = 11; digit_end = m_digit_11->interval.end; }
2665 else if (m_digit_12->match(text,
interval.
end, end, flags)) { dig = 12; digit_end = m_digit_12->interval.end; }
2666 else if (m_digit_13->match(text,
interval.
end, end, flags)) { dig = 13; digit_end = m_digit_13->interval.end; }
2667 else if (m_digit_14->match(text,
interval.
end, end, flags)) { dig = 14; digit_end = m_digit_14->interval.end; }
2668 else if (m_digit_15->match(text,
interval.
end, end, flags)) { dig = 15; digit_end = m_digit_15->interval.end; }
2670 size_t x_n = x * 16 + dig;
2671 if (x_n <= 0xffff) {
2680 if (compaction_i != (
size_t)-1) {
2687 value.s6_words[i] = (uint16_t)x;
2690 if (compaction_i != (
size_t)-1) {
2693 for (j = 8, k = i; k > compaction_i;) {
2697 for (; j > compaction_i;) {
2698 value.s6_words[--j] = 0;
2706 if (m_scope_id_separator && m_scope_id_separator->match(text,
interval.
end, end, flags) &&
2707 scope_id &&
scope_id->match(text, m_scope_id_separator->interval.end, end, flags))
2738 virtual void invalidate()
2767 std::shared_ptr<basic_parser<T>>
2784 std::shared_ptr<basic_parser<T>> m_separator, m_scope_id_separator;
2804 _In_
bool allow_idn,
2805 _In_
const std::locale& locale = std::locale()) :
2807 m_allow_idn(allow_idn),
2812 _In_reads_or_z_(end)
const T* text,
2813 _In_
size_t start = 0,
2814 _In_
size_t end = (
size_t)-1,
2815 _In_
int flags = match_default)
2817 assert(text || start >= end);
2818 if (start < end && text[start]) {
2819 if ((
'A' <= text[start] && text[start] <=
'Z') ||
2820 (
'a' <= text[start] && text[start] <=
'z') ||
2821 (
'0' <= text[start] && text[start] <=
'9'))
2823 else if (text[start] ==
'-')
2825 else if (m_allow_idn && std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
2860 _In_
bool allow_idn,
2861 _In_
const std::locale& locale = std::locale()) :
2866 _In_reads_or_z_(end)
const char* text,
2867 _In_
size_t start = 0,
2868 _In_
size_t end = (
size_t)-1,
2869 _In_
int flags = match_default)
2871 assert(text || start >= end);
2872 if (start < end && text[start]) {
2874 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
2875 const wchar_t* chr_end = chr + stdex::strlen(chr);
2876 if (((
'A' <= chr[0] && chr[0] <=
'Z') ||
2877 (
'a' <= chr[0] && chr[0] <=
'z') ||
2878 (
'0' <= chr[0] && chr[0] <=
'9')) && chr[1] == 0)
2880 else if (chr[0] ==
'-' && chr[1] == 0)
2882 else if (m_allow_idn && std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
2904 _In_
bool allow_absolute,
2907 _In_
const std::locale& locale = std::locale()) :
2910 m_domain_char(domain_char),
2911 m_separator(separator)
2915 _In_reads_or_z_(end)
const T* text,
2916 _In_
size_t start = 0,
2917 _In_
size_t end = (
size_t)-1,
2918 _In_
int flags = match_default)
2920 assert(text || start >= end);
2921 size_t i = start, count;
2922 for (count = 0; i < end && text[i] && count < 127; count++) {
2923 if (m_domain_char->match(text, i, end, flags) &&
2924 m_domain_char->allow_on_edge)
2928 while (i < end && text[i]) {
2929 if (m_domain_char->allow_on_edge &&
2930 m_separator->match(text, i, end, flags))
2937 i = m_separator->interval.end;
2941 if (m_domain_char->match(text, i, end, flags)) {
2942 if (m_domain_char->allow_on_edge)
2945 i = m_domain_char->interval.end;
2966 std::shared_ptr<basic_dns_domain_char<T>> m_domain_char;
2967 std::shared_ptr<basic_parser<T>> m_separator;
2989 _In_reads_or_z_(end)
const T* text,
2990 _In_
size_t start = 0,
2991 _In_
size_t end = (
size_t)-1,
2992 _In_
int flags = match_default)
2994 assert(text || start >= end);
2995 if (start < end && text[start]) {
2996 if (text[start] ==
'-' ||
2997 text[start] ==
'.' ||
2998 text[start] ==
'_' ||
2999 text[start] ==
'~' ||
3000 text[start] ==
'%' ||
3001 text[start] ==
'!' ||
3002 text[start] ==
'$' ||
3003 text[start] ==
'&' ||
3004 text[start] ==
'\'' ||
3007 text[start] ==
'*' ||
3008 text[start] ==
'+' ||
3009 text[start] ==
',' ||
3010 text[start] ==
';' ||
3011 text[start] ==
'=' ||
3012 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
3040 _In_reads_or_z_(end)
const char* text,
3041 _In_
size_t start = 0,
3042 _In_
size_t end = (
size_t)-1,
3043 _In_
int flags = match_default)
3045 assert(text || start >= end);
3046 if (start < end && text[start]) {
3048 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
3049 const wchar_t* chr_end = chr + stdex::strlen(chr);
3050 if ((chr[0] == L
'-' ||
3065 chr[0] == L
'=') && chr[1] == 0 ||
3066 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
3088 _In_reads_or_z_(end)
const T* text,
3089 _In_
size_t start = 0,
3090 _In_
size_t end = (
size_t)-1,
3091 _In_
int flags = match_default)
3093 assert(text || start >= end);
3094 if (start < end && text[start]) {
3095 if (text[start] ==
'-' ||
3096 text[start] ==
'.' ||
3097 text[start] ==
'_' ||
3098 text[start] ==
'~' ||
3099 text[start] ==
'%' ||
3100 text[start] ==
'!' ||
3101 text[start] ==
'$' ||
3102 text[start] ==
'&' ||
3103 text[start] ==
'\'' ||
3104 text[start] ==
'(' ||
3105 text[start] ==
')' ||
3106 text[start] ==
'*' ||
3107 text[start] ==
'+' ||
3108 text[start] ==
',' ||
3109 text[start] ==
';' ||
3110 text[start] ==
'=' ||
3111 text[start] ==
':' ||
3112 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
3140 _In_reads_or_z_(end)
const char* text,
3141 _In_
size_t start = 0,
3142 _In_
size_t end = (
size_t)-1,
3143 _In_
int flags = match_default)
3145 assert(text || start >= end);
3146 if (start < end && text[start]) {
3148 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
3149 const wchar_t* chr_end = chr + stdex::strlen(chr);
3150 if ((chr[0] == L
'-' ||
3166 chr[0] == L
':') && chr[1] == 0 ||
3167 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
3188 _In_reads_or_z_(end)
const T* text,
3189 _In_
size_t start = 0,
3190 _In_
size_t end = (
size_t)-1,
3191 _In_
int flags = match_default)
3193 assert(text || start >= end);
3194 if (start < end && text[start]) {
3195 if (text[start] ==
'/' ||
3196 text[start] ==
'-' ||
3197 text[start] ==
'.' ||
3198 text[start] ==
'_' ||
3199 text[start] ==
'~' ||
3200 text[start] ==
'%' ||
3201 text[start] ==
'!' ||
3202 text[start] ==
'$' ||
3203 text[start] ==
'&' ||
3204 text[start] ==
'\'' ||
3205 text[start] ==
'(' ||
3206 text[start] ==
')' ||
3207 text[start] ==
'*' ||
3208 text[start] ==
'+' ||
3209 text[start] ==
',' ||
3210 text[start] ==
';' ||
3211 text[start] ==
'=' ||
3212 text[start] ==
':' ||
3213 text[start] ==
'@' ||
3214 text[start] ==
'?' ||
3215 text[start] ==
'#' ||
3216 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
3244 _In_reads_or_z_(end)
const char* text,
3245 _In_
size_t start = 0,
3246 _In_
size_t end = (
size_t)-1,
3247 _In_
int flags = match_default)
3249 assert(text || start >= end);
3250 if (start < end && text[start]) {
3252 const wchar_t* chr = next_sgml_cp(text, start, end,
interval.
end, buf);
3253 const wchar_t* chr_end = chr + stdex::strlen(chr);
3254 if ((chr[0] == L
'/' ||
3274 chr[0] == L
'#') && chr[1] == 0 ||
3275 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
3297 _In_
const std::locale& locale = std::locale()) :
3299 m_path_char(path_char),
3300 m_query_start(query_start),
3301 m_bookmark_start(bookmark_start)
3305 _In_reads_or_z_(end)
const T* text,
3306 _In_
size_t start = 0,
3307 _In_
size_t end = (
size_t)-1,
3308 _In_
int flags = match_default)
3310 assert(text || start >= end);
3322 if (m_query_start->match(text,
interval.
end, end, flags)) {
3330 if (m_bookmark_start->match(text,
interval.
end, end, flags)) {
3338 if (m_path_char->match(text,
interval.
end, end, flags))
3348 if (m_path_char->match(text,
interval.
end, end, flags))
3358 if (m_bookmark_start->match(text,
interval.
end, end, flags)) {
3366 if (m_path_char->match(text,
interval.
end, end, flags))
3376 if (m_path_char->match(text,
interval.
end, end, flags))
3396 virtual void invalidate()
3413 std::shared_ptr<basic_parser<T>> m_path_char;
3414 std::shared_ptr<basic_parser<T>> m_query_start;
3415 std::shared_ptr<basic_parser<T>> m_bookmark_start;
3451 _In_
const std::locale& locale = std::locale()) :
3453 http_scheme(_http_scheme),
3454 ftp_scheme(_ftp_scheme),
3455 mailto_scheme(_mailto_scheme),
3456 file_scheme(_file_scheme),
3459 username(_username),
3460 password(_password),
3462 m_ip_lbracket(ip_lbracket),
3463 m_ip_rbracket(ip_rbracket),
3464 ipv4_host(_ipv4_host),
3465 ipv6_host(_ipv6_host),
3466 dns_host(_dns_host),
3472 _In_reads_or_z_(end)
const T* text,
3473 _In_
size_t start = 0,
3474 _In_
size_t end = (
size_t)-1,
3475 _In_
int flags = match_default)
3477 assert(text || start >= end);
3481 if (http_scheme->match(text,
interval.
end, end, flags) &&
3482 m_colon->match(text, http_scheme->interval.end, end, flags) &&
3483 m_slash->match(text, m_colon->interval.end, end, flags) &&
3484 m_slash->match(text, m_slash->interval.end, end, flags))
3488 ftp_scheme->invalidate();
3489 mailto_scheme->invalidate();
3490 file_scheme->invalidate();
3492 else if (ftp_scheme->match(text,
interval.
end, end, flags) &&
3493 m_colon->match(text, ftp_scheme->interval.end, end, flags) &&
3494 m_slash->match(text, m_colon->interval.end, end, flags) &&
3495 m_slash->match(text, m_slash->interval.end, end, flags))
3499 http_scheme->invalidate();
3500 mailto_scheme->invalidate();
3501 file_scheme->invalidate();
3503 else if (mailto_scheme->match(text,
interval.
end, end, flags) &&
3504 m_colon->match(text, mailto_scheme->interval.end, end, flags))
3508 http_scheme->invalidate();
3509 ftp_scheme->invalidate();
3510 file_scheme->invalidate();
3512 else if (file_scheme->match(text,
interval.
end, end, flags) &&
3513 m_colon->match(text, file_scheme->interval.end, end, flags) &&
3514 m_slash->match(text, m_colon->interval.end, end, flags) &&
3515 m_slash->match(text, m_slash->interval.end, end, flags))
3519 http_scheme->invalidate();
3520 ftp_scheme->invalidate();
3521 mailto_scheme->invalidate();
3525 http_scheme->invalidate();
3526 ftp_scheme->invalidate();
3527 mailto_scheme->invalidate();
3528 file_scheme->invalidate();
3531 if (ftp_scheme->interval) {
3532 if (username->match(text,
interval.
end, end, flags)) {
3533 if (m_colon->match(text, username->interval.end, end, flags) &&
3534 password->match(text, m_colon->interval.end, end, flags) &&
3535 m_at->match(text, password->interval.end, end, flags))
3540 else if (m_at->match(text,
interval.
end, end, flags)) {
3543 password->invalidate();
3546 username->invalidate();
3547 password->invalidate();
3551 username->invalidate();
3552 password->invalidate();
3555 if (ipv4_host->match(text,
interval.
end, end, flags)) {
3558 ipv6_host->invalidate();
3559 dns_host->invalidate();
3562 m_ip_lbracket->match(text,
interval.
end, end, flags) &&
3563 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
3564 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3568 ipv4_host->invalidate();
3569 dns_host->invalidate();
3571 else if (dns_host->match(text,
interval.
end, end, flags)) {
3574 ipv4_host->invalidate();
3575 ipv6_host->invalidate();
3582 if (m_colon->match(text,
interval.
end, end, flags) &&
3583 port->match(text, m_colon->interval.end, end, flags))
3591 if (path->match(text,
interval.
end, end, flags)) {
3600 if (mailto_scheme->interval) {
3601 if (username->match(text,
interval.
end, end, flags) &&
3602 m_at->match(text, username->interval.end, end, flags))
3612 if (m_ip_lbracket->match(text,
interval.
end, end, flags) &&
3613 ipv4_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
3614 m_ip_rbracket->match(text, ipv4_host->interval.end, end, flags))
3618 ipv6_host->invalidate();
3619 dns_host->invalidate();
3622 m_ip_lbracket->match(text,
interval.
end, end, flags) &&
3623 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
3624 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3628 ipv4_host->invalidate();
3629 dns_host->invalidate();
3631 else if (dns_host->match(text,
interval.
end, end, flags)) {
3634 ipv4_host->invalidate();
3635 ipv6_host->invalidate();
3642 password->invalidate();
3649 if (file_scheme->interval) {
3650 if (path->match(text,
interval.
end, end, flags)) {
3655 username->invalidate();
3656 password->invalidate();
3657 ipv4_host->invalidate();
3658 ipv6_host->invalidate();
3659 dns_host->invalidate();
3668 if (http_scheme->interval &&
3671 if (m_colon->match(text, username->interval.end, end, flags) &&
3672 password->match(text, m_colon->interval.end, end, flags) &&
3673 m_at->match(text, password->interval.end, end, flags))
3678 else if (m_at->match(text, username->interval.end, end, flags)) {
3681 password->invalidate();
3684 username->invalidate();
3685 password->invalidate();
3689 username->invalidate();
3690 password->invalidate();
3693 if (ipv4_host->match(text,
interval.
end, end, flags)) {
3696 ipv6_host->invalidate();
3697 dns_host->invalidate();
3700 m_ip_lbracket->match(text,
interval.
end, end, flags) &&
3701 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
3702 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3706 ipv4_host->invalidate();
3707 dns_host->invalidate();
3709 else if (dns_host->match(text,
interval.
end, end, flags)) {
3712 ipv4_host->invalidate();
3713 ipv6_host->invalidate();
3720 if (m_colon->match(text,
interval.
end, end, flags) &&
3721 port->match(text, m_colon->interval.end, end, flags))
3729 if (path->match(text,
interval.
end, end, flags)) {
3738 virtual void invalidate()
3740 http_scheme->invalidate();
3741 ftp_scheme->invalidate();
3742 mailto_scheme->invalidate();
3743 file_scheme->invalidate();
3744 username->invalidate();
3745 password->invalidate();
3746 ipv4_host->invalidate();
3747 ipv6_host->invalidate();
3748 dns_host->invalidate();
3755 std::shared_ptr<basic_parser<T>> http_scheme;
3756 std::shared_ptr<basic_parser<T>> ftp_scheme;
3757 std::shared_ptr<basic_parser<T>> mailto_scheme;
3758 std::shared_ptr<basic_parser<T>> file_scheme;
3759 std::shared_ptr<basic_parser<T>> username;
3760 std::shared_ptr<basic_parser<T>> password;
3761 std::shared_ptr<basic_parser<T>> ipv4_host;
3762 std::shared_ptr<basic_parser<T>> ipv6_host;
3763 std::shared_ptr<basic_parser<T>> dns_host;
3764 std::shared_ptr<basic_parser<T>> port;
3765 std::shared_ptr<basic_parser<T>> path;
3768 std::shared_ptr<basic_parser<T>> m_colon;
3769 std::shared_ptr<basic_parser<T>> m_slash;
3770 std::shared_ptr<basic_parser<T>> m_at;
3771 std::shared_ptr<basic_parser<T>> m_ip_lbracket;
3772 std::shared_ptr<basic_parser<T>> m_ip_rbracket;
3799 _In_
const std::locale& locale = std::locale()) :
3801 username(_username),
3803 m_ip_lbracket(ip_lbracket),
3804 m_ip_rbracket(ip_rbracket),
3805 ipv4_host(_ipv4_host),
3806 ipv6_host(_ipv6_host),
3811 _In_reads_or_z_(end)
const T* text,
3812 _In_
size_t start = 0,
3813 _In_
size_t end = (
size_t)-1,
3814 _In_
int flags = match_default)
3816 assert(text || start >= end);
3818 if (username->match(text, start, end, flags) &&
3819 m_at->match(text, username->interval.end, end, flags))
3822 if (m_ip_lbracket->match(text, m_at->interval.end, end, flags) &&
3823 ipv4_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
3824 m_ip_rbracket->match(text, ipv4_host->interval.end, end, flags))
3828 ipv6_host->invalidate();
3829 dns_host->invalidate();
3832 m_ip_lbracket->match(text, m_at->interval.end, end, flags) &&
3833 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
3834 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3838 ipv4_host->invalidate();
3839 dns_host->invalidate();
3841 else if (dns_host->match(text, m_at->interval.end, end, flags)) {
3844 ipv4_host->invalidate();
3845 ipv6_host->invalidate();
3854 username->invalidate();
3855 ipv4_host->invalidate();
3856 ipv6_host->invalidate();
3857 dns_host->invalidate();
3862 virtual void invalidate()
3864 username->invalidate();
3865 ipv4_host->invalidate();
3866 ipv6_host->invalidate();
3867 dns_host->invalidate();
3872 std::shared_ptr<basic_parser<T>> username;
3873 std::shared_ptr<basic_parser<T>> ipv4_host;
3874 std::shared_ptr<basic_parser<T>> ipv6_host;
3875 std::shared_ptr<basic_parser<T>> dns_host;
3878 std::shared_ptr<basic_parser<T>> m_at;
3879 std::shared_ptr<basic_parser<T>> m_ip_lbracket;
3880 std::shared_ptr<basic_parser<T>> m_ip_rbracket;
3905 _In_
const std::locale& locale = std::locale()) :
3915 _In_reads_or_z_(end)
const T* text,
3916 _In_
size_t start = 0,
3917 _In_
size_t end = (
size_t)-1,
3918 _In_
int flags = match_default)
3920 assert(text || start >= end);
3926 mouth->invalidate();
3938 if (
nose &&
nose->match(text,
eyes->interval.end, end, flags) &&
3939 mouth->match(text,
nose->interval.end, end, flags))
3942 start_mouth =
mouth->interval.start,
3943 hit_offset =
mouth->hit_offset;
3946 mouth->interval.start = start_mouth;
3951 if (
mouth->match(text,
eyes->interval.end, end, flags)) {
3953 start_mouth =
mouth->interval.start,
3954 hit_offset =
mouth->hit_offset;
3958 mouth->interval.start = start_mouth;
3969 mouth->invalidate();
3974 virtual void invalidate()
3980 mouth->invalidate();
3986 std::shared_ptr<basic_parser<T>>
apex;
3987 std::shared_ptr<basic_parser<T>>
eyes;
3988 std::shared_ptr<basic_parser<T>>
nose;
4004 ENUM_FLAGS(date_format_t,
int) {
4023 _In_
int format_mask,
4029 _In_
const std::locale& locale = std::locale()) :
4031 format(date_format_t::none),
4032 m_format_mask(format_mask),
4036 m_separator(separator),
4041 _In_reads_or_z_(end)
const T* text,
4042 _In_
size_t start = 0,
4043 _In_
size_t end = (
size_t)-1,
4044 _In_
int flags = match_default)
4046 assert(text || start >= end);
4048 const int space_match_flags = flags & ~match_multiline;
4049 if ((m_format_mask & date_format_t::dmy) == date_format_t::dmy) {
4050 if (day->match(text, start, end, flags)) {
4052 if (m_separator->match(text,
interval.
end, end, flags)) {
4053 size_t hit_offset = m_separator->hit_offset;
4055 if (month->match(text,
interval.
end, end, flags)) {
4057 if (m_separator->match(text,
interval.
end, end, flags) &&
4058 m_separator->hit_offset == hit_offset)
4061 if (year->match(text,
interval.
end, end, flags) &&
4062 is_valid(day->value, month->value))
4066 format = date_format_t::dmy;
4075 if ((m_format_mask & date_format_t::mdy) == date_format_t::mdy) {
4076 if (month->match(text, start, end, flags)) {
4078 if (m_separator->match(text,
interval.
end, end, flags)) {
4079 size_t hit_offset = m_separator->hit_offset;
4083 if (m_separator->match(text,
interval.
end, end, flags) &&
4084 m_separator->hit_offset == hit_offset)
4087 if (year->match(text,
interval.
end, end, flags) &&
4088 is_valid(day->value, month->value))
4092 format = date_format_t::mdy;
4101 if ((m_format_mask & date_format_t::ymd) == date_format_t::ymd) {
4102 if (year->match(text, start, end, flags)) {
4104 if (m_separator->match(text,
interval.
end, end, flags)) {
4105 size_t hit_offset = m_separator->hit_offset;
4107 if (month->match(text,
interval.
end, end, flags)) {
4109 if (m_separator->match(text,
interval.
end, end, flags) &&
4110 m_separator->hit_offset == hit_offset)
4114 is_valid(day->value, month->value))
4118 format = date_format_t::ymd;
4127 if ((m_format_mask & date_format_t::ym) == date_format_t::ym) {
4128 if (year->match(text, start, end, flags)) {
4130 if (m_separator->match(text,
interval.
end, end, flags)) {
4132 if (month->match(text,
interval.
end, end, flags) &&
4133 is_valid((
size_t)-1, month->value))
4135 if (day) day->invalidate();
4138 format = date_format_t::ym;
4145 if ((m_format_mask & date_format_t::my) == date_format_t::my) {
4146 if (month->match(text, start, end, flags)) {
4148 if (m_separator->match(text,
interval.
end, end, flags)) {
4150 if (year->match(text,
interval.
end, end, flags) &&
4151 is_valid((
size_t)-1, month->value))
4153 if (day) day->invalidate();
4156 format = date_format_t::my;
4163 if ((m_format_mask & date_format_t::dm) == date_format_t::dm) {
4164 if (day->match(text, start, end, flags)) {
4166 if (m_separator->match(text,
interval.
end, end, flags)) {
4167 size_t hit_offset = m_separator->hit_offset;
4169 if (month->match(text,
interval.
end, end, flags) &&
4170 is_valid(day->value, month->value))
4172 if (year) year->invalidate();
4175 if (m_separator->match(text,
interval.
end, end, flags) &&
4176 m_separator->hit_offset == hit_offset)
4180 format = date_format_t::dm;
4187 if ((m_format_mask & date_format_t::md) == date_format_t::md) {
4188 if (month->match(text, start, end, flags)) {
4190 if (m_separator->match(text,
interval.
end, end, flags)) {
4191 size_t hit_offset = m_separator->hit_offset;
4194 is_valid(day->value, month->value))
4196 if (year) year->invalidate();
4199 if (m_separator->match(text,
interval.
end, end, flags) &&
4200 m_separator->hit_offset == hit_offset)
4204 format = date_format_t::md;
4211 if (day) day->invalidate();
4212 if (month) month->invalidate();
4213 if (year) year->invalidate();
4214 format = date_format_t::none;
4219 virtual void invalidate()
4221 if (day) day->invalidate();
4222 if (month) month->invalidate();
4223 if (year) year->invalidate();
4224 format = date_format_t::none;
4229 static inline bool is_valid(
size_t day,
size_t month)
4231 if (month == (
size_t)-1) {
4235 if (day == (
size_t)-1) {
4248 return 1 <= day && day <= 31;
4250 return 1 <= day && day <= 29;
4255 return 1 <= day && day <= 30;
4262 date_format_t format;
4263 std::shared_ptr<basic_integer<T>> day;
4264 std::shared_ptr<basic_integer<T>> month;
4265 std::shared_ptr<basic_integer<T>> year;
4269 std::shared_ptr<basic_set<T>> m_separator;
4270 std::shared_ptr<basic_parser<T>> m_space;
4296 _In_
const std::locale& locale = std::locale()) :
4301 millisecond(_millisecond),
4302 m_separator(separator),
4303 m_millisecond_separator(millisecond_separator)
4307 _In_reads_or_z_(end)
const T* text,
4308 _In_
size_t start = 0,
4309 _In_
size_t end = (
size_t)-1,
4310 _In_
int flags = match_default)
4312 assert(text || start >= end);
4314 if (hour->match(text, start, end, flags) &&
4315 m_separator->match(text, hour->interval.end, end, flags) &&
4316 minute->match(text, m_separator->interval.end, end, flags) &&
4320 size_t hit_offset = m_separator->hit_offset;
4321 if (m_separator->match(text, minute->interval.end, end, flags) &&
4322 m_separator->hit_offset == hit_offset &&
4323 second && second->match(text, m_separator->interval.end, end, flags) &&
4327 if (m_millisecond_separator && m_millisecond_separator->match(text, second->interval.end, end, flags) &&
4328 millisecond && millisecond->match(text, m_millisecond_separator->interval.end, end, flags) &&
4329 millisecond->value < 1000)
4335 if (millisecond) millisecond->invalidate();
4340 if (second) second->invalidate();
4341 if (millisecond) millisecond->invalidate();
4349 minute->invalidate();
4350 if (second) second->invalidate();
4351 if (millisecond) millisecond->invalidate();
4356 virtual void invalidate()
4359 minute->invalidate();
4360 if (second) second->invalidate();
4361 if (millisecond) millisecond->invalidate();
4366 std::shared_ptr<basic_integer10<T>> hour;
4367 std::shared_ptr<basic_integer10<T>> minute;
4368 std::shared_ptr<basic_integer10<T>> second;
4369 std::shared_ptr<basic_integer10<T>> millisecond;
4372 std::shared_ptr<basic_set<T>> m_separator;
4373 std::shared_ptr<basic_parser<T>> m_millisecond_separator;
4400 _In_
const std::locale& locale = std::locale()) :
4403 degree_separator(_degree_separator),
4405 minute_separator(_minute_separator),
4407 second_separator(_second_separator),
4412 _In_reads_or_z_(end)
const T* text,
4413 _In_
size_t start = 0,
4414 _In_
size_t end = (
size_t)-1,
4415 _In_
int flags = match_default)
4417 assert(text || start >= end);
4421 if (degree->match(text,
interval.
end, end, flags) &&
4422 degree_separator->match(text, degree->interval.end, end, flags))
4428 degree->invalidate();
4429 degree_separator->invalidate();
4432 if (minute->match(text,
interval.
end, end, flags) &&
4433 minute->value < 60 &&
4434 minute_separator->match(text, minute->interval.end, end, flags))
4440 minute->invalidate();
4441 minute_separator->invalidate();
4444 if (second && second->match(text,
interval.
end, end, flags) &&
4449 if (second_separator && second_separator->match(text,
interval.
end, end, flags))
4452 if (second_separator) second_separator->invalidate();
4455 if (second) second->invalidate();
4456 if (second_separator) second_separator->invalidate();
4459 if (degree->interval.start < degree->interval.end ||
4460 minute->interval.start < minute->interval.end ||
4461 second && second->interval.start < second->interval.end)
4463 if (decimal && decimal->match(text,
interval.
end, end, flags)) {
4468 decimal->invalidate();
4472 if (decimal) decimal->invalidate();
4477 virtual void invalidate()
4479 degree->invalidate();
4480 degree_separator->invalidate();
4481 minute->invalidate();
4482 minute_separator->invalidate();
4483 if (second) second->invalidate();
4484 if (second_separator) second_separator->invalidate();
4485 if (decimal) decimal->invalidate();
4490 std::shared_ptr<basic_integer10<T>> degree;
4491 std::shared_ptr<basic_parser<T>> degree_separator;
4492 std::shared_ptr<basic_integer10<T>> minute;
4493 std::shared_ptr<basic_parser<T>> minute_separator;
4494 std::shared_ptr<basic_integer10<T>> second;
4495 std::shared_ptr<basic_parser<T>> second_separator;
4496 std::shared_ptr<basic_parser<T>> decimal;
4518 _In_
const std::shared_ptr<
basic_set<T>>& lparenthesis,
4519 _In_
const std::shared_ptr<
basic_set<T>>& rparenthesis,
4522 _In_
const std::locale& locale = std::locale()) :
4525 m_plus_sign(plus_sign),
4526 m_lparenthesis(lparenthesis),
4527 m_rparenthesis(rparenthesis),
4528 m_separator(separator),
4533 _In_reads_or_z_(end)
const T* text,
4534 _In_
size_t start = 0,
4535 _In_
size_t end = (
size_t)-1,
4536 _In_
int flags = match_default)
4538 assert(text || start >= end);
4540 size_t safe_digit_end = start, safe_value_size = 0;
4541 bool has_digits =
false, after_digit =
false, in_parentheses =
false, after_parentheses =
false;
4542 const int space_match_flags = flags & ~match_multiline;
4546 m_lparenthesis->invalidate();
4547 m_rparenthesis->invalidate();
4549 if (m_plus_sign && m_plus_sign->match(text,
interval.
end, end, flags)) {
4550 value.append(text + m_plus_sign->interval.start, text + m_plus_sign->interval.end);
4551 safe_value_size =
value.size();
4559 if (m_digit->match(text,
interval.
end, end, flags)) {
4561 value.append(text + m_digit->interval.start, text + m_digit->interval.end);
4563 if (!in_parentheses) {
4565 safe_value_size =
value.size();
4569 after_parentheses =
false;
4572 m_lparenthesis && !m_lparenthesis->interval &&
4573 m_rparenthesis && !m_rparenthesis->interval &&
4574 m_lparenthesis->match(text,
interval.
end, end, flags))
4577 value.append(text + m_lparenthesis->interval.start, m_lparenthesis->interval.size());
4579 in_parentheses =
true;
4580 after_digit =
false;
4581 after_parentheses =
false;
4585 m_rparenthesis && !m_rparenthesis->interval &&
4586 m_rparenthesis->match(text,
interval.
end, end, flags) &&
4587 m_lparenthesis->hit_offset == m_rparenthesis->hit_offset)
4590 value.append(text + m_rparenthesis->interval.start, text + m_rparenthesis->interval.end);
4593 safe_value_size =
value.size();
4594 in_parentheses =
false;
4595 after_digit =
false;
4596 after_parentheses =
true;
4601 !after_parentheses &&
4602 m_separator && m_separator->match(text,
interval.
end, end, flags))
4606 after_digit =
false;
4607 after_parentheses =
false;
4610 (after_digit || after_parentheses) &&
4611 m_space && m_space->match(text,
interval.
end, end, space_match_flags))
4615 after_digit =
false;
4616 after_parentheses =
false;
4622 value.erase(safe_value_size);
4632 virtual void invalidate()
4642 std::shared_ptr<basic_parser<T>> m_digit;
4643 std::shared_ptr<basic_parser<T>> m_plus_sign;
4644 std::shared_ptr<basic_set<T>> m_lparenthesis;
4645 std::shared_ptr<basic_set<T>> m_rparenthesis;
4646 std::shared_ptr<basic_parser<T>> m_separator;
4647 std::shared_ptr<basic_parser<T>> m_space;
4670 _In_
const std::locale& locale = std::locale()) :
4680 _In_reads_or_z_(end)
const T* text,
4681 _In_
size_t start = 0,
4682 _In_
size_t end = (
size_t)-1,
4683 _In_
int flags = match_default)
4685 assert(text || start >= end);
4691 const int element_match_flags = flags & ~match_case_insensitive;
4693 if (m_element->match(text,
interval.
end, end, element_match_flags)) {
4695 while (m_digit->match(text,
interval.
end, end, flags)) {
4701 if (m_sign->match(text,
interval.
end, end, flags)) {
4715 virtual void invalidate()
4727 std::shared_ptr<basic_parser<T>> m_element;
4728 std::shared_ptr<basic_parser<T>> m_digit;
4729 std::shared_ptr<basic_parser<T>> m_sign;
4748 _In_reads_or_z_(end)
const char* text,
4749 _In_
size_t start = 0,
4750 _In_
size_t end = (
size_t)-1,
4751 _In_
int flags = match_default)
4753 assert(text || start >= end);
4784 _In_reads_or_z_(end)
const char* text,
4785 _In_
size_t start = 0,
4786 _In_
size_t end = (
size_t)-1,
4787 _In_
int flags = match_default)
4789 assert(text || start >= end);
4791 if (m_line_break.match(text,
interval.
end, end, flags)) {
4821 _In_reads_or_z_(end)
const char* text,
4822 _In_
size_t start = 0,
4823 _In_
size_t end = (
size_t)-1,
4824 _In_
int flags = match_default)
4826 assert(text || start >= end);
4830 if (m_space.match(text,
interval.
end, end, flags)) {
4855 _In_reads_or_z_(end)
const char* text,
4856 _In_
size_t start = 0,
4857 _In_
size_t end = (
size_t)-1,
4858 _In_
int flags = match_default)
4860 assert(text || start >= end);
4909 _In_reads_or_z_(end)
const char* text,
4910 _In_
size_t start = 0,
4911 _In_
size_t end = (
size_t)-1,
4912 _In_
int flags = match_default)
4914 assert(text || start >= end);
4936 else if (m_chr.match(text,
interval.
end, end, flags))
4954 virtual void invalidate()
4958 parser::invalidate();
4975 _In_reads_or_z_(end)
const char* text,
4976 _In_
size_t start = 0,
4977 _In_
size_t end = (
size_t)-1,
4978 _In_
int flags = match_default)
4980 assert(text || start >= end);
4982 if (
string.match(text,
interval.
end, end, flags)) {
4989 string.invalidate();
5000 virtual void invalidate()
5002 string.invalidate();
5004 parser::invalidate();
5019 _In_reads_or_z_(end)
const char* text,
5020 _In_
size_t start = 0,
5021 _In_
size_t end = (
size_t)-1,
5022 _In_
int flags = match_default)
5024 assert(text || start >= end);
5030 while (m_space.match(text,
interval.
end, end, flags))
5036 while (m_space.match(text,
interval.
end, end, flags))
5052 virtual void invalidate()
5056 parser::invalidate();
5074 _In_reads_or_z_(end)
const char* text,
5075 _In_
size_t start = 0,
5076 _In_
size_t end = (
size_t)-1,
5077 _In_
int flags = match_default)
5079 assert(text || start >= end);
5080 if (start + 2 < end &&
5081 text[start] ==
'*' &&
5082 text[start + 1] ==
'/' &&
5083 text[start + 2] ==
'*')
5088 else if (start < end && text[start] ==
'*') {
5106 _In_reads_or_z_(end)
const char* text,
5107 _In_
size_t start = 0,
5108 _In_
size_t end = (
size_t)-1,
5109 _In_
int flags = match_default)
5111 assert(text || start >= end);
5117 while (m_space.match(text,
interval.
end, end, flags))
5123 while (m_space.match(text,
interval.
end, end, flags))
5125 if (subtype.match(text,
interval.
end, end, flags))
5134 subtype.invalidate();
5139 virtual void invalidate()
5142 subtype.invalidate();
5143 parser::invalidate();
5161 _In_reads_or_z_(end)
const char* text,
5162 _In_
size_t start = 0,
5163 _In_
size_t end = (
size_t)-1,
5164 _In_
int flags = match_default)
5166 assert(text || start >= end);
5167 if (!http_media_range::match(text, start, end, flags))
5172 if (m_space.match(text,
interval.
end, end, flags))
5176 while (m_space.match(text,
interval.
end, end, flags))
5179 if (param.match(text,
interval.
end, end, flags)) {
5181 params.push_back(std::move(param));
5196 http_media_range::invalidate();
5202 virtual void invalidate()
5205 http_media_range::invalidate();
5209 std::list<http_parameter> params;
5219 _In_reads_or_z_(end)
const char* text,
5220 _In_
size_t start = 0,
5221 _In_
size_t end = (
size_t)-1,
5222 _In_
int flags = match_default)
5224 assert(text || start >= end);
5255 http_url_port(_In_
const std::locale& locale = std::locale()) :
5261 _In_reads_or_z_(end)
const char* text,
5262 _In_
size_t start = 0,
5263 _In_
size_t end = (
size_t)-1,
5264 _In_
int flags = match_default)
5266 assert(text || start >= end);
5272 size_t _value = (size_t)value * 10 + text[
interval.
end] -
'0';
5273 if (_value > (uint16_t)-1) {
5278 value = (uint16_t)_value;
5295 virtual void invalidate()
5298 parser::invalidate();
5312 _In_reads_or_z_(end)
const char* text,
5313 _In_
size_t start = 0,
5314 _In_
size_t end = (
size_t)-1,
5315 _In_
int flags = match_default)
5317 assert(text || start >= end);
5345 _In_reads_or_z_(end)
const char* text,
5346 _In_
size_t start = 0,
5347 _In_
size_t end = (
size_t)-1,
5348 _In_
int flags = match_default)
5350 assert(text || start >= end);
5384 virtual void invalidate()
5387 parser::invalidate();
5401 _In_reads_or_z_(end)
const char* text,
5402 _In_
size_t start = 0,
5403 _In_
size_t end = (
size_t)-1,
5404 _In_
int flags = match_default)
5406 assert(text || start >= end);
5461 virtual void invalidate()
5467 parser::invalidate();
5481 http_url(_In_
const std::locale& locale = std::locale()) :
5487 _In_reads_or_z_(end)
const char* text,
5488 _In_
size_t start = 0,
5489 _In_
size_t end = (
size_t)-1,
5490 _In_
int flags = match_default)
5492 assert(text || start >= end);
5495 if (
interval.
end + 7 <= end && stdex::strnicmp(text +
interval.
end, 7,
"http://", (
size_t)-1, m_locale) == 0) {
5512 server.invalidate();
5536 if (param.match(text,
interval.
end, end, flags)) {
5538 params.push_back(std::move(param));
5553 server.invalidate();
5561 virtual void invalidate()
5563 server.invalidate();
5567 parser::invalidate();
5574 std::list<http_url_parameter> params;
5584 _In_reads_or_z_(end)
const char* text,
5585 _In_
size_t start = 0,
5586 _In_
size_t end = (
size_t)-1,
5587 _In_
int flags = match_default)
5589 assert(text || start >= end);
5597 if (k.
end < end && text[k.
end]) {
5598 if (isalpha(text[k.
end]))
5609 components.push_back(k);
5621 if (!components.empty()) {
5630 virtual void invalidate()
5633 parser::invalidate();
5637 std::vector<stdex::interval<size_t>> components;
5646 http_weight(_In_
const std::locale& locale = std::locale()) :
5652 _In_reads_or_z_(end)
const char* text,
5653 _In_
size_t start = 0,
5654 _In_
size_t end = (
size_t)-1,
5655 _In_
int flags = match_default)
5657 assert(text || start >= end);
5658 size_t celi_del = 0, decimalni_del = 0, decimalni_del_n = 1;
5663 celi_del = celi_del * 10 + text[
interval.
end] -
'0';
5671 decimalni_del = decimalni_del * 10 + text[
interval.
end] -
'0';
5672 decimalni_del_n *= 10;
5690 value = (float)((
double)celi_del + (double)decimalni_del / decimalni_del_n);
5699 virtual void invalidate()
5702 parser::invalidate();
5716 _In_reads_or_z_(end)
const char* text,
5717 _In_
size_t start = 0,
5718 _In_
size_t end = (
size_t)-1,
5719 _In_
int flags = match_default)
5721 assert(text || end <= start);
5722 if (start < end && text[start] ==
'*') {
5734 template <
class T,
class T_asterisk = http_asterisk>
5744 _In_reads_or_z_(end)
const char* text,
5745 _In_
size_t start = 0,
5746 _In_
size_t end = (
size_t)-1,
5747 _In_
int flags = match_default)
5749 assert(text || start >= end);
5750 size_t konec_vrednosti;
5752 if (asterisk.match(text,
interval.
end, end, flags)) {
5753 interval.
end = konec_vrednosti = asterisk.interval.end;
5756 else if (value.match(text,
interval.
end, end, flags)) {
5757 interval.
end = konec_vrednosti = value.interval.end;
5758 asterisk.invalidate();
5761 asterisk.invalidate();
5783 factor.invalidate();
5790 virtual void invalidate()
5792 asterisk.invalidate();
5794 factor.invalidate();
5795 parser::invalidate();
5799 T_asterisk asterisk;
5811 _In_reads_or_z_(end)
const char* text,
5812 _In_
size_t start = 0,
5813 _In_
size_t end = (
size_t)-1,
5814 _In_
int flags = match_default)
5816 assert(text || start >= end);
5826 while (m_space.match(text,
interval.
end, end, flags))
5832 while (m_space.match(text,
interval.
end, end, flags))
5848 virtual void invalidate()
5852 parser::invalidate();
5870 _In_reads_or_z_(end)
const char* text,
5871 _In_
size_t start = 0,
5872 _In_
size_t end = (
size_t)-1,
5873 _In_
int flags = match_default)
5875 assert(text || start >= end);
5881 while (m_space.match(text,
interval.
end, end, flags))
5887 while (m_space.match(text,
interval.
end, end, flags))
5896 if (m_space.match(text,
interval.
end, end, flags))
5900 while (m_space.match(text,
interval.
end, end, flags))
5903 if (param.match(text,
interval.
end, end, flags)) {
5905 params.push_back(std::move(param));
5928 virtual void invalidate()
5933 parser::invalidate();
5952 _In_reads_or_z_(end)
const char* text,
5953 _In_
size_t start = 0,
5954 _In_
size_t end = (
size_t)-1,
5955 _In_
int flags = match_default)
5957 assert(text || start >= end);
6007 virtual void invalidate()
6013 parser::invalidate();
6027 http_protocol(_In_
const std::locale& locale = std::locale()) :
6033 _In_reads_or_z_(end)
const char* text,
6034 _In_
size_t start = 0,
6035 _In_
size_t end = (
size_t)-1,
6036 _In_
int flags = match_default)
6038 assert(text || start >= end);
6070 (uint16_t)strtoui(text + version_maj.
start, version_maj.
size(),
nullptr, 10) * 0x100 +
6071 (uint16_t)strtoui(text + version_min.
start, version_min.
size(),
nullptr, 10);
6084 version_min.
start = 1;
6085 version_min.
end = 0;
6086 version = (uint16_t)strtoui(text + version_maj.
start, version_maj.
size(),
nullptr, 10) * 0x100;
6101 version_maj.
start = 1;
6102 version_maj.
end = 0;
6103 version_min.
start = 1;
6104 version_min.
end = 0;
6111 virtual void invalidate()
6115 version_maj.
start = 1;
6116 version_maj.
end = 0;
6117 version_min.
start = 1;
6118 version_min.
end = 0;
6120 parser::invalidate();
6136 http_request(_In_
const std::locale& locale = std::locale()) :
6143 _In_reads_or_z_(end)
const char* text,
6144 _In_
size_t start = 0,
6145 _In_
size_t end = (
size_t)-1,
6146 _In_
int flags = match_default)
6148 assert(text || start >= end);
6152 if (m_line_break.match(text,
interval.
end, end, flags))
6165 if (m_line_break.match(text,
interval.
end, end, flags))
6181 if (m_line_break.match(text,
interval.
end, end, flags))
6197 protocol.invalidate();
6199 if (m_line_break.match(text,
interval.
end, end, flags)) {
6213 if (m_line_break.match(text,
interval.
end, end, flags)) {
6217 else if (protocol.match(text,
interval.
end, end, flags)) {
6226 if (m_line_break.match(text,
interval.
end, end, flags)) {
6244 protocol.invalidate();
6250 virtual void invalidate()
6255 protocol.invalidate();
6256 parser::invalidate();
6275 _In_reads_or_z_(end)
const char* text,
6276 _In_
size_t start = 0,
6277 _In_
size_t end = (
size_t)-1,
6278 _In_
int flags = match_default)
6280 assert(text || start >= end);
6283 if (m_line_break.match(text,
interval.
end, end, flags) ||
6288 if (m_line_break.match(text,
interval.
end, end, flags))
6295 if (m_line_break.match(text,
interval.
end, end, flags))
6325 value.
start = (size_t)-1;
6328 if (m_line_break.match(text,
interval.
end, end, flags)) {
6330 if (!m_line_break.match(text,
interval.
end, end, flags) &&
6360 virtual void invalidate()
6366 parser::invalidate();
6385 _In_reads_or_z_(end)
const char* text,
6386 _In_
size_t start = 0,
6387 _In_
size_t end = (
size_t)-1,
6388 _In_
int flags = match_default)
6390 while (start < end) {
6391 while (start < end && text[start] && isspace(text[start])) start++;
6392 if (start < end && text[start] ==
',') {
6394 while (start < end&& text[start] && isspace(text[start])) start++;
6397 if (el.match(text, start, end, flags)) {
6398 start = el.interval.end;
6399 T::insert(std::move(el));
6409 constexpr bool operator()(
const T& a,
const T& b)
const noexcept
6411 return a.factor.value > b.factor.value;
6418 template <
class T,
class _Alloc = std::allocator<T>>
6440 _In_
const std::locale& locale = std::locale()) :
6456 _In_reads_or_z_(end)
const T* text,
6457 _In_
size_t start = 0,
6458 _In_
size_t end = (
size_t)-1,
6459 _In_
int flags = match_default)
6461 assert(text || start >= end);
6463 if (m_quote->match(text,
interval.
end, end, flags)) {
6467 if (m_quote->match(text,
interval.
end, end, flags)) {
6472 if (m_escape->match(text,
interval.
end, end, flags)) {
6473 if (m_quote->match(text, m_escape->interval.end, end, flags)) {
6474 value +=
'"';
interval.
end = m_quote->interval.end;
6477 if (m_sol->match(text, m_escape->interval.end, end, flags)) {
6481 if (m_bs->match(text, m_escape->interval.end, end, flags)) {
6485 if (m_ff->match(text, m_escape->interval.end, end, flags)) {
6489 if (m_lf->match(text, m_escape->interval.end, end, flags)) {
6493 if (m_cr->match(text, m_escape->interval.end, end, flags)) {
6497 if (m_htab->match(text, m_escape->interval.end, end, flags)) {
6498 value +=
'\t';
interval.
end = m_htab->interval.end;
6502 m_uni->match(text, m_escape->interval.end, end, flags) &&
6503 m_hex->match(text, m_uni->interval.end, std::min(m_uni->interval.end + 4, end), flags | match_case_insensitive) &&
6504 m_hex->interval.size() == 4 )
6506 assert(m_hex->value <= 0xffff);
6507 if (
sizeof(T) == 1) {
6508 if (m_hex->value > 0x7ff) {
6509 value += (T)(0xe0 | (m_hex->value >> 12) & 0x0f);
6510 value += (T)(0x80 | (m_hex->value >> 6) & 0x3f);
6511 value += (T)(0x80 | m_hex->value & 0x3f);
6513 else if (m_hex->value > 0x7f) {
6514 value += (T)(0xc0 | (m_hex->value >> 6) & 0x1f);
6515 value += (T)(0x80 | m_hex->value & 0x3f);
6518 value += (T)(m_hex->value & 0x7f);
6521 value += (T)m_hex->value;
6525 if (m_escape->match(text, m_escape->interval.end, end, flags)) {
6526 value +=
'\\';
interval.
end = m_escape->interval.end;
6530 if (m_chr->match(text,
interval.
end, end, flags)) {
6531 value.Prilepi(text + m_chr->interval.start, m_chr->interval.size());
6543 virtual void invalidate()
6550 std::basic_string<T> value;
6553 std::shared_ptr<basic_parser<T>> m_quote;
6554 std::shared_ptr<basic_parser<T>> m_chr;
6555 std::shared_ptr<basic_parser<T>> m_escape;
6556 std::shared_ptr<basic_parser<T>> m_sol;
6557 std::shared_ptr<basic_parser<T>> m_bs;
6558 std::shared_ptr<basic_parser<T>> m_ff;
6559 std::shared_ptr<basic_parser<T>> m_lf;
6560 std::shared_ptr<basic_parser<T>> m_cr;
6561 std::shared_ptr<basic_parser<T>> m_htab;
6562 std::shared_ptr<basic_parser<T>> m_uni;
6563 std::shared_ptr<basic_integer16<T>> m_hex;
6576#undef ENUM_FLAG_OPERATOR
Test for angle in d°mm'ss.dddd form.
Definition parser.hpp:4390
Test for any code unit.
Definition parser.hpp:217
Test for beginning of line.
Definition parser.hpp:611
Test for any.
Definition parser.hpp:1053
Test for any code unit from a given string of code units.
Definition parser.hpp:716
Test for specific code unit.
Definition parser.hpp:287
Test for date.
Definition parser.hpp:4020
Test for valid DNS domain character.
Definition parser.hpp:2801
bool allow_on_edge
Is character allowed at the beginning or an end of a DNS domain?
Definition parser.hpp:2839
Test for DNS domain/hostname.
Definition parser.hpp:2901
bool m_allow_absolute
May DNS names end with a dot (absolute name)?
Definition parser.hpp:2965
Test for e-mail address.
Definition parser.hpp:3789
Test for emoticon.
Definition parser.hpp:3897
std::shared_ptr< basic_parser< T > > apex
apex/eyebrows/halo (e.g. O, 0)
Definition parser.hpp:3986
std::shared_ptr< basic_parser< T > > eyes
eyes (e.g. :, ;, >, |, B)
Definition parser.hpp:3987
std::shared_ptr< basic_set< T > > mouth
mouth (e.g. ), ), (, (, |, P, D, p, d)
Definition parser.hpp:3989
std::shared_ptr< basic_parser< T > > nose
nose (e.g. -, o)
Definition parser.hpp:3988
std::shared_ptr< basic_parser< T > > emoticon
emoticon as a whole (e.g. 😀, 🤔, 😶)
Definition parser.hpp:3985
Test for end of line.
Definition parser.hpp:649
Test for fraction.
Definition parser.hpp:1682
Test for decimal integer.
Definition parser.hpp:1291
Test for decimal integer possibly containing thousand separators.
Definition parser.hpp:1376
bool has_separators
Did integer have any separators?
Definition parser.hpp:1436
size_t digit_count
Total number of digits in integer.
Definition parser.hpp:1435
Test for hexadecimal integer.
Definition parser.hpp:1457
Base class for integer testing.
Definition parser.hpp:1269
size_t value
Calculated value of the numeral.
Definition parser.hpp:1283
Test for IPv4 address.
Definition parser.hpp:2341
stdex::interval< size_t > components[4]
Individual component intervals.
Definition parser.hpp:2456
struct in_addr value
IPv4 address value.
Definition parser.hpp:2457
Test for IPv6 address.
Definition parser.hpp:2560
std::shared_ptr< basic_parser< T > > scope_id
Scope ID (e.g. NIC index with link-local addresses)
Definition parser.hpp:2764
stdex::interval< size_t > components[8]
Individual component intervals.
Definition parser.hpp:2762
struct in6_addr value
IPv6 address value.
Definition parser.hpp:2763
Test for valid IPv6 address scope ID character.
Definition parser.hpp:2488
Test for repeating.
Definition parser.hpp:906
bool m_greedy
try to match as long sequence as possible
Definition parser.hpp:945
std::shared_ptr< basic_parser< T > > m_el
repeating element
Definition parser.hpp:942
size_t m_min_iterations
minimum number of iterations
Definition parser.hpp:943
size_t m_max_iterations
maximum number of iterations
Definition parser.hpp:944
Test for JSON string.
Definition parser.hpp:6426
Test for mixed numeral.
Definition parser.hpp:1917
std::shared_ptr< basic_parser< T > > fraction
fraction
Definition parser.hpp:2023
std::shared_ptr< basic_parser< T > > special_sign
Special sign (e.g. plus-minus '±')
Definition parser.hpp:2021
std::shared_ptr< basic_parser< T > > negative_sign
Negative sign.
Definition parser.hpp:2020
std::shared_ptr< basic_parser< T > > positive_sign
Positive sign.
Definition parser.hpp:2019
std::shared_ptr< basic_parser< T > > integer
Integer part.
Definition parser.hpp:2022
Test for monetary numeral.
Definition parser.hpp:2212
std::shared_ptr< basic_parser< T > > positive_sign
Positive sign.
Definition parser.hpp:2318
std::shared_ptr< basic_parser< T > > decimal_separator
Decimal separator.
Definition parser.hpp:2323
std::shared_ptr< basic_parser< T > > currency
Currency part.
Definition parser.hpp:2321
std::shared_ptr< basic_parser< T > > decimal
Decimal part.
Definition parser.hpp:2324
std::shared_ptr< basic_parser< T > > integer
Integer part.
Definition parser.hpp:2322
std::shared_ptr< basic_parser< T > > negative_sign
Negative sign.
Definition parser.hpp:2319
std::shared_ptr< basic_parser< T > > special_sign
Special sign (e.g. plus-minus '±')
Definition parser.hpp:2320
"No-op" match
Definition parser.hpp:185
Base template for all parsers.
Definition parser.hpp:66
interval< size_t > interval
Region of the last match.
Definition parser.hpp:165
Test for permutation.
Definition parser.hpp:1193
Test for phone number.
Definition parser.hpp:4513
std::basic_string< T > value
Normalized phone number.
Definition parser.hpp:4639
Test for any punctuation code unit.
Definition parser.hpp:459
Test for Roman numeral.
Definition parser.hpp:1566
Test for scientific numeral.
Definition parser.hpp:2043
std::shared_ptr< basic_parser< T > > special_sign
Special sign (e.g. plus-minus '±')
Definition parser.hpp:2187
std::shared_ptr< basic_parser< T > > exponent_symbol
Exponent symbol (e.g. 'e')
Definition parser.hpp:2191
std::shared_ptr< basic_parser< T > > positive_sign
Positive sign.
Definition parser.hpp:2185
std::shared_ptr< basic_parser< T > > negative_sign
Negative sign.
Definition parser.hpp:2186
double value
Calculated value of the numeral.
Definition parser.hpp:2195
std::shared_ptr< basic_parser< T > > negative_exp_sign
Negative exponent sign (e.g. '-')
Definition parser.hpp:2193
std::shared_ptr< basic_integer< T > > decimal
Decimal part.
Definition parser.hpp:2190
std::shared_ptr< basic_parser< T > > positive_exp_sign
Positive exponent sign (e.g. '+')
Definition parser.hpp:2192
std::shared_ptr< basic_integer< T > > exponent
Exponent part.
Definition parser.hpp:2194
std::shared_ptr< basic_parser< T > > decimal_separator
Decimal separator.
Definition parser.hpp:2189
std::shared_ptr< basic_integer< T > > integer
Integer part.
Definition parser.hpp:2188
Test for match score.
Definition parser.hpp:1745
Test for sequence.
Definition parser.hpp:1002
Definition parser.hpp:684
Test for signed numeral.
Definition parser.hpp:1831
std::shared_ptr< basic_parser< T > > special_sign
Special sign (e.g. plus-minus '±')
Definition parser.hpp:1899
std::shared_ptr< basic_parser< T > > negative_sign
Negative sign.
Definition parser.hpp:1898
std::shared_ptr< basic_parser< T > > positive_sign
Positive sign.
Definition parser.hpp:1897
std::shared_ptr< basic_parser< T > > number
Number.
Definition parser.hpp:1900
Test for any space code unit.
Definition parser.hpp:380
Test for any space or punctuation code unit.
Definition parser.hpp:533
Test for any string.
Definition parser.hpp:1121
Test for given string.
Definition parser.hpp:811
Test for time.
Definition parser.hpp:4287
Test for valid URL password character.
Definition parser.hpp:3083
Test for valid URL path character.
Definition parser.hpp:3183
Test for URL path.
Definition parser.hpp:3291
Test for valid URL username character.
Definition parser.hpp:2984
Test for URL.
Definition parser.hpp:3432
Test for HTTP agent.
Definition parser.hpp:5949
Test for HTTP any type.
Definition parser.hpp:5071
Test for HTTP asterisk.
Definition parser.hpp:5713
Test for HTTP cookie parameter (RFC2109)
Definition parser.hpp:5808
Test for HTTP cookie (RFC2109)
Definition parser.hpp:5867
std::list< http_cookie_parameter > params
List of cookie parameters.
Definition parser.hpp:5939
http_token name
Cookie name.
Definition parser.hpp:5937
http_value value
Cookie value.
Definition parser.hpp:5938
Test for HTTP language (RFC1766)
Definition parser.hpp:5581
Test for HTTP line break (RFC2616: CRLF | LF)
Definition parser.hpp:4745
Test for HTTP parameter (RFC2616: parameter)
Definition parser.hpp:5016
http_token name
Parameter name.
Definition parser.hpp:5060
http_value value
Parameter value.
Definition parser.hpp:5061
Test for HTTP protocol.
Definition parser.hpp:6025
uint16_t version
HTTP protocol version: 0x100 = 1.0, 0x101 = 1.1...
Definition parser.hpp:6127
Test for HTTP quoted string (RFC2616: quoted-string)
Definition parser.hpp:4906
stdex::interval< size_t > content
String content (without quotes)
Definition parser.hpp:4962
Test for HTTP request.
Definition parser.hpp:6134
Test for HTTP space (RFC2616: LWS)
Definition parser.hpp:4781
Test for HTTP text character (RFC2616: TEXT)
Definition parser.hpp:4818
Test for HTTP token (RFC2616: token - tolerates non-ASCII)
Definition parser.hpp:4852
Test for HTTP URL parameter.
Definition parser.hpp:5398
Test for HTTP URL path segment.
Definition parser.hpp:5309
Test for HTTP URL path segment.
Definition parser.hpp:5342
std::vector< http_url_path_segment > segments
Path segments.
Definition parser.hpp:5391
Test for HTTP URL port.
Definition parser.hpp:5253
Test for HTTP URL server.
Definition parser.hpp:5216
Test for HTTP URL.
Definition parser.hpp:5479
Collection of HTTP values.
Definition parser.hpp:6382
Test for HTTP value (RFC2616: value)
Definition parser.hpp:4972
http_quoted_string string
Value when matched as quoted string.
Definition parser.hpp:5008
http_token token
Value when matched as token.
Definition parser.hpp:5009
Test for HTTP weight factor.
Definition parser.hpp:5644
float value
Calculated value of the weight factor.
Definition parser.hpp:5706
Test for HTTP weighted value.
Definition parser.hpp:5736
Base template for collection-holding parsers.
Definition parser.hpp:962
Test for any SGML code point.
Definition parser.hpp:249
Test for any SGML code point from a given string of SGML code points.
Definition parser.hpp:768
Test for specific SGML code point.
Definition parser.hpp:336
Test for valid DNS domain SGML character.
Definition parser.hpp:2857
Test for valid IPv6 address scope ID SGML character.
Definition parser.hpp:2526
Test for any SGML punctuation code point.
Definition parser.hpp:500
Test for any SGML space code point.
Definition parser.hpp:423
Test for any SGML space or punctuation code point.
Definition parser.hpp:576
Test for SGML given string.
Definition parser.hpp:858
Test for valid URL password SGML character.
Definition parser.hpp:3135
Test for valid URL path SGML character.
Definition parser.hpp:3239
Test for valid URL username SGML character.
Definition parser.hpp:3035
Numerical interval.
Definition interval.hpp:18
T size() const
Returns interval size.
Definition interval.hpp:47
T end
interval end
Definition interval.hpp:20
interval() noexcept
Constructs an invalid interval.
Definition interval.hpp:25
T start
interval start
Definition interval.hpp:19
Definition parser.hpp:6408