From fa4f7f1747b99fb365fee42deffdaeb2080e04f0 Mon Sep 17 00:00:00 2001 From: rozmansi Date: Tue, 29 Aug 2023 08:10:06 +0000 Subject: [PATCH] deploy: b76db460769d30b5851481880face712b6102d53 --- annotated.html | 6 +- base64_8hpp_source.html | 37 +- chrono_8hpp_source.html | 47 +- classes.html | 6 +- classstdex_1_1base64__dec-members.html | 6 +- classstdex_1_1base64__dec.html | 20 +- classstdex_1_1base64__enc-members.html | 6 +- classstdex_1_1base64__enc.html | 22 +- classstdex_1_1errno__error-members.html | 6 +- classstdex_1_1errno__error.html | 18 +- classstdex_1_1global__progress-members.html | 6 +- classstdex_1_1global__progress.html | 49 +- classstdex_1_1hex__dec-members.html | 6 +- classstdex_1_1hex__dec.html | 18 +- classstdex_1_1hex__enc-members.html | 6 +- classstdex_1_1hex__enc.html | 12 +- classstdex_1_1idrec_1_1record-members.html | 6 +- classstdex_1_1idrec_1_1record.html | 22 +- classstdex_1_1lazy__progress-members.html | 6 +- classstdex_1_1lazy__progress.html | 36 +- ...dex_1_1parser_1_1basic__angle-members.html | 6 +- classstdex_1_1parser_1_1basic__angle.html | 74 +- ...x_1_1parser_1_1basic__any__cu-members.html | 6 +- classstdex_1_1parser_1_1basic__any__cu.html | 55 +- ...stdex_1_1parser_1_1basic__bol-members.html | 6 +- classstdex_1_1parser_1_1basic__bol.html | 59 +- ...ex_1_1parser_1_1basic__branch-members.html | 6 +- classstdex_1_1parser_1_1basic__branch.html | 88 +- ...r_1_1basic__chemical__formula-members.html | 6 +- ...1_1parser_1_1basic__chemical__formula.html | 74 +- ...sstdex_1_1parser_1_1basic__cu-members.html | 6 +- classstdex_1_1parser_1_1basic__cu.html | 61 +- ...x_1_1parser_1_1basic__cu__set-members.html | 6 +- classstdex_1_1parser_1_1basic__cu__set.html | 72 +- ...tdex_1_1parser_1_1basic__date-members.html | 6 +- classstdex_1_1parser_1_1basic__date.html | 80 +- ...r_1_1basic__dns__domain__char-members.html | 6 +- ...1_1parser_1_1basic__dns__domain__char.html | 63 +- ...1_1parser_1_1basic__dns__name-members.html | 6 +- classstdex_1_1parser_1_1basic__dns__name.html | 63 +- ...rser_1_1basic__email__address-members.html | 6 +- ...ex_1_1parser_1_1basic__email__address.html | 74 +- ..._1_1parser_1_1basic__emoticon-members.html | 6 +- classstdex_1_1parser_1_1basic__emoticon.html | 70 +- ...stdex_1_1parser_1_1basic__eol-members.html | 6 +- classstdex_1_1parser_1_1basic__eol.html | 59 +- ..._1_1parser_1_1basic__fraction-members.html | 6 +- classstdex_1_1parser_1_1basic__fraction.html | 66 +- ...x_1_1parser_1_1basic__integer-members.html | 6 +- classstdex_1_1parser_1_1basic__integer.html | 49 +- ...1_1parser_1_1basic__integer10-members.html | 6 +- classstdex_1_1parser_1_1basic__integer10.html | 84 +- ...1parser_1_1basic__integer10ts-members.html | 6 +- ...stdex_1_1parser_1_1basic__integer10ts.html | 82 +- ...1_1parser_1_1basic__integer16-members.html | 6 +- classstdex_1_1parser_1_1basic__integer16.html | 96 +- ...arser_1_1basic__ipv4__address-members.html | 6 +- ...dex_1_1parser_1_1basic__ipv4__address.html | 90 +- ...arser_1_1basic__ipv6__address-members.html | 6 +- ...dex_1_1parser_1_1basic__ipv6__address.html | 106 +- ...1basic__ipv6__scope__id__char-members.html | 6 +- ...arser_1_1basic__ipv6__scope__id__char.html | 55 +- ..._1parser_1_1basic__iterations-members.html | 6 +- ...sstdex_1_1parser_1_1basic__iterations.html | 69 +- ...parser_1_1basic__json__string-members.html | 6 +- ...tdex_1_1parser_1_1basic__json__string.html | 84 +- ...rser_1_1basic__mixed__numeral-members.html | 6 +- ...ex_1_1parser_1_1basic__mixed__numeral.html | 72 +- ...r_1_1basic__monetary__numeral-members.html | 6 +- ...1_1parser_1_1basic__monetary__numeral.html | 74 +- ...tdex_1_1parser_1_1basic__noop-members.html | 6 +- classstdex_1_1parser_1_1basic__noop.html | 51 +- ...ex_1_1parser_1_1basic__parser-members.html | 6 +- classstdex_1_1parser_1_1basic__parser.html | 36 +- ...1parser_1_1basic__permutation-members.html | 6 +- ...stdex_1_1parser_1_1basic__permutation.html | 78 +- ...arser_1_1basic__phone__number-members.html | 6 +- ...dex_1_1parser_1_1basic__phone__number.html | 74 +- ...1_1parser_1_1basic__punct__cu-members.html | 6 +- classstdex_1_1parser_1_1basic__punct__cu.html | 59 +- ...rser_1_1basic__roman__numeral-members.html | 6 +- ...ex_1_1parser_1_1basic__roman__numeral.html | 82 +- ...1_1basic__scientific__numeral-members.html | 6 +- ...1parser_1_1basic__scientific__numeral.html | 84 +- ...dex_1_1parser_1_1basic__score-members.html | 6 +- classstdex_1_1parser_1_1basic__score.html | 68 +- ..._1_1parser_1_1basic__sequence-members.html | 6 +- classstdex_1_1parser_1_1basic__sequence.html | 74 +- ...stdex_1_1parser_1_1basic__set-members.html | 6 +- classstdex_1_1parser_1_1basic__set.html | 66 +- ...ser_1_1basic__signed__numeral-members.html | 6 +- ...x_1_1parser_1_1basic__signed__numeral.html | 68 +- ...1_1parser_1_1basic__space__cu-members.html | 6 +- classstdex_1_1parser_1_1basic__space__cu.html | 59 +- ..._1basic__space__or__punct__cu-members.html | 6 +- ...parser_1_1basic__space__or__punct__cu.html | 59 +- ...ex_1_1parser_1_1basic__string-members.html | 6 +- classstdex_1_1parser_1_1basic__string.html | 55 +- ...rser_1_1basic__string__branch-members.html | 6 +- ...ex_1_1parser_1_1basic__string__branch.html | 90 +- ...tdex_1_1parser_1_1basic__time-members.html | 6 +- classstdex_1_1parser_1_1basic__time.html | 72 +- ...stdex_1_1parser_1_1basic__url-members.html | 6 +- classstdex_1_1parser_1_1basic__url.html | 92 +- ...1_1basic__url__password__char-members.html | 6 +- ...1parser_1_1basic__url__password__char.html | 55 +- ...1_1parser_1_1basic__url__path-members.html | 6 +- classstdex_1_1parser_1_1basic__url__path.html | 78 +- ...ser_1_1basic__url__path__char-members.html | 6 +- ...x_1_1parser_1_1basic__url__path__char.html | 55 +- ...1_1basic__url__username__char-members.html | 6 +- ...1parser_1_1basic__url__username__char.html | 55 +- ...tdex_1_1parser_1_1http__agent-members.html | 6 +- classstdex_1_1parser_1_1http__agent.html | 56 +- ..._1_1parser_1_1http__any__type-members.html | 6 +- classstdex_1_1parser_1_1http__any__type.html | 45 +- ...x_1_1parser_1_1http__asterisk-members.html | 6 +- classstdex_1_1parser_1_1http__asterisk.html | 45 +- ...dex_1_1parser_1_1http__cookie-members.html | 6 +- classstdex_1_1parser_1_1http__cookie.html | 56 +- ...er_1_1http__cookie__parameter-members.html | 6 +- ..._1_1parser_1_1http__cookie__parameter.html | 54 +- ...dex_1_1parser_1_1http__header-members.html | 6 +- classstdex_1_1parser_1_1http__header.html | 58 +- ...x_1_1parser_1_1http__language-members.html | 6 +- classstdex_1_1parser_1_1http__language.html | 52 +- ..._1parser_1_1http__line__break-members.html | 6 +- ...sstdex_1_1parser_1_1http__line__break.html | 45 +- ...1parser_1_1http__media__range-members.html | 6 +- ...stdex_1_1parser_1_1http__media__range.html | 54 +- ..._1parser_1_1http__media__type-members.html | 6 +- ...sstdex_1_1parser_1_1http__media__type.html | 60 +- ..._1_1parser_1_1http__parameter-members.html | 6 +- classstdex_1_1parser_1_1http__parameter.html | 54 +- ...x_1_1parser_1_1http__protocol-members.html | 6 +- classstdex_1_1parser_1_1http__protocol.html | 68 +- ...arser_1_1http__quoted__string-members.html | 6 +- ...dex_1_1parser_1_1http__quoted__string.html | 54 +- ...ex_1_1parser_1_1http__request-members.html | 6 +- classstdex_1_1parser_1_1http__request.html | 62 +- ...tdex_1_1parser_1_1http__space-members.html | 6 +- classstdex_1_1parser_1_1http__space.html | 47 +- ...1_1parser_1_1http__text__char-members.html | 6 +- classstdex_1_1parser_1_1http__text__char.html | 47 +- ...tdex_1_1parser_1_1http__token-members.html | 6 +- classstdex_1_1parser_1_1http__token.html | 45 +- ...sstdex_1_1parser_1_1http__url-members.html | 6 +- classstdex_1_1parser_1_1http__url.html | 60 +- ...arser_1_1http__url__parameter-members.html | 6 +- ...dex_1_1parser_1_1http__url__parameter.html | 56 +- ..._1_1parser_1_1http__url__path-members.html | 6 +- classstdex_1_1parser_1_1http__url__path.html | 50 +- ...r_1_1http__url__path__segment-members.html | 6 +- ...1_1parser_1_1http__url__path__segment.html | 45 +- ..._1_1parser_1_1http__url__port-members.html | 6 +- classstdex_1_1parser_1_1http__url__port.html | 56 +- ..._1parser_1_1http__url__server-members.html | 6 +- ...sstdex_1_1parser_1_1http__url__server.html | 45 +- ...tdex_1_1parser_1_1http__value-members.html | 6 +- classstdex_1_1parser_1_1http__value.html | 52 +- ...er_1_1http__value__collection-members.html | 6 +- ..._1_1parser_1_1http__value__collection.html | 12 +- ...dex_1_1parser_1_1http__weight-members.html | 6 +- classstdex_1_1parser_1_1http__weight.html | 56 +- ...rser_1_1http__weighted__value-members.html | 6 +- ...ex_1_1parser_1_1http__weighted__value.html | 66 +- ...1parser_1_1parser__collection-members.html | 6 +- ...stdex_1_1parser_1_1parser__collection.html | 55 +- ...ex_1_1parser_1_1sgml__any__cp-members.html | 6 +- classstdex_1_1parser_1_1sgml__any__cp.html | 59 +- classstdex_1_1parser_1_1sgml__cp-members.html | 6 +- classstdex_1_1parser_1_1sgml__cp.html | 55 +- ...ex_1_1parser_1_1sgml__cp__set-members.html | 6 +- classstdex_1_1parser_1_1sgml__cp__set.html | 70 +- ...er_1_1sgml__dns__domain__char-members.html | 6 +- ..._1_1parser_1_1sgml__dns__domain__char.html | 67 +- ..._1sgml__ipv6__scope__id__char-members.html | 6 +- ...parser_1_1sgml__ipv6__scope__id__char.html | 49 +- ..._1_1parser_1_1sgml__punct__cp-members.html | 6 +- classstdex_1_1parser_1_1sgml__punct__cp.html | 63 +- ..._1_1parser_1_1sgml__space__cp-members.html | 6 +- classstdex_1_1parser_1_1sgml__space__cp.html | 63 +- ...1_1sgml__space__or__punct__cp-members.html | 6 +- ...1parser_1_1sgml__space__or__punct__cp.html | 63 +- ...dex_1_1parser_1_1sgml__string-members.html | 6 +- classstdex_1_1parser_1_1sgml__string.html | 51 +- ..._1_1sgml__url__password__char-members.html | 6 +- ..._1parser_1_1sgml__url__password__char.html | 59 +- ...rser_1_1sgml__url__path__char-members.html | 6 +- ...ex_1_1parser_1_1sgml__url__path__char.html | 59 +- ..._1_1sgml__url__username__char-members.html | 6 +- ..._1parser_1_1sgml__url__username__char.html | 59 +- classstdex_1_1progress-members.html | 6 +- classstdex_1_1progress.html | 16 +- classstdex_1_1progress__switcher-members.html | 6 +- classstdex_1_1progress__switcher.html | 53 +- classstdex_1_1ring-members.html | 6 +- classstdex_1_1ring.html | 38 +- ...ex_1_1stream_1_1async__reader-members.html | 6 +- classstdex_1_1stream_1_1async__reader.html | 149 +- ...ex_1_1stream_1_1async__writer-members.html | 6 +- classstdex_1_1stream_1_1async__writer.html | 152 +- classstdex_1_1stream_1_1basic-members.html | 6 +- classstdex_1_1stream_1_1basic.html | 118 +- ...tdex_1_1stream_1_1basic__file-members.html | 6 +- classstdex_1_1stream_1_1basic__file.html | 156 +- ...stdex_1_1stream_1_1basic__sys-members.html | 6 +- classstdex_1_1stream_1_1basic__sys.html | 155 +- classstdex_1_1stream_1_1buffer-members.html | 6 +- classstdex_1_1stream_1_1buffer.html | 159 +- ...ex_1_1stream_1_1buffered__sys-members.html | 6 +- classstdex_1_1stream_1_1buffered__sys.html | 163 +- classstdex_1_1stream_1_1cache-members.html | 6 +- classstdex_1_1stream_1_1cache.html | 226 +- ...dex_1_1stream_1_1cached__file-members.html | 10 +- classstdex_1_1stream_1_1cached__file.html | 254 +- ...sstdex_1_1stream_1_1converter-members.html | 6 +- classstdex_1_1stream_1_1converter.html | 138 +- ...stdex_1_1stream_1_1diag__file-members.html | 6 +- classstdex_1_1stream_1_1diag__file.html | 192 +- classstdex_1_1stream_1_1fifo-members.html | 6 +- classstdex_1_1stream_1_1fifo.html | 137 +- classstdex_1_1stream_1_1file-members.html | 10 +- classstdex_1_1stream_1_1file.html | 255 +- ...dex_1_1stream_1_1file__window-members.html | 6 +- classstdex_1_1stream_1_1file__window.html | 197 +- classstdex_1_1stream_1_1limiter-members.html | 6 +- classstdex_1_1stream_1_1limiter.html | 150 +- ...dex_1_1stream_1_1memory__file-members.html | 12 +- classstdex_1_1stream_1_1memory__file.html | 343 +- ...stdex_1_1stream_1_1replicator-members.html | 6 +- classstdex_1_1stream_1_1replicator.html | 135 +- ...tream_1_1replicator_1_1worker-members.html | 6 +- ...dex_1_1stream_1_1replicator_1_1worker.html | 28 +- classstdex_1_1stream_1_1window-members.html | 6 +- classstdex_1_1stream_1_1window.html | 162 +- classstdex_1_1sys__object-members.html | 6 +- classstdex_1_1sys__object.html | 28 +- classstdex_1_1user__cancelled-members.html | 6 +- classstdex_1_1user__cancelled.html | 8 +- classstdex_1_1vector__queue-members.html | 6 +- classstdex_1_1vector__queue.html | 84 +- dir_4be4f7b278e009bf0f1906cf31fb73bd.html | 6 +- dir_d44c64559bbebec7f509842c48db8b23.html | 6 +- dir_fca3c47b2ea228727bd6729832f89576.html | 6 +- doxygen.css | 34 +- dynsections.js | 69 + endian_8hpp_source.html | 11 +- errno_8hpp_source.html | 23 +- exception_8hpp_source.html | 15 +- files.html | 6 +- functions.html | 6 +- functions_b.html | 6 +- functions_c.html | 8 +- functions_d.html | 6 +- functions_e.html | 6 +- functions_f.html | 8 +- functions_func.html | 6 +- functions_func_b.html | 6 +- functions_func_c.html | 8 +- functions_func_d.html | 6 +- functions_func_e.html | 6 +- functions_func_f.html | 8 +- functions_func_g.html | 6 +- functions_func_h.html | 6 +- functions_func_i.html | 6 +- functions_func_l.html | 8 +- functions_func_m.html | 6 +- functions_func_n.html | 6 +- functions_func_o.html | 8 +- functions_func_p.html | 6 +- functions_func_q.html | 6 +- functions_func_r.html | 6 +- functions_func_s.html | 8 +- functions_func_t.html | 6 +- functions_func_u.html | 6 +- functions_func_v.html | 6 +- functions_func_w.html | 6 +- functions_func_~.html | 6 +- functions_g.html | 6 +- functions_h.html | 6 +- functions_i.html | 6 +- functions_l.html | 8 +- functions_m.html | 6 +- functions_n.html | 6 +- functions_o.html | 8 +- functions_p.html | 6 +- functions_q.html | 6 +- functions_r.html | 6 +- functions_s.html | 8 +- functions_t.html | 6 +- functions_type.html | 6 +- functions_u.html | 6 +- functions_v.html | 6 +- functions_vars.html | 6 +- functions_w.html | 6 +- functions_~.html | 6 +- hex_8hpp_source.html | 29 +- hierarchy.html | 6 +- idrec_8hpp_source.html | 25 +- index.html | 6 +- interval_8hpp_source.html | 13 +- mapping_8hpp_source.html | 13 +- math_8hpp_source.html | 11 +- memory_8hpp_source.html | 15 +- minus.svg | 8 + minusd.svg | 8 + parser_8hpp_source.html | 4517 +++++++++-------- pch_8h_source.html | 11 +- plus.svg | 9 + plusd.svg | 9 + progress_8hpp_source.html | 55 +- ring_8hpp_source.html | 25 +- sal_8hpp_source.html | 11 +- search/all_1.js | 2 +- search/all_10.js | 2 +- search/all_2.js | 2 +- search/all_4.js | 2 +- search/all_5.js | 2 +- search/all_6.js | 2 +- search/all_7.js | 4 +- search/all_8.js | 2 +- search/all_9.js | 4 +- search/all_a.js | 4 +- search/all_c.js | 2 +- search/functions_10.js | 2 +- search/functions_2.js | 2 +- search/functions_5.js | 2 +- search/functions_9.js | 2 +- search/functions_a.js | 2 +- search/functions_c.js | 2 +- search/search.js | 20 + sgml_8hpp_source.html | 11 +- sgml__unicode_8hpp_source.html | 11 +- stream_8hpp_source.html | 381 +- string_8hpp_source.html | 15 +- ...stdex_1_1chrono_1_1aosn__date-members.html | 6 +- structstdex_1_1chrono_1_1aosn__date.html | 32 +- ..._1_1chrono_1_1aosn__timestamp-members.html | 6 +- structstdex_1_1chrono_1_1aosn__timestamp.html | 60 +- ...stdex_1_1free__locale__delete-members.html | 6 +- structstdex_1_1free__locale__delete.html | 8 +- structstdex_1_1interval-members.html | 6 +- structstdex_1_1interval.html | 28 +- structstdex_1_1mapping-members.html | 6 +- structstdex_1_1mapping.html | 20 +- structstdex_1_1no__delete-members.html | 6 +- structstdex_1_1no__delete.html | 10 +- ..._1_1no__delete_3_01_t_0f_0e_4-members.html | 6 +- structstdex_1_1no__delete_3_01_t_0f_0e_4.html | 10 +- ...1parser_1_1http__factor__more-members.html | 6 +- ...stdex_1_1parser_1_1http__factor__more.html | 10 +- ...stream_1_1buffer_1_1buffer__t-members.html | 6 +- ...tdex_1_1stream_1_1buffer_1_1buffer__t.html | 16 +- ..._1stream_1_1cache_1_1cache__t-members.html | 6 +- ...tstdex_1_1stream_1_1cache_1_1cache__t.html | 18 +- ..._1_1stream_1_1fifo_1_1node__t-members.html | 6 +- structstdex_1_1stream_1_1fifo_1_1node__t.html | 12 +- system_8hpp_source.html | 279 +- unicode_8hpp_source.html | 11 +- vector__queue_8hpp_source.html | 71 +- 361 files changed, 8214 insertions(+), 8076 deletions(-) create mode 100644 minus.svg create mode 100644 minusd.svg create mode 100644 plus.svg create mode 100644 plusd.svg diff --git a/annotated.html b/annotated.html index dec32e993..6a4599c2e 100644 --- a/annotated.html +++ b/annotated.html @@ -3,7 +3,7 @@ - + stdex: Class List @@ -30,7 +30,7 @@ - + +
14
15namespace stdex
16{
+
21 {
22 public:
+
26 base64_enc() noexcept : num(0)
27 {
28 buf[0] = 0;
29 buf[1] = 0;
30 buf[2] = 0;
31 }
+
32
33
42 template<class _Elem, class _Traits, class _Ax>
+
43 void encode(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &out, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ bool is_last = true)
44 {
45 assert(data || !size);
@@ -131,22 +140,28 @@ $(function() {
66 num = 0;
67 }
68 }
+
69
70
+
74 void clear() noexcept
75 {
76 num = 0;
77 }
+
78
79
+
87 size_t enc_size(_In_ size_t size) const noexcept
88 {
89 return ((num + size + 2)/3)*4;
90 }
+
91
92
93 protected:
97 template<class _Elem, class _Traits, class _Ax>
+
98 void encode(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &out)
99 {
100 out += base64_enc_lookup[ buf[0] >> 2 ];
@@ -154,9 +169,11 @@ $(function() {
102 out += base64_enc_lookup[((buf[1] << 2) | (buf[2] >> 6)) & 0x3f];
103 out += base64_enc_lookup[ buf[2] & 0x3f];
104 }
+
105
106
110 template<class _Elem, class _Traits, class _Ax>
+
111 void encode(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &out, _In_ size_t size)
112 {
113 if (size > 0) {
@@ -182,12 +199,14 @@ $(function() {
133 out += '=';
134 }
135 }
+
136
137
138 protected:
139 uint8_t buf[3];
140 size_t num;
141 };
+
142
143
145 static const char base64_enc_lookup[64] = {
@@ -198,9 +217,11 @@ $(function() {
150 };
152
153
+
158 {
159 public:
+
163 base64_dec() noexcept : num(0)
164 {
165 buf[0] = 0;
@@ -208,9 +229,11 @@ $(function() {
167 buf[2] = 0;
168 buf[3] = 0;
169 }
+
170
171
180 template<class _Ty, class _Ax, class _Tchr>
+
181 void decode(_Inout_ std::vector<_Ty, _Ax> &out, _Out_ bool &is_last, _In_z_count_(size) const _Tchr *data, _In_ size_t size)
182 {
183 is_last = false;
@@ -241,22 +264,28 @@ $(function() {
208 num++;
209 }
210 }
+
211
212
+
216 void clear() noexcept
217 {
218 num = 0;
219 }
+
220
221
+
229 size_t dec_size(_In_ size_t size) const noexcept
230 {
231 return ((num + size + 3)/4)*3;
232 }
+
233
234
235 protected:
239 template<class _Ty, class _Ax>
+
240 size_t decode(_Inout_ std::vector<_Ty, _Ax> &out)
241 {
242 out.push_back((_Ty)(((buf[0] << 2) | (buf[1] >> 4)) & 0xff));
@@ -270,12 +299,14 @@ $(function() {
250 } else
251 return 1;
252 }
+
253
254
255 protected:
256 uint8_t buf[4];
257 size_t num;
258 };
+
259
260
262 static const uint8_t base64_dec_lookup[256] = {
@@ -318,7 +349,7 @@ $(function() { diff --git a/chrono_8hpp_source.html b/chrono_8hpp_source.html index 4a9bc6116..290fece49 100644 --- a/chrono_8hpp_source.html +++ b/chrono_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/chrono.hpp Source File @@ -30,7 +30,7 @@ - + +
16namespace stdex {
17 namespace chrono
18 {
+
22 struct aosn_date
23 {
24 using rep = int32_t;
@@ -103,6 +109,7 @@ $(function() {
27 using time_point = std::chrono::time_point<aosn_date>;
28 static constexpr bool is_steady = false;
29
+
33 static time_point now() noexcept
34 {
35#ifdef _WIN32
@@ -115,16 +122,21 @@ $(function() {
42 return from_time_t(t);
43#endif
44 }
+
45
+
49 static __time64_t to_time_t(_In_ const time_point tp) noexcept
50 {
51 return static_cast<__time64_t>(tp.time_since_epoch().count()) * 86400 - 210866803200;
52 }
+
53
+
57 static time_point from_time_t(_In_ __time64_t t) noexcept
58 {
59 return time_point(duration(static_cast<rep>((t + 210866803200) / 86400)));
60 }
+
61
62#ifdef _WIN32
66 static time_point from_system(_In_ const SYSTEMTIME& t) noexcept
@@ -146,12 +158,15 @@ $(function() {
88 return from_system(st);
89 }
90#else
+
94 static time_point from_system(_In_ const struct timespec& t) noexcept
95 {
96 return from_time_t(t.tv_sec);
97 }
+
98#endif
99
+
103 static time_point from_dmy(_In_ uint8_t day, _In_ uint8_t month, _In_ int32_t year) noexcept
104 {
105 int32_t mtmp, ytmp;
@@ -170,7 +185,9 @@ $(function() {
118 int32_t result3 = (153 * mtmp + 2) / 5;
119 return time_point(duration(static_cast<int32_t>(result1) + day + result2 + 1721119L + result3));
120 }
+
121
+
125 static void to_dmy(_In_ const time_point tp, _Out_opt_ uint8_t* day, _Out_opt_ uint8_t* month, _Out_opt_ int32_t* year) noexcept
126 {
127 int32_t mtmp = tp.time_since_epoch().count() - 1721119L;
@@ -194,18 +211,25 @@ $(function() {
145 if (month) *month = static_cast<uint8_t>(mo);
146 if (year) *year = yr;
147 }
+
148
+
152 static uint8_t day_of_week(_In_ const time_point tp)
153 {
154 return static_cast<uint8_t>(tp.time_since_epoch().count() % 7);
155 }
+
156
+
160 static uint8_t day_of_week(_In_ uint8_t day, _In_ uint8_t month, _In_ int32_t year)
161 {
162 return static_cast<uint8_t>(from_dmy(day, month, year).time_since_epoch().count() % 7);
163 }
+
164 };
+
165
+
170 {
171 using rep = int64_t;
@@ -226,6 +250,7 @@ $(function() {
186 static constexpr rep p_day = f_day * p_hour; // number of milliseconds per day
187 static constexpr rep p_week = f_week * p_day; // number of milliseconds per week
188
+
192 static time_point now() noexcept
193 {
194#ifdef _WIN32
@@ -238,16 +263,21 @@ $(function() {
201 return from_time_t(t);
202#endif
203 }
+
204
+
208 static __time64_t to_time_t(_In_ const time_point tp) noexcept
209 {
210 return tp.time_since_epoch().count() / p_second - 210866803200;
211 }
+
212
+
216 static time_point from_time_t(_In_ __time64_t t) noexcept
217 {
218 return time_point(duration((static_cast<rep>(t) + 210866803200) * p_second));
219 }
+
220
221#ifdef _WIN32
225 static time_point from_system(_In_ const SYSTEMTIME& t) noexcept
@@ -271,10 +301,12 @@ $(function() {
249 return from_system(st);
250 }
251#else
+
255 static time_point from_system(_In_ const struct timespec& t) noexcept
256 {
257 return from_time_t(t.tv_sec) + t.tv_nsec / 1000;
258 }
+
259#endif
260
261 static void to_system(_In_ time_point tp, _Out_ struct tm& date) noexcept
@@ -294,16 +326,21 @@ $(function() {
275 date.tm_isdst = 0;
276 }
277
+
281 static aosn_date::time_point to_date(_In_ time_point tp) noexcept
282 {
283 return aosn_date::time_point(aosn_date::duration(static_cast<aosn_date::rep>(tp.time_since_epoch().count() / p_day)));
284 }
+
285
+
289 static time_point from_date(_In_ aosn_date::time_point date) noexcept
290 {
291 return time_point(duration(static_cast<rep>(date.time_since_epoch().count()) * p_day));
292 }
+
293
+
297 static time_point from_dmy(
298 _In_ uint8_t day, _In_ uint8_t month, _In_ int32_t year,
299 _In_ uint8_t hour, _In_ uint8_t minute, _In_ uint8_t second, _In_ uint16_t millisecond) noexcept
@@ -312,7 +349,9 @@ $(function() {
302 (static_cast<rep>(aosn_date::from_dmy(day, month, year).time_since_epoch().count()) * p_day) +
303 (static_cast<rep>(hour) * p_hour + static_cast<rep>(minute) * p_minute + static_cast<rep>(second) * p_second + millisecond)));
304 }
+
305
+
309 static void to_dmy(_In_ const time_point tp,
310 _Out_opt_ uint8_t* day, _Out_opt_ uint8_t* month, _Out_opt_ int32_t* year,
311 _Out_opt_ uint8_t* hour, _Out_opt_ uint8_t* minute, _Out_opt_ uint8_t* second, _Out_opt_ uint16_t* millisecond) noexcept
@@ -327,6 +366,7 @@ $(function() {
320 u = u / f_hour;
321 if (hour) *hour = static_cast<uint8_t>(u);
322 }
+
323
324 template<class _Traits = std::char_traits<char>, class _Ax = std::allocator<char>>
325 static std::basic_string<char, _Traits, _Ax> to_str(_In_ const time_point tp, _In_z_ const char* format, _In_opt_ locale_t locale)
@@ -400,6 +440,7 @@ $(function() {
393 return to_str(tp, "%a, %d %b %Y %H:%M:%S GMT", locale_C.get());
394 }
395 };
+
396 }
397}
AOsn date.
Definition chrono.hpp:23
@@ -423,7 +464,7 @@ $(function() { diff --git a/classes.html b/classes.html index 295c0b1e3..97537f538 100644 --- a/classes.html +++ b/classes.html @@ -3,7 +3,7 @@ - + stdex: Class Index @@ -30,7 +30,7 @@ - + +
diff --git a/errno_8hpp_source.html b/errno_8hpp_source.html index 4e4571f89..51ae7dfd8 100644 --- a/errno_8hpp_source.html +++ b/errno_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/errno.hpp Source File @@ -30,7 +30,7 @@ - + +
11
12namespace stdex
13{
+
17 class errno_error : public std::runtime_error
18 {
19 public:
+
26 errno_error(_In_ errno_t num, _In_ const std::string& msg) :
27 m_num(num),
28 runtime_error(msg)
29 {
30 }
+
31
+
38 errno_error(_In_ errno_t num, _In_opt_z_ const char *msg = nullptr) :
39 m_num(num),
40 runtime_error(msg)
41 {
42 }
+
43
+
49 errno_error(_In_ const std::string& msg) :
50 m_num(errno),
51 runtime_error(msg)
52 {
53 }
+
54
+
60 errno_error(_In_opt_z_ const char *msg = nullptr) :
61 m_num(errno),
62 runtime_error(msg)
63 {
64 }
+
65
+
69 errno_t number() const
70 {
71 return m_num;
72 }
+
73
74 protected:
75 errno_t m_num;
76 };
+
77}
Standard C runtime library error.
Definition errno.hpp:18
errno_t m_num
Numeric error code.
Definition errno.hpp:75
@@ -136,7 +153,7 @@ $(function() { diff --git a/exception_8hpp_source.html b/exception_8hpp_source.html index 37adbc484..2db55f09e 100644 --- a/exception_8hpp_source.html +++ b/exception_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/exception.hpp Source File @@ -30,7 +30,7 @@ - + +
10
11namespace stdex
12{
+
16 class user_cancelled : public std::exception
17 {
18 public:
+
24 user_cancelled(_In_opt_z_ const char *msg = nullptr) : exception(msg)
25 {
26 }
+
27 };
+
28}
User cancelled exception.
Definition exception.hpp:17
user_cancelled(const char *msg=nullptr)
Constructs an exception.
Definition exception.hpp:24
diff --git a/files.html b/files.html index ffd58a392..983c60cae 100644 --- a/files.html +++ b/files.html @@ -3,7 +3,7 @@ - + stdex: File List @@ -30,7 +30,7 @@ - + +
14
15namespace stdex
16{
+
20 class hex_enc
21 {
22 public:
+
26 hex_enc() noexcept
27 {
28 }
+
29
30
38 template<class _Elem, class _Traits, class _Ax>
+
39 void encode(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &out, _In_bytecount_(size) const void *data, _In_ size_t size)
40 {
41 assert(data || !size);
@@ -120,26 +129,34 @@ $(function() {
54 out += x_l < 10 ? '0' + x_l : 'A' - 10 + x_l;
55 }
56 }
+
57
58
+
66 size_t enc_size(_In_ size_t size) const noexcept
67 {
68 return size*2;
69 }
+
70 };
+
71
72
+
76 class hex_dec
77 {
78 public:
+
82 hex_dec() noexcept :
83 buf(0),
84 num(0)
85 {
86 }
+
87
88
97 template<class _Ty, class _Ax, class _Tchr>
+
98 void decode(_Inout_ std::vector<_Ty, _Ax> &out, _Out_ bool &is_last, _In_z_count_(size) const _Tchr *data, _In_ size_t size)
99 {
100 is_last = false;
@@ -176,24 +193,30 @@ $(function() {
131 }
132 }
133 }
+
134
135
+
139 void clear() noexcept
140 {
141 num = 0;
142 }
+
143
144
+
152 size_t dec_size(_In_ size_t size) const noexcept
153 {
154 return (size + 1)/2;
155 }
+
156
157
158 protected:
159 uint8_t buf;
160 size_t num;
161 };
+
162}
Hexadecimal decoding session.
Definition hex.hpp:77
void clear() noexcept
Resets decoding session.
Definition hex.hpp:139
@@ -209,7 +232,7 @@ $(function() { diff --git a/hierarchy.html b/hierarchy.html index 25cbc6fdd..16ab3a00e 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -3,7 +3,7 @@ - + stdex: Class Hierarchy @@ -30,7 +30,7 @@ - + +
152
153
157 template <class T, class T_ID, const T_ID ID, class T_SIZE, unsigned int ALIGN>
+
158 class record
159 {
160 public:
@@ -193,39 +199,50 @@ $(function() {
174 record(_In_ const T &d) : data((T&)d) {}
175
176
+
180 static const T_ID id()
181 {
182 return ID;
183 }
+
184
185
+
194 {
-
195 data = r.data;
+
195 data = r.data;
196 return *this;
197 }
+
198
199
+
207 static std::streamoff open(_In_ std::ostream& stream)
208 {
209 return stdex::idrec::open<T_ID, T_SIZE>(stream, ID);
210 }
+
211
212
+
221 static std::streamoff close(_In_ std::ostream& stream, _In_ std::streamoff start)
222 {
223 return stdex::idrec::close<T_ID, T_SIZE, ALIGN>(stream, start);
224 }
+
225
226
+
237 static bool find(_In_ std::istream& stream, _In_opt_ std::streamoff end = (std::streamoff)-1)
238 {
239 return stdex::idrec::find<T_ID, T_SIZE, ALIGN>(stream, ID, end);
240 }
+
241
242
243 T &data;
244 };
+
245 };
246};
247
@@ -275,7 +292,7 @@ $(function() { diff --git a/index.html b/index.html index 417b12b31..e3acee03e 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + stdex: Main Page @@ -30,7 +30,7 @@ - + +
11namespace stdex
12{
16 template <class T>
+
17 struct interval
18 {
@@ -113,6 +119,7 @@ $(function() {
80
88 inline bool contains(_In_ T x) const { return start <= x && x < end; }
89 };
+
90
91 template <class T, class _Alloc = std::allocator<interval<T>>>
92 using interval_vector = std::vector<interval<T>, _Alloc>;
@@ -131,7 +138,7 @@ $(function() { diff --git a/mapping_8hpp_source.html b/mapping_8hpp_source.html index d6af2540d..9c7a5095f 100644 --- a/mapping_8hpp_source.html +++ b/mapping_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/mapping.hpp Source File @@ -30,7 +30,7 @@ - + +
11namespace stdex
12{
16 template <class T>
+
17 struct mapping {
18 T from; // index in source string
19 T to; // index in destination string
@@ -104,6 +110,7 @@ $(function() {
49
57 inline bool operator!=(const mapping& other) const { return !operator==(other); }
58 };
+
59
60 template <class T, class _Alloc = std::allocator<mapping<T>>>
61 using mapping_vector = std::vector<mapping<T>, _Alloc>;
@@ -117,7 +124,7 @@ $(function() { diff --git a/math_8hpp_source.html b/math_8hpp_source.html index c2d0ee7af..65e6c0a81 100644 --- a/math_8hpp_source.html +++ b/math_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/math.hpp Source File @@ -30,7 +30,7 @@ - + +
diff --git a/memory_8hpp_source.html b/memory_8hpp_source.html index a3d3521fa..c9665eeea 100644 --- a/memory_8hpp_source.html +++ b/memory_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/memory.hpp Source File @@ -30,7 +30,7 @@ - + +
10namespace stdex
11{
15 template <class T>
+
16 struct no_delete {
17 constexpr no_delete() noexcept = default;
18
@@ -97,8 +103,10 @@ $(function() {
21
22 inline void operator()(T* p) const noexcept { p; }
23 };
+
24
28 template <class T>
+
29 struct no_delete<T[]> {
30 constexpr no_delete() noexcept = default;
31
@@ -108,6 +116,7 @@ $(function() {
35 template <class _Uty, std::enable_if_t<std::is_convertible_v<_Uty(*)[], T(*)[]>, int> = 0>
36 inline void operator()(_Uty* p) const noexcept { p; }
37 };
+
38
47 template <class T>
48 inline std::shared_ptr<T> make_shared_no_delete(_In_ T* p)
@@ -119,7 +128,7 @@ $(function() { diff --git a/minus.svg b/minus.svg new file mode 100644 index 000000000..f70d0c1a1 --- /dev/null +++ b/minus.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/minusd.svg b/minusd.svg new file mode 100644 index 000000000..5f8e87962 --- /dev/null +++ b/minusd.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/parser_8hpp_source.html b/parser_8hpp_source.html index d6d9812c7..29b68cf5c 100644 --- a/parser_8hpp_source.html +++ b/parser_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/parser.hpp Source File @@ -30,7 +30,7 @@ - + +
61 constexpr int match_multiline = 0x2;
62
66 template <class T>
+
68 {
69 public:
-
70 basic_parser(_In_ const std::locale& locale = std::locale()) : m_locale(locale) {}
+
70 basic_parser(_In_ const std::locale& locale = std::locale()) : m_locale(locale) {}
71 virtual ~basic_parser() {}
72
73 bool search(
-
74 _In_reads_or_z_(end) const T* text,
-
75 _In_ size_t start = 0,
-
76 _In_ size_t end = (size_t)-1,
-
77 _In_ int flags = match_default)
+
74 _In_reads_or_z_(end) const T* text,
+
75 _In_ size_t start = 0,
+
76 _In_ size_t end = (size_t)-1,
+
77 _In_ int flags = match_default)
78 {
-
79 for (size_t i = start; i < end && text[i]; i++)
-
80 if (match(text, i, end, flags))
+
79 for (size_t i = start; i < end && text[i]; i++)
+
80 if (match(text, i, end, flags))
81 return true;
82 return false;
83 }
84
85 virtual bool match(
-
86 _In_reads_or_z_(end) const T* text,
-
87 _In_ size_t start = 0,
-
88 _In_ size_t end = (size_t)-1,
-
89 _In_ int flags = match_default) = 0;
+
86 _In_reads_or_z_(end) const T* text,
+
87 _In_ size_t start = 0,
+
88 _In_ size_t end = (size_t)-1,
+
89 _In_ int flags = match_default) = 0;
90
91 template<class _Traits, class _Ax>
92 inline bool match(
-
93 const std::basic_string<T, _Traits, _Ax>& text,
-
94 _In_ size_t start = 0,
-
95 _In_ size_t end = (size_t)-1,
-
96 _In_ int flags = match_default)
+
93 const std::basic_string<T, _Traits, _Ax>& text,
+
94 _In_ size_t start = 0,
+
95 _In_ size_t end = (size_t)-1,
+
96 _In_ int flags = match_default)
97 {
-
98 return match(text.c_str(), start, std::min<size_t>(end, text.size()), flags);
+
98 return match(text.c_str(), start, std::min<size_t>(end, text.size()), flags);
99 }
100
101 virtual void invalidate()
@@ -178,90 +184,92 @@ $(function() {
105 }
106
107 protected:
-
109 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 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])
110 {
-
111 if (text[start] == '&') {
+
111 if (text[start] == '&') {
112 // Potential entity start
-
113 const auto& ctype = std::use_facet<std::ctype<T>>(m_locale);
-
114 for (chr_end = start + 1;; chr_end++) {
-
115 if (chr_end >= end || text[chr_end] == 0) {
+
113 const auto& ctype = std::use_facet<std::ctype<T>>(m_locale);
+
114 for (chr_end = start + 1;; chr_end++) {
+
115 if (chr_end >= end || text[chr_end] == 0) {
116 // Unterminated entity
117 break;
118 }
-
119 if (text[chr_end] == ';') {
+
119 if (text[chr_end] == ';') {
120 // Entity end
-
121 size_t n = chr_end - start - 1;
-
122 if (n >= 2 && text[start + 1] == '#') {
+
121 size_t n = chr_end - start - 1;
+
122 if (n >= 2 && text[start + 1] == '#') {
123 // Numerical entity
-
124 char32_t unicode;
-
125 if (text[start + 2] == 'x' || text[start + 2] == 'X')
-
126 unicode = strtou32(text + start + 3, n - 2, nullptr, 16);
+
124 char32_t unicode;
+
125 if (text[start + 2] == 'x' || text[start + 2] == 'X')
+
126 unicode = strtou32(text + start + 3, n - 2, nullptr, 16);
127 else
-
128 unicode = strtou32(text + start + 2, n - 1, nullptr, 10);
+
128 unicode = strtou32(text + start + 2, n - 1, nullptr, 10);
129#ifdef _WIN32
-
130 if (unicode < 0x10000) {
-
131 buf[0] = (wchar_t)unicode;
+
130 if (unicode < 0x10000) {
+
131 buf[0] = (wchar_t)unicode;
132 buf[1] = 0;
133 }
134 else {
-
135 ucs4_to_surrogate_pair(buf, unicode);
+
135 ucs4_to_surrogate_pair(buf, unicode);
136 buf[2] = 0;
137 }
138#else
-
139 buf[0] = (wchar_t)unicode;
+
139 buf[0] = (wchar_t)unicode;
140 buf[1] = 0;
141#endif
-
142 chr_end++;
+
142 chr_end++;
143 return buf;
144 }
-
145 const wchar_t* entity_w = sgml2uni(text + start + 1, n);
-
146 if (entity_w) {
-
147 chr_end++;
-
148 return entity_w;
+
145 const wchar_t* entity_w = sgml2uni(text + start + 1, n);
+
146 if (entity_w) {
+
147 chr_end++;
+
148 return entity_w;
149 }
150 // Unknown entity.
151 break;
152 }
-
153 else if (text[chr_end] == '&' || ctype.is(ctype.space, text[chr_end])) {
+
153 else if (text[chr_end] == '&' || ctype.is(ctype.space, text[chr_end])) {
154 // This char cannot possibly be a part of entity.
155 break;
156 }
157 }
158 }
-
159 buf[0] = text[start];
+
159 buf[0] = text[start];
160 buf[1] = 0;
-
161 chr_end = start + 1;
+
161 chr_end = start + 1;
162 return buf;
163 }
165
166 public:
- +
168
169 protected:
170 std::locale m_locale;
171 };
+
172
-
173 using parser = basic_parser<char>;
-
174 using wparser = basic_parser<wchar_t>;
+
173 using parser = basic_parser<char>;
+
174 using wparser = basic_parser<wchar_t>;
175#ifdef _UNICODE
-
176 using tparser = wparser;
+
176 using tparser = wparser;
177#else
178 using tparser = parser;
179#endif
-
180 using sgml_parser = basic_parser<char>;
+
180 using sgml_parser = basic_parser<char>;
181
185 template <class T>
+
186 class basic_noop : public basic_parser<T>
187 {
188 public:
189 virtual bool match(
-
190 _In_reads_or_z_(end) const T* text,
-
191 _In_ size_t start = 0,
-
192 _In_ size_t end = (size_t)-1,
-
193 _In_ int flags = match_default)
+
190 _In_reads_or_z_(end) const T* text,
+
191 _In_ size_t start = 0,
+
192 _In_ size_t end = (size_t)-1,
+
193 _In_ int flags = match_default)
194 {
-
195 assert(text || start >= end);
-
196 if (start < end && text[start]) {
+
195 assert(text || start >= end);
+
196 if (start < end && text[start]) {
197 interval.start = interval.end = start;
198 return true;
199 }
@@ -269,30 +277,32 @@ $(function() {
201 return false;
202 }
203 };
+
204
-
205 using noop = basic_noop<char>;
-
206 using wnoop = basic_noop<wchar_t>;
+
205 using noop = basic_noop<char>;
+
206 using wnoop = basic_noop<wchar_t>;
207#ifdef _UNICODE
-
208 using tnoop = wnoop;
+
208 using tnoop = wnoop;
209#else
-
210 using tnoop = noop;
+
210 using tnoop = noop;
211#endif
-
212 using sgml_noop = basic_noop<char>;
+
212 using sgml_noop = basic_noop<char>;
213
217 template <class T>
+
218 class basic_any_cu : public basic_parser<T>
219 {
220 public:
-
221 basic_any_cu(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
+
221 basic_any_cu(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
222
223 virtual bool match(
-
224 _In_reads_or_z_(end) const T* text,
-
225 _In_ size_t start = 0,
-
226 _In_ size_t end = (size_t)-1,
-
227 _In_ int flags = match_default)
+
224 _In_reads_or_z_(end) const T* text,
+
225 _In_ size_t start = 0,
+
226 _In_ size_t end = (size_t)-1,
+
227 _In_ int flags = match_default)
228 {
-
229 assert(text || start >= end);
-
230 if (start < end && text[start]) {
+
229 assert(text || start >= end);
+
230 if (start < end && text[start]) {
231 interval.end = (interval.start = start) + 1;
232 return true;
233 }
@@ -300,38 +310,40 @@ $(function() {
235 return false;
236 }
237 };
+
238
-
239 using any_cu = basic_any_cu<char>;
-
240 using wany_cu = basic_any_cu<wchar_t>;
+
239 using any_cu = basic_any_cu<char>;
+
240 using wany_cu = basic_any_cu<wchar_t>;
241#ifdef _UNICODE
-
242 using tany_cu = wany_cu;
+
242 using tany_cu = wany_cu;
243#else
244 using tany_cu = any_cu;
245#endif
246
+
250 class sgml_any_cp : public basic_any_cu<char>
251 {
252 public:
-
253 sgml_any_cp(_In_ const std::locale& locale = std::locale()) : basic_any_cu<char>(locale) {}
+
253 sgml_any_cp(_In_ const std::locale& locale = std::locale()) : basic_any_cu<char>(locale) {}
254
255 virtual bool match(
-
256 _In_reads_or_z_(end) const char* text,
-
257 _In_ size_t start = 0,
-
258 _In_ size_t end = (size_t)-1,
-
259 _In_ int flags = match_default)
+
256 _In_reads_or_z_(end) const char* text,
+
257 _In_ size_t start = 0,
+
258 _In_ size_t end = (size_t)-1,
+
259 _In_ int flags = match_default)
260 {
-
261 assert(text || start >= end);
-
262 if (start < end && text[start]) {
-
263 if (text[start] == '&') {
+
261 assert(text || start >= end);
+
262 if (start < end && text[start]) {
+
263 if (text[start] == '&') {
264 // SGML entity
-
265 const auto& ctype = std::use_facet<std::ctype<char>>(m_locale);
-
266 for (interval.end = start + 1; interval.end < end && text[interval.end]; interval.end++)
-
267 if (text[interval.end] == ';') {
+
265 const auto& ctype = std::use_facet<std::ctype<char>>(m_locale);
+
266 for (interval.end = start + 1; interval.end < end && text[interval.end]; interval.end++)
+
267 if (text[interval.end] == ';') {
268 interval.end++;
269 interval.start = start;
270 return true;
271 }
-
272 else if (text[interval.end] == '&' || ctype.is(ctype.space, text[interval.end]))
+
272 else if (text[interval.end] == '&' || ctype.is(ctype.space, text[interval.end]))
273 break;
274 // Unterminated entity
275 }
@@ -342,33 +354,35 @@ $(function() {
280 return false;
281 }
282 };
+
283
287 template <class T>
+
288 class basic_cu : public basic_parser<T>
289 {
290 public:
-
291 basic_cu(T chr, bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
292 basic_parser<T>(locale),
-
293 m_chr(chr),
-
294 m_invert(invert)
+
291 basic_cu(T chr, bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
292 basic_parser<T>(locale),
+
293 m_chr(chr),
+
294 m_invert(invert)
295 {}
296
297 virtual bool match(
-
298 _In_reads_or_z_(end) const T* text,
-
299 _In_ size_t start = 0,
-
300 _In_ size_t end = (size_t)-1,
-
301 _In_ int flags = match_default)
+
298 _In_reads_or_z_(end) const T* text,
+
299 _In_ size_t start = 0,
+
300 _In_ size_t end = (size_t)-1,
+
301 _In_ int flags = match_default)
302 {
-
303 assert(text || start >= end);
-
304 if (start < end && text[start]) {
-
305 bool r;
-
306 if (flags & match_case_insensitive) {
-
307 const auto& ctype = std::use_facet<std::ctype<T>>(m_locale);
-
308 r = ctype.tolower(text[start]) == ctype.tolower(m_chr);
+
303 assert(text || start >= end);
+
304 if (start < end && text[start]) {
+
305 bool r;
+
306 if (flags & match_case_insensitive) {
+
307 const auto& ctype = std::use_facet<std::ctype<T>>(m_locale);
+
308 r = ctype.tolower(text[start]) == ctype.tolower(m_chr);
309 }
310 else
-
311 r = text[start] == m_chr;
-
312 if (r && !m_invert || !r && m_invert) {
+
311 r = text[start] == m_chr;
+
312 if (r && !m_invert || !r && m_invert) {
313 interval.end = (interval.start = start) + 1;
314 return true;
315 }
@@ -381,42 +395,44 @@ $(function() {
322 T m_chr;
323 bool m_invert;
324 };
+
325
-
326 using cu = basic_cu<char>;
-
327 using wcu = basic_cu<wchar_t>;
+
326 using cu = basic_cu<char>;
+
327 using wcu = basic_cu<wchar_t>;
328#ifdef _UNICODE
-
329 using tcu = wcu;
+
329 using tcu = wcu;
330#else
-
331 using tcu = cu;
+
331 using tcu = cu;
332#endif
333
+
337 class sgml_cp : public sgml_parser
338 {
339 public:
-
340 sgml_cp(const char* chr, size_t count = (size_t)-1, bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
340 sgml_cp(const char* chr, size_t count = (size_t)-1, bool invert = false, _In_ const std::locale& locale = std::locale()) :
341 sgml_parser(locale),
-
342 m_invert(invert)
+
342 m_invert(invert)
343 {
-
344 assert(chr || !count);
+
344 assert(chr || !count);
345 wchar_t buf[3];
-
346 size_t chr_end;
-
347 m_chr.assign(count ? next_sgml_cp(chr, 0, count, chr_end, buf) : L"");
+
346 size_t chr_end;
+
347 m_chr.assign(count ? next_sgml_cp(chr, 0, count, chr_end, buf) : L"");
348 }
349
350 virtual bool match(
-
351 _In_reads_or_z_(end) const char* text,
-
352 _In_ size_t start = 0,
-
353 _In_ size_t end = (size_t)-1,
-
354 _In_ int flags = match_default)
+
351 _In_reads_or_z_(end) const char* text,
+
352 _In_ size_t start = 0,
+
353 _In_ size_t end = (size_t)-1,
+
354 _In_ int flags = match_default)
355 {
-
356 assert(text || start >= end);
-
357 if (start < end && text[start]) {
+
356 assert(text || start >= end);
+
357 if (start < end && text[start]) {
358 wchar_t buf[3];
-
359 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
360 bool r = ((flags & match_case_insensitive) ?
-
361 stdex::strnicmp(chr, (size_t)-1, m_chr.c_str(), m_chr.size(), m_locale) :
-
362 stdex::strncmp(chr, (size_t)-1, m_chr.c_str(), m_chr.size())) == 0;
-
363 if (r && !m_invert || !r && m_invert) {
+
359 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
360 bool r = ((flags & match_case_insensitive) ?
+
361 stdex::strnicmp(chr, (size_t)-1, m_chr.c_str(), m_chr.size(), m_locale) :
+
362 stdex::strncmp(chr, (size_t)-1, m_chr.c_str(), m_chr.size())) == 0;
+
363 if (r && !m_invert || !r && m_invert) {
364 interval.start = start;
365 return true;
366 }
@@ -429,28 +445,30 @@ $(function() {
373 std::wstring m_chr;
374 bool m_invert;
375 };
+
376
380 template <class T>
+
381 class basic_space_cu : public basic_parser<T>
382 {
383 public:
-
384 basic_space_cu(bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
385 basic_parser<T>(locale),
-
386 m_invert(invert)
+
384 basic_space_cu(bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
385 basic_parser<T>(locale),
+
386 m_invert(invert)
387 {}
388
389 virtual bool match(
-
390 _In_reads_or_z_(end) const T* text,
-
391 _In_ size_t start = 0,
-
392 _In_ size_t end = (size_t)-1,
-
393 _In_ int flags = match_default)
+
390 _In_reads_or_z_(end) const T* text,
+
391 _In_ size_t start = 0,
+
392 _In_ size_t end = (size_t)-1,
+
393 _In_ int flags = match_default)
394 {
-
395 assert(text || start >= end);
-
396 if (start < end && text[start]) {
-
397 bool r =
-
398 ((flags & match_multiline) || !islbreak(text[start])) &&
-
399 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::space, text[start]);
-
400 if (r && !m_invert || !r && m_invert) {
+
395 assert(text || start >= end);
+
396 if (start < end && text[start]) {
+
397 bool r =
+
398 ((flags & match_multiline) || !islbreak(text[start])) &&
+
399 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::space, text[start]);
+
400 if (r && !m_invert || !r && m_invert) {
401 interval.end = (interval.start = start) + 1;
402 return true;
403 }
@@ -462,37 +480,39 @@ $(function() {
409 protected:
410 bool m_invert;
411 };
+
412
-
413 using space_cu = basic_space_cu<char>;
-
414 using wspace_cu = basic_space_cu<wchar_t>;
+
413 using space_cu = basic_space_cu<char>;
+
414 using wspace_cu = basic_space_cu<wchar_t>;
415#ifdef _UNICODE
-
416 using tspace_cu = wspace_cu;
+
416 using tspace_cu = wspace_cu;
417#else
418 using tspace_cu = space_cu;
419#endif
420
+
424 class sgml_space_cp : public basic_space_cu<char>
425 {
426 public:
-
427 sgml_space_cp(_In_ bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
428 basic_space_cu<char>(invert, locale)
+
427 sgml_space_cp(_In_ bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
429 {}
430
431 virtual bool match(
-
432 _In_reads_or_z_(end) const char* text,
-
433 _In_ size_t start = 0,
-
434 _In_ size_t end = (size_t)-1,
-
435 _In_ int flags = match_default)
+
432 _In_reads_or_z_(end) const char* text,
+
433 _In_ size_t start = 0,
+
434 _In_ size_t end = (size_t)-1,
+
435 _In_ int flags = match_default)
436 {
-
437 assert(text || start >= end);
-
438 if (start < end && text[start]) {
+
437 assert(text || start >= end);
+
438 if (start < end && text[start]) {
439 wchar_t buf[3];
-
440 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
441 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
442 bool r =
-
443 ((flags & match_multiline) || !islbreak(chr, (size_t)-1)) &&
-
444 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::space, chr, chr_end) == chr_end;
-
445 if (r && !m_invert || !r && m_invert) {
+
440 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
441 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
442 bool r =
+
443 ((flags & match_multiline) || !islbreak(chr, (size_t)-1)) &&
+
444 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::space, chr, chr_end) == chr_end;
+
445 if (r && !m_invert || !r && m_invert) {
446 interval.start = start;
447 return true;
448 }
@@ -502,26 +522,28 @@ $(function() {
452 return false;
453 }
454 };
+
455
459 template <class T>
+
460 class basic_punct_cu : public basic_parser<T>
461 {
462 public:
-
463 basic_punct_cu(bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
464 basic_parser<T>(locale),
-
465 m_invert(invert)
+
463 basic_punct_cu(bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
464 basic_parser<T>(locale),
+
465 m_invert(invert)
466 {}
467
468 virtual bool match(
-
469 _In_reads_or_z_(end) const T* text,
-
470 _In_ size_t start = 0,
-
471 _In_ size_t end = (size_t)-1,
-
472 _In_ int flags = match_default)
+
469 _In_reads_or_z_(end) const T* text,
+
470 _In_ size_t start = 0,
+
471 _In_ size_t end = (size_t)-1,
+
472 _In_ int flags = match_default)
473 {
-
474 assert(text || start >= end);
-
475 if (start < end && text[start]) {
-
476 bool r = std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::punct, text[start]);
-
477 if (r && !m_invert || !r && m_invert) {
+
474 assert(text || start >= end);
+
475 if (start < end && text[start]) {
+
476 bool r = std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::punct, text[start]);
+
477 if (r && !m_invert || !r && m_invert) {
478 interval.end = (interval.start = start) + 1;
479 return true;
480 }
@@ -533,35 +555,37 @@ $(function() {
486 protected:
487 bool m_invert;
488 };
+
489
-
490 using punct_cu = basic_punct_cu<char>;
-
491 using wpunct_cu = basic_punct_cu<wchar_t>;
+
490 using punct_cu = basic_punct_cu<char>;
+
491 using wpunct_cu = basic_punct_cu<wchar_t>;
492#ifdef _UNICODE
-
493 using tpunct_cu = wpunct_cu;
+
493 using tpunct_cu = wpunct_cu;
494#else
495 using tpunct_cu = punct_cu;
496#endif
497
+
501 class sgml_punct_cp : public basic_punct_cu<char>
502 {
503 public:
-
504 sgml_punct_cp(bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
505 basic_punct_cu<char>(invert, locale)
+
504 sgml_punct_cp(bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
506 {}
507
508 virtual bool match(
-
509 _In_reads_or_z_(end) const char* text,
-
510 _In_ size_t start = 0,
-
511 _In_ size_t end = (size_t)-1,
-
512 _In_ int flags = match_default)
+
509 _In_reads_or_z_(end) const char* text,
+
510 _In_ size_t start = 0,
+
511 _In_ size_t end = (size_t)-1,
+
512 _In_ int flags = match_default)
513 {
-
514 assert(text || start >= end);
-
515 if (start < end && text[start]) {
+
514 assert(text || start >= end);
+
515 if (start < end && text[start]) {
516 wchar_t buf[3];
-
517 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
518 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
519 bool r = std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::punct, chr, chr_end) == chr_end;
-
520 if (r && !m_invert || !r && m_invert) {
+
517 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
518 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
519 bool r = std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::punct, chr, chr_end) == chr_end;
+
520 if (r && !m_invert || !r && m_invert) {
521 interval.start = start;
522 return true;
523 }
@@ -570,28 +594,30 @@ $(function() {
526 return false;
527 }
528 };
+
529
533 template <class T>
+
535 {
536 public:
-
537 basic_space_or_punct_cu(bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
538 basic_parser<T>(locale),
-
539 m_invert(invert)
+
537 basic_space_or_punct_cu(bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
538 basic_parser<T>(locale),
+
539 m_invert(invert)
540 {}
541
542 virtual bool match(
-
543 _In_reads_or_z_(end) const T* text,
-
544 _In_ size_t start = 0,
-
545 _In_ size_t end = (size_t)-1,
-
546 _In_ int flags = match_default)
+
543 _In_reads_or_z_(end) const T* text,
+
544 _In_ size_t start = 0,
+
545 _In_ size_t end = (size_t)-1,
+
546 _In_ int flags = match_default)
547 {
-
548 assert(text || start >= end);
-
549 if (start < end && text[start]) {
-
550 bool r =
-
551 ((flags & match_multiline) || !islbreak(text[start])) &&
-
552 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::space | std::ctype_base::punct, text[start]);
-
553 if (r && !m_invert || !r && m_invert) {
+
548 assert(text || start >= end);
+
549 if (start < end && text[start]) {
+
550 bool r =
+
551 ((flags & match_multiline) || !islbreak(text[start])) &&
+
552 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::space | std::ctype_base::punct, text[start]);
+
553 if (r && !m_invert || !r && m_invert) {
554 interval.end = (interval.start = start) + 1;
555 return true;
556 }
@@ -603,37 +629,39 @@ $(function() {
562 protected:
563 bool m_invert;
564 };
+
565
-
566 using space_or_punct_cu = basic_space_or_punct_cu<char>;
-
567 using wspace_or_punct_cu = basic_space_or_punct_cu<wchar_t>;
+
566 using space_or_punct_cu = basic_space_or_punct_cu<char>;
+
567 using wspace_or_punct_cu = basic_space_or_punct_cu<wchar_t>;
568#ifdef _UNICODE
-
569 using tspace_or_punct_cu = wspace_or_punct_cu;
+
569 using tspace_or_punct_cu = wspace_or_punct_cu;
570#else
571 using tspace_or_punct_cu = space_or_punct_cu;
572#endif
573
+
578 {
579 public:
-
580 sgml_space_or_punct_cp(bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
581 basic_space_or_punct_cu<char>(invert, locale)
+
580 sgml_space_or_punct_cp(bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
582 {}
583
584 virtual bool match(
-
585 _In_reads_or_z_(end) const char* text,
-
586 _In_ size_t start = 0,
-
587 _In_ size_t end = (size_t)-1,
-
588 _In_ int flags = match_default)
+
585 _In_reads_or_z_(end) const char* text,
+
586 _In_ size_t start = 0,
+
587 _In_ size_t end = (size_t)-1,
+
588 _In_ int flags = match_default)
589 {
-
590 assert(text || start >= end);
-
591 if (start < end && text[start]) {
+
590 assert(text || start >= end);
+
591 if (start < end && text[start]) {
592 wchar_t buf[3];
-
593 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
594 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
595 bool r =
-
596 ((flags & match_multiline) || !islbreak(chr, (size_t)-1)) &&
-
597 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::space | std::ctype_base::punct, chr, chr_end) == chr_end;
-
598 if (r && !m_invert || !r && m_invert) {
+
593 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
594 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
595 bool r =
+
596 ((flags & match_multiline) || !islbreak(chr, (size_t)-1)) &&
+
597 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::space | std::ctype_base::punct, chr, chr_end) == chr_end;
+
598 if (r && !m_invert || !r && m_invert) {
599 interval.start = start;
600 return true;
601 }
@@ -642,22 +670,24 @@ $(function() {
604 return false;
605 }
606 };
+
607
611 template <class T>
+
612 class basic_bol : public basic_parser<T>
613 {
614 public:
-
615 basic_bol(bool invert = false) : m_invert(invert) {}
+
615 basic_bol(bool invert = false) : m_invert(invert) {}
616
617 virtual bool match(
-
618 _In_reads_or_z_(end) const T* text,
-
619 _In_ size_t start = 0,
-
620 _In_ size_t end = (size_t)-1,
-
621 _In_ int flags = match_default)
+
618 _In_reads_or_z_(end) const T* text,
+
619 _In_ size_t start = 0,
+
620 _In_ size_t end = (size_t)-1,
+
621 _In_ int flags = match_default)
622 {
-
623 assert(text || start >= end);
-
624 bool r = start == 0 || start <= end && islbreak(text[start - 1]);
-
625 if (r && !m_invert || !r && m_invert) {
+
623 assert(text || start >= end);
+
624 bool r = start == 0 || start <= end && islbreak(text[start - 1]);
+
625 if (r && !m_invert || !r && m_invert) {
626 interval.end = interval.start = start;
627 return true;
628 }
@@ -668,31 +698,33 @@ $(function() {
633 protected:
634 bool m_invert;
635 };
+
636
-
637 using bol = basic_bol<char>;
-
638 using wbol = basic_bol<wchar_t>;
+
637 using bol = basic_bol<char>;
+
638 using wbol = basic_bol<wchar_t>;
639#ifdef _UNICODE
-
640 using tbol = wbol;
+
640 using tbol = wbol;
641#else
-
642 using tbol = bol;
+
642 using tbol = bol;
643#endif
-
644 using sgml_bol = basic_bol<char>;
+
644 using sgml_bol = basic_bol<char>;
645
649 template <class T>
+
650 class basic_eol : public basic_parser<T>
651 {
652 public:
-
653 basic_eol(bool invert = false) : m_invert(invert) {}
+
653 basic_eol(bool invert = false) : m_invert(invert) {}
654
655 virtual bool match(
-
656 _In_reads_or_z_(end) const T* text,
-
657 _In_ size_t start = 0,
-
658 _In_ size_t end = (size_t)-1,
-
659 _In_ int flags = match_default)
+
656 _In_reads_or_z_(end) const T* text,
+
657 _In_ size_t start = 0,
+
658 _In_ size_t end = (size_t)-1,
+
659 _In_ int flags = match_default)
660 {
-
661 assert(text || start >= end);
-
662 bool r = islbreak(text[start]);
-
663 if (r && !m_invert || !r && m_invert) {
+
661 assert(text || start >= end);
+
662 bool r = islbreak(text[start]);
+
663 if (r && !m_invert || !r && m_invert) {
664 interval.end = interval.start = start;
665 return true;
666 }
@@ -703,35 +735,37 @@ $(function() {
671 protected:
672 bool m_invert;
673 };
+
674
-
675 using eol = basic_eol<char>;
-
676 using weol = basic_eol<wchar_t>;
+
675 using eol = basic_eol<char>;
+
676 using weol = basic_eol<wchar_t>;
677#ifdef _UNICODE
-
678 using teol = weol;
+
678 using teol = weol;
679#else
-
680 using teol = eol;
+
680 using teol = eol;
681#endif
-
682 using sgml_eol = basic_eol<char>;
+
682 using sgml_eol = basic_eol<char>;
683
684 template <class T>
+
685 class basic_set : public basic_parser<T>
686 {
687 public:
-
688 basic_set(bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
689 basic_parser<T>(locale),
+
688 basic_set(bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
689 basic_parser<T>(locale),
690 hit_offset((size_t)-1),
-
691 m_invert(invert)
+
691 m_invert(invert)
692 {}
693
694 virtual bool match(
-
695 _In_reads_or_z_(end) const T* text,
-
696 _In_ size_t start = 0,
-
697 _In_ size_t end = (size_t)-1,
-
698 _In_ int flags = match_default) = 0;
+
695 _In_reads_or_z_(end) const T* text,
+
696 _In_ size_t start = 0,
+
697 _In_ size_t end = (size_t)-1,
+
698 _In_ int flags = match_default) = 0;
699
700 virtual void invalidate()
701 {
-
702 hit_offset = (size_t)-1;
+
702 hit_offset = (size_t)-1;
704 }
705
@@ -741,41 +775,43 @@ $(function() {
709 protected:
710 bool m_invert;
711 };
+
712
716 template <class T>
+
717 class basic_cu_set : public basic_set<T>
718 {
719 public:
-
721 _In_reads_or_z_(count) const T* set,
-
722 _In_ size_t count = (size_t)-1,
-
723 _In_ bool invert = false,
-
724 _In_ const std::locale& locale = std::locale()) :
-
725 basic_set<T>(invert, locale)
+
721 _In_reads_or_z_(count) const T* set,
+
722 _In_ size_t count = (size_t)-1,
+
723 _In_ bool invert = false,
+
724 _In_ const std::locale& locale = std::locale()) :
+
725 basic_set<T>(invert, locale)
726 {
727 if (set)
-
728 m_set.assign(set, set + stdex::strnlen(set, count));
+
728 m_set.assign(set, set + stdex::strnlen(set, count));
729 }
730
731 virtual bool match(
-
732 _In_reads_or_z_(end) const T* text,
-
733 _In_ size_t start = 0,
-
734 _In_ size_t end = (size_t)-1,
-
735 _In_ int flags = match_default)
+
732 _In_reads_or_z_(end) const T* text,
+
733 _In_ size_t start = 0,
+
734 _In_ size_t end = (size_t)-1,
+
735 _In_ int flags = match_default)
736 {
-
737 assert(text || start >= end);
-
738 if (start < end && text[start]) {
+
737 assert(text || start >= end);
+
738 if (start < end && text[start]) {
739 const T* set = m_set.c_str();
-
740 size_t r = (flags & match_case_insensitive) ?
-
741 stdex::strnichr(set, m_set.size(), text[start], m_locale) :
-
742 stdex::strnchr(set, m_set.size(), text[start]);
-
743 if (r != stdex::npos && !m_invert || r == stdex::npos && m_invert) {
-
744 hit_offset = r;
+
740 size_t r = (flags & match_case_insensitive) ?
+
741 stdex::strnichr(set, m_set.size(), text[start], m_locale) :
+
742 stdex::strnchr(set, m_set.size(), text[start]);
+
743 if (r != stdex::npos && !m_invert || r == stdex::npos && m_invert) {
+
744 hit_offset = r;
745 interval.end = (interval.start = start) + 1;
746 return true;
747 }
748 }
-
749 hit_offset = (size_t)-1;
+
749 hit_offset = (size_t)-1;
750 interval.start = (interval.end = start) + 1;
751 return false;
752 }
@@ -783,46 +819,48 @@ $(function() {
754 protected:
755 std::basic_string<T> m_set;
756 };
+
757
-
758 using cu_set = basic_cu_set<char>;
-
759 using wcu_set = basic_cu_set<wchar_t>;
+
758 using cu_set = basic_cu_set<char>;
+
759 using wcu_set = basic_cu_set<wchar_t>;
760#ifdef _UNICODE
-
761 using tcu_set = wcu_set;
+
761 using tcu_set = wcu_set;
762#else
-
763 using tcu_set = cu_set;
+
763 using tcu_set = cu_set;
764#endif
765
+
769 class sgml_cp_set : public basic_set<char>
770 {
771 public:
-
772 sgml_cp_set(const char* set, size_t count = (size_t)-1, bool invert = false, _In_ const std::locale& locale = std::locale()) :
-
773 basic_set<char>(invert, locale)
+
772 sgml_cp_set(const char* set, size_t count = (size_t)-1, bool invert = false, _In_ const std::locale& locale = std::locale()) :
+
773 basic_set<char>(invert, locale)
774 {
775 if (set)
-
776 m_set = sgml2wstr(set, count);
+
776 m_set = sgml2wstr(set, count);
777 }
778
779 virtual bool match(
-
780 _In_reads_or_z_(end) const char* text,
-
781 _In_ size_t start = 0,
-
782 _In_ size_t end = (size_t)-1,
-
783 _In_ int flags = match_default)
+
780 _In_reads_or_z_(end) const char* text,
+
781 _In_ size_t start = 0,
+
782 _In_ size_t end = (size_t)-1,
+
783 _In_ int flags = match_default)
784 {
-
785 assert(text || start >= end);
-
786 if (start < end && text[start]) {
+
785 assert(text || start >= end);
+
786 if (start < end && text[start]) {
787 wchar_t buf[3];
-
788 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
788 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
789 const wchar_t* set = m_set.c_str();
-
790 size_t r = (flags & match_case_insensitive) ?
-
791 stdex::strnistr(set, m_set.size(), chr, m_locale) :
-
792 stdex::strnstr(set, m_set.size(), chr);
-
793 if (r != stdex::npos && !m_invert || r == stdex::npos && m_invert) {
-
794 hit_offset = r;
+
790 size_t r = (flags & match_case_insensitive) ?
+
791 stdex::strnistr(set, m_set.size(), chr, m_locale) :
+
792 stdex::strnstr(set, m_set.size(), chr);
+
793 if (r != stdex::npos && !m_invert || r == stdex::npos && m_invert) {
+
794 hit_offset = r;
795 interval.start = start;
796 return true;
797 }
798 }
-
799 hit_offset = (size_t)-1;
+
799 hit_offset = (size_t)-1;
800 interval.start = (interval.end = start) + 1;
801 return false;
802 }
@@ -830,34 +868,36 @@ $(function() {
804 protected:
805 std::wstring m_set;
806 };
+
807
811 template <class T>
+
812 class basic_string : public basic_parser<T>
813 {
814 public:
-
816 _In_reads_or_z_(count) const T* str,
-
817 _In_ size_t count = (size_t)-1,
-
818 _In_ const std::locale& locale = std::locale()) :
-
819 basic_parser<T>(locale),
-
820 m_str(str, str + stdex::strnlen(str, count))
+
816 _In_reads_or_z_(count) const T* str,
+
817 _In_ size_t count = (size_t)-1,
+
818 _In_ const std::locale& locale = std::locale()) :
+
819 basic_parser<T>(locale),
+
820 m_str(str, str + stdex::strnlen(str, count))
821 {}
822
823 virtual bool match(
-
824 _In_reads_or_z_(end) const T* text,
-
825 _In_ size_t start = 0,
-
826 _In_ size_t end = (size_t)-1,
-
827 _In_ int flags = match_default)
+
824 _In_reads_or_z_(end) const T* text,
+
825 _In_ size_t start = 0,
+
826 _In_ size_t end = (size_t)-1,
+
827 _In_ int flags = match_default)
828 {
-
829 assert(text || start >= end);
+
829 assert(text || start >= end);
830 size_t
-
831 m = m_str.size(),
-
832 n = std::min<size_t>(end - start, m);
-
833 bool r = ((flags & match_case_insensitive) ?
-
834 stdex::strnicmp(text + start, n, m_str.c_str(), m, m_locale) :
-
835 stdex::strncmp(text + start, n, m_str.c_str(), m)) == 0;
-
836 if (r) {
-
837 interval.end = (interval.start = start) + n;
+
831 m = m_str.size(),
+
832 n = std::min<size_t>(end - start, m);
+
833 bool r = ((flags & match_case_insensitive) ?
+
834 stdex::strnicmp(text + start, n, m_str.c_str(), m, m_locale) :
+
835 stdex::strncmp(text + start, n, m_str.c_str(), m)) == 0;
+
836 if (r) {
+
837 interval.end = (interval.start = start) + n;
838 return true;
839 }
840 interval.start = (interval.end = start) + 1;
@@ -867,6 +907,7 @@ $(function() {
844 protected:
845 std::basic_string<T> m_str;
846 };
+
847
848 using string = basic_string<char>;
849 using wstring = basic_string<wchar_t>;
@@ -876,38 +917,39 @@ $(function() {
853 using tstring = string;
854#endif
855
+
860 {
861 public:
-
862 sgml_string(const char* str, size_t count = (size_t)-1, _In_ const std::locale& locale = std::locale()) :
+
862 sgml_string(const char* str, size_t count = (size_t)-1, _In_ const std::locale& locale = std::locale()) :
863 sgml_parser(locale),
-
864 m_str(sgml2wstr(str, count))
+
864 m_str(sgml2wstr(str, count))
865 {}
866
867 virtual bool match(
-
868 _In_reads_or_z_(end) const char* text,
-
869 _In_ size_t start = 0,
-
870 _In_ size_t end = (size_t)-1,
-
871 _In_ int flags = match_default)
+
868 _In_reads_or_z_(end) const char* text,
+
869 _In_ size_t start = 0,
+
870 _In_ size_t end = (size_t)-1,
+
871 _In_ int flags = match_default)
872 {
-
873 assert(text || start >= end);
-
874 const wchar_t* str = m_str.c_str();
-
875 const bool case_insensitive = flags & match_case_insensitive ? true : false;
-
876 const auto& ctype = std::use_facet<std::ctype<wchar_t>>(m_locale);
+
873 assert(text || start >= end);
+
874 const wchar_t* str = m_str.c_str();
+
875 const bool case_insensitive = flags & match_case_insensitive ? true : false;
+
876 const auto& ctype = std::use_facet<std::ctype<wchar_t>>(m_locale);
877 for (interval.end = start;;) {
-
878 if (!*str) {
+
878 if (!*str) {
879 interval.start = start;
880 return true;
881 }
-
882 if (interval.end >= end || !text[interval.end]) {
+
882 if (interval.end >= end || !text[interval.end]) {
883 interval.start = (interval.end = start) + 1;
884 return false;
885 }
886 wchar_t buf[3];
-
887 const wchar_t* chr = next_sgml_cp(text, interval.end, end, interval.end, buf);
-
888 for (; *chr; ++str, ++chr) {
-
889 if (!*str ||
-
890 (case_insensitive ? ctype.tolower(*str) != ctype.tolower(*chr) : *str != *chr))
+
887 const wchar_t* chr = next_sgml_cp(text, interval.end, end, interval.end, buf);
+
888 for (; *chr; ++str, ++chr) {
+
889 if (!*str ||
+
890 (case_insensitive ? ctype.tolower(*str) != ctype.tolower(*chr) : *str != *chr))
891 {
892 interval.start = (interval.end = start) + 1;
893 return false;
@@ -919,31 +961,33 @@ $(function() {
899 protected:
900 std::wstring m_str;
901 };
+
902
906 template <class T>
+
908 {
909 public:
-
910 basic_iterations(const std::shared_ptr<basic_parser<T>>& el, size_t min_iterations = 0, size_t max_iterations = (size_t)-1, bool greedy = true) :
-
911 m_el(el),
-
912 m_min_iterations(min_iterations),
-
913 m_max_iterations(max_iterations),
-
914 m_greedy(greedy)
+
910 basic_iterations(const std::shared_ptr<basic_parser<T>>& el, size_t min_iterations = 0, size_t max_iterations = (size_t)-1, bool greedy = true) :
+
911 m_el(el),
+ + +
915 {}
916
917 virtual bool match(
-
918 _In_reads_or_z_(end) const T* text,
-
919 _In_ size_t start = 0,
-
920 _In_ size_t end = (size_t)-1,
-
921 _In_ int flags = match_default)
+
918 _In_reads_or_z_(end) const T* text,
+
919 _In_ size_t start = 0,
+
920 _In_ size_t end = (size_t)-1,
+
921 _In_ int flags = match_default)
922 {
-
923 assert(text || start >= end);
+
923 assert(text || start >= end);
924 interval.start = interval.end = start;
-
925 for (size_t i = 0; ; i++) {
-
926 if (!m_greedy && i >= m_min_iterations || i >= m_max_iterations)
+
925 for (size_t i = 0; ; i++) {
+
927 return true;
-
928 if (!m_el->match(text, interval.end, end, flags)) {
-
929 if (i >= m_min_iterations)
+
928 if (!m_el->match(text, interval.end, end, flags)) {
+
929 if (i >= m_min_iterations)
930 return true;
931 break;
932 }
@@ -963,81 +1007,85 @@ $(function() {
947 bool m_greedy;
948 };
+
949
-
950 using iterations = basic_iterations<char>;
-
951 using witerations = basic_iterations<wchar_t>;
+
950 using iterations = basic_iterations<char>;
+
951 using witerations = basic_iterations<wchar_t>;
952#ifdef _UNICODE
-
953 using titerations = witerations;
+
953 using titerations = witerations;
954#else
-
955 using titerations = iterations;
+
955 using titerations = iterations;
956#endif
-
957 using sgml_iterations = basic_iterations<char>;
+
957 using sgml_iterations = basic_iterations<char>;
958
962 template <class T>
+
964 {
965 protected:
-
966 parser_collection(_In_ const std::locale& locale) : basic_parser<T>(locale) {}
+
966 parser_collection(_In_ const std::locale& locale) : basic_parser<T>(locale) {}
967
968 public:
-
970 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el,
-
971 _In_ size_t count,
-
972 _In_ const std::locale& locale = std::locale()) :
-
973 basic_parser<T>(locale)
+
970 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el,
+
971 _In_ size_t count,
+
972 _In_ const std::locale& locale = std::locale()) :
+
973 basic_parser<T>(locale)
974 {
-
975 assert(el || !count);
-
976 m_collection.reserve(count);
-
977 for (size_t i = 0; i < count; i++)
-
978 m_collection.push_back(el[i]);
+
975 assert(el || !count);
+
976 m_collection.reserve(count);
+
977 for (size_t i = 0; i < count; i++)
+
978 m_collection.push_back(el[i]);
979 }
980
-
982 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
-
983 _In_ const std::locale& locale = std::locale()) :
-
984 basic_parser<T>(locale),
-
985 m_collection(std::move(collection))
+
982 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
+
983 _In_ const std::locale& locale = std::locale()) :
+
984 basic_parser<T>(locale),
+
985 m_collection(std::move(collection))
986 {}
987
988 virtual void invalidate()
989 {
-
990 for (auto& el: m_collection)
-
991 el->invalidate();
+
990 for (auto& el: m_collection)
+
991 el->invalidate();
993 }
994
995 protected:
996 std::vector<std::shared_ptr<basic_parser<T>>> m_collection;
997 };
+
998
1002 template <class T>
+
1004 {
1005 public:
-
1007 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el = nullptr,
-
1008 _In_ size_t count = 0,
-
1009 _In_ const std::locale& locale = std::locale()) :
-
1010 parser_collection<T>(el, count, locale)
+
1007 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el = nullptr,
+
1008 _In_ size_t count = 0,
+
1009 _In_ const std::locale& locale = std::locale()) :
+
1010 parser_collection<T>(el, count, locale)
1011 {}
1012
-
1014 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
-
1015 _In_ const std::locale& locale = std::locale()) :
-
1016 parser_collection<T>(std::move(collection), locale)
+
1014 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
+
1015 _In_ const std::locale& locale = std::locale()) :
+
1016 parser_collection<T>(std::move(collection), locale)
1017 {}
1018
1019 virtual bool match(
-
1020 _In_reads_or_z_(end) const T* text,
-
1021 _In_ size_t start = 0,
-
1022 _In_ size_t end = (size_t)-1,
-
1023 _In_ int flags = match_default)
+
1020 _In_reads_or_z_(end) const T* text,
+
1021 _In_ size_t start = 0,
+
1022 _In_ size_t end = (size_t)-1,
+
1023 _In_ int flags = match_default)
1024 {
-
1025 assert(text || start >= end);
+
1025 assert(text || start >= end);
1026 interval.end = start;
-
1027 for (auto i = m_collection.begin(); i != m_collection.end(); ++i) {
-
1028 if (!(*i)->match(text, interval.end, end, flags)) {
-
1029 for (++i; i != m_collection.end(); ++i)
+
1027 for (auto i = m_collection.begin(); i != m_collection.end(); ++i) {
+
1028 if (!(*i)->match(text, interval.end, end, flags)) {
+
1029 for (++i; i != m_collection.end(); ++i)
1030 (*i)->invalidate();
1031 interval.start = (interval.end = start) + 1;
1032 return false;
@@ -1048,177 +1096,183 @@ $(function() {
1037 return true;
1038 }
1039 };
+
1040
-
1041 using sequence = basic_sequence<char>;
-
1042 using wsequence = basic_sequence<wchar_t>;
+
1041 using sequence = basic_sequence<char>;
+
1042 using wsequence = basic_sequence<wchar_t>;
1043#ifdef _UNICODE
-
1044 using tsequence = wsequence;
+
1044 using tsequence = wsequence;
1045#else
-
1046 using tsequence = sequence;
+
1046 using tsequence = sequence;
1047#endif
-
1048 using sgml_sequence = basic_sequence<char>;
+
1048 using sgml_sequence = basic_sequence<char>;
1049
1053 template <class T>
+
1055 {
1056 protected:
-
1057 basic_branch(_In_ const std::locale& locale) :
-
1058 parser_collection<T>(locale),
+
1057 basic_branch(_In_ const std::locale& locale) :
+
1058 parser_collection<T>(locale),
1059 hit_offset((size_t)-1)
1060 {}
1061
1062 public:
-
1064 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el = nullptr,
-
1065 _In_ size_t count = 0,
-
1066 _In_ const std::locale& locale = std::locale()) :
-
1067 parser_collection<T>(el, count, locale),
+
1064 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el = nullptr,
+
1065 _In_ size_t count = 0,
+
1066 _In_ const std::locale& locale = std::locale()) :
+
1067 parser_collection<T>(el, count, locale),
1068 hit_offset((size_t)-1)
1069 {}
1070
-
1072 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
-
1073 _In_ const std::locale& locale = std::locale()) :
-
1074 parser_collection<T>(std::move(collection), locale),
+
1072 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
+
1073 _In_ const std::locale& locale = std::locale()) :
+
1074 parser_collection<T>(std::move(collection), locale),
1075 hit_offset((size_t)-1)
1076 {}
1077
1078 virtual bool match(
-
1079 _In_reads_or_z_(end) const T* text,
-
1080 _In_ size_t start = 0,
-
1081 _In_ size_t end = (size_t)-1,
-
1082 _In_ int flags = match_default)
+
1079 _In_reads_or_z_(end) const T* text,
+
1080 _In_ size_t start = 0,
+
1081 _In_ size_t end = (size_t)-1,
+
1082 _In_ int flags = match_default)
1083 {
-
1084 assert(text || start >= end);
+
1084 assert(text || start >= end);
1085 hit_offset = 0;
-
1086 for (auto i = m_collection.begin(); i != m_collection.end(); ++i, ++hit_offset) {
-
1087 if ((*i)->match(text, start, end, flags)) {
+
1086 for (auto i = m_collection.begin(); i != m_collection.end(); ++i, ++hit_offset) {
+
1087 if ((*i)->match(text, start, end, flags)) {
1088 interval = (*i)->interval;
-
1089 for (++i; i != m_collection.end(); ++i)
+
1089 for (++i; i != m_collection.end(); ++i)
1090 (*i)->invalidate();
1091 return true;
1092 }
1093 }
-
1094 hit_offset = (size_t)-1;
+
1094 hit_offset = (size_t)-1;
1095 interval.start = (interval.end = start) + 1;
1096 return false;
1097 }
1098
1099 virtual void invalidate()
1100 {
-
1101 hit_offset = (size_t)-1;
+
1101 hit_offset = (size_t)-1;
1103 }
1104
1105 public:
1106 size_t hit_offset;
1107 };
+
1108
-
1109 using branch = basic_branch<char>;
-
1110 using wbranch = basic_branch<wchar_t>;
+
1109 using branch = basic_branch<char>;
+
1110 using wbranch = basic_branch<wchar_t>;
1111#ifdef _UNICODE
-
1112 using tbranch = wbranch;
+
1112 using tbranch = wbranch;
1113#else
-
1114 using tbranch = branch;
+
1114 using tbranch = branch;
1115#endif
-
1116 using sgml_branch = basic_branch<char>;
+
1116 using sgml_branch = basic_branch<char>;
1117
1121 template <class T, class T_parser = basic_string<T>>
+
1123 {
1124 public:
1125 inline basic_string_branch(
-
1126 _In_reads_(count) const T* str_z = nullptr,
-
1127 _In_ size_t count = 0,
-
1128 _In_ const std::locale& locale = std::locale()) :
-
1129 basic_branch<T>(locale)
+
1126 _In_reads_(count) const T* str_z = nullptr,
+
1127 _In_ size_t count = 0,
+
1128 _In_ const std::locale& locale = std::locale()) :
+
1129 basic_branch<T>(locale)
1130 {
-
1131 build(str_z, count);
+
1131 build(str_z, count);
1132 }
1133
-
1134 inline basic_string_branch(_In_z_ const T* str, ...) :
-
1135 basic_branch<T>(std::locale())
+
1134 inline basic_string_branch(_In_z_ const T* str, ...) :
+
1135 basic_branch<T>(std::locale())
1136 {
-
1137 va_list params;
-
1138 va_start(params, str);
-
1139 build(str, params);
-
1140 va_end(params);
+
1137 va_list params;
+
1138 va_start(params, str);
+
1139 build(str, params);
+
1140 va_end(params);
1141 }
1142
-
1143 inline basic_string_branch(_In_ const std::locale& locale, _In_z_ const T* str, ...) :
-
1144 basic_branch<T>(locale)
+
1143 inline basic_string_branch(_In_ const std::locale& locale, _In_z_ const T* str, ...) :
+
1144 basic_branch<T>(locale)
1145 {
-
1146 va_list params;
-
1147 va_start(params, str);
-
1148 build(str, params);
-
1149 va_end(params);
+
1146 va_list params;
+
1147 va_start(params, str);
+
1148 build(str, params);
+
1149 va_end(params);
1150 }
1151
1152 protected:
-
1153 void build(_In_reads_(count) const T* str_z, _In_ size_t count)
+
1153 void build(_In_reads_(count) const T* str_z, _In_ size_t count)
1154 {
-
1155 assert(str_z || !count);
-
1156 if (count) {
-
1157 size_t offset, n;
+
1155 assert(str_z || !count);
+
1156 if (count) {
+
1157 size_t offset, n;
1158 for (
-
1159 offset = n = 0;
-
1160 offset < count && str_z[offset];
-
1161 offset += stdex::strnlen(str_z + offset, count - offset) + 1, ++n);
-
1162 m_collection.reserve(n);
+
1159 offset = n = 0;
+
1160 offset < count && str_z[offset];
+
1161 offset += stdex::strnlen(str_z + offset, count - offset) + 1, ++n);
+
1162 m_collection.reserve(n);
1163 for (
1164 offset = 0;
-
1165 offset < count && str_z[offset];
-
1166 offset += stdex::strnlen(str_z + offset, count - offset) + 1)
-
1167 m_collection.push_back(std::move(std::make_shared<T_parser>(str_z + offset, count - offset, m_locale)));
+
1165 offset < count && str_z[offset];
+
1166 offset += stdex::strnlen(str_z + offset, count - offset) + 1)
+
1167 m_collection.push_back(std::move(std::make_shared<T_parser>(str_z + offset, count - offset, m_locale)));
1168 }
1169 }
1170
-
1171 void build(_In_z_ const T* str, _In_ va_list params)
+
1171 void build(_In_z_ const T* str, _In_ va_list params)
1172 {
-
1173 const T* p;
+
1173 const T* p;
1174 for (
-
1175 m_collection.push_back(std::move(std::make_shared<T_parser>(str, (size_t)-1, m_locale)));
-
1176 (p = va_arg(params, const T*)) != nullptr;
-
1177 m_collection.push_back(std::move(std::make_shared<T_parser>(p, (size_t)-1, m_locale))));
+
1175 m_collection.push_back(std::move(std::make_shared<T_parser>(str, (size_t)-1, m_locale)));
+
1176 (p = va_arg(params, const T*)) != nullptr;
+
1177 m_collection.push_back(std::move(std::make_shared<T_parser>(p, (size_t)-1, m_locale))));
1178 }
1179 };
+
1180
-
1181 using string_branch = basic_string_branch<char>;
-
1182 using wstring_branch = basic_string_branch<wchar_t>;
+
1181 using string_branch = basic_string_branch<char>;
+
1182 using wstring_branch = basic_string_branch<wchar_t>;
1183#ifdef _UNICODE
-
1184 using tstring_branch = wstring_branch;
+
1184 using tstring_branch = wstring_branch;
1185#else
-
1186 using tstring_branch = string_branch;
+
1186 using tstring_branch = string_branch;
1187#endif
-
1188 using sgml_string_branch = basic_string_branch<char, sgml_string>;
+
1188 using sgml_string_branch = basic_string_branch<char, sgml_string>;
1189
1193 template <class T>
+
1195 {
1196 public:
-
1198 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el = nullptr,
-
1199 _In_ size_t count = 0,
-
1200 _In_ const std::locale& locale = std::locale()) :
-
1201 parser_collection<T>(el, count, locale)
+
1198 _In_count_(count) const std::shared_ptr<basic_parser<T>>* el = nullptr,
+
1199 _In_ size_t count = 0,
+
1200 _In_ const std::locale& locale = std::locale()) :
+
1201 parser_collection<T>(el, count, locale)
1202 {}
1203
-
1205 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
-
1206 _In_ const std::locale& locale = std::locale()) :
-
1207 parser_collection<T>(std::move(collection), locale)
+
1205 _Inout_ std::vector<std::shared_ptr<basic_parser<T>>>&& collection,
+
1206 _In_ const std::locale& locale = std::locale()) :
+
1207 parser_collection<T>(std::move(collection), locale)
1208 {}
1209
1210 virtual bool match(
-
1211 _In_reads_or_z_(end) const T* text,
-
1212 _In_ size_t start = 0,
-
1213 _In_ size_t end = (size_t)-1,
-
1214 _In_ int flags = match_default)
+
1211 _In_reads_or_z_(end) const T* text,
+
1212 _In_ size_t start = 0,
+
1213 _In_ size_t end = (size_t)-1,
+
1214 _In_ int flags = match_default)
1215 {
-
1216 assert(text || start >= end);
-
1217 for (auto& el: m_collection)
-
1218 el->invalidate();
-
1219 if (match_recursively(text, start, end, flags)) {
+
1216 assert(text || start >= end);
+
1217 for (auto& el: m_collection)
+
1218 el->invalidate();
+
1219 if (match_recursively(text, start, end, flags)) {
1220 interval.start = start;
1221 return true;
1222 }
@@ -1228,49 +1282,51 @@ $(function() {
1226
1227 protected:
1228 bool match_recursively(
-
1229 _In_reads_or_z_(end) const T* text,
-
1230 _In_ size_t start = 0,
-
1231 _In_ size_t end = (size_t)-1,
-
1232 _In_ int flags = match_default)
+
1229 _In_reads_or_z_(end) const T* text,
+
1230 _In_ size_t start = 0,
+
1231 _In_ size_t end = (size_t)-1,
+
1232 _In_ int flags = match_default)
1233 {
-
1234 bool all_matched = true;
-
1235 for (auto& el: m_collection) {
-
1236 if (!el->interval) {
+
1234 bool all_matched = true;
+
1235 for (auto& el: m_collection) {
+
1236 if (!el->interval) {
1237 // Element was not matched in permutatuion yet.
-
1238 all_matched = false;
-
1239 if (el->match(text, start, end, flags)) {
+
1238 all_matched = false;
+
1239 if (el->match(text, start, end, flags)) {
1240 // Element matched for the first time.
-
1241 if (match_recursively(text, el->interval.end, end, flags)) {
+
1241 if (match_recursively(text, el->interval.end, end, flags)) {
1242 // Rest of the elements matched too.
1243 return true;
1244 }
-
1245 el->invalidate();
+
1245 el->invalidate();
1246 }
1247 }
1248 }
-
1249 if (all_matched) {
+
1249 if (all_matched) {
1250 interval.end = start;
1251 return true;
1252 }
1253 return false;
1254 }
1255 };
+
1256
-
1257 using permutation = basic_permutation<char>;
-
1258 using wpermutation = basic_permutation<wchar_t>;
+
1257 using permutation = basic_permutation<char>;
+
1258 using wpermutation = basic_permutation<wchar_t>;
1259#ifdef _UNICODE
-
1260 using tpermutation = wpermutation;
+
1260 using tpermutation = wpermutation;
1261#else
-
1262 using tpermutation = permutation;
+
1262 using tpermutation = permutation;
1263#endif
-
1264 using sgml_permutation = basic_permutation<char>;
+
1264 using sgml_permutation = basic_permutation<char>;
1265
1269 template <class T>
+
1270 class basic_integer : public basic_parser<T>
1271 {
1272 public:
-
1273 basic_integer(_In_ const std::locale& locale = std::locale()) :
-
1274 basic_parser<T>(locale),
+
1273 basic_integer(_In_ const std::locale& locale = std::locale()) :
+
1274 basic_parser<T>(locale),
1275 value(0)
1276 {}
1277
@@ -1283,57 +1339,59 @@ $(function() {
1284 public:
1285 size_t value;
1286 };
+
1287
1291 template <class T>
+
1293 {
1294 public:
-
1296 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
-
1297 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
-
1298 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
-
1299 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
-
1300 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
-
1301 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
-
1302 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
-
1303 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
-
1304 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
-
1305 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
-
1306 _In_ const std::locale& locale = std::locale()) :
-
1307 basic_integer<T>(locale),
-
1308 m_digit_0(digit_0),
-
1309 m_digit_1(digit_1),
-
1310 m_digit_2(digit_2),
-
1311 m_digit_3(digit_3),
-
1312 m_digit_4(digit_4),
-
1313 m_digit_5(digit_5),
-
1314 m_digit_6(digit_6),
-
1315 m_digit_7(digit_7),
-
1316 m_digit_8(digit_8),
-
1317 m_digit_9(digit_9)
+
1296 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
+
1297 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
+
1298 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
+
1299 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
+
1300 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
+
1301 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
+
1302 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
+
1303 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
+
1304 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
+
1305 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
+
1306 _In_ const std::locale& locale = std::locale()) :
+
1307 basic_integer<T>(locale),
+
1308 m_digit_0(digit_0),
+
1309 m_digit_1(digit_1),
+
1310 m_digit_2(digit_2),
+
1311 m_digit_3(digit_3),
+
1312 m_digit_4(digit_4),
+
1313 m_digit_5(digit_5),
+
1314 m_digit_6(digit_6),
+
1315 m_digit_7(digit_7),
+
1316 m_digit_8(digit_8),
+
1317 m_digit_9(digit_9)
1318 {}
1319
1320 virtual bool match(
-
1321 _In_reads_or_z_(end) const T* text,
-
1322 _In_ size_t start = 0,
-
1323 _In_ size_t end = (size_t)-1,
-
1324 _In_ int flags = match_default)
+
1321 _In_reads_or_z_(end) const T* text,
+
1322 _In_ size_t start = 0,
+
1323 _In_ size_t end = (size_t)-1,
+
1324 _In_ int flags = match_default)
1325 {
-
1326 assert(text || start >= end);
-
1327 for (interval.end = start, value = 0; interval.end < end && text[interval.end];) {
-
1328 size_t dig;
-
1329 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; interval.end = m_digit_0->interval.end; }
-
1330 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; interval.end = m_digit_1->interval.end; }
-
1331 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; interval.end = m_digit_2->interval.end; }
-
1332 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; interval.end = m_digit_3->interval.end; }
-
1333 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; interval.end = m_digit_4->interval.end; }
-
1334 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; interval.end = m_digit_5->interval.end; }
-
1335 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; interval.end = m_digit_6->interval.end; }
-
1336 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; interval.end = m_digit_7->interval.end; }
-
1337 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; interval.end = m_digit_8->interval.end; }
-
1338 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; interval.end = m_digit_9->interval.end; }
+
1326 assert(text || start >= end);
+
1327 for (interval.end = start, value = 0; interval.end < end && text[interval.end];) {
+
1328 size_t dig;
+
1329 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; interval.end = m_digit_0->interval.end; }
+
1330 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; interval.end = m_digit_1->interval.end; }
+
1331 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; interval.end = m_digit_2->interval.end; }
+
1332 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; interval.end = m_digit_3->interval.end; }
+
1333 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; interval.end = m_digit_4->interval.end; }
+
1334 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; interval.end = m_digit_5->interval.end; }
+
1335 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; interval.end = m_digit_6->interval.end; }
+
1336 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; interval.end = m_digit_7->interval.end; }
+
1337 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; interval.end = m_digit_8->interval.end; }
+
1338 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; interval.end = m_digit_9->interval.end; }
1339 else break;
-
1340 value = value * 10 + dig;
+
1340 value = value * 10 + dig;
1341 }
1342 if (start < interval.end) {
1343 interval.start = start;
@@ -1356,39 +1414,41 @@ $(function() {
1360 m_digit_8,
1361 m_digit_9;
1362 };
+
1363
-
1364 using integer10 = basic_integer10<char>;
-
1365 using winteger10 = basic_integer10<wchar_t>;
+
1364 using integer10 = basic_integer10<char>;
+
1365 using winteger10 = basic_integer10<wchar_t>;
1366#ifdef _UNICODE
-
1367 using tinteger10 = winteger10;
+
1367 using tinteger10 = winteger10;
1368#else
-
1369 using tinteger10 = integer10;
+
1369 using tinteger10 = integer10;
1370#endif
-
1371 using sgml_integer10 = basic_integer10<char>;
+
1371 using sgml_integer10 = basic_integer10<char>;
1372
1376 template <class T>
+
1378 {
1379 public:
-
1381 _In_ const std::shared_ptr<basic_integer10<T>>& digits,
-
1382 _In_ const std::shared_ptr<basic_set<T>>& separator,
-
1383 _In_ const std::locale& locale = std::locale()) :
-
1384 basic_integer<T>(locale),
+
1381 _In_ const std::shared_ptr<basic_integer10<T>>& digits,
+
1382 _In_ const std::shared_ptr<basic_set<T>>& separator,
+
1383 _In_ const std::locale& locale = std::locale()) :
+
1384 basic_integer<T>(locale),
1385 digit_count(0),
1386 has_separators(false),
-
1387 m_digits(digits),
+
1387 m_digits(digits),
1388 m_separator(separator)
1389 {}
1390
1391 virtual bool match(
-
1392 _In_reads_or_z_(end) const T* text,
-
1393 _In_ size_t start = 0,
-
1394 _In_ size_t end = (size_t)-1,
-
1395 _In_ int flags = match_default)
+
1392 _In_reads_or_z_(end) const T* text,
+
1393 _In_ size_t start = 0,
+
1394 _In_ size_t end = (size_t)-1,
+
1395 _In_ int flags = match_default)
1396 {
-
1397 assert(text || start >= end);
-
1398 if (m_digits->match(text, start, end, flags)) {
+
1397 assert(text || start >= end);
+
1398 if (m_digits->match(text, start, end, flags)) {
1399 // Leading part match.
1400 value = m_digits->value;
1401 digit_count = m_digits->interval.size();
@@ -1397,10 +1457,10 @@ $(function() {
1404 interval.end = m_digits->interval.end;
1405 if (m_digits->interval.size() <= 3) {
1406 // Maybe separated with thousand separators?
-
1407 size_t hit_offset = (size_t)-1;
-
1408 while (m_separator->match(text, interval.end, end, flags) &&
-
1409 (hit_offset == (size_t)-1 || hit_offset == m_separator->hit_offset) && // All separators must be the same, no mixing.
-
1410 m_digits->match(text, m_separator->interval.end, end, flags) &&
+
1407 size_t hit_offset = (size_t)-1;
+
1408 while (m_separator->match(text, interval.end, end, flags) &&
+
1409 (hit_offset == (size_t)-1 || hit_offset == m_separator->hit_offset) && // All separators must be the same, no mixing.
+
1410 m_digits->match(text, m_separator->interval.end, end, flags) &&
1411 m_digits->interval.size() == 3)
1412 {
1413 // Thousand separator and three-digit integer followed.
@@ -1434,84 +1494,86 @@ $(function() {
1441 std::shared_ptr<basic_integer10<T>> m_digits;
1442 std::shared_ptr<basic_set<T>> m_separator;
1443 };
+
1444
-
1445 using integer10ts = basic_integer10ts<char>;
-
1446 using winteger10ts = basic_integer10ts<wchar_t>;
+
1445 using integer10ts = basic_integer10ts<char>;
+
1446 using winteger10ts = basic_integer10ts<wchar_t>;
1447#ifdef _UNICODE
-
1448 using tinteger10ts = winteger10ts;
+
1448 using tinteger10ts = winteger10ts;
1449#else
-
1450 using tinteger10ts = integer10ts;
+
1450 using tinteger10ts = integer10ts;
1451#endif
-
1452 using sgml_integer10ts = basic_integer10ts<char>;
+
1452 using sgml_integer10ts = basic_integer10ts<char>;
1453
1457 template <class T>
+
1459 {
1460 public:
-
1462 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
-
1463 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
-
1464 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
-
1465 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
-
1466 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
-
1467 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
-
1468 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
-
1469 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
-
1470 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
-
1471 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
-
1472 _In_ const std::shared_ptr<basic_parser<T>>& digit_10,
-
1473 _In_ const std::shared_ptr<basic_parser<T>>& digit_11,
-
1474 _In_ const std::shared_ptr<basic_parser<T>>& digit_12,
-
1475 _In_ const std::shared_ptr<basic_parser<T>>& digit_13,
-
1476 _In_ const std::shared_ptr<basic_parser<T>>& digit_14,
-
1477 _In_ const std::shared_ptr<basic_parser<T>>& digit_15,
-
1478 _In_ const std::locale& locale = std::locale()) :
-
1479 basic_integer<T>(locale),
-
1480 m_digit_0(digit_0),
-
1481 m_digit_1(digit_1),
-
1482 m_digit_2(digit_2),
-
1483 m_digit_3(digit_3),
-
1484 m_digit_4(digit_4),
-
1485 m_digit_5(digit_5),
-
1486 m_digit_6(digit_6),
-
1487 m_digit_7(digit_7),
-
1488 m_digit_8(digit_8),
-
1489 m_digit_9(digit_9),
-
1490 m_digit_10(digit_10),
-
1491 m_digit_11(digit_11),
-
1492 m_digit_12(digit_12),
-
1493 m_digit_13(digit_13),
-
1494 m_digit_14(digit_14),
-
1495 m_digit_15(digit_15)
+
1462 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
+
1463 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
+
1464 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
+
1465 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
+
1466 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
+
1467 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
+
1468 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
+
1469 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
+
1470 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
+
1471 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
+
1472 _In_ const std::shared_ptr<basic_parser<T>>& digit_10,
+
1473 _In_ const std::shared_ptr<basic_parser<T>>& digit_11,
+
1474 _In_ const std::shared_ptr<basic_parser<T>>& digit_12,
+
1475 _In_ const std::shared_ptr<basic_parser<T>>& digit_13,
+
1476 _In_ const std::shared_ptr<basic_parser<T>>& digit_14,
+
1477 _In_ const std::shared_ptr<basic_parser<T>>& digit_15,
+
1478 _In_ const std::locale& locale = std::locale()) :
+
1479 basic_integer<T>(locale),
+
1480 m_digit_0(digit_0),
+
1481 m_digit_1(digit_1),
+
1482 m_digit_2(digit_2),
+
1483 m_digit_3(digit_3),
+
1484 m_digit_4(digit_4),
+
1485 m_digit_5(digit_5),
+
1486 m_digit_6(digit_6),
+
1487 m_digit_7(digit_7),
+
1488 m_digit_8(digit_8),
+
1489 m_digit_9(digit_9),
+
1490 m_digit_10(digit_10),
+
1491 m_digit_11(digit_11),
+
1492 m_digit_12(digit_12),
+
1493 m_digit_13(digit_13),
+
1494 m_digit_14(digit_14),
+
1495 m_digit_15(digit_15)
1496 {}
1497
1498 virtual bool match(
-
1499 _In_reads_or_z_(end) const T* text,
-
1500 _In_ size_t start = 0,
-
1501 _In_ size_t end = (size_t)-1,
-
1502 _In_ int flags = match_default)
+
1499 _In_reads_or_z_(end) const T* text,
+
1500 _In_ size_t start = 0,
+
1501 _In_ size_t end = (size_t)-1,
+
1502 _In_ int flags = match_default)
1503 {
-
1504 assert(text || start >= end);
-
1505 for (interval.end = start, value = 0; interval.end < end && text[interval.end];) {
-
1506 size_t dig;
-
1507 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; interval.end = m_digit_0->interval.end; }
-
1508 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; interval.end = m_digit_1->interval.end; }
-
1509 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; interval.end = m_digit_2->interval.end; }
-
1510 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; interval.end = m_digit_3->interval.end; }
-
1511 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; interval.end = m_digit_4->interval.end; }
-
1512 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; interval.end = m_digit_5->interval.end; }
-
1513 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; interval.end = m_digit_6->interval.end; }
-
1514 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; interval.end = m_digit_7->interval.end; }
-
1515 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; interval.end = m_digit_8->interval.end; }
-
1516 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; interval.end = m_digit_9->interval.end; }
-
1517 else if (m_digit_10->match(text, interval.end, end, flags)) { dig = 10; interval.end = m_digit_10->interval.end; }
-
1518 else if (m_digit_11->match(text, interval.end, end, flags)) { dig = 11; interval.end = m_digit_11->interval.end; }
-
1519 else if (m_digit_12->match(text, interval.end, end, flags)) { dig = 12; interval.end = m_digit_12->interval.end; }
-
1520 else if (m_digit_13->match(text, interval.end, end, flags)) { dig = 13; interval.end = m_digit_13->interval.end; }
-
1521 else if (m_digit_14->match(text, interval.end, end, flags)) { dig = 14; interval.end = m_digit_14->interval.end; }
-
1522 else if (m_digit_15->match(text, interval.end, end, flags)) { dig = 15; interval.end = m_digit_15->interval.end; }
+
1504 assert(text || start >= end);
+
1505 for (interval.end = start, value = 0; interval.end < end && text[interval.end];) {
+
1506 size_t dig;
+
1507 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; interval.end = m_digit_0->interval.end; }
+
1508 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; interval.end = m_digit_1->interval.end; }
+
1509 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; interval.end = m_digit_2->interval.end; }
+
1510 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; interval.end = m_digit_3->interval.end; }
+
1511 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; interval.end = m_digit_4->interval.end; }
+
1512 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; interval.end = m_digit_5->interval.end; }
+
1513 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; interval.end = m_digit_6->interval.end; }
+
1514 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; interval.end = m_digit_7->interval.end; }
+
1515 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; interval.end = m_digit_8->interval.end; }
+
1516 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; interval.end = m_digit_9->interval.end; }
+
1517 else if (m_digit_10->match(text, interval.end, end, flags)) { dig = 10; interval.end = m_digit_10->interval.end; }
+
1518 else if (m_digit_11->match(text, interval.end, end, flags)) { dig = 11; interval.end = m_digit_11->interval.end; }
+
1519 else if (m_digit_12->match(text, interval.end, end, flags)) { dig = 12; interval.end = m_digit_12->interval.end; }
+
1520 else if (m_digit_13->match(text, interval.end, end, flags)) { dig = 13; interval.end = m_digit_13->interval.end; }
+
1521 else if (m_digit_14->match(text, interval.end, end, flags)) { dig = 14; interval.end = m_digit_14->interval.end; }
+
1522 else if (m_digit_15->match(text, interval.end, end, flags)) { dig = 15; interval.end = m_digit_15->interval.end; }
1523 else break;
-
1524 value = value * 16 + dig;
+
1524 value = value * 16 + dig;
1525 }
1526 if (start < interval.end) {
1527 interval.start = start;
@@ -1540,93 +1602,95 @@ $(function() {
1550 m_digit_14,
1551 m_digit_15;
1552 };
+
1553
-
1554 using integer16 = basic_integer16<char>;
-
1555 using winteger16 = basic_integer16<wchar_t>;
+
1554 using integer16 = basic_integer16<char>;
+
1555 using winteger16 = basic_integer16<wchar_t>;
1556#ifdef _UNICODE
-
1557 using tinteger16 = winteger16;
+
1557 using tinteger16 = winteger16;
1558#else
-
1559 using tinteger16 = integer16;
+
1559 using tinteger16 = integer16;
1560#endif
-
1561 using sgml_integer16 = basic_integer16<char>;
+
1561 using sgml_integer16 = basic_integer16<char>;
1562
1566 template <class T>
+
1568 {
1569 public:
-
1571 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
-
1572 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
-
1573 _In_ const std::shared_ptr<basic_parser<T>>& digit_10,
-
1574 _In_ const std::shared_ptr<basic_parser<T>>& digit_50,
-
1575 _In_ const std::shared_ptr<basic_parser<T>>& digit_100,
-
1576 _In_ const std::shared_ptr<basic_parser<T>>& digit_500,
-
1577 _In_ const std::shared_ptr<basic_parser<T>>& digit_1000,
-
1578 _In_ const std::shared_ptr<basic_parser<T>>& digit_5000,
-
1579 _In_ const std::shared_ptr<basic_parser<T>>& digit_10000,
-
1580 _In_ const std::locale& locale = std::locale()) :
-
1581 basic_integer<T>(locale),
-
1582 m_digit_1(digit_1),
-
1583 m_digit_5(digit_5),
-
1584 m_digit_10(digit_10),
-
1585 m_digit_50(digit_50),
-
1586 m_digit_100(digit_100),
-
1587 m_digit_500(digit_500),
-
1588 m_digit_1000(digit_1000),
-
1589 m_digit_5000(digit_5000),
-
1590 m_digit_10000(digit_10000)
+
1571 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
+
1572 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
+
1573 _In_ const std::shared_ptr<basic_parser<T>>& digit_10,
+
1574 _In_ const std::shared_ptr<basic_parser<T>>& digit_50,
+
1575 _In_ const std::shared_ptr<basic_parser<T>>& digit_100,
+
1576 _In_ const std::shared_ptr<basic_parser<T>>& digit_500,
+
1577 _In_ const std::shared_ptr<basic_parser<T>>& digit_1000,
+
1578 _In_ const std::shared_ptr<basic_parser<T>>& digit_5000,
+
1579 _In_ const std::shared_ptr<basic_parser<T>>& digit_10000,
+
1580 _In_ const std::locale& locale = std::locale()) :
+
1581 basic_integer<T>(locale),
+
1582 m_digit_1(digit_1),
+
1583 m_digit_5(digit_5),
+
1584 m_digit_10(digit_10),
+
1585 m_digit_50(digit_50),
+
1586 m_digit_100(digit_100),
+
1587 m_digit_500(digit_500),
+
1588 m_digit_1000(digit_1000),
+
1589 m_digit_5000(digit_5000),
+
1590 m_digit_10000(digit_10000)
1591 {}
1592
1593 virtual bool match(
-
1594 _In_reads_or_z_(end) const T* text,
-
1595 _In_ size_t start = 0,
-
1596 _In_ size_t end = (size_t)-1,
-
1597 _In_ int flags = match_default)
+
1594 _In_reads_or_z_(end) const T* text,
+
1595 _In_ size_t start = 0,
+
1596 _In_ size_t end = (size_t)-1,
+
1597 _In_ int flags = match_default)
1598 {
-
1599 assert(text || start >= end);
+
1599 assert(text || start >= end);
1600 size_t
-
1601 dig[5] = { (size_t)-1, (size_t)-1, (size_t)-1, (size_t)-1, (size_t)-1 },
-
1602 end2;
+
1601 dig[5] = { (size_t)-1, (size_t)-1, (size_t)-1, (size_t)-1, (size_t)-1 },
+
1602 end2;
1603
-
1604 for (interval.end = start, value = 0; interval.end < end && text[interval.end]; dig[3] = dig[2], dig[2] = dig[1], dig[1] = dig[0], interval.end = end2) {
-
1605 if (m_digit_1 && m_digit_1->match(text, interval.end, end, flags)) { dig[0] = 1; end2 = m_digit_1->interval.end; }
-
1606 else if (m_digit_5 && m_digit_5->match(text, interval.end, end, flags)) { dig[0] = 5; end2 = m_digit_5->interval.end; }
-
1607 else if (m_digit_10 && m_digit_10->match(text, interval.end, end, flags)) { dig[0] = 10; end2 = m_digit_10->interval.end; }
-
1608 else if (m_digit_50 && m_digit_50->match(text, interval.end, end, flags)) { dig[0] = 50; end2 = m_digit_50->interval.end; }
-
1609 else if (m_digit_100 && m_digit_100->match(text, interval.end, end, flags)) { dig[0] = 100; end2 = m_digit_100->interval.end; }
-
1610 else if (m_digit_500 && m_digit_500->match(text, interval.end, end, flags)) { dig[0] = 500; end2 = m_digit_500->interval.end; }
-
1611 else if (m_digit_1000 && m_digit_1000->match(text, interval.end, end, flags)) { dig[0] = 1000; end2 = m_digit_1000->interval.end; }
-
1612 else if (m_digit_5000 && m_digit_5000->match(text, interval.end, end, flags)) { dig[0] = 5000; end2 = m_digit_5000->interval.end; }
-
1613 else if (m_digit_10000 && m_digit_10000->match(text, interval.end, end, flags)) { dig[0] = 10000; end2 = m_digit_10000->interval.end; }
+
1604 for (interval.end = start, value = 0; interval.end < end && text[interval.end]; dig[3] = dig[2], dig[2] = dig[1], dig[1] = dig[0], interval.end = end2) {
+
1605 if (m_digit_1 && m_digit_1->match(text, interval.end, end, flags)) { dig[0] = 1; end2 = m_digit_1->interval.end; }
+
1606 else if (m_digit_5 && m_digit_5->match(text, interval.end, end, flags)) { dig[0] = 5; end2 = m_digit_5->interval.end; }
+
1607 else if (m_digit_10 && m_digit_10->match(text, interval.end, end, flags)) { dig[0] = 10; end2 = m_digit_10->interval.end; }
+
1608 else if (m_digit_50 && m_digit_50->match(text, interval.end, end, flags)) { dig[0] = 50; end2 = m_digit_50->interval.end; }
+
1609 else if (m_digit_100 && m_digit_100->match(text, interval.end, end, flags)) { dig[0] = 100; end2 = m_digit_100->interval.end; }
+
1610 else if (m_digit_500 && m_digit_500->match(text, interval.end, end, flags)) { dig[0] = 500; end2 = m_digit_500->interval.end; }
+
1611 else if (m_digit_1000 && m_digit_1000->match(text, interval.end, end, flags)) { dig[0] = 1000; end2 = m_digit_1000->interval.end; }
+
1612 else if (m_digit_5000 && m_digit_5000->match(text, interval.end, end, flags)) { dig[0] = 5000; end2 = m_digit_5000->interval.end; }
+
1613 else if (m_digit_10000 && m_digit_10000->match(text, interval.end, end, flags)) { dig[0] = 10000; end2 = m_digit_10000->interval.end; }
1614 else break;
1615
1616 // Store first digit.
-
1617 if (dig[4] == (size_t)-1) dig[4] = dig[0];
+
1617 if (dig[4] == (size_t)-1) dig[4] = dig[0];
1618
-
1619 if (dig[3] == dig[2] && dig[2] == dig[1] && dig[1] == dig[0] && dig[0] != dig[4]) {
+
1619 if (dig[3] == dig[2] && dig[2] == dig[1] && dig[1] == dig[0] && dig[0] != dig[4]) {
1620 // Same digit repeated four times. No-go, unless first digit. E.g. XIIII vs. XIV. MMMMMCD allowed, IIII also...
1621 break;
1622 }
-
1623 if (dig[0] <= dig[1]) {
+
1623 if (dig[0] <= dig[1]) {
1624 // Digit is less or equal previous one: add.
-
1625 value += dig[0];
+
1625 value += dig[0];
1626 }
1627 else if (
-
1628 dig[1] == 1 && (dig[0] == 5 || dig[0] == 10) ||
-
1629 dig[1] == 10 && (dig[0] == 50 || dig[0] == 100) ||
-
1630 dig[1] == 100 && (dig[0] == 500 || dig[0] == 1000) ||
-
1631 dig[1] == 1000 && (dig[0] == 5000 || dig[0] == 10000))
+
1628 dig[1] == 1 && (dig[0] == 5 || dig[0] == 10) ||
+
1629 dig[1] == 10 && (dig[0] == 50 || dig[0] == 100) ||
+
1630 dig[1] == 100 && (dig[0] == 500 || dig[0] == 1000) ||
+
1631 dig[1] == 1000 && (dig[0] == 5000 || dig[0] == 10000))
1632 {
1633 // Digit is up to two orders bigger than previous one: subtract. But...
-
1634 if (dig[2] < dig[0]) {
+
1634 if (dig[2] < dig[0]) {
1635 // Digit is also bigger than pre-previous one. E.g. VIX (V < X => invalid)
1636 break;
1637 }
-
1638 value -= dig[1]; // Cancel addition in the previous step.
-
1639 dig[0] -= dig[1]; // Combine last two digits.
-
1640 dig[1] = dig[2]; // The true previous digit is now pre-previous one. :)
-
1641 dig[2] = dig[3]; // The true pre-previous digit is now pre-pre-previous one. :)
-
1642 value += dig[0]; // Add combined value.
+
1638 value -= dig[1]; // Cancel addition in the previous step.
+
1639 dig[0] -= dig[1]; // Combine last two digits.
+
1640 dig[1] = dig[2]; // The true previous digit is now pre-previous one. :)
+
1641 dig[2] = dig[3]; // The true pre-previous digit is now pre-pre-previous one. :)
+
1642 value += dig[0]; // Add combined value.
1643 }
1644 else {
1645 // New digit is too big than the previous one. E.g. VX (V < X => invalid)
@@ -1653,41 +1717,43 @@ $(function() {
1666 m_digit_5000,
1667 m_digit_10000;
1668 };
+
1669
-
1670 using roman_numeral = basic_roman_numeral<char>;
-
1671 using wroman_numeral = basic_roman_numeral<wchar_t>;
+
1670 using roman_numeral = basic_roman_numeral<char>;
+
1671 using wroman_numeral = basic_roman_numeral<wchar_t>;
1672#ifdef _UNICODE
-
1673 using troman_numeral = wroman_numeral;
+
1673 using troman_numeral = wroman_numeral;
1674#else
-
1675 using troman_numeral = roman_numeral;
+
1675 using troman_numeral = roman_numeral;
1676#endif
-
1677 using sgml_roman_numeral = basic_roman_numeral<char>;
+
1677 using sgml_roman_numeral = basic_roman_numeral<char>;
1678
1682 template <class T>
+
1684 {
1685 public:
-
1687 _In_ const std::shared_ptr<basic_parser<T>>& _numerator,
-
1688 _In_ const std::shared_ptr<basic_parser<T>>& _fraction_line,
-
1689 _In_ const std::shared_ptr<basic_parser<T>>& _denominator,
-
1690 _In_ const std::locale& locale = std::locale()) :
-
1691 basic_parser<T>(locale),
-
1692 numerator(_numerator),
-
1693 fraction_line(_fraction_line),
-
1694 denominator(_denominator)
+
1687 _In_ const std::shared_ptr<basic_parser<T>>& _numerator,
+
1688 _In_ const std::shared_ptr<basic_parser<T>>& _fraction_line,
+
1689 _In_ const std::shared_ptr<basic_parser<T>>& _denominator,
+
1690 _In_ const std::locale& locale = std::locale()) :
+
1691 basic_parser<T>(locale),
+
1692 numerator(_numerator),
+
1693 fraction_line(_fraction_line),
+
1694 denominator(_denominator)
1695 {}
1696
1697 virtual bool match(
-
1698 _In_reads_or_z_(end) const T* text,
-
1699 _In_ size_t start = 0,
-
1700 _In_ size_t end = (size_t)-1,
-
1701 _In_ int flags = match_default)
+
1698 _In_reads_or_z_(end) const T* text,
+
1699 _In_ size_t start = 0,
+
1700 _In_ size_t end = (size_t)-1,
+
1701 _In_ int flags = match_default)
1702 {
-
1703 assert(text || start >= end);
-
1704 if (numerator->match(text, start, end, flags) &&
-
1705 fraction_line->match(text, numerator->interval.end, end, flags) &&
-
1706 denominator->match(text, fraction_line->interval.end, end, flags))
+
1703 assert(text || start >= end);
+
1704 if (numerator->match(text, start, end, flags) &&
+
1705 fraction_line->match(text, numerator->interval.end, end, flags) &&
+
1706 denominator->match(text, fraction_line->interval.end, end, flags))
1707 {
1708 interval.start = start;
1709 interval.end = denominator->interval.end;
@@ -1713,58 +1779,60 @@ $(function() {
1729 std::shared_ptr<basic_parser<T>> fraction_line;
1730 std::shared_ptr<basic_parser<T>> denominator;
1731 };
+
1732
-
1733 using fraction = basic_fraction<char>;
-
1734 using wfraction = basic_fraction<wchar_t>;
+
1733 using fraction = basic_fraction<char>;
+
1734 using wfraction = basic_fraction<wchar_t>;
1735#ifdef _UNICODE
-
1736 using tfraction = wfraction;
+
1736 using tfraction = wfraction;
1737#else
-
1738 using tfraction = fraction;
+
1738 using tfraction = fraction;
1739#endif
-
1740 using sgml_fraction = basic_fraction<char>;
+
1740 using sgml_fraction = basic_fraction<char>;
1741
1745 template <class T>
+
1746 class basic_score : public basic_parser<T>
1747 {
1748 public:
-
1750 _In_ const std::shared_ptr<basic_parser<T>>& _home,
-
1751 _In_ const std::shared_ptr<basic_parser<T>>& _separator,
-
1752 _In_ const std::shared_ptr<basic_parser<T>>& _guest,
-
1753 _In_ const std::shared_ptr<basic_parser<T>>& space,
-
1754 _In_ const std::locale& locale = std::locale()) :
-
1755 basic_parser<T>(locale),
-
1756 home(_home),
-
1757 separator(_separator),
-
1758 guest(_guest),
+
1750 _In_ const std::shared_ptr<basic_parser<T>>& _home,
+
1751 _In_ const std::shared_ptr<basic_parser<T>>& _separator,
+
1752 _In_ const std::shared_ptr<basic_parser<T>>& _guest,
+
1753 _In_ const std::shared_ptr<basic_parser<T>>& space,
+
1754 _In_ const std::locale& locale = std::locale()) :
+
1755 basic_parser<T>(locale),
+
1756 home(_home),
+
1757 separator(_separator),
+
1758 guest(_guest),
1759 m_space(space)
1760 {}
1761
1762 virtual bool match(
-
1763 _In_reads_or_z_(end) const T* text,
-
1764 _In_ size_t start = 0,
-
1765 _In_ size_t end = (size_t)-1,
-
1766 _In_ int flags = match_default)
+
1763 _In_reads_or_z_(end) const T* text,
+
1764 _In_ size_t start = 0,
+
1765 _In_ size_t end = (size_t)-1,
+
1766 _In_ int flags = match_default)
1767 {
-
1768 assert(text || start >= end);
+
1768 assert(text || start >= end);
1769 interval.end = start;
1770
-
1771 if (home->match(text, interval.end, end, flags))
+
1771 if (home->match(text, interval.end, end, flags))
1772 interval.end = home->interval.end;
1773 else
1774 goto end;
1775
-
1776 const int space_match_flags = flags & ~match_multiline; // Spaces in score must never be broken in new line.
-
1777 for (; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
1776 const int space_match_flags = flags & ~match_multiline; // Spaces in score must never be broken in new line.
+
1777 for (; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
1778
-
1779 if (separator->match(text, interval.end, end, flags))
+
1779 if (separator->match(text, interval.end, end, flags))
1780 interval.end = separator->interval.end;
1781 else
1782 goto end;
1783
-
1784 for (; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
1784 for (; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
1785
-
1786 if (guest->match(text, interval.end, end, flags))
+
1786 if (guest->match(text, interval.end, end, flags))
1787 interval.end = guest->interval.end;
1788 else
1789 goto end;
@@ -1796,52 +1864,54 @@ $(function() {
1815 protected:
1816 std::shared_ptr<basic_parser<T>> m_space;
1817 };
+
1818
-
1819 using score = basic_score<char>;
-
1820 using wscore = basic_score<wchar_t>;
+
1819 using score = basic_score<char>;
+
1820 using wscore = basic_score<wchar_t>;
1821#ifdef _UNICODE
-
1822 using tscore = wscore;
+
1822 using tscore = wscore;
1823#else
-
1824 using tscore = score;
+
1824 using tscore = score;
1825#endif
-
1826 using sgml_score = basic_score<char>;
+
1826 using sgml_score = basic_score<char>;
1827
1831 template <class T>
+
1833 {
1834 public:
-
1836 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
-
1837 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
-
1838 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
-
1839 _In_ const std::shared_ptr<basic_parser<T>>& _number,
-
1840 _In_ const std::locale& locale = std::locale()) :
-
1841 basic_parser<T>(locale),
-
1842 positive_sign(_positive_sign),
-
1843 negative_sign(_negative_sign),
-
1844 special_sign(_special_sign),
-
1845 number(_number)
+
1836 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
+
1837 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
+
1838 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
+
1839 _In_ const std::shared_ptr<basic_parser<T>>& _number,
+
1840 _In_ const std::locale& locale = std::locale()) :
+
1841 basic_parser<T>(locale),
+ + + +
1846 {}
1847
1848 virtual bool match(
-
1849 _In_reads_or_z_(end) const T* text,
-
1850 _In_ size_t start = 0,
-
1851 _In_ size_t end = (size_t)-1,
-
1852 _In_ int flags = match_default)
+
1849 _In_reads_or_z_(end) const T* text,
+
1850 _In_ size_t start = 0,
+
1851 _In_ size_t end = (size_t)-1,
+
1852 _In_ int flags = match_default)
1853 {
-
1854 assert(text || start >= end);
+
1854 assert(text || start >= end);
1855 interval.end = start;
-
1856 if (positive_sign && positive_sign->match(text, interval.end, end, flags)) {
+
1856 if (positive_sign && positive_sign->match(text, interval.end, end, flags)) {
1857 interval.end = positive_sign->interval.end;
1858 if (negative_sign) negative_sign->invalidate();
1859 if (special_sign) special_sign->invalidate();
1860 }
-
1861 else if (negative_sign && negative_sign->match(text, interval.end, end, flags)) {
+
1861 else if (negative_sign && negative_sign->match(text, interval.end, end, flags)) {
1862 interval.end = negative_sign->interval.end;
1863 if (positive_sign) positive_sign->invalidate();
1864 if (special_sign) special_sign->invalidate();
1865 }
-
1866 else if (special_sign && special_sign->match(text, interval.end, end, flags)) {
+
1866 else if (special_sign && special_sign->match(text, interval.end, end, flags)) {
1867 interval.end = special_sign->interval.end;
1868 if (positive_sign) positive_sign->invalidate();
1869 if (negative_sign) negative_sign->invalidate();
@@ -1851,7 +1921,7 @@ $(function() {
1873 if (negative_sign) negative_sign->invalidate();
1874 if (special_sign) special_sign->invalidate();
1875 }
-
1876 if (number->match(text, interval.end, end, flags)) {
+
1876 if (number->match(text, interval.end, end, flags)) {
1877 interval.start = start;
1878 interval.end = number->interval.end;
1879 return true;
@@ -1879,57 +1949,59 @@ $(function() {
1901 std::shared_ptr<basic_parser<T>> special_sign;
1902 std::shared_ptr<basic_parser<T>> number;
1903 };
+
1904
-
1905 using signed_numeral = basic_signed_numeral<char>;
-
1906 using wsigned_numeral = basic_signed_numeral<wchar_t>;
+
1905 using signed_numeral = basic_signed_numeral<char>;
+
1906 using wsigned_numeral = basic_signed_numeral<wchar_t>;
1907#ifdef _UNICODE
-
1908 using tsigned_numeral = wsigned_numeral;
+
1908 using tsigned_numeral = wsigned_numeral;
1909#else
-
1910 using tsigned_numeral = signed_numeral;
+
1910 using tsigned_numeral = signed_numeral;
1911#endif
-
1912 using sgml_signed_numeral = basic_signed_numeral<char>;
+
1912 using sgml_signed_numeral = basic_signed_numeral<char>;
1913
1917 template <class T>
+
1919 {
1920 public:
-
1922 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
-
1923 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
-
1924 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
-
1925 _In_ const std::shared_ptr<basic_parser<T>>& _integer,
-
1926 _In_ const std::shared_ptr<basic_parser<T>>& space,
-
1927 _In_ const std::shared_ptr<basic_parser<T>>& _fraction,
-
1928 _In_ const std::locale& locale = std::locale()) :
-
1929 basic_parser<T>(locale),
-
1930 positive_sign(_positive_sign),
-
1931 negative_sign(_negative_sign),
-
1932 special_sign(_special_sign),
-
1933 integer(_integer),
-
1934 fraction(_fraction),
+
1922 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
+
1923 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
+
1924 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
+
1925 _In_ const std::shared_ptr<basic_parser<T>>& _integer,
+
1926 _In_ const std::shared_ptr<basic_parser<T>>& space,
+
1927 _In_ const std::shared_ptr<basic_parser<T>>& _fraction,
+
1928 _In_ const std::locale& locale = std::locale()) :
+
1929 basic_parser<T>(locale),
+ + + + +
1935 m_space(space)
1936 {}
1937
1938 virtual bool match(
-
1939 _In_reads_or_z_(end) const T* text,
-
1940 _In_ size_t start = 0,
-
1941 _In_ size_t end = (size_t)-1,
-
1942 _In_ int flags = match_default)
+
1939 _In_reads_or_z_(end) const T* text,
+
1940 _In_ size_t start = 0,
+
1941 _In_ size_t end = (size_t)-1,
+
1942 _In_ int flags = match_default)
1943 {
-
1944 assert(text || start >= end);
+
1944 assert(text || start >= end);
1945 interval.end = start;
1946
-
1947 if (positive_sign && positive_sign->match(text, interval.end, end, flags)) {
+
1947 if (positive_sign && positive_sign->match(text, interval.end, end, flags)) {
1948 interval.end = positive_sign->interval.end;
1949 if (negative_sign) negative_sign->invalidate();
1950 if (special_sign) special_sign->invalidate();
1951 }
-
1952 else if (negative_sign && negative_sign->match(text, interval.end, end, flags)) {
+
1952 else if (negative_sign && negative_sign->match(text, interval.end, end, flags)) {
1953 interval.end = negative_sign->interval.end;
1954 if (positive_sign) positive_sign->invalidate();
1955 if (special_sign) special_sign->invalidate();
1956 }
-
1957 else if (special_sign && special_sign->match(text, interval.end, end, flags)) {
+
1957 else if (special_sign && special_sign->match(text, interval.end, end, flags)) {
1958 interval.end = special_sign->interval.end;
1959 if (positive_sign) positive_sign->invalidate();
1960 if (negative_sign) negative_sign->invalidate();
@@ -1941,33 +2013,33 @@ $(function() {
1966 }
1967
1968 // Check for <integer> <fraction>
-
1969 const int space_match_flags = flags & ~match_multiline; // Spaces in fractions must never be broken in new line.
-
1970 if (integer->match(text, interval.end, end, flags) &&
-
1971 m_space->match(text, integer->interval.end, end, space_match_flags))
+
1969 const int space_match_flags = flags & ~match_multiline; // Spaces in fractions must never be broken in new line.
+
1970 if (integer->match(text, interval.end, end, flags) &&
+
1971 m_space->match(text, integer->interval.end, end, space_match_flags))
1972 {
-
1973 for (interval.end = m_space->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
1974 if (fraction->match(text, interval.end, end, flags)) {
+
1973 for (interval.end = m_space->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
1974 if (fraction->match(text, interval.end, end, flags)) {
1975 interval.start = start;
- +
1977 return true;
1978 }
-
1979 fraction->invalidate();
+
1979 fraction->invalidate();
1980 interval.start = start;
1981 interval.end = integer->interval.end;
1982 return true;
1983 }
1984
1985 // Check for <fraction>
-
1986 if (fraction->match(text, interval.end, end, flags)) {
+
1986 if (fraction->match(text, interval.end, end, flags)) {
1987 integer->invalidate();
1988 interval.start = start;
- +
1990 return true;
1991 }
1992
1993 // Check for <integer>
-
1994 if (integer->match(text, interval.end, end, flags)) {
-
1995 fraction->invalidate();
+
1994 if (integer->match(text, interval.end, end, flags)) {
+
1995 fraction->invalidate();
1996 interval.start = start;
1997 interval.end = integer->interval.end;
1998 return true;
@@ -1977,7 +2049,7 @@ $(function() {
2002 if (negative_sign) negative_sign->invalidate();
2003 if (special_sign) special_sign->invalidate();
2004 integer->invalidate();
-
2005 fraction->invalidate();
+
2005 fraction->invalidate();
2006 interval.start = (interval.end = start) + 1;
2007 return false;
2008 }
@@ -1988,7 +2060,7 @@ $(function() {
2013 if (negative_sign) negative_sign->invalidate();
2014 if (special_sign) special_sign->invalidate();
2015 integer->invalidate();
-
2016 fraction->invalidate();
+
2016 fraction->invalidate();
2018 }
2019
@@ -2002,66 +2074,68 @@ $(function() {
2027 protected:
2028 std::shared_ptr<basic_parser<T>> m_space;
2029 };
+
2030
-
2031 using mixed_numeral = basic_mixed_numeral<char>;
-
2032 using wmixed_numeral = basic_mixed_numeral<wchar_t>;
+
2031 using mixed_numeral = basic_mixed_numeral<char>;
+
2032 using wmixed_numeral = basic_mixed_numeral<wchar_t>;
2033#ifdef _UNICODE
-
2034 using tmixed_numeral = wmixed_numeral;
+
2034 using tmixed_numeral = wmixed_numeral;
2035#else
-
2036 using tmixed_numeral = mixed_numeral;
+
2036 using tmixed_numeral = mixed_numeral;
2037#endif
-
2038 using sgml_mixed_numeral = basic_mixed_numeral<char>;
+
2038 using sgml_mixed_numeral = basic_mixed_numeral<char>;
2039
2043 template <class T>
+
2045 {
2046 public:
-
2048 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
-
2049 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
-
2050 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
-
2051 _In_ const std::shared_ptr<basic_integer<T>>& _integer,
-
2052 _In_ const std::shared_ptr<basic_parser<T>>& _decimal_separator,
-
2053 _In_ const std::shared_ptr<basic_integer<T>>& _decimal,
-
2054 _In_ const std::shared_ptr<basic_parser<T>>& _exponent_symbol,
-
2055 _In_ const std::shared_ptr<basic_parser<T>>& _positive_exp_sign,
-
2056 _In_ const std::shared_ptr<basic_parser<T>>& _negative_exp_sign,
-
2057 _In_ const std::shared_ptr<basic_integer<T>>& _exponent,
-
2058 _In_ const std::locale& locale = std::locale()) :
-
2059 basic_parser<T>(locale),
-
2060 positive_sign(_positive_sign),
-
2061 negative_sign(_negative_sign),
-
2062 special_sign(_special_sign),
-
2063 integer(_integer),
-
2064 decimal_separator(_decimal_separator),
-
2065 decimal(_decimal),
-
2066 exponent_symbol(_exponent_symbol),
-
2067 positive_exp_sign(_positive_exp_sign),
-
2068 negative_exp_sign(_negative_exp_sign),
-
2069 exponent(_exponent),
+
2048 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
+
2049 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
+
2050 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
+
2051 _In_ const std::shared_ptr<basic_integer<T>>& _integer,
+
2052 _In_ const std::shared_ptr<basic_parser<T>>& _decimal_separator,
+
2053 _In_ const std::shared_ptr<basic_integer<T>>& _decimal,
+
2054 _In_ const std::shared_ptr<basic_parser<T>>& _exponent_symbol,
+
2055 _In_ const std::shared_ptr<basic_parser<T>>& _positive_exp_sign,
+
2056 _In_ const std::shared_ptr<basic_parser<T>>& _negative_exp_sign,
+
2057 _In_ const std::shared_ptr<basic_integer<T>>& _exponent,
+
2058 _In_ const std::locale& locale = std::locale()) :
+
2059 basic_parser<T>(locale),
+ + + + + + + + + +
2070 value(std::numeric_limits<double>::quiet_NaN())
2071 {}
2072
2073 virtual bool match(
-
2074 _In_reads_or_z_(end) const T* text,
-
2075 _In_ size_t start = 0,
-
2076 _In_ size_t end = (size_t)-1,
-
2077 _In_ int flags = match_default)
+
2074 _In_reads_or_z_(end) const T* text,
+
2075 _In_ size_t start = 0,
+
2076 _In_ size_t end = (size_t)-1,
+
2077 _In_ int flags = match_default)
2078 {
-
2079 assert(text || start >= end);
+
2079 assert(text || start >= end);
2080 interval.end = start;
2081
-
2082 if (positive_sign && positive_sign->match(text, interval.end, end, flags)) {
+
2082 if (positive_sign && positive_sign->match(text, interval.end, end, flags)) {
2083 interval.end = positive_sign->interval.end;
2084 if (negative_sign) negative_sign->invalidate();
2085 if (special_sign) special_sign->invalidate();
2086 }
-
2087 else if (negative_sign && negative_sign->match(text, interval.end, end, flags)) {
+
2087 else if (negative_sign && negative_sign->match(text, interval.end, end, flags)) {
2088 interval.end = negative_sign->interval.end;
2089 if (positive_sign) positive_sign->invalidate();
2090 if (special_sign) special_sign->invalidate();
2091 }
-
2092 else if (special_sign && special_sign->match(text, interval.end, end, flags)) {
+
2092 else if (special_sign && special_sign->match(text, interval.end, end, flags)) {
2093 interval.end = special_sign->interval.end;
2094 if (positive_sign) positive_sign->invalidate();
2095 if (negative_sign) negative_sign->invalidate();
@@ -2072,11 +2146,11 @@ $(function() {
2100 if (special_sign) special_sign->invalidate();
2101 }
2102
-
2103 if (integer->match(text, interval.end, end, flags))
+
2103 if (integer->match(text, interval.end, end, flags))
2104 interval.end = integer->interval.end;
2105
-
2106 if (decimal_separator->match(text, interval.end, end, flags) &&
-
2107 decimal->match(text, decimal_separator->interval.end, end, flags))
+
2106 if (decimal_separator->match(text, interval.end, end, flags) &&
+
2108 interval.end = decimal->interval.end;
2109 else {
2110 decimal_separator->invalidate();
@@ -2101,17 +2175,17 @@ $(function() {
2129 return false;
2130 }
2131
-
2132 if (exponent_symbol && exponent_symbol->match(text, interval.end, end, flags) &&
-
2133 (positive_exp_sign && positive_exp_sign->match(text, exponent_symbol->interval.end, end, flags) &&
-
2134 exponent && exponent->match(text, positive_exp_sign->interval.end, end, flags) ||
-
2135 exponent && exponent->match(text, exponent_symbol->interval.end, end, flags)))
+
2132 if (exponent_symbol && exponent_symbol->match(text, interval.end, end, flags) &&
+ + +
2136 {
2137 interval.end = exponent->interval.end;
2138 if (negative_exp_sign) negative_exp_sign->invalidate();
2139 }
-
2140 else if (exponent_symbol && exponent_symbol->match(text, interval.end, end, flags) &&
-
2141 negative_exp_sign && negative_exp_sign->match(text, exponent_symbol->interval.end, end, flags) &&
-
2142 exponent && exponent->match(text, negative_exp_sign->interval.end, end, flags))
+
2140 else if (exponent_symbol && exponent_symbol->match(text, interval.end, end, flags) &&
+ +
2143 {
2144 interval.end = exponent->interval.end;
2145 if (positive_exp_sign) positive_exp_sign->invalidate();
@@ -2123,16 +2197,16 @@ $(function() {
2151 if (exponent) exponent->invalidate();
2152 }
2153
-
2154 value = (double)integer->value;
+
2154 value = (double)integer->value;
2155 if (decimal->interval)
-
2156 value += (double)decimal->value * pow(10.0, -(double)decimal->interval.size());
+
2156 value += (double)decimal->value * pow(10.0, -(double)decimal->interval.size());
2157 if (negative_sign && negative_sign->interval)
2158 value = -value;
2159 if (exponent && exponent->interval) {
-
2160 double e = (double)exponent->value;
+
2160 double e = (double)exponent->value;
2161 if (negative_exp_sign && negative_exp_sign->interval)
-
2162 e = -e;
-
2163 value *= pow(10.0, e);
+
2162 e = -e;
+
2163 value *= pow(10.0, e);
2164 }
2165
2166 interval.start = start;
@@ -2168,59 +2242,61 @@ $(function() {
2196 std::shared_ptr<basic_integer<T>> exponent;
2197 double value;
2198 };
+
2199
-
2200 using scientific_numeral = basic_scientific_numeral<char>;
-
2201 using wscientific_numeral = basic_scientific_numeral<wchar_t>;
+
2200 using scientific_numeral = basic_scientific_numeral<char>;
+
2201 using wscientific_numeral = basic_scientific_numeral<wchar_t>;
2202#ifdef _UNICODE
-
2203 using tscientific_numeral = wscientific_numeral;
+
2203 using tscientific_numeral = wscientific_numeral;
2204#else
-
2205 using tscientific_numeral = scientific_numeral;
+
2205 using tscientific_numeral = scientific_numeral;
2206#endif
-
2207 using sgml_scientific_numeral = basic_scientific_numeral<char>;
+
2207 using sgml_scientific_numeral = basic_scientific_numeral<char>;
2208
2212 template <class T>
+
2214 {
2215 public:
-
2217 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
-
2218 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
-
2219 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
-
2220 _In_ const std::shared_ptr<basic_parser<T>>& _currency,
-
2221 _In_ const std::shared_ptr<basic_parser<T>>& _integer,
-
2222 _In_ const std::shared_ptr<basic_parser<T>>& _decimal_separator,
-
2223 _In_ const std::shared_ptr<basic_parser<T>>& _decimal,
-
2224 _In_ const std::locale& locale = std::locale()) :
-
2225 basic_parser<T>(locale),
-
2226 positive_sign(_positive_sign),
-
2227 negative_sign(_negative_sign),
-
2228 special_sign(_special_sign),
-
2229 currency(_currency),
-
2230 integer(_integer),
-
2231 decimal_separator(_decimal_separator),
-
2232 decimal(_decimal)
+
2217 _In_ const std::shared_ptr<basic_parser<T>>& _positive_sign,
+
2218 _In_ const std::shared_ptr<basic_parser<T>>& _negative_sign,
+
2219 _In_ const std::shared_ptr<basic_parser<T>>& _special_sign,
+
2220 _In_ const std::shared_ptr<basic_parser<T>>& _currency,
+
2221 _In_ const std::shared_ptr<basic_parser<T>>& _integer,
+
2222 _In_ const std::shared_ptr<basic_parser<T>>& _decimal_separator,
+
2223 _In_ const std::shared_ptr<basic_parser<T>>& _decimal,
+
2224 _In_ const std::locale& locale = std::locale()) :
+
2225 basic_parser<T>(locale),
+ + + + + + +
2233 {}
2234
2235 virtual bool match(
-
2236 _In_reads_or_z_(end) const T* text,
-
2237 _In_ size_t start = 0,
-
2238 _In_ size_t end = (size_t)-1,
-
2239 _In_ int flags = match_default)
+
2236 _In_reads_or_z_(end) const T* text,
+
2237 _In_ size_t start = 0,
+
2238 _In_ size_t end = (size_t)-1,
+
2239 _In_ int flags = match_default)
2240 {
-
2241 assert(text || start >= end);
+
2241 assert(text || start >= end);
2242 interval.end = start;
2243
-
2244 if (positive_sign->match(text, interval.end, end, flags)) {
+
2244 if (positive_sign->match(text, interval.end, end, flags)) {
2245 interval.end = positive_sign->interval.end;
2246 if (negative_sign) negative_sign->invalidate();
2247 if (special_sign) special_sign->invalidate();
2248 }
-
2249 else if (negative_sign->match(text, interval.end, end, flags)) {
+
2249 else if (negative_sign->match(text, interval.end, end, flags)) {
2250 interval.end = negative_sign->interval.end;
2251 if (positive_sign) positive_sign->invalidate();
2252 if (special_sign) special_sign->invalidate();
2253 }
-
2254 else if (special_sign->match(text, interval.end, end, flags)) {
+
2254 else if (special_sign->match(text, interval.end, end, flags)) {
2255 interval.end = special_sign->interval.end;
2256 if (positive_sign) positive_sign->invalidate();
2257 if (negative_sign) negative_sign->invalidate();
@@ -2231,7 +2307,7 @@ $(function() {
2262 if (special_sign) special_sign->invalidate();
2263 }
2264
-
2265 if (currency->match(text, interval.end, end, flags))
+
2265 if (currency->match(text, interval.end, end, flags))
2266 interval.end = currency->interval.end;
2267 else {
2268 if (positive_sign) positive_sign->invalidate();
@@ -2244,10 +2320,10 @@ $(function() {
2275 return false;
2276 }
2277
-
2278 if (integer->match(text, interval.end, end, flags))
+
2278 if (integer->match(text, interval.end, end, flags))
2279 interval.end = integer->interval.end;
-
2280 if (decimal_separator->match(text, interval.end, end, flags) &&
-
2281 decimal->match(text, decimal_separator->interval.end, end, flags))
+
2280 if (decimal_separator->match(text, interval.end, end, flags) &&
+
2282 interval.end = decimal->interval.end;
2283 else {
2284 decimal_separator->invalidate();
@@ -2294,105 +2370,107 @@ $(function() {
2325 std::shared_ptr<basic_parser<T>> decimal_separator;
2326 std::shared_ptr<basic_parser<T>> decimal;
2327 };
+
2328
-
2329 using monetary_numeral = basic_monetary_numeral<char>;
-
2330 using wmonetary_numeral = basic_monetary_numeral<wchar_t>;
+
2329 using monetary_numeral = basic_monetary_numeral<char>;
+
2330 using wmonetary_numeral = basic_monetary_numeral<wchar_t>;
2331#ifdef _UNICODE
-
2332 using tmonetary_numeral = wmonetary_numeral;
+
2332 using tmonetary_numeral = wmonetary_numeral;
2333#else
-
2334 using tmonetary_numeral = monetary_numeral;
+
2334 using tmonetary_numeral = monetary_numeral;
2335#endif
-
2336 using sgml_monetary_numeral = basic_monetary_numeral<char>;
+
2336 using sgml_monetary_numeral = basic_monetary_numeral<char>;
2337
2341 template <class T>
+
2343 {
2344 public:
-
2346 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
-
2347 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
-
2348 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
-
2349 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
-
2350 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
-
2351 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
-
2352 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
-
2353 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
-
2354 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
-
2355 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
-
2356 _In_ const std::shared_ptr<basic_parser<T>>& separator,
-
2357 _In_ const std::locale& locale = std::locale()) :
-
2358 basic_parser<T>(locale),
-
2359 m_digit_0(digit_0),
-
2360 m_digit_1(digit_1),
-
2361 m_digit_2(digit_2),
-
2362 m_digit_3(digit_3),
-
2363 m_digit_4(digit_4),
-
2364 m_digit_5(digit_5),
-
2365 m_digit_6(digit_6),
-
2366 m_digit_7(digit_7),
-
2367 m_digit_8(digit_8),
-
2368 m_digit_9(digit_9),
+
2346 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
+
2347 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
+
2348 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
+
2349 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
+
2350 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
+
2351 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
+
2352 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
+
2353 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
+
2354 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
+
2355 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
+
2356 _In_ const std::shared_ptr<basic_parser<T>>& separator,
+
2357 _In_ const std::locale& locale = std::locale()) :
+
2358 basic_parser<T>(locale),
+
2359 m_digit_0(digit_0),
+
2360 m_digit_1(digit_1),
+
2361 m_digit_2(digit_2),
+
2362 m_digit_3(digit_3),
+
2363 m_digit_4(digit_4),
+
2364 m_digit_5(digit_5),
+
2365 m_digit_6(digit_6),
+
2366 m_digit_7(digit_7),
+
2367 m_digit_8(digit_8),
+
2368 m_digit_9(digit_9),
2369 m_separator(separator)
2370 {
2371 value.s_addr = 0;
2372 }
2373
2374 virtual bool match(
-
2375 _In_reads_or_z_(end) const T* text,
-
2376 _In_ size_t start = 0,
-
2377 _In_ size_t end = (size_t)-1,
-
2378 _In_ int flags = match_default)
+
2375 _In_reads_or_z_(end) const T* text,
+
2376 _In_ size_t start = 0,
+
2377 _In_ size_t end = (size_t)-1,
+
2378 _In_ int flags = match_default)
2379 {
-
2380 assert(text || start >= end);
+
2380 assert(text || start >= end);
2381 interval.end = start;
2382 value.s_addr = 0;
2383
-
2384 size_t i;
-
2385 for (i = 0; i < 4; i++) {
-
2386 if (i) {
-
2387 if (m_separator->match(text, interval.end, end, flags))
+
2384 size_t i;
+
2385 for (i = 0; i < 4; i++) {
+
2386 if (i) {
+
2387 if (m_separator->match(text, interval.end, end, flags))
2388 interval.end = m_separator->interval.end;
2389 else
-
2390 goto error;
+
2390 goto error;
2391 }
2392
- -
2394 bool is_empty = true;
-
2395 size_t x;
-
2396 for (x = 0; interval.end < end && text[interval.end];) {
-
2397 size_t dig, digit_end;
-
2398 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; digit_end = m_digit_0->interval.end; }
-
2399 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; digit_end = m_digit_1->interval.end; }
-
2400 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; digit_end = m_digit_2->interval.end; }
-
2401 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; digit_end = m_digit_3->interval.end; }
-
2402 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; digit_end = m_digit_4->interval.end; }
-
2403 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; digit_end = m_digit_5->interval.end; }
-
2404 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; digit_end = m_digit_6->interval.end; }
-
2405 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; digit_end = m_digit_7->interval.end; }
-
2406 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; digit_end = m_digit_8->interval.end; }
-
2407 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; digit_end = m_digit_9->interval.end; }
+ +
2394 bool is_empty = true;
+
2395 size_t x;
+
2396 for (x = 0; interval.end < end && text[interval.end];) {
+
2397 size_t dig, digit_end;
+
2398 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; digit_end = m_digit_0->interval.end; }
+
2399 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; digit_end = m_digit_1->interval.end; }
+
2400 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; digit_end = m_digit_2->interval.end; }
+
2401 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; digit_end = m_digit_3->interval.end; }
+
2402 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; digit_end = m_digit_4->interval.end; }
+
2403 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; digit_end = m_digit_5->interval.end; }
+
2404 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; digit_end = m_digit_6->interval.end; }
+
2405 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; digit_end = m_digit_7->interval.end; }
+
2406 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; digit_end = m_digit_8->interval.end; }
+
2407 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; digit_end = m_digit_9->interval.end; }
2408 else break;
-
2409 size_t x_n = x * 10 + dig;
-
2410 if (x_n <= 255) {
-
2411 x = x_n;
-
2412 interval.end = digit_end;
-
2413 is_empty = false;
+
2409 size_t x_n = x * 10 + dig;
+
2410 if (x_n <= 255) {
+
2411 x = x_n;
+ +
2413 is_empty = false;
2414 }
2415 else
2416 break;
2417 }
-
2418 if (is_empty)
-
2419 goto error;
- -
2421 value.s_addr = (value.s_addr << 8) | (uint8_t)x;
+
2418 if (is_empty)
+
2419 goto error;
+ +
2421 value.s_addr = (value.s_addr << 8) | (uint8_t)x;
2422 }
-
2423 if (i < 4)
-
2424 goto error;
+
2423 if (i < 4)
+
2424 goto error;
2425
2426 interval.start = start;
2427 return true;
2428
-
2429 error:
+
2429 error:
2430 components[0].start = 1;
2431 components[0].end = 0;
2432 components[1].start = 1;
@@ -2422,7 +2500,7 @@ $(function() {
2456
2457 public:
-
2459 struct in_addr value;
+
2460
2461 protected:
2462 std::shared_ptr<basic_parser<T>>
@@ -2438,34 +2516,36 @@ $(function() {
2472 m_digit_9;
2473 std::shared_ptr<basic_parser<T>> m_separator;
2474 };
+
2475
-
2476 using ipv4_address = basic_ipv4_address<char>;
-
2477 using wipv4_address = basic_ipv4_address<wchar_t>;
+
2476 using ipv4_address = basic_ipv4_address<char>;
+
2477 using wipv4_address = basic_ipv4_address<wchar_t>;
2478#ifdef _UNICODE
-
2479 using tipv4_address = wipv4_address;
+
2479 using tipv4_address = wipv4_address;
2480#else
-
2481 using tipv4_address = ipv4_address;
+
2481 using tipv4_address = ipv4_address;
2482#endif
-
2483 using sgml_ipv4_address = basic_ipv4_address<char>;
+
2483 using sgml_ipv4_address = basic_ipv4_address<char>;
2484
2488 template <class T>
+
2490 {
2491 public:
-
2492 basic_ipv6_scope_id_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
+
2492 basic_ipv6_scope_id_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
2493
2494 virtual bool match(
-
2495 _In_reads_or_z_(end) const T* text,
-
2496 _In_ size_t start = 0,
-
2497 _In_ size_t end = (size_t)-1,
-
2498 _In_ int flags = match_default)
+
2495 _In_reads_or_z_(end) const T* text,
+
2496 _In_ size_t start = 0,
+
2497 _In_ size_t end = (size_t)-1,
+
2498 _In_ int flags = match_default)
2499 {
-
2500 assert(text || start >= end);
-
2501 if (start < end && text[start]) {
-
2502 if (text[start] == '-' ||
-
2503 text[start] == '_' ||
-
2504 text[start] == ':' ||
-
2505 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
+
2500 assert(text || start >= end);
+
2501 if (start < end && text[start]) {
+
2502 if (text[start] == '-' ||
+
2503 text[start] == '_' ||
+
2504 text[start] == ':' ||
+
2505 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
2506 {
2507 interval.end = (interval.start = start) + 1;
2508 return true;
@@ -2475,35 +2555,37 @@ $(function() {
2512 return false;
2513 }
2514 };
+
2515
-
2516 using ipv6_scope_id_char = basic_ipv6_scope_id_char<char>;
-
2517 using wipv6_scope_id_char = basic_ipv6_scope_id_char<wchar_t>;
+
2516 using ipv6_scope_id_char = basic_ipv6_scope_id_char<char>;
+
2517 using wipv6_scope_id_char = basic_ipv6_scope_id_char<wchar_t>;
2518#ifdef _UNICODE
-
2519 using tipv6_scope_id_char = wipv6_scope_id_char;
+
2519 using tipv6_scope_id_char = wipv6_scope_id_char;
2520#else
-
2521 using tipv6_scope_id_char = ipv6_scope_id_char;
+
2521 using tipv6_scope_id_char = ipv6_scope_id_char;
2522#endif
2523
+
2528 {
2529 public:
-
2530 sgml_ipv6_scope_id_char(_In_ const std::locale& locale = std::locale()) : sgml_parser(locale) {}
+
2530 sgml_ipv6_scope_id_char(_In_ const std::locale& locale = std::locale()) : sgml_parser(locale) {}
2531
2532 virtual bool match(
-
2533 _In_reads_or_z_(end) const char* text,
-
2534 _In_ size_t start = 0,
-
2535 _In_ size_t end = (size_t)-1,
-
2536 _In_ int flags = match_default)
+
2533 _In_reads_or_z_(end) const char* text,
+
2534 _In_ size_t start = 0,
+
2535 _In_ size_t end = (size_t)-1,
+
2536 _In_ int flags = match_default)
2537 {
-
2538 assert(text || start >= end);
-
2539 if (start < end && text[start]) {
+
2538 assert(text || start >= end);
+
2539 if (start < end && text[start]) {
2540 wchar_t buf[3];
-
2541 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
2542 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
2543 if ((chr[0] == L'-' ||
-
2544 chr[0] == L'_' ||
-
2545 chr[0] == L':') && chr[1] == 0 ||
-
2546 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
+
2541 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
2542 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
2543 if ((chr[0] == L'-' ||
+
2544 chr[0] == L'_' ||
+
2545 chr[0] == L':') && chr[1] == 0 ||
+
2546 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
2547 {
2548 interval.start = start;
2549 return true;
@@ -2513,77 +2595,79 @@ $(function() {
2553 return false;
2554 }
2555 };
+
2556
2560 template <class T>
+
2562 {
2563 public:
-
2565 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
-
2566 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
-
2567 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
-
2568 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
-
2569 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
-
2570 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
-
2571 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
-
2572 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
-
2573 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
-
2574 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
-
2575 _In_ const std::shared_ptr<basic_parser<T>>& digit_10,
-
2576 _In_ const std::shared_ptr<basic_parser<T>>& digit_11,
-
2577 _In_ const std::shared_ptr<basic_parser<T>>& digit_12,
-
2578 _In_ const std::shared_ptr<basic_parser<T>>& digit_13,
-
2579 _In_ const std::shared_ptr<basic_parser<T>>& digit_14,
-
2580 _In_ const std::shared_ptr<basic_parser<T>>& digit_15,
-
2581 _In_ const std::shared_ptr<basic_parser<T>>& separator,
-
2582 _In_ const std::shared_ptr<basic_parser<T>>& scope_id_separator = nullptr,
-
2583 _In_ const std::shared_ptr<basic_parser<T>>& _scope_id = nullptr,
-
2584 _In_ const std::locale& locale = std::locale()) :
-
2585 basic_parser<T>(locale),
-
2586 m_digit_0(digit_0),
-
2587 m_digit_1(digit_1),
-
2588 m_digit_2(digit_2),
-
2589 m_digit_3(digit_3),
-
2590 m_digit_4(digit_4),
-
2591 m_digit_5(digit_5),
-
2592 m_digit_6(digit_6),
-
2593 m_digit_7(digit_7),
-
2594 m_digit_8(digit_8),
-
2595 m_digit_9(digit_9),
-
2596 m_digit_10(digit_10),
-
2597 m_digit_11(digit_11),
-
2598 m_digit_12(digit_12),
-
2599 m_digit_13(digit_13),
-
2600 m_digit_14(digit_14),
-
2601 m_digit_15(digit_15),
+
2565 _In_ const std::shared_ptr<basic_parser<T>>& digit_0,
+
2566 _In_ const std::shared_ptr<basic_parser<T>>& digit_1,
+
2567 _In_ const std::shared_ptr<basic_parser<T>>& digit_2,
+
2568 _In_ const std::shared_ptr<basic_parser<T>>& digit_3,
+
2569 _In_ const std::shared_ptr<basic_parser<T>>& digit_4,
+
2570 _In_ const std::shared_ptr<basic_parser<T>>& digit_5,
+
2571 _In_ const std::shared_ptr<basic_parser<T>>& digit_6,
+
2572 _In_ const std::shared_ptr<basic_parser<T>>& digit_7,
+
2573 _In_ const std::shared_ptr<basic_parser<T>>& digit_8,
+
2574 _In_ const std::shared_ptr<basic_parser<T>>& digit_9,
+
2575 _In_ const std::shared_ptr<basic_parser<T>>& digit_10,
+
2576 _In_ const std::shared_ptr<basic_parser<T>>& digit_11,
+
2577 _In_ const std::shared_ptr<basic_parser<T>>& digit_12,
+
2578 _In_ const std::shared_ptr<basic_parser<T>>& digit_13,
+
2579 _In_ const std::shared_ptr<basic_parser<T>>& digit_14,
+
2580 _In_ const std::shared_ptr<basic_parser<T>>& digit_15,
+
2581 _In_ const std::shared_ptr<basic_parser<T>>& separator,
+
2582 _In_ const std::shared_ptr<basic_parser<T>>& scope_id_separator = nullptr,
+
2583 _In_ const std::shared_ptr<basic_parser<T>>& _scope_id = nullptr,
+
2584 _In_ const std::locale& locale = std::locale()) :
+
2585 basic_parser<T>(locale),
+
2586 m_digit_0(digit_0),
+
2587 m_digit_1(digit_1),
+
2588 m_digit_2(digit_2),
+
2589 m_digit_3(digit_3),
+
2590 m_digit_4(digit_4),
+
2591 m_digit_5(digit_5),
+
2592 m_digit_6(digit_6),
+
2593 m_digit_7(digit_7),
+
2594 m_digit_8(digit_8),
+
2595 m_digit_9(digit_9),
+
2596 m_digit_10(digit_10),
+
2597 m_digit_11(digit_11),
+
2598 m_digit_12(digit_12),
+
2599 m_digit_13(digit_13),
+
2600 m_digit_14(digit_14),
+
2601 m_digit_15(digit_15),
2602 m_separator(separator),
-
2603 m_scope_id_separator(scope_id_separator),
-
2604 scope_id(_scope_id)
+
2603 m_scope_id_separator(scope_id_separator),
+
2605 {
-
2606 memset(&value, 0, sizeof(value));
+
2606 memset(&value, 0, sizeof(value));
2607 }
2608
2609 virtual bool match(
-
2610 _In_reads_or_z_(end) const T* text,
-
2611 _In_ size_t start = 0,
-
2612 _In_ size_t end = (size_t)-1,
-
2613 _In_ int flags = match_default)
+
2610 _In_reads_or_z_(end) const T* text,
+
2611 _In_ size_t start = 0,
+
2612 _In_ size_t end = (size_t)-1,
+
2613 _In_ int flags = match_default)
2614 {
-
2615 assert(text || start >= end);
+
2615 assert(text || start >= end);
2616 interval.end = start;
-
2617 memset(&value, 0, sizeof(value));
+
2617 memset(&value, 0, sizeof(value));
2618
-
2619 size_t i, compaction_i = (size_t)-1, compaction_start = start;
-
2620 for (i = 0; i < 8; i++) {
-
2621 bool is_empty = true;
+
2619 size_t i, compaction_i = (size_t)-1, compaction_start = start;
+
2620 for (i = 0; i < 8; i++) {
+
2621 bool is_empty = true;
2622
-
2623 if (m_separator->match(text, interval.end, end, flags)) {
-
2624 if (m_separator->match(text, m_separator->interval.end, end, flags)) {
+
2623 if (m_separator->match(text, interval.end, end, flags)) {
+
2624 if (m_separator->match(text, m_separator->interval.end, end, flags)) {
2625 // :: found
-
2626 if (compaction_i == (size_t)-1) {
+
2626 if (compaction_i == (size_t)-1) {
2627 // Zero compaction start
-
2628 compaction_i = i;
-
2629 compaction_start = m_separator->interval.start;
+
2628 compaction_i = i;
+
2629 compaction_start = m_separator->interval.start;
2630 interval.end = m_separator->interval.end;
2631 }
2632 else {
@@ -2591,79 +2675,79 @@ $(function() {
2634 break;
2635 }
2636 }
-
2637 else if (i) {
+
2637 else if (i) {
2638 // Inner : found
2639 interval.end = m_separator->interval.end;
2640 }
2641 else {
2642 // Leading : found
-
2643 goto error;
+
2643 goto error;
2644 }
2645 }
-
2646 else if (i) {
+
2646 else if (i) {
2647 // : missing
2648 break;
2649 }
2650
- -
2652 size_t x;
-
2653 for (x = 0; interval.end < end && text[interval.end];) {
-
2654 size_t dig, digit_end;
-
2655 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; digit_end = m_digit_0->interval.end; }
-
2656 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; digit_end = m_digit_1->interval.end; }
-
2657 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; digit_end = m_digit_2->interval.end; }
-
2658 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; digit_end = m_digit_3->interval.end; }
-
2659 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; digit_end = m_digit_4->interval.end; }
-
2660 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; digit_end = m_digit_5->interval.end; }
-
2661 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; digit_end = m_digit_6->interval.end; }
-
2662 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; digit_end = m_digit_7->interval.end; }
-
2663 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; digit_end = m_digit_8->interval.end; }
-
2664 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; digit_end = m_digit_9->interval.end; }
-
2665 else if (m_digit_10->match(text, interval.end, end, flags)) { dig = 10; digit_end = m_digit_10->interval.end; }
-
2666 else if (m_digit_11->match(text, interval.end, end, flags)) { dig = 11; digit_end = m_digit_11->interval.end; }
-
2667 else if (m_digit_12->match(text, interval.end, end, flags)) { dig = 12; digit_end = m_digit_12->interval.end; }
-
2668 else if (m_digit_13->match(text, interval.end, end, flags)) { dig = 13; digit_end = m_digit_13->interval.end; }
-
2669 else if (m_digit_14->match(text, interval.end, end, flags)) { dig = 14; digit_end = m_digit_14->interval.end; }
-
2670 else if (m_digit_15->match(text, interval.end, end, flags)) { dig = 15; digit_end = m_digit_15->interval.end; }
+ +
2652 size_t x;
+
2653 for (x = 0; interval.end < end && text[interval.end];) {
+
2654 size_t dig, digit_end;
+
2655 if (m_digit_0->match(text, interval.end, end, flags)) { dig = 0; digit_end = m_digit_0->interval.end; }
+
2656 else if (m_digit_1->match(text, interval.end, end, flags)) { dig = 1; digit_end = m_digit_1->interval.end; }
+
2657 else if (m_digit_2->match(text, interval.end, end, flags)) { dig = 2; digit_end = m_digit_2->interval.end; }
+
2658 else if (m_digit_3->match(text, interval.end, end, flags)) { dig = 3; digit_end = m_digit_3->interval.end; }
+
2659 else if (m_digit_4->match(text, interval.end, end, flags)) { dig = 4; digit_end = m_digit_4->interval.end; }
+
2660 else if (m_digit_5->match(text, interval.end, end, flags)) { dig = 5; digit_end = m_digit_5->interval.end; }
+
2661 else if (m_digit_6->match(text, interval.end, end, flags)) { dig = 6; digit_end = m_digit_6->interval.end; }
+
2662 else if (m_digit_7->match(text, interval.end, end, flags)) { dig = 7; digit_end = m_digit_7->interval.end; }
+
2663 else if (m_digit_8->match(text, interval.end, end, flags)) { dig = 8; digit_end = m_digit_8->interval.end; }
+
2664 else if (m_digit_9->match(text, interval.end, end, flags)) { dig = 9; digit_end = m_digit_9->interval.end; }
+
2665 else if (m_digit_10->match(text, interval.end, end, flags)) { dig = 10; digit_end = m_digit_10->interval.end; }
+
2666 else if (m_digit_11->match(text, interval.end, end, flags)) { dig = 11; digit_end = m_digit_11->interval.end; }
+
2667 else if (m_digit_12->match(text, interval.end, end, flags)) { dig = 12; digit_end = m_digit_12->interval.end; }
+
2668 else if (m_digit_13->match(text, interval.end, end, flags)) { dig = 13; digit_end = m_digit_13->interval.end; }
+
2669 else if (m_digit_14->match(text, interval.end, end, flags)) { dig = 14; digit_end = m_digit_14->interval.end; }
+
2670 else if (m_digit_15->match(text, interval.end, end, flags)) { dig = 15; digit_end = m_digit_15->interval.end; }
2671 else break;
-
2672 size_t x_n = x * 16 + dig;
-
2673 if (x_n <= 0xffff) {
-
2674 x = x_n;
-
2675 interval.end = digit_end;
-
2676 is_empty = false;
+
2672 size_t x_n = x * 16 + dig;
+
2673 if (x_n <= 0xffff) {
+
2674 x = x_n;
+ +
2676 is_empty = false;
2677 }
2678 else
2679 break;
2680 }
-
2681 if (is_empty) {
-
2682 if (compaction_i != (size_t)-1) {
+
2681 if (is_empty) {
+
2682 if (compaction_i != (size_t)-1) {
2683 // Zero compaction active: no sweat.
2684 break;
2685 }
-
2686 goto error;
+
2686 goto error;
2687 }
- -
2689 value.s6_words[i] = (uint16_t)x;
+ +
2689 value.s6_words[i] = (uint16_t)x;
2690 }
2691
-
2692 if (compaction_i != (size_t)-1) {
+
2692 if (compaction_i != (size_t)-1) {
2693 // Align components right due to zero compaction.
-
2694 size_t j, k;
-
2695 for (j = 8, k = i; k > compaction_i;) {
-
2696 value.s6_words[--j] = value.s6_words[--k];
-
2697 components[j] = components[k];
+
2694 size_t j, k;
+
2695 for (j = 8, k = i; k > compaction_i;) {
+
2696 value.s6_words[--j] = value.s6_words[--k];
+
2698 }
-
2699 for (; j > compaction_i;) {
-
2700 value.s6_words[--j] = 0;
-
2701 components[j].start =
-
2702 components[j].end = compaction_start;
+
2699 for (; j > compaction_i;) {
+
2700 value.s6_words[--j] = 0;
+
2701 components[j].start =
+
2703 }
2704 }
-
2705 else if (i < 8)
-
2706 goto error;
+
2705 else if (i < 8)
+
2706 goto error;
2707
-
2708 if (m_scope_id_separator && m_scope_id_separator->match(text, interval.end, end, flags) &&
-
2709 scope_id && scope_id->match(text, m_scope_id_separator->interval.end, end, flags))
+
2708 if (m_scope_id_separator && m_scope_id_separator->match(text, interval.end, end, flags) &&
+
2709 scope_id && scope_id->match(text, m_scope_id_separator->interval.end, end, flags))
2710 interval.end = scope_id->interval.end;
2711 else if (scope_id)
2712 scope_id->invalidate();
@@ -2671,7 +2755,7 @@ $(function() {
2714 interval.start = start;
2715 return true;
2716
-
2717 error:
+
2717 error:
2718 components[0].start = 1;
2719 components[0].end = 0;
2720 components[1].start = 1;
@@ -2688,7 +2772,7 @@ $(function() {
2731 components[6].end = 0;
2732 components[7].start = 1;
2733 components[7].end = 0;
-
2734 memset(&value, 0, sizeof(value));
+
2734 memset(&value, 0, sizeof(value));
2735 if (scope_id) scope_id->invalidate();
2736 interval.start = (interval.end = start) + 1;
2737 return false;
@@ -2712,14 +2796,14 @@ $(function() {
2755 components[6].end = 0;
2756 components[7].start = 1;
2757 components[7].end = 0;
-
2758 memset(&value, 0, sizeof(value));
+
2758 memset(&value, 0, sizeof(value));
2759 if (scope_id) scope_id->invalidate();
2761 }
2762
2763 public:
-
2765 struct in6_addr value;
+
2766 std::shared_ptr<basic_parser<T>> scope_id;
2767
2768 protected:
@@ -2742,43 +2826,45 @@ $(function() {
2785 m_digit_15;
2786 std::shared_ptr<basic_parser<T>> m_separator, m_scope_id_separator;
2787 };
+
2788
-
2789 using ipv6_address = basic_ipv6_address<char>;
-
2790 using wipv6_address = basic_ipv6_address<wchar_t>;
+
2789 using ipv6_address = basic_ipv6_address<char>;
+
2790 using wipv6_address = basic_ipv6_address<wchar_t>;
2791#ifdef _UNICODE
-
2792 using tipv6_address = wipv6_address;
+
2792 using tipv6_address = wipv6_address;
2793#else
-
2794 using tipv6_address = ipv6_address;
+
2794 using tipv6_address = ipv6_address;
2795#endif
-
2796 using sgml_ipv6_address = basic_ipv6_address<char>;
+
2796 using sgml_ipv6_address = basic_ipv6_address<char>;
2797
2801 template <class T>
+
2803 {
2804 public:
-
2806 _In_ bool allow_idn,
-
2807 _In_ const std::locale& locale = std::locale()) :
-
2808 basic_parser<T>(locale),
-
2809 m_allow_idn(allow_idn),
+
2806 _In_ bool allow_idn,
+
2807 _In_ const std::locale& locale = std::locale()) :
+
2808 basic_parser<T>(locale),
+
2809 m_allow_idn(allow_idn),
2810 allow_on_edge(true)
2811 {}
2812
2813 virtual bool match(
-
2814 _In_reads_or_z_(end) const T* text,
-
2815 _In_ size_t start = 0,
-
2816 _In_ size_t end = (size_t)-1,
-
2817 _In_ int flags = match_default)
+
2814 _In_reads_or_z_(end) const T* text,
+
2815 _In_ size_t start = 0,
+
2816 _In_ size_t end = (size_t)-1,
+
2817 _In_ int flags = match_default)
2818 {
-
2819 assert(text || start >= end);
-
2820 if (start < end && text[start]) {
-
2821 if (('A' <= text[start] && text[start] <= 'Z') ||
-
2822 ('a' <= text[start] && text[start] <= 'z') ||
-
2823 ('0' <= text[start] && text[start] <= '9'))
+
2819 assert(text || start >= end);
+
2820 if (start < end && text[start]) {
+
2821 if (('A' <= text[start] && text[start] <= 'Z') ||
+
2822 ('a' <= text[start] && text[start] <= 'z') ||
+
2823 ('0' <= text[start] && text[start] <= '9'))
2824 allow_on_edge = true;
-
2825 else if (text[start] == '-')
+
2825 else if (text[start] == '-')
2826 allow_on_edge = false;
-
2827 else if (m_allow_idn && std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
+
2827 else if (m_allow_idn && std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
2828 allow_on_edge = true;
2829 else {
2830 interval.start = (interval.end = start) + 1;
@@ -2797,42 +2883,44 @@ $(function() {
2843 protected:
2844 bool m_allow_idn;
2845 };
+
2846
-
2847 using dns_domain_char = basic_dns_domain_char<char>;
-
2848 using wdns_domain_char = basic_dns_domain_char<wchar_t>;
+
2847 using dns_domain_char = basic_dns_domain_char<char>;
+
2848 using wdns_domain_char = basic_dns_domain_char<wchar_t>;
2849#ifdef _UNICODE
-
2850 using tdns_domain_char = wdns_domain_char;
+
2850 using tdns_domain_char = wdns_domain_char;
2851#else
2852 using tdns_domain_char = dns_domain_char;
2853#endif
2854
+
2859 {
2860 public:
-
2862 _In_ bool allow_idn,
-
2863 _In_ const std::locale& locale = std::locale()) :
-
2864 basic_dns_domain_char<char>(allow_idn, locale)
+
2862 _In_ bool allow_idn,
+
2863 _In_ const std::locale& locale = std::locale()) :
+
2865 {}
2866
2867 virtual bool match(
-
2868 _In_reads_or_z_(end) const char* text,
-
2869 _In_ size_t start = 0,
-
2870 _In_ size_t end = (size_t)-1,
-
2871 _In_ int flags = match_default)
+
2868 _In_reads_or_z_(end) const char* text,
+
2869 _In_ size_t start = 0,
+
2870 _In_ size_t end = (size_t)-1,
+
2871 _In_ int flags = match_default)
2872 {
-
2873 assert(text || start >= end);
-
2874 if (start < end && text[start]) {
+
2873 assert(text || start >= end);
+
2874 if (start < end && text[start]) {
2875 wchar_t buf[3];
-
2876 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
2877 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
2878 if ((('A' <= chr[0] && chr[0] <= 'Z') ||
-
2879 ('a' <= chr[0] && chr[0] <= 'z') ||
-
2880 ('0' <= chr[0] && chr[0] <= '9')) && chr[1] == 0)
+
2876 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
2877 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
2878 if ((('A' <= chr[0] && chr[0] <= 'Z') ||
+
2879 ('a' <= chr[0] && chr[0] <= 'z') ||
+
2880 ('0' <= chr[0] && chr[0] <= '9')) && chr[1] == 0)
2881 allow_on_edge = true;
-
2882 else if (chr[0] == '-' && chr[1] == 0)
+
2882 else if (chr[0] == '-' && chr[1] == 0)
2883 allow_on_edge = false;
-
2884 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)
+
2884 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)
2885 allow_on_edge = true;
2886 else {
2887 interval.start = (interval.end = start) + 1;
@@ -2845,54 +2933,56 @@ $(function() {
2894 return false;
2895 }
2896 };
+
2897
2901 template <class T>
+
2903 {
2904 public:
-
2906 _In_ bool allow_absolute,
-
2907 _In_ const std::shared_ptr<basic_dns_domain_char<T>>& domain_char,
-
2908 _In_ const std::shared_ptr<basic_parser<T>>& separator,
-
2909 _In_ const std::locale& locale = std::locale()) :
-
2910 basic_parser<T>(locale),
-
2911 m_allow_absolute(allow_absolute),
-
2912 m_domain_char(domain_char),
+
2906 _In_ bool allow_absolute,
+
2907 _In_ const std::shared_ptr<basic_dns_domain_char<T>>& domain_char,
+
2908 _In_ const std::shared_ptr<basic_parser<T>>& separator,
+
2909 _In_ const std::locale& locale = std::locale()) :
+
2910 basic_parser<T>(locale),
+ +
2912 m_domain_char(domain_char),
2913 m_separator(separator)
2914 {}
2915
2916 virtual bool match(
-
2917 _In_reads_or_z_(end) const T* text,
-
2918 _In_ size_t start = 0,
-
2919 _In_ size_t end = (size_t)-1,
-
2920 _In_ int flags = match_default)
+
2917 _In_reads_or_z_(end) const T* text,
+
2918 _In_ size_t start = 0,
+
2919 _In_ size_t end = (size_t)-1,
+
2920 _In_ int flags = match_default)
2921 {
-
2922 assert(text || start >= end);
-
2923 size_t i = start, count;
-
2924 for (count = 0; i < end && text[i] && count < 127; count++) {
-
2925 if (m_domain_char->match(text, i, end, flags) &&
+
2922 assert(text || start >= end);
+
2923 size_t i = start, count;
+
2924 for (count = 0; i < end && text[i] && count < 127; count++) {
+
2925 if (m_domain_char->match(text, i, end, flags) &&
2926 m_domain_char->allow_on_edge)
2927 {
2928 // Domain start
-
2929 interval.end = i = m_domain_char->interval.end;
-
2930 while (i < end && text[i]) {
+
2929 interval.end = i = m_domain_char->interval.end;
+
2930 while (i < end && text[i]) {
2931 if (m_domain_char->allow_on_edge &&
-
2932 m_separator->match(text, i, end, flags))
+
2932 m_separator->match(text, i, end, flags))
2933 {
2934 // Domain end
2935 if (m_allow_absolute)
-
2936 interval.end = i = m_separator->interval.end;
+
2936 interval.end = i = m_separator->interval.end;
2937 else {
-
2938 interval.end = i;
-
2939 i = m_separator->interval.end;
+
2938 interval.end = i;
+
2939 i = m_separator->interval.end;
2940 }
2941 break;
2942 }
-
2943 if (m_domain_char->match(text, i, end, flags)) {
+
2943 if (m_domain_char->match(text, i, end, flags)) {
2944 if (m_domain_char->allow_on_edge)
-
2945 interval.end = i = m_domain_char->interval.end;
+
2945 interval.end = i = m_domain_char->interval.end;
2946 else
-
2947 i = m_domain_char->interval.end;
+
2947 i = m_domain_char->interval.end;
2948 }
2949 else {
2950 interval.start = start;
@@ -2903,7 +2993,7 @@ $(function() {
2955 else
2956 break;
2957 }
-
2958 if (count) {
+
2958 if (count) {
2959 interval.start = start;
2960 return true;
2961 }
@@ -2916,47 +3006,49 @@ $(function() {
2968 std::shared_ptr<basic_dns_domain_char<T>> m_domain_char;
2969 std::shared_ptr<basic_parser<T>> m_separator;
2970 };
+
2971
-
2972 using dns_name = basic_dns_name<char>;
-
2973 using wdns_name = basic_dns_name<wchar_t>;
+
2972 using dns_name = basic_dns_name<char>;
+
2973 using wdns_name = basic_dns_name<wchar_t>;
2974#ifdef _UNICODE
-
2975 using tdns_name = wdns_name;
+
2975 using tdns_name = wdns_name;
2976#else
-
2977 using tdns_name = dns_name;
+
2977 using tdns_name = dns_name;
2978#endif
-
2979 using sgml_dns_name = basic_dns_name<char>;
+
2979 using sgml_dns_name = basic_dns_name<char>;
2980
2984 template <class T>
+
2986 {
2987 public:
-
2988 basic_url_username_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
+
2988 basic_url_username_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
2989
2990 virtual bool match(
-
2991 _In_reads_or_z_(end) const T* text,
-
2992 _In_ size_t start = 0,
-
2993 _In_ size_t end = (size_t)-1,
-
2994 _In_ int flags = match_default)
+
2991 _In_reads_or_z_(end) const T* text,
+
2992 _In_ size_t start = 0,
+
2993 _In_ size_t end = (size_t)-1,
+
2994 _In_ int flags = match_default)
2995 {
-
2996 assert(text || start >= end);
-
2997 if (start < end && text[start]) {
-
2998 if (text[start] == '-' ||
-
2999 text[start] == '.' ||
-
3000 text[start] == '_' ||
-
3001 text[start] == '~' ||
-
3002 text[start] == '%' ||
-
3003 text[start] == '!' ||
-
3004 text[start] == '$' ||
-
3005 text[start] == '&' ||
-
3006 text[start] == '\'' ||
+
2996 assert(text || start >= end);
+
2997 if (start < end && text[start]) {
+
2998 if (text[start] == '-' ||
+
2999 text[start] == '.' ||
+
3000 text[start] == '_' ||
+
3001 text[start] == '~' ||
+
3002 text[start] == '%' ||
+
3003 text[start] == '!' ||
+
3004 text[start] == '$' ||
+
3005 text[start] == '&' ||
+
3006 text[start] == '\'' ||
3007 //text[start] == '(' ||
3008 //text[start] == ')' ||
-
3009 text[start] == '*' ||
-
3010 text[start] == '+' ||
-
3011 text[start] == ',' ||
-
3012 text[start] == ';' ||
-
3013 text[start] == '=' ||
-
3014 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
+
3009 text[start] == '*' ||
+
3010 text[start] == '+' ||
+
3011 text[start] == ',' ||
+
3012 text[start] == ';' ||
+
3013 text[start] == '=' ||
+
3014 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
3015 {
3016 interval.end = (interval.start = start) + 1;
3017 return true;
@@ -2966,48 +3058,50 @@ $(function() {
3021 return false;
3022 }
3023 };
+
3024
-
3025 using url_username_char = basic_url_username_char<char>;
-
3026 using wurl_username_char = basic_url_username_char<wchar_t>;
+
3025 using url_username_char = basic_url_username_char<char>;
+
3026 using wurl_username_char = basic_url_username_char<wchar_t>;
3027#ifdef _UNICODE
-
3028 using turl_username_char = wurl_username_char;
+
3028 using turl_username_char = wurl_username_char;
3029#else
3030 using turl_username_char = url_username_char;
3031#endif
3032
+
3037 {
3038 public:
-
3039 sgml_url_username_char(_In_ const std::locale& locale = std::locale()) : basic_url_username_char<char>(locale) {}
+
3039 sgml_url_username_char(_In_ const std::locale& locale = std::locale()) : basic_url_username_char<char>(locale) {}
3040
3041 virtual bool match(
-
3042 _In_reads_or_z_(end) const char* text,
-
3043 _In_ size_t start = 0,
-
3044 _In_ size_t end = (size_t)-1,
-
3045 _In_ int flags = match_default)
+
3042 _In_reads_or_z_(end) const char* text,
+
3043 _In_ size_t start = 0,
+
3044 _In_ size_t end = (size_t)-1,
+
3045 _In_ int flags = match_default)
3046 {
-
3047 assert(text || start >= end);
-
3048 if (start < end && text[start]) {
+
3047 assert(text || start >= end);
+
3048 if (start < end && text[start]) {
3049 wchar_t buf[3];
-
3050 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
3051 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
3052 if ((chr[0] == L'-' ||
-
3053 chr[0] == L'.' ||
-
3054 chr[0] == L'_' ||
-
3055 chr[0] == L'~' ||
-
3056 chr[0] == L'%' ||
-
3057 chr[0] == L'!' ||
-
3058 chr[0] == L'$' ||
-
3059 chr[0] == L'&' ||
-
3060 chr[0] == L'\'' ||
+
3050 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
3051 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
3052 if ((chr[0] == L'-' ||
+
3053 chr[0] == L'.' ||
+
3054 chr[0] == L'_' ||
+
3055 chr[0] == L'~' ||
+
3056 chr[0] == L'%' ||
+
3057 chr[0] == L'!' ||
+
3058 chr[0] == L'$' ||
+
3059 chr[0] == L'&' ||
+
3060 chr[0] == L'\'' ||
3061 //chr[0] == L'(' ||
3062 //chr[0] == L')' ||
-
3063 chr[0] == L'*' ||
-
3064 chr[0] == L'+' ||
-
3065 chr[0] == L',' ||
-
3066 chr[0] == L';' ||
-
3067 chr[0] == L'=') && chr[1] == 0 ||
-
3068 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
+
3063 chr[0] == L'*' ||
+
3064 chr[0] == L'+' ||
+
3065 chr[0] == L',' ||
+
3066 chr[0] == L';' ||
+
3067 chr[0] == L'=') && chr[1] == 0 ||
+
3068 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
3069 {
3070 interval.start = start;
3071 return true;
@@ -3018,39 +3112,41 @@ $(function() {
3076 return false;
3077 }
3078 };
+
3079
3083 template <class T>
+
3085 {
3086 public:
-
3087 basic_url_password_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
+
3087 basic_url_password_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
3088
3089 virtual bool match(
-
3090 _In_reads_or_z_(end) const T* text,
-
3091 _In_ size_t start = 0,
-
3092 _In_ size_t end = (size_t)-1,
-
3093 _In_ int flags = match_default)
+
3090 _In_reads_or_z_(end) const T* text,
+
3091 _In_ size_t start = 0,
+
3092 _In_ size_t end = (size_t)-1,
+
3093 _In_ int flags = match_default)
3094 {
-
3095 assert(text || start >= end);
-
3096 if (start < end && text[start]) {
-
3097 if (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 text[start] == '=' ||
-
3113 text[start] == ':' ||
-
3114 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
+
3095 assert(text || start >= end);
+
3096 if (start < end && text[start]) {
+
3097 if (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 text[start] == '=' ||
+
3113 text[start] == ':' ||
+
3114 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
3115 {
3116 interval.end = (interval.start = start) + 1;
3117 return true;
@@ -3060,49 +3156,51 @@ $(function() {
3121 return false;
3122 }
3123 };
+
3124
-
3125 using url_password_char = basic_url_password_char<char>;
-
3126 using wurl_password_char = basic_url_password_char<wchar_t>;
+
3125 using url_password_char = basic_url_password_char<char>;
+
3126 using wurl_password_char = basic_url_password_char<wchar_t>;
3127#ifdef _UNICODE
-
3128 using turl_password_char = wurl_password_char;
+
3128 using turl_password_char = wurl_password_char;
3129#else
3130 using turl_password_char = url_password_char;
3131#endif
3132
+
3137 {
3138 public:
-
3139 sgml_url_password_char(_In_ const std::locale& locale = std::locale()) : basic_url_password_char<char>(locale) {}
+
3139 sgml_url_password_char(_In_ const std::locale& locale = std::locale()) : basic_url_password_char<char>(locale) {}
3140
3141 virtual bool match(
-
3142 _In_reads_or_z_(end) const char* text,
-
3143 _In_ size_t start = 0,
-
3144 _In_ size_t end = (size_t)-1,
-
3145 _In_ int flags = match_default)
+
3142 _In_reads_or_z_(end) const char* text,
+
3143 _In_ size_t start = 0,
+
3144 _In_ size_t end = (size_t)-1,
+
3145 _In_ int flags = match_default)
3146 {
-
3147 assert(text || start >= end);
-
3148 if (start < end && text[start]) {
+
3147 assert(text || start >= end);
+
3148 if (start < end && text[start]) {
3149 wchar_t buf[3];
-
3150 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
3151 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
3152 if ((chr[0] == L'-' ||
-
3153 chr[0] == L'.' ||
-
3154 chr[0] == L'_' ||
-
3155 chr[0] == L'~' ||
-
3156 chr[0] == L'%' ||
-
3157 chr[0] == L'!' ||
-
3158 chr[0] == L'$' ||
-
3159 chr[0] == L'&' ||
-
3160 chr[0] == L'\'' ||
-
3161 chr[0] == L'(' ||
-
3162 chr[0] == L')' ||
-
3163 chr[0] == L'*' ||
-
3164 chr[0] == L'+' ||
-
3165 chr[0] == L',' ||
-
3166 chr[0] == L';' ||
-
3167 chr[0] == L'=' ||
-
3168 chr[0] == L':') && chr[1] == 0 ||
-
3169 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
+
3150 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
3151 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
3152 if ((chr[0] == L'-' ||
+
3153 chr[0] == L'.' ||
+
3154 chr[0] == L'_' ||
+
3155 chr[0] == L'~' ||
+
3156 chr[0] == L'%' ||
+
3157 chr[0] == L'!' ||
+
3158 chr[0] == L'$' ||
+
3159 chr[0] == L'&' ||
+
3160 chr[0] == L'\'' ||
+
3161 chr[0] == L'(' ||
+
3162 chr[0] == L')' ||
+
3163 chr[0] == L'*' ||
+
3164 chr[0] == L'+' ||
+
3165 chr[0] == L',' ||
+
3166 chr[0] == L';' ||
+
3167 chr[0] == L'=' ||
+
3168 chr[0] == L':') && chr[1] == 0 ||
+
3169 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
3170 {
3171 interval.start = start;
3172 return true;
@@ -3112,43 +3210,45 @@ $(function() {
3176 return false;
3177 }
3178 };
+
3179
3183 template <class T>
+
3185 {
3186 public:
-
3187 basic_url_path_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
+
3187 basic_url_path_char(_In_ const std::locale& locale = std::locale()) : basic_parser<T>(locale) {}
3188
3189 virtual bool match(
-
3190 _In_reads_or_z_(end) const T* text,
-
3191 _In_ size_t start = 0,
-
3192 _In_ size_t end = (size_t)-1,
-
3193 _In_ int flags = match_default)
+
3190 _In_reads_or_z_(end) const T* text,
+
3191 _In_ size_t start = 0,
+
3192 _In_ size_t end = (size_t)-1,
+
3193 _In_ int flags = match_default)
3194 {
-
3195 assert(text || start >= end);
-
3196 if (start < end && text[start]) {
-
3197 if (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 text[start] == '?' ||
-
3217 text[start] == '#' ||
-
3218 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
+
3195 assert(text || start >= end);
+
3196 if (start < end && text[start]) {
+
3197 if (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 text[start] == '?' ||
+
3217 text[start] == '#' ||
+
3218 std::use_facet<std::ctype<T>>(m_locale).is(std::ctype_base::alnum, text[start]))
3219 {
3220 interval.end = (interval.start = start) + 1;
3221 return true;
@@ -3158,53 +3258,55 @@ $(function() {
3225 return false;
3226 }
3227 };
+
3228
-
3229 using url_path_char = basic_url_path_char<char>;
-
3230 using wurl_path_char = basic_url_path_char<wchar_t>;
+
3229 using url_path_char = basic_url_path_char<char>;
+
3230 using wurl_path_char = basic_url_path_char<wchar_t>;
3231#ifdef _UNICODE
-
3232 using turl_path_char = wurl_path_char;
+
3232 using turl_path_char = wurl_path_char;
3233#else
3234 using turl_path_char = url_path_char;
3235#endif
3236
+
3241 {
3242 public:
-
3243 sgml_url_path_char(_In_ const std::locale& locale = std::locale()) : basic_url_path_char<char>(locale) {}
+
3243 sgml_url_path_char(_In_ const std::locale& locale = std::locale()) : basic_url_path_char<char>(locale) {}
3244
3245 virtual bool match(
-
3246 _In_reads_or_z_(end) const char* text,
-
3247 _In_ size_t start = 0,
-
3248 _In_ size_t end = (size_t)-1,
-
3249 _In_ int flags = match_default)
+
3246 _In_reads_or_z_(end) const char* text,
+
3247 _In_ size_t start = 0,
+
3248 _In_ size_t end = (size_t)-1,
+
3249 _In_ int flags = match_default)
3250 {
-
3251 assert(text || start >= end);
-
3252 if (start < end && text[start]) {
+
3251 assert(text || start >= end);
+
3252 if (start < end && text[start]) {
3253 wchar_t buf[3];
-
3254 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
-
3255 const wchar_t* chr_end = chr + stdex::strlen(chr);
-
3256 if ((chr[0] == L'/' ||
-
3257 chr[0] == L'-' ||
-
3258 chr[0] == L'.' ||
-
3259 chr[0] == L'_' ||
-
3260 chr[0] == L'~' ||
-
3261 chr[0] == L'%' ||
-
3262 chr[0] == L'!' ||
-
3263 chr[0] == L'$' ||
-
3264 chr[0] == L'&' ||
-
3265 chr[0] == L'\'' ||
-
3266 chr[0] == L'(' ||
-
3267 chr[0] == L')' ||
-
3268 chr[0] == L'*' ||
-
3269 chr[0] == L'+' ||
-
3270 chr[0] == L',' ||
-
3271 chr[0] == L';' ||
-
3272 chr[0] == L'=' ||
-
3273 chr[0] == L':' ||
-
3274 chr[0] == L'@' ||
-
3275 chr[0] == L'?' ||
-
3276 chr[0] == L'#') && chr[1] == 0 ||
-
3277 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
+
3254 const wchar_t* chr = next_sgml_cp(text, start, end, interval.end, buf);
+
3255 const wchar_t* chr_end = chr + stdex::strlen(chr);
+
3256 if ((chr[0] == L'/' ||
+
3257 chr[0] == L'-' ||
+
3258 chr[0] == L'.' ||
+
3259 chr[0] == L'_' ||
+
3260 chr[0] == L'~' ||
+
3261 chr[0] == L'%' ||
+
3262 chr[0] == L'!' ||
+
3263 chr[0] == L'$' ||
+
3264 chr[0] == L'&' ||
+
3265 chr[0] == L'\'' ||
+
3266 chr[0] == L'(' ||
+
3267 chr[0] == L')' ||
+
3268 chr[0] == L'*' ||
+
3269 chr[0] == L'+' ||
+
3270 chr[0] == L',' ||
+
3271 chr[0] == L';' ||
+
3272 chr[0] == L'=' ||
+
3273 chr[0] == L':' ||
+
3274 chr[0] == L'@' ||
+
3275 chr[0] == L'?' ||
+
3276 chr[0] == L'#') && chr[1] == 0 ||
+
3277 std::use_facet<std::ctype<wchar_t>>(m_locale).scan_not(std::ctype_base::alnum, chr, chr_end) == chr_end)
3278 {
3279 interval.start = start;
3280 return true;
@@ -3214,29 +3316,31 @@ $(function() {
3284 return false;
3285 }
3286 };
+
3287
3291 template <class T>
+
3293 {
3294 public:
-
3296 _In_ const std::shared_ptr<basic_parser<T>>& path_char,
-
3297 _In_ const std::shared_ptr<basic_parser<T>>& query_start,
-
3298 _In_ const std::shared_ptr<basic_parser<T>>& bookmark_start,
-
3299 _In_ const std::locale& locale = std::locale()) :
-
3300 basic_parser<T>(locale),
-
3301 m_path_char(path_char),
-
3302 m_query_start(query_start),
-
3303 m_bookmark_start(bookmark_start)
+
3296 _In_ const std::shared_ptr<basic_parser<T>>& path_char,
+
3297 _In_ const std::shared_ptr<basic_parser<T>>& query_start,
+
3298 _In_ const std::shared_ptr<basic_parser<T>>& bookmark_start,
+
3299 _In_ const std::locale& locale = std::locale()) :
+
3300 basic_parser<T>(locale),
+
3301 m_path_char(path_char),
+
3302 m_query_start(query_start),
+
3303 m_bookmark_start(bookmark_start)
3304 {}
3305
3306 virtual bool match(
-
3307 _In_reads_or_z_(end) const T* text,
-
3308 _In_ size_t start = 0,
-
3309 _In_ size_t end = (size_t)-1,
-
3310 _In_ int flags = match_default)
+
3307 _In_reads_or_z_(end) const T* text,
+
3308 _In_ size_t start = 0,
+
3309 _In_ size_t end = (size_t)-1,
+
3310 _In_ int flags = match_default)
3311 {
-
3312 assert(text || start >= end);
+
3312 assert(text || start >= end);
3313
3314 interval.end = start;
3315 path.start = start;
@@ -3246,25 +3350,25 @@ $(function() {
3319 bookmark.end = 0;
3320
3321 for (;;) {
-
3322 if (interval.end >= end || !text[interval.end])
+
3322 if (interval.end >= end || !text[interval.end])
3323 break;
-
3324 if (m_query_start->match(text, interval.end, end, flags)) {
+
3324 if (m_query_start->match(text, interval.end, end, flags)) {
3325 path.end = interval.end;
3326 query.start = interval.end = m_query_start->interval.end;
3327 for (;;) {
-
3328 if (interval.end >= end || !text[interval.end]) {
+
3328 if (interval.end >= end || !text[interval.end]) {
3329 query.end = interval.end;
3330 break;
3331 }
-
3332 if (m_bookmark_start->match(text, interval.end, end, flags)) {
+
3332 if (m_bookmark_start->match(text, interval.end, end, flags)) {
3333 query.end = interval.end;
3334 bookmark.start = interval.end = m_bookmark_start->interval.end;
3335 for (;;) {
-
3336 if (interval.end >= end || !text[interval.end]) {
+
3336 if (interval.end >= end || !text[interval.end]) {
3337 bookmark.end = interval.end;
3338 break;
3339 }
-
3340 if (m_path_char->match(text, interval.end, end, flags))
+
3340 if (m_path_char->match(text, interval.end, end, flags))
3341 interval.end = m_path_char->interval.end;
3342 else {
3343 bookmark.end = interval.end;
@@ -3274,7 +3378,7 @@ $(function() {
3347 interval.start = start;
3348 return true;
3349 }
-
3350 if (m_path_char->match(text, interval.end, end, flags))
+
3350 if (m_path_char->match(text, interval.end, end, flags))
3351 interval.end = m_path_char->interval.end;
3352 else {
3353 query.end = interval.end;
@@ -3284,15 +3388,15 @@ $(function() {
3357 interval.start = start;
3358 return true;
3359 }
-
3360 if (m_bookmark_start->match(text, interval.end, end, flags)) {
+
3360 if (m_bookmark_start->match(text, interval.end, end, flags)) {
3361 path.end = interval.end;
3362 bookmark.start = interval.end = m_bookmark_start->interval.end;
3363 for (;;) {
-
3364 if (interval.end >= end || !text[interval.end]) {
+
3364 if (interval.end >= end || !text[interval.end]) {
3365 bookmark.end = interval.end;
3366 break;
3367 }
-
3368 if (m_path_char->match(text, interval.end, end, flags))
+
3368 if (m_path_char->match(text, interval.end, end, flags))
3369 interval.end = m_path_char->interval.end;
3370 else {
3371 bookmark.end = interval.end;
@@ -3302,7 +3406,7 @@ $(function() {
3375 interval.start = start;
3376 return true;
3377 }
-
3378 if (m_path_char->match(text, interval.end, end, flags))
+
3378 if (m_path_char->match(text, interval.end, end, flags))
3379 interval.end = m_path_char->interval.end;
3380 else
3381 break;
@@ -3343,71 +3447,73 @@ $(function() {
3416 std::shared_ptr<basic_parser<T>> m_query_start;
3417 std::shared_ptr<basic_parser<T>> m_bookmark_start;
3418 };
+
3419
-
3420 using url_path = basic_url_path<char>;
-
3421 using wurl_path = basic_url_path<wchar_t>;
+
3420 using url_path = basic_url_path<char>;
+
3421 using wurl_path = basic_url_path<wchar_t>;
3422#ifdef _UNICODE
-
3423 using turl_path = wurl_path;
+
3423 using turl_path = wurl_path;
3424#else
-
3425 using turl_path = url_path;
+
3425 using turl_path = url_path;
3426#endif
-
3427 using sgml_url_path = basic_url_path<char>;
+
3427 using sgml_url_path = basic_url_path<char>;
3428
3432 template <class T>
+
3433 class basic_url : public basic_parser<T>
3434 {
3435 public:
3436 basic_url(
-
3437 _In_ const std::shared_ptr<basic_parser<T>>& _http_scheme,
-
3438 _In_ const std::shared_ptr<basic_parser<T>>& _ftp_scheme,
-
3439 _In_ const std::shared_ptr<basic_parser<T>>& _mailto_scheme,
-
3440 _In_ const std::shared_ptr<basic_parser<T>>& _file_scheme,
-
3441 _In_ const std::shared_ptr<basic_parser<T>>& colon,
-
3442 _In_ const std::shared_ptr<basic_parser<T>>& slash,
-
3443 _In_ const std::shared_ptr<basic_parser<T>>& _username,
-
3444 _In_ const std::shared_ptr<basic_parser<T>>& _password,
-
3445 _In_ const std::shared_ptr<basic_parser<T>>& at,
-
3446 _In_ const std::shared_ptr<basic_parser<T>>& ip_lbracket,
-
3447 _In_ const std::shared_ptr<basic_parser<T>>& ip_rbracket,
-
3448 _In_ const std::shared_ptr<basic_parser<T>>& _ipv4_host,
-
3449 _In_ const std::shared_ptr<basic_parser<T>>& _ipv6_host,
-
3450 _In_ const std::shared_ptr<basic_parser<T>>& _dns_host,
-
3451 _In_ const std::shared_ptr<basic_parser<T>>& _port,
-
3452 _In_ const std::shared_ptr<basic_parser<T>>& _path,
-
3453 _In_ const std::locale& locale = std::locale()) :
-
3454 basic_parser<T>(locale),
-
3455 http_scheme(_http_scheme),
-
3456 ftp_scheme(_ftp_scheme),
-
3457 mailto_scheme(_mailto_scheme),
-
3458 file_scheme(_file_scheme),
-
3459 m_colon(colon),
-
3460 m_slash(slash),
-
3461 username(_username),
-
3462 password(_password),
+
3437 _In_ const std::shared_ptr<basic_parser<T>>& _http_scheme,
+
3438 _In_ const std::shared_ptr<basic_parser<T>>& _ftp_scheme,
+
3439 _In_ const std::shared_ptr<basic_parser<T>>& _mailto_scheme,
+
3440 _In_ const std::shared_ptr<basic_parser<T>>& _file_scheme,
+
3441 _In_ const std::shared_ptr<basic_parser<T>>& colon,
+
3442 _In_ const std::shared_ptr<basic_parser<T>>& slash,
+
3443 _In_ const std::shared_ptr<basic_parser<T>>& _username,
+
3444 _In_ const std::shared_ptr<basic_parser<T>>& _password,
+
3445 _In_ const std::shared_ptr<basic_parser<T>>& at,
+
3446 _In_ const std::shared_ptr<basic_parser<T>>& ip_lbracket,
+
3447 _In_ const std::shared_ptr<basic_parser<T>>& ip_rbracket,
+
3448 _In_ const std::shared_ptr<basic_parser<T>>& _ipv4_host,
+
3449 _In_ const std::shared_ptr<basic_parser<T>>& _ipv6_host,
+
3450 _In_ const std::shared_ptr<basic_parser<T>>& _dns_host,
+
3451 _In_ const std::shared_ptr<basic_parser<T>>& _port,
+
3452 _In_ const std::shared_ptr<basic_parser<T>>& _path,
+
3453 _In_ const std::locale& locale = std::locale()) :
+
3454 basic_parser<T>(locale),
+
3455 http_scheme(_http_scheme),
+
3456 ftp_scheme(_ftp_scheme),
+
3457 mailto_scheme(_mailto_scheme),
+
3458 file_scheme(_file_scheme),
+
3459 m_colon(colon),
+
3460 m_slash(slash),
+
3461 username(_username),
+
3462 password(_password),
3463 m_at(at),
-
3464 m_ip_lbracket(ip_lbracket),
-
3465 m_ip_rbracket(ip_rbracket),
-
3466 ipv4_host(_ipv4_host),
-
3467 ipv6_host(_ipv6_host),
-
3468 dns_host(_dns_host),
-
3469 port(_port),
-
3470 path(_path)
+
3464 m_ip_lbracket(ip_lbracket),
+
3465 m_ip_rbracket(ip_rbracket),
+
3466 ipv4_host(_ipv4_host),
+
3467 ipv6_host(_ipv6_host),
+
3468 dns_host(_dns_host),
+
3469 port(_port),
+
3470 path(_path)
3471 {}
3472
3473 virtual bool match(
-
3474 _In_reads_or_z_(end) const T* text,
-
3475 _In_ size_t start = 0,
-
3476 _In_ size_t end = (size_t)-1,
-
3477 _In_ int flags = match_default)
+
3474 _In_reads_or_z_(end) const T* text,
+
3475 _In_ size_t start = 0,
+
3476 _In_ size_t end = (size_t)-1,
+
3477 _In_ int flags = match_default)
3478 {
-
3479 assert(text || start >= end);
+
3479 assert(text || start >= end);
3480
3481 interval.end = start;
3482
-
3483 if (http_scheme->match(text, interval.end, end, flags) &&
-
3484 m_colon->match(text, http_scheme->interval.end, end, flags) &&
-
3485 m_slash->match(text, m_colon->interval.end, end, flags) &&
-
3486 m_slash->match(text, m_slash->interval.end, end, flags))
+
3483 if (http_scheme->match(text, interval.end, end, flags) &&
+
3484 m_colon->match(text, http_scheme->interval.end, end, flags) &&
+
3485 m_slash->match(text, m_colon->interval.end, end, flags) &&
+
3486 m_slash->match(text, m_slash->interval.end, end, flags))
3487 {
3488 // http://
3489 interval.end = m_slash->interval.end;
@@ -3415,10 +3521,10 @@ $(function() {
3491 mailto_scheme->invalidate();
3492 file_scheme->invalidate();
3493 }
-
3494 else if (ftp_scheme->match(text, interval.end, end, flags) &&
-
3495 m_colon->match(text, ftp_scheme->interval.end, end, flags) &&
-
3496 m_slash->match(text, m_colon->interval.end, end, flags) &&
-
3497 m_slash->match(text, m_slash->interval.end, end, flags))
+
3494 else if (ftp_scheme->match(text, interval.end, end, flags) &&
+
3495 m_colon->match(text, ftp_scheme->interval.end, end, flags) &&
+
3496 m_slash->match(text, m_colon->interval.end, end, flags) &&
+
3497 m_slash->match(text, m_slash->interval.end, end, flags))
3498 {
3499 // ftp://
3500 interval.end = m_slash->interval.end;
@@ -3426,8 +3532,8 @@ $(function() {
3502 mailto_scheme->invalidate();
3503 file_scheme->invalidate();
3504 }
-
3505 else if (mailto_scheme->match(text, interval.end, end, flags) &&
-
3506 m_colon->match(text, mailto_scheme->interval.end, end, flags))
+
3505 else if (mailto_scheme->match(text, interval.end, end, flags) &&
+
3506 m_colon->match(text, mailto_scheme->interval.end, end, flags))
3507 {
3508 // mailto:
3509 interval.end = m_colon->interval.end;
@@ -3435,10 +3541,10 @@ $(function() {
3511 ftp_scheme->invalidate();
3512 file_scheme->invalidate();
3513 }
-
3514 else if (file_scheme->match(text, interval.end, end, flags) &&
-
3515 m_colon->match(text, file_scheme->interval.end, end, flags) &&
-
3516 m_slash->match(text, m_colon->interval.end, end, flags) &&
-
3517 m_slash->match(text, m_slash->interval.end, end, flags))
+
3514 else if (file_scheme->match(text, interval.end, end, flags) &&
+
3515 m_colon->match(text, file_scheme->interval.end, end, flags) &&
+
3516 m_slash->match(text, m_colon->interval.end, end, flags) &&
+
3517 m_slash->match(text, m_slash->interval.end, end, flags))
3518 {
3519 // file://
3520 interval.end = m_slash->interval.end;
@@ -3455,15 +3561,15 @@ $(function() {
3531 }
3532
3533 if (ftp_scheme->interval) {
-
3534 if (username->match(text, interval.end, end, flags)) {
-
3535 if (m_colon->match(text, username->interval.end, end, flags) &&
-
3536 password->match(text, m_colon->interval.end, end, flags) &&
-
3537 m_at->match(text, password->interval.end, end, flags))
+
3534 if (username->match(text, interval.end, end, flags)) {
+
3535 if (m_colon->match(text, username->interval.end, end, flags) &&
+
3536 password->match(text, m_colon->interval.end, end, flags) &&
+
3537 m_at->match(text, password->interval.end, end, flags))
3538 {
3539 // Username and password
3540 interval.end = m_at->interval.end;
3541 }
-
3542 else if (m_at->match(text, interval.end, end, flags)) {
+
3542 else if (m_at->match(text, interval.end, end, flags)) {
3543 // Username only
3544 interval.end = m_at->interval.end;
3545 password->invalidate();
@@ -3478,23 +3584,23 @@ $(function() {
3554 password->invalidate();
3555 }
3556
-
3557 if (ipv4_host->match(text, interval.end, end, flags)) {
+
3557 if (ipv4_host->match(text, interval.end, end, flags)) {
3558 // Host is IPv4
3559 interval.end = ipv4_host->interval.end;
3560 ipv6_host->invalidate();
3561 dns_host->invalidate();
3562 }
3563 else if (
-
3564 m_ip_lbracket->match(text, interval.end, end, flags) &&
-
3565 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
-
3566 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
+
3564 m_ip_lbracket->match(text, interval.end, end, flags) &&
+
3565 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
+
3566 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3567 {
3568 // Host is IPv6
3569 interval.end = m_ip_rbracket->interval.end;
3570 ipv4_host->invalidate();
3571 dns_host->invalidate();
3572 }
-
3573 else if (dns_host->match(text, interval.end, end, flags)) {
+
3573 else if (dns_host->match(text, interval.end, end, flags)) {
3574 // Host is hostname
3575 interval.end = dns_host->interval.end;
3576 ipv4_host->invalidate();
@@ -3505,8 +3611,8 @@ $(function() {
3581 return false;
3582 }
3583
-
3584 if (m_colon->match(text, interval.end, end, flags) &&
-
3585 port->match(text, m_colon->interval.end, end, flags))
+
3584 if (m_colon->match(text, interval.end, end, flags) &&
+
3585 port->match(text, m_colon->interval.end, end, flags))
3586 {
3587 // Port
3588 interval.end = port->interval.end;
@@ -3514,7 +3620,7 @@ $(function() {
3590 else
3591 port->invalidate();
3592
-
3593 if (path->match(text, interval.end, end, flags)) {
+
3593 if (path->match(text, interval.end, end, flags)) {
3594 // Path
3595 interval.end = path->interval.end;
3596 }
@@ -3524,8 +3630,8 @@ $(function() {
3600 }
3601
3602 if (mailto_scheme->interval) {
-
3603 if (username->match(text, interval.end, end, flags) &&
-
3604 m_at->match(text, username->interval.end, end, flags))
+
3603 if (username->match(text, interval.end, end, flags) &&
+
3604 m_at->match(text, username->interval.end, end, flags))
3605 {
3606 // Username
3607 interval.end = m_at->interval.end;
@@ -3535,9 +3641,9 @@ $(function() {
3611 return false;
3612 }
3613
-
3614 if (m_ip_lbracket->match(text, interval.end, end, flags) &&
-
3615 ipv4_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
-
3616 m_ip_rbracket->match(text, ipv4_host->interval.end, end, flags))
+
3614 if (m_ip_lbracket->match(text, interval.end, end, flags) &&
+
3615 ipv4_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
+
3616 m_ip_rbracket->match(text, ipv4_host->interval.end, end, flags))
3617 {
3618 // Host is IPv4
3619 interval.end = m_ip_rbracket->interval.end;
@@ -3545,16 +3651,16 @@ $(function() {
3621 dns_host->invalidate();
3622 }
3623 else if (
-
3624 m_ip_lbracket->match(text, interval.end, end, flags) &&
-
3625 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
-
3626 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
+
3624 m_ip_lbracket->match(text, interval.end, end, flags) &&
+
3625 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
+
3626 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3627 {
3628 // Host is IPv6
3629 interval.end = m_ip_rbracket->interval.end;
3630 ipv4_host->invalidate();
3631 dns_host->invalidate();
3632 }
-
3633 else if (dns_host->match(text, interval.end, end, flags)) {
+
3633 else if (dns_host->match(text, interval.end, end, flags)) {
3634 // Host is hostname
3635 interval.end = dns_host->interval.end;
3636 ipv4_host->invalidate();
@@ -3573,7 +3679,7 @@ $(function() {
3649 }
3650
3651 if (file_scheme->interval) {
-
3652 if (path->match(text, interval.end, end, flags)) {
+
3652 if (path->match(text, interval.end, end, flags)) {
3653 // Path
3654 interval.end = path->interval.end;
3655 }
@@ -3592,16 +3698,16 @@ $(function() {
3668
3669 // If "http://" explicit, test for username&password.
3670 if (http_scheme->interval &&
-
3671 username->match(text, interval.end, end, flags))
+
3671 username->match(text, interval.end, end, flags))
3672 {
-
3673 if (m_colon->match(text, username->interval.end, end, flags) &&
-
3674 password->match(text, m_colon->interval.end, end, flags) &&
-
3675 m_at->match(text, password->interval.end, end, flags))
+
3673 if (m_colon->match(text, username->interval.end, end, flags) &&
+
3674 password->match(text, m_colon->interval.end, end, flags) &&
+
3675 m_at->match(text, password->interval.end, end, flags))
3676 {
3677 // Username and password
3678 interval.end = m_at->interval.end;
3679 }
-
3680 else if (m_at->match(text, username->interval.end, end, flags)) {
+
3680 else if (m_at->match(text, username->interval.end, end, flags)) {
3681 // Username only
3682 interval.end = m_at->interval.end;
3683 password->invalidate();
@@ -3616,23 +3722,23 @@ $(function() {
3692 password->invalidate();
3693 }
3694
-
3695 if (ipv4_host->match(text, interval.end, end, flags)) {
+
3695 if (ipv4_host->match(text, interval.end, end, flags)) {
3696 // Host is IPv4
3697 interval.end = ipv4_host->interval.end;
3698 ipv6_host->invalidate();
3699 dns_host->invalidate();
3700 }
3701 else if (
-
3702 m_ip_lbracket->match(text, interval.end, end, flags) &&
-
3703 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
-
3704 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
+
3702 m_ip_lbracket->match(text, interval.end, end, flags) &&
+
3703 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
+
3704 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3705 {
3706 // Host is IPv6
3707 interval.end = m_ip_rbracket->interval.end;
3708 ipv4_host->invalidate();
3709 dns_host->invalidate();
3710 }
-
3711 else if (dns_host->match(text, interval.end, end, flags)) {
+
3711 else if (dns_host->match(text, interval.end, end, flags)) {
3712 // Host is hostname
3713 interval.end = dns_host->interval.end;
3714 ipv4_host->invalidate();
@@ -3643,8 +3749,8 @@ $(function() {
3719 return false;
3720 }
3721
-
3722 if (m_colon->match(text, interval.end, end, flags) &&
-
3723 port->match(text, m_colon->interval.end, end, flags))
+
3722 if (m_colon->match(text, interval.end, end, flags) &&
+
3723 port->match(text, m_colon->interval.end, end, flags))
3724 {
3725 // Port
3726 interval.end = port->interval.end;
@@ -3652,7 +3758,7 @@ $(function() {
3728 else
3729 port->invalidate();
3730
-
3731 if (path->match(text, interval.end, end, flags)) {
+
3731 if (path->match(text, interval.end, end, flags)) {
3732 // Path
3733 interval.end = path->interval.end;
3734 }
@@ -3697,54 +3803,56 @@ $(function() {
3773 std::shared_ptr<basic_parser<T>> m_ip_lbracket;
3774 std::shared_ptr<basic_parser<T>> m_ip_rbracket;
3775 };
+
3776
-
3777 using url = basic_url<char>;
-
3778 using wurl = basic_url<wchar_t>;
+
3777 using url = basic_url<char>;
+
3778 using wurl = basic_url<wchar_t>;
3779#ifdef _UNICODE
-
3780 using turl = wurl;
+
3780 using turl = wurl;
3781#else
-
3782 using turl = url;
+
3782 using turl = url;
3783#endif
-
3784 using sgml_url = basic_url<char>;
+
3784 using sgml_url = basic_url<char>;
3785
3789 template <class T>
+
3791 {
3792 public:
-
3794 _In_ const std::shared_ptr<basic_parser<T>>& _username,
-
3795 _In_ const std::shared_ptr<basic_parser<T>>& at,
-
3796 _In_ const std::shared_ptr<basic_parser<T>>& ip_lbracket,
-
3797 _In_ const std::shared_ptr<basic_parser<T>>& ip_rbracket,
-
3798 _In_ const std::shared_ptr<basic_parser<T>>& _ipv4_host,
-
3799 _In_ const std::shared_ptr<basic_parser<T>>& _ipv6_host,
-
3800 _In_ const std::shared_ptr<basic_parser<T>>& _dns_host,
-
3801 _In_ const std::locale& locale = std::locale()) :
-
3802 basic_parser<T>(locale),
-
3803 username(_username),
+
3794 _In_ const std::shared_ptr<basic_parser<T>>& _username,
+
3795 _In_ const std::shared_ptr<basic_parser<T>>& at,
+
3796 _In_ const std::shared_ptr<basic_parser<T>>& ip_lbracket,
+
3797 _In_ const std::shared_ptr<basic_parser<T>>& ip_rbracket,
+
3798 _In_ const std::shared_ptr<basic_parser<T>>& _ipv4_host,
+
3799 _In_ const std::shared_ptr<basic_parser<T>>& _ipv6_host,
+
3800 _In_ const std::shared_ptr<basic_parser<T>>& _dns_host,
+
3801 _In_ const std::locale& locale = std::locale()) :
+
3802 basic_parser<T>(locale),
+
3803 username(_username),
3804 m_at(at),
-
3805 m_ip_lbracket(ip_lbracket),
-
3806 m_ip_rbracket(ip_rbracket),
-
3807 ipv4_host(_ipv4_host),
-
3808 ipv6_host(_ipv6_host),
-
3809 dns_host(_dns_host)
+
3805 m_ip_lbracket(ip_lbracket),
+
3806 m_ip_rbracket(ip_rbracket),
+
3807 ipv4_host(_ipv4_host),
+
3808 ipv6_host(_ipv6_host),
+
3809 dns_host(_dns_host)
3810 {}
3811
3812 virtual bool match(
-
3813 _In_reads_or_z_(end) const T* text,
-
3814 _In_ size_t start = 0,
-
3815 _In_ size_t end = (size_t)-1,
-
3816 _In_ int flags = match_default)
+
3813 _In_reads_or_z_(end) const T* text,
+
3814 _In_ size_t start = 0,
+
3815 _In_ size_t end = (size_t)-1,
+
3816 _In_ int flags = match_default)
3817 {
-
3818 assert(text || start >= end);
+
3818 assert(text || start >= end);
3819
-
3820 if (username->match(text, start, end, flags) &&
-
3821 m_at->match(text, username->interval.end, end, flags))
+
3820 if (username->match(text, start, end, flags) &&
+
3821 m_at->match(text, username->interval.end, end, flags))
3822 {
3823 // Username@
-
3824 if (m_ip_lbracket->match(text, m_at->interval.end, end, flags) &&
-
3825 ipv4_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
-
3826 m_ip_rbracket->match(text, ipv4_host->interval.end, end, flags))
+
3824 if (m_ip_lbracket->match(text, m_at->interval.end, end, flags) &&
+
3825 ipv4_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
+
3826 m_ip_rbracket->match(text, ipv4_host->interval.end, end, flags))
3827 {
3828 // Host is IPv4
3829 interval.end = m_ip_rbracket->interval.end;
@@ -3752,28 +3860,28 @@ $(function() {
3831 dns_host->invalidate();
3832 }
3833 else if (
-
3834 m_ip_lbracket->match(text, m_at->interval.end, end, flags) &&
-
3835 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
-
3836 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
+
3834 m_ip_lbracket->match(text, m_at->interval.end, end, flags) &&
+
3835 ipv6_host->match(text, m_ip_lbracket->interval.end, end, flags) &&
+
3836 m_ip_rbracket->match(text, ipv6_host->interval.end, end, flags))
3837 {
3838 // Host is IPv6
3839 interval.end = m_ip_rbracket->interval.end;
3840 ipv4_host->invalidate();
3841 dns_host->invalidate();
3842 }
-
3843 else if (dns_host->match(text, m_at->interval.end, end, flags)) {
+
3843 else if (dns_host->match(text, m_at->interval.end, end, flags)) {
3844 // Host is hostname
3845 interval.end = dns_host->interval.end;
3846 ipv4_host->invalidate();
3847 ipv6_host->invalidate();
3848 }
3849 else
-
3850 goto error;
+
3850 goto error;
3851 interval.start = start;
3852 return true;
3853 }
3854
-
3855 error:
+
3855 error:
3856 username->invalidate();
3857 ipv4_host->invalidate();
3858 ipv6_host->invalidate();
@@ -3802,87 +3910,89 @@ $(function() {
3881 std::shared_ptr<basic_parser<T>> m_ip_lbracket;
3882 std::shared_ptr<basic_parser<T>> m_ip_rbracket;
3883 };
+
3884
-
3885 using email_address = basic_email_address<char>;
-
3886 using wemail_address = basic_email_address<wchar_t>;
+
3885 using email_address = basic_email_address<char>;
+
3886 using wemail_address = basic_email_address<wchar_t>;
3887#ifdef _UNICODE
-
3888 using temail_address = wemail_address;
+
3888 using temail_address = wemail_address;
3889#else
-
3890 using temail_address = email_address;
+
3890 using temail_address = email_address;
3891#endif
-
3892 using sgml_email_address = basic_email_address<char>;
+
3892 using sgml_email_address = basic_email_address<char>;
3893
3897 template <class T>
+
3899 {
3900 public:
-
3902 _In_ const std::shared_ptr<basic_parser<T>>& _emoticon,
-
3903 _In_ const std::shared_ptr<basic_parser<T>>& _apex,
-
3904 _In_ const std::shared_ptr<basic_parser<T>>& _eyes,
-
3905 _In_ const std::shared_ptr<basic_parser<T>>& _nose,
-
3906 _In_ const std::shared_ptr<basic_set<T>>& _mouth,
-
3907 _In_ const std::locale& locale = std::locale()) :
-
3908 basic_parser<T>(locale),
-
3909 emoticon(_emoticon),
-
3910 apex(_apex),
-
3911 eyes(_eyes),
-
3912 nose(_nose),
-
3913 mouth(_mouth)
+
3902 _In_ const std::shared_ptr<basic_parser<T>>& _emoticon,
+
3903 _In_ const std::shared_ptr<basic_parser<T>>& _apex,
+
3904 _In_ const std::shared_ptr<basic_parser<T>>& _eyes,
+
3905 _In_ const std::shared_ptr<basic_parser<T>>& _nose,
+
3906 _In_ const std::shared_ptr<basic_set<T>>& _mouth,
+
3907 _In_ const std::locale& locale = std::locale()) :
+
3908 basic_parser<T>(locale),
+ +
3910 apex(_apex),
+
3911 eyes(_eyes),
+
3912 nose(_nose),
+
3913 mouth(_mouth)
3914 {}
3915
3916 virtual bool match(
-
3917 _In_reads_or_z_(end) const T* text,
-
3918 _In_ size_t start = 0,
-
3919 _In_ size_t end = (size_t)-1,
-
3920 _In_ int flags = match_default)
+
3917 _In_reads_or_z_(end) const T* text,
+
3918 _In_ size_t start = 0,
+
3919 _In_ size_t end = (size_t)-1,
+
3920 _In_ int flags = match_default)
3921 {
-
3922 assert(text || start >= end);
+
3922 assert(text || start >= end);
3923
-
3924 if (emoticon && emoticon->match(text, start, end, flags)) {
+
3924 if (emoticon && emoticon->match(text, start, end, flags)) {
3925 if (apex) apex->invalidate();
3926 eyes->invalidate();
3927 if (nose) nose->invalidate();
3928 mouth->invalidate();
3929 interval.start = start;
- +
3931 return true;
3932 }
3933
3934 interval.end = start;
3935
-
3936 if (apex && apex->match(text, interval.end, end, flags))
+
3936 if (apex && apex->match(text, interval.end, end, flags))
3937 interval.end = apex->interval.end;
3938
-
3939 if (eyes->match(text, interval.end, end, flags)) {
-
3940 if (nose && nose->match(text, eyes->interval.end, end, flags) &&
-
3941 mouth->match(text, nose->interval.end, end, flags))
+
3939 if (eyes->match(text, interval.end, end, flags)) {
+
3940 if (nose && nose->match(text, eyes->interval.end, end, flags) &&
+
3941 mouth->match(text, nose->interval.end, end, flags))
3942 {
3943 size_t
-
3944 start_mouth = mouth->interval.start,
+
3945 hit_offset = mouth->hit_offset;
3946 // Mouth may repeat :-)))))))
-
3947 for (interval.end = mouth->interval.end; mouth->match(text, interval.end, end, flags) && mouth->hit_offset == hit_offset; interval.end = mouth->interval.end);
-
3948 mouth->interval.start = start_mouth;
-
3949 mouth->interval.end = interval.end;
+
3947 for (interval.end = mouth->interval.end; mouth->match(text, interval.end, end, flags) && mouth->hit_offset == hit_offset; interval.end = mouth->interval.end);
+
3948 mouth->interval.start = start_mouth;
+
3950 interval.start = start;
3951 return true;
3952 }
-
3953 if (mouth->match(text, eyes->interval.end, end, flags)) {
+
3953 if (mouth->match(text, eyes->interval.end, end, flags)) {
3954 size_t
-
3955 start_mouth = mouth->interval.start,
+
3956 hit_offset = mouth->hit_offset;
3957 // Mouth may repeat :-)))))))
-
3958 for (interval.end = mouth->interval.end; mouth->match(text, interval.end, end, flags) && mouth->hit_offset == hit_offset; interval.end = mouth->interval.end);
+
3958 for (interval.end = mouth->interval.end; mouth->match(text, interval.end, end, flags) && mouth->hit_offset == hit_offset; interval.end = mouth->interval.end);
3959 if (nose) nose->invalidate();
-
3960 mouth->interval.start = start_mouth;
-
3961 mouth->interval.end = interval.end;
+
3960 mouth->interval.start = start_mouth;
+
3962 interval.start = start;
3963 return true;
3964 }
3965 }
3966
-
3967 if (emoticon) emoticon->invalidate();
+
3967 if (emoticon) emoticon->invalidate();
3968 if (apex) apex->invalidate();
3969 eyes->invalidate();
3970 if (nose) nose->invalidate();
@@ -3893,7 +4003,7 @@ $(function() {
3975
3976 virtual void invalidate()
3977 {
-
3978 if (emoticon) emoticon->invalidate();
+
3978 if (emoticon) emoticon->invalidate();
3979 if (apex) apex->invalidate();
3980 eyes->invalidate();
3981 if (nose) nose->invalidate();
@@ -3908,15 +4018,16 @@ $(function() {
3990 std::shared_ptr<basic_parser<T>> nose;
3991 std::shared_ptr<basic_set<T>> mouth;
3992 };
+
3993
-
3994 using emoticon = basic_emoticon<char>;
-
3995 using wemoticon = basic_emoticon<wchar_t>;
+
3994 using emoticon = basic_emoticon<char>;
+
3995 using wemoticon = basic_emoticon<wchar_t>;
3996#ifdef _UNICODE
-
3997 using temoticon = wemoticon;
+
3997 using temoticon = wemoticon;
3998#else
-
3999 using temoticon = emoticon;
+
3999 using temoticon = emoticon;
4000#endif
-
4001 using sgml_emoticon = basic_emoticon<char>;
+
4001 using sgml_emoticon = basic_emoticon<char>;
4002
4006 enum date_format_t {
4007 date_format_none = 0,
@@ -3930,49 +4041,50 @@ $(function() {
4015 };
4016
4020 template <class T>
+
4021 class basic_date : public basic_parser<T>
4022 {
4023 public:
4024 basic_date(
-
4025 _In_ int format_mask,
-
4026 _In_ const std::shared_ptr<basic_integer<T>>& _day,
-
4027 _In_ const std::shared_ptr<basic_integer<T>>& _month,
-
4028 _In_ const std::shared_ptr<basic_integer<T>>& _year,
-
4029 _In_ const std::shared_ptr<basic_set<T>>& separator,
-
4030 _In_ const std::shared_ptr<basic_parser<T>>& space,
-
4031 _In_ const std::locale& locale = std::locale()) :
-
4032 basic_parser<T>(locale),
+
4025 _In_ int format_mask,
+
4026 _In_ const std::shared_ptr<basic_integer<T>>& _day,
+
4027 _In_ const std::shared_ptr<basic_integer<T>>& _month,
+
4028 _In_ const std::shared_ptr<basic_integer<T>>& _year,
+
4029 _In_ const std::shared_ptr<basic_set<T>>& separator,
+
4030 _In_ const std::shared_ptr<basic_parser<T>>& space,
+
4031 _In_ const std::locale& locale = std::locale()) :
+
4032 basic_parser<T>(locale),
4033 format(date_format_none),
-
4034 m_format_mask(format_mask),
-
4035 day(_day),
-
4036 month(_month),
-
4037 year(_year),
+
4034 m_format_mask(format_mask),
+
4035 day(_day),
+
4036 month(_month),
+
4037 year(_year),
4038 m_separator(separator),
4039 m_space(space)
4040 {}
4041
4042 virtual bool match(
-
4043 _In_reads_or_z_(end) const T* text,
-
4044 _In_ size_t start = 0,
-
4045 _In_ size_t end = (size_t)-1,
-
4046 _In_ int flags = match_default)
+
4043 _In_reads_or_z_(end) const T* text,
+
4044 _In_ size_t start = 0,
+
4045 _In_ size_t end = (size_t)-1,
+
4046 _In_ int flags = match_default)
4047 {
-
4048 assert(text || start >= end);
+
4048 assert(text || start >= end);
4049
-
4050 const int space_match_flags = flags & ~match_multiline; // Spaces in dates must never be broken in new line.
+
4050 const int space_match_flags = flags & ~match_multiline; // Spaces in dates must never be broken in new line.
4051 if ((m_format_mask & date_format_dmy) == date_format_dmy) {
-
4052 if (day->match(text, start, end, flags)) {
-
4053 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4054 if (m_separator->match(text, interval.end, end, flags)) {
+
4052 if (day->match(text, start, end, flags)) {
+
4053 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4054 if (m_separator->match(text, interval.end, end, flags)) {
4055 size_t hit_offset = m_separator->hit_offset;
-
4056 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4057 if (month->match(text, interval.end, end, flags)) {
-
4058 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4059 if (m_separator->match(text, interval.end, end, flags) &&
+
4056 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4057 if (month->match(text, interval.end, end, flags)) {
+
4058 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4059 if (m_separator->match(text, interval.end, end, flags) &&
4060 m_separator->hit_offset == hit_offset) // Both separators must match.
4061 {
-
4062 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4063 if (year->match(text, interval.end, end, flags) &&
+
4062 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4063 if (year->match(text, interval.end, end, flags) &&
4064 is_valid(day->value, month->value))
4065 {
4066 interval.start = start;
@@ -3987,18 +4099,18 @@ $(function() {
4075 }
4076
4077 if ((m_format_mask & date_format_mdy) == date_format_mdy) {
-
4078 if (month->match(text, start, end, flags)) {
-
4079 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4080 if (m_separator->match(text, interval.end, end, flags)) {
+
4078 if (month->match(text, start, end, flags)) {
+
4079 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4080 if (m_separator->match(text, interval.end, end, flags)) {
4081 size_t hit_offset = m_separator->hit_offset;
-
4082 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4083 if (day->match(text, interval.end, end, flags)) {
-
4084 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4085 if (m_separator->match(text, interval.end, end, flags) &&
+
4082 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4083 if (day->match(text, interval.end, end, flags)) {
+
4084 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4085 if (m_separator->match(text, interval.end, end, flags) &&
4086 m_separator->hit_offset == hit_offset) // Both separators must match.
4087 {
-
4088 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4089 if (year->match(text, interval.end, end, flags) &&
+
4088 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4089 if (year->match(text, interval.end, end, flags) &&
4090 is_valid(day->value, month->value))
4091 {
4092 interval.start = start;
@@ -4013,18 +4125,18 @@ $(function() {
4101 }
4102
4103 if ((m_format_mask & date_format_ymd) == date_format_ymd) {
-
4104 if (year->match(text, start, end, flags)) {
-
4105 for (interval.end = year->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4106 if (m_separator->match(text, interval.end, end, flags)) {
+
4104 if (year->match(text, start, end, flags)) {
+
4105 for (interval.end = year->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4106 if (m_separator->match(text, interval.end, end, flags)) {
4107 size_t hit_offset = m_separator->hit_offset;
-
4108 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4109 if (month->match(text, interval.end, end, flags)) {
-
4110 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4111 if (m_separator->match(text, interval.end, end, flags) &&
+
4108 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4109 if (month->match(text, interval.end, end, flags)) {
+
4110 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4111 if (m_separator->match(text, interval.end, end, flags) &&
4112 m_separator->hit_offset == hit_offset) // Both separators must match.
4113 {
-
4114 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4115 if (day->match(text, interval.end, end, flags) &&
+
4114 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4115 if (day->match(text, interval.end, end, flags) &&
4116 is_valid(day->value, month->value))
4117 {
4118 interval.start = start;
@@ -4039,11 +4151,11 @@ $(function() {
4127 }
4128
4129 if ((m_format_mask & date_format_ym) == date_format_ym) {
-
4130 if (year->match(text, start, end, flags)) {
-
4131 for (interval.end = year->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4132 if (m_separator->match(text, interval.end, end, flags)) {
-
4133 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4134 if (month->match(text, interval.end, end, flags) &&
+
4130 if (year->match(text, start, end, flags)) {
+
4131 for (interval.end = year->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4132 if (m_separator->match(text, interval.end, end, flags)) {
+
4133 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4134 if (month->match(text, interval.end, end, flags) &&
4135 is_valid((size_t)-1, month->value))
4136 {
4137 if (day) day->invalidate();
@@ -4057,11 +4169,11 @@ $(function() {
4145 }
4146
4147 if ((m_format_mask & date_format_my) == date_format_my) {
-
4148 if (month->match(text, start, end, flags)) {
-
4149 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4150 if (m_separator->match(text, interval.end, end, flags)) {
-
4151 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4152 if (year->match(text, interval.end, end, flags) &&
+
4148 if (month->match(text, start, end, flags)) {
+
4149 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4150 if (m_separator->match(text, interval.end, end, flags)) {
+
4151 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4152 if (year->match(text, interval.end, end, flags) &&
4153 is_valid((size_t)-1, month->value))
4154 {
4155 if (day) day->invalidate();
@@ -4075,18 +4187,18 @@ $(function() {
4163 }
4164
4165 if ((m_format_mask & date_format_dm) == date_format_dm) {
-
4166 if (day->match(text, start, end, flags)) {
-
4167 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4168 if (m_separator->match(text, interval.end, end, flags)) {
+
4166 if (day->match(text, start, end, flags)) {
+
4167 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4168 if (m_separator->match(text, interval.end, end, flags)) {
4169 size_t hit_offset = m_separator->hit_offset;
-
4170 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4171 if (month->match(text, interval.end, end, flags) &&
+
4170 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4171 if (month->match(text, interval.end, end, flags) &&
4172 is_valid(day->value, month->value))
4173 {
4174 if (year) year->invalidate();
4175 interval.start = start;
-
4176 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4177 if (m_separator->match(text, interval.end, end, flags) &&
+
4176 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4177 if (m_separator->match(text, interval.end, end, flags) &&
4178 m_separator->hit_offset == hit_offset) // Both separators must match.
4179 interval.end = m_separator->interval.end;
4180 else
@@ -4099,18 +4211,18 @@ $(function() {
4187 }
4188
4189 if ((m_format_mask & date_format_md) == date_format_md) {
-
4190 if (month->match(text, start, end, flags)) {
-
4191 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4192 if (m_separator->match(text, interval.end, end, flags)) {
+
4190 if (month->match(text, start, end, flags)) {
+
4191 for (interval.end = month->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4192 if (m_separator->match(text, interval.end, end, flags)) {
4193 size_t hit_offset = m_separator->hit_offset;
-
4194 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4195 if (day->match(text, interval.end, end, flags) &&
+
4194 for (interval.end = m_separator->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4195 if (day->match(text, interval.end, end, flags) &&
4196 is_valid(day->value, month->value))
4197 {
4198 if (year) year->invalidate();
4199 interval.start = start;
-
4200 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
-
4201 if (m_separator->match(text, interval.end, end, flags) &&
+
4200 for (interval.end = day->interval.end; m_space->match(text, interval.end, end, space_match_flags); interval.end = m_space->interval.end);
+
4201 if (m_separator->match(text, interval.end, end, flags) &&
4202 m_separator->hit_offset == hit_offset) // Both separators must match.
4203 interval.end = m_separator->interval.end;
4204 else
@@ -4183,60 +4295,62 @@ $(function() {
4271 std::shared_ptr<basic_set<T>> m_separator;
4272 std::shared_ptr<basic_parser<T>> m_space;
4273 };
+
4274
-
4275 using date = basic_date<char>;
-
4276 using wdate = basic_date<wchar_t>;
+
4275 using date = basic_date<char>;
+
4276 using wdate = basic_date<wchar_t>;
4277#ifdef _UNICODE
-
4278 using tdate = wdate;
+
4278 using tdate = wdate;
4279#else
-
4280 using tdate = date;
+
4280 using tdate = date;
4281#endif
-
4282 using sgml_date = basic_date<char>;
+
4282 using sgml_date = basic_date<char>;
4283
4287 template <class T>
+
4288 class basic_time : public basic_parser<T>
4289 {
4290 public:
4291 basic_time(
-
4292 _In_ const std::shared_ptr<basic_integer10<T>>& _hour,
-
4293 _In_ const std::shared_ptr<basic_integer10<T>>& _minute,
-
4294 _In_ const std::shared_ptr<basic_integer10<T>>& _second,
-
4295 _In_ const std::shared_ptr<basic_integer10<T>>& _millisecond,
-
4296 _In_ const std::shared_ptr<basic_set<T>>& separator,
-
4297 _In_ const std::shared_ptr<basic_parser<T>>& millisecond_separator,
-
4298 _In_ const std::locale& locale = std::locale()) :
-
4299 basic_parser<T>(locale),
-
4300 hour(_hour),
-
4301 minute(_minute),
-
4302 second(_second),
-
4303 millisecond(_millisecond),
+
4292 _In_ const std::shared_ptr<basic_integer10<T>>& _hour,
+
4293 _In_ const std::shared_ptr<basic_integer10<T>>& _minute,
+
4294 _In_ const std::shared_ptr<basic_integer10<T>>& _second,
+
4295 _In_ const std::shared_ptr<basic_integer10<T>>& _millisecond,
+
4296 _In_ const std::shared_ptr<basic_set<T>>& separator,
+
4297 _In_ const std::shared_ptr<basic_parser<T>>& millisecond_separator,
+
4298 _In_ const std::locale& locale = std::locale()) :
+
4299 basic_parser<T>(locale),
+
4300 hour(_hour),
+
4301 minute(_minute),
+
4302 second(_second),
+
4303 millisecond(_millisecond),
4304 m_separator(separator),
-
4305 m_millisecond_separator(millisecond_separator)
+
4305 m_millisecond_separator(millisecond_separator)
4306 {}
4307
4308 virtual bool match(
-
4309 _In_reads_or_z_(end) const T* text,
-
4310 _In_ size_t start = 0,
-
4311 _In_ size_t end = (size_t)-1,
-
4312 _In_ int flags = match_default)
+
4309 _In_reads_or_z_(end) const T* text,
+
4310 _In_ size_t start = 0,
+
4311 _In_ size_t end = (size_t)-1,
+
4312 _In_ int flags = match_default)
4313 {
-
4314 assert(text || start >= end);
+
4314 assert(text || start >= end);
4315
-
4316 if (hour->match(text, start, end, flags) &&
-
4317 m_separator->match(text, hour->interval.end, end, flags) &&
-
4318 minute->match(text, m_separator->interval.end, end, flags) &&
+
4316 if (hour->match(text, start, end, flags) &&
+
4317 m_separator->match(text, hour->interval.end, end, flags) &&
+
4318 minute->match(text, m_separator->interval.end, end, flags) &&
4319 minute->value < 60)
4320 {
4321 // hh::mm
4322 size_t hit_offset = m_separator->hit_offset;
-
4323 if (m_separator->match(text, minute->interval.end, end, flags) &&
+
4323 if (m_separator->match(text, minute->interval.end, end, flags) &&
4324 m_separator->hit_offset == hit_offset && // Both separators must match.
-
4325 second && second->match(text, m_separator->interval.end, end, flags) &&
+
4325 second && second->match(text, m_separator->interval.end, end, flags) &&
4326 second->value < 60)
4327 {
4328 // hh::mm:ss
-
4329 if (m_millisecond_separator && m_millisecond_separator->match(text, second->interval.end, end, flags) &&
-
4330 millisecond && millisecond->match(text, m_millisecond_separator->interval.end, end, flags) &&
+
4329 if (m_millisecond_separator && m_millisecond_separator->match(text, second->interval.end, end, flags) &&
+
4330 millisecond && millisecond->match(text, m_millisecond_separator->interval.end, end, flags) &&
4331 millisecond->value < 1000)
4332 {
4333 // hh::mm:ss.mmmm
@@ -4283,51 +4397,53 @@ $(function() {
4374 std::shared_ptr<basic_set<T>> m_separator;
4375 std::shared_ptr<basic_parser<T>> m_millisecond_separator;
4376 };
+
4377
-
4378 using time = basic_time<char>;
-
4379 using wtime = basic_time<wchar_t>;
+
4378 using time = basic_time<char>;
+
4379 using wtime = basic_time<wchar_t>;
4380#ifdef _UNICODE
-
4381 using ttime = wtime;
+
4381 using ttime = wtime;
4382#else
-
4383 using ttime = time;
+
4383 using ttime = time;
4384#endif
-
4385 using sgml_time = basic_time<char>;
+
4385 using sgml_time = basic_time<char>;
4386
4390 template <class T>
+
4391 class basic_angle : public basic_parser<T>
4392 {
4393 public:
-
4395 _In_ const std::shared_ptr<basic_integer10<T>>& _degree,
-
4396 _In_ const std::shared_ptr<basic_parser<T>>& _degree_separator,
-
4397 _In_ const std::shared_ptr<basic_integer10<T>>& _minute,
-
4398 _In_ const std::shared_ptr<basic_parser<T>>& _minute_separator,
-
4399 _In_ const std::shared_ptr<basic_integer10<T>>& _second,
-
4400 _In_ const std::shared_ptr<basic_parser<T>>& _second_separator,
-
4401 _In_ const std::shared_ptr<basic_parser<T>>& _decimal,
-
4402 _In_ const std::locale& locale = std::locale()) :
-
4403 basic_parser<T>(locale),
-
4404 degree(_degree),
-
4405 degree_separator(_degree_separator),
-
4406 minute(_minute),
-
4407 minute_separator(_minute_separator),
-
4408 second(_second),
-
4409 second_separator(_second_separator),
-
4410 decimal(_decimal)
+
4395 _In_ const std::shared_ptr<basic_integer10<T>>& _degree,
+
4396 _In_ const std::shared_ptr<basic_parser<T>>& _degree_separator,
+
4397 _In_ const std::shared_ptr<basic_integer10<T>>& _minute,
+
4398 _In_ const std::shared_ptr<basic_parser<T>>& _minute_separator,
+
4399 _In_ const std::shared_ptr<basic_integer10<T>>& _second,
+
4400 _In_ const std::shared_ptr<basic_parser<T>>& _second_separator,
+
4401 _In_ const std::shared_ptr<basic_parser<T>>& _decimal,
+
4402 _In_ const std::locale& locale = std::locale()) :
+
4403 basic_parser<T>(locale),
+
4404 degree(_degree),
+
4405 degree_separator(_degree_separator),
+
4406 minute(_minute),
+
4407 minute_separator(_minute_separator),
+
4408 second(_second),
+
4409 second_separator(_second_separator),
+
4410 decimal(_decimal)
4411 {}
4412
4413 virtual bool match(
-
4414 _In_reads_or_z_(end) const T* text,
-
4415 _In_ size_t start = 0,
-
4416 _In_ size_t end = (size_t)-1,
-
4417 _In_ int flags = match_default)
+
4414 _In_reads_or_z_(end) const T* text,
+
4415 _In_ size_t start = 0,
+
4416 _In_ size_t end = (size_t)-1,
+
4417 _In_ int flags = match_default)
4418 {
-
4419 assert(text || start >= end);
+
4419 assert(text || start >= end);
4420
4421 interval.end = start;
4422
-
4423 if (degree->match(text, interval.end, end, flags) &&
-
4424 degree_separator->match(text, degree->interval.end, end, flags))
+
4423 if (degree->match(text, interval.end, end, flags) &&
+
4424 degree_separator->match(text, degree->interval.end, end, flags))
4425 {
4426 // Degrees
4427 interval.end = degree_separator->interval.end;
@@ -4337,9 +4453,9 @@ $(function() {
4431 degree_separator->invalidate();
4432 }
4433
-
4434 if (minute->match(text, interval.end, end, flags) &&
+
4434 if (minute->match(text, interval.end, end, flags) &&
4435 minute->value < 60 &&
-
4436 minute_separator->match(text, minute->interval.end, end, flags))
+
4436 minute_separator->match(text, minute->interval.end, end, flags))
4437 {
4438 // Minutes
4439 interval.end = minute_separator->interval.end;
@@ -4349,12 +4465,12 @@ $(function() {
4443 minute_separator->invalidate();
4444 }
4445
-
4446 if (second && second->match(text, interval.end, end, flags) &&
+
4446 if (second && second->match(text, interval.end, end, flags) &&
4447 second->value < 60)
4448 {
4449 // Seconds
4450 interval.end = second->interval.end;
-
4451 if (second_separator && second_separator->match(text, interval.end, end, flags))
+
4451 if (second_separator && second_separator->match(text, interval.end, end, flags))
4452 interval.end = second_separator->interval.end;
4453 else
4454 if (second_separator) second_separator->invalidate();
@@ -4368,7 +4484,7 @@ $(function() {
4462 minute->interval.start < minute->interval.end ||
4463 second && second->interval.start < second->interval.end)
4464 {
-
4465 if (decimal && decimal->match(text, interval.end, end, flags)) {
+
4465 if (decimal && decimal->match(text, interval.end, end, flags)) {
4466 // Decimals
4467 interval.end = decimal->interval.end;
4468 }
@@ -4403,130 +4519,132 @@ $(function() {
4497 std::shared_ptr<basic_parser<T>> second_separator;
4498 std::shared_ptr<basic_parser<T>> decimal;
4499 };
+
4500
-
4501 using angle = basic_angle<char>;
-
4502 using wangle = basic_angle<wchar_t>;
+
4501 using angle = basic_angle<char>;
+
4502 using wangle = basic_angle<wchar_t>;
4503#ifdef _UNICODE
-
4504 using RRegElKot = wangle;
+
4504 using RRegElKot = wangle;
4505#else
-
4506 using RRegElKot = angle;
+
4506 using RRegElKot = angle;
4507#endif
-
4508 using sgml_angle = basic_angle<char>;
+
4508 using sgml_angle = basic_angle<char>;
4509
4513 template <class T>
+
4515 {
4516 public:
-
4518 _In_ const std::shared_ptr<basic_parser<T>>& digit,
-
4519 _In_ const std::shared_ptr<basic_parser<T>>& plus_sign,
-
4520 _In_ const std::shared_ptr<basic_set<T>>& lparenthesis,
-
4521 _In_ const std::shared_ptr<basic_set<T>>& rparenthesis,
-
4522 _In_ const std::shared_ptr<basic_parser<T>>& separator,
-
4523 _In_ const std::shared_ptr<basic_parser<T>>& space,
-
4524 _In_ const std::locale& locale = std::locale()) :
-
4525 basic_parser<T>(locale),
-
4526 m_digit(digit),
-
4527 m_plus_sign(plus_sign),
-
4528 m_lparenthesis(lparenthesis),
-
4529 m_rparenthesis(rparenthesis),
+
4518 _In_ const std::shared_ptr<basic_parser<T>>& digit,
+
4519 _In_ const std::shared_ptr<basic_parser<T>>& plus_sign,
+
4520 _In_ const std::shared_ptr<basic_set<T>>& lparenthesis,
+
4521 _In_ const std::shared_ptr<basic_set<T>>& rparenthesis,
+
4522 _In_ const std::shared_ptr<basic_parser<T>>& separator,
+
4523 _In_ const std::shared_ptr<basic_parser<T>>& space,
+
4524 _In_ const std::locale& locale = std::locale()) :
+
4525 basic_parser<T>(locale),
+
4526 m_digit(digit),
+
4527 m_plus_sign(plus_sign),
+
4528 m_lparenthesis(lparenthesis),
+
4529 m_rparenthesis(rparenthesis),
4530 m_separator(separator),
4531 m_space(space)
4532 {}
4533
4534 virtual bool match(
-
4535 _In_reads_or_z_(end) const T* text,
-
4536 _In_ size_t start = 0,
-
4537 _In_ size_t end = (size_t)-1,
-
4538 _In_ int flags = match_default)
+
4535 _In_reads_or_z_(end) const T* text,
+
4536 _In_ size_t start = 0,
+
4537 _In_ size_t end = (size_t)-1,
+
4538 _In_ int flags = match_default)
4539 {
-
4540 assert(text || start >= end);
+
4540 assert(text || start >= end);
4541
-
4542 size_t safe_digit_end = start, safe_value_size = 0;
-
4543 bool has_digits = false, after_digit = false, in_parentheses = false, after_parentheses = false;
-
4544 const int space_match_flags = flags & ~match_multiline; // Spaces in phone numbers must never be broken in new line.
+
4542 size_t safe_digit_end = start, safe_value_size = 0;
+
4543 bool has_digits = false, after_digit = false, in_parentheses = false, after_parentheses = false;
+
4544 const int space_match_flags = flags & ~match_multiline; // Spaces in phone numbers must never be broken in new line.
4545
4546 interval.end = start;
4547 value.clear();
4548 m_lparenthesis->invalidate();
4549 m_rparenthesis->invalidate();
4550
-
4551 if (m_plus_sign && m_plus_sign->match(text, interval.end, end, flags)) {
-
4552 value.append(text + m_plus_sign->interval.start, text + m_plus_sign->interval.end);
-
4553 safe_value_size = value.size();
+
4551 if (m_plus_sign && m_plus_sign->match(text, interval.end, end, flags)) {
+
4552 value.append(text + m_plus_sign->interval.start, text + m_plus_sign->interval.end);
+
4553 safe_value_size = value.size();
4554 interval.end = m_plus_sign->interval.end;
4555 }
4556
4557 for (;;) {
-
4558 assert(text || interval.end >= end);
-
4559 if (interval.end >= end || !text[interval.end])
+
4558 assert(text || interval.end >= end);
+
4559 if (interval.end >= end || !text[interval.end])
4560 break;
-
4561 if (m_digit->match(text, interval.end, end, flags)) {
+
4561 if (m_digit->match(text, interval.end, end, flags)) {
4562 // Digit
-
4563 value.append(text + m_digit->interval.start, text + m_digit->interval.end);
+
4563 value.append(text + m_digit->interval.start, text + m_digit->interval.end);
4564 interval.end = m_digit->interval.end;
-
4565 if (!in_parentheses) {
-
4566 safe_digit_end = interval.end;
-
4567 safe_value_size = value.size();
+
4565 if (!in_parentheses) {
+ +
4567 safe_value_size = value.size();
4568 has_digits = true;
4569 }
-
4570 after_digit = true;
-
4571 after_parentheses = false;
+
4570 after_digit = true;
+
4571 after_parentheses = false;
4572 }
4573 else if (
4574 m_lparenthesis && !m_lparenthesis->interval && // No left parenthesis yet
4575 m_rparenthesis && !m_rparenthesis->interval && // Right parenthesis after left
-
4576 m_lparenthesis->match(text, interval.end, end, flags))
+
4576 m_lparenthesis->match(text, interval.end, end, flags))
4577 {
4578 // Left parenthesis
-
4579 value.append(text + m_lparenthesis->interval.start, m_lparenthesis->interval.size());
+
4579 value.append(text + m_lparenthesis->interval.start, m_lparenthesis->interval.size());
4580 interval.end = m_lparenthesis->interval.end;
-
4581 in_parentheses = true;
-
4582 after_digit = false;
-
4583 after_parentheses = false;
+
4581 in_parentheses = true;
+
4582 after_digit = false;
+
4583 after_parentheses = false;
4584 }
4585 else if (
-
4586 in_parentheses && // After left parenthesis
+
4586 in_parentheses && // After left parenthesis
4587 m_rparenthesis && !m_rparenthesis->interval && // No right parenthesis yet
-
4588 m_rparenthesis->match(text, interval.end, end, flags) &&
+
4588 m_rparenthesis->match(text, interval.end, end, flags) &&
4589 m_lparenthesis->hit_offset == m_rparenthesis->hit_offset) // Left and right parentheses must match
4590 {
4591 // Right parenthesis
-
4592 value.append(text + m_rparenthesis->interval.start, text + m_rparenthesis->interval.end);
+
4592 value.append(text + m_rparenthesis->interval.start, text + m_rparenthesis->interval.end);
4593 interval.end = m_rparenthesis->interval.end;
-
4594 safe_digit_end = interval.end;
-
4595 safe_value_size = value.size();
-
4596 in_parentheses = false;
-
4597 after_digit = false;
-
4598 after_parentheses = true;
+ +
4595 safe_value_size = value.size();
+
4596 in_parentheses = false;
+
4597 after_digit = false;
+
4598 after_parentheses = true;
4599 }
4600 else if (
-
4601 after_digit &&
-
4602 !in_parentheses && // No separators inside parentheses
-
4603 !after_parentheses && // No separators following right parenthesis
-
4604 m_separator && m_separator->match(text, interval.end, end, flags))
+
4601 after_digit &&
+
4602 !in_parentheses && // No separators inside parentheses
+
4603 !after_parentheses && // No separators following right parenthesis
+
4604 m_separator && m_separator->match(text, interval.end, end, flags))
4605 {
4606 // Separator
4607 interval.end = m_separator->interval.end;
-
4608 after_digit = false;
-
4609 after_parentheses = false;
+
4608 after_digit = false;
+
4609 after_parentheses = false;
4610 }
4611 else if (
-
4612 (after_digit || after_parentheses) &&
-
4613 m_space && m_space->match(text, interval.end, end, space_match_flags))
+ +
4613 m_space && m_space->match(text, interval.end, end, space_match_flags))
4614 {
4615 // Space
4616 interval.end = m_space->interval.end;
-
4617 after_digit = false;
-
4618 after_parentheses = false;
+
4617 after_digit = false;
+
4618 after_parentheses = false;
4619 }
4620 else
4621 break;
4622 }
4623 if (has_digits) {
-
4624 value.erase(safe_value_size);
+
4624 value.erase(safe_value_size);
4625 interval.start = start;
-
4626 interval.end = safe_digit_end;
+
4627 return true;
4628 }
4629 value.clear();
@@ -4551,56 +4669,58 @@ $(function() {
4648 std::shared_ptr<basic_parser<T>> m_separator;
4649 std::shared_ptr<basic_parser<T>> m_space;
4650 };
+
4651
-
4652 using phone_number = basic_phone_number<char>;
-
4653 using wphone_number = basic_phone_number<wchar_t>;
+
4652 using phone_number = basic_phone_number<char>;
+
4653 using wphone_number = basic_phone_number<wchar_t>;
4654#ifdef _UNICODE
-
4655 using tphone_number = wphone_number;
+
4655 using tphone_number = wphone_number;
4656#else
-
4657 using tphone_number = phone_number;
+
4657 using tphone_number = phone_number;
4658#endif
-
4659 using sgml_phone_number = basic_phone_number<char>;
+
4659 using sgml_phone_number = basic_phone_number<char>;
4660
4664 template <class T>
+
4666 {
4667 public:
-
4669 _In_ const std::shared_ptr<basic_parser<T>>& element,
-
4670 _In_ const std::shared_ptr<basic_parser<T>>& digit,
-
4671 _In_ const std::shared_ptr<basic_parser<T>>& sign,
-
4672 _In_ const std::locale& locale = std::locale()) :
-
4673 basic_parser<T>(locale),
-
4674 m_element(element),
-
4675 m_digit(digit),
-
4676 m_sign(sign),
+
4669 _In_ const std::shared_ptr<basic_parser<T>>& element,
+
4670 _In_ const std::shared_ptr<basic_parser<T>>& digit,
+
4671 _In_ const std::shared_ptr<basic_parser<T>>& sign,
+
4672 _In_ const std::locale& locale = std::locale()) :
+
4673 basic_parser<T>(locale),
+
4674 m_element(element),
+
4675 m_digit(digit),
+
4676 m_sign(sign),
4677 has_digits(false),
4678 has_charge(false)
4679 {}
4680
4681 virtual bool match(
-
4682 _In_reads_or_z_(end) const T* text,
-
4683 _In_ size_t start = 0,
-
4684 _In_ size_t end = (size_t)-1,
-
4685 _In_ int flags = match_default)
+
4682 _In_reads_or_z_(end) const T* text,
+
4683 _In_ size_t start = 0,
+
4684 _In_ size_t end = (size_t)-1,
+
4685 _In_ int flags = match_default)
4686 {
-
4687 assert(text || start >= end);
+
4687 assert(text || start >= end);
4688
4689 has_digits = false;
4690 has_charge = false;
4691 interval.end = start;
4692
-
4693 const int element_match_flags = flags & ~match_case_insensitive; // Chemical elements are always case-sensitive.
+
4693 const int element_match_flags = flags & ~match_case_insensitive; // Chemical elements are always case-sensitive.
4694 for (;;) {
-
4695 if (m_element->match(text, interval.end, end, element_match_flags)) {
+
4695 if (m_element->match(text, interval.end, end, element_match_flags)) {
4696 interval.end = m_element->interval.end;
-
4697 while (m_digit->match(text, interval.end, end, flags)) {
+
4697 while (m_digit->match(text, interval.end, end, flags)) {
4698 interval.end = m_digit->interval.end;
4699 has_digits = true;
4700 }
4701 }
4702 else if (start < interval.end) {
-
4703 if (m_sign->match(text, interval.end, end, flags)) {
+
4703 if (m_sign->match(text, interval.end, end, flags)) {
4704 interval.end = m_sign->interval.end;
4705 has_charge = true;
4706 }
@@ -4630,39 +4750,41 @@ $(function() {
4730 std::shared_ptr<basic_parser<T>> m_digit;
4731 std::shared_ptr<basic_parser<T>> m_sign;
4732 };
+
4733
-
4734 using chemical_formula = basic_chemical_formula<char>;
-
4735 using wchemical_formula = basic_chemical_formula<wchar_t>;
+
4734 using chemical_formula = basic_chemical_formula<char>;
+
4735 using wchemical_formula = basic_chemical_formula<wchar_t>;
4736#ifdef _UNICODE
-
4737 using tchemical_formula = wchemical_formula;
+
4737 using tchemical_formula = wchemical_formula;
4738#else
-
4739 using tchemical_formula = chemical_formula;
+
4739 using tchemical_formula = chemical_formula;
4740#endif
-
4741 using sgml_chemical_formula = basic_chemical_formula<char>;
+
4741 using sgml_chemical_formula = basic_chemical_formula<char>;
4742
+
4747 {
4748 public:
4749 virtual bool match(
-
4750 _In_reads_or_z_(end) const char* text,
-
4751 _In_ size_t start = 0,
-
4752 _In_ size_t end = (size_t)-1,
-
4753 _In_ int flags = match_default)
+
4750 _In_reads_or_z_(end) const char* text,
+
4751 _In_ size_t start = 0,
+
4752 _In_ size_t end = (size_t)-1,
+
4753 _In_ int flags = match_default)
4754 {
-
4755 assert(text || start >= end);
+
4755 assert(text || start >= end);
4756 interval.end = start;
4757
-
4758 assert(text || interval.end >= end);
-
4759 if (interval.end < end && text[interval.end]) {
-
4760 if (text[interval.end] == '\r') {
+
4758 assert(text || interval.end >= end);
+
4759 if (interval.end < end && text[interval.end]) {
+
4760 if (text[interval.end] == '\r') {
4761 interval.end++;
-
4762 if (interval.end < end && text[interval.end] == '\n') {
+
4762 if (interval.end < end && text[interval.end] == '\n') {
4763 interval.start = start;
4764 interval.end++;
4765 return true;
4766 }
4767 }
-
4768 else if (text[interval.end] == '\n') {
+
4768 else if (text[interval.end] == '\n') {
4769 interval.start = start;
4770 interval.end++;
4771 return true;
@@ -4672,31 +4794,33 @@ $(function() {
4775 return false;
4776 }
4777 };
+
4778
+
4782 class http_space : public parser
4783 {
4784 public:
4785 virtual bool match(
-
4786 _In_reads_or_z_(end) const char* text,
-
4787 _In_ size_t start = 0,
-
4788 _In_ size_t end = (size_t)-1,
-
4789 _In_ int flags = match_default)
+
4786 _In_reads_or_z_(end) const char* text,
+
4787 _In_ size_t start = 0,
+
4788 _In_ size_t end = (size_t)-1,
+
4789 _In_ int flags = match_default)
4790 {
-
4791 assert(text || start >= end);
+
4791 assert(text || start >= end);
4792 interval.end = start;
-
4793 if (m_line_break.match(text, interval.end, end, flags)) {
+
4793 if (m_line_break.match(text, interval.end, end, flags)) {
4794 interval.end = m_line_break.interval.end;
-
4795 if (interval.end < end && text[interval.end] && isspace(text[interval.end])) {
+
4795 if (interval.end < end && text[interval.end] && isspace(text[interval.end])) {
4796 interval.start = start;
4797 interval.end++;
-
4798 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
+
4798 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
4799 return true;
4800 }
4801 }
-
4802 else if (interval.end < end && text[interval.end] && isspace(text[interval.end])) {
+
4802 else if (interval.end < end && text[interval.end] && isspace(text[interval.end])) {
4803 interval.start = start;
4804 interval.end++;
-
4805 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
+
4805 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
4806 return true;
4807 }
4808 interval.start = (interval.end = start) + 1;
@@ -4706,26 +4830,28 @@ $(function() {
4812 protected:
4813 http_line_break m_line_break;
4814 };
+
4815
+
4819 class http_text_char : public parser
4820 {
4821 public:
4822 virtual bool match(
-
4823 _In_reads_or_z_(end) const char* text,
-
4824 _In_ size_t start = 0,
-
4825 _In_ size_t end = (size_t)-1,
-
4826 _In_ int flags = match_default)
+
4823 _In_reads_or_z_(end) const char* text,
+
4824 _In_ size_t start = 0,
+
4825 _In_ size_t end = (size_t)-1,
+
4826 _In_ int flags = match_default)
4827 {
-
4828 assert(text || start >= end);
+
4828 assert(text || start >= end);
4829 interval.end = start;
4830
-
4831 assert(text || interval.end >= end);
-
4832 if (m_space.match(text, interval.end, end, flags)) {
+
4831 assert(text || interval.end >= end);
+
4832 if (m_space.match(text, interval.end, end, flags)) {
4833 interval.start = start;
4834 interval.end = m_space.interval.end;
4835 return true;
4836 }
-
4837 else if (interval.end < end && text[interval.end] && text[interval.end] >= 0x20) {
+
4837 else if (interval.end < end && text[interval.end] && text[interval.end] >= 0x20) {
4838 interval.start = start;
4839 interval.end++;
4840 return true;
@@ -4737,40 +4863,42 @@ $(function() {
4846 protected:
4847 http_space m_space;
4848 };
+
4849
+
4853 class http_token : public parser
4854 {
4855 public:
4856 virtual bool match(
-
4857 _In_reads_or_z_(end) const char* text,
-
4858 _In_ size_t start = 0,
-
4859 _In_ size_t end = (size_t)-1,
-
4860 _In_ int flags = match_default)
+
4857 _In_reads_or_z_(end) const char* text,
+
4858 _In_ size_t start = 0,
+
4859 _In_ size_t end = (size_t)-1,
+
4860 _In_ int flags = match_default)
4861 {
-
4862 assert(text || start >= end);
+
4862 assert(text || start >= end);
4863 interval.end = start;
4864 for (;;) {
-
4865 if (interval.end < end && text[interval.end]) {
-
4866 if ((unsigned int)text[interval.end] < 0x20 ||
-
4867 (unsigned int)text[interval.end] == 0x7f ||
-
4868 text[interval.end] == '(' ||
-
4869 text[interval.end] == ')' ||
-
4870 text[interval.end] == '<' ||
-
4871 text[interval.end] == '>' ||
-
4872 text[interval.end] == '@' ||
-
4873 text[interval.end] == ',' ||
-
4874 text[interval.end] == ';' ||
-
4875 text[interval.end] == ':' ||
-
4876 text[interval.end] == '\\' ||
-
4877 text[interval.end] == '\"' ||
-
4878 text[interval.end] == '/' ||
-
4879 text[interval.end] == '[' ||
-
4880 text[interval.end] == ']' ||
-
4881 text[interval.end] == '?' ||
-
4882 text[interval.end] == '=' ||
-
4883 text[interval.end] == '{' ||
-
4884 text[interval.end] == '}' ||
-
4885 isspace(text[interval.end]))
+
4865 if (interval.end < end && text[interval.end]) {
+
4866 if ((unsigned int)text[interval.end] < 0x20 ||
+
4867 (unsigned int)text[interval.end] == 0x7f ||
+
4868 text[interval.end] == '(' ||
+
4869 text[interval.end] == ')' ||
+
4870 text[interval.end] == '<' ||
+
4871 text[interval.end] == '>' ||
+
4872 text[interval.end] == '@' ||
+
4873 text[interval.end] == ',' ||
+
4874 text[interval.end] == ';' ||
+
4875 text[interval.end] == ':' ||
+
4876 text[interval.end] == '\\' ||
+
4877 text[interval.end] == '\"' ||
+
4878 text[interval.end] == '/' ||
+
4879 text[interval.end] == '[' ||
+
4880 text[interval.end] == ']' ||
+
4881 text[interval.end] == '?' ||
+
4882 text[interval.end] == '=' ||
+
4883 text[interval.end] == '{' ||
+
4884 text[interval.end] == '}' ||
+
4886 break;
4887 else
4888 interval.end++;
@@ -4788,50 +4916,52 @@ $(function() {
4900 }
4901 }
4902 };
+
4903
+
4908 {
4909 public:
4910 virtual bool match(
-
4911 _In_reads_or_z_(end) const char* text,
-
4912 _In_ size_t start = 0,
-
4913 _In_ size_t end = (size_t)-1,
-
4914 _In_ int flags = match_default)
+
4911 _In_reads_or_z_(end) const char* text,
+
4912 _In_ size_t start = 0,
+
4913 _In_ size_t end = (size_t)-1,
+
4914 _In_ int flags = match_default)
4915 {
-
4916 assert(text || start >= end);
+
4916 assert(text || start >= end);
4917 interval.end = start;
-
4918 if (interval.end < end && text[interval.end] != '"')
-
4919 goto error;
+
4918 if (interval.end < end && text[interval.end] != '"')
+
4919 goto error;
4920 interval.end++;
4922 for (;;) {
-
4923 assert(text || interval.end >= end);
-
4924 if (interval.end < end && text[interval.end]) {
-
4925 if (text[interval.end] == '"') {
+
4923 assert(text || interval.end >= end);
+
4924 if (interval.end < end && text[interval.end]) {
+
4925 if (text[interval.end] == '"') {
4927 interval.end++;
4928 break;
4929 }
-
4930 else if (text[interval.end] == '\\') {
+
4930 else if (text[interval.end] == '\\') {
4931 interval.end++;
-
4932 if (interval.end < end && text[interval.end]) {
+
4932 if (interval.end < end && text[interval.end]) {
4933 interval.end++;
4934 }
4935 else
-
4936 goto error;
+
4936 goto error;
4937 }
-
4938 else if (m_chr.match(text, interval.end, end, flags))
+
4938 else if (m_chr.match(text, interval.end, end, flags))
4939 interval.end++;
4940 else
-
4941 goto error;
+
4941 goto error;
4942 }
4943 else
-
4944 goto error;
+
4944 goto error;
4945 }
4946 interval.start = start;
4947 return true;
4948
-
4949 error:
+
4949 error:
4950 content.start = 1;
4951 content.end = 0;
4952 interval.start = (interval.end = start) + 1;
@@ -4851,25 +4981,27 @@ $(function() {
4966 protected:
4967 http_text_char m_chr;
4968 };
+
4969
+
4973 class http_value : public parser
4974 {
4975 public:
4976 virtual bool match(
-
4977 _In_reads_or_z_(end) const char* text,
-
4978 _In_ size_t start = 0,
-
4979 _In_ size_t end = (size_t)-1,
-
4980 _In_ int flags = match_default)
+
4977 _In_reads_or_z_(end) const char* text,
+
4978 _In_ size_t start = 0,
+
4979 _In_ size_t end = (size_t)-1,
+
4980 _In_ int flags = match_default)
4981 {
-
4982 assert(text || start >= end);
+
4982 assert(text || start >= end);
4983 interval.end = start;
-
4984 if (string.match(text, interval.end, end, flags)) {
+
4984 if (string.match(text, interval.end, end, flags)) {
4985 token.invalidate();
4986 interval.end = string.interval.end;
4987 interval.start = start;
4988 return true;
4989 }
-
4990 else if (token.match(text, interval.end, end, flags)) {
+
4990 else if (token.match(text, interval.end, end, flags)) {
4991 string.invalidate();
4993 interval.start = start;
@@ -4892,38 +5024,40 @@ $(function() {
5012 };
+
5013
+
5017 class http_parameter : public parser
5018 {
5019 public:
5020 virtual bool match(
-
5021 _In_reads_or_z_(end) const char* text,
-
5022 _In_ size_t start = 0,
-
5023 _In_ size_t end = (size_t)-1,
-
5024 _In_ int flags = match_default)
+
5021 _In_reads_or_z_(end) const char* text,
+
5022 _In_ size_t start = 0,
+
5023 _In_ size_t end = (size_t)-1,
+
5024 _In_ int flags = match_default)
5025 {
-
5026 assert(text || start >= end);
+
5026 assert(text || start >= end);
5027 interval.end = start;
-
5028 if (name.match(text, interval.end, end, flags))
+
5028 if (name.match(text, interval.end, end, flags))
5030 else
-
5031 goto error;
-
5032 while (m_space.match(text, interval.end, end, flags))
+
5031 goto error;
+
5032 while (m_space.match(text, interval.end, end, flags))
5033 interval.end = m_space.interval.end;
-
5034 assert(text || interval.end >= end);
-
5035 if (interval.end < end && text[interval.end] == '=')
+
5034 assert(text || interval.end >= end);
+
5035 if (interval.end < end && text[interval.end] == '=')
5036 interval.end++;
5037 else
-
5038 while (m_space.match(text, interval.end, end, flags))
+
5038 while (m_space.match(text, interval.end, end, flags))
5039 interval.end = m_space.interval.end;
-
5040 if (value.match(text, interval.end, end, flags))
+
5040 if (value.match(text, interval.end, end, flags))
5042 else
-
5043 goto error;
+
5043 goto error;
5044 interval.start = start;
5045 return true;
5046
-
5047 error:
+
5047 error:
5048 name.invalidate();
5049 value.invalidate();
5050 interval.start = (interval.end = start) + 1;
@@ -4944,26 +5078,28 @@ $(function() {
5065 protected:
5066 http_space m_space;
5067 };
+
5068
+
5072 class http_any_type : public parser
5073 {
5074 public:
5075 virtual bool match(
-
5076 _In_reads_or_z_(end) const char* text,
-
5077 _In_ size_t start = 0,
-
5078 _In_ size_t end = (size_t)-1,
-
5079 _In_ int flags = match_default)
+
5076 _In_reads_or_z_(end) const char* text,
+
5077 _In_ size_t start = 0,
+
5078 _In_ size_t end = (size_t)-1,
+
5079 _In_ int flags = match_default)
5080 {
-
5081 assert(text || start >= end);
+
5081 assert(text || start >= end);
5082 if (start + 2 < end &&
-
5083 text[start] == '*' &&
-
5084 text[start + 1] == '/' &&
-
5085 text[start + 2] == '*')
+
5083 text[start] == '*' &&
+
5084 text[start + 1] == '/' &&
+
5085 text[start + 2] == '*')
5086 {
5087 interval.end = (interval.start = start) + 3;
5088 return true;
5089 }
-
5090 else if (start < end && text[start] == '*') {
+
5090 else if (start < end && text[start] == '*') {
5091 interval.end = (interval.start = start) + 1;
5092 return true;
5093 }
@@ -4973,38 +5109,40 @@ $(function() {
5097 }
5098 }
5099 };
+
5100
+
5105 {
5106 public:
5107 virtual bool match(
-
5108 _In_reads_or_z_(end) const char* text,
-
5109 _In_ size_t start = 0,
-
5110 _In_ size_t end = (size_t)-1,
-
5111 _In_ int flags = match_default)
+
5108 _In_reads_or_z_(end) const char* text,
+
5109 _In_ size_t start = 0,
+
5110 _In_ size_t end = (size_t)-1,
+
5111 _In_ int flags = match_default)
5112 {
-
5113 assert(text || start >= end);
+
5113 assert(text || start >= end);
5114 interval.end = start;
-
5115 if (type.match(text, interval.end, end, flags))
+
5115 if (type.match(text, interval.end, end, flags))
5116 interval.end = type.interval.end;
5117 else
-
5118 goto error;
-
5119 while (m_space.match(text, interval.end, end, flags))
+
5118 goto error;
+
5119 while (m_space.match(text, interval.end, end, flags))
5120 interval.end = m_space.interval.end;
-
5121 if (interval.end < end && text[interval.end] == '/')
+
5121 if (interval.end < end && text[interval.end] == '/')
5122 interval.end++;
5123 else
-
5124 goto error;
-
5125 while (m_space.match(text, interval.end, end, flags))
+
5124 goto error;
+
5125 while (m_space.match(text, interval.end, end, flags))
5126 interval.end = m_space.interval.end;
-
5127 if (subtype.match(text, interval.end, end, flags))
+
5127 if (subtype.match(text, interval.end, end, flags))
5128 interval.end = subtype.interval.end;
5129 else
-
5130 goto error;
+
5130 goto error;
5131 interval.start = start;
5132 return true;
5133
-
5134 error:
+
5134 error:
5135 type.invalidate();
5136 subtype.invalidate();
5137 interval.start = (interval.end = start) + 1;
@@ -5025,32 +5163,34 @@ $(function() {
5152 protected:
5153 http_space m_space;
5154 };
+
5155
+
5160 {
5161 public:
5162 virtual bool match(
-
5163 _In_reads_or_z_(end) const char* text,
-
5164 _In_ size_t start = 0,
-
5165 _In_ size_t end = (size_t)-1,
-
5166 _In_ int flags = match_default)
+
5163 _In_reads_or_z_(end) const char* text,
+
5164 _In_ size_t start = 0,
+
5165 _In_ size_t end = (size_t)-1,
+
5166 _In_ int flags = match_default)
5167 {
-
5168 assert(text || start >= end);
-
5169 if (!http_media_range::match(text, start, end, flags))
-
5170 goto error;
+
5168 assert(text || start >= end);
+
5169 if (!http_media_range::match(text, start, end, flags))
+
5170 goto error;
5171 params.clear();
5172 for (;;) {
-
5173 if (interval.end < end && text[interval.end]) {
-
5174 if (m_space.match(text, interval.end, end, flags))
+
5173 if (interval.end < end && text[interval.end]) {
+
5174 if (m_space.match(text, interval.end, end, flags))
5175 interval.end = m_space.interval.end;
-
5176 else if (text[interval.end] == ';') {
+
5176 else if (text[interval.end] == ';') {
5177 interval.end++;
-
5178 while (m_space.match(text, interval.end, end, flags))
+
5178 while (m_space.match(text, interval.end, end, flags))
5179 interval.end = m_space.interval.end;
-
5180 http_parameter param;
-
5181 if (param.match(text, interval.end, end, flags)) {
-
5182 interval.end = param.interval.end;
-
5183 params.push_back(std::move(param));
+ +
5181 if (param.match(text, interval.end, end, flags)) {
+ +
5183 params.push_back(std::move(param));
5184 }
5185 else
5186 break;
@@ -5064,7 +5204,7 @@ $(function() {
5194 interval.end = params.empty() ? subtype.interval.end : params.back().interval.end;
5195 return true;
5196
-
5197 error:
+
5197 error:
5198 http_media_range::invalidate();
5199 params.clear();
5200 interval.start = (interval.end = start) + 1;
@@ -5080,25 +5220,27 @@ $(function() {
5210 public:
5211 std::list<http_parameter> params;
5212 };
+
5213
+
5218 {
5219 public:
5220 virtual bool match(
-
5221 _In_reads_or_z_(end) const char* text,
-
5222 _In_ size_t start = 0,
-
5223 _In_ size_t end = (size_t)-1,
-
5224 _In_ int flags = match_default)
+
5221 _In_reads_or_z_(end) const char* text,
+
5222 _In_ size_t start = 0,
+
5223 _In_ size_t end = (size_t)-1,
+
5224 _In_ int flags = match_default)
5225 {
-
5226 assert(text || start >= end);
+
5226 assert(text || start >= end);
5227 interval.end = start;
5228 for (;;) {
-
5229 if (interval.end < end && text[interval.end]) {
-
5230 if ((unsigned int)text[interval.end] < 0x20 ||
-
5231 (unsigned int)text[interval.end] == 0x7f ||
-
5232 text[interval.end] == ':' ||
-
5233 text[interval.end] == '/' ||
-
5234 isspace(text[interval.end]))
+
5229 if (interval.end < end && text[interval.end]) {
+
5230 if ((unsigned int)text[interval.end] < 0x20 ||
+
5231 (unsigned int)text[interval.end] == 0x7f ||
+
5232 text[interval.end] == ':' ||
+
5233 text[interval.end] == '/' ||
+
5235 break;
5236 else
5237 interval.end++;
@@ -5114,34 +5256,36 @@ $(function() {
5247 return false;
5248 }
5249 };
+
5250
+
5254 class http_url_port : public parser
5255 {
5256 public:
-
5257 http_url_port(_In_ const std::locale& locale = std::locale()) :
+
5257 http_url_port(_In_ const std::locale& locale = std::locale()) :
5258 parser(locale),
5259 value(0)
5260 {}
5261
5262 virtual bool match(
-
5263 _In_reads_or_z_(end) const char* text,
-
5264 _In_ size_t start = 0,
-
5265 _In_ size_t end = (size_t)-1,
-
5266 _In_ int flags = match_default)
+
5263 _In_reads_or_z_(end) const char* text,
+
5264 _In_ size_t start = 0,
+
5265 _In_ size_t end = (size_t)-1,
+
5266 _In_ int flags = match_default)
5267 {
-
5268 assert(text || start >= end);
+
5268 assert(text || start >= end);
5269 value = 0;
5270 interval.end = start;
5271 for (;;) {
-
5272 if (interval.end < end && text[interval.end]) {
-
5273 if ('0' <= text[interval.end] && text[interval.end] <= '9') {
-
5274 size_t _value = (size_t)value * 10 + text[interval.end] - '0';
-
5275 if (_value > (uint16_t)-1) {
+
5272 if (interval.end < end && text[interval.end]) {
+
5273 if ('0' <= text[interval.end] && text[interval.end] <= '9') {
+
5274 size_t _value = (size_t)value * 10 + text[interval.end] - '0';
+
5275 if (_value > (uint16_t)-1) {
5276 value = 0;
5277 interval.start = (interval.end = start) + 1;
5278 return false;
5279 }
-
5280 value = (uint16_t)_value;
+
5280 value = (uint16_t)_value;
5281 interval.end++;
5282 }
5283 else
@@ -5165,27 +5309,29 @@ $(function() {
5301 }
5302
5303 public:
-
5304 uint16_t value;
+
5304 uint16_t value;
5305 };
+
5306
+
5311 {
5312 public:
5313 virtual bool match(
-
5314 _In_reads_or_z_(end) const char* text,
-
5315 _In_ size_t start = 0,
-
5316 _In_ size_t end = (size_t)-1,
-
5317 _In_ int flags = match_default)
+
5314 _In_reads_or_z_(end) const char* text,
+
5315 _In_ size_t start = 0,
+
5316 _In_ size_t end = (size_t)-1,
+
5317 _In_ int flags = match_default)
5318 {
-
5319 assert(text || start >= end);
+
5319 assert(text || start >= end);
5320 interval.end = start;
5321 for (;;) {
-
5322 if (interval.end < end && text[interval.end]) {
-
5323 if ((unsigned int)text[interval.end] < 0x20 ||
-
5324 (unsigned int)text[interval.end] == 0x7f ||
-
5325 text[interval.end] == '?' ||
-
5326 text[interval.end] == '/' ||
-
5327 isspace(text[interval.end]))
+
5322 if (interval.end < end && text[interval.end]) {
+
5323 if ((unsigned int)text[interval.end] < 0x20 ||
+
5324 (unsigned int)text[interval.end] == 0x7f ||
+
5325 text[interval.end] == '?' ||
+
5326 text[interval.end] == '/' ||
+
5328 break;
5329 else
5330 interval.end++;
@@ -5197,34 +5343,36 @@ $(function() {
5336 return true;
5337 }
5338 };
+
5339
+
5343 class http_url_path : public parser
5344 {
5345 public:
5346 virtual bool match(
-
5347 _In_reads_or_z_(end) const char* text,
-
5348 _In_ size_t start = 0,
-
5349 _In_ size_t end = (size_t)-1,
-
5350 _In_ int flags = match_default)
+
5347 _In_reads_or_z_(end) const char* text,
+
5348 _In_ size_t start = 0,
+
5349 _In_ size_t end = (size_t)-1,
+
5350 _In_ int flags = match_default)
5351 {
-
5352 assert(text || start >= end);
- +
5352 assert(text || start >= end);
+
5354 interval.end = start;
5355 segments.clear();
-
5356 assert(text || interval.end >= end);
-
5357 if (interval.end < end && text[interval.end] != '/')
-
5358 goto error;
+
5356 assert(text || interval.end >= end);
+
5357 if (interval.end < end && text[interval.end] != '/')
+
5358 goto error;
5359 interval.end++;
-
5360 s.match(text, interval.end, end, flags);
-
5361 segments.push_back(s);
- +
5360 s.match(text, interval.end, end, flags);
+
5361 segments.push_back(s);
+
5363 for (;;) {
-
5364 if (interval.end < end && text[interval.end]) {
-
5365 if (text[interval.end] == '/') {
+
5364 if (interval.end < end && text[interval.end]) {
+
5365 if (text[interval.end] == '/') {
5366 interval.end++;
-
5367 s.match(text, interval.end, end, flags);
-
5368 segments.push_back(s);
- +
5367 s.match(text, interval.end, end, flags);
+
5368 segments.push_back(s);
+
5370 }
5371 else
5372 break;
@@ -5235,7 +5383,7 @@ $(function() {
5377 interval.start = start;
5378 return true;
5379
-
5380 error:
+
5380 error:
5381 segments.clear();
5382 interval.start = (interval.end = start) + 1;
5383 return false;
@@ -5250,26 +5398,28 @@ $(function() {
5392 public:
5393 std::vector<http_url_path_segment> segments;
5394 };
+
5395
+
5400 {
5401 public:
5402 virtual bool match(
-
5403 _In_reads_or_z_(end) const char* text,
-
5404 _In_ size_t start = 0,
-
5405 _In_ size_t end = (size_t)-1,
-
5406 _In_ int flags = match_default)
+
5403 _In_reads_or_z_(end) const char* text,
+
5404 _In_ size_t start = 0,
+
5405 _In_ size_t end = (size_t)-1,
+
5406 _In_ int flags = match_default)
5407 {
-
5408 assert(text || start >= end);
+
5408 assert(text || start >= end);
5409 interval.end = start;
5410 name.start = interval.end;
5411 for (;;) {
-
5412 if (interval.end < end && text[interval.end]) {
-
5413 if ((unsigned int)text[interval.end] < 0x20 ||
-
5414 (unsigned int)text[interval.end] == 0x7f ||
-
5415 text[interval.end] == '&' ||
-
5416 text[interval.end] == '=' ||
-
5417 isspace(text[interval.end]))
+
5412 if (interval.end < end && text[interval.end]) {
+
5413 if ((unsigned int)text[interval.end] < 0x20 ||
+
5414 (unsigned int)text[interval.end] == 0x7f ||
+
5415 text[interval.end] == '&' ||
+
5416 text[interval.end] == '=' ||
+
5418 break;
5419 else
5420 interval.end++;
@@ -5280,16 +5430,16 @@ $(function() {
5425 if (start < interval.end)
5426 name.end = interval.end;
5427 else
-
5428 goto error;
-
5429 if (text[interval.end] == '=') {
+
5428 goto error;
+
5429 if (text[interval.end] == '=') {
5430 interval.end++;
5431 value.start = interval.end;
5432 for (;;) {
-
5433 if (interval.end < end && text[interval.end]) {
-
5434 if ((unsigned int)text[interval.end] < 0x20 ||
-
5435 (unsigned int)text[interval.end] == 0x7f ||
-
5436 text[interval.end] == '&' ||
-
5437 isspace(text[interval.end]))
+
5433 if (interval.end < end && text[interval.end]) {
+
5434 if ((unsigned int)text[interval.end] < 0x20 ||
+
5435 (unsigned int)text[interval.end] == 0x7f ||
+
5436 text[interval.end] == '&' ||
+
5438 break;
5439 else
5440 interval.end++;
@@ -5306,7 +5456,7 @@ $(function() {
5451 interval.start = start;
5452 return true;
5453
-
5454 error:
+
5454 error:
5455 name.start = 1;
5456 name.end = 0;
5457 value.start = 1;
@@ -5328,33 +5478,35 @@ $(function() {
5475 };
+
5476
+
5480 class http_url : public parser
5481 {
5482 public:
-
5483 http_url(_In_ const std::locale& locale = std::locale()) :
+
5483 http_url(_In_ const std::locale& locale = std::locale()) :
5484 parser(locale),
5485 port(locale)
5486 {}
5487
5488 virtual bool match(
-
5489 _In_reads_or_z_(end) const char* text,
-
5490 _In_ size_t start = 0,
-
5491 _In_ size_t end = (size_t)-1,
-
5492 _In_ int flags = match_default)
+
5489 _In_reads_or_z_(end) const char* text,
+
5490 _In_ size_t start = 0,
+
5491 _In_ size_t end = (size_t)-1,
+
5492 _In_ int flags = match_default)
5493 {
-
5494 assert(text || start >= end);
+
5494 assert(text || start >= end);
5495 interval.end = start;
5496
-
5497 if (interval.end + 7 <= end && stdex::strnicmp(text + interval.end, 7, "http://", (size_t)-1, m_locale) == 0) {
+
5497 if (interval.end + 7 <= end && stdex::strnicmp(text + interval.end, 7, "http://", (size_t)-1, m_locale) == 0) {
5498 interval.end += 7;
-
5499 if (server.match(text, interval.end, end, flags))
+
5499 if (server.match(text, interval.end, end, flags))
5500 interval.end = server.interval.end;
5501 else
-
5502 goto error;
-
5503 if (interval.end < end && text[interval.end] == ':') {
+
5502 goto error;
+
5503 if (interval.end < end && text[interval.end] == ':') {
5504 interval.end++;
-
5505 if (port.match(text, interval.end, end, flags))
+
5505 if (port.match(text, interval.end, end, flags))
5506 interval.end = port.interval.end;
5507 }
5508 else {
@@ -5368,28 +5520,28 @@ $(function() {
5516 port.value = 80;
5517 }
5518
-
5519 if (path.match(text, interval.end, end, flags))
+
5519 if (path.match(text, interval.end, end, flags))
5520 interval.end = path.interval.end;
5521 else
-
5522 goto error;
+
5522 goto error;
5523
5524 params.clear();
5525
-
5526 if (interval.end < end && text[interval.end] == '?') {
+
5526 if (interval.end < end && text[interval.end] == '?') {
5527 interval.end++;
5528 for (;;) {
-
5529 if (interval.end < end && text[interval.end]) {
-
5530 if ((unsigned int)text[interval.end] < 0x20 ||
-
5531 (unsigned int)text[interval.end] == 0x7f ||
-
5532 isspace(text[interval.end]))
+
5529 if (interval.end < end && text[interval.end]) {
+
5530 if ((unsigned int)text[interval.end] < 0x20 ||
+
5531 (unsigned int)text[interval.end] == 0x7f ||
+
5533 break;
-
5534 else if (text[interval.end] == '&')
+
5534 else if (text[interval.end] == '&')
5535 interval.end++;
5536 else {
-
5537 http_url_parameter param;
-
5538 if (param.match(text, interval.end, end, flags)) {
-
5539 interval.end = param.interval.end;
-
5540 params.push_back(std::move(param));
+ +
5538 if (param.match(text, interval.end, end, flags)) {
+ +
5540 params.push_back(std::move(param));
5541 }
5542 else
5543 break;
@@ -5403,7 +5555,7 @@ $(function() {
5551 interval.start = start;
5552 return true;
5553
-
5554 error:
+
5554 error:
5555 server.invalidate();
5556 port.invalidate();
5557 path.invalidate();
@@ -5427,41 +5579,43 @@ $(function() {
5575 http_url_path path;
5576 std::list<http_url_parameter> params;
5577 };
+
5578
+
5582 class http_language : public parser
5583 {
5584 public:
5585 virtual bool match(
-
5586 _In_reads_or_z_(end) const char* text,
-
5587 _In_ size_t start = 0,
-
5588 _In_ size_t end = (size_t)-1,
-
5589 _In_ int flags = match_default)
+
5586 _In_reads_or_z_(end) const char* text,
+
5587 _In_ size_t start = 0,
+
5588 _In_ size_t end = (size_t)-1,
+
5589 _In_ int flags = match_default)
5590 {
-
5591 assert(text || start >= end);
+
5591 assert(text || start >= end);
5592 interval.end = start;
5593 components.clear();
5594 for (;;) {
-
5595 if (interval.end < end && text[interval.end]) {
- -
5597 k.end = interval.end;
+
5595 if (interval.end < end && text[interval.end]) {
+ +
5597 k.end = interval.end;
5598 for (;;) {
-
5599 if (k.end < end && text[k.end]) {
-
5600 if (isalpha(text[k.end]))
-
5601 k.end++;
+
5599 if (k.end < end && text[k.end]) {
+
5600 if (isalpha(text[k.end]))
+
5601 k.end++;
5602 else
5603 break;
5604 }
5605 else
5606 break;
5607 }
-
5608 if (interval.end < k.end) {
-
5609 k.start = interval.end;
-
5610 interval.end = k.end;
-
5611 components.push_back(k);
+
5608 if (interval.end < k.end) {
+
5609 k.start = interval.end;
+
5610 interval.end = k.end;
+
5611 components.push_back(k);
5612 }
5613 else
5614 break;
-
5615 if (interval.end < end && text[interval.end] == '-')
+
5615 if (interval.end < end && text[interval.end] == '-')
5616 interval.end++;
5617 else
5618 break;
@@ -5487,37 +5641,39 @@ $(function() {
5638 public:
5639 std::vector<stdex::interval<size_t>> components;
5640 };
+
5641
+
5645 class http_weight : public parser
5646 {
5647 public:
-
5648 http_weight(_In_ const std::locale& locale = std::locale()) :
+
5648 http_weight(_In_ const std::locale& locale = std::locale()) :
5649 parser(locale),
5650 value(1.0f)
5651 {}
5652
5653 virtual bool match(
-
5654 _In_reads_or_z_(end) const char* text,
-
5655 _In_ size_t start = 0,
-
5656 _In_ size_t end = (size_t)-1,
-
5657 _In_ int flags = match_default)
+
5654 _In_reads_or_z_(end) const char* text,
+
5655 _In_ size_t start = 0,
+
5656 _In_ size_t end = (size_t)-1,
+
5657 _In_ int flags = match_default)
5658 {
-
5659 assert(text || start >= end);
-
5660 size_t celi_del = 0, decimalni_del = 0, decimalni_del_n = 1;
+
5659 assert(text || start >= end);
+
5660 size_t celi_del = 0, decimalni_del = 0, decimalni_del_n = 1;
5661 interval.end = start;
5662 for (;;) {
-
5663 if (interval.end < end && text[interval.end]) {
-
5664 if ('0' <= text[interval.end] && text[interval.end] <= '9') {
-
5665 celi_del = celi_del * 10 + text[interval.end] - '0';
+
5663 if (interval.end < end && text[interval.end]) {
+
5664 if ('0' <= text[interval.end] && text[interval.end] <= '9') {
+
5665 celi_del = celi_del * 10 + text[interval.end] - '0';
5666 interval.end++;
5667 }
-
5668 else if (text[interval.end] == '.') {
+
5668 else if (text[interval.end] == '.') {
5669 interval.end++;
5670 for (;;) {
-
5671 if (interval.end < end && text[interval.end]) {
-
5672 if ('0' <= text[interval.end] && text[interval.end] <= '9') {
-
5673 decimalni_del = decimalni_del * 10 + text[interval.end] - '0';
-
5674 decimalni_del_n *= 10;
+
5671 if (interval.end < end && text[interval.end]) {
+
5672 if ('0' <= text[interval.end] && text[interval.end] <= '9') {
+ +
5674 decimalni_del_n *= 10;
5675 interval.end++;
5676 }
5677 else
@@ -5535,7 +5691,7 @@ $(function() {
5689 break;
5690 }
5691 if (start < interval.end) {
-
5692 value = (float)((double)celi_del + (double)decimalni_del / decimalni_del_n);
+
5693 interval.start = start;
5694 return true;
5695 }
@@ -5553,18 +5709,20 @@ $(function() {
5707 public:
5708 float value;
5709 };
+
5710
+
5714 class http_asterisk : public parser
5715 {
5716 public:
5717 virtual bool match(
-
5718 _In_reads_or_z_(end) const char* text,
-
5719 _In_ size_t start = 0,
-
5720 _In_ size_t end = (size_t)-1,
-
5721 _In_ int flags = match_default)
+
5718 _In_reads_or_z_(end) const char* text,
+
5719 _In_ size_t start = 0,
+
5720 _In_ size_t end = (size_t)-1,
+
5721 _In_ int flags = match_default)
5722 {
-
5723 assert(text || end <= start);
-
5724 if (start < end && text[start] == '*') {
+
5723 assert(text || end <= start);
+
5724 if (start < end && text[start] == '*') {
5725 interval.end = (interval.start = start) + 1;
5726 return true;
5727 }
@@ -5572,31 +5730,33 @@ $(function() {
5729 return false;
5730 }
5731 };
+
5732
5736 template <class T, class T_asterisk = http_asterisk>
+
5738 {
5739 public:
-
5740 http_weighted_value(_In_ const std::locale& locale = std::locale()) :
+
5740 http_weighted_value(_In_ const std::locale& locale = std::locale()) :
5741 parser(locale),
5742 factor(locale)
5743 {}
5744
5745 virtual bool match(
-
5746 _In_reads_or_z_(end) const char* text,
-
5747 _In_ size_t start = 0,
-
5748 _In_ size_t end = (size_t)-1,
-
5749 _In_ int flags = match_default)
+
5746 _In_reads_or_z_(end) const char* text,
+
5747 _In_ size_t start = 0,
+
5748 _In_ size_t end = (size_t)-1,
+
5749 _In_ int flags = match_default)
5750 {
-
5751 assert(text || start >= end);
-
5752 size_t konec_vrednosti;
+
5751 assert(text || start >= end);
+
5752 size_t konec_vrednosti;
5753 interval.end = start;
-
5754 if (asterisk.match(text, interval.end, end, flags)) {
-
5755 interval.end = konec_vrednosti = asterisk.interval.end;
+
5754 if (asterisk.match(text, interval.end, end, flags)) {
+
5756 value.invalidate();
5757 }
-
5758 else if (value.match(text, interval.end, end, flags)) {
-
5759 interval.end = konec_vrednosti = value.interval.end;
+
5758 else if (value.match(text, interval.end, end, flags)) {
+
5759 interval.end = konec_vrednosti = value.interval.end;
5760 asterisk.invalidate();
5761 }
5762 else {
@@ -5606,24 +5766,24 @@ $(function() {
5766 return false;
5767 }
5768
-
5769 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
-
5770 if (interval.end < end && text[interval.end] == ';') {
+
5769 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
+
5770 if (interval.end < end && text[interval.end] == ';') {
5771 interval.end++;
-
5772 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
-
5773 if (interval.end < end && (text[interval.end] == 'q' || text[interval.end] == 'Q')) {
+
5772 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
+
5773 if (interval.end < end && (text[interval.end] == 'q' || text[interval.end] == 'Q')) {
5774 interval.end++;
-
5775 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
-
5776 if (interval.end < end && text[interval.end] == '=') {
+
5775 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
+
5776 if (interval.end < end && text[interval.end] == '=') {
5777 interval.end++;
-
5778 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
-
5779 if (factor.match(text, interval.end, end, flags))
+
5778 while (interval.end < end && text[interval.end] && isspace(text[interval.end])) interval.end++;
+
5779 if (factor.match(text, interval.end, end, flags))
5780 interval.end = factor.interval.end;
5781 }
5782 }
5783 }
5784 if (!factor.interval) {
5785 factor.invalidate();
-
5786 interval.end = konec_vrednosti;
+
5787 }
5788 interval.start = start;
5789 return true;
@@ -5638,46 +5798,48 @@ $(function() {
5798 }
5799
5800 public:
-
5801 T_asterisk asterisk;
+
5801 T_asterisk asterisk;
5802 T value;
5803 http_weight factor;
5804 };
+
5805
+
5810 {
5811 public:
5812 virtual bool match(
-
5813 _In_reads_or_z_(end) const char* text,
-
5814 _In_ size_t start = 0,
-
5815 _In_ size_t end = (size_t)-1,
-
5816 _In_ int flags = match_default)
+
5813 _In_reads_or_z_(end) const char* text,
+
5814 _In_ size_t start = 0,
+
5815 _In_ size_t end = (size_t)-1,
+
5816 _In_ int flags = match_default)
5817 {
-
5818 assert(text || start >= end);
+
5818 assert(text || start >= end);
5819 interval.end = start;
-
5820 if (interval.end < end && text[interval.end] == '$')
+
5820 if (interval.end < end && text[interval.end] == '$')
5821 interval.end++;
5822 else
-
5823 goto error;
-
5824 if (name.match(text, interval.end, end, flags))
+
5823 goto error;
+
5824 if (name.match(text, interval.end, end, flags))
5825 interval.end = name.interval.end;
5826 else
-
5827 goto error;
-
5828 while (m_space.match(text, interval.end, end, flags))
+
5827 goto error;
+
5828 while (m_space.match(text, interval.end, end, flags))
5829 interval.end = m_space.interval.end;
-
5830 if (interval.end < end && text[interval.end] == '=')
+
5830 if (interval.end < end && text[interval.end] == '=')
5831 interval.end++;
5832 else
-
5833 goto error;
-
5834 while (m_space.match(text, interval.end, end, flags))
+
5833 goto error;
+
5834 while (m_space.match(text, interval.end, end, flags))
5835 interval.end = m_space.interval.end;
-
5836 if (value.match(text, interval.end, end, flags))
+
5836 if (value.match(text, interval.end, end, flags))
5837 interval.end = value.interval.end;
5838 else
-
5839 goto error;
+
5839 goto error;
5840 interval.start = start;
5841 return true;
5842
-
5843 error:
+
5843 error:
5844 name.invalidate();
5845 value.invalidate();
5846 interval.start = (interval.end = start) + 1;
@@ -5698,47 +5860,49 @@ $(function() {
5861 protected:
5862 http_space m_space;
5863 };
+
5864
+
5868 class http_cookie : public parser
5869 {
5870 public:
5871 virtual bool match(
-
5872 _In_reads_or_z_(end) const char* text,
-
5873 _In_ size_t start = 0,
-
5874 _In_ size_t end = (size_t)-1,
-
5875 _In_ int flags = match_default)
+
5872 _In_reads_or_z_(end) const char* text,
+
5873 _In_ size_t start = 0,
+
5874 _In_ size_t end = (size_t)-1,
+
5875 _In_ int flags = match_default)
5876 {
-
5877 assert(text || start >= end);
+
5877 assert(text || start >= end);
5878 interval.end = start;
-
5879 if (name.match(text, interval.end, end, flags))
+
5879 if (name.match(text, interval.end, end, flags))
5881 else
-
5882 goto error;
-
5883 while (m_space.match(text, interval.end, end, flags))
+
5882 goto error;
+
5883 while (m_space.match(text, interval.end, end, flags))
5884 interval.end = m_space.interval.end;
-
5885 if (interval.end < end && text[interval.end] == '=')
+
5885 if (interval.end < end && text[interval.end] == '=')
5886 interval.end++;
5887 else
-
5888 goto error;
-
5889 while (m_space.match(text, interval.end, end, flags))
+
5888 goto error;
+
5889 while (m_space.match(text, interval.end, end, flags))
5890 interval.end = m_space.interval.end;
-
5891 if (value.match(text, interval.end, end, flags))
+
5891 if (value.match(text, interval.end, end, flags))
5893 else
-
5894 goto error;
+
5894 goto error;
5895 params.clear();
5896 for (;;) {
-
5897 if (interval.end < end && text[interval.end]) {
-
5898 if (m_space.match(text, interval.end, end, flags))
+
5897 if (interval.end < end && text[interval.end]) {
+
5898 if (m_space.match(text, interval.end, end, flags))
5899 interval.end = m_space.interval.end;
-
5900 else if (text[interval.end] == ';') {
+
5900 else if (text[interval.end] == ';') {
5901 interval.end++;
-
5902 while (m_space.match(text, interval.end, end, flags))
+
5902 while (m_space.match(text, interval.end, end, flags))
5903 interval.end = m_space.interval.end;
- -
5905 if (param.match(text, interval.end, end, flags)) {
-
5906 interval.end = param.interval.end;
-
5907 params.push_back(std::move(param));
+ +
5905 if (param.match(text, interval.end, end, flags)) {
+ +
5907 params.push_back(std::move(param));
5908 }
5909 else
5910 break;
@@ -5753,7 +5917,7 @@ $(function() {
5919 interval.end = params.empty() ? value.interval.end : params.back().interval.end;
5920 return true;
5921
-
5922 error:
+
5922 error:
5923 name.invalidate();
5924 value.invalidate();
5925 params.clear();
@@ -5777,28 +5941,30 @@ $(function() {
5943 protected:
5944 http_space m_space;
5945 };
+
5946
+
5950 class http_agent : public parser
5951 {
5952 public:
5953 virtual bool match(
-
5954 _In_reads_or_z_(end) const char* text,
-
5955 _In_ size_t start = 0,
-
5956 _In_ size_t end = (size_t)-1,
-
5957 _In_ int flags = match_default)
+
5954 _In_reads_or_z_(end) const char* text,
+
5955 _In_ size_t start = 0,
+
5956 _In_ size_t end = (size_t)-1,
+
5957 _In_ int flags = match_default)
5958 {
-
5959 assert(text || start >= end);
+
5959 assert(text || start >= end);
5960 interval.end = start;
5961 type.start = interval.end;
5962 for (;;) {
-
5963 if (interval.end < end && text[interval.end]) {
-
5964 if (text[interval.end] == '/') {
+
5963 if (interval.end < end && text[interval.end]) {
+
5964 if (text[interval.end] == '/') {
5965 type.end = interval.end;
5966 interval.end++;
5967 version.start = interval.end;
5968 for (;;) {
-
5969 if (interval.end < end && text[interval.end]) {
-
5970 if (isspace(text[interval.end])) {
+
5969 if (interval.end < end && text[interval.end]) {
+
5970 if (isspace(text[interval.end])) {
5971 version.end = interval.end;
5972 break;
5973 }
@@ -5812,7 +5978,7 @@ $(function() {
5981 }
5982 break;
5983 }
-
5984 else if (isspace(text[interval.end])) {
+
5984 else if (isspace(text[interval.end])) {
5985 type.end = interval.end;
5986 break;
5987 }
@@ -5850,82 +6016,84 @@ $(function() {
6021 };
+
6022
+
6026 class http_protocol : public parser
6027 {
6028 public:
-
6029 http_protocol(_In_ const std::locale& locale = std::locale()) :
+
6029 http_protocol(_In_ const std::locale& locale = std::locale()) :
6030 parser(locale),
6031 version(0x009)
6032 {}
6033
6034 virtual bool match(
-
6035 _In_reads_or_z_(end) const char* text,
-
6036 _In_ size_t start = 0,
-
6037 _In_ size_t end = (size_t)-1,
-
6038 _In_ int flags = match_default)
+
6035 _In_reads_or_z_(end) const char* text,
+
6036 _In_ size_t start = 0,
+
6037 _In_ size_t end = (size_t)-1,
+
6038 _In_ int flags = match_default)
6039 {
-
6040 assert(text || start >= end);
+
6040 assert(text || start >= end);
6041 interval.end = start;
6042 type.start = interval.end;
6043 for (;;) {
-
6044 if (interval.end < end && text[interval.end]) {
-
6045 if (text[interval.end] == '/') {
+
6044 if (interval.end < end && text[interval.end]) {
+
6045 if (text[interval.end] == '/') {
6046 type.end = interval.end;
6047 interval.end++;
6048 break;
6049 }
-
6050 else if (isspace(text[interval.end]))
-
6051 goto error;
+
6050 else if (isspace(text[interval.end]))
+
6051 goto error;
6052 else
6053 interval.end++;
6054 }
6055 else {
6056 type.end = interval.end;
-
6057 goto error;
+
6057 goto error;
6058 }
6059 }
6060 version_maj.start = interval.end;
6061 for (;;) {
-
6062 if (interval.end < end && text[interval.end]) {
-
6063 if (text[interval.end] == '.') {
+
6062 if (interval.end < end && text[interval.end]) {
+
6063 if (text[interval.end] == '.') {
6064 version_maj.end = interval.end;
6065 interval.end++;
6066 version_min.start = interval.end;
6067 for (;;) {
-
6068 if (interval.end < end && text[interval.end]) {
-
6069 if (isspace(text[interval.end])) {
+
6068 if (interval.end < end && text[interval.end]) {
+
6069 if (isspace(text[interval.end])) {
6070 version_min.end = interval.end;
6071 version =
-
6072 (uint16_t)strtoui(text + version_maj.start, version_maj.size(), nullptr, 10) * 0x100 +
-
6073 (uint16_t)strtoui(text + version_min.start, version_min.size(), nullptr, 10);
+
6072 (uint16_t)strtoui(text + version_maj.start, version_maj.size(), nullptr, 10) * 0x100 +
+
6073 (uint16_t)strtoui(text + version_min.start, version_min.size(), nullptr, 10);
6074 break;
6075 }
6076 else
6077 interval.end++;
6078 }
6079 else
-
6080 goto error;
+
6080 goto error;
6081 }
6082 break;
6083 }
-
6084 else if (isspace(text[interval.end])) {
+
6084 else if (isspace(text[interval.end])) {
6085 version_maj.end = interval.end;
6086 version_min.start = 1;
6087 version_min.end = 0;
-
6088 version = (uint16_t)strtoui(text + version_maj.start, version_maj.size(), nullptr, 10) * 0x100;
+
6088 version = (uint16_t)strtoui(text + version_maj.start, version_maj.size(), nullptr, 10) * 0x100;
6089 break;
6090 }
6091 else
6092 interval.end++;
6093 }
6094 else
-
6095 goto error;
+
6095 goto error;
6096 }
6097 interval.start = start;
6098 return true;
6099
-
6100 error:
+
6100 error:
6101 type.start = 1;
6102 type.end = 0;
6103 version_maj.start = 1;
@@ -5954,45 +6122,47 @@ $(function() {
6127 stdex::interval<size_t> version_maj;
6128 stdex::interval<size_t> version_min;
-
6129 uint16_t version;
+
6130 };
+
6131
+
6135 class http_request : public parser
6136 {
6137 public:
-
6138 http_request(_In_ const std::locale& locale = std::locale()) :
+
6138 http_request(_In_ const std::locale& locale = std::locale()) :
6139 parser(locale),
-
6140 url(locale),
+
6140 url(locale),
6141 protocol(locale)
6142 {}
6143
6144 virtual bool match(
-
6145 _In_reads_or_z_(end) const char* text,
-
6146 _In_ size_t start = 0,
-
6147 _In_ size_t end = (size_t)-1,
-
6148 _In_ int flags = match_default)
+
6145 _In_reads_or_z_(end) const char* text,
+
6146 _In_ size_t start = 0,
+
6147 _In_ size_t end = (size_t)-1,
+
6148 _In_ int flags = match_default)
6149 {
-
6150 assert(text || start >= end);
+
6150 assert(text || start >= end);
6151 interval.end = start;
6152
6153 for (;;) {
-
6154 if (m_line_break.match(text, interval.end, end, flags))
-
6155 goto error;
-
6156 else if (interval.end < end && text[interval.end]) {
-
6157 if (isspace(text[interval.end]))
+
6154 if (m_line_break.match(text, interval.end, end, flags))
+
6155 goto error;
+
6156 else if (interval.end < end && text[interval.end]) {
+
6157 if (isspace(text[interval.end]))
6158 interval.end++;
6159 else
6160 break;
6161 }
6162 else
-
6163 goto error;
+
6163 goto error;
6164 }
6165 verb.start = interval.end;
6166 for (;;) {
-
6167 if (m_line_break.match(text, interval.end, end, flags))
-
6168 goto error;
-
6169 else if (interval.end < end && text[interval.end]) {
-
6170 if (isspace(text[interval.end])) {
+
6167 if (m_line_break.match(text, interval.end, end, flags))
+
6168 goto error;
+
6169 else if (interval.end < end && text[interval.end]) {
+
6170 if (isspace(text[interval.end])) {
6171 verb.end = interval.end;
6172 interval.end++;
6173 break;
@@ -6001,34 +6171,34 @@ $(function() {
6176 interval.end++;
6177 }
6178 else
-
6179 goto error;
+
6179 goto error;
6180 }
6181
6182 for (;;) {
-
6183 if (m_line_break.match(text, interval.end, end, flags))
-
6184 goto error;
-
6185 else if (interval.end < end && text[interval.end]) {
-
6186 if (isspace(text[interval.end]))
+
6183 if (m_line_break.match(text, interval.end, end, flags))
+
6184 goto error;
+
6185 else if (interval.end < end && text[interval.end]) {
+
6186 if (isspace(text[interval.end]))
6187 interval.end++;
6188 else
6189 break;
6190 }
6191 else
-
6192 goto error;
+
6192 goto error;
6193 }
-
6194 if (url.match(text, interval.end, end, flags))
- +
6194 if (url.match(text, interval.end, end, flags))
+
6196 else
-
6197 goto error;
+
6197 goto error;
6198
6199 protocol.invalidate();
6200 for (;;) {
-
6201 if (m_line_break.match(text, interval.end, end, flags)) {
+
6201 if (m_line_break.match(text, interval.end, end, flags)) {
6202 interval.end = m_line_break.interval.end;
6203 goto end;
6204 }
-
6205 else if (interval.end < end && text[interval.end]) {
-
6206 if (isspace(text[interval.end]))
+
6205 else if (interval.end < end && text[interval.end]) {
+
6206 if (isspace(text[interval.end]))
6207 interval.end++;
6208 else
6209 break;
@@ -6037,11 +6207,11 @@ $(function() {
6212 goto end;
6213 }
6214 for (;;) {
-
6215 if (m_line_break.match(text, interval.end, end, flags)) {
+
6215 if (m_line_break.match(text, interval.end, end, flags)) {
6216 interval.end = m_line_break.interval.end;
6217 goto end;
6218 }
-
6219 else if (protocol.match(text, interval.end, end, flags)) {
+
6219 else if (protocol.match(text, interval.end, end, flags)) {
6220 interval.end = protocol.interval.end;
6221 break;
6222 }
@@ -6050,11 +6220,11 @@ $(function() {
6225 }
6226
6227 for (;;) {
-
6228 if (m_line_break.match(text, interval.end, end, flags)) {
+
6228 if (m_line_break.match(text, interval.end, end, flags)) {
6229 interval.end = m_line_break.interval.end;
6230 break;
6231 }
-
6232 else if (interval.end < end && text[interval.end])
+
6232 else if (interval.end < end && text[interval.end])
6233 interval.end++;
6234 else
6235 goto end;
@@ -6064,10 +6234,10 @@ $(function() {
6239 interval.start = start;
6240 return true;
6241
-
6242 error:
+
6242 error:
6243 verb.start = 1;
6244 verb.end = 0;
-
6245 url.invalidate();
+
6245 url.invalidate();
6246 protocol.invalidate();
6247 interval.start = 1;
6248 interval.end = 0;
@@ -6078,64 +6248,66 @@ $(function() {
6253 {
6254 verb.start = 1;
6255 verb.end = 0;
-
6256 url.invalidate();
+
6256 url.invalidate();
6257 protocol.invalidate();
6258 parser::invalidate();
6259 }
6260
6261 public:
-
6263 http_url url;
+
6263 http_url url;
6264 http_protocol protocol;
6265
6266 protected:
6267 http_line_break m_line_break;
6268 };
+
6269
+
6273 class http_header : public parser
6274 {
6275 public:
6276 virtual bool match(
-
6277 _In_reads_or_z_(end) const char* text,
-
6278 _In_ size_t start = 0,
-
6279 _In_ size_t end = (size_t)-1,
-
6280 _In_ int flags = match_default)
+
6277 _In_reads_or_z_(end) const char* text,
+
6278 _In_ size_t start = 0,
+
6279 _In_ size_t end = (size_t)-1,
+
6280 _In_ int flags = match_default)
6281 {
-
6282 assert(text || start >= end);
+
6282 assert(text || start >= end);
6283 interval.end = start;
6284
-
6285 if (m_line_break.match(text, interval.end, end, flags) ||
-
6286 interval.end < end && text[interval.end] && isspace(text[interval.end]))
-
6287 goto error;
+
6285 if (m_line_break.match(text, interval.end, end, flags) ||
+ +
6287 goto error;
6288 name.start = interval.end;
6289 for (;;) {
-
6290 if (m_line_break.match(text, interval.end, end, flags))
-
6291 goto error;
-
6292 else if (interval.end < end && text[interval.end]) {
-
6293 if (isspace(text[interval.end])) {
+
6290 if (m_line_break.match(text, interval.end, end, flags))
+
6291 goto error;
+
6292 else if (interval.end < end && text[interval.end]) {
+
6293 if (isspace(text[interval.end])) {
6294 name.end = interval.end;
6295 interval.end++;
6296 for (;;) {
-
6297 if (m_line_break.match(text, interval.end, end, flags))
-
6298 goto error;
-
6299 else if (interval.end < end && text[interval.end]) {
-
6300 if (isspace(text[interval.end]))
+
6297 if (m_line_break.match(text, interval.end, end, flags))
+
6298 goto error;
+
6299 else if (interval.end < end && text[interval.end]) {
+
6300 if (isspace(text[interval.end]))
6301 interval.end++;
6302 else
6303 break;
6304 }
6305 else
-
6306 goto error;
+
6306 goto error;
6307 }
-
6308 if (interval.end < end && text[interval.end] == ':') {
+
6308 if (interval.end < end && text[interval.end] == ':') {
6309 interval.end++;
6310 break;
6311 }
6312 else
-
6313 goto error;
+
6313 goto error;
6314 break;
6315 }
-
6316 else if (text[interval.end] == ':') {
+
6316 else if (text[interval.end] == ':') {
6317 name.end = interval.end;
6318 interval.end++;
6319 break;
@@ -6144,21 +6316,21 @@ $(function() {
6322 interval.end++;
6323 }
6324 else
-
6325 goto error;
+
6325 goto error;
6326 }
-
6327 value.start = (size_t)-1;
+
6327 value.start = (size_t)-1;
6328 value.end = 0;
6329 for (;;) {
-
6330 if (m_line_break.match(text, interval.end, end, flags)) {
+
6330 if (m_line_break.match(text, interval.end, end, flags)) {
6331 interval.end = m_line_break.interval.end;
-
6332 if (!m_line_break.match(text, interval.end, end, flags) &&
-
6333 interval.end < end && text[interval.end] && isspace(text[interval.end]))
+
6332 if (!m_line_break.match(text, interval.end, end, flags) &&
+
6334 interval.end++;
6335 else
6336 break;
6337 }
-
6338 else if (interval.end < end && text[interval.end]) {
-
6339 if (isspace(text[interval.end]))
+
6338 else if (interval.end < end && text[interval.end]) {
+
6339 if (isspace(text[interval.end]))
6340 interval.end++;
6341 else {
6342 if (value.start == (size_t)-1) value.start = interval.end;
@@ -6171,7 +6343,7 @@ $(function() {
6349 interval.start = start;
6350 return true;
6351
-
6352 error:
+
6352 error:
6353 name.start = 1;
6354 name.end = 0;
6355 value.start = 1;
@@ -6197,128 +6369,134 @@ $(function() {
6375 protected:
6376 http_line_break m_line_break;
6377 };
+
6378
6382 template <class T>
+
6383 class http_value_collection : public T
6384 {
6385 public:
6386 void insert(
-
6387 _In_reads_or_z_(end) const char* text,
-
6388 _In_ size_t start = 0,
-
6389 _In_ size_t end = (size_t)-1,
-
6390 _In_ int flags = match_default)
+
6387 _In_reads_or_z_(end) const char* text,
+
6388 _In_ size_t start = 0,
+
6389 _In_ size_t end = (size_t)-1,
+
6390 _In_ int flags = match_default)
6391 {
6392 while (start < end) {
-
6393 while (start < end && text[start] && isspace(text[start])) start++;
-
6394 if (start < end && text[start] == ',') {
+
6393 while (start < end && text[start] && isspace(text[start])) start++;
+
6394 if (start < end && text[start] == ',') {
6395 start++;
-
6396 while (start < end&& text[start] && isspace(text[start])) start++;
+
6396 while (start < end&& text[start] && isspace(text[start])) start++;
6397 }
-
6398 T::key_type el;
-
6399 if (el.match(text, start, end, flags)) {
-
6400 start = el.interval.end;
-
6401 T::insert(std::move(el));
+
6398 T::key_type el;
+
6399 if (el.match(text, start, end, flags)) {
+
6400 start = el.interval.end;
+
6401 T::insert(std::move(el));
6402 }
6403 else
6404 break;
6405 }
6406 }
6407 };
+
6408
6409 template <class T>
+
-
6411 constexpr bool operator()(const T& a, const T& b) const noexcept
+
6411 constexpr bool operator()(const T& a, const T& b) const noexcept
6412 {
-
6413 return a.factor.value > b.factor.value;
+
6413 return a.factor.value > b.factor.value;
6414 }
6415 };
+
6416
6420 template <class T, class _Alloc = std::allocator<T>>
-
6421 using http_weighted_collection = http_value_collection<std::multiset<T, http_factor_more<T>, _Alloc>>;
+
6421 using http_weighted_collection = http_value_collection<std::multiset<T, http_factor_more<T>, _Alloc>>;
6422
6426 template <class T>
+
6428 {
6429 public:
-
6431 _In_ const std::shared_ptr<basic_parser<T>>& quote,
-
6432 _In_ const std::shared_ptr<basic_parser<T>>& chr,
-
6433 _In_ const std::shared_ptr<basic_parser<T>>& escape,
-
6434 _In_ const std::shared_ptr<basic_parser<T>>& sol,
-
6435 _In_ const std::shared_ptr<basic_parser<T>>& bs,
-
6436 _In_ const std::shared_ptr<basic_parser<T>>& ff,
-
6437 _In_ const std::shared_ptr<basic_parser<T>>& lf,
-
6438 _In_ const std::shared_ptr<basic_parser<T>>& cr,
-
6439 _In_ const std::shared_ptr<basic_parser<T>>& htab,
-
6440 _In_ const std::shared_ptr<basic_parser<T>>& uni,
-
6441 _In_ const std::shared_ptr<basic_integer16<T>>& hex,
-
6442 _In_ const std::locale& locale = std::locale()) :
-
6443 basic_parser<T>(locale),
-
6444 m_quote(quote),
-
6445 m_chr(chr),
-
6446 m_escape(escape),
-
6447 m_sol(sol),
-
6448 m_bs(bs),
-
6449 m_ff(ff),
-
6450 m_lf(lf),
-
6451 m_cr(cr),
-
6452 m_htab(htab),
-
6453 m_uni(uni),
-
6454 m_hex(hex)
+
6431 _In_ const std::shared_ptr<basic_parser<T>>& quote,
+
6432 _In_ const std::shared_ptr<basic_parser<T>>& chr,
+
6433 _In_ const std::shared_ptr<basic_parser<T>>& escape,
+
6434 _In_ const std::shared_ptr<basic_parser<T>>& sol,
+
6435 _In_ const std::shared_ptr<basic_parser<T>>& bs,
+
6436 _In_ const std::shared_ptr<basic_parser<T>>& ff,
+
6437 _In_ const std::shared_ptr<basic_parser<T>>& lf,
+
6438 _In_ const std::shared_ptr<basic_parser<T>>& cr,
+
6439 _In_ const std::shared_ptr<basic_parser<T>>& htab,
+
6440 _In_ const std::shared_ptr<basic_parser<T>>& uni,
+
6441 _In_ const std::shared_ptr<basic_integer16<T>>& hex,
+
6442 _In_ const std::locale& locale = std::locale()) :
+
6443 basic_parser<T>(locale),
+
6444 m_quote(quote),
+
6445 m_chr(chr),
+
6446 m_escape(escape),
+
6447 m_sol(sol),
+
6448 m_bs(bs),
+
6449 m_ff(ff),
+
6450 m_lf(lf),
+
6451 m_cr(cr),
+
6452 m_htab(htab),
+
6453 m_uni(uni),
+
6454 m_hex(hex)
6455 {}
6456
6457 virtual bool match(
-
6458 _In_reads_or_z_(end) const T* text,
-
6459 _In_ size_t start = 0,
-
6460 _In_ size_t end = (size_t)-1,
-
6461 _In_ int flags = match_default)
+
6458 _In_reads_or_z_(end) const T* text,
+
6459 _In_ size_t start = 0,
+
6460 _In_ size_t end = (size_t)-1,
+
6461 _In_ int flags = match_default)
6462 {
-
6463 assert(text || start >= end);
+
6463 assert(text || start >= end);
6464 interval.end = start;
-
6465 if (m_quote->match(text, interval.end, end, flags)) {
+
6465 if (m_quote->match(text, interval.end, end, flags)) {
6466 interval.end = m_quote->interval.end;
6467 value.clear();
6468 for (;;) {
-
6469 if (m_quote->match(text, interval.end, end, flags)) {
+
6469 if (m_quote->match(text, interval.end, end, flags)) {
6470 interval.start = start;
6471 interval.end = m_quote->interval.end;
6472 return true;
6473 }
-
6474 if (m_escape->match(text, interval.end, end, flags)) {
-
6475 if (m_quote->match(text, m_escape->interval.end, end, flags)) {
+
6474 if (m_escape->match(text, interval.end, end, flags)) {
+
6475 if (m_quote->match(text, m_escape->interval.end, end, flags)) {
6476 value += '"'; interval.end = m_quote->interval.end;
6477 continue;
6478 }
-
6479 if (m_sol->match(text, m_escape->interval.end, end, flags)) {
+
6479 if (m_sol->match(text, m_escape->interval.end, end, flags)) {
6480 value += '/'; interval.end = m_sol->interval.end;
6481 continue;
6482 }
-
6483 if (m_bs->match(text, m_escape->interval.end, end, flags)) {
+
6483 if (m_bs->match(text, m_escape->interval.end, end, flags)) {
6484 value += '\b'; interval.end = m_bs->interval.end;
6485 continue;
6486 }
-
6487 if (m_ff->match(text, m_escape->interval.end, end, flags)) {
+
6487 if (m_ff->match(text, m_escape->interval.end, end, flags)) {
6488 value += '\f'; interval.end = m_ff->interval.end;
6489 continue;
6490 }
-
6491 if (m_lf->match(text, m_escape->interval.end, end, flags)) {
+
6491 if (m_lf->match(text, m_escape->interval.end, end, flags)) {
6492 value += '\n'; interval.end = m_lf->interval.end;
6493 continue;
6494 }
-
6495 if (m_cr->match(text, m_escape->interval.end, end, flags)) {
+
6495 if (m_cr->match(text, m_escape->interval.end, end, flags)) {
6496 value += '\r'; interval.end = m_cr->interval.end;
6497 continue;
6498 }
-
6499 if (m_htab->match(text, m_escape->interval.end, end, flags)) {
+
6499 if (m_htab->match(text, m_escape->interval.end, end, flags)) {
6500 value += '\t'; interval.end = m_htab->interval.end;
6501 continue;
6502 }
6503 if (
-
6504 m_uni->match(text, m_escape->interval.end, end, flags) &&
-
6505 m_hex->match(text, m_uni->interval.end, std::min(m_uni->interval.end + 4, end), flags | match_case_insensitive) &&
+
6504 m_uni->match(text, m_escape->interval.end, end, flags) &&
+
6505 m_hex->match(text, m_uni->interval.end, std::min(m_uni->interval.end + 4, end), flags | match_case_insensitive) &&
6506 m_hex->interval.size() == 4 /* JSON requests 4-digit Unicode sequneces: \u.... */)
6507 {
-
6508 assert(m_hex->value <= 0xffff);
+
6508 assert(m_hex->value <= 0xffff);
6509 if (sizeof(T) == 1) {
6510 if (m_hex->value > 0x7ff) {
6511 value += (T)(0xe0 | (m_hex->value >> 12) & 0x0f);
@@ -6337,13 +6515,13 @@ $(function() {
6524 interval.end = m_hex->interval.end;
6525 continue;
6526 }
-
6527 if (m_escape->match(text, m_escape->interval.end, end, flags)) {
+
6527 if (m_escape->match(text, m_escape->interval.end, end, flags)) {
6528 value += '\\'; interval.end = m_escape->interval.end;
6529 continue;
6530 }
6531 }
-
6532 if (m_chr->match(text, interval.end, end, flags)) {
-
6533 value.Prilepi(text + m_chr->interval.start, m_chr->interval.size());
+
6532 if (m_chr->match(text, interval.end, end, flags)) {
+
6533 value.Prilepi(text + m_chr->interval.start, m_chr->interval.size());
6534 interval.end = m_chr->interval.end;
6535 continue;
6536 }
@@ -6377,13 +6555,14 @@ $(function() {
6564 std::shared_ptr<basic_parser<T>> m_uni;
6565 std::shared_ptr<basic_integer16<T>> m_hex;
6566 };
+
6567
-
6568 using json_string = basic_json_string<char>;
-
6569 using wjson_string = basic_json_string<wchar_t>;
+
6568 using json_string = basic_json_string<char>;
+
6569 using wjson_string = basic_json_string<wchar_t>;
6570#ifdef _UNICODE
-
6571 using tjson_string = wjson_string;
+
6571 using tjson_string = wjson_string;
6572#else
-
6573 using tjson_string = json_string;
+
6573 using tjson_string = json_string;
6574#endif
6575 }
6576}
@@ -6548,7 +6727,7 @@ $(function() { diff --git a/pch_8h_source.html b/pch_8h_source.html index 16290914e..7f9f4ba1a 100644 --- a/pch_8h_source.html +++ b/pch_8h_source.html @@ -3,7 +3,7 @@ - + stdex: UnitTests/pch.h Source File @@ -30,7 +30,7 @@ - + +
diff --git a/plus.svg b/plus.svg new file mode 100644 index 000000000..075201655 --- /dev/null +++ b/plus.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/plusd.svg b/plusd.svg new file mode 100644 index 000000000..0c65bfe94 --- /dev/null +++ b/plusd.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/progress_8hpp_source.html b/progress_8hpp_source.html index b8aabeca5..7b4252c3c 100644 --- a/progress_8hpp_source.html +++ b/progress_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/progress.hpp Source File @@ -30,7 +30,7 @@ - + +
12namespace stdex
13{
17 template <class T>
+
19 {
20 public:
+
26 virtual void set_text(_In_z_ const char* msg)
27 {
28 msg;
29 }
+
30
+
37 virtual void set_range(_In_ T start, _In_ T end)
38 {
39 start; end;
40 }
+
41
+
47 virtual void set(_In_ T value)
48 {
49 value;
50 }
+
51
+
57 virtual void show(_In_ bool show = true)
58 {
59 show;
60 }
+
61
+
65 virtual bool cancel()
66 {
67 return false;
68 }
+
69 };
+
70
76 template <class T>
+
77 class lazy_progress : public progress<T>
78 {
79 public:
+
85 lazy_progress(_In_ const std::chrono::nanoseconds& timeout = std::chrono::nanoseconds(500000)) :
86 m_timeout(timeout),
87 m_start(0),
88 m_end(0),
89 m_value(-1)
90 {}
+
91
+
98 virtual void set_range(_In_ T start, _In_ T end)
99 {
100 m_start = start;
101 m_end = end;
102 }
+
103
+
109 virtual void set(_In_ T value)
110 {
111 if (value == m_start || value == m_end)
@@ -152,6 +175,7 @@ $(function() {
121 m_value = value;
122 do_set();
123 }
+
124
125 protected:
129 virtual void do_set() {}
@@ -161,26 +185,35 @@ $(function() {
133 std::chrono::steady_clock::time_point m_last;
134 T m_start, m_end, m_value;
135 };
+
136
142 template <class T>
+
143 class global_progress : public progress<T>
144 {
145 public:
+
151 global_progress(_In_opt_ progress<T>* host = NULL) : m_host(host)
152 {}
+
153
+
159 inline void attach(_In_opt_ progress<T>* host)
160 {
161 m_host = host;
162 }
+
163
+
170 {
171 progress* k = m_host;
172 m_host = NULL;
173 return k;
174 }
+
175
+
182 inline void set_global_range(_In_ T start, _In_ T end)
183 {
184 m_global.start = start;
@@ -188,25 +221,33 @@ $(function() {
186 if (m_host)
187 m_host->set_range(m_global.start, m_global.end);
188 }
+
189
+
196 inline void set_section_range(_In_ T start, _In_ T end)
197 {
198 m_section.start = start;
199 m_section.end = end;
200 }
+
201
+
207 virtual void set_text(_In_ const char* msg)
208 {
209 if (m_host)
210 m_host->set_text(msg);
211 }
+
212
+
219 virtual void set_range(_In_ T start, _In_ T end)
220 {
221 m_local.start = start;
222 m_local.end = end;
223 }
+
224
+
230 virtual void set(_In_ T value)
231 {
232 if (m_host) {
@@ -217,25 +258,32 @@ $(function() {
237 }
238 }
239 }
+
240
+
246 virtual void show(_In_ bool show = true)
247 {
248 if (m_host)
249 m_host->show(show);
250 }
+
251
+
255 virtual bool cancel()
256 {
257 return m_host && m_host->cancel();
258 }
+
259
260 protected:
261 progress* m_host;
262 interval<T> m_local, m_global, m_section;
263 };
+
264
270
271 template <class T>
+
273 {
274 public:
@@ -254,6 +302,7 @@ $(function() {
287 protected:
288 progress<T>*& m_host_ref;
289 };
+
290}
Global progress indicator base class.
Definition progress.hpp:144
global_progress(progress< T > *host=NULL)
Constructs a progress indicator.
Definition progress.hpp:151
@@ -282,7 +331,7 @@ $(function() { diff --git a/ring_8hpp_source.html b/ring_8hpp_source.html index 958a9a1d4..367b0d088 100644 --- a/ring_8hpp_source.html +++ b/ring_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/ring.hpp Source File @@ -30,7 +30,7 @@ - + +
14namespace stdex
15{
22 template <class T, size_t CAPACITY>
+
23 class ring
24 {
25 public:
@@ -103,6 +109,7 @@ $(function() {
30 m_quit(false)
31 {}
32
+
38 std::tuple<T*, size_t> back()
39 {
40 std::unique_lock<std::mutex> lk(m_mutex);
@@ -114,7 +121,9 @@ $(function() {
46 size_t tail = wrap(m_head + m_size);
47 return { &m_data[tail], m_head <= tail ? CAPACITY - tail : m_head - tail };
48 }
+
49
+
55 void push(_In_ size_t size)
56 {
57 {
@@ -127,7 +136,9 @@ $(function() {
64 }
65 m_tail_moved.notify_one();
66 }
+
67
+
73 std::tuple<T*, size_t> front()
74 {
75 std::unique_lock<std::mutex> lk(m_mutex);
@@ -139,7 +150,9 @@ $(function() {
81 size_t tail = wrap(m_head + m_size);
82 return { &m_data[m_head], m_head < tail ? m_size : CAPACITY - m_head };
83 }
+
84
+
90 void pop(_In_ size_t size)
91 {
92 {
@@ -153,7 +166,9 @@ $(function() {
100 }
101 m_head_moved.notify_one();
102 }
+
103
+
107 void quit()
108 {
109 {
@@ -163,12 +178,15 @@ $(function() {
113 m_head_moved.notify_one();
114 m_tail_moved.notify_one();
115 }
+
116
+
120 void sync()
121 {
122 std::unique_lock<std::mutex> lk(m_mutex);
123 m_head_moved.wait(lk, [&]{return m_quit || empty();});
124 }
+
125
126 protected:
127 inline size_t wrap(_In_ size_t idx) const
@@ -194,6 +212,7 @@ $(function() {
147 bool m_quit;
148 T m_data[CAPACITY];
149 };
+
150}
Ring buffer.
Definition ring.hpp:24
void quit()
Cancells waiting sender and receiver.
Definition ring.hpp:107
@@ -205,7 +224,7 @@ $(function() { diff --git a/sal_8hpp_source.html b/sal_8hpp_source.html index 1ebb7fd83..0fcfe6cd3 100644 --- a/sal_8hpp_source.html +++ b/sal_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/sal.hpp Source File @@ -30,7 +30,7 @@ - + +
diff --git a/search/all_1.js b/search/all_1.js index 1e0144429..3e6b88209 100644 --- a/search/all_1.js +++ b/search/all_1.js @@ -2,7 +2,7 @@ var searchData= [ ['back_0',['back',['../classstdex_1_1ring.html#a3e41365e5bcb914099baff6b02686bca',1,'stdex::ring::back()'],['../classstdex_1_1vector__queue.html#a564c31d1a260f9f210541b7fd4803d3e',1,'stdex::vector_queue::back()'],['../classstdex_1_1vector__queue.html#a4a76efc22a2e2b9310b541ba44fd05e9',1,'stdex::vector_queue::back() const']]], ['base64_5fdec_1',['base64_dec',['../classstdex_1_1base64__dec.html#a17d956a883e99d8d884d2cb2edade8c5',1,'stdex::base64_dec::base64_dec()'],['../classstdex_1_1base64__dec.html',1,'stdex::base64_dec']]], - ['base64_5fenc_2',['base64_enc',['../classstdex_1_1base64__enc.html#abc6c72530634c3fea8168710ab5b1a28',1,'stdex::base64_enc::base64_enc()'],['../classstdex_1_1base64__enc.html',1,'stdex::base64_enc']]], + ['base64_5fenc_2',['base64_enc',['../classstdex_1_1base64__enc.html',1,'stdex::base64_enc'],['../classstdex_1_1base64__enc.html#abc6c72530634c3fea8168710ab5b1a28',1,'stdex::base64_enc::base64_enc()']]], ['basic_3',['basic',['../classstdex_1_1stream_1_1basic.html',1,'stdex::stream']]], ['basic_5fangle_4',['basic_angle',['../classstdex_1_1parser_1_1basic__angle.html',1,'stdex::parser']]], ['basic_5fany_5fcu_5',['basic_any_cu',['../classstdex_1_1parser_1_1basic__any__cu.html',1,'stdex::parser']]], diff --git a/search/all_10.js b/search/all_10.js index e3e137797..79934f81f 100644 --- a/search/all_10.js +++ b/search/all_10.js @@ -1,6 +1,6 @@ var searchData= [ - ['save_0',['save',['../classstdex_1_1stream_1_1memory__file.html#aef50ff3c88577d89d83ee625cc5d1bfd',1,'stdex::stream::memory_file']]], + ['save_0',['save',['../classstdex_1_1stream_1_1memory__file.html#a96210fbbca48af7097ddad7cc9bf6cb5',1,'stdex::stream::memory_file']]], ['scope_5fid_1',['scope_id',['../classstdex_1_1parser_1_1basic__ipv6__address.html#a67486e83888f48afc62b031f745012c0',1,'stdex::parser::basic_ipv6_address']]], ['seek_2',['seek',['../classstdex_1_1stream_1_1diag__file.html#a9f616580a2547b37beccd7d114ed06d0',1,'stdex::stream::diag_file::seek()'],['../classstdex_1_1stream_1_1memory__file.html#a9e67e40e9e3c0f7b002fcdab5220b4e7',1,'stdex::stream::memory_file::seek()'],['../classstdex_1_1stream_1_1file.html#acdfc1dc079ebeaeb05312e03925485ff',1,'stdex::stream::file::seek()'],['../classstdex_1_1stream_1_1cache.html#af2979118bdeca35cbfd84a8a2be00f8a',1,'stdex::stream::cache::seek()'],['../classstdex_1_1stream_1_1file__window.html#a53a12a1979b770030c0de05b349f1e55',1,'stdex::stream::file_window::seek()'],['../classstdex_1_1stream_1_1basic__file.html#afcaac612398bd7d02d8d146dcad74465',1,'stdex::stream::basic_file::seek(foff_t offset, seek_t how=seek_t::beg)=0']]], ['seekbeg_3',['seekbeg',['../classstdex_1_1stream_1_1basic__file.html#a6a8da9a1b0a3926b9bc453bf0209ee5e',1,'stdex::stream::basic_file']]], diff --git a/search/all_2.js b/search/all_2.js index 7d283cd10..dac55a75d 100644 --- a/search/all_2.js +++ b/search/all_2.js @@ -2,7 +2,7 @@ var searchData= [ ['cache_0',['cache',['../classstdex_1_1stream_1_1cache.html',1,'stdex::stream']]], ['cache_5ft_1',['cache_t',['../structstdex_1_1stream_1_1cache_1_1cache__t.html',1,'stdex::stream::cache']]], - ['cached_5ffile_2',['cached_file',['../classstdex_1_1stream_1_1cached__file.html#aace5ebb17927a869e6e923b592d8b3da',1,'stdex::stream::cached_file::cached_file()'],['../classstdex_1_1stream_1_1cached__file.html',1,'stdex::stream::cached_file']]], + ['cached_5ffile_2',['cached_file',['../classstdex_1_1stream_1_1cached__file.html',1,'stdex::stream::cached_file'],['../classstdex_1_1stream_1_1cached__file.html#aa53149a79b463450f64223f45285dc02',1,'stdex::stream::cached_file::cached_file()']]], ['cancel_3',['cancel',['../classstdex_1_1progress.html#a03380c822297092b3bb9867deee26202',1,'stdex::progress::cancel()'],['../classstdex_1_1global__progress.html#a74a5ea9089ff7b7015ea4a2071f3113e',1,'stdex::global_progress::cancel()']]], ['capacity_4',['capacity',['../classstdex_1_1vector__queue.html#add3d6ed93d3c1471b80351c56639bab7',1,'stdex::vector_queue']]], ['clear_5',['clear',['../classstdex_1_1base64__enc.html#afb6a85176589d9ce1f65ce6355592fe7',1,'stdex::base64_enc::clear()'],['../classstdex_1_1base64__dec.html#a94738b63789489022e0c16063b732305',1,'stdex::base64_dec::clear()'],['../classstdex_1_1hex__dec.html#a282bf5db0d16b29b12c71b73d3a33cc4',1,'stdex::hex_dec::clear()'],['../classstdex_1_1vector__queue.html#a93259be5f471580d2f8d7bee41032f9b',1,'stdex::vector_queue::clear()']]], diff --git a/search/all_4.js b/search/all_4.js index ac5df4c4e..3448fb3a2 100644 --- a/search/all_4.js +++ b/search/all_4.js @@ -5,7 +5,7 @@ var searchData= ['enc_5fsize_2',['enc_size',['../classstdex_1_1base64__enc.html#afbae8f49a0948ea7bb23d0faa8f67f21',1,'stdex::base64_enc::enc_size()'],['../classstdex_1_1hex__enc.html#a47db116dcc51daa878d3ecc4c1ab4d8f',1,'stdex::hex_enc::enc_size(size_t size) const noexcept']]], ['encode_3',['encode',['../classstdex_1_1hex__enc.html#a51554940e79b6192f10a7860ca407191',1,'stdex::hex_enc::encode()'],['../classstdex_1_1base64__enc.html#a709172f7120284fcea1d7856d8ff550d',1,'stdex::base64_enc::encode(std::basic_string< _Elem, _Traits, _Ax > &out, size_t size)'],['../classstdex_1_1base64__enc.html#a506985ccd54fd95dbc021457881d77c2',1,'stdex::base64_enc::encode(std::basic_string< _Elem, _Traits, _Ax > &out)'],['../classstdex_1_1base64__enc.html#a0ee96b5ec63fecc20c44afe1f1df6f04',1,'stdex::base64_enc::encode(std::basic_string< _Elem, _Traits, _Ax > &out, const void *data, size_t size, bool is_last=true)']]], ['end_4',['end',['../structstdex_1_1interval.html#a9b92e2b20290d8ac5a9b00209f25e27a',1,'stdex::interval']]], - ['errno_5ferror_5',['errno_error',['../classstdex_1_1errno__error.html#a3dc5e2df06c563a88b3f8766b5e689fc',1,'stdex::errno_error::errno_error(errno_t num, const std::string &msg)'],['../classstdex_1_1errno__error.html#aecd4c5513593dc5270086aee1e192fb2',1,'stdex::errno_error::errno_error(errno_t num, const char *msg=nullptr)'],['../classstdex_1_1errno__error.html#adca7aeb224bac759d355881bf640a2a4',1,'stdex::errno_error::errno_error(const std::string &msg)'],['../classstdex_1_1errno__error.html#add900d5748b938a3a9a123dfd618cbcc',1,'stdex::errno_error::errno_error(const char *msg=nullptr)'],['../classstdex_1_1errno__error.html',1,'stdex::errno_error']]], + ['errno_5ferror_5',['errno_error',['../classstdex_1_1errno__error.html',1,'stdex::errno_error'],['../classstdex_1_1errno__error.html#a3dc5e2df06c563a88b3f8766b5e689fc',1,'stdex::errno_error::errno_error(errno_t num, const std::string &msg)'],['../classstdex_1_1errno__error.html#aecd4c5513593dc5270086aee1e192fb2',1,'stdex::errno_error::errno_error(errno_t num, const char *msg=nullptr)'],['../classstdex_1_1errno__error.html#adca7aeb224bac759d355881bf640a2a4',1,'stdex::errno_error::errno_error(const std::string &msg)'],['../classstdex_1_1errno__error.html#add900d5748b938a3a9a123dfd618cbcc',1,'stdex::errno_error::errno_error(const char *msg=nullptr)']]], ['exponent_6',['exponent',['../classstdex_1_1parser_1_1basic__scientific__numeral.html#ac3b886b3334d64811d82d1d47fbafe66',1,'stdex::parser::basic_scientific_numeral']]], ['exponent_5fsymbol_7',['exponent_symbol',['../classstdex_1_1parser_1_1basic__scientific__numeral.html#a66134e1cb72bdfb75f2ac634fee02ee3',1,'stdex::parser::basic_scientific_numeral']]], ['eyes_8',['eyes',['../classstdex_1_1parser_1_1basic__emoticon.html#a2700be6652350445e571cf95940fd32a',1,'stdex::parser::basic_emoticon']]] diff --git a/search/all_5.js b/search/all_5.js index 977a94a4d..5d5fc1000 100644 --- a/search/all_5.js +++ b/search/all_5.js @@ -1,7 +1,7 @@ var searchData= [ ['fifo_0',['fifo',['../classstdex_1_1stream_1_1fifo.html',1,'stdex::stream']]], - ['file_1',['file',['../classstdex_1_1stream_1_1file.html#a3324c7a122b9debf2fde7f4e4f340683',1,'stdex::stream::file::file()'],['../classstdex_1_1stream_1_1file.html',1,'stdex::stream::file']]], + ['file_1',['file',['../classstdex_1_1stream_1_1file.html',1,'stdex::stream::file'],['../classstdex_1_1stream_1_1file.html#a31e46e58ec40db989b36c3553b09084f',1,'stdex::stream::file::file()']]], ['file_5fwindow_2',['file_window',['../classstdex_1_1stream_1_1file__window.html',1,'stdex::stream']]], ['find_3',['find',['../classstdex_1_1idrec_1_1record.html#a19523040d07119055884a7a2f8ef25fd',1,'stdex::idrec::record']]], ['flush_4',['flush',['../classstdex_1_1stream_1_1basic__sys.html#a6eae9769feea69fa9ce8b127ca2f7891',1,'stdex::stream::basic_sys::flush()'],['../classstdex_1_1stream_1_1diag__file.html#aadb3e9de2c84e317bf454ae764d8fcdf',1,'stdex::stream::diag_file::flush()'],['../classstdex_1_1stream_1_1cache.html#ac33e763d8103ad8e910b75085a4cf3ac',1,'stdex::stream::cache::flush()'],['../classstdex_1_1stream_1_1file__window.html#a2a2b88934b073b456da579ca3e3b43ff',1,'stdex::stream::file_window::flush()'],['../classstdex_1_1stream_1_1buffer.html#a18f9edc9af41f3a71d84f7eb4e7d5332',1,'stdex::stream::buffer::flush()'],['../classstdex_1_1stream_1_1async__writer.html#a25c72d3b2edaba300eb158d06dfd03d2',1,'stdex::stream::async_writer::flush()'],['../classstdex_1_1stream_1_1replicator.html#a77d2ddda29ef5dfb835453ff1dd90f2e',1,'stdex::stream::replicator::flush()'],['../classstdex_1_1stream_1_1converter.html#a0d6af4c223625bc8ab677978b225d06e',1,'stdex::stream::converter::flush()'],['../classstdex_1_1stream_1_1basic.html#a46c70519f3e4b1f3436e85a6623555dc',1,'stdex::stream::basic::flush()']]], diff --git a/search/all_6.js b/search/all_6.js index 34ccbb274..f94c886df 100644 --- a/search/all_6.js +++ b/search/all_6.js @@ -1,5 +1,5 @@ var searchData= [ ['get_0',['get',['../classstdex_1_1stream_1_1memory__file.html#a41124fc38a3439c4407ea1c9ef4962b1',1,'stdex::stream::memory_file::get()'],['../classstdex_1_1sys__object.html#a68edd83d50aee1dd85645aa0506c8769',1,'stdex::sys_object::get()']]], - ['global_5fprogress_1',['global_progress',['../classstdex_1_1global__progress.html#a0ffa6fafa04588c0df06d077ae51d037',1,'stdex::global_progress::global_progress()'],['../classstdex_1_1global__progress.html',1,'stdex::global_progress< T >']]] + ['global_5fprogress_1',['global_progress',['../classstdex_1_1global__progress.html',1,'stdex::global_progress< T >'],['../classstdex_1_1global__progress.html#a0ffa6fafa04588c0df06d077ae51d037',1,'stdex::global_progress::global_progress()']]] ]; diff --git a/search/all_7.js b/search/all_7.js index 088bbf909..2b7a68819 100644 --- a/search/all_7.js +++ b/search/all_7.js @@ -2,8 +2,8 @@ var searchData= [ ['has_5fseparators_0',['has_separators',['../classstdex_1_1parser_1_1basic__integer10ts.html#a2ac33bec062d1f6b21d033831a8742a9',1,'stdex::parser::basic_integer10ts']]], ['head_1',['head',['../classstdex_1_1vector__queue.html#a5d1e9d77cf329abd9127d2a6dfbd08c4',1,'stdex::vector_queue']]], - ['hex_5fdec_2',['hex_dec',['../classstdex_1_1hex__dec.html#a61bd84f6b79b2b8e9daebfafeb2f17ad',1,'stdex::hex_dec::hex_dec()'],['../classstdex_1_1hex__dec.html',1,'stdex::hex_dec']]], - ['hex_5fenc_3',['hex_enc',['../classstdex_1_1hex__enc.html#a882581bc4798b138de9322d1b0bdd433',1,'stdex::hex_enc::hex_enc()'],['../classstdex_1_1hex__enc.html',1,'stdex::hex_enc']]], + ['hex_5fdec_2',['hex_dec',['../classstdex_1_1hex__dec.html',1,'stdex::hex_dec'],['../classstdex_1_1hex__dec.html#a61bd84f6b79b2b8e9daebfafeb2f17ad',1,'stdex::hex_dec::hex_dec()']]], + ['hex_5fenc_3',['hex_enc',['../classstdex_1_1hex__enc.html',1,'stdex::hex_enc'],['../classstdex_1_1hex__enc.html#a882581bc4798b138de9322d1b0bdd433',1,'stdex::hex_enc::hex_enc()']]], ['http_5fagent_4',['http_agent',['../classstdex_1_1parser_1_1http__agent.html',1,'stdex::parser']]], ['http_5fany_5ftype_5',['http_any_type',['../classstdex_1_1parser_1_1http__any__type.html',1,'stdex::parser']]], ['http_5fasterisk_6',['http_asterisk',['../classstdex_1_1parser_1_1http__asterisk.html',1,'stdex::parser']]], diff --git a/search/all_8.js b/search/all_8.js index 97e8cd037..89e7d722d 100644 --- a/search/all_8.js +++ b/search/all_8.js @@ -2,7 +2,7 @@ var searchData= [ ['id_0',['id',['../classstdex_1_1idrec_1_1record.html#a24e54541a476b01e332290c57a495926',1,'stdex::idrec::record']]], ['integer_1',['integer',['../classstdex_1_1parser_1_1basic__mixed__numeral.html#af42e711d277a70c9624864e5f74a0bfd',1,'stdex::parser::basic_mixed_numeral::integer'],['../classstdex_1_1parser_1_1basic__scientific__numeral.html#aff899e847d2b78df90ab367ef824505a',1,'stdex::parser::basic_scientific_numeral::integer'],['../classstdex_1_1parser_1_1basic__monetary__numeral.html#acdbf4ca7d154c8723e8c318000853cce',1,'stdex::parser::basic_monetary_numeral::integer']]], - ['interval_2',['interval',['../classstdex_1_1parser_1_1basic__parser.html#a0b46b1904e5af116c34a10087a5bc056',1,'stdex::parser::basic_parser::interval'],['../structstdex_1_1interval.html#a9f6c66e8a3fd15c693011216bb45d6b9',1,'stdex::interval::interval() noexcept'],['../structstdex_1_1interval.html#a100a68cd81867cbf1b275cd5ab5d2160',1,'stdex::interval::interval(T x) noexcept'],['../structstdex_1_1interval.html#a41ac8e9fdb33a2dfaae6113006b792d8',1,'stdex::interval::interval(T _start, T _end) noexcept'],['../structstdex_1_1interval.html',1,'stdex::interval< T >']]], + ['interval_2',['interval',['../structstdex_1_1interval.html',1,'stdex::interval< T >'],['../classstdex_1_1parser_1_1basic__parser.html#a0b46b1904e5af116c34a10087a5bc056',1,'stdex::parser::basic_parser::interval'],['../structstdex_1_1interval.html#a9f6c66e8a3fd15c693011216bb45d6b9',1,'stdex::interval::interval() noexcept'],['../structstdex_1_1interval.html#a100a68cd81867cbf1b275cd5ab5d2160',1,'stdex::interval::interval(T x) noexcept'],['../structstdex_1_1interval.html#a41ac8e9fdb33a2dfaae6113006b792d8',1,'stdex::interval::interval(T _start, T _end) noexcept']]], ['interval_3c_20fpos_5ft_20_3e_3',['interval< fpos_t >',['../structstdex_1_1interval.html',1,'stdex']]], ['interval_3c_20size_5ft_20_3e_4',['interval< size_t >',['../structstdex_1_1interval.html',1,'stdex']]] ]; diff --git a/search/all_9.js b/search/all_9.js index f2a2437d5..0274ea554 100644 --- a/search/all_9.js +++ b/search/all_9.js @@ -1,8 +1,8 @@ var searchData= [ - ['lazy_5fprogress_0',['lazy_progress',['../classstdex_1_1lazy__progress.html#a90d8aaa2e2135537f7bb103bf795956a',1,'stdex::lazy_progress::lazy_progress()'],['../classstdex_1_1lazy__progress.html',1,'stdex::lazy_progress< T >']]], + ['lazy_5fprogress_0',['lazy_progress',['../classstdex_1_1lazy__progress.html',1,'stdex::lazy_progress< T >'],['../classstdex_1_1lazy__progress.html#a90d8aaa2e2135537f7bb103bf795956a',1,'stdex::lazy_progress::lazy_progress()']]], ['length_1',['length',['../classstdex_1_1stream_1_1replicator_1_1worker.html#acdf8a4a4f07271bc7bd4f634640e7f5a',1,'stdex::stream::replicator::worker']]], ['limiter_2',['limiter',['../classstdex_1_1stream_1_1limiter.html',1,'stdex::stream']]], - ['load_3',['load',['../classstdex_1_1stream_1_1memory__file.html#a3333329f0e94c0d08caf326cfb483d15',1,'stdex::stream::memory_file']]], + ['load_3',['load',['../classstdex_1_1stream_1_1memory__file.html#a98f0a5ecb59b4e50d5990aa505b658c2',1,'stdex::stream::memory_file']]], ['lock_4',['lock',['../classstdex_1_1stream_1_1basic__file.html#a484ec74004fe0b4528c11675b91161e0',1,'stdex::stream::basic_file::lock()'],['../classstdex_1_1stream_1_1file__window.html#a820fea50931a0769161f617a524f72c6',1,'stdex::stream::file_window::lock()'],['../classstdex_1_1stream_1_1cache.html#ac1ca25b572574b35cd4895964e835204',1,'stdex::stream::cache::lock()'],['../classstdex_1_1stream_1_1file.html#a74fdb70cb8ce4d0ee73f6db9d7051d86',1,'stdex::stream::file::lock()'],['../classstdex_1_1stream_1_1diag__file.html#a5d4bcde718ef182590c742f0c600e54b',1,'stdex::stream::diag_file::lock()']]] ]; diff --git a/search/all_a.js b/search/all_a.js index 0be010daa..497f98580 100644 --- a/search/all_a.js +++ b/search/all_a.js @@ -14,8 +14,8 @@ var searchData= ['m_5freserved_11',['m_reserved',['../classstdex_1_1stream_1_1memory__file.html#a6aa8c2deeabc66f065c858ba399d911c',1,'stdex::stream::memory_file']]], ['m_5fsize_12',['m_size',['../classstdex_1_1stream_1_1memory__file.html#a41121ff122745e109c1b9851632abce3',1,'stdex::stream::memory_file']]], ['m_5fsize_5fmax_13',['m_size_max',['../classstdex_1_1vector__queue.html#a7192dc2991d690b04a2fb24dd6fdc325',1,'stdex::vector_queue']]], - ['mapping_14',['mapping',['../structstdex_1_1mapping.html#a9634b5ef182398e24b61c2ca78cc8e46',1,'stdex::mapping::mapping()'],['../structstdex_1_1mapping.html#a48069d4eb38c276e856d650075f6c3bd',1,'stdex::mapping::mapping(T x)'],['../structstdex_1_1mapping.html#ae72436dbc2b54e2062822cd7772de830',1,'stdex::mapping::mapping(T _from, T _to)'],['../structstdex_1_1mapping.html',1,'stdex::mapping< T >']]], - ['memory_5ffile_15',['memory_file',['../classstdex_1_1stream_1_1memory__file.html#a6b4b9daa088fb20678a502e81553c745',1,'stdex::stream::memory_file::memory_file(size_t size, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#af7fdc0b7ffcd3713487a75cfd9c1704f',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, size_t reserved, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#ad0da8c8758672af312026957e2556b60',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#a92f7f489afbe28ed27c4c48c2a54891c',1,'stdex::stream::memory_file::memory_file(const sys_char *filename, int mode)'],['../classstdex_1_1stream_1_1memory__file.html',1,'stdex::stream::memory_file']]], + ['mapping_14',['mapping',['../structstdex_1_1mapping.html',1,'stdex::mapping< T >'],['../structstdex_1_1mapping.html#a48069d4eb38c276e856d650075f6c3bd',1,'stdex::mapping::mapping(T x)'],['../structstdex_1_1mapping.html#ae72436dbc2b54e2062822cd7772de830',1,'stdex::mapping::mapping(T _from, T _to)'],['../structstdex_1_1mapping.html#a9634b5ef182398e24b61c2ca78cc8e46',1,'stdex::mapping::mapping()']]], + ['memory_5ffile_15',['memory_file',['../classstdex_1_1stream_1_1memory__file.html',1,'stdex::stream::memory_file'],['../classstdex_1_1stream_1_1memory__file.html#a0bb7b9759667e810c91b3e58c1771d91',1,'stdex::stream::memory_file::memory_file(const schar_t *filename, int mode)'],['../classstdex_1_1stream_1_1memory__file.html#ad0da8c8758672af312026957e2556b60',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#af7fdc0b7ffcd3713487a75cfd9c1704f',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, size_t reserved, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#a6b4b9daa088fb20678a502e81553c745',1,'stdex::stream::memory_file::memory_file(size_t size, state_t state=state_t::ok)']]], ['mouth_16',['mouth',['../classstdex_1_1parser_1_1basic__emoticon.html#a43d0de6a54546e509807c7c888bb8dc8',1,'stdex::parser::basic_emoticon']]], ['mtime_17',['mtime',['../classstdex_1_1stream_1_1basic__file.html#ae10432137e01b7ce7c254c2a455c719e',1,'stdex::stream::basic_file::mtime()'],['../classstdex_1_1stream_1_1cache.html#a8350e6c158982e5511da18ed122bf24d',1,'stdex::stream::cache::mtime()'],['../classstdex_1_1stream_1_1file.html#a23e1061f6a9473241ef8af99f6a3f08f',1,'stdex::stream::file::mtime()']]] ]; diff --git a/search/all_c.js b/search/all_c.js index 0a5709ae4..e62fec319 100644 --- a/search/all_c.js +++ b/search/all_c.js @@ -2,7 +2,7 @@ var searchData= [ ['ok_0',['ok',['../classstdex_1_1stream_1_1basic.html#a0295e4efe18eef2a8962680274957ac1',1,'stdex::stream::basic']]], ['op_1',['op',['../classstdex_1_1stream_1_1replicator_1_1worker.html#a9ddd37c6da22d559f6deb46102833f31',1,'stdex::stream::replicator::worker']]], - ['open_2',['open',['../classstdex_1_1idrec_1_1record.html#a379d9eeac3c52375982ba75df33604ca',1,'stdex::idrec::record::open()'],['../classstdex_1_1stream_1_1file.html#a70b9101a911ed513fb0097d3bec5023a',1,'stdex::stream::file::open()'],['../classstdex_1_1stream_1_1cached__file.html#ac2a52fed78cb08987e63210b4f34fd1b',1,'stdex::stream::cached_file::open()']]], + ['open_2',['open',['../classstdex_1_1idrec_1_1record.html#a379d9eeac3c52375982ba75df33604ca',1,'stdex::idrec::record::open()'],['../classstdex_1_1stream_1_1file.html#a556c4cff7086d5f258dcdf914556084a',1,'stdex::stream::file::open()'],['../classstdex_1_1stream_1_1cached__file.html#a8a1ac6ccd8e1d321112412d346eec0e1',1,'stdex::stream::cached_file::open()']]], ['operator_20bool_3',['operator bool',['../structstdex_1_1interval.html#a15945d1ba829410c61466d95922000d0',1,'stdex::interval::operator bool()'],['../classstdex_1_1sys__object.html#a529b0f9294ed46591389ca3dd9c540f3',1,'stdex::sys_object::operator bool()']]], ['operator_21_3d_4',['operator!=',['../structstdex_1_1mapping.html#a99e44b5840a155e5ce366d440cbe234b',1,'stdex::mapping::operator!=()'],['../structstdex_1_1interval.html#aa5e6ff5a63e3cd9f8e36a32663ebfda8',1,'stdex::interval::operator!=()']]], ['operator_28_29_5',['operator()',['../structstdex_1_1free__locale__delete.html#ab7a2cd4be45534b436a871e09805b36f',1,'stdex::free_locale_delete']]], diff --git a/search/functions_10.js b/search/functions_10.js index f9633d8ff..e610bd84d 100644 --- a/search/functions_10.js +++ b/search/functions_10.js @@ -1,6 +1,6 @@ var searchData= [ - ['save_0',['save',['../classstdex_1_1stream_1_1memory__file.html#aef50ff3c88577d89d83ee625cc5d1bfd',1,'stdex::stream::memory_file']]], + ['save_0',['save',['../classstdex_1_1stream_1_1memory__file.html#a96210fbbca48af7097ddad7cc9bf6cb5',1,'stdex::stream::memory_file']]], ['seek_1',['seek',['../classstdex_1_1stream_1_1basic__file.html#afcaac612398bd7d02d8d146dcad74465',1,'stdex::stream::basic_file::seek()'],['../classstdex_1_1stream_1_1diag__file.html#a9f616580a2547b37beccd7d114ed06d0',1,'stdex::stream::diag_file::seek()'],['../classstdex_1_1stream_1_1memory__file.html#a9e67e40e9e3c0f7b002fcdab5220b4e7',1,'stdex::stream::memory_file::seek()'],['../classstdex_1_1stream_1_1cache.html#af2979118bdeca35cbfd84a8a2be00f8a',1,'stdex::stream::cache::seek()'],['../classstdex_1_1stream_1_1file__window.html#a53a12a1979b770030c0de05b349f1e55',1,'stdex::stream::file_window::seek()'],['../classstdex_1_1stream_1_1file.html#acdfc1dc079ebeaeb05312e03925485ff',1,'stdex::stream::file::seek()']]], ['seekbeg_2',['seekbeg',['../classstdex_1_1stream_1_1basic__file.html#a6a8da9a1b0a3926b9bc453bf0209ee5e',1,'stdex::stream::basic_file']]], ['seekcur_3',['seekcur',['../classstdex_1_1stream_1_1basic__file.html#a8158cb89ef54a737b7bcfed635c215d6',1,'stdex::stream::basic_file']]], diff --git a/search/functions_2.js b/search/functions_2.js index fe8320309..7826537b9 100644 --- a/search/functions_2.js +++ b/search/functions_2.js @@ -1,6 +1,6 @@ var searchData= [ - ['cached_5ffile_0',['cached_file',['../classstdex_1_1stream_1_1cached__file.html#aace5ebb17927a869e6e923b592d8b3da',1,'stdex::stream::cached_file']]], + ['cached_5ffile_0',['cached_file',['../classstdex_1_1stream_1_1cached__file.html#aa53149a79b463450f64223f45285dc02',1,'stdex::stream::cached_file']]], ['cancel_1',['cancel',['../classstdex_1_1progress.html#a03380c822297092b3bb9867deee26202',1,'stdex::progress::cancel()'],['../classstdex_1_1global__progress.html#a74a5ea9089ff7b7015ea4a2071f3113e',1,'stdex::global_progress::cancel()']]], ['capacity_2',['capacity',['../classstdex_1_1vector__queue.html#add3d6ed93d3c1471b80351c56639bab7',1,'stdex::vector_queue']]], ['clear_3',['clear',['../classstdex_1_1base64__enc.html#afb6a85176589d9ce1f65ce6355592fe7',1,'stdex::base64_enc::clear()'],['../classstdex_1_1base64__dec.html#a94738b63789489022e0c16063b732305',1,'stdex::base64_dec::clear()'],['../classstdex_1_1hex__dec.html#a282bf5db0d16b29b12c71b73d3a33cc4',1,'stdex::hex_dec::clear()'],['../classstdex_1_1vector__queue.html#a93259be5f471580d2f8d7bee41032f9b',1,'stdex::vector_queue::clear()']]], diff --git a/search/functions_5.js b/search/functions_5.js index d0f6a48b4..976481fed 100644 --- a/search/functions_5.js +++ b/search/functions_5.js @@ -1,6 +1,6 @@ var searchData= [ - ['file_0',['file',['../classstdex_1_1stream_1_1file.html#a3324c7a122b9debf2fde7f4e4f340683',1,'stdex::stream::file']]], + ['file_0',['file',['../classstdex_1_1stream_1_1file.html#a31e46e58ec40db989b36c3553b09084f',1,'stdex::stream::file']]], ['find_1',['find',['../classstdex_1_1idrec_1_1record.html#a19523040d07119055884a7a2f8ef25fd',1,'stdex::idrec::record']]], ['flush_2',['flush',['../classstdex_1_1stream_1_1diag__file.html#aadb3e9de2c84e317bf454ae764d8fcdf',1,'stdex::stream::diag_file::flush()'],['../classstdex_1_1stream_1_1basic__sys.html#a6eae9769feea69fa9ce8b127ca2f7891',1,'stdex::stream::basic_sys::flush()'],['../classstdex_1_1stream_1_1cache.html#ac33e763d8103ad8e910b75085a4cf3ac',1,'stdex::stream::cache::flush()'],['../classstdex_1_1stream_1_1file__window.html#a2a2b88934b073b456da579ca3e3b43ff',1,'stdex::stream::file_window::flush()'],['../classstdex_1_1stream_1_1buffer.html#a18f9edc9af41f3a71d84f7eb4e7d5332',1,'stdex::stream::buffer::flush()'],['../classstdex_1_1stream_1_1async__writer.html#a25c72d3b2edaba300eb158d06dfd03d2',1,'stdex::stream::async_writer::flush()'],['../classstdex_1_1stream_1_1replicator.html#a77d2ddda29ef5dfb835453ff1dd90f2e',1,'stdex::stream::replicator::flush()'],['../classstdex_1_1stream_1_1converter.html#a0d6af4c223625bc8ab677978b225d06e',1,'stdex::stream::converter::flush()'],['../classstdex_1_1stream_1_1basic.html#a46c70519f3e4b1f3436e85a6623555dc',1,'stdex::stream::basic::flush()']]], ['from_5fdate_3',['from_date',['../structstdex_1_1chrono_1_1aosn__timestamp.html#a47f38a2cdf1525e44ac800311d9ab825',1,'stdex::chrono::aosn_timestamp']]], diff --git a/search/functions_9.js b/search/functions_9.js index c8d9e8f4e..0aa3711f2 100644 --- a/search/functions_9.js +++ b/search/functions_9.js @@ -1,6 +1,6 @@ var searchData= [ ['lazy_5fprogress_0',['lazy_progress',['../classstdex_1_1lazy__progress.html#a90d8aaa2e2135537f7bb103bf795956a',1,'stdex::lazy_progress']]], - ['load_1',['load',['../classstdex_1_1stream_1_1memory__file.html#a3333329f0e94c0d08caf326cfb483d15',1,'stdex::stream::memory_file']]], + ['load_1',['load',['../classstdex_1_1stream_1_1memory__file.html#a98f0a5ecb59b4e50d5990aa505b658c2',1,'stdex::stream::memory_file']]], ['lock_2',['lock',['../classstdex_1_1stream_1_1basic__file.html#a484ec74004fe0b4528c11675b91161e0',1,'stdex::stream::basic_file::lock()'],['../classstdex_1_1stream_1_1file__window.html#a820fea50931a0769161f617a524f72c6',1,'stdex::stream::file_window::lock()'],['../classstdex_1_1stream_1_1cache.html#ac1ca25b572574b35cd4895964e835204',1,'stdex::stream::cache::lock()'],['../classstdex_1_1stream_1_1file.html#a74fdb70cb8ce4d0ee73f6db9d7051d86',1,'stdex::stream::file::lock()'],['../classstdex_1_1stream_1_1diag__file.html#a5d4bcde718ef182590c742f0c600e54b',1,'stdex::stream::diag_file::lock()']]] ]; diff --git a/search/functions_a.js b/search/functions_a.js index 004702923..b460f7bb6 100644 --- a/search/functions_a.js +++ b/search/functions_a.js @@ -1,6 +1,6 @@ var searchData= [ ['mapping_0',['mapping',['../structstdex_1_1mapping.html#a9634b5ef182398e24b61c2ca78cc8e46',1,'stdex::mapping::mapping()'],['../structstdex_1_1mapping.html#a48069d4eb38c276e856d650075f6c3bd',1,'stdex::mapping::mapping(T x)'],['../structstdex_1_1mapping.html#ae72436dbc2b54e2062822cd7772de830',1,'stdex::mapping::mapping(T _from, T _to)']]], - ['memory_5ffile_1',['memory_file',['../classstdex_1_1stream_1_1memory__file.html#a6b4b9daa088fb20678a502e81553c745',1,'stdex::stream::memory_file::memory_file(size_t size, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#af7fdc0b7ffcd3713487a75cfd9c1704f',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, size_t reserved, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#ad0da8c8758672af312026957e2556b60',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#a92f7f489afbe28ed27c4c48c2a54891c',1,'stdex::stream::memory_file::memory_file(const sys_char *filename, int mode)']]], + ['memory_5ffile_1',['memory_file',['../classstdex_1_1stream_1_1memory__file.html#a6b4b9daa088fb20678a502e81553c745',1,'stdex::stream::memory_file::memory_file(size_t size, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#af7fdc0b7ffcd3713487a75cfd9c1704f',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, size_t reserved, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#ad0da8c8758672af312026957e2556b60',1,'stdex::stream::memory_file::memory_file(void *data, size_t size, bool manage=false, state_t state=state_t::ok)'],['../classstdex_1_1stream_1_1memory__file.html#a0bb7b9759667e810c91b3e58c1771d91',1,'stdex::stream::memory_file::memory_file(const schar_t *filename, int mode)']]], ['mtime_2',['mtime',['../classstdex_1_1stream_1_1basic__file.html#ae10432137e01b7ce7c254c2a455c719e',1,'stdex::stream::basic_file::mtime()'],['../classstdex_1_1stream_1_1cache.html#a8350e6c158982e5511da18ed122bf24d',1,'stdex::stream::cache::mtime()'],['../classstdex_1_1stream_1_1file.html#a23e1061f6a9473241ef8af99f6a3f08f',1,'stdex::stream::file::mtime()']]] ]; diff --git a/search/functions_c.js b/search/functions_c.js index f5fb846be..0442bcda6 100644 --- a/search/functions_c.js +++ b/search/functions_c.js @@ -1,7 +1,7 @@ var searchData= [ ['ok_0',['ok',['../classstdex_1_1stream_1_1basic.html#a0295e4efe18eef2a8962680274957ac1',1,'stdex::stream::basic']]], - ['open_1',['open',['../classstdex_1_1idrec_1_1record.html#a379d9eeac3c52375982ba75df33604ca',1,'stdex::idrec::record::open()'],['../classstdex_1_1stream_1_1file.html#a70b9101a911ed513fb0097d3bec5023a',1,'stdex::stream::file::open()'],['../classstdex_1_1stream_1_1cached__file.html#ac2a52fed78cb08987e63210b4f34fd1b',1,'stdex::stream::cached_file::open()']]], + ['open_1',['open',['../classstdex_1_1idrec_1_1record.html#a379d9eeac3c52375982ba75df33604ca',1,'stdex::idrec::record::open()'],['../classstdex_1_1stream_1_1file.html#a556c4cff7086d5f258dcdf914556084a',1,'stdex::stream::file::open()'],['../classstdex_1_1stream_1_1cached__file.html#a8a1ac6ccd8e1d321112412d346eec0e1',1,'stdex::stream::cached_file::open()']]], ['operator_20bool_2',['operator bool',['../structstdex_1_1interval.html#a15945d1ba829410c61466d95922000d0',1,'stdex::interval::operator bool()'],['../classstdex_1_1sys__object.html#a529b0f9294ed46591389ca3dd9c540f3',1,'stdex::sys_object::operator bool()']]], ['operator_21_3d_3',['operator!=',['../structstdex_1_1interval.html#aa5e6ff5a63e3cd9f8e36a32663ebfda8',1,'stdex::interval::operator!=()'],['../structstdex_1_1mapping.html#a99e44b5840a155e5ce366d440cbe234b',1,'stdex::mapping::operator!=()']]], ['operator_28_29_4',['operator()',['../structstdex_1_1free__locale__delete.html#ab7a2cd4be45534b436a871e09805b36f',1,'stdex::free_locale_delete']]], diff --git a/search/search.js b/search/search.js index 9b7a52a19..6fd40c677 100644 --- a/search/search.js +++ b/search/search.js @@ -195,6 +195,7 @@ function SearchBox(name, resultsPath, extension) } else if (e.keyCode==27) // Escape out of the search field { + e.stopPropagation(); this.DOMSearchField().blur(); this.DOMPopupSearchResultsWindow().style.display = 'none'; this.DOMSearchClose().style.display = 'none'; @@ -289,6 +290,7 @@ function SearchBox(name, resultsPath, extension) } else if (e.keyCode==13 || e.keyCode==27) { + e.stopPropagation(); this.OnSelectItem(this.searchIndex); this.CloseSelectionWindow(); this.DOMSearchField().focus(); @@ -670,6 +672,7 @@ function SearchResults(name) } else if (this.lastKey==27) // Escape { + e.stopPropagation(); searchBox.CloseResultsWindow(); document.getElementById("MSearchField").focus(); } @@ -713,6 +716,7 @@ function SearchResults(name) } else if (this.lastKey==27) // Escape { + e.stopPropagation(); searchBox.CloseResultsWindow(); document.getElementById("MSearchField").focus(); } @@ -806,6 +810,7 @@ function createResults(resultsPath) function init_search() { var results = document.getElementById("MSearchSelectWindow"); + results.tabIndex=0; for (var key in indexSectionLabels) { var link = document.createElement('a'); @@ -816,5 +821,20 @@ function init_search() results.appendChild(link); } searchBox.OnSelectItem(0); + + var input = document.getElementById("MSearchSelect"); + var searchSelectWindow = document.getElementById("MSearchSelectWindow"); + input.tabIndex=0; + input.addEventListener("keydown", function(event) { + if (event.keyCode==13 || event.keyCode==40) { + event.preventDefault(); + if (searchSelectWindow.style.display == 'block') { + searchBox.CloseSelectionWindow(); + } else { + searchBox.OnSearchSelectShow(); + searchBox.DOMSearchSelectWindow().focus(); + } + } + }); } /* @license-end */ diff --git a/sgml_8hpp_source.html b/sgml_8hpp_source.html index 14c718c49..8eb4d54d8 100644 --- a/sgml_8hpp_source.html +++ b/sgml_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/sgml.hpp Source File @@ -30,7 +30,7 @@ - + +
diff --git a/sgml__unicode_8hpp_source.html b/sgml__unicode_8hpp_source.html index f71597cfa..2122d1f8c 100644 --- a/sgml__unicode_8hpp_source.html +++ b/sgml__unicode_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/sgml_unicode.hpp Source File @@ -30,7 +30,7 @@ - + +
diff --git a/stream_8hpp_source.html b/stream_8hpp_source.html index d89af7bc3..353d9ec42 100644 --- a/stream_8hpp_source.html +++ b/stream_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/stream.hpp Source File @@ -30,7 +30,7 @@ - + +
30
31#if !defined(SET_FILE_OP_TIMES) && defined(RDAT_BELEZI_CAS_DOSTOPA_VER)
32#define SET_FILE_OP_TIMES 1
-
33#pragma message("RDAT_BELEZI_CAS_DOSTOPA_VER is deprecated. Use SET_FILE_OP_TIMES instead.")
+
33#pragma message("RDAT_BELEZI_CAS_DOSTOPA_VER is deprecated. Use SET_FILE_OP_TIMES instead.")
34#elif !defined(SET_FILE_OP_TIMES)
35#define SET_FILE_OP_TIMES 0
36#endif
37#if !defined(CHECK_STREAM_STATE) && defined(RDAT_NE_PREVERJAJ_STANJA_VER)
38#define CHECK_STREAM_STATE 0
-
39#pragma message("RDAT_NE_PREVERJAJ_EOF_VER is deprecated. Use CHECK_STREAM_STATE=0 instead.")
+
39#pragma message("RDAT_NE_PREVERJAJ_EOF_VER is deprecated. Use CHECK_STREAM_STATE=0 instead.")
40#else
41#define CHECK_STREAM_STATE 1
42#endif
@@ -138,11 +143,13 @@ $(function() {
65 constexpr wchar_t utf16_bom = L'\ufeff';
66 constexpr const char utf8_bom[3] = { '\xef', '\xbb', '\xbf' };
67
+
71 class basic
72 {
73 public:
74 basic(_In_ state_t state = state_t::ok) : m_state(state) {}
75
+
87 virtual _Success_(return != 0 || length == 0) size_t read(
88 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
89 {
@@ -151,7 +158,9 @@ $(function() {
92 m_state = state_t::fail;
93 return 0;
94 }
+
95
+
105 virtual _Success_(return != 0) size_t write(
106 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
107 {
@@ -160,17 +169,23 @@ $(function() {
110 m_state = state_t::fail;
111 return 0;
112 }
+
113
+
117 virtual void flush()
118 {
119 m_state = state_t::ok;
120 }
+
121
+
125 virtual void close()
126 {
127 m_state = state_t::ok;
128 }
+
129
+
133 virtual void skip(_In_ fsize_t amount)
134 {
135 if (amount == 1)
@@ -195,11 +210,13 @@ $(function() {
154 catch (std::bad_alloc) { m_state = state_t::fail; }
155 }
156 }
+
157
161 inline state_t state() const { return m_state; };
162
166 inline bool ok() const { return m_state == state_t::ok; };
167
+
175 virtual std::vector<uint8_t> read_remainder(_In_ size_t max_length = SIZE_MAX)
176 {
177 std::vector<uint8_t> result;
@@ -222,7 +239,9 @@ $(function() {
194 result.resize(offset);
195 return result;
196 }
+
197
+
201 inline uint8_t read_byte()
202 {
203 uint8_t byte;
@@ -230,7 +249,9 @@ $(function() {
205 return byte;
206 throw std::runtime_error("failed to read");
207 }
+
208
+
212 void write_byte(_In_ uint8_t byte, _In_ fsize_t amount = 1)
213 {
214 if (amount == 1)
@@ -256,8 +277,10 @@ $(function() {
234 catch (std::bad_alloc) { m_state = state_t::fail; }
235 }
236 }
+
237
249 template <class T>
+
250 inline basic& read_data(_Out_ T& data)
251 {
252 if (!ok()) _Unlikely_ {
@@ -273,8 +296,10 @@ $(function() {
262 }
263 return *this;
264 }
+
265
277 template <class T>
+
278 inline basic& write_data(_In_ const T data)
279 {
280 if (!ok()) _Unlikely_
@@ -287,22 +312,28 @@ $(function() {
287#endif
288 return *this;
289 }
+
290
296 template<class _Traits = std::char_traits<char>, class _Ax = std::allocator<char>>
+
297 inline size_t readln(_Inout_ std::basic_string<char, _Traits, _Ax>& str)
298 {
299 str.clear();
300 return readln_and_attach(str);
301 }
+
302
308 template<class _Traits = std::char_traits<wchar_t>, class _Ax = std::allocator<wchar_t>>
+
309 inline size_t readln(_Inout_ std::basic_string<wchar_t, _Traits, _Ax>& wstr)
310 {
311 wstr.clear();
312 return readln_and_attach(wstr);
313 }
+
314
320 template<class _Traits = std::char_traits<wchar_t>, class _Ax = std::allocator<wchar_t>>
+
321 size_t readln(_Inout_ std::basic_string<wchar_t, _Traits, _Ax>& wstr, _In_ charset_id charset)
322 {
323 if (charset == charset_id::utf16)
@@ -313,8 +344,10 @@ $(function() {
328 str2wstr(wstr, str, charset);
329 return wstr.size();
330 }
+
331
337 template<class _Elem, class _Traits = std::char_traits<_Elem>, class _Ax = std::allocator<_Elem>>
+
338 size_t readln_and_attach(_Inout_ std::basic_string<_Elem, _Traits, _Ax>& str)
339 {
340 bool initial = true;
@@ -329,8 +362,10 @@ $(function() {
349 } while (ok() && chr != static_cast<_Elem>('\n'));
350 return str.size();
351 }
+
352
358 template<class _Traits = std::char_traits<wchar_t>, class _Ax = std::allocator<wchar_t>>
+
359 size_t readln_and_attach(_Inout_ std::basic_string<wchar_t, _Traits, _Ax>& wstr, _In_ charset_id charset)
360 {
361 if (charset == charset_id::utf16)
@@ -340,7 +375,9 @@ $(function() {
365 str2wstr(wstr, str, charset);
366 return wstr.size();
367 }
+
368
+
374 size_t read_array(_Out_writes_bytes_(size* count) void* array, _In_ size_t size, _In_ size_t count)
375 {
376 for (size_t to_read = mul(size, count);;) {
@@ -353,12 +390,16 @@ $(function() {
383 reinterpret_cast<uint8_t*&>(array) += num_read;
384 }
385 }
+
386
+
392 inline size_t write_array(_In_reads_bytes_opt_(size* count) const void* array, _In_ size_t size, _In_ size_t count)
393 {
394 return write(array, mul(size, count)) / size;
395 }
+
396
+
405 size_t write_array(_In_z_ const wchar_t* wstr, _In_ charset_id charset)
406 {
407 if (!ok()) _Unlikely_
@@ -370,7 +411,9 @@ $(function() {
413 }
414 return write_array(wstr, sizeof(wchar_t), num_chars);
415 }
+
416
+
426 size_t write_array(_In_reads_or_z_opt_(num_chars) const wchar_t* wstr, _In_ size_t num_chars, _In_ charset_id charset)
427 {
428 if (!ok()) _Unlikely_
@@ -382,8 +425,10 @@ $(function() {
434 }
435 return write_array(wstr, sizeof(wchar_t), num_chars);
436 }
+
437
446 template<class _Traits = std::char_traits<wchar_t>, class _Ax = std::allocator<wchar_t>>
+
447 size_t write_array(_In_ const std::basic_string<wchar_t, _Traits, _Ax>& wstr, _In_ charset_id charset)
448 {
449 if (!ok()) _Unlikely_
@@ -394,8 +439,10 @@ $(function() {
454 }
455 return write_array(wstr.data(), sizeof(wchar_t), wstr.size());
456 }
+
457
469 template<class _Elem, class _Traits = std::char_traits<_Elem>, class _Ax = std::allocator<_Elem>>
+
470 inline basic& read_str(_Inout_ std::basic_string<_Elem, _Traits, _Ax>& data)
471 {
472 uint32_t num_chars;
@@ -408,8 +455,10 @@ $(function() {
479 data.resize(read_array(data.data(), sizeof(_Elem), num_chars));
480 return *this;
481 }
+
482
494 template <class T>
+
495 inline basic& write_str(_In_z_ const T* data)
496 {
497 // Stream state will be checked in write_data.
@@ -422,6 +471,7 @@ $(function() {
504 write_array(data, sizeof(T), num_chars);
505 return *this;
506 }
+
507
508#ifdef _WIN32
514 size_t write_sa(_In_ LPSAFEARRAY sa)
@@ -435,6 +485,7 @@ $(function() {
522 }
523#endif
524
+
530 fsize_t write_stream(_Inout_ basic& stream, _In_ fsize_t amount = fsize_max)
531 {
532 std::unique_ptr<uint8_t[]> data(new uint8_t[static_cast<size_t>(std::min<fsize_t>(amount, default_block_size))]);
@@ -456,7 +507,9 @@ $(function() {
548 }
549 return num_copied;
550 }
+
551
+
555 void write_charset(_In_ charset_id charset)
556 {
557 if (charset == charset_id::utf16)
@@ -464,7 +517,9 @@ $(function() {
559 else if (charset == charset_id::utf8)
560 write_array(utf8_bom, sizeof(utf8_bom), 1);
561 }
+
562
+
568 size_t write_sprintf(_In_z_ _Printf_format_string_params_(2) const char* format, _In_opt_ locale_t locale, ...)
569 {
570 va_list params;
@@ -473,7 +528,9 @@ $(function() {
573 va_end(params);
574 return num_chars;
575 }
+
576
+
582 size_t write_sprintf(_In_z_ _Printf_format_string_params_(2) const wchar_t* format, _In_opt_ locale_t locale, ...)
583 {
584 va_list params;
@@ -482,7 +539,9 @@ $(function() {
587 va_end(params);
588 return num_chars;
589 }
+
590
+
596 size_t write_vsprintf(_In_z_ _Printf_format_string_params_(2) const char* format, _In_opt_ locale_t locale, _In_ va_list params)
597 {
598 std::string str;
@@ -490,7 +549,9 @@ $(function() {
600 vappendf(str, format, locale, params);
601 return write_array(str.data(), sizeof(char), str.size());
602 }
+
603
+
609 size_t write_vsprintf(_In_z_ _Printf_format_string_params_(2) const wchar_t* format, _In_opt_ locale_t locale, _In_ va_list params)
610 {
611 std::wstring str;
@@ -498,6 +559,7 @@ $(function() {
613 vappendf(str, format, locale, params);
614 return write_array(str.data(), sizeof(wchar_t), str.size());
615 }
+
616
617 inline basic& operator >>(_Out_ int8_t& data) { return read_data(data); }
618 inline basic& operator <<(_In_ const int8_t data) { return write_data(data); }
@@ -537,6 +599,7 @@ $(function() {
652 protected:
653 state_t m_state;
654 };
+
655
659 using fpos_t = uint64_t;
660 constexpr fpos_t fpos_max = UINT64_MAX;
@@ -564,9 +627,11 @@ $(function() {
688 using time_point = std::chrono::time_point<std::chrono::system_clock>;
689#endif
690
+
694 class basic_file : virtual public basic
695 {
696 public:
+
697 virtual std::vector<uint8_t> read_remainder(_In_ size_t max_length = SIZE_MAX)
698 {
699 size_t length = std::min<size_t>(max_length, static_cast<size_t>(size() - tell()));
@@ -579,6 +644,7 @@ $(function() {
706 result.resize(read_array(result.data(), sizeof(uint8_t), length));
707 return result;
708 }
+
709
715 virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg) = 0;
716
@@ -588,63 +654,81 @@ $(function() {
730
736 inline fpos_t seekend(_In_ foff_t offset) { return seek(offset, seek_t::end); }
737
+
738 virtual void skip(_In_ fsize_t amount)
739 {
740 seek(amount, seek_t::cur);
741 }
+
742
749 virtual fpos_t tell() const = 0;
750
+
754 virtual void lock(_In_ fpos_t offset, _In_ fsize_t length)
755 {
756 UNREFERENCED_PARAMETER(offset);
757 UNREFERENCED_PARAMETER(length);
758 throw std::exception("not implemented");
759 }
+
760
+
764 virtual void unlock(_In_ fpos_t offset, _In_ fsize_t length)
765 {
766 UNREFERENCED_PARAMETER(offset);
767 UNREFERENCED_PARAMETER(length);
768 throw std::exception("not implemented");
769 }
+
770
775 virtual fsize_t size() = 0;
776
780 virtual void truncate() = 0;
781
+
785 virtual time_point ctime() const
786 {
787 return time_point::min();
788 }
+
789
+
793 virtual time_point atime() const
794 {
795 return time_point::min();
796 }
+
797
+
801 virtual time_point mtime() const
802 {
803 return time_point::min();
804 }
+
805
+
809 virtual void set_ctime(time_point date)
810 {
811 UNREFERENCED_PARAMETER(date);
812 throw std::exception("not implemented");
813 }
+
814
+
818 virtual void set_atime(time_point date)
819 {
820 UNREFERENCED_PARAMETER(date);
821 throw std::exception("not implemented");
822 }
+
823
+
827 virtual void set_mtime(time_point date)
828 {
829 UNREFERENCED_PARAMETER(date);
830 throw std::exception("not implemented");
831 }
+
832
833#ifdef _WIN32
837 LPSAFEARRAY read_sa()
@@ -663,6 +747,7 @@ $(function() {
850 }
851#endif
852
+
858 charset_id read_charset(_In_ charset_id default_charset = charset_id::default)
859 {
860 if (seek(0) != 0)
@@ -687,8 +772,11 @@ $(function() {
879 throw std::runtime_error("failed to seek");
880 return default_charset;
881 }
+
882 };
+
883
+
887 class converter : public basic
888 {
889 protected:
@@ -714,6 +802,7 @@ $(function() {
909 m_source(&source)
910 {}
911
+
912 virtual _Success_(return != 0 || length == 0) size_t read(
913 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
914 {
@@ -721,7 +810,9 @@ $(function() {
916 m_state = m_source->state();
917 return num_read;
918 }
+
919
+
920 virtual _Success_(return != 0) size_t write(
921 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
922 {
@@ -729,23 +820,30 @@ $(function() {
924 m_state = m_source->state();
925 return num_written;
926 }
+
927
+
928 virtual void close()
929 {
930 m_source->close();
931 m_state = m_source->state();
932 }
+
933
+
934 virtual void flush()
935 {
936 m_source->flush();
937 m_state = m_source->state();
938 }
+
939
940 protected:
941 basic* m_source;
942 };
+
943
+
947 class replicator : public basic
948 {
949 public:
@@ -763,11 +861,14 @@ $(function() {
961 w->get()->thread.join();
962 }
963
+
967 void push_back(_In_ basic* source)
968 {
969 m_workers.push_back(std::unique_ptr<worker>(new worker(source)));
970 }
+
971
+
975 void remove(basic* source)
976 {
977 for (auto w = m_workers.begin(), w_end = m_workers.end(); w != w_end; ++w) {
@@ -784,7 +885,9 @@ $(function() {
988 }
989 }
990 }
+
991
+
992 virtual _Success_(return != 0) size_t write(
993 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
994 {
@@ -811,18 +914,24 @@ $(function() {
1015 }
1016 return num_written;
1017 }
+
1018
+
1019 virtual void close()
1020 {
1021 foreach_worker(worker::op_t::close);
1022 }
+
1023
+
1024 virtual void flush()
1025 {
1026 foreach_worker(worker::op_t::flush);
1027 }
+
1028
1029 protected:
+
1031 {
1032 public:
@@ -876,6 +985,7 @@ $(function() {
1080 std::condition_variable cv;
1081 std::thread thread;
1082 };
+
1083
1084 void foreach_worker(_In_ worker::op_t op)
1085 {
@@ -899,10 +1009,12 @@ $(function() {
1103
1104 std::list<std::unique_ptr<worker>> m_workers;
1105 };
+
1106
1107 constexpr size_t default_async_limit = 0x100000;
1108
1114 template <size_t CAPACITY = default_async_limit>
+
1116 {
1117 public:
@@ -918,6 +1030,7 @@ $(function() {
1127 }
1128
1129#pragma warning(suppress: 6101) // See [1] below
+
1130 virtual _Success_(return != 0 || length == 0) size_t read(
1131 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
1132 {
@@ -942,6 +1055,7 @@ $(function() {
1151 reinterpret_cast<uint8_t*&>(data) += num_read;
1152 }
1153 }
+
1154
1155 protected:
1156 static void process(_Inout_ async_reader& w)
@@ -964,8 +1078,10 @@ $(function() {
1173 ring<uint8_t, CAPACITY> m_ring;
1174 std::thread m_worker;
1175 };
+
1176
1182 template <size_t CAPACITY = default_async_limit>
+
1184 {
1185 public:
@@ -980,6 +1096,7 @@ $(function() {
1194 m_worker.join();
1195 }
1196
+
1197 virtual _Success_(return != 0) size_t write(
1198 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
1199 {
@@ -1003,12 +1120,15 @@ $(function() {
1217 reinterpret_cast<const uint8_t*&>(data) += num_write;
1218 }
1219 }
+
1220
+
1221 virtual void flush()
1222 {
1223 m_ring.sync();
1225 }
+
1226
1227 protected:
1228 static void process(_Inout_ async_writer& w)
@@ -1031,9 +1151,11 @@ $(function() {
1245 ring<uint8_t, CAPACITY> m_ring;
1246 std::thread m_worker;
1247 };
+
1248
1249 constexpr size_t default_buffer_size = 0x400;
1250
+
1254 class buffer : public converter
1255 {
1256 protected:
@@ -1063,6 +1185,7 @@ $(function() {
1280 flush_write();
1281 }
1282
+
1283 virtual _Success_(return != 0 || length == 0) size_t read(
1284 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
1285 {
@@ -1098,7 +1221,9 @@ $(function() {
1315 }
1316 }
1317 }
+
1318
+
1319 virtual _Success_(return != 0) size_t write(
1320 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
1321 {
@@ -1144,13 +1269,16 @@ $(function() {
1361 }
1362 }
1363 }
+
1364
+
1365 virtual void flush()
1366 {
1367 flush_write();
1368 if (ok())
1370 }
+
1371
1372 protected:
1373 void flush_write()
@@ -1170,6 +1298,7 @@ $(function() {
1387 m_state = state_t::ok;
1388 }
1389
+
1390 struct buffer_t {
1391 uint8_t* data;
1392 size_t head, tail, capacity;
@@ -1187,8 +1316,11 @@ $(function() {
1404 delete[] data;
1405 }
1406 } m_read_buffer, m_write_buffer;
+
1407 };
+
1408
+
1412 class limiter : public converter
1413 {
1414 public:
@@ -1198,6 +1330,7 @@ $(function() {
1418 write_limit(_write_limit)
1419 {}
1420
+
1421 virtual _Success_(return != 0 || length == 0) size_t read(
1422 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
1423 {
@@ -1222,7 +1355,9 @@ $(function() {
1442 }
1443 return num_read;
1444 }
+
1445
+
1446 virtual _Success_(return != 0) size_t write(
1447 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
1448 {
@@ -1247,13 +1382,16 @@ $(function() {
1467 }
1468 return num_written;
1469 }
+
1470
1471 public:
1472 fsize_t
1475 };
+
1476
+
1480 class window : public limiter
1481 {
1482 public:
@@ -1263,6 +1401,7 @@ $(function() {
1486 write_offset(_write_offset)
1487 {}
1488
+
1489 virtual _Success_(return != 0 || length == 0) size_t read(
1490 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
1491 {
@@ -1295,7 +1434,9 @@ $(function() {
1518 }
1519 return num_read;
1520 }
+
1521
+
1522 virtual _Success_(return != 0) size_t write(
1523 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
1524 {
@@ -1335,13 +1476,16 @@ $(function() {
1558 }
1559 return num_skipped + num_written;
1560 }
+
1561
1562 public:
1563 fpos_t
1566 };
+
1567
+
1572 {
1573 public:
@@ -1352,6 +1496,7 @@ $(function() {
1578 m_region(offset, offset + length)
1579 {}
1580
+
1581 virtual _Success_(return != 0 || length == 0) size_t read(
1582 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
1583 {
@@ -1365,7 +1510,9 @@ $(function() {
1591 m_state = length ? state_t::eof : state_t::ok;
1592 return 0;
1593 }
+
1594
+
1595 virtual _Success_(return != 0) size_t write(
1596 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
1597 {
@@ -1379,38 +1526,50 @@ $(function() {
1605 m_state = state_t::fail;
1606 return 0;
1607 }
+
1608
+
1609 virtual void close()
1610 {
1611 m_source.close();
1612 m_state = m_source.state();
1613 }
+
1614
+
1615 virtual void flush()
1616 {
1617 m_source.flush();
1618 m_state = m_source.state();
1619 }
+
1620
+
1621 virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg)
1622 {
1623 m_offset = m_source.seek(offset, how);
1624 m_state = m_source.state();
1625 return ok() ? m_offset - m_region.start : fpos_max;
1626 }
+
1627
+
1628 virtual void skip(_In_ fsize_t amount)
1629 {
1630 m_source.skip(amount);
1631 m_state = m_source.state();
1632 }
+
1633
+
1634 virtual fpos_t tell() const
1635 {
1636 fpos_t offset = m_source.tell();
1637 return m_region.contains(offset) ? offset - m_region.start : fpos_max;
1638 }
+
1639
+
1640 virtual void lock(_In_ fpos_t offset, _In_ fsize_t length)
1641 {
1642 if (m_region.contains(offset)) {
@@ -1420,7 +1579,9 @@ $(function() {
1646 else
1647 m_state = state_t::fail;
1648 }
+
1649
+
1650 virtual void unlock(_In_ fpos_t offset, _In_ fsize_t length)
1651 {
1652 if (m_region.contains(offset)) {
@@ -1430,25 +1591,32 @@ $(function() {
1656 else
1657 m_state = state_t::fail;
1658 }
+
1659
+
1660 virtual fsize_t size()
1661 {
1662 return m_region.size();
1663 }
+
1664
+
1665 virtual void truncate()
1666 {
1667 m_state = state_t::fail;
1668 }
+
1669
1670 protected:
1671 basic_file& m_source;
1672 fpos_t m_offset;
1673 interval<fpos_t> m_region;
1674 };
+
1675
1676 constexpr size_t default_cache_size = 0x1000;
1677
+
1681 class cache : public basic_file
1682 {
1683 protected:
@@ -1467,7 +1635,7 @@ $(function() {
1696 {
1697 m_state = source.state();
1698 m_source = &source;
-
1699 m_offset = source.tell();
+
1699 m_offset = source.tell();
1700#if SET_FILE_OP_TIMES
1701 m_atime = source.atime();
1702 m_mtime = source.mtime();
@@ -1507,6 +1675,7 @@ $(function() {
1736 }
1737 }
1738
+
1739 virtual _Success_(return != 0 || length == 0) size_t read(
1740 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
1741 {
@@ -1568,7 +1737,9 @@ $(function() {
1797 }
1798 }
1799 }
+
1800
+
1801 virtual _Success_(return != 0) size_t write(
1802 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
1803 {
@@ -1621,7 +1792,9 @@ $(function() {
1850 return length - to_write;
1851 }
1852 }
+
1853
+
1854 virtual void close()
1855 {
1856 invalidate_cache();
@@ -1630,7 +1803,9 @@ $(function() {
1859 m_source->close();
1860 m_state = m_source->state();
1861 }
+
1862
+
1863 virtual void flush()
1864 {
1865#if SET_FILE_OP_TIMES
@@ -1641,7 +1816,9 @@ $(function() {
1870 return;
1871 m_source->flush();
1872 }
+
1873
+
1874 virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg)
1875 {
1876 m_state = state_t::ok;
@@ -1656,31 +1833,41 @@ $(function() {
1885 throw std::invalid_argument("unknown seek origin");
1886 }
1887 }
+
1888
+
1889 virtual fpos_t tell() const
1890 {
1891 return m_offset;
1892 }
+
1893
+
1894 virtual void lock(_In_ fpos_t offset, _In_ fsize_t length)
1895 {
1896 m_source->lock(offset, length);
1897 m_state = m_source->state();
1898 }
+
1899
+
1900 virtual void unlock(_In_ fpos_t offset, _In_ fsize_t length)
1901 {
1902 m_source->unlock(offset, length);
1903 m_state = m_source->state();
1904 }
+
1905
+
1906 virtual fsize_t size()
1907 {
1908 return m_cache.status != cache_t::cache_t::status_t::empty ?
1909 std::max(m_source->size(), m_cache.region.end) :
1910 m_source->size();
1911 }
+
1912
+
1913 virtual void truncate()
1914 {
1915#if SET_FILE_OP_TIMES
@@ -1701,12 +1888,16 @@ $(function() {
1930 m_source->truncate();
1931 m_state = m_source->state();
1932 }
+
1933
+
1934 virtual time_point ctime() const
1935 {
1936 return m_source->ctime();
1937 }
+
1938
+
1939 virtual time_point atime() const
1940 {
1941#if SET_FILE_OP_TIMES
@@ -1715,7 +1906,9 @@ $(function() {
1944 return m_source->atime();
1945#endif
1946 }
+
1947
+
1948 virtual time_point mtime() const
1949 {
1950#if SET_FILE_OP_TIMES
@@ -1724,12 +1917,16 @@ $(function() {
1953 return m_source->mtime();
1954#endif
1955 }
+
1956
+
1957 virtual void set_ctime(time_point date)
1958 {
1959 m_source->set_ctime(date);
1960 }
+
1961
+
1962 virtual void set_atime(time_point date)
1963 {
1964#if SET_FILE_OP_TIMES
@@ -1737,7 +1934,9 @@ $(function() {
1966#endif
1967 m_source->set_atime(date);
1968 }
+
1969
+
1970 virtual void set_mtime(time_point date)
1971 {
1972#if SET_FILE_OP_TIMES
@@ -1745,6 +1944,7 @@ $(function() {
1974#endif
1975 m_source->set_mtime(date);
1976 }
+
1977
1978 protected:
1979 void flush_cache()
@@ -1796,6 +1996,7 @@ $(function() {
2025 }
2026
2027 basic_file* m_source;
+
2028 struct cache_t {
2029 uint8_t* data;
2030 size_t capacity;
@@ -1818,6 +2019,7 @@ $(function() {
2047 delete[] data;
2048 }
2049 } m_cache;
+
2050 fpos_t m_offset;
2051#if SET_FILE_OP_TIMES
2052 time_point
@@ -1825,7 +2027,9 @@ $(function() {
2054 m_mtime;
2055#endif
2056 };
+
2057
+
2061 class basic_sys : virtual public basic, public sys_object
2062 {
2063 public:
@@ -1834,6 +2038,7 @@ $(function() {
2066 sys_object(h)
2067 {}
2068
+
2069 virtual _Success_(return != 0 || length == 0) size_t read(
2070 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
2071 {
@@ -1884,7 +2089,9 @@ $(function() {
2116 reinterpret_cast<uint8_t*&>(data) += num_read;
2117 }
2118 }
+
2119
+
2120 virtual _Success_(return != 0) size_t write(
2121 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
2122 {
@@ -1931,7 +2138,9 @@ $(function() {
2163#endif
2164 }
2165 }
+
2166
+
2167 virtual void close()
2168 {
2169 try {
@@ -1942,7 +2151,9 @@ $(function() {
2174 m_state = state_t::fail;
2175 }
2176 }
+
2177
+
2178 virtual void flush()
2179 {
2180#ifdef _WIN32
@@ -1951,8 +2162,11 @@ $(function() {
2183 m_state = fsync(m_h) >= 0 ? state_t::ok : state_t::fail;
2184#endif
2185 }
+
2186 };
+
2187
+
2191 class buffered_sys : public buffer
2192 {
2193 public:
@@ -1971,6 +2185,7 @@ $(function() {
2206 protected:
2207 basic_sys m_source;
2208 };
+
2209
2210#ifdef _WIN32
2214 class sequential_stream : public basic
@@ -2182,17 +2397,21 @@ $(function() {
2426
2427#pragma warning(push)
2428#pragma warning(disable: 4250)
+
2432 class file : virtual public basic_file, virtual public basic_sys
2433 {
2434 public:
2435 file(_In_opt_ sys_handle h = invalid_handle, _In_ state_t state = state_t::ok) : basic_sys(h, state) {}
2436
-
2443 file(_In_z_ const sys_char* filename, _In_ int mode)
+
+
2443 file(_In_z_ const schar_t* filename, _In_ int mode)
2444 {
-
2445 open(filename, mode);
+
2445 open(filename, mode);
2446 }
+
2447
-
2454 void open(_In_z_ const sys_char* filename, _In_ int mode)
+
+
2454 void open(_In_z_ const schar_t* filename, _In_ int mode)
2455 {
2456 if (m_h != invalid_handle)
2457 close();
@@ -2234,7 +2453,7 @@ $(function() {
2493 if (mode & hint_write_thru) flags |= O_DSYNC;
2494 if (mode & hint_no_buffering) flags |= O_RSYNC;
2495
-
2496 m_h = open(filename, flags, DEFFILEMODE);
+
2496 m_h = open(filename, flags, DEFFILEMODE);
2497#endif
2498 if (m_h != invalid_handle) {
2499 m_state = state_t::ok;
@@ -2244,7 +2463,9 @@ $(function() {
2503 else
2504 m_state = state_t::fail;
2505 }
+
2506
+
2507 virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg)
2508 {
2509#ifdef _WIN32
@@ -2265,7 +2486,9 @@ $(function() {
2524 m_state = state_t::fail;
2525 return fpos_max;
2526 }
+
2527
+
2528 virtual fpos_t tell() const
2529 {
2530 if (m_h != invalid_handle) {
@@ -2283,7 +2506,9 @@ $(function() {
2542 }
2543 return fpos_max;
2544 }
+
2545
+
2546 virtual void lock(_In_ fpos_t offset, _In_ fsize_t length)
2547 {
2548#ifdef _WIN32
@@ -2306,7 +2531,9 @@ $(function() {
2565#endif
2566 m_state = state_t::fail;
2567 }
+
2568
+
2569 virtual void unlock(_In_ fpos_t offset, _In_ fsize_t length)
2570 {
2571#ifdef _WIN32
@@ -2331,7 +2558,9 @@ $(function() {
2590#endif
2591 m_state = state_t::fail;
2592 }
+
2593
+
2594 virtual fsize_t size()
2595 {
2596#ifdef _WIN32
@@ -2349,7 +2578,9 @@ $(function() {
2608 return length;
2609#endif
2610 }
+
2611
+
2612 virtual void truncate()
2613 {
2614#ifdef _WIN32
@@ -2366,6 +2597,7 @@ $(function() {
2625#endif
2626 m_state = state_t::fail;
2627 }
+
2628
2629#ifdef _WIN32
2630 static inline time_point ft2tp(_In_ const FILETIME& ft)
@@ -2390,6 +2622,7 @@ $(function() {
2649 }
2650#endif
2651
+
2652 virtual time_point ctime() const
2653 {
2654#ifdef _WIN32
@@ -2399,7 +2632,9 @@ $(function() {
2658#endif
2659 return time_point::min();
2660 }
+
2661
+
2662 virtual time_point atime() const
2663 {
2664#ifdef _WIN32
@@ -2413,7 +2648,9 @@ $(function() {
2672#endif
2673 return time_point::min();
2674 }
+
2675
+
2676 virtual time_point mtime() const
2677 {
2678#ifdef _WIN32
@@ -2427,7 +2664,9 @@ $(function() {
2686#endif
2687 return time_point::min();
2688 }
+
2689
+
2690 virtual void set_ctime(time_point date)
2691 {
2692 assert(m_h != invalid_handle);
@@ -2439,7 +2678,9 @@ $(function() {
2698#endif
2699 throw std::runtime_error("failed to set file ctime");
2700 }
+
2701
+
2702 virtual void set_atime(time_point date)
2703 {
2704 assert(m_h != invalid_handle);
@@ -2457,7 +2698,9 @@ $(function() {
2716#endif
2717 throw std::runtime_error("failed to set file atime");
2718 }
+
2719
+
2720 virtual void set_mtime(time_point date)
2721 {
2722#ifdef _WIN32
@@ -2474,9 +2717,12 @@ $(function() {
2733#endif
2734 throw std::runtime_error("failed to set file mtime");
2735 }
+
2736 };
+
2737#pragma warning(pop)
2738
+
2742 class cached_file : public cache
2743 {
2744 public:
@@ -2487,26 +2733,29 @@ $(function() {
2749 init(m_source);
2750 }
2751
-
2759 cached_file(_In_z_ const sys_char* filename, _In_ int mode, _In_ size_t cache_size = default_cache_size) :
+
+
2759 cached_file(_In_z_ const schar_t* filename, _In_ int mode, _In_ size_t cache_size = default_cache_size) :
2760 cache(cache_size),
2761 m_source(filename, mode & mode_for_writing ? mode | mode_for_reading : mode)
2762 {
2763 init(m_source);
2764 }
+
2765
2766 virtual ~cached_file()
2767 {
2768 done();
2769 }
2770
-
2778 void open(_In_z_ const sys_char* filename, _In_ int mode)
+
+
2778 void open(_In_z_ const schar_t* filename, _In_ int mode)
2779 {
2780 invalidate_cache();
2781 if (!ok()) _Unlikely_{
2782 m_state = state_t::fail;
2783 return;
2784 }
-
2785 m_source.open(filename, mode & mode_for_writing ? mode | mode_for_reading : mode);
+
2785 m_source.open(filename, mode & mode_for_writing ? mode | mode_for_reading : mode);
2786 if (m_source.ok()) {
2787#if SET_FILE_OP_TIMES
2788 m_atime = m_source.atime();
@@ -2518,11 +2767,14 @@ $(function() {
2794 }
2795 m_state = state_t::fail;
2796 }
+
2797
2798 protected:
2799 file m_source;
2800 };
+
2801
+
2806 {
2807 public:
@@ -2539,6 +2791,7 @@ $(function() {
2818#endif
2819 }
2820
+
2827 memory_file(_In_ size_t size, _In_ state_t state = state_t::ok) :
2828 basic(state),
2829 m_data(reinterpret_cast<uint8_t*>(malloc(size))),
@@ -2553,7 +2806,9 @@ $(function() {
2838 m_ctime = m_atime = m_mtime = time_point::now();
2839#endif
2840 }
+
2841
+
2851 memory_file(_Inout_ void* data, _In_ size_t size, _In_ size_t reserved, _In_ bool manage = false, _In_ state_t state = state_t::ok) :
2852 basic(state),
2853 m_data(reinterpret_cast<uint8_t*>(data)),
@@ -2568,15 +2823,20 @@ $(function() {
2862 m_ctime = m_atime = m_mtime = time_point::now();
2863#endif
2864 }
+
2865
+
2874 memory_file(_Inout_ void* data, _In_ size_t size, _In_ bool manage = false, _In_ state_t state = state_t::ok) :
2875 memory_file(data, size, size, manage, state)
2876 {}
+
2877
-
2884 memory_file(_In_z_ const sys_char* filename, _In_ int mode) : memory_file()
+
+
2884 memory_file(_In_z_ const schar_t* filename, _In_ int mode) : memory_file()
2885 {
-
2886 load(filename, mode);
+
2886 load(filename, mode);
2887 }
+
2888
2889 virtual ~memory_file()
2890 {
@@ -2584,6 +2844,7 @@ $(function() {
2892 free(m_data);
2893 }
2894
+
2901 void reserve(_In_ size_t required, _In_ bool tight = false) noexcept
2902 {
2903 if (required <= m_reserved && (!tight || required >= m_reserved)) {
@@ -2606,8 +2867,10 @@ $(function() {
2920 m_reserved = reserved;
2921 m_state = state_t::ok;
2922 }
+
2923
-
2930 void load(_In_z_ const sys_char* filename, _In_ int mode)
+
+
2930 void load(_In_z_ const schar_t* filename, _In_ int mode)
2931 {
2932 file f(filename, (mode & ~hint_random_access) | mode_for_reading | hint_sequential_access);
2933 if (!f.ok()) {
@@ -2633,8 +2896,10 @@ $(function() {
2953 m_mtime = f.mtime();
2954#endif
2955 }
+
2956
-
2963 void save(_In_z_ const sys_char* filename, _In_ int mode)
+
+
2963 void save(_In_z_ const schar_t* filename, _In_ int mode)
2964 {
2965 file f(filename, (mode & ~hint_random_access) | mode_for_writing | hint_sequential_access);
2966 if (!f.ok()) {
@@ -2653,9 +2918,11 @@ $(function() {
2979 f.set_mtime(m_mtime);
2980#endif
2981 }
+
2982
2986 inline const void* data() const { return m_data; }
2987
+
2988 virtual _Success_(return != 0 || length == 0) size_t read(
2989 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
2990 {
@@ -2679,8 +2946,10 @@ $(function() {
3008 m_state = state_t::ok;
3009 return available;
3010 }
+
3011
3026 template <class T>
+
3028 {
3029#if SET_FILE_OP_TIMES
@@ -2705,8 +2974,10 @@ $(function() {
3048 }
3049 return *this;
3050 }
+
3051
3066 template<class _Elem, class _Traits = std::char_traits<_Elem>, class _Ax = std::allocator<_Elem>>
+
3067 memory_file& read_str(_Inout_ std::basic_string<_Elem, _Traits, _Ax>&data)
3068 {
3069#if SET_FILE_OP_TIMES
@@ -2737,7 +3008,9 @@ $(function() {
3094 m_state = state_t::eof;
3095 return *this;
3096 }
+
3097
+
3098 virtual _Success_(return != 0) size_t write(
3099 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
3100 {
@@ -2758,7 +3031,9 @@ $(function() {
3115 m_state = state_t::ok;
3116 return length;
3117 }
+
3118
+
3122 void write_byte(_In_ uint8_t byte, _In_ size_t amount = 1)
3123 {
3124#if SET_FILE_OP_TIMES
@@ -2776,8 +3051,10 @@ $(function() {
3136 m_size = m_offset;
3137 m_state = state_t::ok;
3138 }
+
3139
3154 template <class T>
+
3155 inline memory_file& write_data(const T data)
3156 {
3157#if SET_FILE_OP_TIMES
@@ -2800,8 +3077,10 @@ $(function() {
3174#endif
3175 return *this;
3176 }
+
3177
3192 template <class T>
+
3193 inline memory_file& write_str(_In_z_ const T * data)
3194 {
3195#if SET_FILE_OP_TIMES
@@ -2831,7 +3110,9 @@ $(function() {
3219#endif
3220 return *this;
3221 }
+
3222
+
3228 size_t write_stream(_Inout_ basic & stream, _In_ size_t amount = SIZE_MAX)
3229 {
3230#if SET_FILE_OP_TIMES
@@ -2881,7 +3162,9 @@ $(function() {
3274 m_size = m_offset;
3275 return num_copied;
3276 }
+
3277
+
3278 virtual void close()
3279 {
3280 if (m_manage && m_data)
@@ -2895,7 +3178,9 @@ $(function() {
3288#endif
3289 m_state = state_t::ok;
3290 }
+
3291
+
3292 virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg)
3293 {
3294 fpos_t target;
@@ -2912,17 +3197,23 @@ $(function() {
3305 m_state = state_t::fail;
3306 return fpos_max;
3307 }
+
3308
+
3309 virtual fpos_t tell() const
3310 {
3311 return m_offset;
3312 }
+
3313
+
3314 virtual fsize_t size()
3315 {
3316 return m_size;
3317 }
+
3318
+
3319 virtual void truncate()
3320 {
3321#if SET_FILE_OP_TIMES
@@ -2931,6 +3222,7 @@ $(function() {
3324 m_size = m_offset;
3326 }
+
3327
3328#if SET_FILE_OP_TIMES
3329 virtual time_point ctime() const
@@ -2966,6 +3258,7 @@ $(function() {
3359
3360 protected:
3368 template <class T>
+
3369 inline void set(_In_ fpos_t offset, _In_ const T data)
3370 {
3371#if SET_FILE_OP_TIMES
@@ -2974,6 +3267,7 @@ $(function() {
3374 assert(offset + sizeof(T) < m_size);
3375 (*reinterpret_cast<T*>(m_data + offset)) = HE2LE(data);
3376 }
+
3377
3378 public:
3379 inline void set(_In_ fpos_t offset, _In_ const int8_t data) { set<int8_t>(offset, data); }
@@ -2996,6 +3290,7 @@ $(function() {
3396
3404 protected:
3405 template <class T>
+
3406 inline void get(_In_ fpos_t offset, _Out_ T & data)
3407 {
3408 assert(offset + sizeof(T) < m_size);
@@ -3004,6 +3299,7 @@ $(function() {
3411 m_atime = time_point::now();
3412#endif
3413 }
+
3414
3415 public:
3416 inline void get(_In_ fpos_t offset, _Out_ int8_t & data) { get<int8_t>(offset, data); }
@@ -3072,7 +3368,9 @@ $(function() {
3479 m_mtime;
3480#endif
3481 };
+
3482
+
3486 class fifo : public basic {
3487 public:
3488 fifo() :
@@ -3092,6 +3390,7 @@ $(function() {
3502 }
3503
3504#pragma warning(suppress: 6101) // See [2] below
+
3505 virtual _Success_(return != 0 || length == 0) size_t read(
3506 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
3507 {
@@ -3120,7 +3419,9 @@ $(function() {
3530 delete p;
3531 }
3532 }
+
3533
+
3534 virtual _Success_(return != 0) size_t write(
3535 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
3536 {
@@ -3143,7 +3444,9 @@ $(function() {
3553 return 0;
3554 }
3555 }
+
3556
+
3557 virtual void close()
3558 {
3559 m_size = m_offset = 0;
@@ -3154,19 +3457,24 @@ $(function() {
3564 }
3565 m_state = state_t::ok;
3566 }
+
3567
3571 inline size_t size() const { return m_size; };
3572
3573 protected:
3574 size_t m_offset, m_size;
+
3575 struct node_t {
3576 node_t* next;
3577 size_t size;
3578#pragma warning(suppress:4200)
3579 uint8_t data[0];
3580 } *m_head, * m_tail;
+
3581 };
+
3582
+
3586 class diag_file : public basic_file {
3587 public:
3588 diag_file(_In_count_(num_files) basic_file* const* files, _In_ size_t num_files) :
@@ -3175,6 +3483,7 @@ $(function() {
3591 {
3592 }
3593
+
3594 virtual _Success_(return != 0 || length == 0) size_t read(
3595 _Out_writes_bytes_to_opt_(length, return) void* data, _In_ size_t length)
3596 {
@@ -3197,7 +3506,9 @@ $(function() {
3613 }
3614 return result;
3615 }
+
3616
+
3617 virtual _Success_(return != 0) size_t write(
3618 _In_reads_bytes_opt_(length) const void* data, _In_ size_t length)
3619 {
@@ -3215,7 +3526,9 @@ $(function() {
3631 }
3632 return result;
3633 }
+
3634
+
3635 virtual void flush()
3636 {
3637 if (m_files.empty()) {
@@ -3230,7 +3543,9 @@ $(function() {
3646 throw std::runtime_error("state mismatch");
3647 }
3648 }
+
3649
+
3650 virtual void close()
3651 {
3652 if (m_files.empty()) {
@@ -3247,7 +3562,9 @@ $(function() {
3663 m_tmp.clear();
3664 m_tmp.shrink_to_fit();
3665 }
+
3666
+
3667 virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg)
3668 {
3669 if (m_files.empty()) {
@@ -3264,7 +3581,9 @@ $(function() {
3680 }
3681 return result;
3682 }
+
3683
+
3684 virtual fpos_t tell() const
3685 {
3686 if (m_files.empty())
@@ -3276,7 +3595,9 @@ $(function() {
3692 }
3693 return result;
3694 }
+
3695
+
3696 virtual void lock(_In_ fpos_t offset, _In_ fsize_t length)
3697 {
3698 if (m_files.empty())
@@ -3289,7 +3610,9 @@ $(function() {
3705 throw std::runtime_error("state mismatch");
3706 }
3707 }
+
3708
+
3709 virtual void unlock(_In_ fpos_t offset, _In_ fsize_t length)
3710 {
3711 if (m_files.empty())
@@ -3302,7 +3625,9 @@ $(function() {
3718 throw std::runtime_error("state mismatch");
3719 }
3720 }
+
3721
+
3722 virtual fsize_t size()
3723 {
3724 if (m_files.empty()) {
@@ -3319,7 +3644,9 @@ $(function() {
3735 }
3736 return result;
3737 }
+
3738
+
3739 virtual void truncate()
3740 {
3741 if (m_files.empty())
@@ -3332,11 +3659,13 @@ $(function() {
3748 throw std::runtime_error("state mismatch");
3749 }
3750 }
+
3751
3752 protected:
3753 std::vector<basic_file*> m_files;
3754 std::vector<uint8_t> m_tmp;
3755 };
+
3756 }
3757}
Provides read-ahead stream capability.
Definition stream.hpp:1116
@@ -3423,8 +3752,8 @@ $(function() {
virtual void set_atime(time_point date)
Sets file access time.
Definition stream.hpp:1962
virtual fpos_t seek(foff_t offset, seek_t how=seek_t::beg)
Seeks to specified relative file position.
Definition stream.hpp:1874
Cached file-system file.
Definition stream.hpp:2743
-
cached_file(const sys_char *filename, int mode, size_t cache_size=default_cache_size)
Opens file.
Definition stream.hpp:2759
-
void open(const sys_char *filename, int mode)
Opens file.
Definition stream.hpp:2778
+
void open(const schar_t *filename, int mode)
Opens file.
Definition stream.hpp:2778
+
cached_file(const schar_t *filename, int mode, size_t cache_size=default_cache_size)
Opens file.
Definition stream.hpp:2759
Modifies data on the fly when reading from/writing to a source stream.
Definition stream.hpp:888
virtual void flush()
Persists volatile element data.
Definition stream.hpp:934
virtual void close()
Closes the stream.
Definition stream.hpp:928
@@ -3461,12 +3790,12 @@ $(function() {
File-system file.
Definition stream.hpp:2433
virtual time_point mtime() const
Returns file modification time.
Definition stream.hpp:2676
virtual void unlock(fpos_t offset, fsize_t length)
Unlocks file section for exclusive access.
Definition stream.hpp:2569
-
file(const sys_char *filename, int mode)
Opens file.
Definition stream.hpp:2443
+
file(const schar_t *filename, int mode)
Opens file.
Definition stream.hpp:2443
virtual void set_ctime(time_point date)
Sets file create time.
Definition stream.hpp:2690
virtual time_point atime() const
Returns file access time.
Definition stream.hpp:2662
+
void open(const schar_t *filename, int mode)
Opens file.
Definition stream.hpp:2454
virtual void set_mtime(time_point date)
Sets file modification time.
Definition stream.hpp:2720
virtual void set_atime(time_point date)
Sets file access time.
Definition stream.hpp:2702
-
void open(const sys_char *filename, int mode)
Opens file.
Definition stream.hpp:2454
virtual void lock(fpos_t offset, fsize_t length)
Locks file section for exclusive access.
Definition stream.hpp:2546
virtual void truncate()
Sets file size - truncates the remainder of file content from the current file position to the end of...
Definition stream.hpp:2612
virtual time_point ctime() const
Returns file creation time.
Definition stream.hpp:2652
@@ -3479,7 +3808,7 @@ $(function() {
virtual size_t write(_In_reads_bytes_opt_(length) const void *data, size_t length)
Writes block of data to the stream.
Definition stream.hpp:1446
fsize_t write_limit
Number of bytes left, that can be written to the stream.
Definition stream.hpp:1474
In-memory file.
Definition stream.hpp:2806
-
void load(const sys_char *filename, int mode)
Loads content from a file-system file.
Definition stream.hpp:2930
+
memory_file(const schar_t *filename, int mode)
Loads content from file-system file.
Definition stream.hpp:2884
size_t m_size
file size
Definition stream.hpp:3473
void get(fpos_t offset, T &data)
Reads data from specified file location This does not move file pointer. It checks for data size asse...
Definition stream.hpp:3406
size_t write_stream(basic &stream, size_t amount=SIZE_MAX)
Writes content of another stream.
Definition stream.hpp:3228
@@ -3495,7 +3824,8 @@ $(function() {
void write_byte(uint8_t byte, size_t amount=1)
Writes a byte of data.
Definition stream.hpp:3122
void set(fpos_t offset, const T data)
Writes data to specified file location This does not move file pointer nor update file size....
Definition stream.hpp:3369
size_t m_offset
file pointer
Definition stream.hpp:3472
-
memory_file(const sys_char *filename, int mode)
Loads content from file-system file.
Definition stream.hpp:2884
+
void save(const schar_t *filename, int mode)
Saves content to a file-system file.
Definition stream.hpp:2963
+
void load(const schar_t *filename, int mode)
Loads content from a file-system file.
Definition stream.hpp:2930
virtual fsize_t size()
Returns file size Should the file size cannot be determined, the method returns fsize_max and it does...
Definition stream.hpp:3314
virtual fpos_t seek(foff_t offset, seek_t how=seek_t::beg)
Seeks to specified relative file position.
Definition stream.hpp:3292
virtual void truncate()
Sets file size - truncates the remainder of file content from the current file position to the end of...
Definition stream.hpp:3319
@@ -3504,7 +3834,6 @@ $(function() {
bool m_manage
may reallocate m_data?
Definition stream.hpp:3471
memory_file(void *data, size_t size, bool manage=false, state_t state=state_t::ok)
Creates a file based on available data.
Definition stream.hpp:2874
virtual size_t write(_In_reads_bytes_opt_(length) const void *data, size_t length)
Writes block of data to the stream.
Definition stream.hpp:3098
-
void save(const sys_char *filename, int mode)
Saves content to a file-system file.
Definition stream.hpp:2963
memory_file(void *data, size_t size, size_t reserved, bool manage=false, state_t state=state_t::ok)
Creates a file based on available data.
Definition stream.hpp:2851
const void * data() const
Returns pointer to data.
Definition stream.hpp:2986
Definition stream.hpp:1031
@@ -3523,8 +3852,8 @@ $(function() {
virtual size_t write(_In_reads_bytes_opt_(length) const void *data, size_t length)
Writes block of data to the stream.
Definition stream.hpp:1522
virtual size_t read(_Out_writes_bytes_to_opt_(length, return) void *data, size_t length)
Reads block of data from the stream.
Definition stream.hpp:1489
fpos_t read_offset
Number of bytes to skip on read.
Definition stream.hpp:1564
-
Operating system object (file, pipe, anything with an OS handle etc.)
Definition system.hpp:64
-
virtual void close()
Closes object.
Definition system.hpp:105
+
Operating system object (file, pipe, anything with an OS handle etc.)
Definition system.hpp:76
+
virtual void close()
Closes object.
Definition system.hpp:117
Numerical interval.
Definition interval.hpp:18
bool contains(T x) const
Is value in interval?
Definition interval.hpp:88
bool empty() const
Is interval empty?
Definition interval.hpp:54
@@ -3538,7 +3867,7 @@ $(function() { diff --git a/string_8hpp_source.html b/string_8hpp_source.html index 2096d0206..297614d89 100644 --- a/string_8hpp_source.html +++ b/string_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/string.hpp Source File @@ -30,7 +30,7 @@ - + +
26 using locale_t = ::locale_t;
27#endif
28
+
33 {
+
37 void operator()(_In_ locale_t locale) const
38 {
39 free_locale(locale);
40 }
+
41 };
+
42
46 using locale = std::unique_ptr<__crt_locale_pointers, free_locale_delete>;
47
@@ -839,7 +848,7 @@ $(function() { diff --git a/structstdex_1_1chrono_1_1aosn__date-members.html b/structstdex_1_1chrono_1_1aosn__date-members.html index 357b30715..133a4e75b 100644 --- a/structstdex_1_1chrono_1_1aosn__date-members.html +++ b/structstdex_1_1chrono_1_1aosn__date-members.html @@ -3,7 +3,7 @@ - + stdex: Member List @@ -30,7 +30,7 @@ - + +
43#endif
44
48#if defined(_WIN32)
-
49 using sys_char = TCHAR;
+
49 using schar_t = TCHAR;
50#else
-
51 using sys_char = char;
+
51 using schar_t = char;
52#define _T(x) x
53#endif
54
-
58 using sys_string = std::basic_string<stdex::sys_char>;
-
59
-
63 class sys_object
-
64 {
-
65 public:
-
66 sys_object(_In_opt_ sys_handle h = invalid_handle) : m_h(h) {}
-
67
-
68 sys_object(_In_ const sys_object& other) : m_h(other.m_h != invalid_handle ? duplicate(other.m_h, false) : invalid_handle) {}
-
69
-
70 sys_object& operator =(_In_ const sys_object& other)
-
71 {
-
72 if (this != std::addressof(other)) {
-
73 if (m_h != invalid_handle)
-
74 close(m_h);
-
75 m_h = other.m_h != invalid_handle ? duplicate(other.m_h, false) : invalid_handle;
-
76 }
-
77 return *this;
-
78 }
+
59 using sys_char = schar_t;
+
60
+
64 using sstring = std::basic_string<stdex::schar_t>;
+
65
+
70 using sys_string = sstring;
+
71
+
+ +
76 {
+
77 public:
+
78 sys_object(_In_opt_ sys_handle h = invalid_handle) : m_h(h) {}
79
-
80 sys_object(_Inout_ sys_object&& other) noexcept : m_h(other.m_h)
-
81 {
-
82 other.m_h = invalid_handle;
-
83 }
-
84
-
85 sys_object& operator =(_Inout_ sys_object&& other) noexcept
-
86 {
-
87 if (this != std::addressof(other)) {
-
88 if (m_h != invalid_handle)
-
89 close(m_h);
-
90 m_h = other.m_h;
-
91 other.m_h = invalid_handle;
-
92 }
-
93 return *this;
-
94 }
-
95
-
96 virtual ~sys_object()
-
97 {
-
98 if (m_h != invalid_handle)
-
99 close(m_h);
-
100 }
-
101
-
105 virtual void close()
-
106 {
-
107 if (m_h != invalid_handle) {
-
108 close(m_h);
-
109 m_h = invalid_handle;
-
110 }
-
111 }
-
112
-
116 inline operator bool() const noexcept { return m_h != invalid_handle; }
-
117
-
121 inline sys_handle get() const noexcept { return m_h; }
-
122
-
123 protected:
-
127 static void close(sys_handle h)
-
128 {
-
129#ifdef _WIN32
-
130 if (CloseHandle(h) || GetLastError() == ERROR_INVALID_HANDLE)
-
131#else
-
132 if (close(h) >= 0 || errno == EBADF)
-
133#endif
-
134 return;
-
135 throw std::runtime_error("failed to close handle");
-
136 }
-
137
-
141 static sys_handle duplicate(_In_ sys_handle h, _In_ bool inherit)
-
142 {
-
143 sys_handle h_new;
-
144#ifdef _WIN32
-
145 HANDLE process = GetCurrentProcess();
-
146 if (DuplicateHandle(process, h, process, &h_new, 0, inherit, DUPLICATE_SAME_ACCESS))
-
147#else
-
148 UNREFERENCED_PARAMETER(inherit);
-
149 if ((h_new = dup(h)) >= 0)
-
150#endif
-
151 return h_new;
-
152 throw std::runtime_error("failed to duplicate handle");
-
153 }
-
154
-
155 protected:
-
156 sys_handle m_h;
-
157 };
-
158
-
159#ifdef _WIN32
-
160 template <class T>
-
161 class safearray_accessor
-
162 {
-
163 public:
-
164 safearray_accessor(_In_ LPSAFEARRAY sa) : m_sa(sa)
-
165 {
-
166 HRESULT hr = SafeArrayAccessData(sa, reinterpret_cast<void HUGEP**>(&m_data));
-
167 if (FAILED(hr))
-
168 throw std::invalid_argument("SafeArrayAccessData failed");
-
169 }
+
80 sys_object(_In_ const sys_object& other) : m_h(other.m_h != invalid_handle ? duplicate(other.m_h, false) : invalid_handle) {}
+
81
+
82 sys_object& operator =(_In_ const sys_object& other)
+
83 {
+
84 if (this != std::addressof(other)) {
+
85 if (m_h != invalid_handle)
+
86 close(m_h);
+
87 m_h = other.m_h != invalid_handle ? duplicate(other.m_h, false) : invalid_handle;
+
88 }
+
89 return *this;
+
90 }
+
91
+
92 sys_object(_Inout_ sys_object&& other) noexcept : m_h(other.m_h)
+
93 {
+
94 other.m_h = invalid_handle;
+
95 }
+
96
+
97 sys_object& operator =(_Inout_ sys_object&& other) noexcept
+
98 {
+
99 if (this != std::addressof(other)) {
+
100 if (m_h != invalid_handle)
+
101 close(m_h);
+
102 m_h = other.m_h;
+
103 other.m_h = invalid_handle;
+
104 }
+
105 return *this;
+
106 }
+
107
+
108 virtual ~sys_object()
+
109 {
+
110 if (m_h != invalid_handle)
+
111 close(m_h);
+
112 }
+
113
+
+
117 virtual void close()
+
118 {
+
119 if (m_h != invalid_handle) {
+
120 close(m_h);
+
121 m_h = invalid_handle;
+
122 }
+
123 }
+
+
124
+
128 inline operator bool() const noexcept { return m_h != invalid_handle; }
+
129
+
133 inline sys_handle get() const noexcept { return m_h; }
+
134
+
135 protected:
+
+
139 static void close(sys_handle h)
+
140 {
+
141#ifdef _WIN32
+
142 if (CloseHandle(h) || GetLastError() == ERROR_INVALID_HANDLE)
+
143#else
+
144 if (close(h) >= 0 || errno == EBADF)
+
145#endif
+
146 return;
+
147 throw std::runtime_error("failed to close handle");
+
148 }
+
+
149
+
+
153 static sys_handle duplicate(_In_ sys_handle h, _In_ bool inherit)
+
154 {
+
155 sys_handle h_new;
+
156#ifdef _WIN32
+
157 HANDLE process = GetCurrentProcess();
+
158 if (DuplicateHandle(process, h, process, &h_new, 0, inherit, DUPLICATE_SAME_ACCESS))
+
159#else
+
160 UNREFERENCED_PARAMETER(inherit);
+
161 if ((h_new = dup(h)) >= 0)
+
162#endif
+
163 return h_new;
+
164 throw std::runtime_error("failed to duplicate handle");
+
165 }
+
+
166
+
167 protected:
+
168 sys_handle m_h;
+
169 };
+
170
-
171 ~safearray_accessor()
-
172 {
-
173 SafeArrayUnaccessData(m_sa);
-
174 }
-
175
-
176 T* data() const { return m_data; }
-
177
-
178 protected:
-
179 LPSAFEARRAY m_sa;
-
180 T* m_data;
-
181 };
+
171#ifdef _WIN32
+
172 template <class T>
+
173 class safearray_accessor
+
174 {
+
175 public:
+
176 safearray_accessor(_In_ LPSAFEARRAY sa) : m_sa(sa)
+
177 {
+
178 HRESULT hr = SafeArrayAccessData(sa, reinterpret_cast<void HUGEP**>(&m_data));
+
179 if (FAILED(hr))
+
180 throw std::invalid_argument("SafeArrayAccessData failed");
+
181 }
182
-
186 struct SafeArrayDestroy_delete
-
187 {
-
191 void operator()(_In_ LPSAFEARRAY sa) const
-
192 {
-
193 SafeArrayDestroy(sa);
-
194 }
-
195 };
-
196
-
200 struct SysFreeString_delete
-
201 {
-
205 void operator()(_In_ BSTR sa) const
-
206 {
-
207 SysFreeString(sa);
-
208 }
-
209 };
-
210#endif
-
211}
-
Operating system object (file, pipe, anything with an OS handle etc.)
Definition system.hpp:64
-
sys_handle get() const noexcept
Returns object handle.
Definition system.hpp:121
-
virtual void close()
Closes object.
Definition system.hpp:105
-
static sys_handle duplicate(sys_handle h, bool inherit)
Duplicates given object.
Definition system.hpp:141
-
static void close(sys_handle h)
Closes object.
Definition system.hpp:127
+
183 ~safearray_accessor()
+
184 {
+
185 SafeArrayUnaccessData(m_sa);
+
186 }
+
187
+
188 T* data() const { return m_data; }
+
189
+
190 protected:
+
191 LPSAFEARRAY m_sa;
+
192 T* m_data;
+
193 };
+
194
+
198 struct SafeArrayDestroy_delete
+
199 {
+
203 void operator()(_In_ LPSAFEARRAY sa) const
+
204 {
+
205 SafeArrayDestroy(sa);
+
206 }
+
207 };
+
208
+
212 struct SysFreeString_delete
+
213 {
+
217 void operator()(_In_ BSTR sa) const
+
218 {
+
219 SysFreeString(sa);
+
220 }
+
221 };
+
222#endif
+
223}
+
Operating system object (file, pipe, anything with an OS handle etc.)
Definition system.hpp:76
+
sys_handle get() const noexcept
Returns object handle.
Definition system.hpp:133
+
virtual void close()
Closes object.
Definition system.hpp:117
+
static sys_handle duplicate(sys_handle h, bool inherit)
Duplicates given object.
Definition system.hpp:153
+
static void close(sys_handle h)
Closes object.
Definition system.hpp:139
diff --git a/unicode_8hpp_source.html b/unicode_8hpp_source.html index 9f35bccfd..4161e8b6f 100644 --- a/unicode_8hpp_source.html +++ b/unicode_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/unicode.hpp Source File @@ -30,7 +30,7 @@ - + +
diff --git a/vector__queue_8hpp_source.html b/vector__queue_8hpp_source.html index dc63aeb1a..1ecc0f52f 100644 --- a/vector__queue_8hpp_source.html +++ b/vector__queue_8hpp_source.html @@ -3,7 +3,7 @@ - + stdex: include/stdex/vector_queue.hpp Source File @@ -30,7 +30,7 @@ - + +
10namespace stdex
11{
15 template <class T>
+
17 {
18 public:
@@ -105,6 +111,7 @@ $(function() {
47 typedef const T* const_pointer;
48
49 public:
+
55 vector_queue(_In_ size_type size_max) :
56 m_data(new value_type[size_max]),
57 m_head(0),
@@ -112,7 +119,9 @@ $(function() {
59 m_size_max(size_max)
60 {
61 }
+
62
+
69 m_data(new value_type[other.m_size_max]),
70 m_head(other.m_head),
@@ -125,12 +134,16 @@ $(function() {
77 m_data[i_l] = other.m_data[i_l];
78 }
79 }
+
80
+
84 virtual ~vector_queue()
85 {
86 if (m_data) delete [] m_data;
87 }
+
88
+
95 m_data (std::move(other.m_data )),
96 m_head (std::move(other.m_head )),
@@ -143,7 +156,9 @@ $(function() {
103 other.m_count = 0;
104 other.m_size_max = 0;
105 }
+
106
+
113 {
114 if (this != std::addressof(other)) {
@@ -162,7 +177,9 @@ $(function() {
127
128 return *this;
129 }
+
130
+
137 {
138 if (this != std::addressof(other)) {
@@ -180,63 +197,85 @@ $(function() {
150
151 return *this;
152 }
+
153
+
158 {
159 return m_count;
160 }
+
161
+
166 {
167 return m_size_max;
168 }
+
169
+
173 void clear()
174 {
175 m_count = 0;
176 }
+
177
+
181 bool empty() const
182 {
183 return m_count == 0;
184 }
+
185
+
192 {
193 if (pos >= m_count) throw std::invalid_argument("Invalid subscript");
194 return m_data[abs(pos)];
195 }
+
196
+
203 {
204 if (pos >= m_count) throw std::invalid_argument("Invalid subscript");
205 return m_data[abs(pos)];
206 }
+
207
+
214 {
215 if (pos >= m_count) throw std::invalid_argument("Invalid subscript");
216 return m_data[abs(pos)];
217 }
+
218
+
225 {
226 if (pos >= m_count) throw std::invalid_argument("Invalid subscript");
227 return m_data[abs(pos)];
228 }
+
229
+
238 {
239 if (pos >= m_size_max) throw std::invalid_argument("Invalid subscript");
240 return m_data[pos];
241 }
+
242
+
251 {
252 if (pos >= m_size_max) throw std::invalid_argument("Invalid subscript");
253 return m_data[pos];
254 }
+
255
+
264 {
265 if (m_count < m_size_max) {
@@ -251,7 +290,9 @@ $(function() {
274 return pos;
275 }
276 }
+
277
+
286 {
287 if (m_count < m_size_max) {
@@ -266,13 +307,17 @@ $(function() {
296 return pos;
297 }
298 }
+
299
+
303 void pop_back()
304 {
305 if (!m_count) throw std::invalid_argument("Empty storage");
306 m_count--;
307 }
+
308
+
317 {
318 m_head = abs(-1);
@@ -281,7 +326,9 @@ $(function() {
321 m_data[m_head] = v;
322 return m_head;
323 }
+
324
+
333 {
334 m_head = abs(-1);
@@ -290,51 +337,68 @@ $(function() {
337 m_data[m_head] = std::move(v);
338 return m_head;
339 }
+
340
+
345 {
346 if (!m_count) throw std::invalid_argument("Empty storage");
347 m_head = abs(1);
348 m_count--;
349 }
+
350
+
355 {
356 if (!m_count) throw std::invalid_argument("Empty storage");
357 return m_data[m_head];
358 }
+
359
+
364 {
365 if (!m_count) throw std::invalid_argument("Empty storage");
366 return m_data[m_head];
367 }
+
368
+
373 {
374 return m_data[tail()];
375 }
+
376
+
381 {
382 return m_data[tail()];
383 }
+
384
+
389 {
390 return m_head;
391 }
+
392
+
397 {
398 if (!m_count) throw std::invalid_argument("Empty storage");
399 return abs(m_count - 1);
400 }
+
401
+
405 size_type abs(_In_ size_type pos) const
406 {
407 return (m_head + pos) % m_size_max;
408 }
+
409
410 protected:
@@ -342,6 +406,7 @@ $(function() {
415 };
+
416}
Helper class to allow limited size FIFO queues implemented as vector of elements.
Definition vector_queue.hpp:17
vector_queue< value_type > & operator=(const vector_queue< value_type > &other)
Copies existing queue.
Definition vector_queue.hpp:112
@@ -386,7 +451,7 @@ $(function() {