Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba
- pjl-misc
- Merge into trunk
Proposed by
Paul J. Lucas
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 11205 |
Merged at revision: | 11445 |
Proposed branch: | lp:~paul-lucas/zorba/pjl-misc |
Merge into: | lp:zorba |
Diff against target: |
3663 lines (+694/-521) 52 files modified
bin/zorbacmd.cpp (+0/-1) include/zorba/internal/ztd.h (+8/-3) src/api/serialization/serializer.cpp (+2/-2) src/api/zorba_functions.cpp (+1/-1) src/compiler/parser/symbol_table.cpp (+4/-4) src/compiler/parser/xqdoc_comment.cpp (+3/-3) src/compiler/translator/translator.cpp (+2/-2) src/runtime/core/constructors.cpp (+1/-1) src/runtime/durations_dates_times/format_dateTime.cpp (+6/-6) src/runtime/numerics/format_number.cpp (+1/-1) src/runtime/qnames/qnames_impl.cpp (+4/-4) src/runtime/strings/strings_impl.cpp (+2/-2) src/store/naive/atomic_items.cpp (+1/-1) src/store/naive/simple_item_factory.cpp (+2/-2) src/types/casting.cpp (+10/-10) src/types/schema/XercesParseUtils.cpp (+23/-23) src/types/schema/schema.cpp (+1/-1) src/types/schema/validate.cpp (+1/-1) src/unit_tests/test_string.cpp (+17/-17) src/util/ascii_util.cpp (+1/-1) src/util/ascii_util.h (+151/-79) src/util/ascii_util.tcc (+26/-42) src/util/base64_util.h (+12/-6) src/util/error_util.h (+1/-4) src/util/fs_util.h (+20/-54) src/util/hexbinary_util.cpp (+2/-2) src/util/hexbinary_util.h (+9/-5) src/util/icu_streambuf.cpp (+1/-1) src/util/json_util.h (+1/-3) src/util/passthru_streambuf.cpp (+1/-1) src/util/stl_util.h (+1/-1) src/util/stream_util.cpp (+1/-1) src/util/string_util.cpp (+3/-3) src/util/string_util.h (+95/-49) src/util/time_parse.cpp (+3/-3) src/util/time_parse.h (+5/-13) src/util/time_util.h (+1/-4) src/util/unicode_util.h (+3/-2) src/util/uri_util.h (+28/-13) src/util/uri_util.tcc (+4/-1) src/util/utf8_util.h (+138/-69) src/util/utf8_util.tcc (+24/-9) src/util/utf8_util_base.h (+1/-4) src/util/xml_util.h (+36/-14) src/zorbatypes/URI.cpp (+2/-2) src/zorbatypes/binary.cpp (+1/-1) src/zorbatypes/datetime/datetimetype.cpp (+16/-16) src/zorbatypes/datetime/duration.cpp (+7/-7) src/zorbatypes/datetime/timezone.cpp (+3/-3) src/zorbatypes/decimal.cpp (+1/-1) src/zorbatypes/floatimpl.cpp (+2/-2) src/zorbautils/locale.h (+5/-20) |
To merge this branch: | bzr merge lp:~paul-lucas/zorba/pjl-misc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+163078@code.launchpad.net |
Commit message
Util function argument bullet-proofing and clean-up.
Description of the change
Util function argument bullet-proofing and clean-up.
To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job pjl-misc-
All tests succeeded!
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve.
Revision history for this message
Matthias Brantner (matthias-brantner) : | # |
review:
Approve
Revision history for this message
Matthias Brantner (matthias-brantner) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job pjl-misc-
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/zorbacmd.cpp' | |||
2 | --- bin/zorbacmd.cpp 2013-03-21 23:41:00 +0000 | |||
3 | +++ bin/zorbacmd.cpp 2013-05-09 00:49:28 +0000 | |||
4 | @@ -662,7 +662,6 @@ | |||
5 | 662 | TimingInfo& timing) | 662 | TimingInfo& timing) |
6 | 663 | { | 663 | { |
7 | 664 | unsigned long lNumExecutions = properties.multiple(); | 664 | unsigned long lNumExecutions = properties.multiple(); |
8 | 665 | bool lIndent = properties.indent(); | ||
9 | 666 | bool doTiming = properties.timing(); | 665 | bool doTiming = properties.timing(); |
10 | 667 | bool serializePlan = properties.serializePlan(); | 666 | bool serializePlan = properties.serializePlan(); |
11 | 668 | bool savePlan = properties.savePlan(); | 667 | bool savePlan = properties.savePlan(); |
12 | 669 | 668 | ||
13 | === modified file 'include/zorba/internal/ztd.h' | |||
14 | --- include/zorba/internal/ztd.h 2013-02-07 17:24:36 +0000 | |||
15 | +++ include/zorba/internal/ztd.h 2013-05-09 00:49:28 +0000 | |||
16 | @@ -258,6 +258,11 @@ | |||
17 | 258 | ZORBA_DECL_HAS_MEM_FN( str ); | 258 | ZORBA_DECL_HAS_MEM_FN( str ); |
18 | 259 | ZORBA_DECL_HAS_MEM_FN( toString ); | 259 | ZORBA_DECL_HAS_MEM_FN( toString ); |
19 | 260 | 260 | ||
20 | 261 | #define ZORBA_HAS_C_STR(T) \ | ||
21 | 262 | ::zorba::internal::ztd::has_c_str<T,char const* (T::*)() const>::value | ||
22 | 263 | |||
23 | 264 | #define ZORBA_IS_STRING(T) ZORBA_HAS_C_STR(T) | ||
24 | 265 | |||
25 | 261 | /** | 266 | /** |
26 | 262 | * \internal | 267 | * \internal |
27 | 263 | * Tests whether a given type \a T is a C string type. | 268 | * Tests whether a given type \a T is a C string type. |
28 | @@ -310,7 +315,7 @@ | |||
29 | 310 | */ | 315 | */ |
30 | 311 | template<class T> inline | 316 | template<class T> inline |
31 | 312 | typename std::enable_if<!has_insertion_operator<T>::value | 317 | typename std::enable_if<!has_insertion_operator<T>::value |
33 | 313 | && has_c_str<T,char const* (T::*)() const>::value, | 318 | && ZORBA_HAS_C_STR(T), |
34 | 314 | std::string>::type | 319 | std::string>::type |
35 | 315 | to_string( T const &t ) { | 320 | to_string( T const &t ) { |
36 | 316 | return t.c_str(); | 321 | return t.c_str(); |
37 | @@ -331,7 +336,7 @@ | |||
38 | 331 | */ | 336 | */ |
39 | 332 | template<class T> inline | 337 | template<class T> inline |
40 | 333 | typename std::enable_if<!has_insertion_operator<T>::value | 338 | typename std::enable_if<!has_insertion_operator<T>::value |
42 | 334 | && !has_c_str<T,char const* (T::*)() const>::value | 339 | && !ZORBA_HAS_C_STR(T) |
43 | 335 | && has_str<T,std::string (T::*)() const>::value | 340 | && has_str<T,std::string (T::*)() const>::value |
44 | 336 | && !has_toString<T,std::string (T::*)() const>::value, | 341 | && !has_toString<T,std::string (T::*)() const>::value, |
45 | 337 | std::string>::type | 342 | std::string>::type |
46 | @@ -354,7 +359,7 @@ | |||
47 | 354 | */ | 359 | */ |
48 | 355 | template<class T> inline | 360 | template<class T> inline |
49 | 356 | typename std::enable_if<!has_insertion_operator<T>::value | 361 | typename std::enable_if<!has_insertion_operator<T>::value |
51 | 357 | && !has_c_str<T,char const* (T::*)() const>::value | 362 | && !ZORBA_HAS_C_STR(T) |
52 | 358 | && !has_str<T,std::string (T::*)() const>::value | 363 | && !has_str<T,std::string (T::*)() const>::value |
53 | 359 | && has_toString<T,std::string (T::*)() const>::value, | 364 | && has_toString<T,std::string (T::*)() const>::value, |
54 | 360 | std::string>::type | 365 | std::string>::type |
55 | 361 | 366 | ||
56 | === modified file 'src/api/serialization/serializer.cpp' | |||
57 | --- src/api/serialization/serializer.cpp 2013-05-08 20:14:47 +0000 | |||
58 | +++ src/api/serialization/serializer.cpp 2013-05-09 00:49:28 +0000 | |||
59 | @@ -568,7 +568,7 @@ | |||
60 | 568 | 568 | ||
61 | 569 | // Put a space between consecutive text nodes (or a text node and an | 569 | // Put a space between consecutive text nodes (or a text node and an |
62 | 570 | // atomic item), unless the text node contains whitespace only. | 570 | // atomic item), unless the text node contains whitespace only. |
64 | 571 | if (!ascii::is_whitespace(text.c_str())) | 571 | if (!ascii::is_space(text.c_str())) |
65 | 572 | { | 572 | { |
66 | 573 | thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT; | 573 | thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT; |
67 | 574 | } | 574 | } |
68 | @@ -729,7 +729,7 @@ | |||
69 | 729 | // Ignore whitespace text nodes when doing indentation | 729 | // Ignore whitespace text nodes when doing indentation |
70 | 730 | if (!ser->indent || | 730 | if (!ser->indent || |
71 | 731 | child->getNodeKind() != store::StoreConsts::textNode || | 731 | child->getNodeKind() != store::StoreConsts::textNode || |
73 | 732 | !ascii::is_whitespace(child->getStringValue().c_str())) | 732 | !ascii::is_space(child->getStringValue().c_str())) |
74 | 733 | { | 733 | { |
75 | 734 | emit_node(child, depth); | 734 | emit_node(child, depth); |
76 | 735 | prev_node_kind = child->getNodeKind(); | 735 | prev_node_kind = child->getNodeKind(); |
77 | 736 | 736 | ||
78 | === modified file 'src/api/zorba_functions.cpp' | |||
79 | --- src/api/zorba_functions.cpp 2013-02-07 17:24:36 +0000 | |||
80 | +++ src/api/zorba_functions.cpp 2013-05-09 00:49:28 +0000 | |||
81 | @@ -28,7 +28,7 @@ | |||
82 | 28 | /////////////////////////////////////////////////////////////////////////////// | 28 | /////////////////////////////////////////////////////////////////////////////// |
83 | 29 | 29 | ||
84 | 30 | void trim( String &s ) { | 30 | void trim( String &s ) { |
86 | 31 | ascii::trim_whitespace( s ); | 31 | ascii::trim_space( s ); |
87 | 32 | } | 32 | } |
88 | 33 | 33 | ||
89 | 34 | void trim( String &s, char const *chars ) { | 34 | void trim( String &s, char const *chars ) { |
90 | 35 | 35 | ||
91 | === modified file 'src/compiler/parser/symbol_table.cpp' | |||
92 | --- src/compiler/parser/symbol_table.cpp 2013-05-08 20:14:47 +0000 | |||
93 | +++ src/compiler/parser/symbol_table.cpp 2013-05-09 00:49:28 +0000 | |||
94 | @@ -113,12 +113,12 @@ | |||
95 | 113 | { | 113 | { |
96 | 114 | if (do_trim_start) | 114 | if (do_trim_start) |
97 | 115 | { | 115 | { |
99 | 116 | text = ascii::trim_start_whitespace(text, &length); | 116 | text = ascii::trim_start_space(text, &length); |
100 | 117 | } | 117 | } |
101 | 118 | 118 | ||
102 | 119 | if (do_trim_end) | 119 | if (do_trim_end) |
103 | 120 | { | 120 | { |
105 | 121 | length = ascii::trim_end_whitespace(text, length); | 121 | length = ascii::trim_end_space(text, length); |
106 | 122 | } | 122 | } |
107 | 123 | 123 | ||
108 | 124 | if (!is_eqname) | 124 | if (!is_eqname) |
109 | @@ -146,13 +146,13 @@ | |||
110 | 146 | off_t symbol_table::put_uri(char const* text, size_t length) | 146 | off_t symbol_table::put_uri(char const* text, size_t length) |
111 | 147 | { | 147 | { |
112 | 148 | // trim whitespace | 148 | // trim whitespace |
114 | 149 | text = ascii::trim_whitespace(text, &length); | 149 | text = ascii::trim_space(text, &length); |
115 | 150 | 150 | ||
116 | 151 | // normalize whitespace | 151 | // normalize whitespace |
117 | 152 | string result; | 152 | string result; |
118 | 153 | if (! decode_string (text, length, &result)) | 153 | if (! decode_string (text, length, &result)) |
119 | 154 | return -1; | 154 | return -1; |
121 | 155 | ascii::normalize_whitespace( result ); | 155 | ascii::normalize_space( result ); |
122 | 156 | 156 | ||
123 | 157 | return heap.put (result.c_str (), 0, result.length ()); | 157 | return heap.put (result.c_str (), 0, result.length ()); |
124 | 158 | } | 158 | } |
125 | 159 | 159 | ||
126 | === modified file 'src/compiler/parser/xqdoc_comment.cpp' | |||
127 | --- src/compiler/parser/xqdoc_comment.cpp 2013-02-07 17:24:36 +0000 | |||
128 | +++ src/compiler/parser/xqdoc_comment.cpp 2013-05-09 00:49:28 +0000 | |||
129 | @@ -78,7 +78,7 @@ | |||
130 | 78 | 78 | ||
131 | 79 | // if the line contains an annotation, than we finish the description | 79 | // if the line contains an annotation, than we finish the description |
132 | 80 | zstring lTmp; | 80 | zstring lTmp; |
134 | 81 | ascii::trim_whitespace( lLine, &lTmp ); | 81 | ascii::trim_space( lLine, &lTmp ); |
135 | 82 | if ( !lTmp.empty() && lTmp[0] == '@' ) { | 82 | if ( !lTmp.empty() && lTmp[0] == '@' ) { |
136 | 83 | lDescriptionState = false; | 83 | lDescriptionState = false; |
137 | 84 | if (!lAnntotation.empty()) { | 84 | if (!lAnntotation.empty()) { |
138 | @@ -102,7 +102,7 @@ | |||
139 | 102 | XQDocComment::startsWithColon(zstring& aLine) | 102 | XQDocComment::startsWithColon(zstring& aLine) |
140 | 103 | { | 103 | { |
141 | 104 | zstring temp; | 104 | zstring temp; |
143 | 105 | ascii::trim_whitespace( aLine, &temp ); | 105 | ascii::trim_space( aLine, &temp ); |
144 | 106 | 106 | ||
145 | 107 | if ( !temp.empty() && temp[0] == ':' ) { | 107 | if ( !temp.empty() && temp[0] == ':' ) { |
146 | 108 | aLine = temp.substr(1); | 108 | aLine = temp.substr(1); |
147 | @@ -126,7 +126,7 @@ | |||
148 | 126 | } | 126 | } |
149 | 127 | 127 | ||
150 | 128 | ascii::to_lower( lName ); | 128 | ascii::to_lower( lName ); |
152 | 129 | ascii::normalize_whitespace( lValue ); | 129 | ascii::normalize_space( lValue ); |
153 | 130 | 130 | ||
154 | 131 | if ("version" == lName) { | 131 | if ("version" == lName) { |
155 | 132 | theVersion = lValue; | 132 | theVersion = lValue; |
156 | 133 | 133 | ||
157 | === modified file 'src/compiler/translator/translator.cpp' | |||
158 | --- src/compiler/translator/translator.cpp 2013-05-08 20:14:47 +0000 | |||
159 | +++ src/compiler/translator/translator.cpp 2013-05-09 00:49:28 +0000 | |||
160 | @@ -13567,7 +13567,7 @@ | |||
161 | 13567 | if (lPrevIsBoundary) | 13567 | if (lPrevIsBoundary) |
162 | 13568 | { | 13568 | { |
163 | 13569 | zstring content = v.get_elem_content().str(); | 13569 | zstring content = v.get_elem_content().str(); |
165 | 13570 | utf8::trim_whitespace(content); | 13570 | utf8::trim_space(content); |
166 | 13571 | 13571 | ||
167 | 13572 | // Filtering out of whitespaces | 13572 | // Filtering out of whitespaces |
168 | 13573 | if (content.empty()) | 13573 | if (content.empty()) |
169 | @@ -14800,7 +14800,7 @@ | |||
170 | 14800 | // is not in the lexical space of NCName, a type error is raised [err:XPTY0004] | 14800 | // is not in the lexical space of NCName, a type error is raised [err:XPTY0004] |
171 | 14801 | 14801 | ||
172 | 14802 | zstring lNormalizedTarget; | 14802 | zstring lNormalizedTarget; |
174 | 14803 | ascii::normalize_whitespace(target, &lNormalizedTarget); | 14803 | ascii::normalize_space(target, &lNormalizedTarget); |
175 | 14804 | 14804 | ||
176 | 14805 | if (!GenericCast::castableToNCName(lNormalizedTarget)) | 14805 | if (!GenericCast::castableToNCName(lNormalizedTarget)) |
177 | 14806 | { | 14806 | { |
178 | 14807 | 14807 | ||
179 | === modified file 'src/runtime/core/constructors.cpp' | |||
180 | --- src/runtime/core/constructors.cpp 2013-03-15 08:22:41 +0000 | |||
181 | +++ src/runtime/core/constructors.cpp 2013-05-09 00:49:28 +0000 | |||
182 | @@ -687,7 +687,7 @@ | |||
183 | 687 | // normalize value of xml:id | 687 | // normalize value of xml:id |
184 | 688 | if (isId) | 688 | if (isId) |
185 | 689 | { | 689 | { |
187 | 690 | ascii::normalize_whitespace(lexicalValue); | 690 | ascii::normalize_space(lexicalValue); |
188 | 691 | } | 691 | } |
189 | 692 | 692 | ||
190 | 693 | GENV_ITEMFACTORY->createUntypedAtomic(typedValue, lexicalValue); | 693 | GENV_ITEMFACTORY->createUntypedAtomic(typedValue, lexicalValue); |
191 | 694 | 694 | ||
192 | === modified file 'src/runtime/durations_dates_times/format_dateTime.cpp' | |||
193 | --- src/runtime/durations_dates_times/format_dateTime.cpp 2013-05-04 20:23:57 +0000 | |||
194 | +++ src/runtime/durations_dates_times/format_dateTime.cpp 2013-05-09 00:49:28 +0000 | |||
195 | @@ -630,7 +630,7 @@ | |||
196 | 630 | zstring::const_iterator *i, | 630 | zstring::const_iterator *i, |
197 | 631 | modifier *mod, QueryLoc const &loc ) { | 631 | modifier *mod, QueryLoc const &loc ) { |
198 | 632 | zstring::const_iterator &j = *i; | 632 | zstring::const_iterator &j = *i; |
200 | 633 | ascii::skip_whitespace( picture_str, &j ); | 633 | ascii::skip_space( picture_str, &j ); |
201 | 634 | if ( j == picture_str.end() || *j == ',' ) { | 634 | if ( j == picture_str.end() || *j == ',' ) { |
202 | 635 | // | 635 | // |
203 | 636 | // Assume that the ',' is the start of the width modifier (hence there is | 636 | // Assume that the ',' is the start of the width modifier (hence there is |
204 | @@ -875,7 +875,7 @@ | |||
205 | 875 | zstring::const_iterator *i, modifier *mod, | 875 | zstring::const_iterator *i, modifier *mod, |
206 | 876 | QueryLoc const &loc ) { | 876 | QueryLoc const &loc ) { |
207 | 877 | zstring::const_iterator &j = *i; | 877 | zstring::const_iterator &j = *i; |
209 | 878 | ascii::skip_whitespace( picture_str, &j ); | 878 | ascii::skip_space( picture_str, &j ); |
210 | 879 | if ( j == picture_str.end() ) | 879 | if ( j == picture_str.end() ) |
211 | 880 | return; | 880 | return; |
212 | 881 | 881 | ||
213 | @@ -965,10 +965,10 @@ | |||
214 | 965 | QueryLoc const &loc ) { | 965 | QueryLoc const &loc ) { |
215 | 966 | zstring::const_iterator &j = *i; | 966 | zstring::const_iterator &j = *i; |
216 | 967 | 967 | ||
218 | 968 | ascii::skip_whitespace( picture_str, &j ); | 968 | ascii::skip_space( picture_str, &j ); |
219 | 969 | if ( j == picture_str.end() || (*j != ',' && *j != ';') ) | 969 | if ( j == picture_str.end() || (*j != ',' && *j != ';') ) |
220 | 970 | return; | 970 | return; |
222 | 971 | ascii::skip_whitespace( picture_str, &++j ); | 971 | ascii::skip_space( picture_str, &++j ); |
223 | 972 | if ( j == picture_str.end() ) | 972 | if ( j == picture_str.end() ) |
224 | 973 | goto bad_width_modifier; | 973 | goto bad_width_modifier; |
225 | 974 | if ( *j == '*' ) { | 974 | if ( *j == '*' ) { |
226 | @@ -987,10 +987,10 @@ | |||
227 | 987 | 987 | ||
228 | 988 | mod->max_width = 0; | 988 | mod->max_width = 0; |
229 | 989 | 989 | ||
231 | 990 | ascii::skip_whitespace( picture_str, &j ); | 990 | ascii::skip_space( picture_str, &j ); |
232 | 991 | if ( j == picture_str.end() || *j != '-' ) | 991 | if ( j == picture_str.end() || *j != '-' ) |
233 | 992 | return; | 992 | return; |
235 | 993 | ascii::skip_whitespace( picture_str, &++j ); | 993 | ascii::skip_space( picture_str, &++j ); |
236 | 994 | if ( j == picture_str.end() ) | 994 | if ( j == picture_str.end() ) |
237 | 995 | goto bad_width_modifier; | 995 | goto bad_width_modifier; |
238 | 996 | if ( *j == '*' ) | 996 | if ( *j == '*' ) |
239 | 997 | 997 | ||
240 | === modified file 'src/runtime/numerics/format_number.cpp' | |||
241 | --- src/runtime/numerics/format_number.cpp 2013-05-04 14:06:36 +0000 | |||
242 | +++ src/runtime/numerics/format_number.cpp 2013-05-09 00:49:28 +0000 | |||
243 | @@ -786,7 +786,7 @@ | |||
244 | 786 | } else { | 786 | } else { |
245 | 787 | 787 | ||
246 | 788 | zstring format_name( format_name_item->getStringValue() ); | 788 | zstring format_name( format_name_item->getStringValue() ); |
248 | 789 | ascii::trim_whitespace( format_name ); | 789 | ascii::trim_space( format_name ); |
249 | 790 | zstring prefix, local; | 790 | zstring prefix, local; |
250 | 791 | if ( !xml::split_name( format_name, &prefix, &local ) || | 791 | if ( !xml::split_name( format_name, &prefix, &local ) || |
251 | 792 | prefix.empty() ) { | 792 | prefix.empty() ) { |
252 | 793 | 793 | ||
253 | === modified file 'src/runtime/qnames/qnames_impl.cpp' | |||
254 | --- src/runtime/qnames/qnames_impl.cpp 2013-02-07 17:24:36 +0000 | |||
255 | +++ src/runtime/qnames/qnames_impl.cpp 2013-05-09 00:49:28 +0000 | |||
256 | @@ -58,7 +58,7 @@ | |||
257 | 58 | { | 58 | { |
258 | 59 | itemQName->getStringValue2(qname); | 59 | itemQName->getStringValue2(qname); |
259 | 60 | 60 | ||
261 | 61 | ascii::trim_whitespace(qname); | 61 | ascii::trim_space(qname); |
262 | 62 | 62 | ||
263 | 63 | index = qname.find(":", 0, 1); | 63 | index = qname.find(":", 0, 1); |
264 | 64 | 64 | ||
265 | @@ -135,14 +135,14 @@ | |||
266 | 135 | { | 135 | { |
267 | 136 | itemURI->getStringValue2(resNs); | 136 | itemURI->getStringValue2(resNs); |
268 | 137 | 137 | ||
270 | 138 | ascii::trim_whitespace(resNs); | 138 | ascii::trim_space(resNs); |
271 | 139 | } | 139 | } |
272 | 140 | 140 | ||
273 | 141 | consumeNext(itemQName, theChild1.getp(), planState ); | 141 | consumeNext(itemQName, theChild1.getp(), planState ); |
274 | 142 | 142 | ||
275 | 143 | itemQName->getStringValue2(qname); | 143 | itemQName->getStringValue2(qname); |
276 | 144 | 144 | ||
278 | 145 | ascii::trim_whitespace(qname); | 145 | ascii::trim_space(qname); |
279 | 146 | 146 | ||
280 | 147 | index = qname.find(":", 0, 1); | 147 | index = qname.find(":", 0, 1); |
281 | 148 | 148 | ||
282 | @@ -295,7 +295,7 @@ | |||
283 | 295 | else | 295 | else |
284 | 296 | { | 296 | { |
285 | 297 | itemPrefix->getStringValue2(prefix); | 297 | itemPrefix->getStringValue2(prefix); |
287 | 298 | ascii::trim_whitespace(prefix); | 298 | ascii::trim_space(prefix); |
288 | 299 | } | 299 | } |
289 | 300 | 300 | ||
290 | 301 | if (!consumeNext(itemElem, theChildren[1].getp(), planState )) | 301 | if (!consumeNext(itemElem, theChildren[1].getp(), planState )) |
291 | 302 | 302 | ||
292 | === modified file 'src/runtime/strings/strings_impl.cpp' | |||
293 | --- src/runtime/strings/strings_impl.cpp 2013-05-06 14:27:15 +0000 | |||
294 | +++ src/runtime/strings/strings_impl.cpp 2013-05-09 00:49:28 +0000 | |||
295 | @@ -767,7 +767,7 @@ | |||
296 | 767 | if (consumeNext(item, theChildren [0].getp(), planState)) | 767 | if (consumeNext(item, theChildren [0].getp(), planState)) |
297 | 768 | { | 768 | { |
298 | 769 | item->getStringValue2(resStr); | 769 | item->getStringValue2(resStr); |
300 | 770 | ascii::normalize_whitespace(resStr); | 770 | ascii::normalize_space(resStr); |
301 | 771 | STACK_PUSH(GENV_ITEMFACTORY->createString(result, resStr), state); | 771 | STACK_PUSH(GENV_ITEMFACTORY->createString(result, resStr), state); |
302 | 772 | } | 772 | } |
303 | 773 | else | 773 | else |
304 | @@ -811,7 +811,7 @@ | |||
305 | 811 | ZORBA_ASSERT(false); | 811 | ZORBA_ASSERT(false); |
306 | 812 | 812 | ||
307 | 813 | item1->getStringValue2(normForm); | 813 | item1->getStringValue2(normForm); |
309 | 814 | ascii::trim_whitespace(normForm); | 814 | ascii::trim_space(normForm); |
310 | 815 | zstring tmp(normForm); | 815 | zstring tmp(normForm); |
311 | 816 | utf8::to_upper(tmp, &normForm); | 816 | utf8::to_upper(tmp, &normForm); |
312 | 817 | } | 817 | } |
313 | 818 | 818 | ||
314 | === modified file 'src/store/naive/atomic_items.cpp' | |||
315 | --- src/store/naive/atomic_items.cpp 2013-05-08 20:14:47 +0000 | |||
316 | +++ src/store/naive/atomic_items.cpp 2013-05-09 00:49:28 +0000 | |||
317 | @@ -570,7 +570,7 @@ | |||
318 | 570 | bool UntypedAtomicItem::castToBoolean(store::Item_t& result) const | 570 | bool UntypedAtomicItem::castToBoolean(store::Item_t& result) const |
319 | 571 | { | 571 | { |
320 | 572 | zstring str; | 572 | zstring str; |
322 | 573 | ascii::trim_whitespace(theValue, &str); | 573 | ascii::trim_space(theValue, &str); |
323 | 574 | bool value = true; | 574 | bool value = true; |
324 | 575 | 575 | ||
325 | 576 | if (ZSTREQ(str, "false") || ZSTREQ(str, "0")) | 576 | if (ZSTREQ(str, "false") || ZSTREQ(str, "0")) |
326 | 577 | 577 | ||
327 | === modified file 'src/store/naive/simple_item_factory.cpp' | |||
328 | --- src/store/naive/simple_item_factory.cpp 2013-04-17 18:37:33 +0000 | |||
329 | +++ src/store/naive/simple_item_factory.cpp 2013-05-09 00:49:28 +0000 | |||
330 | @@ -1222,7 +1222,7 @@ | |||
331 | 1222 | zstring prefix; | 1222 | zstring prefix; |
332 | 1223 | zstring local; | 1223 | zstring local; |
333 | 1224 | 1224 | ||
335 | 1225 | ascii::trim_whitespace(str); | 1225 | ascii::trim_space(str); |
336 | 1226 | zstring::size_type pos = str.rfind(":", str.size(), 1); | 1226 | zstring::size_type pos = str.rfind(":", str.size(), 1); |
337 | 1227 | 1227 | ||
338 | 1228 | if (pos != zstring::npos) | 1228 | if (pos != zstring::npos) |
339 | @@ -2202,7 +2202,7 @@ | |||
340 | 2202 | zstring& textValue, | 2202 | zstring& textValue, |
341 | 2203 | std::vector<zstring>& atomicTextValues) | 2203 | std::vector<zstring>& atomicTextValues) |
342 | 2204 | { | 2204 | { |
344 | 2205 | ascii::normalize_whitespace(textValue); | 2205 | ascii::normalize_space(textValue); |
345 | 2206 | 2206 | ||
346 | 2207 | zstring::size_type start = 0; | 2207 | zstring::size_type start = 0; |
347 | 2208 | zstring::size_type i = 0; | 2208 | zstring::size_type i = 0; |
348 | 2209 | 2209 | ||
349 | === modified file 'src/types/casting.cpp' | |||
350 | --- src/types/casting.cpp 2013-05-08 20:14:47 +0000 | |||
351 | +++ src/types/casting.cpp 2013-05-09 00:49:28 +0000 | |||
352 | @@ -576,7 +576,7 @@ | |||
353 | 576 | zstring::size_type len = strval.size(); | 576 | zstring::size_type len = strval.size(); |
354 | 577 | zstring::size_type pos = 0; | 577 | zstring::size_type pos = 0; |
355 | 578 | 578 | ||
357 | 579 | ascii::skip_whitespace(str, len, &pos); | 579 | ascii::skip_space(str, len, &pos); |
358 | 580 | 580 | ||
359 | 581 | str += pos; | 581 | str += pos; |
360 | 582 | 582 | ||
361 | @@ -606,7 +606,7 @@ | |||
362 | 606 | } | 606 | } |
363 | 607 | 607 | ||
364 | 608 | pos = str - strval.c_str(); | 608 | pos = str - strval.c_str(); |
366 | 609 | ascii::skip_whitespace(strval.c_str(), len, &pos); | 609 | ascii::skip_space(strval.c_str(), len, &pos); |
367 | 610 | 610 | ||
368 | 611 | if (pos != len) | 611 | if (pos != len) |
369 | 612 | { | 612 | { |
370 | @@ -661,7 +661,7 @@ | |||
371 | 661 | 661 | ||
372 | 662 | T1_TO_T2(str, QN) | 662 | T1_TO_T2(str, QN) |
373 | 663 | { | 663 | { |
375 | 664 | ascii::trim_whitespace(strval); | 664 | ascii::trim_space(strval); |
376 | 665 | 665 | ||
377 | 666 | zstring::size_type idx = strval.find(":"); | 666 | zstring::size_type idx = strval.find(":"); |
378 | 667 | zstring::size_type lidx = strval.rfind(":", strval.size(), 1); | 667 | zstring::size_type lidx = strval.rfind(":", strval.size(), 1); |
379 | @@ -713,7 +713,7 @@ | |||
380 | 713 | 713 | ||
381 | 714 | T1_TO_T2(str, NOT) | 714 | T1_TO_T2(str, NOT) |
382 | 715 | { | 715 | { |
384 | 716 | ascii::trim_whitespace(strval); | 716 | ascii::trim_space(strval); |
385 | 717 | 717 | ||
386 | 718 | zstring uri; | 718 | zstring uri; |
387 | 719 | zstring prefix; | 719 | zstring prefix; |
388 | @@ -1736,7 +1736,7 @@ | |||
389 | 1736 | char ch; | 1736 | char ch; |
390 | 1737 | zstring::size_type sz = strval.size(); | 1737 | zstring::size_type sz = strval.size(); |
391 | 1738 | 1738 | ||
393 | 1739 | ascii::trim_whitespace(strval); | 1739 | ascii::trim_space(strval); |
394 | 1740 | 1740 | ||
395 | 1741 | bool spaceSeen = false; | 1741 | bool spaceSeen = false; |
396 | 1742 | 1742 | ||
397 | @@ -1783,7 +1783,7 @@ | |||
398 | 1783 | } | 1783 | } |
399 | 1784 | case store::XS_NMTOKEN: | 1784 | case store::XS_NMTOKEN: |
400 | 1785 | { | 1785 | { |
402 | 1786 | ascii::trim_whitespace(strval); | 1786 | ascii::trim_space(strval); |
403 | 1787 | 1787 | ||
404 | 1788 | if (GenericCast::instance()->castableToNMToken(strval)) | 1788 | if (GenericCast::instance()->castableToNMToken(strval)) |
405 | 1789 | { | 1789 | { |
406 | @@ -1794,7 +1794,7 @@ | |||
407 | 1794 | } | 1794 | } |
408 | 1795 | case store::XS_NAME: | 1795 | case store::XS_NAME: |
409 | 1796 | { | 1796 | { |
411 | 1797 | ascii::trim_whitespace(strval); | 1797 | ascii::trim_space(strval); |
412 | 1798 | 1798 | ||
413 | 1799 | if (GenericCast::instance()->castableToName(strval)) | 1799 | if (GenericCast::instance()->castableToName(strval)) |
414 | 1800 | { | 1800 | { |
415 | @@ -1805,8 +1805,8 @@ | |||
416 | 1805 | } | 1805 | } |
417 | 1806 | case store::XS_NCNAME: | 1806 | case store::XS_NCNAME: |
418 | 1807 | { | 1807 | { |
421 | 1808 | ascii::normalize_whitespace(strval); | 1808 | ascii::normalize_space(strval); |
422 | 1809 | ascii::trim_whitespace(strval); | 1809 | ascii::trim_space(strval); |
423 | 1810 | 1810 | ||
424 | 1811 | if (GenericCast::castableToNCName(strval)) | 1811 | if (GenericCast::castableToNCName(strval)) |
425 | 1812 | { | 1812 | { |
426 | @@ -2665,7 +2665,7 @@ | |||
427 | 2665 | zstring strval; | 2665 | zstring strval; |
428 | 2666 | item->getStringValue2(strval); | 2666 | item->getStringValue2(strval); |
429 | 2667 | 2667 | ||
431 | 2668 | ascii::trim_whitespace(strval); | 2668 | ascii::trim_space(strval); |
432 | 2669 | 2669 | ||
433 | 2670 | zstring::size_type idx = strval.find(":"); | 2670 | zstring::size_type idx = strval.find(":"); |
434 | 2671 | zstring::size_type lidx = strval.rfind(":", strval.size(), 1); | 2671 | zstring::size_type lidx = strval.rfind(":", strval.size(), 1); |
435 | 2672 | 2672 | ||
436 | === modified file 'src/types/schema/XercesParseUtils.cpp' | |||
437 | --- src/types/schema/XercesParseUtils.cpp 2013-05-08 20:14:47 +0000 | |||
438 | +++ src/types/schema/XercesParseUtils.cpp 2013-05-09 00:49:28 +0000 | |||
439 | @@ -463,7 +463,7 @@ | |||
440 | 463 | // remove following if xs:float will be represented by a C float | 463 | // remove following if xs:float will be represented by a C float |
441 | 464 | //textValue = textValue.trim(" \n\r\t",4); | 464 | //textValue = textValue.trim(" \n\r\t",4); |
442 | 465 | zstring textValue2; | 465 | zstring textValue2; |
444 | 466 | utf8::normalize_whitespace(textValue, &textValue2); | 466 | utf8::normalize_space(textValue, &textValue2); |
445 | 467 | try | 467 | try |
446 | 468 | { | 468 | { |
447 | 469 | xs_float const n(textValue2.c_str()); | 469 | xs_float const n(textValue2.c_str()); |
448 | @@ -501,7 +501,7 @@ | |||
449 | 501 | // remove following if xs:float will be represented by a C float | 501 | // remove following if xs:float will be represented by a C float |
450 | 502 | //textValue = textValue.trim(" \n\r\t",4); | 502 | //textValue = textValue.trim(" \n\r\t",4); |
451 | 503 | zstring textValue2; | 503 | zstring textValue2; |
453 | 504 | utf8::normalize_whitespace(textValue, &textValue2); | 504 | utf8::normalize_space(textValue, &textValue2); |
454 | 505 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 505 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
455 | 506 | try { | 506 | try { |
456 | 507 | xs_double const n(textValue2.c_str()); | 507 | xs_double const n(textValue2.c_str()); |
457 | @@ -550,7 +550,7 @@ | |||
458 | 550 | { | 550 | { |
459 | 551 | // optimization posible since there is no pattern to be checked | 551 | // optimization posible since there is no pattern to be checked |
460 | 552 | zstring textValue2; | 552 | zstring textValue2; |
462 | 553 | utf8::normalize_whitespace(textValue, &textValue2); | 553 | utf8::normalize_space(textValue, &textValue2); |
463 | 554 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 554 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
464 | 555 | return factory->createString(result, textValue2); | 555 | return factory->createString(result, textValue2); |
465 | 556 | } | 556 | } |
466 | @@ -562,7 +562,7 @@ | |||
467 | 562 | { | 562 | { |
468 | 563 | // optimization posible since there is no pattern to be checked | 563 | // optimization posible since there is no pattern to be checked |
469 | 564 | zstring textValue2; | 564 | zstring textValue2; |
471 | 565 | utf8::normalize_whitespace(textValue, &textValue2); | 565 | utf8::normalize_space(textValue, &textValue2); |
472 | 566 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 566 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
473 | 567 | 567 | ||
474 | 568 | return factory->createNormalizedString(result, textValue2); | 568 | return factory->createNormalizedString(result, textValue2); |
475 | @@ -580,7 +580,7 @@ | |||
476 | 580 | //return true; | 580 | //return true; |
477 | 581 | 581 | ||
478 | 582 | zstring textValue2; | 582 | zstring textValue2; |
480 | 583 | utf8::normalize_whitespace(textValue, &textValue2); | 583 | utf8::normalize_space(textValue, &textValue2); |
481 | 584 | XMLCh* content = XMLString::transcode(textValue2.c_str()); | 584 | XMLCh* content = XMLString::transcode(textValue2.c_str()); |
482 | 585 | XSValue::DataType datatype = XSValue::dt_token; | 585 | XSValue::DataType datatype = XSValue::dt_token; |
483 | 586 | XSValue::Status status = XSValue::st_Init; | 586 | XSValue::Status status = XSValue::st_Init; |
484 | @@ -607,7 +607,7 @@ | |||
485 | 607 | store::Item_t &result) | 607 | store::Item_t &result) |
486 | 608 | { | 608 | { |
487 | 609 | zstring textValue2; | 609 | zstring textValue2; |
489 | 610 | utf8::normalize_whitespace(textValue, &textValue2); | 610 | utf8::normalize_space(textValue, &textValue2); |
490 | 611 | 611 | ||
491 | 612 | XMLCh* content = XMLString::transcode(textValue2.c_str()); | 612 | XMLCh* content = XMLString::transcode(textValue2.c_str()); |
492 | 613 | XSValue::DataType datatype = XSValue::dt_NMTOKEN; | 613 | XSValue::DataType datatype = XSValue::dt_NMTOKEN; |
493 | @@ -635,7 +635,7 @@ | |||
494 | 635 | store::Item_t &result) | 635 | store::Item_t &result) |
495 | 636 | { | 636 | { |
496 | 637 | zstring textValue2; | 637 | zstring textValue2; |
498 | 638 | utf8::normalize_whitespace(textValue, &textValue2); | 638 | utf8::normalize_space(textValue, &textValue2); |
499 | 639 | 639 | ||
500 | 640 | XMLCh* content = XMLString::transcode(textValue2.c_str()); | 640 | XMLCh* content = XMLString::transcode(textValue2.c_str()); |
501 | 641 | XSValue::DataType datatype = XSValue::dt_Name; | 641 | XSValue::DataType datatype = XSValue::dt_Name; |
502 | @@ -664,7 +664,7 @@ | |||
503 | 664 | store::Item_t &result) | 664 | store::Item_t &result) |
504 | 665 | { | 665 | { |
505 | 666 | zstring textValue2; | 666 | zstring textValue2; |
507 | 667 | utf8::normalize_whitespace(textValue, &textValue2); | 667 | utf8::normalize_space(textValue, &textValue2); |
508 | 668 | 668 | ||
509 | 669 | XMLCh* content = XMLString::transcode(textValue2.c_str()); | 669 | XMLCh* content = XMLString::transcode(textValue2.c_str()); |
510 | 670 | XSValue::DataType datatype = XSValue::dt_NCName; | 670 | XSValue::DataType datatype = XSValue::dt_NCName; |
511 | @@ -692,7 +692,7 @@ | |||
512 | 692 | store::Item_t &result) | 692 | store::Item_t &result) |
513 | 693 | { | 693 | { |
514 | 694 | zstring textValue2; | 694 | zstring textValue2; |
516 | 695 | utf8::normalize_whitespace(textValue, &textValue2); | 695 | utf8::normalize_space(textValue, &textValue2); |
517 | 696 | 696 | ||
518 | 697 | XMLCh* content = XMLString::transcode(textValue.c_str()); | 697 | XMLCh* content = XMLString::transcode(textValue.c_str()); |
519 | 698 | XSValue::DataType datatype = XSValue::dt_ID; | 698 | XSValue::DataType datatype = XSValue::dt_ID; |
520 | @@ -720,7 +720,7 @@ | |||
521 | 720 | store::Item_t &result) | 720 | store::Item_t &result) |
522 | 721 | { | 721 | { |
523 | 722 | zstring textValue2; | 722 | zstring textValue2; |
525 | 723 | utf8::normalize_whitespace(textValue, &textValue2); | 723 | utf8::normalize_space(textValue, &textValue2); |
526 | 724 | 724 | ||
527 | 725 | XMLCh* content = XMLString::transcode(textValue.c_str()); | 725 | XMLCh* content = XMLString::transcode(textValue.c_str()); |
528 | 726 | XSValue::DataType datatype = XSValue::dt_IDREF; | 726 | XSValue::DataType datatype = XSValue::dt_IDREF; |
529 | @@ -748,7 +748,7 @@ | |||
530 | 748 | store::Item_t &result) | 748 | store::Item_t &result) |
531 | 749 | { | 749 | { |
532 | 750 | zstring textValue2; | 750 | zstring textValue2; |
534 | 751 | utf8::normalize_whitespace(textValue, &textValue2); | 751 | utf8::normalize_space(textValue, &textValue2); |
535 | 752 | 752 | ||
536 | 753 | XMLCh* content = XMLString::transcode(textValue2.c_str()); | 753 | XMLCh* content = XMLString::transcode(textValue2.c_str()); |
537 | 754 | XSValue::DataType datatype = XSValue::dt_ENTITY; | 754 | XSValue::DataType datatype = XSValue::dt_ENTITY; |
538 | @@ -776,7 +776,7 @@ | |||
539 | 776 | store::Item_t &result) | 776 | store::Item_t &result) |
540 | 777 | { | 777 | { |
541 | 778 | zstring textValue2; | 778 | zstring textValue2; |
543 | 779 | utf8::normalize_whitespace(textValue, &textValue2); | 779 | utf8::normalize_space(textValue, &textValue2); |
544 | 780 | 780 | ||
545 | 781 | XMLCh* content = XMLString::transcode(textValue2.c_str()); | 781 | XMLCh* content = XMLString::transcode(textValue2.c_str()); |
546 | 782 | XSValue::DataType datatype = XSValue::dt_NOTATION; | 782 | XSValue::DataType datatype = XSValue::dt_NOTATION; |
547 | @@ -834,7 +834,7 @@ | |||
548 | 834 | //return factory->createDateTime(result, year, month, day, hour, minute, sec); | 834 | //return factory->createDateTime(result, year, month, day, hour, minute, sec); |
549 | 835 | xs_dateTime dt; | 835 | xs_dateTime dt; |
550 | 836 | zstring textValue2; | 836 | zstring textValue2; |
552 | 837 | utf8::normalize_whitespace(textValue, &textValue2); | 837 | utf8::normalize_space(textValue, &textValue2); |
553 | 838 | 838 | ||
554 | 839 | // Warning: parsing code is not using Xerces | 839 | // Warning: parsing code is not using Xerces |
555 | 840 | if (0 == DateTime::parseDateTime(textValue2.c_str(), textValue2.size(), dt)) | 840 | if (0 == DateTime::parseDateTime(textValue2.c_str(), textValue2.size(), dt)) |
556 | @@ -874,7 +874,7 @@ | |||
557 | 874 | //return factory->createDate(result, tValue); | 874 | //return factory->createDate(result, tValue); |
558 | 875 | xs_date d; | 875 | xs_date d; |
559 | 876 | zstring textValue2; | 876 | zstring textValue2; |
561 | 877 | utf8::normalize_whitespace(textValue, &textValue2); | 877 | utf8::normalize_space(textValue, &textValue2); |
562 | 878 | 878 | ||
563 | 879 | // Warning: parsing code is not using Xerces | 879 | // Warning: parsing code is not using Xerces |
564 | 880 | if (0 == DateTime::parseDate(textValue2.c_str(), textValue2.size(), d)) | 880 | if (0 == DateTime::parseDate(textValue2.c_str(), textValue2.size(), d)) |
565 | @@ -919,7 +919,7 @@ | |||
566 | 919 | //return factory->createTime(result, tValue); | 919 | //return factory->createTime(result, tValue); |
567 | 920 | xs_time t; | 920 | xs_time t; |
568 | 921 | zstring textValue2; | 921 | zstring textValue2; |
570 | 922 | utf8::normalize_whitespace(textValue, &textValue2); | 922 | utf8::normalize_space(textValue, &textValue2); |
571 | 923 | 923 | ||
572 | 924 | // Warning: parsing code is not using Xerces | 924 | // Warning: parsing code is not using Xerces |
573 | 925 | if (0 == DateTime::parseTime(textValue2.c_str(), textValue2.size(), t)) | 925 | if (0 == DateTime::parseTime(textValue2.c_str(), textValue2.size(), t)) |
574 | @@ -954,7 +954,7 @@ | |||
575 | 954 | xs_gYearMonth tValue; | 954 | xs_gYearMonth tValue; |
576 | 955 | 955 | ||
577 | 956 | zstring textValue2; | 956 | zstring textValue2; |
579 | 957 | utf8::normalize_whitespace(textValue, &textValue2); | 957 | utf8::normalize_space(textValue, &textValue2); |
580 | 958 | 958 | ||
581 | 959 | // Warning: parsing code is not using Xerces | 959 | // Warning: parsing code is not using Xerces |
582 | 960 | if (DateTime::parseGYearMonth(textValue2.c_str(), textValue2.size(), tValue)) | 960 | if (DateTime::parseGYearMonth(textValue2.c_str(), textValue2.size(), tValue)) |
583 | @@ -988,7 +988,7 @@ | |||
584 | 988 | xs_gYear tValue; | 988 | xs_gYear tValue; |
585 | 989 | 989 | ||
586 | 990 | zstring textValue2; | 990 | zstring textValue2; |
588 | 991 | utf8::normalize_whitespace(textValue, &textValue2); | 991 | utf8::normalize_space(textValue, &textValue2); |
589 | 992 | 992 | ||
590 | 993 | // Warning: parsing code is not using Xerces | 993 | // Warning: parsing code is not using Xerces |
591 | 994 | if (DateTime::parseGYear(textValue2.c_str(), textValue2.size(), tValue)) | 994 | if (DateTime::parseGYear(textValue2.c_str(), textValue2.size(), tValue)) |
592 | @@ -1022,7 +1022,7 @@ | |||
593 | 1022 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 1022 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
594 | 1023 | xs_gMonthDay tValue; | 1023 | xs_gMonthDay tValue; |
595 | 1024 | zstring textValue2; | 1024 | zstring textValue2; |
597 | 1025 | utf8::normalize_whitespace(textValue, &textValue2); | 1025 | utf8::normalize_space(textValue, &textValue2); |
598 | 1026 | 1026 | ||
599 | 1027 | // Warning: parsing code is not using Xerces | 1027 | // Warning: parsing code is not using Xerces |
600 | 1028 | if (DateTime::parseGMonthDay(textValue2.c_str(), textValue2.size(), tValue)) | 1028 | if (DateTime::parseGMonthDay(textValue2.c_str(), textValue2.size(), tValue)) |
601 | @@ -1055,7 +1055,7 @@ | |||
602 | 1055 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 1055 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
603 | 1056 | xs_gDay tValue; | 1056 | xs_gDay tValue; |
604 | 1057 | zstring textValue2; | 1057 | zstring textValue2; |
606 | 1058 | utf8::normalize_whitespace(textValue, &textValue2); | 1058 | utf8::normalize_space(textValue, &textValue2); |
607 | 1059 | 1059 | ||
608 | 1060 | // Warning: parsing code is not using Xerces | 1060 | // Warning: parsing code is not using Xerces |
609 | 1061 | if (DateTime::parseGDay(textValue2.c_str(), textValue2.size(), tValue)) | 1061 | if (DateTime::parseGDay(textValue2.c_str(), textValue2.size(), tValue)) |
610 | @@ -1088,7 +1088,7 @@ | |||
611 | 1088 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 1088 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
612 | 1089 | xs_gMonth tValue; | 1089 | xs_gMonth tValue; |
613 | 1090 | zstring textValue2; | 1090 | zstring textValue2; |
615 | 1091 | utf8::normalize_whitespace(textValue, &textValue2); | 1091 | utf8::normalize_space(textValue, &textValue2); |
616 | 1092 | 1092 | ||
617 | 1093 | // Warning: parsing code is not using Xerces | 1093 | // Warning: parsing code is not using Xerces |
618 | 1094 | if (DateTime::parseGMonth(textValue2.c_str(), textValue2.size(), tValue)) | 1094 | if (DateTime::parseGMonth(textValue2.c_str(), textValue2.size(), tValue)) |
619 | @@ -1127,7 +1127,7 @@ | |||
620 | 1127 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 1127 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
621 | 1128 | Duration tValue; | 1128 | Duration tValue; |
622 | 1129 | zstring textValue2; | 1129 | zstring textValue2; |
624 | 1130 | utf8::normalize_whitespace(textValue, &textValue2); | 1130 | utf8::normalize_space(textValue, &textValue2); |
625 | 1131 | 1131 | ||
626 | 1132 | // Warning: parsing code is not using Xerces | 1132 | // Warning: parsing code is not using Xerces |
627 | 1133 | if (0 == Duration::parseDuration(textValue2.c_str(), textValue2.size(), tValue)) | 1133 | if (0 == Duration::parseDuration(textValue2.c_str(), textValue2.size(), tValue)) |
628 | @@ -1263,7 +1263,7 @@ | |||
629 | 1263 | 1263 | ||
630 | 1264 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 1264 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
631 | 1265 | zstring textValue2; | 1265 | zstring textValue2; |
633 | 1266 | utf8::normalize_whitespace(textValue, &textValue2); | 1266 | utf8::normalize_space(textValue, &textValue2); |
634 | 1267 | 1267 | ||
635 | 1268 | return factory->createAnyURI(result, textValue2); | 1268 | return factory->createAnyURI(result, textValue2); |
636 | 1269 | } | 1269 | } |
637 | @@ -1289,7 +1289,7 @@ | |||
638 | 1289 | 1289 | ||
639 | 1290 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 1290 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
640 | 1291 | zstring textValue2; | 1291 | zstring textValue2; |
642 | 1292 | utf8::normalize_whitespace(textValue, &textValue2); | 1292 | utf8::normalize_space(textValue, &textValue2); |
643 | 1293 | 1293 | ||
644 | 1294 | // todo: get the right namespace from the current context | 1294 | // todo: get the right namespace from the current context |
645 | 1295 | zstring lNamespace; | 1295 | zstring lNamespace; |
646 | 1296 | 1296 | ||
647 | === modified file 'src/types/schema/schema.cpp' | |||
648 | --- src/types/schema/schema.cpp 2013-05-02 00:18:56 +0000 | |||
649 | +++ src/types/schema/schema.cpp 2013-05-09 00:49:28 +0000 | |||
650 | @@ -1839,7 +1839,7 @@ | |||
651 | 1839 | std::vector<zstring>& atomicTextValues) | 1839 | std::vector<zstring>& atomicTextValues) |
652 | 1840 | { | 1840 | { |
653 | 1841 | zstring normalizedTextValue; | 1841 | zstring normalizedTextValue; |
655 | 1842 | utf8::normalize_whitespace(textValue, &normalizedTextValue); | 1842 | utf8::normalize_space(textValue, &normalizedTextValue); |
656 | 1843 | 1843 | ||
657 | 1844 | size_t start = 0; | 1844 | size_t start = 0; |
658 | 1845 | size_t i = 0; | 1845 | size_t i = 0; |
659 | 1846 | 1846 | ||
660 | === modified file 'src/types/schema/validate.cpp' | |||
661 | --- src/types/schema/validate.cpp 2013-04-23 20:38:23 +0000 | |||
662 | +++ src/types/schema/validate.cpp 2013-05-09 00:49:28 +0000 | |||
663 | @@ -732,7 +732,7 @@ | |||
664 | 732 | 732 | ||
665 | 733 | // XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/ | 733 | // XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/ |
666 | 734 | // section 6.7.4 Construction from a PSVI | 734 | // section 6.7.4 Construction from a PSVI |
668 | 735 | if ( !utf8::is_whitespace(textNodeValue) ) | 735 | if ( !utf8::is_space(textNodeValue) ) |
669 | 736 | { | 736 | { |
670 | 737 | zstring empty; | 737 | zstring empty; |
671 | 738 | GENV_ITEMFACTORY->createTextNode(validatedTextNode, | 738 | GENV_ITEMFACTORY->createTextNode(validatedTextNode, |
672 | 739 | 739 | ||
673 | === modified file 'src/unit_tests/test_string.cpp' | |||
674 | --- src/unit_tests/test_string.cpp 2013-02-07 17:24:36 +0000 | |||
675 | +++ src/unit_tests/test_string.cpp 2013-05-09 00:49:28 +0000 | |||
676 | @@ -330,16 +330,16 @@ | |||
677 | 330 | } | 330 | } |
678 | 331 | 331 | ||
679 | 332 | template<class StringType> | 332 | template<class StringType> |
681 | 333 | static void test_normalize_whitespace() { | 333 | static void test_normalize_space() { |
682 | 334 | StringType const s( " hello world " ); | 334 | StringType const s( " hello world " ); |
683 | 335 | StringType u; | 335 | StringType u; |
684 | 336 | 336 | ||
686 | 337 | ascii::normalize_whitespace( s, &u ); | 337 | ascii::normalize_space( s, &u ); |
687 | 338 | ASSERT_TRUE( u == "hello world" ); | 338 | ASSERT_TRUE( u == "hello world" ); |
688 | 339 | 339 | ||
689 | 340 | utf8_string<StringType const> const s8( s ); | 340 | utf8_string<StringType const> const s8( s ); |
690 | 341 | utf8_string<StringType> u8( u ); | 341 | utf8_string<StringType> u8( u ); |
692 | 342 | utf8::normalize_whitespace( s8, &u8 ); | 342 | utf8::normalize_space( s8, &u8 ); |
693 | 343 | ASSERT_TRUE( u8 == "hello world" ); | 343 | ASSERT_TRUE( u8 == "hello world" ); |
694 | 344 | } | 344 | } |
695 | 345 | 345 | ||
696 | @@ -493,14 +493,14 @@ | |||
697 | 493 | ASSERT_TRUE( !utf8::ends_with( u_ab, "a" ) ); | 493 | ASSERT_TRUE( !utf8::ends_with( u_ab, "a" ) ); |
698 | 494 | } | 494 | } |
699 | 495 | 495 | ||
701 | 496 | static void test_skip_whitespace() { | 496 | static void test_skip_space() { |
702 | 497 | char const s[] = " hello world"; | 497 | char const s[] = " hello world"; |
703 | 498 | ascii::size_type const s_len = ::strlen( s ); | 498 | ascii::size_type const s_len = ::strlen( s ); |
704 | 499 | ascii::size_type pos = 0; | 499 | ascii::size_type pos = 0; |
706 | 500 | ascii::skip_whitespace( s, s_len, &pos ); | 500 | ascii::skip_space( s, s_len, &pos ); |
707 | 501 | ASSERT_TRUE( pos == 2 ); | 501 | ASSERT_TRUE( pos == 2 ); |
708 | 502 | pos = 7; | 502 | pos = 7; |
710 | 503 | ascii::skip_whitespace( s, s_len, &pos ); | 503 | ascii::skip_space( s, s_len, &pos ); |
711 | 504 | ASSERT_TRUE( pos == 8 ); | 504 | ASSERT_TRUE( pos == 8 ); |
712 | 505 | } | 505 | } |
713 | 506 | 506 | ||
714 | @@ -673,16 +673,16 @@ | |||
715 | 673 | } | 673 | } |
716 | 674 | 674 | ||
717 | 675 | template<class StringType> | 675 | template<class StringType> |
719 | 676 | static void test_trim_whitespace() { | 676 | static void test_trim_space() { |
720 | 677 | StringType const s( " hello world " ); | 677 | StringType const s( " hello world " ); |
721 | 678 | StringType u; | 678 | StringType u; |
722 | 679 | 679 | ||
724 | 680 | ascii::trim_whitespace( s, &u ); | 680 | ascii::trim_space( s, &u ); |
725 | 681 | ASSERT_TRUE( u == "hello world" ); | 681 | ASSERT_TRUE( u == "hello world" ); |
726 | 682 | 682 | ||
727 | 683 | utf8_string<StringType const> const s8( s ); | 683 | utf8_string<StringType const> const s8( s ); |
728 | 684 | utf8_string<StringType> u8( u ); | 684 | utf8_string<StringType> u8( u ); |
730 | 685 | utf8::trim_whitespace( s8, &u8 ); | 685 | utf8::trim_space( s8, &u8 ); |
731 | 686 | ASSERT_TRUE( u8 == "hello world" ); | 686 | ASSERT_TRUE( u8 == "hello world" ); |
732 | 687 | } | 687 | } |
733 | 688 | 688 | ||
734 | @@ -854,10 +854,10 @@ | |||
735 | 854 | test_next_match(); | 854 | test_next_match(); |
736 | 855 | test_next_token(); | 855 | test_next_token(); |
737 | 856 | 856 | ||
742 | 857 | test_normalize_whitespace<string>(); | 857 | test_normalize_space<string>(); |
743 | 858 | test_normalize_whitespace<zstring>(); | 858 | test_normalize_space<zstring>(); |
744 | 859 | test_normalize_whitespace<zstring_p>(); | 859 | test_normalize_space<zstring_p>(); |
745 | 860 | test_normalize_whitespace<String>(); | 860 | test_normalize_space<String>(); |
746 | 861 | 861 | ||
747 | 862 | test_replace_all<string>(); | 862 | test_replace_all<string>(); |
748 | 863 | test_replace_all<String>(); | 863 | test_replace_all<String>(); |
749 | @@ -872,7 +872,7 @@ | |||
750 | 872 | test_reverse<zstring_p>( utf8_aeiou_acute ); | 872 | test_reverse<zstring_p>( utf8_aeiou_acute ); |
751 | 873 | test_reverse<String>( utf8_aeiou_acute ); | 873 | test_reverse<String>( utf8_aeiou_acute ); |
752 | 874 | 874 | ||
754 | 875 | test_skip_whitespace(); | 875 | test_skip_space(); |
755 | 876 | 876 | ||
756 | 877 | test_split<string>( "a", "b" ); | 877 | test_split<string>( "a", "b" ); |
757 | 878 | test_split<zstring>( "a", "b" ); | 878 | test_split<zstring>( "a", "b" ); |
758 | @@ -911,9 +911,9 @@ | |||
759 | 911 | 911 | ||
760 | 912 | test_trim_start(); | 912 | test_trim_start(); |
761 | 913 | test_trim_end(); | 913 | test_trim_end(); |
765 | 914 | test_trim_whitespace<string>(); | 914 | test_trim_space<string>(); |
766 | 915 | test_trim_whitespace<zstring>(); | 915 | test_trim_space<zstring>(); |
767 | 916 | test_trim_whitespace<String>(); | 916 | test_trim_space<String>(); |
768 | 917 | 917 | ||
769 | 918 | test_uri_encode<string>(); | 918 | test_uri_encode<string>(); |
770 | 919 | test_uri_encode<String>(); | 919 | test_uri_encode<String>(); |
771 | 920 | 920 | ||
772 | === modified file 'src/util/ascii_util.cpp' | |||
773 | --- src/util/ascii_util.cpp 2013-03-19 04:22:49 +0000 | |||
774 | +++ src/util/ascii_util.cpp 2013-05-09 00:49:28 +0000 | |||
775 | @@ -30,7 +30,7 @@ | |||
776 | 30 | 30 | ||
777 | 31 | /////////////////////////////////////////////////////////////////////////////// | 31 | /////////////////////////////////////////////////////////////////////////////// |
778 | 32 | 32 | ||
780 | 33 | bool is_whitespace( char const *s ) { | 33 | bool is_space( char const *s ) { |
781 | 34 | for ( ; *s; ++s ) { | 34 | for ( ; *s; ++s ) { |
782 | 35 | if ( !is_space( *s ) ) | 35 | if ( !is_space( *s ) ) |
783 | 36 | return false; | 36 | return false; |
784 | 37 | 37 | ||
785 | === modified file 'src/util/ascii_util.h' | |||
786 | --- src/util/ascii_util.h 2013-05-06 22:57:08 +0000 | |||
787 | +++ src/util/ascii_util.h 2013-05-09 00:49:28 +0000 | |||
788 | @@ -73,7 +73,7 @@ | |||
789 | 73 | * | 73 | * |
790 | 74 | * @param s The string to append to. | 74 | * @param s The string to append to. |
791 | 75 | */ | 75 | */ |
793 | 76 | explicit back_ascii_insert_iterator( StringType &s ) : base_type( s ) { | 76 | explicit back_ascii_insert_iterator( StringType *s ) : base_type( s ) { |
794 | 77 | } | 77 | } |
795 | 78 | 78 | ||
796 | 79 | back_ascii_insert_iterator& operator=( value_type c ); | 79 | back_ascii_insert_iterator& operator=( value_type c ); |
797 | @@ -86,7 +86,7 @@ | |||
798 | 86 | * @param out The output string. | 86 | * @param out The output string. |
799 | 87 | */ | 87 | */ |
800 | 88 | template<class StringType> inline back_ascii_insert_iterator<StringType> | 88 | template<class StringType> inline back_ascii_insert_iterator<StringType> |
802 | 89 | back_ascii_inserter( StringType &out ) { | 89 | back_ascii_inserter( StringType *out ) { |
803 | 90 | return back_ascii_insert_iterator<StringType>( out ); | 90 | return back_ascii_insert_iterator<StringType>( out ); |
804 | 91 | } | 91 | } |
805 | 92 | 92 | ||
806 | @@ -102,7 +102,8 @@ | |||
807 | 102 | * @return Returns \c true only if the character is an ASCII character. | 102 | * @return Returns \c true only if the character is an ASCII character. |
808 | 103 | */ | 103 | */ |
809 | 104 | template<typename CharType> inline | 104 | template<typename CharType> inline |
811 | 105 | bool is_ascii( CharType c ) { | 105 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
812 | 106 | is_ascii( CharType c ) { | ||
813 | 106 | #ifdef WIN32 | 107 | #ifdef WIN32 |
814 | 107 | return __isascii( c ); | 108 | return __isascii( c ); |
815 | 108 | #else | 109 | #else |
816 | @@ -120,7 +121,8 @@ | |||
817 | 120 | * @return Returns \c true only if the character is an alphabetic character. | 121 | * @return Returns \c true only if the character is an alphabetic character. |
818 | 121 | */ | 122 | */ |
819 | 122 | template<typename CharType> inline | 123 | template<typename CharType> inline |
821 | 123 | bool is_alpha( CharType c ) { | 124 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
822 | 125 | is_alpha( CharType c ) { | ||
823 | 124 | return is_ascii( c ) && isalpha( c ); | 126 | return is_ascii( c ) && isalpha( c ); |
824 | 125 | } | 127 | } |
825 | 126 | 128 | ||
826 | @@ -134,7 +136,8 @@ | |||
827 | 134 | * @return Returns \c true only if the character is an alpha-numeric character. | 136 | * @return Returns \c true only if the character is an alpha-numeric character. |
828 | 135 | */ | 137 | */ |
829 | 136 | template<typename CharType> inline | 138 | template<typename CharType> inline |
831 | 137 | bool is_alnum( CharType c ) { | 139 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
832 | 140 | is_alnum( CharType c ) { | ||
833 | 138 | return is_ascii( c ) && isalnum( c ); | 141 | return is_ascii( c ) && isalnum( c ); |
834 | 139 | } | 142 | } |
835 | 140 | 143 | ||
836 | @@ -148,7 +151,8 @@ | |||
837 | 148 | * @return Returns \c true only if the character is a control character. | 151 | * @return Returns \c true only if the character is a control character. |
838 | 149 | */ | 152 | */ |
839 | 150 | template<typename CharType> inline | 153 | template<typename CharType> inline |
841 | 151 | bool is_cntrl( CharType c ) { | 154 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
842 | 155 | is_cntrl( CharType c ) { | ||
843 | 152 | return is_ascii( c ) && iscntrl( c ); | 156 | return is_ascii( c ) && iscntrl( c ); |
844 | 153 | } | 157 | } |
845 | 154 | 158 | ||
846 | @@ -162,7 +166,8 @@ | |||
847 | 162 | * @return Returns \c true only if the character is a decimal digit. | 166 | * @return Returns \c true only if the character is a decimal digit. |
848 | 163 | */ | 167 | */ |
849 | 164 | template<typename CharType> inline | 168 | template<typename CharType> inline |
851 | 165 | bool is_digit( CharType c ) { | 169 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
852 | 170 | is_digit( CharType c ) { | ||
853 | 166 | return is_ascii( c ) && isdigit( c ); | 171 | return is_ascii( c ) && isdigit( c ); |
854 | 167 | } | 172 | } |
855 | 168 | 173 | ||
856 | @@ -176,7 +181,8 @@ | |||
857 | 176 | * @return Returns \c true only if the character is a printing character. | 181 | * @return Returns \c true only if the character is a printing character. |
858 | 177 | */ | 182 | */ |
859 | 178 | template<typename CharType> inline | 183 | template<typename CharType> inline |
861 | 179 | bool is_print( CharType c ) { | 184 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
862 | 185 | is_print( CharType c ) { | ||
863 | 180 | return is_ascii( c ) && isprint( c ); | 186 | return is_ascii( c ) && isprint( c ); |
864 | 181 | } | 187 | } |
865 | 182 | 188 | ||
866 | @@ -190,7 +196,8 @@ | |||
867 | 190 | * @return Returns \c true only if the character is a punctuation character. | 196 | * @return Returns \c true only if the character is a punctuation character. |
868 | 191 | */ | 197 | */ |
869 | 192 | template<typename CharType> inline | 198 | template<typename CharType> inline |
871 | 193 | bool is_punct( CharType c ) { | 199 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
872 | 200 | is_punct( CharType c ) { | ||
873 | 194 | return is_ascii( c ) && ispunct( c ); | 201 | return is_ascii( c ) && ispunct( c ); |
874 | 195 | } | 202 | } |
875 | 196 | 203 | ||
876 | @@ -199,12 +206,13 @@ | |||
877 | 199 | * exists to make a proper function out of the standard isspace(3) that may be | 206 | * exists to make a proper function out of the standard isspace(3) that may be |
878 | 200 | * implemented as a macro. | 207 | * implemented as a macro. |
879 | 201 | * | 208 | * |
881 | 202 | * @param CharType The character type. | 209 | * @tparam CharType The character type. |
882 | 203 | * @param c The character to check. | 210 | * @param c The character to check. |
883 | 204 | * @return Returns \c true only if the character is a whitespace character. | 211 | * @return Returns \c true only if the character is a whitespace character. |
884 | 205 | */ | 212 | */ |
885 | 206 | template<typename CharType> inline | 213 | template<typename CharType> inline |
887 | 207 | bool is_space( CharType c ) { | 214 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
888 | 215 | is_space( CharType c ) { | ||
889 | 208 | return is_ascii( c ) && isspace( c ); | 216 | return is_ascii( c ) && isspace( c ); |
890 | 209 | } | 217 | } |
891 | 210 | 218 | ||
892 | @@ -214,17 +222,19 @@ | |||
893 | 214 | * @param s The NULL-terminated C string to check. | 222 | * @param s The NULL-terminated C string to check. |
894 | 215 | * @return Returns \c true only if the entire string is whitespace. | 223 | * @return Returns \c true only if the entire string is whitespace. |
895 | 216 | */ | 224 | */ |
897 | 217 | bool is_whitespace( char const *s ); | 225 | bool is_space( char const *s ); |
898 | 218 | 226 | ||
899 | 219 | /** | 227 | /** |
900 | 220 | * Checks whether an entire string is whitespace. | 228 | * Checks whether an entire string is whitespace. |
901 | 221 | * | 229 | * |
902 | 230 | * @tparam StringType The string type. | ||
903 | 222 | * @param s The string to check. | 231 | * @param s The string to check. |
904 | 223 | * @return Returns \c true only if the entire string is whitespace. | 232 | * @return Returns \c true only if the entire string is whitespace. |
905 | 224 | */ | 233 | */ |
906 | 225 | template<class StringType> inline | 234 | template<class StringType> inline |
909 | 226 | bool is_whitespace( StringType const &s ) { | 235 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),bool>::type |
910 | 227 | return is_whitespace( s.c_str() ); | 236 | is_space( StringType const &s ) { |
911 | 237 | return is_space( s.c_str() ); | ||
912 | 228 | } | 238 | } |
913 | 229 | 239 | ||
914 | 230 | /** | 240 | /** |
915 | @@ -237,7 +247,8 @@ | |||
916 | 237 | * @return Returns \c true only if the character is a hexadecimal digit. | 247 | * @return Returns \c true only if the character is a hexadecimal digit. |
917 | 238 | */ | 248 | */ |
918 | 239 | template<typename CharType> inline | 249 | template<typename CharType> inline |
920 | 240 | bool is_xdigit( CharType c ) { | 250 | typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type |
921 | 251 | is_xdigit( CharType c ) { | ||
922 | 241 | return is_ascii( c ) && isxdigit( c ); | 252 | return is_ascii( c ) && isxdigit( c ); |
923 | 242 | } | 253 | } |
924 | 243 | 254 | ||
925 | @@ -263,7 +274,8 @@ | |||
926 | 263 | * @return Returns \c true only if \a s begins with \a c. | 274 | * @return Returns \c true only if \a s begins with \a c. |
927 | 264 | */ | 275 | */ |
928 | 265 | template<class StringType> inline | 276 | template<class StringType> inline |
930 | 266 | bool begins_with( StringType const &s, char c ) { | 277 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
931 | 278 | begins_with( StringType const &s, char c ) { | ||
932 | 267 | return !s.empty() && s[0] == c; | 279 | return !s.empty() && s[0] == c; |
933 | 268 | } | 280 | } |
934 | 269 | 281 | ||
935 | @@ -300,8 +312,9 @@ | |||
936 | 300 | * @return Returns \c true only if \a s begins with \a ps. | 312 | * @return Returns \c true only if \a s begins with \a ps. |
937 | 301 | */ | 313 | */ |
938 | 302 | template<class StringType> inline | 314 | template<class StringType> inline |
941 | 303 | bool begins_with( StringType const &s, char const *ps, | 315 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
942 | 304 | typename StringType::size_type n ) { | 316 | begins_with( StringType const &s, char const *ps, |
943 | 317 | typename StringType::size_type n ) { | ||
944 | 305 | typedef typename StringType::traits_type traits_type; | 318 | typedef typename StringType::traits_type traits_type; |
945 | 306 | return n <= s.size() && traits_type::compare( s.data(), ps, n ) == 0; | 319 | return n <= s.size() && traits_type::compare( s.data(), ps, n ) == 0; |
946 | 307 | } | 320 | } |
947 | @@ -315,7 +328,8 @@ | |||
948 | 315 | * @return Returns \c true only if \a s begins with \a ps. | 328 | * @return Returns \c true only if \a s begins with \a ps. |
949 | 316 | */ | 329 | */ |
950 | 317 | template<class StringType> inline | 330 | template<class StringType> inline |
952 | 318 | bool begins_with( StringType const &s, char const *ps ) { | 331 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
953 | 332 | begins_with( StringType const &s, char const *ps ) { | ||
954 | 319 | return begins_with( s, ps, std::strlen( ps ) ); | 333 | return begins_with( s, ps, std::strlen( ps ) ); |
955 | 320 | } | 334 | } |
956 | 321 | 335 | ||
957 | @@ -329,7 +343,10 @@ | |||
958 | 329 | * @return Returns \c true only if \a s ends with \a ps. | 343 | * @return Returns \c true only if \a s ends with \a ps. |
959 | 330 | */ | 344 | */ |
960 | 331 | template<class StringType,class PrefixStringType> inline | 345 | template<class StringType,class PrefixStringType> inline |
962 | 332 | bool begins_with( StringType const &s, PrefixStringType const &ps ) { | 346 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
963 | 347 | && ZORBA_IS_STRING(PrefixStringType), | ||
964 | 348 | bool>::type | ||
965 | 349 | begins_with( StringType const &s, PrefixStringType const &ps ) { | ||
966 | 333 | return begins_with( s, ps.data(), ps.size() ); | 350 | return begins_with( s, ps.data(), ps.size() ); |
967 | 334 | } | 351 | } |
968 | 335 | 352 | ||
969 | @@ -354,7 +371,8 @@ | |||
970 | 354 | * @return Returns \c true only if \a s ends with \a c. | 371 | * @return Returns \c true only if \a s ends with \a c. |
971 | 355 | */ | 372 | */ |
972 | 356 | template<class StringType> inline | 373 | template<class StringType> inline |
974 | 357 | bool ends_with( StringType const &s, char c ) { | 374 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
975 | 375 | ends_with( StringType const &s, char c ) { | ||
976 | 358 | return !s.empty() && s[ s.size() - 1 ] == c; | 376 | return !s.empty() && s[ s.size() - 1 ] == c; |
977 | 359 | } | 377 | } |
978 | 360 | 378 | ||
979 | @@ -392,8 +410,9 @@ | |||
980 | 392 | * @return Returns \c true only if \a s ends with \a ss. | 410 | * @return Returns \c true only if \a s ends with \a ss. |
981 | 393 | */ | 411 | */ |
982 | 394 | template<class StringType> inline | 412 | template<class StringType> inline |
985 | 395 | bool ends_with( StringType const &s, char const *ss, | 413 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
986 | 396 | typename StringType::size_type ss_len ) { | 414 | ends_with( StringType const &s, char const *ss, |
987 | 415 | typename StringType::size_type ss_len ) { | ||
988 | 397 | typename StringType::size_type const result = s.rfind( ss ); | 416 | typename StringType::size_type const result = s.rfind( ss ); |
989 | 398 | return result != StringType::npos && result + ss_len == s.size(); | 417 | return result != StringType::npos && result + ss_len == s.size(); |
990 | 399 | } | 418 | } |
991 | @@ -407,7 +426,8 @@ | |||
992 | 407 | * @return Returns \c true only if \a s ends with \a ss. | 426 | * @return Returns \c true only if \a s ends with \a ss. |
993 | 408 | */ | 427 | */ |
994 | 409 | template<class StringType> inline | 428 | template<class StringType> inline |
996 | 410 | bool ends_with( StringType const &s, char const *ss ) { | 429 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
997 | 430 | ends_with( StringType const &s, char const *ss ) { | ||
998 | 411 | return ends_with( s, ss, std::strlen( ss ) ); | 431 | return ends_with( s, ss, std::strlen( ss ) ); |
999 | 412 | } | 432 | } |
1000 | 413 | 433 | ||
1001 | @@ -421,7 +441,10 @@ | |||
1002 | 421 | * @return Returns \c true only if \a s ends with \a ss. | 441 | * @return Returns \c true only if \a s ends with \a ss. |
1003 | 422 | */ | 442 | */ |
1004 | 423 | template<class StringType,class SuffixStringType> inline | 443 | template<class StringType,class SuffixStringType> inline |
1006 | 424 | bool ends_with( StringType const &s, SuffixStringType const &ss ) { | 444 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
1007 | 445 | && ZORBA_IS_STRING(SuffixStringType), | ||
1008 | 446 | bool>::type | ||
1009 | 447 | ends_with( StringType const &s, SuffixStringType const &ss ) { | ||
1010 | 425 | return ends_with( s, ss.data(), ss.size() ); | 448 | return ends_with( s, ss.data(), ss.size() ); |
1011 | 426 | } | 449 | } |
1012 | 427 | 450 | ||
1013 | @@ -467,7 +490,8 @@ | |||
1014 | 467 | * @param s The string to convert. | 490 | * @param s The string to convert. |
1015 | 468 | */ | 491 | */ |
1016 | 469 | template<class StringType> inline | 492 | template<class StringType> inline |
1018 | 470 | void to_lower( StringType &s ) { | 493 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1019 | 494 | to_lower( StringType &s ) { | ||
1020 | 471 | std::transform( | 495 | std::transform( |
1021 | 472 | s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_lower ) | 496 | s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_lower ) |
1022 | 473 | ); | 497 | ); |
1023 | @@ -483,7 +507,10 @@ | |||
1024 | 483 | * contents are overwritten. | 507 | * contents are overwritten. |
1025 | 484 | */ | 508 | */ |
1026 | 485 | template<class InputStringType,class OutputStringType> inline | 509 | template<class InputStringType,class OutputStringType> inline |
1028 | 486 | void to_lower( InputStringType const &in, OutputStringType *out ) { | 510 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1029 | 511 | && ZORBA_IS_STRING(OutputStringType), | ||
1030 | 512 | void>::type | ||
1031 | 513 | to_lower( InputStringType const &in, OutputStringType *out ) { | ||
1032 | 487 | std::transform( | 514 | std::transform( |
1033 | 488 | in.begin(), in.end(), std::back_inserter( *out ), | 515 | in.begin(), in.end(), std::back_inserter( *out ), |
1034 | 489 | static_cast<char (*)(char)>( to_lower ) | 516 | static_cast<char (*)(char)>( to_lower ) |
1035 | @@ -530,7 +557,8 @@ | |||
1036 | 530 | * @param s The string to convert. | 557 | * @param s The string to convert. |
1037 | 531 | */ | 558 | */ |
1038 | 532 | template<class StringType> inline | 559 | template<class StringType> inline |
1040 | 533 | void to_upper( StringType &s ) { | 560 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1041 | 561 | to_upper( StringType &s ) { | ||
1042 | 534 | std::transform( | 562 | std::transform( |
1043 | 535 | s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_upper ) | 563 | s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_upper ) |
1044 | 536 | ); | 564 | ); |
1045 | @@ -546,7 +574,10 @@ | |||
1046 | 546 | * contents are overwritten. | 574 | * contents are overwritten. |
1047 | 547 | */ | 575 | */ |
1048 | 548 | template<class InputStringType,class OutputStringType> inline | 576 | template<class InputStringType,class OutputStringType> inline |
1050 | 549 | void to_upper( InputStringType const &in, OutputStringType *out ) { | 577 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1051 | 578 | && ZORBA_IS_STRING(OutputStringType), | ||
1052 | 579 | void>::type | ||
1053 | 580 | to_upper( InputStringType const &in, OutputStringType *out ) { | ||
1054 | 550 | std::transform( | 581 | std::transform( |
1055 | 551 | in.begin(), in.end(), std::back_inserter( *out ), | 582 | in.begin(), in.end(), std::back_inserter( *out ), |
1056 | 552 | static_cast<char (*)(char)>( to_upper ) | 583 | static_cast<char (*)(char)>( to_upper ) |
1057 | @@ -588,7 +619,8 @@ | |||
1058 | 588 | * @return Returns \c true only if at least one replacement is performed. | 619 | * @return Returns \c true only if at least one replacement is performed. |
1059 | 589 | */ | 620 | */ |
1060 | 590 | template<class StringType> | 621 | template<class StringType> |
1062 | 591 | bool replace_all( StringType &s, char from, char to ); | 622 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
1063 | 623 | replace_all( StringType &s, char from, char to ); | ||
1064 | 592 | 624 | ||
1065 | 593 | /** | 625 | /** |
1066 | 594 | * Replaces all occurrences of one substring with another. | 626 | * Replaces all occurrences of one substring with another. |
1067 | @@ -602,9 +634,10 @@ | |||
1068 | 602 | * @return Returns \c true only if at least one replacement is performed. | 634 | * @return Returns \c true only if at least one replacement is performed. |
1069 | 603 | */ | 635 | */ |
1070 | 604 | template<class StringType> | 636 | template<class StringType> |
1074 | 605 | bool replace_all( StringType &s, | 637 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
1075 | 606 | char const *from, typename StringType::size_type from_len, | 638 | replace_all( StringType &s, |
1076 | 607 | char const *to, typename StringType::size_type to_len ); | 639 | char const *from, typename StringType::size_type from_len, |
1077 | 640 | char const *to, typename StringType::size_type to_len ); | ||
1078 | 608 | 641 | ||
1079 | 609 | /** | 642 | /** |
1080 | 610 | * Replaces all occurrences of one substring with another. | 643 | * Replaces all occurrences of one substring with another. |
1081 | @@ -616,7 +649,8 @@ | |||
1082 | 616 | * @return Returns \c true only if at least one replacement is performed. | 649 | * @return Returns \c true only if at least one replacement is performed. |
1083 | 617 | */ | 650 | */ |
1084 | 618 | template<class StringType> inline | 651 | template<class StringType> inline |
1086 | 619 | bool replace_all( StringType &s, char const *from, char const *to ) { | 652 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
1087 | 653 | replace_all( StringType &s, char const *from, char const *to ) { | ||
1088 | 620 | return replace_all( s, from, std::strlen( from ), to, std::strlen( to ) ); | 654 | return replace_all( s, from, std::strlen( from ), to, std::strlen( to ) ); |
1089 | 621 | } | 655 | } |
1090 | 622 | 656 | ||
1091 | @@ -630,7 +664,10 @@ | |||
1092 | 630 | * @return Returns \c true only if at least one replacement is performed. | 664 | * @return Returns \c true only if at least one replacement is performed. |
1093 | 631 | */ | 665 | */ |
1094 | 632 | template<class StringType,class ToStringType> inline | 666 | template<class StringType,class ToStringType> inline |
1096 | 633 | bool replace_all( StringType &s, char const *from, ToStringType const &to ) { | 667 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
1097 | 668 | && ZORBA_IS_STRING(ToStringType), | ||
1098 | 669 | bool>::type | ||
1099 | 670 | replace_all( StringType &s, char const *from, ToStringType const &to ) { | ||
1100 | 634 | return replace_all( s, from, std::strlen( from ), to.data(), to.size() ); | 671 | return replace_all( s, from, std::strlen( from ), to.data(), to.size() ); |
1101 | 635 | } | 672 | } |
1102 | 636 | 673 | ||
1103 | @@ -644,8 +681,12 @@ | |||
1104 | 644 | * @return Returns \c true only if at least one replacement is performed. | 681 | * @return Returns \c true only if at least one replacement is performed. |
1105 | 645 | */ | 682 | */ |
1106 | 646 | template<class StringType,class FromStringType,class ToStringType> inline | 683 | template<class StringType,class FromStringType,class ToStringType> inline |
1109 | 647 | bool replace_all( StringType &s, FromStringType const &from, | 684 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
1110 | 648 | ToStringType const &to ) { | 685 | && ZORBA_IS_STRING(FromStringType) |
1111 | 686 | && ZORBA_IS_STRING(ToStringType), | ||
1112 | 687 | bool>::type | ||
1113 | 688 | replace_all( StringType &s, FromStringType const &from, | ||
1114 | 689 | ToStringType const &to ) { | ||
1115 | 649 | return replace_all( s, from.data(), from.size(), to.data(), to.size() ); | 690 | return replace_all( s, from.data(), from.size(), to.data(), to.size() ); |
1116 | 650 | } | 691 | } |
1117 | 651 | 692 | ||
1118 | @@ -797,7 +838,10 @@ | |||
1119 | 797 | * @param out The output string (which must be different from \a in). | 838 | * @param out The output string (which must be different from \a in). |
1120 | 798 | */ | 839 | */ |
1121 | 799 | template<class InputStringType,class OutputStringType> | 840 | template<class InputStringType,class OutputStringType> |
1123 | 800 | void normalize_whitespace( InputStringType const &in, OutputStringType *out ); | 841 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1124 | 842 | && ZORBA_IS_STRING(OutputStringType), | ||
1125 | 843 | void>::type | ||
1126 | 844 | normalize_space( InputStringType const &in, OutputStringType *out ); | ||
1127 | 801 | 845 | ||
1128 | 802 | /** | 846 | /** |
1129 | 803 | * Converts sequences of one or more whitespace characters to a single space. | 847 | * Converts sequences of one or more whitespace characters to a single space. |
1130 | @@ -807,9 +851,10 @@ | |||
1131 | 807 | * @param s The string. | 851 | * @param s The string. |
1132 | 808 | */ | 852 | */ |
1133 | 809 | template<class StringType> inline | 853 | template<class StringType> inline |
1135 | 810 | void normalize_whitespace( StringType &s ) { | 854 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1136 | 855 | normalize_space( StringType &s ) { | ||
1137 | 811 | StringType temp; | 856 | StringType temp; |
1139 | 812 | normalize_whitespace( s, &temp ); | 857 | normalize_space( s, &temp ); |
1140 | 813 | s = temp; | 858 | s = temp; |
1141 | 814 | } | 859 | } |
1142 | 815 | 860 | ||
1143 | @@ -827,11 +872,13 @@ | |||
1144 | 827 | /** | 872 | /** |
1145 | 828 | * Removes all characters that are not among the specified characters. | 873 | * Removes all characters that are not among the specified characters. |
1146 | 829 | * | 874 | * |
1147 | 875 | * @tparam StringType The string type. | ||
1148 | 830 | * @param s The string to remove characters from. | 876 | * @param s The string to remove characters from. |
1149 | 831 | * @param keep_chars The characters to keep. | 877 | * @param keep_chars The characters to keep. |
1150 | 832 | */ | 878 | */ |
1151 | 833 | template<class StringType> | 879 | template<class StringType> |
1153 | 834 | void remove_not_chars( StringType &s, char const *keep_chars ); | 880 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1154 | 881 | remove_not_chars( StringType &s, char const *keep_chars ); | ||
1155 | 835 | 882 | ||
1156 | 836 | /** | 883 | /** |
1157 | 837 | * Removes all whitespace characters by shifting the contents of the buffer to | 884 | * Removes all whitespace characters by shifting the contents of the buffer to |
1158 | @@ -841,7 +888,7 @@ | |||
1159 | 841 | * @param s_len The length of \a s. | 888 | * @param s_len The length of \a s. |
1160 | 842 | * @return Returns the new length of \a s with all whitespace removed. | 889 | * @return Returns the new length of \a s with all whitespace removed. |
1161 | 843 | */ | 890 | */ |
1163 | 844 | inline size_type remove_whitespace( char *s, size_type s_len ) { | 891 | inline size_type remove_space( char *s, size_type s_len ) { |
1164 | 845 | return remove_chars( s, s_len, whitespace ); | 892 | return remove_chars( s, s_len, whitespace ); |
1165 | 846 | } | 893 | } |
1166 | 847 | 894 | ||
1167 | @@ -855,8 +902,10 @@ | |||
1168 | 855 | * @param out The output string (which must be different from \a in). | 902 | * @param out The output string (which must be different from \a in). |
1169 | 856 | */ | 903 | */ |
1170 | 857 | template<class InputStringType,class OutputStringType> | 904 | template<class InputStringType,class OutputStringType> |
1173 | 858 | void trim( InputStringType const &in, char const *chars, | 905 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1174 | 859 | OutputStringType *out ); | 906 | && ZORBA_IS_STRING(OutputStringType), |
1175 | 907 | void>::type | ||
1176 | 908 | trim( InputStringType const &in, char const *chars, OutputStringType *out ); | ||
1177 | 860 | 909 | ||
1178 | 861 | /** | 910 | /** |
1179 | 862 | * Removes all leading and trailing specified characters. | 911 | * Removes all leading and trailing specified characters. |
1180 | @@ -865,7 +914,8 @@ | |||
1181 | 865 | * @param s The string. | 914 | * @param s The string. |
1182 | 866 | */ | 915 | */ |
1183 | 867 | template<class StringType> inline | 916 | template<class StringType> inline |
1185 | 868 | void trim( StringType &s, char const *chars ) { | 917 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1186 | 918 | trim( StringType &s, char const *chars ) { | ||
1187 | 869 | StringType temp; | 919 | StringType temp; |
1188 | 870 | trim( s, chars, &temp ); | 920 | trim( s, chars, &temp ); |
1189 | 871 | s = temp; | 921 | s = temp; |
1190 | @@ -917,8 +967,11 @@ | |||
1191 | 917 | * @param out The output string (which must be different from \a in). | 967 | * @param out The output string (which must be different from \a in). |
1192 | 918 | */ | 968 | */ |
1193 | 919 | template<class InputStringType,class OutputStringType> | 969 | template<class InputStringType,class OutputStringType> |
1196 | 920 | void trim_start( InputStringType const &in, char const *chars, | 970 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1197 | 921 | OutputStringType *out ); | 971 | && ZORBA_IS_STRING(OutputStringType), |
1198 | 972 | void>::type | ||
1199 | 973 | trim_start( InputStringType const &in, char const *chars, | ||
1200 | 974 | OutputStringType *out ); | ||
1201 | 922 | 975 | ||
1202 | 923 | /** | 976 | /** |
1203 | 924 | * Removes all leading specified characters. | 977 | * Removes all leading specified characters. |
1204 | @@ -928,7 +981,8 @@ | |||
1205 | 928 | * @param chars The characters to trim. | 981 | * @param chars The characters to trim. |
1206 | 929 | */ | 982 | */ |
1207 | 930 | template<class StringType> inline | 983 | template<class StringType> inline |
1209 | 931 | void trim_start( StringType &s, char const *chars ) { | 984 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1210 | 985 | trim_start( StringType &s, char const *chars ) { | ||
1211 | 932 | StringType temp; | 986 | StringType temp; |
1212 | 933 | trim_start( s, chars, &temp ); | 987 | trim_start( s, chars, &temp ); |
1213 | 934 | s = temp; | 988 | s = temp; |
1214 | @@ -941,7 +995,7 @@ | |||
1215 | 941 | * @return Returns a pointer to the first character in \a s that is not a | 995 | * @return Returns a pointer to the first character in \a s that is not a |
1216 | 942 | * whitespace character. | 996 | * whitespace character. |
1217 | 943 | */ | 997 | */ |
1219 | 944 | inline char const* trim_start_whitespace( char const *s ) { | 998 | inline char const* trim_start_space( char const *s ) { |
1220 | 945 | return trim_start( s, whitespace ); | 999 | return trim_start( s, whitespace ); |
1221 | 946 | } | 1000 | } |
1222 | 947 | 1001 | ||
1223 | @@ -954,7 +1008,7 @@ | |||
1224 | 954 | * @return Returns a pointer to the first character in \a s that is not a | 1008 | * @return Returns a pointer to the first character in \a s that is not a |
1225 | 955 | * whitespace character. | 1009 | * whitespace character. |
1226 | 956 | */ | 1010 | */ |
1228 | 957 | inline char const* trim_start_whitespace( char const *s, size_type *s_len ) { | 1011 | inline char const* trim_start_space( char const *s, size_type *s_len ) { |
1229 | 958 | return trim_start( s, s_len, whitespace ); | 1012 | return trim_start( s, s_len, whitespace ); |
1230 | 959 | } | 1013 | } |
1231 | 960 | 1014 | ||
1232 | @@ -966,7 +1020,7 @@ | |||
1233 | 966 | * @return Returns a pointer to the first character in \a s that is not a | 1020 | * @return Returns a pointer to the first character in \a s that is not a |
1234 | 967 | * whitespace character. | 1021 | * whitespace character. |
1235 | 968 | */ | 1022 | */ |
1237 | 969 | inline char const* trim_start_whitespace( char const *s, size_type s_len ) { | 1023 | inline char const* trim_start_space( char const *s, size_type s_len ) { |
1238 | 970 | return trim_start( s, s_len, whitespace ); | 1024 | return trim_start( s, s_len, whitespace ); |
1239 | 971 | } | 1025 | } |
1240 | 972 | 1026 | ||
1241 | @@ -979,7 +1033,10 @@ | |||
1242 | 979 | * @param out The output string (which must be different from \a in). | 1033 | * @param out The output string (which must be different from \a in). |
1243 | 980 | */ | 1034 | */ |
1244 | 981 | template<class InputStringType,class OutputStringType> inline | 1035 | template<class InputStringType,class OutputStringType> inline |
1246 | 982 | void trim_start_whitespace( InputStringType const &in, OutputStringType *out ) { | 1036 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1247 | 1037 | && ZORBA_IS_STRING(OutputStringType), | ||
1248 | 1038 | void>::type | ||
1249 | 1039 | trim_start_space( InputStringType const &in, OutputStringType *out ) { | ||
1250 | 983 | trim_start( in, whitespace, out ); | 1040 | trim_start( in, whitespace, out ); |
1251 | 984 | } | 1041 | } |
1252 | 985 | 1042 | ||
1253 | @@ -990,9 +1047,10 @@ | |||
1254 | 990 | * @param s The string. | 1047 | * @param s The string. |
1255 | 991 | */ | 1048 | */ |
1256 | 992 | template<class StringType> inline | 1049 | template<class StringType> inline |
1258 | 993 | void trim_start_whitespace( StringType &s ) { | 1050 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1259 | 1051 | trim_start_space( StringType &s ) { | ||
1260 | 994 | StringType temp; | 1052 | StringType temp; |
1262 | 995 | trim_start_whitespace( s, &temp ); | 1053 | trim_start_space( s, &temp ); |
1263 | 996 | s = temp; | 1054 | s = temp; |
1264 | 997 | } | 1055 | } |
1265 | 998 | 1056 | ||
1266 | @@ -1027,8 +1085,10 @@ | |||
1267 | 1027 | * @param out The output string (which must be different from \a in). | 1085 | * @param out The output string (which must be different from \a in). |
1268 | 1028 | */ | 1086 | */ |
1269 | 1029 | template<class InputStringType,class OutputStringType> | 1087 | template<class InputStringType,class OutputStringType> |
1272 | 1030 | void trim_end( InputStringType const &in, char const *chars, | 1088 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1273 | 1031 | OutputStringType *out ); | 1089 | && ZORBA_IS_STRING(OutputStringType), |
1274 | 1090 | void>::type | ||
1275 | 1091 | trim_end( InputStringType const &in, char const *chars, OutputStringType *out ); | ||
1276 | 1032 | 1092 | ||
1277 | 1033 | /** | 1093 | /** |
1278 | 1034 | * Removes all trailing specified characters. | 1094 | * Removes all trailing specified characters. |
1279 | @@ -1037,7 +1097,8 @@ | |||
1280 | 1037 | * @param s The string. | 1097 | * @param s The string. |
1281 | 1038 | */ | 1098 | */ |
1282 | 1039 | template<class StringType> inline | 1099 | template<class StringType> inline |
1284 | 1040 | void trim_end( StringType &s, char const *chars ) { | 1100 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1285 | 1101 | trim_end( StringType &s, char const *chars ) { | ||
1286 | 1041 | StringType temp; | 1102 | StringType temp; |
1287 | 1042 | trim_end( s, chars, &temp ); | 1103 | trim_end( s, chars, &temp ); |
1288 | 1043 | s = temp; | 1104 | s = temp; |
1289 | @@ -1050,7 +1111,7 @@ | |||
1290 | 1050 | * @param s_len The length of \a s. | 1111 | * @param s_len The length of \a s. |
1291 | 1051 | * @return Returns the new length of \a s. | 1112 | * @return Returns the new length of \a s. |
1292 | 1052 | */ | 1113 | */ |
1294 | 1053 | inline size_type trim_end_whitespace( char const *s, size_type s_len ) { | 1114 | inline size_type trim_end_space( char const *s, size_type s_len ) { |
1295 | 1054 | return trim_end( s, s_len, whitespace ); | 1115 | return trim_end( s, s_len, whitespace ); |
1296 | 1055 | } | 1116 | } |
1297 | 1056 | 1117 | ||
1298 | @@ -1060,7 +1121,7 @@ | |||
1299 | 1060 | * @param s The string to trim. | 1121 | * @param s The string to trim. |
1300 | 1061 | * @return Returns the new length of \a s. | 1122 | * @return Returns the new length of \a s. |
1301 | 1062 | */ | 1123 | */ |
1303 | 1063 | inline size_type trim_end_whitespace( char const *s ) { | 1124 | inline size_type trim_end_space( char const *s ) { |
1304 | 1064 | return trim_end( s, whitespace ); | 1125 | return trim_end( s, whitespace ); |
1305 | 1065 | } | 1126 | } |
1306 | 1066 | 1127 | ||
1307 | @@ -1073,7 +1134,10 @@ | |||
1308 | 1073 | * @param out The output string (which must be different from \a in). | 1134 | * @param out The output string (which must be different from \a in). |
1309 | 1074 | */ | 1135 | */ |
1310 | 1075 | template<class InputStringType,class OutputStringType> | 1136 | template<class InputStringType,class OutputStringType> |
1312 | 1076 | void trim_end_whitespace( InputStringType const &in, OutputStringType *out ) { | 1137 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1313 | 1138 | && ZORBA_IS_STRING(OutputStringType), | ||
1314 | 1139 | void>::type | ||
1315 | 1140 | trim_end_space( InputStringType const &in, OutputStringType *out ) { | ||
1316 | 1077 | return trim_end( in, whitespace, out ); | 1141 | return trim_end( in, whitespace, out ); |
1317 | 1078 | } | 1142 | } |
1318 | 1079 | 1143 | ||
1319 | @@ -1084,12 +1148,13 @@ | |||
1320 | 1084 | * @param s The string. | 1148 | * @param s The string. |
1321 | 1085 | */ | 1149 | */ |
1322 | 1086 | template<class StringType> inline | 1150 | template<class StringType> inline |
1324 | 1087 | void trim_end_whitespace( StringType &s ) { | 1151 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1325 | 1152 | trim_end_space( StringType &s ) { | ||
1326 | 1088 | trim_end( s, whitespace ); | 1153 | trim_end( s, whitespace ); |
1327 | 1089 | } | 1154 | } |
1328 | 1090 | 1155 | ||
1329 | 1091 | /** | 1156 | /** |
1331 | 1092 | * Removed sll leading and trailing whitespace. | 1157 | * Removes all leading and trailing whitespace. |
1332 | 1093 | * | 1158 | * |
1333 | 1094 | * @param s The input C string. | 1159 | * @param s The input C string. |
1334 | 1095 | * @param s_len A pointer to the length of \a s. It is updated with the new | 1160 | * @param s_len A pointer to the length of \a s. It is updated with the new |
1335 | @@ -1097,9 +1162,9 @@ | |||
1336 | 1097 | * @return Returns a pointer to the first character in \a s that is not | 1162 | * @return Returns a pointer to the first character in \a s that is not |
1337 | 1098 | * whitespace. | 1163 | * whitespace. |
1338 | 1099 | */ | 1164 | */ |
1342 | 1100 | inline char const* trim_whitespace( char const *s, size_type *s_len ) { | 1165 | inline char const* trim_space( char const *s, size_type *s_len ) { |
1343 | 1101 | s = trim_start_whitespace( s, s_len ); | 1166 | s = trim_start_space( s, s_len ); |
1344 | 1102 | *s_len = trim_end_whitespace( s, *s_len ); | 1167 | *s_len = trim_end_space( s, *s_len ); |
1345 | 1103 | return s; | 1168 | return s; |
1346 | 1104 | } | 1169 | } |
1347 | 1105 | 1170 | ||
1348 | @@ -1112,7 +1177,10 @@ | |||
1349 | 1112 | * @param out The output string (which must be different from \a in). | 1177 | * @param out The output string (which must be different from \a in). |
1350 | 1113 | */ | 1178 | */ |
1351 | 1114 | template<class InputStringType,class OutputStringType> inline | 1179 | template<class InputStringType,class OutputStringType> inline |
1353 | 1115 | void trim_whitespace( InputStringType const &in, OutputStringType *out ) { | 1180 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1354 | 1181 | && ZORBA_IS_STRING(OutputStringType), | ||
1355 | 1182 | void>::type | ||
1356 | 1183 | trim_space( InputStringType const &in, OutputStringType *out ) { | ||
1357 | 1116 | trim( in, whitespace, out ); | 1184 | trim( in, whitespace, out ); |
1358 | 1117 | } | 1185 | } |
1359 | 1118 | 1186 | ||
1360 | @@ -1123,9 +1191,10 @@ | |||
1361 | 1123 | * @param s The string. | 1191 | * @param s The string. |
1362 | 1124 | */ | 1192 | */ |
1363 | 1125 | template<class StringType> inline | 1193 | template<class StringType> inline |
1365 | 1126 | void trim_whitespace( StringType &s ) { | 1194 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1366 | 1195 | trim_space( StringType &s ) { | ||
1367 | 1127 | StringType temp; | 1196 | StringType temp; |
1369 | 1128 | trim_whitespace( s, &temp ); | 1197 | trim_space( s, &temp ); |
1370 | 1129 | s = temp; | 1198 | s = temp; |
1371 | 1130 | } | 1199 | } |
1372 | 1131 | 1200 | ||
1373 | @@ -1138,10 +1207,10 @@ | |||
1374 | 1138 | * @param pos The position within \a s where to start looking for whitespace. | 1207 | * @param pos The position within \a s where to start looking for whitespace. |
1375 | 1139 | * On return, \a pos is updated with the position of the 1st non-whitespace | 1208 | * On return, \a pos is updated with the position of the 1st non-whitespace |
1376 | 1140 | * char. | 1209 | * char. |
1378 | 1141 | * @deprecated Use trim_start_whitespace() instead. | 1210 | * @deprecated Use trim_start_space() instead. |
1379 | 1142 | */ | 1211 | */ |
1382 | 1143 | inline void skip_whitespace( char const *s, size_type s_len, size_type *pos ) { | 1212 | inline void skip_space( char const *s, size_type s_len, size_type *pos ) { |
1383 | 1144 | *pos = trim_start_whitespace( s + *pos, s_len - *pos ) - s; | 1213 | *pos = trim_start_space( s + *pos, s_len - *pos ) - s; |
1384 | 1145 | } | 1214 | } |
1385 | 1146 | 1215 | ||
1386 | 1147 | /** | 1216 | /** |
1387 | @@ -1155,11 +1224,11 @@ | |||
1388 | 1155 | * char. | 1224 | * char. |
1389 | 1156 | */ | 1225 | */ |
1390 | 1157 | template<class StringType> inline | 1226 | template<class StringType> inline |
1393 | 1158 | void skip_whitespace( StringType const &s, | 1227 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1394 | 1159 | typename StringType::const_iterator *i ) { | 1228 | skip_space( StringType const &s, typename StringType::const_iterator *i ) { |
1395 | 1160 | typename StringType::difference_type const d = *i - s.begin(); | 1229 | typename StringType::difference_type const d = *i - s.begin(); |
1396 | 1161 | char const *const sd = s.data() + d; | 1230 | char const *const sd = s.data() + d; |
1398 | 1162 | std::advance( *i, trim_start_whitespace( sd, s.size() - d ) - sd ); | 1231 | std::advance( *i, trim_start_space( sd, s.size() - d ) - sd ); |
1399 | 1163 | } | 1232 | } |
1400 | 1164 | 1233 | ||
1401 | 1165 | ////////// Miscellaneous ////////////////////////////////////////////////////// | 1234 | ////////// Miscellaneous ////////////////////////////////////////////////////// |
1402 | @@ -1174,8 +1243,8 @@ | |||
1403 | 1174 | * @return Returns \c *s. | 1243 | * @return Returns \c *s. |
1404 | 1175 | */ | 1244 | */ |
1405 | 1176 | template<class StringType> inline | 1245 | template<class StringType> inline |
1408 | 1177 | StringType& left_pad( StringType *s, typename StringType::size_type width, | 1246 | typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type |
1409 | 1178 | char c ) { | 1247 | left_pad( StringType *s, typename StringType::size_type width, char c ) { |
1410 | 1179 | typedef typename StringType::size_type size_type; | 1248 | typedef typename StringType::size_type size_type; |
1411 | 1180 | if ( s->size() < width ) | 1249 | if ( s->size() < width ) |
1412 | 1181 | s->insert( static_cast<size_type>( 0 ), width - s->size(), c ); | 1250 | s->insert( static_cast<size_type>( 0 ), width - s->size(), c ); |
1413 | @@ -1192,8 +1261,8 @@ | |||
1414 | 1192 | * @return Returns \c *s. | 1261 | * @return Returns \c *s. |
1415 | 1193 | */ | 1262 | */ |
1416 | 1194 | template<class StringType> inline | 1263 | template<class StringType> inline |
1419 | 1195 | StringType& right_pad( StringType *s, typename StringType::size_type width, | 1264 | typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type |
1420 | 1196 | char c ) { | 1265 | right_pad( StringType *s, typename StringType::size_type width, char c ) { |
1421 | 1197 | if ( s->size() < width ) | 1266 | if ( s->size() < width ) |
1422 | 1198 | s->append( width - s->size(), c ); | 1267 | s->append( width - s->size(), c ); |
1423 | 1199 | return *s; | 1268 | return *s; |
1424 | @@ -1222,7 +1291,10 @@ | |||
1425 | 1222 | * @param out The output string. | 1291 | * @param out The output string. |
1426 | 1223 | */ | 1292 | */ |
1427 | 1224 | template<class InputStringType,class OutputStringType> inline | 1293 | template<class InputStringType,class OutputStringType> inline |
1429 | 1225 | void reverse( InputStringType const &in, OutputStringType *out ) { | 1294 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1430 | 1295 | && ZORBA_IS_STRING(OutputStringType), | ||
1431 | 1296 | void>::type | ||
1432 | 1297 | reverse( InputStringType const &in, OutputStringType *out ) { | ||
1433 | 1226 | std::reverse_copy( in.begin(), in.end(), std::back_inserter( *out ) ); | 1298 | std::reverse_copy( in.begin(), in.end(), std::back_inserter( *out ) ); |
1434 | 1227 | } | 1299 | } |
1435 | 1228 | 1300 | ||
1436 | 1229 | 1301 | ||
1437 | === modified file 'src/util/ascii_util.tcc' | |||
1438 | --- src/util/ascii_util.tcc 2013-05-06 22:57:08 +0000 | |||
1439 | +++ src/util/ascii_util.tcc 2013-05-09 00:49:28 +0000 | |||
1440 | @@ -36,7 +36,10 @@ | |||
1441 | 36 | /////////////////////////////////////////////////////////////////////////////// | 36 | /////////////////////////////////////////////////////////////////////////////// |
1442 | 37 | 37 | ||
1443 | 38 | template<class InputStringType,class OutputStringType> | 38 | template<class InputStringType,class OutputStringType> |
1445 | 39 | void normalize_whitespace( InputStringType const &in, OutputStringType *out ) { | 39 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1446 | 40 | && ZORBA_IS_STRING(OutputStringType), | ||
1447 | 41 | void>::type | ||
1448 | 42 | normalize_space( InputStringType const &in, OutputStringType *out ) { | ||
1449 | 40 | typedef typename InputStringType::const_iterator const_iterator; | 43 | typedef typename InputStringType::const_iterator const_iterator; |
1450 | 41 | const_iterator i( in.begin() ); | 44 | const_iterator i( in.begin() ); |
1451 | 42 | const_iterator const j( in.end() ); | 45 | const_iterator const j( in.end() ); |
1452 | @@ -56,14 +59,16 @@ | |||
1453 | 56 | } | 59 | } |
1454 | 57 | 60 | ||
1455 | 58 | template<class StringType> | 61 | template<class StringType> |
1457 | 59 | void remove_not_chars( StringType &s, char const *keep_chars ) { | 62 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
1458 | 63 | remove_not_chars( StringType &s, char const *keep_chars ) { | ||
1459 | 60 | typename StringType::size_type pos = 0; | 64 | typename StringType::size_type pos = 0; |
1460 | 61 | while ( (pos = s.find_first_not_of( keep_chars, pos )) != StringType::npos ) | 65 | while ( (pos = s.find_first_not_of( keep_chars, pos )) != StringType::npos ) |
1461 | 62 | s.erase( pos, 1 ); | 66 | s.erase( pos, 1 ); |
1462 | 63 | } | 67 | } |
1463 | 64 | 68 | ||
1464 | 65 | template<class StringType> | 69 | template<class StringType> |
1466 | 66 | bool replace_all( StringType &s, char from, char to ) { | 70 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
1467 | 71 | replace_all( StringType &s, char from, char to ) { | ||
1468 | 67 | bool replaced_any = false; | 72 | bool replaced_any = false; |
1469 | 68 | for ( typename StringType::size_type pos = 0; pos < s.size(); ++pos ) { | 73 | for ( typename StringType::size_type pos = 0; pos < s.size(); ++pos ) { |
1470 | 69 | if ( (pos = s.find( from, pos )) == StringType::npos ) | 74 | if ( (pos = s.find( from, pos )) == StringType::npos ) |
1471 | @@ -75,9 +80,10 @@ | |||
1472 | 75 | } | 80 | } |
1473 | 76 | 81 | ||
1474 | 77 | template<class StringType> | 82 | template<class StringType> |
1478 | 78 | bool replace_all( StringType &s, | 83 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
1479 | 79 | char const *from, typename StringType::size_type from_len, | 84 | replace_all( StringType &s, |
1480 | 80 | char const *to, typename StringType::size_type to_len ) { | 85 | char const *from, typename StringType::size_type from_len, |
1481 | 86 | char const *to, typename StringType::size_type to_len ) { | ||
1482 | 81 | bool replaced_any = false; | 87 | bool replaced_any = false; |
1483 | 82 | for ( typename StringType::size_type pos = 0; | 88 | for ( typename StringType::size_type pos = 0; |
1484 | 83 | pos + from_len <= s.size(); pos += to_len ) { | 89 | pos + from_len <= s.size(); pos += to_len ) { |
1485 | @@ -90,8 +96,10 @@ | |||
1486 | 90 | } | 96 | } |
1487 | 91 | 97 | ||
1488 | 92 | template<class InputStringType,class OutputStringType> | 98 | template<class InputStringType,class OutputStringType> |
1491 | 93 | void trim( InputStringType const &in, char const *chars, | 99 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1492 | 94 | OutputStringType *out ) { | 100 | && ZORBA_IS_STRING(OutputStringType), |
1493 | 101 | void>::type | ||
1494 | 102 | trim( InputStringType const &in, char const *chars, OutputStringType *out ) { | ||
1495 | 95 | *out = in; | 103 | *out = in; |
1496 | 96 | typename OutputStringType::size_type pos = out->find_first_not_of( chars ); | 104 | typename OutputStringType::size_type pos = out->find_first_not_of( chars ); |
1497 | 97 | out->erase( 0, pos ); | 105 | out->erase( 0, pos ); |
1498 | @@ -101,52 +109,28 @@ | |||
1499 | 101 | } | 109 | } |
1500 | 102 | 110 | ||
1501 | 103 | template<class InputStringType,class OutputStringType> | 111 | template<class InputStringType,class OutputStringType> |
1504 | 104 | void trim_start( InputStringType const &in, char const *chars, | 112 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1505 | 105 | OutputStringType *out ) { | 113 | && ZORBA_IS_STRING(OutputStringType), |
1506 | 114 | void>::type | ||
1507 | 115 | trim_start( InputStringType const &in, char const *chars, | ||
1508 | 116 | OutputStringType *out ) { | ||
1509 | 106 | *out = in; | 117 | *out = in; |
1510 | 107 | typename OutputStringType::size_type pos = out->find_first_not_of( chars ); | 118 | typename OutputStringType::size_type pos = out->find_first_not_of( chars ); |
1511 | 108 | out->erase( 0, pos ); | 119 | out->erase( 0, pos ); |
1512 | 109 | } | 120 | } |
1513 | 110 | 121 | ||
1514 | 111 | template<class InputStringType,class OutputStringType> | 122 | template<class InputStringType,class OutputStringType> |
1517 | 112 | void trim_end( InputStringType const &in, char const *chars, | 123 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
1518 | 113 | OutputStringType *out ) { | 124 | && ZORBA_IS_STRING(OutputStringType), |
1519 | 125 | void>::type | ||
1520 | 126 | trim_end( InputStringType const &in, char const *chars, | ||
1521 | 127 | OutputStringType *out ) { | ||
1522 | 114 | *out = in; | 128 | *out = in; |
1523 | 115 | typename OutputStringType::size_type pos = out->find_last_not_of( chars ); | 129 | typename OutputStringType::size_type pos = out->find_last_not_of( chars ); |
1524 | 116 | if ( pos != OutputStringType::npos && ++pos < out->size() ) | 130 | if ( pos != OutputStringType::npos && ++pos < out->size() ) |
1525 | 117 | out->erase( pos ); | 131 | out->erase( pos ); |
1526 | 118 | } | 132 | } |
1527 | 119 | 133 | ||
1528 | 120 | template<class InputStringType,class OutputStringType> | ||
1529 | 121 | void uri_decode( InputStringType const &in, OutputStringType *out ) { | ||
1530 | 122 | extern signed char const hex2dec[]; | ||
1531 | 123 | |||
1532 | 124 | typedef typename InputStringType::const_iterator const_iterator; | ||
1533 | 125 | const_iterator i( in.begin() ); | ||
1534 | 126 | const_iterator const j( in.end() ); | ||
1535 | 127 | |||
1536 | 128 | out->reserve( out->size() + in.size() ); | ||
1537 | 129 | for ( ; i != j; ++i ) { | ||
1538 | 130 | char c = *i; | ||
1539 | 131 | if ( c == '%' ) { | ||
1540 | 132 | const_iterator k = i; | ||
1541 | 133 | do { | ||
1542 | 134 | if ( ++k == j ) | ||
1543 | 135 | break; | ||
1544 | 136 | signed char const c1 = hex2dec[ static_cast<unsigned>( *k ) & 0xFF ]; | ||
1545 | 137 | if ( c1 == -1 || ++k == j ) | ||
1546 | 138 | break; | ||
1547 | 139 | signed char const c2 = hex2dec[ static_cast<unsigned>( *k ) & 0xFF ]; | ||
1548 | 140 | if ( c2 == -1 ) | ||
1549 | 141 | break; | ||
1550 | 142 | c = static_cast<char>( (c1 << 4) | c2 ); | ||
1551 | 143 | i = k; | ||
1552 | 144 | } while ( false ); | ||
1553 | 145 | } | ||
1554 | 146 | out->push_back( c ); | ||
1555 | 147 | } | ||
1556 | 148 | } | ||
1557 | 149 | |||
1558 | 150 | /////////////////////////////////////////////////////////////////////////////// | 134 | /////////////////////////////////////////////////////////////////////////////// |
1559 | 151 | 135 | ||
1560 | 152 | } // namespace ascii | 136 | } // namespace ascii |
1561 | 153 | 137 | ||
1562 | === modified file 'src/util/base64_util.h' | |||
1563 | --- src/util/base64_util.h 2013-04-16 22:12:03 +0000 | |||
1564 | +++ src/util/base64_util.h 2013-05-09 00:49:28 +0000 | |||
1565 | @@ -18,11 +18,14 @@ | |||
1566 | 18 | #ifndef ZORBA_BASE64_UTIL_H | 18 | #ifndef ZORBA_BASE64_UTIL_H |
1567 | 19 | #define ZORBA_BASE64_UTIL_H | 19 | #define ZORBA_BASE64_UTIL_H |
1568 | 20 | 20 | ||
1569 | 21 | // standard | ||
1570 | 21 | #include <iostream> | 22 | #include <iostream> |
1571 | 22 | #include <stdexcept> | 23 | #include <stdexcept> |
1572 | 23 | #include <sys/types.h> /* for size_t */ | 24 | #include <sys/types.h> /* for size_t */ |
1573 | 24 | #include <vector> | 25 | #include <vector> |
1574 | 25 | 26 | ||
1575 | 27 | // Zorba | ||
1576 | 28 | #include <zorba/internal/ztd.h> | ||
1577 | 26 | #include "cxx_util.h" | 29 | #include "cxx_util.h" |
1578 | 27 | #include "stream_util.h" | 30 | #include "stream_util.h" |
1579 | 28 | 31 | ||
1580 | @@ -132,8 +135,9 @@ | |||
1581 | 132 | * invalid byte is encountered. | 135 | * invalid byte is encountered. |
1582 | 133 | */ | 136 | */ |
1583 | 134 | template<class ToStringType> | 137 | template<class ToStringType> |
1586 | 135 | size_type decode( char const *from, size_type from_len, ToStringType *to, | 138 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1587 | 136 | int options = dopt_none ) { | 139 | decode( char const *from, size_type from_len, ToStringType *to, |
1588 | 140 | int options = dopt_none ) { | ||
1589 | 137 | size_type decoded = 0; | 141 | size_type decoded = 0; |
1590 | 138 | if ( from_len ) { | 142 | if ( from_len ) { |
1591 | 139 | typename ToStringType::size_type const orig_size = to->size(); | 143 | typename ToStringType::size_type const orig_size = to->size(); |
1592 | @@ -175,8 +179,8 @@ | |||
1593 | 175 | * invalid byte is encountered. | 179 | * invalid byte is encountered. |
1594 | 176 | */ | 180 | */ |
1595 | 177 | template<class ToStringType> | 181 | template<class ToStringType> |
1598 | 178 | size_type decode( std::istream &from, ToStringType *to, | 182 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1599 | 179 | int options = dopt_none ) { | 183 | decode( std::istream &from, ToStringType *to, int options = dopt_none ) { |
1600 | 180 | bool const ignore_ws = !!(options & dopt_ignore_ws); | 184 | bool const ignore_ws = !!(options & dopt_ignore_ws); |
1601 | 181 | size_type total_decoded = 0; | 185 | size_type total_decoded = 0; |
1602 | 182 | while ( !from.eof() ) { | 186 | while ( !from.eof() ) { |
1603 | @@ -279,7 +283,8 @@ | |||
1604 | 279 | * @return Returns the number of encoded bytes. | 283 | * @return Returns the number of encoded bytes. |
1605 | 280 | */ | 284 | */ |
1606 | 281 | template<class ToStringType> | 285 | template<class ToStringType> |
1608 | 282 | size_type encode( char const *from, size_type from_len, ToStringType *to ) { | 286 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1609 | 287 | encode( char const *from, size_type from_len, ToStringType *to ) { | ||
1610 | 283 | size_type encoded = 0; | 288 | size_type encoded = 0; |
1611 | 284 | if ( from_len ) { | 289 | if ( from_len ) { |
1612 | 285 | typename ToStringType::size_type const orig_size = to->size(); | 290 | typename ToStringType::size_type const orig_size = to->size(); |
1613 | @@ -307,7 +312,8 @@ | |||
1614 | 307 | * @return Returns the number of encoded bytes. | 312 | * @return Returns the number of encoded bytes. |
1615 | 308 | */ | 313 | */ |
1616 | 309 | template<class ToStringType> | 314 | template<class ToStringType> |
1618 | 310 | size_type encode( std::istream &from, ToStringType *to ) { | 315 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1619 | 316 | encode( std::istream &from, ToStringType *to ) { | ||
1620 | 311 | size_type total_encoded = 0; | 317 | size_type total_encoded = 0; |
1621 | 312 | while ( !from.eof() ) { | 318 | while ( !from.eof() ) { |
1622 | 313 | char from_buf[ 1024 * 3 ], to_buf[ 1024 * 4 ]; | 319 | char from_buf[ 1024 * 3 ], to_buf[ 1024 * 4 ]; |
1623 | 314 | 320 | ||
1624 | === modified file 'src/util/error_util.h' | |||
1625 | --- src/util/error_util.h 2013-02-07 17:24:36 +0000 | |||
1626 | +++ src/util/error_util.h 2013-05-09 00:49:28 +0000 | |||
1627 | @@ -151,10 +151,7 @@ | |||
1628 | 151 | * @return Returns said error string. | 151 | * @return Returns said error string. |
1629 | 152 | */ | 152 | */ |
1630 | 153 | template<class StringType> inline | 153 | template<class StringType> inline |
1635 | 154 | typename std::enable_if< | 154 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),std::string>::type |
1632 | 155 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
1633 | 156 | std::string | ||
1634 | 157 | >::type | ||
1636 | 158 | get_err_string( StringType const &function, code_type code = get_err_code() ) { | 155 | get_err_string( StringType const &function, code_type code = get_err_code() ) { |
1637 | 159 | return get_err_string( function.c_str(), code ); | 156 | return get_err_string( function.c_str(), code ); |
1638 | 160 | } | 157 | } |
1639 | 161 | 158 | ||
1640 | === modified file 'src/util/fs_util.h' | |||
1641 | --- src/util/fs_util.h 2013-03-06 01:45:25 +0000 | |||
1642 | +++ src/util/fs_util.h 2013-05-09 00:49:28 +0000 | |||
1643 | @@ -123,9 +123,7 @@ | |||
1644 | 123 | * @param path The full path of the directory to change to. | 123 | * @param path The full path of the directory to change to. |
1645 | 124 | */ | 124 | */ |
1646 | 125 | template<class PathStringType> inline | 125 | template<class PathStringType> inline |
1650 | 126 | typename std::enable_if<ztd::has_c_str<PathStringType, | 126 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type |
1648 | 127 | char const* (PathStringType::*)() const>::value, | ||
1649 | 128 | void>::type | ||
1651 | 129 | chdir( PathStringType const &path ) { | 127 | chdir( PathStringType const &path ) { |
1652 | 130 | chdir( path.c_str() ); | 128 | chdir( path.c_str() ); |
1653 | 131 | } | 129 | } |
1654 | @@ -158,9 +156,7 @@ | |||
1655 | 158 | * @throws fs::exception if the creation fails. | 156 | * @throws fs::exception if the creation fails. |
1656 | 159 | */ | 157 | */ |
1657 | 160 | template<class PathStringType> inline | 158 | template<class PathStringType> inline |
1661 | 161 | typename std::enable_if<ztd::has_c_str<PathStringType, | 159 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type |
1659 | 162 | char const* (PathStringType::*)() const>::value, | ||
1660 | 163 | void>::type | ||
1662 | 164 | mkdir( PathStringType const &path ) { | 160 | mkdir( PathStringType const &path ) { |
1663 | 165 | mkdir( path.c_str() ); | 161 | mkdir( path.c_str() ); |
1664 | 166 | } | 162 | } |
1665 | @@ -191,10 +187,8 @@ | |||
1666 | 191 | */ | 187 | */ |
1667 | 192 | template<class PathStringType> | 188 | template<class PathStringType> |
1668 | 193 | iterator( PathStringType const &path, | 189 | iterator( PathStringType const &path, |
1673 | 194 | typename std::enable_if< | 190 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType) |
1674 | 195 | ztd::has_c_str<PathStringType, | 191 | >::type* = 0 ) : dir_path_( path.c_str() ) { |
1671 | 196 | char const* (PathStringType::*)() const>::value | ||
1672 | 197 | >::type* = 0 ) : dir_path_( path.c_str() ) { | ||
1675 | 198 | ctor_impl(); | 192 | ctor_impl(); |
1676 | 199 | } | 193 | } |
1677 | 200 | 194 | ||
1678 | @@ -292,9 +286,7 @@ | |||
1679 | 292 | * @throws fs::exception if the creation failed. | 286 | * @throws fs::exception if the creation failed. |
1680 | 293 | */ | 287 | */ |
1681 | 294 | template<class PathStringType> inline | 288 | template<class PathStringType> inline |
1685 | 295 | typename std::enable_if<ztd::has_c_str<PathStringType, | 289 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type |
1683 | 296 | char const* (PathStringType::*)() const>::value, | ||
1684 | 297 | void>::type | ||
1686 | 298 | create( PathStringType const &path ) { | 290 | create( PathStringType const &path ) { |
1687 | 299 | create( path.c_str() ); | 291 | create( path.c_str() ); |
1688 | 300 | } | 292 | } |
1689 | @@ -321,9 +313,7 @@ | |||
1690 | 321 | * @return Returns \c true only if the file or directory was removed. | 313 | * @return Returns \c true only if the file or directory was removed. |
1691 | 322 | */ | 314 | */ |
1692 | 323 | template<class PathStringType> inline | 315 | template<class PathStringType> inline |
1696 | 324 | typename std::enable_if<ztd::has_c_str<PathStringType, | 316 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),bool>::type |
1694 | 325 | char const* (PathStringType::*)() const>::value, | ||
1695 | 326 | bool>::type | ||
1697 | 327 | remove( PathStringType const &path ) { | 317 | remove( PathStringType const &path ) { |
1698 | 328 | return remove( path.c_str() ); | 318 | return remove( path.c_str() ); |
1699 | 329 | } | 319 | } |
1700 | @@ -510,9 +500,7 @@ | |||
1701 | 510 | * then returns \a path. | 500 | * then returns \a path. |
1702 | 511 | */ | 501 | */ |
1703 | 512 | template<class PathStringType> inline | 502 | template<class PathStringType> inline |
1707 | 513 | typename std::enable_if<ztd::has_c_str<PathStringType, | 503 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),char const*>::type |
1705 | 514 | char const* (PathStringType::*)() const>::value, | ||
1706 | 515 | char const*>::type | ||
1708 | 516 | base_name( PathStringType const &path ) { | 504 | base_name( PathStringType const &path ) { |
1709 | 517 | return base_name( path.c_str() ); | 505 | return base_name( path.c_str() ); |
1710 | 518 | } | 506 | } |
1711 | @@ -546,9 +534,7 @@ | |||
1712 | 546 | * \a path does not refer to a symbolic link, returns the type of \a path. | 534 | * \a path does not refer to a symbolic link, returns the type of \a path. |
1713 | 547 | */ | 535 | */ |
1714 | 548 | template<class PathStringType> inline | 536 | template<class PathStringType> inline |
1718 | 549 | typename std::enable_if<ztd::has_c_str<PathStringType, | 537 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),type>::type |
1716 | 550 | char const* (PathStringType::*)() const>::value, | ||
1717 | 551 | type>::type | ||
1719 | 552 | get_type( PathStringType const &path, bool follow_symlink = true, | 538 | get_type( PathStringType const &path, bool follow_symlink = true, |
1720 | 553 | size_type *size = nullptr ) { | 539 | size_type *size = nullptr ) { |
1721 | 554 | return get_type( path.c_str(), follow_symlink, size ); | 540 | return get_type( path.c_str(), follow_symlink, size ); |
1722 | @@ -580,9 +566,7 @@ | |||
1723 | 580 | * @return Returns \c true only if the path is absolute. | 566 | * @return Returns \c true only if the path is absolute. |
1724 | 581 | */ | 567 | */ |
1725 | 582 | template<class PathStringType> inline | 568 | template<class PathStringType> inline |
1729 | 583 | typename std::enable_if<ztd::has_c_str<PathStringType, | 569 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),bool>::type |
1727 | 584 | char const* (PathStringType::*)() const>::value, | ||
1728 | 585 | bool>::type | ||
1730 | 586 | is_absolute( PathStringType const &path ) { | 570 | is_absolute( PathStringType const &path ) { |
1731 | 587 | return is_absolute( path.c_str() ); | 571 | return is_absolute( path.c_str() ); |
1732 | 588 | } | 572 | } |
1733 | @@ -609,9 +593,7 @@ | |||
1734 | 609 | * @throws fs::exception if the rename fails. | 593 | * @throws fs::exception if the rename fails. |
1735 | 610 | */ | 594 | */ |
1736 | 611 | template<class FromStringType> inline | 595 | template<class FromStringType> inline |
1740 | 612 | typename std::enable_if<ztd::has_c_str<FromStringType, | 596 | typename std::enable_if<ZORBA_HAS_C_STR(FromStringType),void>::type |
1738 | 613 | char const* (FromStringType::*)() const>::value, | ||
1739 | 614 | void>::type | ||
1741 | 615 | rename( FromStringType const &from, char const *to ) { | 597 | rename( FromStringType const &from, char const *to ) { |
1742 | 616 | rename( from.c_str(), to ); | 598 | rename( from.c_str(), to ); |
1743 | 617 | } | 599 | } |
1744 | @@ -625,9 +607,7 @@ | |||
1745 | 625 | * @throws fs::exception if the rename fails. | 607 | * @throws fs::exception if the rename fails. |
1746 | 626 | */ | 608 | */ |
1747 | 627 | template<class ToStringType> inline | 609 | template<class ToStringType> inline |
1751 | 628 | typename std::enable_if<ztd::has_c_str<ToStringType, | 610 | typename std::enable_if<ZORBA_HAS_C_STR(ToStringType),void>::type |
1749 | 629 | char const* (ToStringType::*)() const>::value, | ||
1750 | 630 | void>::type | ||
1752 | 631 | rename( char const *from, ToStringType const &to ) { | 611 | rename( char const *from, ToStringType const &to ) { |
1753 | 632 | rename( from, to.c_str() ); | 612 | rename( from, to.c_str() ); |
1754 | 633 | } | 613 | } |
1755 | @@ -642,10 +622,8 @@ | |||
1756 | 642 | * @throws fs::exception if the rename fails. | 622 | * @throws fs::exception if the rename fails. |
1757 | 643 | */ | 623 | */ |
1758 | 644 | template<class FromStringType,class ToStringType> inline | 624 | template<class FromStringType,class ToStringType> inline |
1763 | 645 | typename std::enable_if<ztd::has_c_str<FromStringType, | 625 | typename std::enable_if<ZORBA_HAS_C_STR(FromStringType) |
1764 | 646 | char const* (FromStringType::*)() const>::value | 626 | && ZORBA_HAS_C_STR(ToStringType), |
1761 | 647 | && ztd::has_c_str<ToStringType, | ||
1762 | 648 | char const* (ToStringType::*)() const>::value, | ||
1765 | 649 | void>::type | 627 | void>::type |
1766 | 650 | rename( FromStringType const &from, ToStringType const &to ) { | 628 | rename( FromStringType const &from, ToStringType const &to ) { |
1767 | 651 | rename( from.c_str(), to.c_str() ); | 629 | rename( from.c_str(), to.c_str() ); |
1768 | @@ -675,9 +653,7 @@ | |||
1769 | 675 | * @throws XQueryException err::XPTY0004 for malformed paths. | 653 | * @throws XQueryException err::XPTY0004 for malformed paths. |
1770 | 676 | */ | 654 | */ |
1771 | 677 | template<class PathStringType> inline | 655 | template<class PathStringType> inline |
1775 | 678 | typename std::enable_if<ztd::has_c_str<PathStringType, | 656 | typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),zstring>::type |
1773 | 679 | char const* (PathStringType::*)() const>::value, | ||
1774 | 680 | zstring>::type | ||
1776 | 681 | get_normalized_path( PathStringType const &path, | 657 | get_normalized_path( PathStringType const &path, |
1777 | 682 | PathStringType const &base = "" ) { | 658 | PathStringType const &base = "" ) { |
1778 | 683 | return get_normalized_path( path.c_str(), base.c_str() ); | 659 | return get_normalized_path( path.c_str(), base.c_str() ); |
1779 | @@ -693,9 +669,7 @@ | |||
1780 | 693 | * @throws XQueryException err::XPTY0004 for malformed paths. | 669 | * @throws XQueryException err::XPTY0004 for malformed paths. |
1781 | 694 | */ | 670 | */ |
1782 | 695 | template<class PathStringType> inline | 671 | template<class PathStringType> inline |
1786 | 696 | typename std::enable_if<ztd::has_c_str<PathStringType, | 672 | typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type |
1784 | 697 | char const* (PathStringType::*)() const>::value, | ||
1785 | 698 | void>::type | ||
1787 | 699 | normalize_path( PathStringType &path, PathStringType const &base = "" ) { | 673 | normalize_path( PathStringType &path, PathStringType const &base = "" ) { |
1788 | 700 | path = get_normalized_path( path, base ); | 674 | path = get_normalized_path( path, base ); |
1789 | 701 | } | 675 | } |
1790 | @@ -711,9 +685,7 @@ | |||
1791 | 711 | * @param path2 The path to append. | 685 | * @param path2 The path to append. |
1792 | 712 | */ | 686 | */ |
1793 | 713 | template<class PathStringType1> inline | 687 | template<class PathStringType1> inline |
1797 | 714 | typename std::enable_if<ztd::has_c_str<PathStringType1, | 688 | typename std::enable_if<ZORBA_IS_STRING(PathStringType1),void>::type |
1795 | 715 | char const* (PathStringType1::*)() const>::value, | ||
1796 | 716 | void>::type | ||
1798 | 717 | append( PathStringType1 &path1, char const *path2 ) { | 689 | append( PathStringType1 &path1, char const *path2 ) { |
1799 | 718 | if ( !ascii::ends_with( path1, dir_separator ) ) | 690 | if ( !ascii::ends_with( path1, dir_separator ) ) |
1800 | 719 | path1 += dir_separator; | 691 | path1 += dir_separator; |
1801 | @@ -729,10 +701,8 @@ | |||
1802 | 729 | * @param path2 The path to append. | 701 | * @param path2 The path to append. |
1803 | 730 | */ | 702 | */ |
1804 | 731 | template<class PathStringType1,class PathStringType2> inline | 703 | template<class PathStringType1,class PathStringType2> inline |
1809 | 732 | typename std::enable_if<ztd::has_c_str<PathStringType1, | 704 | typename std::enable_if<ZORBA_IS_STRING(PathStringType1) |
1810 | 733 | char const* (PathStringType1::*)() const>::value | 705 | && ZORBA_HAS_C_STR(PathStringType2), |
1807 | 734 | && ztd::has_c_str<PathStringType2, | ||
1808 | 735 | char const* (PathStringType2::*)() const>::value, | ||
1811 | 736 | void>::type | 706 | void>::type |
1812 | 737 | append( PathStringType1 &path1, PathStringType2 const &path2 ) { | 707 | append( PathStringType1 &path1, PathStringType2 const &path2 ) { |
1813 | 738 | append( path1, path2.c_str() ); | 708 | append( path1, path2.c_str() ); |
1814 | @@ -745,9 +715,7 @@ | |||
1815 | 745 | * @param path The path to make absolute. | 715 | * @param path The path to make absolute. |
1816 | 746 | */ | 716 | */ |
1817 | 747 | template<class PathStringType> inline | 717 | template<class PathStringType> inline |
1821 | 748 | typename std::enable_if<ztd::has_c_str<PathStringType, | 718 | typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type |
1819 | 749 | char const* (PathStringType::*)() const>::value, | ||
1820 | 750 | void>::type | ||
1822 | 751 | make_absolute( PathStringType &path ) { | 719 | make_absolute( PathStringType &path ) { |
1823 | 752 | if ( !is_absolute( path ) ) { | 720 | if ( !is_absolute( path ) ) { |
1824 | 753 | #ifndef WIN32 | 721 | #ifndef WIN32 |
1825 | @@ -783,9 +751,7 @@ | |||
1826 | 783 | * @throws fs::exception if the operation fails. | 751 | * @throws fs::exception if the operation fails. |
1827 | 784 | */ | 752 | */ |
1828 | 785 | template<class PathStringType> inline | 753 | template<class PathStringType> inline |
1832 | 786 | typename std::enable_if<ztd::has_c_str<PathStringType, | 754 | typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type |
1830 | 787 | char const* (PathStringType::*)() const>::value, | ||
1831 | 788 | void>::type | ||
1833 | 789 | get_temp_file( PathStringType *path ) { | 755 | get_temp_file( PathStringType *path ) { |
1834 | 790 | char path_buf[ MAX_PATH ]; | 756 | char path_buf[ MAX_PATH ]; |
1835 | 791 | get_temp_file( path_buf ); | 757 | get_temp_file( path_buf ); |
1836 | 792 | 758 | ||
1837 | === modified file 'src/util/hexbinary_util.cpp' | |||
1838 | --- src/util/hexbinary_util.cpp 2013-04-16 22:12:03 +0000 | |||
1839 | +++ src/util/hexbinary_util.cpp 2013-05-09 00:49:28 +0000 | |||
1840 | @@ -75,7 +75,7 @@ | |||
1841 | 75 | int options ) { | 75 | int options ) { |
1842 | 76 | bool const ignore_ws = !!(options & dopt_ignore_ws); | 76 | bool const ignore_ws = !!(options & dopt_ignore_ws); |
1843 | 77 | if ( ignore_ws ) | 77 | if ( ignore_ws ) |
1845 | 78 | from = ascii::trim_whitespace( from, &from_len ); | 78 | from = ascii::trim_space( from, &from_len ); |
1846 | 79 | if ( from_len % 2 ) | 79 | if ( from_len % 2 ) |
1847 | 80 | throw invalid_argument( "HexBinary length is not a multiple of 2" ); | 80 | throw invalid_argument( "HexBinary length is not a multiple of 2" ); |
1848 | 81 | 81 | ||
1849 | @@ -107,7 +107,7 @@ | |||
1850 | 107 | std::vector<char> *to, int options ) { | 107 | std::vector<char> *to, int options ) { |
1851 | 108 | bool const ignore_ws = !!(options & dopt_ignore_ws); | 108 | bool const ignore_ws = !!(options & dopt_ignore_ws); |
1852 | 109 | if ( ignore_ws ) | 109 | if ( ignore_ws ) |
1854 | 110 | from = ascii::trim_whitespace( from, &from_len ); | 110 | from = ascii::trim_space( from, &from_len ); |
1855 | 111 | if ( from_len % 2 ) | 111 | if ( from_len % 2 ) |
1856 | 112 | throw invalid_argument( "HexBinary length is not a multiple of 2" ); | 112 | throw invalid_argument( "HexBinary length is not a multiple of 2" ); |
1857 | 113 | size_type decoded = 0; | 113 | size_type decoded = 0; |
1858 | 114 | 114 | ||
1859 | === modified file 'src/util/hexbinary_util.h' | |||
1860 | --- src/util/hexbinary_util.h 2013-04-16 22:12:03 +0000 | |||
1861 | +++ src/util/hexbinary_util.h 2013-05-09 00:49:28 +0000 | |||
1862 | @@ -128,8 +128,9 @@ | |||
1863 | 128 | * @throws hexbinary::exception if an invalid byte is encountered. | 128 | * @throws hexbinary::exception if an invalid byte is encountered. |
1864 | 129 | */ | 129 | */ |
1865 | 130 | template<class ToStringType> | 130 | template<class ToStringType> |
1868 | 131 | size_type decode( char const *from, size_type from_len, ToStringType *to, | 131 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1869 | 132 | int options = dopt_none ) { | 132 | decode( char const *from, size_type from_len, ToStringType *to, |
1870 | 133 | int options = dopt_none ) { | ||
1871 | 133 | size_type decoded = 0; | 134 | size_type decoded = 0; |
1872 | 134 | if ( from_len ) { | 135 | if ( from_len ) { |
1873 | 135 | typename ToStringType::size_type const orig_size = to->size(); | 136 | typename ToStringType::size_type const orig_size = to->size(); |
1874 | @@ -168,7 +169,8 @@ | |||
1875 | 168 | * @throws hexbinary::exception if an invalid byte is encountered. | 169 | * @throws hexbinary::exception if an invalid byte is encountered. |
1876 | 169 | */ | 170 | */ |
1877 | 170 | template<class ToStringType> | 171 | template<class ToStringType> |
1879 | 171 | size_type decode( std::istream &from, ToStringType *to, | 172 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1880 | 173 | decode( std::istream &from, ToStringType *to, | ||
1881 | 172 | int options = dopt_none ) { | 174 | int options = dopt_none ) { |
1882 | 173 | bool const ignore_ws = !!(options & dopt_ignore_ws); | 175 | bool const ignore_ws = !!(options & dopt_ignore_ws); |
1883 | 174 | size_type total_decoded = 0; | 176 | size_type total_decoded = 0; |
1884 | @@ -269,7 +271,8 @@ | |||
1885 | 269 | * @return Returns the number of encoded bytes. | 271 | * @return Returns the number of encoded bytes. |
1886 | 270 | */ | 272 | */ |
1887 | 271 | template<class ToStringType> | 273 | template<class ToStringType> |
1889 | 272 | size_type encode( char const *from, size_type from_len, ToStringType *to ) { | 274 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1890 | 275 | encode( char const *from, size_type from_len, ToStringType *to ) { | ||
1891 | 273 | size_type encoded = 0; | 276 | size_type encoded = 0; |
1892 | 274 | if ( from_len ) { | 277 | if ( from_len ) { |
1893 | 275 | typename ToStringType::size_type const orig_size = to->size(); | 278 | typename ToStringType::size_type const orig_size = to->size(); |
1894 | @@ -296,7 +299,8 @@ | |||
1895 | 296 | * @return Returns the number of encoded bytes. | 299 | * @return Returns the number of encoded bytes. |
1896 | 297 | */ | 300 | */ |
1897 | 298 | template<class ToStringType> | 301 | template<class ToStringType> |
1899 | 299 | size_type encode( std::istream &from, ToStringType *to ) { | 302 | typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type |
1900 | 303 | encode( std::istream &from, ToStringType *to ) { | ||
1901 | 300 | size_type total_encoded = 0; | 304 | size_type total_encoded = 0; |
1902 | 301 | while ( !from.eof() ) { | 305 | while ( !from.eof() ) { |
1903 | 302 | char from_buf[ 1024 * 2 ], to_buf[ 1024 ]; | 306 | char from_buf[ 1024 * 2 ], to_buf[ 1024 ]; |
1904 | 303 | 307 | ||
1905 | === modified file 'src/util/icu_streambuf.cpp' | |||
1906 | --- src/util/icu_streambuf.cpp 2013-04-16 22:12:03 +0000 | |||
1907 | +++ src/util/icu_streambuf.cpp 2013-05-09 00:49:28 +0000 | |||
1908 | @@ -110,7 +110,7 @@ | |||
1909 | 110 | // "ASCII", so check for "US-ASCII" ourselves. | 110 | // "ASCII", so check for "US-ASCII" ourselves. |
1910 | 111 | // | 111 | // |
1911 | 112 | zstring charset( cc_charset ); | 112 | zstring charset( cc_charset ); |
1913 | 113 | ascii::trim_whitespace( charset ); | 113 | ascii::trim_space( charset ); |
1914 | 114 | ascii::to_upper( charset ); | 114 | ascii::to_upper( charset ); |
1915 | 115 | if ( charset == "US-ASCII" ) | 115 | if ( charset == "US-ASCII" ) |
1916 | 116 | cc_charset += 3; // skip "US-" | 116 | cc_charset += 3; // skip "US-" |
1917 | 117 | 117 | ||
1918 | === modified file 'src/util/json_util.h' | |||
1919 | --- src/util/json_util.h 2012-07-25 23:20:47 +0000 | |||
1920 | +++ src/util/json_util.h 2013-05-09 00:49:28 +0000 | |||
1921 | @@ -52,9 +52,7 @@ | |||
1922 | 52 | * @return Returns \a os. | 52 | * @return Returns \a os. |
1923 | 53 | */ | 53 | */ |
1924 | 54 | template<class StringType> inline | 54 | template<class StringType> inline |
1928 | 55 | typename std::enable_if<ztd::has_c_str<StringType, | 55 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),std::ostream&>::type |
1926 | 56 | char const* (StringType::*)() const>::value, | ||
1927 | 57 | std::ostream&>::type | ||
1929 | 58 | serialize( std::ostream &os, StringType const &s ) { | 56 | serialize( std::ostream &os, StringType const &s ) { |
1930 | 59 | return serialize( os, s.c_str() ); | 57 | return serialize( os, s.c_str() ); |
1931 | 60 | } | 58 | } |
1932 | 61 | 59 | ||
1933 | === modified file 'src/util/passthru_streambuf.cpp' | |||
1934 | --- src/util/passthru_streambuf.cpp 2013-04-12 04:34:41 +0000 | |||
1935 | +++ src/util/passthru_streambuf.cpp 2013-05-09 00:49:28 +0000 | |||
1936 | @@ -44,7 +44,7 @@ | |||
1937 | 44 | if ( !*cc_charset ) | 44 | if ( !*cc_charset ) |
1938 | 45 | throw invalid_argument( "empty charset" ); | 45 | throw invalid_argument( "empty charset" ); |
1939 | 46 | zstring charset( cc_charset ); | 46 | zstring charset( cc_charset ); |
1941 | 47 | ascii::trim_whitespace( charset ); | 47 | ascii::trim_space( charset ); |
1942 | 48 | ascii::to_upper( charset ); | 48 | ascii::to_upper( charset ); |
1943 | 49 | return charset != "ASCII" | 49 | return charset != "ASCII" |
1944 | 50 | && charset != "US-ASCII" | 50 | && charset != "US-ASCII" |
1945 | 51 | 51 | ||
1946 | === modified file 'src/util/stl_util.h' | |||
1947 | --- src/util/stl_util.h 2013-05-08 20:14:47 +0000 | |||
1948 | +++ src/util/stl_util.h 2013-05-09 00:49:28 +0000 | |||
1949 | @@ -80,7 +80,7 @@ | |||
1950 | 80 | } | 80 | } |
1951 | 81 | 81 | ||
1952 | 82 | protected: | 82 | protected: |
1954 | 83 | back_insert_iterator_base( ContainerType &c ) : container( &c ) { | 83 | back_insert_iterator_base( ContainerType *c ) : container( c ) { |
1955 | 84 | } | 84 | } |
1956 | 85 | 85 | ||
1957 | 86 | /** | 86 | /** |
1958 | 87 | 87 | ||
1959 | === modified file 'src/util/stream_util.cpp' | |||
1960 | --- src/util/stream_util.cpp 2013-04-16 22:12:03 +0000 | |||
1961 | +++ src/util/stream_util.cpp 2013-05-09 00:49:28 +0000 | |||
1962 | @@ -62,7 +62,7 @@ | |||
1963 | 62 | while ( buf < buf_end ) { | 62 | while ( buf < buf_end ) { |
1964 | 63 | is.read( buf, n ); | 63 | is.read( buf, n ); |
1965 | 64 | if ( streamsize read = is.gcount() ) { | 64 | if ( streamsize read = is.gcount() ) { |
1967 | 65 | read = ascii::remove_whitespace( | 65 | read = ascii::remove_space( |
1968 | 66 | buf, static_cast<ascii::size_type>( read ) | 66 | buf, static_cast<ascii::size_type>( read ) |
1969 | 67 | ); | 67 | ); |
1970 | 68 | buf += read, n -= read; | 68 | buf += read, n -= read; |
1971 | 69 | 69 | ||
1972 | === modified file 'src/util/string_util.cpp' | |||
1973 | --- src/util/string_util.cpp 2013-04-16 03:48:46 +0000 | |||
1974 | +++ src/util/string_util.cpp 2013-05-09 00:49:28 +0000 | |||
1975 | @@ -131,7 +131,7 @@ | |||
1976 | 131 | // | 131 | // |
1977 | 132 | // We have to check for '-' ourselves since strtoull(3) allows it (oddly). | 132 | // We have to check for '-' ourselves since strtoull(3) allows it (oddly). |
1978 | 133 | // | 133 | // |
1980 | 134 | buf = ascii::trim_start_whitespace( buf ); | 134 | buf = ascii::trim_start_space( buf ); |
1981 | 135 | bool const minus = *buf == '-'; | 135 | bool const minus = *buf == '-'; |
1982 | 136 | 136 | ||
1983 | 137 | unsigned long long const result = std::strtoull( buf, (char**)last, 10 ); | 137 | unsigned long long const result = std::strtoull( buf, (char**)last, 10 ); |
1984 | @@ -153,7 +153,7 @@ | |||
1985 | 153 | long long atoll( char const *buf, char const *end, char const **last ) { | 153 | long long atoll( char const *buf, char const *end, char const **last ) { |
1986 | 154 | aton_context const ctx( last ); | 154 | aton_context const ctx( last ); |
1987 | 155 | long long n = 0; | 155 | long long n = 0; |
1989 | 156 | char const *s0 = ascii::trim_start_whitespace( buf, end - buf ); | 156 | char const *s0 = ascii::trim_start_space( buf, end - buf ); |
1990 | 157 | char const *s = s0; | 157 | char const *s = s0; |
1991 | 158 | 158 | ||
1992 | 159 | if ( s < end ) { | 159 | if ( s < end ) { |
1993 | @@ -190,7 +190,7 @@ | |||
1994 | 190 | char const **last ) { | 190 | char const **last ) { |
1995 | 191 | aton_context const ctx( last ); | 191 | aton_context const ctx( last ); |
1996 | 192 | unsigned long long n = 0; | 192 | unsigned long long n = 0; |
1998 | 193 | char const *s0 = ascii::trim_start_whitespace( buf, end - buf ); | 193 | char const *s0 = ascii::trim_start_space( buf, end - buf ); |
1999 | 194 | char const *s = s0; | 194 | char const *s = s0; |
2000 | 195 | 195 | ||
2001 | 196 | if ( s < end ) { | 196 | if ( s < end ) { |
2002 | 197 | 197 | ||
2003 | === modified file 'src/util/string_util.h' | |||
2004 | --- src/util/string_util.h 2013-04-16 02:30:37 +0000 | |||
2005 | +++ src/util/string_util.h 2013-05-09 00:49:28 +0000 | |||
2006 | @@ -171,8 +171,9 @@ | |||
2007 | 171 | * @return Returns \c true only if \a s1 \c == \a s2. | 171 | * @return Returns \c true only if \a s1 \c == \a s2. |
2008 | 172 | */ | 172 | */ |
2009 | 173 | template<class StringType> inline | 173 | template<class StringType> inline |
2012 | 174 | bool equals( StringType const &s1, char const *s2, | 174 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2013 | 175 | typename StringType::size_type s2_n ) { | 175 | equals( StringType const &s1, char const *s2, |
2014 | 176 | typename StringType::size_type s2_n ) { | ||
2015 | 176 | typedef typename StringType::traits_type traits_type; | 177 | typedef typename StringType::traits_type traits_type; |
2016 | 177 | return s1.size() == s2_n && traits_type::compare( s1.data(), s2, s2_n ) == 0; | 178 | return s1.size() == s2_n && traits_type::compare( s1.data(), s2, s2_n ) == 0; |
2017 | 178 | } | 179 | } |
2018 | @@ -186,8 +187,9 @@ | |||
2019 | 186 | * @return Returns \c true only if \a s1 \c == \a s2. | 187 | * @return Returns \c true only if \a s1 \c == \a s2. |
2020 | 187 | */ | 188 | */ |
2021 | 188 | template<class StringType> inline | 189 | template<class StringType> inline |
2024 | 189 | bool equals( char const *s1, typename StringType::size_type s1_n, | 190 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2025 | 190 | StringType const &s2 ) { | 191 | equals( char const *s1, typename StringType::size_type s1_n, |
2026 | 192 | StringType const &s2 ) { | ||
2027 | 191 | typedef typename StringType::traits_type traits_type; | 193 | typedef typename StringType::traits_type traits_type; |
2028 | 192 | return s1_n == s2.size() && traits_type::compare( s1, s2.data(), s1_n ) == 0; | 194 | return s1_n == s2.size() && traits_type::compare( s1, s2.data(), s1_n ) == 0; |
2029 | 193 | } | 195 | } |
2030 | @@ -215,8 +217,11 @@ | |||
2031 | 215 | * present in \a in). | 217 | * present in \a in). |
2032 | 216 | */ | 218 | */ |
2033 | 217 | template<class OutputStringType1,class OutputStringType2> | 219 | template<class OutputStringType1,class OutputStringType2> |
2036 | 218 | bool split( char const *in, char delim, OutputStringType1 *out1, | 220 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType1) |
2037 | 219 | OutputStringType2 *out2 ) { | 221 | && ZORBA_IS_STRING(OutputStringType2), |
2038 | 222 | bool>::type | ||
2039 | 223 | split( char const *in, char delim, OutputStringType1 *out1, | ||
2040 | 224 | OutputStringType2 *out2 ) { | ||
2041 | 220 | if ( char const *const pos = std::strchr( in, delim ) ) { | 225 | if ( char const *const pos = std::strchr( in, delim ) ) { |
2042 | 221 | if ( out1 ) | 226 | if ( out1 ) |
2043 | 222 | *out1 = OutputStringType1( in, pos - in ); | 227 | *out1 = OutputStringType1( in, pos - in ); |
2044 | @@ -229,13 +234,15 @@ | |||
2045 | 229 | 234 | ||
2046 | 230 | // Allows out1 to be nullptr. | 235 | // Allows out1 to be nullptr. |
2047 | 231 | template<class OutputStringType2> inline | 236 | template<class OutputStringType2> inline |
2049 | 232 | bool split( char const *in, char delim, void*, OutputStringType2 *out2 ) { | 237 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType2),bool>::type |
2050 | 238 | split( char const *in, char delim, void*, OutputStringType2 *out2 ) { | ||
2051 | 233 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); | 239 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); |
2052 | 234 | } | 240 | } |
2053 | 235 | 241 | ||
2054 | 236 | // Allows out2 to be nullptr. | 242 | // Allows out2 to be nullptr. |
2055 | 237 | template<class OutputStringType1> inline | 243 | template<class OutputStringType1> inline |
2057 | 238 | bool split( char const *in, char delim, OutputStringType1 *out1, void* ) { | 244 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType1),bool>::type |
2058 | 245 | split( char const *in, char delim, OutputStringType1 *out1, void* ) { | ||
2059 | 239 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); | 246 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); |
2060 | 240 | } | 247 | } |
2061 | 241 | 248 | ||
2062 | @@ -255,22 +262,31 @@ | |||
2063 | 255 | * present in \a in). | 262 | * present in \a in). |
2064 | 256 | */ | 263 | */ |
2065 | 257 | template<class InputStringType,class OutputStringType1,class OutputStringType2> | 264 | template<class InputStringType,class OutputStringType1,class OutputStringType2> |
2067 | 258 | inline bool split( InputStringType const &in, char delim, | 265 | inline |
2068 | 266 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) | ||
2069 | 267 | && ZORBA_IS_STRING(OutputStringType1) | ||
2070 | 268 | && ZORBA_IS_STRING(OutputStringType2), | ||
2071 | 269 | bool>::type | ||
2072 | 270 | split( InputStringType const &in, char delim, | ||
2073 | 259 | OutputStringType1 *out1, OutputStringType2 *out2 ) { | 271 | OutputStringType1 *out1, OutputStringType2 *out2 ) { |
2074 | 260 | return split( in.c_str(), delim, out1, out2 ); | 272 | return split( in.c_str(), delim, out1, out2 ); |
2075 | 261 | } | 273 | } |
2076 | 262 | 274 | ||
2077 | 263 | // Allows out1 to be nullptr. | 275 | // Allows out1 to be nullptr. |
2078 | 264 | template<class InputStringType,class OutputStringType2> inline | 276 | template<class InputStringType,class OutputStringType2> inline |
2081 | 265 | bool split( InputStringType const &in, char delim, void*, | 277 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2082 | 266 | OutputStringType2 *out2 ) { | 278 | && ZORBA_IS_STRING(OutputStringType2), |
2083 | 279 | bool>::type | ||
2084 | 280 | split( InputStringType const &in, char delim, void*, OutputStringType2 *out2 ) { | ||
2085 | 267 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); | 281 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); |
2086 | 268 | } | 282 | } |
2087 | 269 | 283 | ||
2088 | 270 | // Allows out2 to be nullptr. | 284 | // Allows out2 to be nullptr. |
2089 | 271 | template<class InputStringType,class OutputStringType1> inline | 285 | template<class InputStringType,class OutputStringType1> inline |
2092 | 272 | bool split( InputStringType const &in, char delim, OutputStringType1 *out1, | 286 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2093 | 273 | void* ) { | 287 | && ZORBA_IS_STRING(OutputStringType1), |
2094 | 288 | bool>::type | ||
2095 | 289 | split( InputStringType const &in, char delim, OutputStringType1 *out1, void* ) { | ||
2096 | 274 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); | 290 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); |
2097 | 275 | } | 291 | } |
2098 | 276 | 292 | ||
2099 | @@ -289,8 +305,11 @@ | |||
2100 | 289 | * present in \a in). | 305 | * present in \a in). |
2101 | 290 | */ | 306 | */ |
2102 | 291 | template<class OutputStringType1,class OutputStringType2> | 307 | template<class OutputStringType1,class OutputStringType2> |
2105 | 292 | bool split( char const *in, char const *delim, OutputStringType1 *out1, | 308 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType1) |
2106 | 293 | OutputStringType2 *out2 ) { | 309 | && ZORBA_IS_STRING(OutputStringType2), |
2107 | 310 | bool>::type | ||
2108 | 311 | split( char const *in, char const *delim, OutputStringType1 *out1, | ||
2109 | 312 | OutputStringType2 *out2 ) { | ||
2110 | 294 | if ( *delim ) | 313 | if ( *delim ) |
2111 | 295 | if ( char const *const pos = std::strstr( in, delim ) ) { | 314 | if ( char const *const pos = std::strstr( in, delim ) ) { |
2112 | 296 | if ( out1 ) | 315 | if ( out1 ) |
2113 | @@ -304,15 +323,15 @@ | |||
2114 | 304 | 323 | ||
2115 | 305 | // Allows out1 to be nullptr. | 324 | // Allows out1 to be nullptr. |
2116 | 306 | template<class OutputStringType2> inline | 325 | template<class OutputStringType2> inline |
2119 | 307 | bool split( char const *in, char const *delim, void*, | 326 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType2),bool>::type |
2120 | 308 | OutputStringType2 *out2 ) { | 327 | split( char const *in, char const *delim, void*, OutputStringType2 *out2 ) { |
2121 | 309 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); | 328 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); |
2122 | 310 | } | 329 | } |
2123 | 311 | 330 | ||
2124 | 312 | // Allows out2 to be nullptr. | 331 | // Allows out2 to be nullptr. |
2125 | 313 | template<class OutputStringType1> inline | 332 | template<class OutputStringType1> inline |
2128 | 314 | bool split( char const *in, char const *delim, OutputStringType1 *out1, | 333 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType1),bool>::type |
2129 | 315 | void* ) { | 334 | split( char const *in, char const *delim, OutputStringType1 *out1, void* ) { |
2130 | 316 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); | 335 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); |
2131 | 317 | } | 336 | } |
2132 | 318 | 337 | ||
2133 | @@ -332,22 +351,33 @@ | |||
2134 | 332 | * present in \a in). | 351 | * present in \a in). |
2135 | 333 | */ | 352 | */ |
2136 | 334 | template<class InputStringType,class OutputStringType1,class OutputStringType2> | 353 | template<class InputStringType,class OutputStringType1,class OutputStringType2> |
2139 | 335 | inline bool split( InputStringType const &in, char const *delim, | 354 | inline |
2140 | 336 | OutputStringType1 *out1, OutputStringType2 *out2 ) { | 355 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2141 | 356 | && ZORBA_IS_STRING(OutputStringType1) | ||
2142 | 357 | && ZORBA_IS_STRING(OutputStringType2), | ||
2143 | 358 | bool>::type | ||
2144 | 359 | split( InputStringType const &in, char const *delim, OutputStringType1 *out1, | ||
2145 | 360 | OutputStringType2 *out2 ) { | ||
2146 | 337 | return split( in.c_str(), delim, out1, out2 ); | 361 | return split( in.c_str(), delim, out1, out2 ); |
2147 | 338 | } | 362 | } |
2148 | 339 | 363 | ||
2149 | 340 | // Allows out1 to be nullptr. | 364 | // Allows out1 to be nullptr. |
2150 | 341 | template<class InputStringType,class OutputStringType2> inline | 365 | template<class InputStringType,class OutputStringType2> inline |
2152 | 342 | bool split( InputStringType const &in, char const *delim, void*, | 366 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2153 | 367 | && ZORBA_IS_STRING(OutputStringType2), | ||
2154 | 368 | bool>::type | ||
2155 | 369 | split( InputStringType const &in, char const *delim, void*, | ||
2156 | 343 | OutputStringType2 *out2 ) { | 370 | OutputStringType2 *out2 ) { |
2157 | 344 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); | 371 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); |
2158 | 345 | } | 372 | } |
2159 | 346 | 373 | ||
2160 | 347 | // Allows out2 to be nullptr. | 374 | // Allows out2 to be nullptr. |
2161 | 348 | template<class InputStringType,class OutputStringType1> inline | 375 | template<class InputStringType,class OutputStringType1> inline |
2164 | 349 | bool split( InputStringType const &in, char const *delim, | 376 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2165 | 350 | OutputStringType1 *out1, void* ) { | 377 | && ZORBA_IS_STRING(OutputStringType1), |
2166 | 378 | bool>::type | ||
2167 | 379 | split( InputStringType const &in, char const *delim, OutputStringType1 *out1, | ||
2168 | 380 | void* ) { | ||
2169 | 351 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); | 381 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); |
2170 | 352 | } | 382 | } |
2171 | 353 | 383 | ||
2172 | @@ -373,8 +403,13 @@ | |||
2173 | 373 | class OutputStringType1, | 403 | class OutputStringType1, |
2174 | 374 | class OutputStringType2 | 404 | class OutputStringType2 |
2175 | 375 | > | 405 | > |
2178 | 376 | bool split( InputStringType const &in, DelimStringType const &delim, | 406 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2179 | 377 | OutputStringType1 *out1, OutputStringType2 *out2 ) { | 407 | && ZORBA_IS_STRING(DelimStringType) |
2180 | 408 | && ZORBA_IS_STRING(OutputStringType1) | ||
2181 | 409 | && ZORBA_IS_STRING(OutputStringType2), | ||
2182 | 410 | bool>::type | ||
2183 | 411 | split( InputStringType const &in, DelimStringType const &delim, | ||
2184 | 412 | OutputStringType1 *out1, OutputStringType2 *out2 ) { | ||
2185 | 378 | typename InputStringType::size_type const pos = in.find( delim ); | 413 | typename InputStringType::size_type const pos = in.find( delim ); |
2186 | 379 | if ( pos != InputStringType::npos ) { | 414 | if ( pos != InputStringType::npos ) { |
2187 | 380 | if ( out1 ) | 415 | if ( out1 ) |
2188 | @@ -387,24 +422,26 @@ | |||
2189 | 387 | } | 422 | } |
2190 | 388 | 423 | ||
2191 | 389 | // Allows out1 to be nullptr. | 424 | // Allows out1 to be nullptr. |
2199 | 390 | template< | 425 | template<class InputStringType,class DelimStringType,class OutputStringType2> |
2200 | 391 | class InputStringType, | 426 | inline |
2201 | 392 | class DelimStringType, | 427 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2202 | 393 | class OutputStringType2 | 428 | && ZORBA_IS_STRING(DelimStringType) |
2203 | 394 | > | 429 | && ZORBA_IS_STRING(OutputStringType2), |
2204 | 395 | inline bool split( InputStringType const &in, DelimStringType const &delim, | 430 | bool>::type |
2205 | 396 | void*, OutputStringType2 *out2 ) { | 431 | split( InputStringType const &in, DelimStringType const &delim, void*, |
2206 | 432 | OutputStringType2 *out2 ) { | ||
2207 | 397 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); | 433 | return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 ); |
2208 | 398 | } | 434 | } |
2209 | 399 | 435 | ||
2210 | 400 | // Allows out2 to be nullptr. | 436 | // Allows out2 to be nullptr. |
2218 | 401 | template< | 437 | template<class InputStringType,class DelimStringType,class OutputStringType1> |
2219 | 402 | class InputStringType, | 438 | inline |
2220 | 403 | class DelimStringType, | 439 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2221 | 404 | class OutputStringType1 | 440 | && ZORBA_IS_STRING(DelimStringType) |
2222 | 405 | > | 441 | && ZORBA_IS_STRING(OutputStringType1), |
2223 | 406 | inline bool split( InputStringType const &in, DelimStringType const &delim, | 442 | bool>::type |
2224 | 407 | OutputStringType1 *out1, void* ) { | 443 | split( InputStringType const &in, DelimStringType const &delim, |
2225 | 444 | OutputStringType1 *out1, void* ) { | ||
2226 | 408 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); | 445 | return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) ); |
2227 | 409 | } | 446 | } |
2228 | 410 | 447 | ||
2229 | @@ -846,7 +883,8 @@ | |||
2230 | 846 | template<typename T,class OutputStringType> inline | 883 | template<typename T,class OutputStringType> inline |
2231 | 847 | typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value | 884 | typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value |
2232 | 848 | && !ZORBA_TR1_NS::is_integral<T>::value | 885 | && !ZORBA_TR1_NS::is_integral<T>::value |
2234 | 849 | && has_insertion_operator<T>::value, | 886 | && has_insertion_operator<T>::value |
2235 | 887 | && ZORBA_IS_STRING(OutputStringType), | ||
2236 | 850 | void>::type | 888 | void>::type |
2237 | 851 | to_string( T const &t, OutputStringType *out ) { | 889 | to_string( T const &t, OutputStringType *out ) { |
2238 | 852 | std::ostringstream o; | 890 | std::ostringstream o; |
2239 | @@ -863,7 +901,9 @@ | |||
2240 | 863 | * @param out The output string. | 901 | * @param out The output string. |
2241 | 864 | */ | 902 | */ |
2242 | 865 | template<typename T,class OutputStringType> inline | 903 | template<typename T,class OutputStringType> inline |
2244 | 866 | typename std::enable_if<ZORBA_TR1_NS::is_integral<T>::value,void>::type | 904 | typename std::enable_if<ZORBA_TR1_NS::is_integral<T>::value |
2245 | 905 | && ZORBA_IS_STRING(OutputStringType), | ||
2246 | 906 | void>::type | ||
2247 | 867 | to_string( T t, OutputStringType *out ) { | 907 | to_string( T t, OutputStringType *out ) { |
2248 | 868 | ascii::itoa_buf_type buf; | 908 | ascii::itoa_buf_type buf; |
2249 | 869 | *out = ascii::itoa( t, buf ); | 909 | *out = ascii::itoa( t, buf ); |
2250 | @@ -882,7 +922,8 @@ | |||
2251 | 882 | */ | 922 | */ |
2252 | 883 | template<class T,class OutputStringType> inline | 923 | template<class T,class OutputStringType> inline |
2253 | 884 | typename std::enable_if<!has_insertion_operator<T>::value | 924 | typename std::enable_if<!has_insertion_operator<T>::value |
2255 | 885 | && has_c_str<T,char const* (T::*)() const>::value, | 925 | && ZORBA_HAS_C_STR(T) |
2256 | 926 | && ZORBA_IS_STRING(OutputStringType), | ||
2257 | 886 | void>::type | 927 | void>::type |
2258 | 887 | to_string( T const &t, OutputStringType *out ) { | 928 | to_string( T const &t, OutputStringType *out ) { |
2259 | 888 | *out = t.c_str(); | 929 | *out = t.c_str(); |
2260 | @@ -903,9 +944,10 @@ | |||
2261 | 903 | */ | 944 | */ |
2262 | 904 | template<class T,class OutputStringType> inline | 945 | template<class T,class OutputStringType> inline |
2263 | 905 | typename std::enable_if<!has_insertion_operator<T>::value | 946 | typename std::enable_if<!has_insertion_operator<T>::value |
2265 | 906 | && !has_c_str<T,char const* (T::*)() const>::value | 947 | && !ZORBA_HAS_C_STR(T) |
2266 | 907 | && has_str<T,std::string (T::*)() const>::value | 948 | && has_str<T,std::string (T::*)() const>::value |
2268 | 908 | && !has_toString<T,std::string (T::*)() const>::value, | 949 | && !has_toString<T,std::string (T::*)() const>::value |
2269 | 950 | && ZORBA_IS_STRING(OutputStringType), | ||
2270 | 909 | void>::type | 951 | void>::type |
2271 | 910 | to_string( T const &t, OutputStringType *out ) { | 952 | to_string( T const &t, OutputStringType *out ) { |
2272 | 911 | *out = t.str(); | 953 | *out = t.str(); |
2273 | @@ -926,9 +968,10 @@ | |||
2274 | 926 | */ | 968 | */ |
2275 | 927 | template<class T,class OutputStringType> inline | 969 | template<class T,class OutputStringType> inline |
2276 | 928 | typename std::enable_if<!has_insertion_operator<T>::value | 970 | typename std::enable_if<!has_insertion_operator<T>::value |
2278 | 929 | && !has_c_str<T,char const* (T::*)() const>::value | 971 | && !ZORBA_HAS_C_STR(T) |
2279 | 930 | && !has_str<T,std::string (T::*)() const>::value | 972 | && !has_str<T,std::string (T::*)() const>::value |
2281 | 931 | && has_toString<T,std::string (T::*)() const>::value, | 973 | && has_toString<T,std::string (T::*)() const>::value |
2282 | 974 | && ZORBA_IS_STRING(OutputStringType), | ||
2283 | 932 | void>::type | 975 | void>::type |
2284 | 933 | to_string( T const &t, OutputStringType *out ) { | 976 | to_string( T const &t, OutputStringType *out ) { |
2285 | 934 | *out = t.toString(); | 977 | *out = t.toString(); |
2286 | @@ -944,7 +987,9 @@ | |||
2287 | 944 | * the result of \c to_string(*p); otherwise \c "<null>". | 987 | * the result of \c to_string(*p); otherwise \c "<null>". |
2288 | 945 | */ | 988 | */ |
2289 | 946 | template<typename T,class OutputStringType> inline | 989 | template<typename T,class OutputStringType> inline |
2291 | 947 | typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value,void>::type | 990 | typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value |
2292 | 991 | && ZORBA_IS_STRING(OutputStringType), | ||
2293 | 992 | void>::type | ||
2294 | 948 | to_string( T p, OutputStringType *out ) { | 993 | to_string( T p, OutputStringType *out ) { |
2295 | 949 | typedef typename ZORBA_TR1_NS::remove_pointer<T>::type const* T_const_ptr; | 994 | typedef typename ZORBA_TR1_NS::remove_pointer<T>::type const* T_const_ptr; |
2296 | 950 | if ( p ) | 995 | if ( p ) |
2297 | @@ -961,7 +1006,8 @@ | |||
2298 | 961 | * @param out The output string. | 1006 | * @param out The output string. |
2299 | 962 | */ | 1007 | */ |
2300 | 963 | template<class OutputStringType> inline | 1008 | template<class OutputStringType> inline |
2302 | 964 | void to_string( char const *s, OutputStringType *out ) { | 1009 | typename std::enable_if<ZORBA_IS_STRING(OutputStringType),void>::type |
2303 | 1010 | to_string( char const *s, OutputStringType *out ) { | ||
2304 | 965 | *out = s ? s : "<null>"; | 1011 | *out = s ? s : "<null>"; |
2305 | 966 | } | 1012 | } |
2306 | 967 | 1013 | ||
2307 | 968 | 1014 | ||
2308 | === modified file 'src/util/time_parse.cpp' | |||
2309 | --- src/util/time_parse.cpp 2013-03-22 19:04:27 +0000 | |||
2310 | +++ src/util/time_parse.cpp 2013-05-09 00:49:28 +0000 | |||
2311 | @@ -93,7 +93,7 @@ | |||
2312 | 93 | invalid_value_value::invalid_value_value( char const *buf, size_t len ) : | 93 | invalid_value_value::invalid_value_value( char const *buf, size_t len ) : |
2313 | 94 | value_( buf, min_len( buf, len ) ) | 94 | value_( buf, min_len( buf, len ) ) |
2314 | 95 | { | 95 | { |
2316 | 96 | ascii::trim_end_whitespace( value_ ); | 96 | ascii::trim_end_space( value_ ); |
2317 | 97 | } | 97 | } |
2318 | 98 | 98 | ||
2319 | 99 | template<typename ValueType> | 99 | template<typename ValueType> |
2320 | @@ -308,7 +308,7 @@ | |||
2321 | 308 | throw insufficient_buffer(); | 308 | throw insufficient_buffer(); |
2322 | 309 | 309 | ||
2323 | 310 | if ( ascii::is_space( c ) ) { | 310 | if ( ascii::is_space( c ) ) { |
2325 | 311 | bp = ascii::trim_start_whitespace( bp ); | 311 | bp = ascii::trim_start_space( bp ); |
2326 | 312 | continue; | 312 | continue; |
2327 | 313 | } | 313 | } |
2328 | 314 | 314 | ||
2329 | @@ -441,7 +441,7 @@ | |||
2330 | 441 | case 'n': // newline | 441 | case 'n': // newline |
2331 | 442 | case 't': // tab | 442 | case 't': // tab |
2332 | 443 | CHECK_ALT(0); | 443 | CHECK_ALT(0); |
2334 | 444 | bp = ascii::trim_start_whitespace( bp ); | 444 | bp = ascii::trim_start_space( bp ); |
2335 | 445 | break; | 445 | break; |
2336 | 446 | 446 | ||
2337 | 447 | case 'O': // "%O?" alternative conversion modifier | 447 | case 'O': // "%O?" alternative conversion modifier |
2338 | 448 | 448 | ||
2339 | === modified file 'src/util/time_parse.h' | |||
2340 | --- src/util/time_parse.h 2013-01-04 16:08:03 +0000 | |||
2341 | +++ src/util/time_parse.h 2013-05-09 00:49:28 +0000 | |||
2342 | @@ -406,10 +406,7 @@ | |||
2343 | 406 | // Template version of parse(). | 406 | // Template version of parse(). |
2344 | 407 | // | 407 | // |
2345 | 408 | template<class BufferType> inline | 408 | template<class BufferType> inline |
2350 | 409 | typename std::enable_if< | 409 | typename std::enable_if<ZORBA_HAS_C_STR(BufferType),char const*>::type |
2347 | 410 | ztd::has_c_str<BufferType,char const* (BufferType::*)() const>::value, | ||
2348 | 411 | char const* | ||
2349 | 412 | >::type | ||
2351 | 413 | parse( BufferType const &buf, char const *fmt, | 410 | parse( BufferType const &buf, char const *fmt, |
2352 | 414 | locale::iso639_1::type lang, locale::iso3166_1::type country, | 411 | locale::iso639_1::type lang, locale::iso3166_1::type country, |
2353 | 415 | ztm *tm, unsigned *set_fields = nullptr ) { | 412 | ztm *tm, unsigned *set_fields = nullptr ) { |
2354 | @@ -420,10 +417,7 @@ | |||
2355 | 420 | // Template version of parse(). | 417 | // Template version of parse(). |
2356 | 421 | // | 418 | // |
2357 | 422 | template<class FormatType> inline | 419 | template<class FormatType> inline |
2362 | 423 | typename std::enable_if< | 420 | typename std::enable_if<ZORBA_HAS_C_STR(FormatType),char const*>::type |
2359 | 424 | ztd::has_c_str<FormatType,char const* (FormatType::*)() const>::value, | ||
2360 | 425 | char const* | ||
2361 | 426 | >::type | ||
2363 | 427 | parse( char const *buf, FormatType const &fmt, | 421 | parse( char const *buf, FormatType const &fmt, |
2364 | 428 | locale::iso639_1::type lang, locale::iso3166_1::type country, | 422 | locale::iso639_1::type lang, locale::iso3166_1::type country, |
2365 | 429 | ztm *tm, unsigned *set_fields = nullptr ) { | 423 | ztm *tm, unsigned *set_fields = nullptr ) { |
2366 | @@ -434,11 +428,9 @@ | |||
2367 | 434 | // Template version of parse(). | 428 | // Template version of parse(). |
2368 | 435 | // | 429 | // |
2369 | 436 | template<class BufferType,class FormatType> inline | 430 | template<class BufferType,class FormatType> inline |
2375 | 437 | typename std::enable_if< | 431 | typename std::enable_if<ZORBA_HAS_C_STR(BufferType) |
2376 | 438 | ztd::has_c_str<BufferType,char const* (BufferType::*)() const>::value && | 432 | && ZORBA_HAS_C_STR(FormatType), |
2377 | 439 | ztd::has_c_str<FormatType,char const* (FormatType::*)() const>::value, | 433 | char const*>::type |
2373 | 440 | char const* | ||
2374 | 441 | >::type | ||
2378 | 442 | parse( BufferType const &buf, FormatType const &fmt, | 434 | parse( BufferType const &buf, FormatType const &fmt, |
2379 | 443 | locale::iso639_1::type lang, locale::iso3166_1::type country, | 435 | locale::iso639_1::type lang, locale::iso3166_1::type country, |
2380 | 444 | ztm *tm, unsigned *set_fields = nullptr ) { | 436 | ztm *tm, unsigned *set_fields = nullptr ) { |
2381 | 445 | 437 | ||
2382 | === modified file 'src/util/time_util.h' | |||
2383 | --- src/util/time_util.h 2013-05-04 18:47:13 +0000 | |||
2384 | +++ src/util/time_util.h 2013-05-09 00:49:28 +0000 | |||
2385 | @@ -164,10 +164,7 @@ | |||
2386 | 164 | // Template version of find(). | 164 | // Template version of find(). |
2387 | 165 | // | 165 | // |
2388 | 166 | template<class StringType> inline | 166 | template<class StringType> inline |
2393 | 167 | typename std::enable_if< | 167 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type |
2390 | 168 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
2391 | 169 | type | ||
2392 | 170 | >::type | ||
2394 | 171 | find( StringType const &calendar ) { | 168 | find( StringType const &calendar ) { |
2395 | 172 | return find( calendar.c_str() ); | 169 | return find( calendar.c_str() ); |
2396 | 173 | } | 170 | } |
2397 | 174 | 171 | ||
2398 | === modified file 'src/util/unicode_util.h' | |||
2399 | --- src/util/unicode_util.h 2013-04-22 23:57:31 +0000 | |||
2400 | +++ src/util/unicode_util.h 2013-05-09 00:49:28 +0000 | |||
2401 | @@ -397,8 +397,9 @@ | |||
2402 | 397 | * @param out The Unicode string result. | 397 | * @param out The Unicode string result. |
2403 | 398 | * @return Returns \c true only if the conversion succeeded. | 398 | * @return Returns \c true only if the conversion succeeded. |
2404 | 399 | */ | 399 | */ |
2407 | 400 | template<class StringType> | 400 | template<class StringType> inline |
2408 | 401 | inline bool to_string( StringType const &in, string *out ) { | 401 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2409 | 402 | to_string( StringType const &in, string *out ) { | ||
2410 | 402 | return to_string( in.data(), static_cast<size_type>( in.size() ), out ); | 403 | return to_string( in.data(), static_cast<size_type>( in.size() ), out ); |
2411 | 403 | } | 404 | } |
2412 | 404 | 405 | ||
2413 | 405 | 406 | ||
2414 | === modified file 'src/util/uri_util.h' | |||
2415 | --- src/util/uri_util.h 2013-02-07 17:24:36 +0000 | |||
2416 | +++ src/util/uri_util.h 2013-05-09 00:49:28 +0000 | |||
2417 | @@ -70,7 +70,8 @@ | |||
2418 | 70 | * or scheme::none (if none). | 70 | * or scheme::none (if none). |
2419 | 71 | */ | 71 | */ |
2420 | 72 | template<class StringType> inline | 72 | template<class StringType> inline |
2422 | 73 | scheme get_scheme( StringType const &uri, StringType *sname = nullptr ) { | 73 | typename std::enable_if<ZORBA_IS_STRING(StringType),scheme>::type |
2423 | 74 | get_scheme( StringType const &uri, StringType *sname = nullptr ) { | ||
2424 | 74 | char const *colon; | 75 | char const *colon; |
2425 | 75 | scheme const s = get_scheme( uri.c_str(), &colon ); | 76 | scheme const s = get_scheme( uri.c_str(), &colon ); |
2426 | 76 | if ( sname && s ) | 77 | if ( sname && s ) |
2427 | @@ -109,7 +110,7 @@ | |||
2428 | 109 | * @param s The string to append to. | 110 | * @param s The string to append to. |
2429 | 110 | * @param encode_slash If \c true, encodes the '/' character also. | 111 | * @param encode_slash If \c true, encodes the '/' character also. |
2430 | 111 | */ | 112 | */ |
2432 | 112 | explicit back_insert_iterator( StringType &s, bool encode_slash = false ) | 113 | explicit back_insert_iterator( StringType *s, bool encode_slash = false ) |
2433 | 113 | : base_type( s ), encode_slash_( encode_slash ) | 114 | : base_type( s ), encode_slash_( encode_slash ) |
2434 | 114 | { | 115 | { |
2435 | 115 | buf_[0] = '%'; | 116 | buf_[0] = '%'; |
2436 | @@ -129,8 +130,10 @@ | |||
2437 | 129 | * @param out The output string. | 130 | * @param out The output string. |
2438 | 130 | * @param encode_slash If \c true, encodes the '/' character also. | 131 | * @param encode_slash If \c true, encodes the '/' character also. |
2439 | 131 | */ | 132 | */ |
2442 | 132 | template<class StringType> inline back_insert_iterator<StringType> | 133 | template<class StringType> inline |
2443 | 133 | back_inserter( StringType &out, bool encode_slash = false ) { | 134 | typename std::enable_if<ZORBA_IS_STRING(StringType), |
2444 | 135 | back_insert_iterator<StringType> >::type | ||
2445 | 136 | back_inserter( StringType *out, bool encode_slash = false ) { | ||
2446 | 134 | return back_insert_iterator<StringType>( out, encode_slash ); | 137 | return back_insert_iterator<StringType>( out, encode_slash ); |
2447 | 135 | } | 138 | } |
2448 | 136 | 139 | ||
2449 | @@ -144,7 +147,10 @@ | |||
2450 | 144 | * contents are appended to. | 147 | * contents are appended to. |
2451 | 145 | */ | 148 | */ |
2452 | 146 | template<class InputStringType,class OutputStringType> | 149 | template<class InputStringType,class OutputStringType> |
2454 | 147 | void decode( InputStringType const &in, OutputStringType *out ); | 150 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2455 | 151 | && ZORBA_IS_STRING(OutputStringType), | ||
2456 | 152 | void>::type | ||
2457 | 153 | decode( InputStringType const &in, OutputStringType *out ); | ||
2458 | 148 | 154 | ||
2459 | 149 | /** | 155 | /** |
2460 | 150 | * Percent-decodes (%xx) illegal URI characters. | 156 | * Percent-decodes (%xx) illegal URI characters. |
2461 | @@ -153,7 +159,8 @@ | |||
2462 | 153 | * @param s The string. | 159 | * @param s The string. |
2463 | 154 | */ | 160 | */ |
2464 | 155 | template<class StringType> inline | 161 | template<class StringType> inline |
2466 | 156 | void decode( StringType &s ) { | 162 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2467 | 163 | decode( StringType &s ) { | ||
2468 | 157 | StringType temp; | 164 | StringType temp; |
2469 | 158 | decode( s, &temp ); | 165 | decode( s, &temp ); |
2470 | 159 | s = temp; | 166 | s = temp; |
2471 | @@ -170,9 +177,12 @@ | |||
2472 | 170 | * @param encode_slash Encodes the slash character ("/") only if \c true. | 177 | * @param encode_slash Encodes the slash character ("/") only if \c true. |
2473 | 171 | */ | 178 | */ |
2474 | 172 | template<class InputStringType,class OutputStringType> inline | 179 | template<class InputStringType,class OutputStringType> inline |
2478 | 173 | void encode( InputStringType const &in, OutputStringType *out, | 180 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2479 | 174 | bool encode_slash = true ) { | 181 | && ZORBA_IS_STRING(OutputStringType), |
2480 | 175 | std::copy( in.begin(), in.end(), back_inserter( *out, encode_slash ) ); | 182 | void>::type |
2481 | 183 | encode( InputStringType const &in, OutputStringType *out, | ||
2482 | 184 | bool encode_slash = true ) { | ||
2483 | 185 | std::copy( in.begin(), in.end(), back_inserter( out, encode_slash ) ); | ||
2484 | 176 | } | 186 | } |
2485 | 177 | 187 | ||
2486 | 178 | /** | 188 | /** |
2487 | @@ -183,7 +193,8 @@ | |||
2488 | 183 | * @param encode_slash Encodes the slash character ("/") only if \c true. | 193 | * @param encode_slash Encodes the slash character ("/") only if \c true. |
2489 | 184 | */ | 194 | */ |
2490 | 185 | template<class StringType> inline | 195 | template<class StringType> inline |
2492 | 186 | void encode( StringType &s, bool encode_slash = true ) { | 196 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2493 | 197 | encode( StringType &s, bool encode_slash = true ) { | ||
2494 | 187 | StringType temp; | 198 | StringType temp; |
2495 | 188 | encode( s, &temp, encode_slash ); | 199 | encode( s, &temp, encode_slash ); |
2496 | 189 | s = temp; | 200 | s = temp; |
2497 | @@ -204,7 +215,8 @@ | |||
2498 | 204 | * local file is a created temporary file; \c false otherwise. | 215 | * local file is a created temporary file; \c false otherwise. |
2499 | 205 | */ | 216 | */ |
2500 | 206 | template<class PathStringType> inline | 217 | template<class PathStringType> inline |
2502 | 207 | void fetch( char const *uri, PathStringType *path, bool *is_temp = nullptr ) { | 218 | typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type |
2503 | 219 | fetch( char const *uri, PathStringType *path, bool *is_temp = nullptr ) { | ||
2504 | 208 | char path_buf[ MAX_PATH ]; | 220 | char path_buf[ MAX_PATH ]; |
2505 | 209 | fetch_to_path_impl( uri, path_buf, is_temp ); | 221 | fetch_to_path_impl( uri, path_buf, is_temp ); |
2506 | 210 | *path = path_buf; | 222 | *path = path_buf; |
2507 | @@ -221,8 +233,11 @@ | |||
2508 | 221 | * local file is a created temporary file; \c false otherwise. | 233 | * local file is a created temporary file; \c false otherwise. |
2509 | 222 | */ | 234 | */ |
2510 | 223 | template<class URIStringType,class PathStringType> inline | 235 | template<class URIStringType,class PathStringType> inline |
2513 | 224 | void fetch( URIStringType const &uri, PathStringType *file, | 236 | typename std::enable_if<ZORBA_HAS_C_STR(URIStringType) |
2514 | 225 | bool *is_temp = nullptr ) { | 237 | && ZORBA_IS_STRING(PathStringType), |
2515 | 238 | void>::type | ||
2516 | 239 | fetch( URIStringType const &uri, PathStringType *file, | ||
2517 | 240 | bool *is_temp = nullptr ) { | ||
2518 | 226 | fetch( uri.c_str(), file, is_temp ); | 241 | fetch( uri.c_str(), file, is_temp ); |
2519 | 227 | } | 242 | } |
2520 | 228 | 243 | ||
2521 | 229 | 244 | ||
2522 | === modified file 'src/util/uri_util.tcc' | |||
2523 | --- src/util/uri_util.tcc 2013-02-07 17:24:36 +0000 | |||
2524 | +++ src/util/uri_util.tcc 2013-05-09 00:49:28 +0000 | |||
2525 | @@ -43,7 +43,10 @@ | |||
2526 | 43 | /////////////////////////////////////////////////////////////////////////////// | 43 | /////////////////////////////////////////////////////////////////////////////// |
2527 | 44 | 44 | ||
2528 | 45 | template<class InputStringType,class OutputStringType> | 45 | template<class InputStringType,class OutputStringType> |
2530 | 46 | void decode( InputStringType const &in, OutputStringType *out ) { | 46 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2531 | 47 | && ZORBA_IS_STRING(OutputStringType), | ||
2532 | 48 | void>::type | ||
2533 | 49 | decode( InputStringType const &in, OutputStringType *out ) { | ||
2534 | 47 | extern signed char const hex2dec[]; | 50 | extern signed char const hex2dec[]; |
2535 | 48 | 51 | ||
2536 | 49 | typedef typename InputStringType::const_iterator const_iterator; | 52 | typedef typename InputStringType::const_iterator const_iterator; |
2537 | 50 | 53 | ||
2538 | === modified file 'src/util/utf8_util.h' | |||
2539 | --- src/util/utf8_util.h 2013-04-22 14:32:41 +0000 | |||
2540 | +++ src/util/utf8_util.h 2013-05-09 00:49:28 +0000 | |||
2541 | @@ -43,9 +43,9 @@ | |||
2542 | 43 | 43 | ||
2543 | 44 | using ascii::begins_with; | 44 | using ascii::begins_with; |
2544 | 45 | using ascii::ends_with; | 45 | using ascii::ends_with; |
2548 | 46 | using ascii::is_whitespace; | 46 | using ascii::is_space; |
2549 | 47 | using ascii::normalize_whitespace; | 47 | using ascii::normalize_space; |
2550 | 48 | using ascii::trim_whitespace; | 48 | using ascii::trim_space; |
2551 | 49 | 49 | ||
2552 | 50 | ////////// begins/ends_with /////////////////////////////////////////////////// | 50 | ////////// begins/ends_with /////////////////////////////////////////////////// |
2553 | 51 | 51 | ||
2554 | @@ -59,7 +59,8 @@ | |||
2555 | 59 | * @return Returns \c true only if \a s begins with \a c. | 59 | * @return Returns \c true only if \a s begins with \a c. |
2556 | 60 | */ | 60 | */ |
2557 | 61 | template<class StringType> inline | 61 | template<class StringType> inline |
2559 | 62 | bool begins_with( utf8_string<StringType> const &s, char c ) { | 62 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2560 | 63 | begins_with( utf8_string<StringType> const &s, char c ) { | ||
2561 | 63 | return ascii::begins_with( *s.get(), c ); | 64 | return ascii::begins_with( *s.get(), c ); |
2562 | 64 | } | 65 | } |
2563 | 65 | 66 | ||
2564 | @@ -73,8 +74,9 @@ | |||
2565 | 73 | * @return Returns \c true only if \a s begins with \a ps. | 74 | * @return Returns \c true only if \a s begins with \a ps. |
2566 | 74 | */ | 75 | */ |
2567 | 75 | template<class StringType> inline | 76 | template<class StringType> inline |
2570 | 76 | bool begins_with( utf8_string<StringType> const &s, char const *ps, | 77 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2571 | 77 | typename StringType::size_type n ) { | 78 | begins_with( utf8_string<StringType> const &s, char const *ps, |
2572 | 79 | typename StringType::size_type n ) { | ||
2573 | 78 | return ascii::begins_with( *s.get(), ps, n ); | 80 | return ascii::begins_with( *s.get(), ps, n ); |
2574 | 79 | } | 81 | } |
2575 | 80 | 82 | ||
2576 | @@ -87,7 +89,8 @@ | |||
2577 | 87 | * @return Returns \c true only if \a s begins with \a ps. | 89 | * @return Returns \c true only if \a s begins with \a ps. |
2578 | 88 | */ | 90 | */ |
2579 | 89 | template<class StringType> inline | 91 | template<class StringType> inline |
2581 | 90 | bool begins_with( utf8_string<StringType> const &s, char const *ps ) { | 92 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2582 | 93 | begins_with( utf8_string<StringType> const &s, char const *ps ) { | ||
2583 | 91 | return ascii::begins_with( *s.get(), ps ); | 94 | return ascii::begins_with( *s.get(), ps ); |
2584 | 92 | } | 95 | } |
2585 | 93 | 96 | ||
2586 | @@ -101,8 +104,10 @@ | |||
2587 | 101 | * @return Returns \c true only if \a s ends with \a ps. | 104 | * @return Returns \c true only if \a s ends with \a ps. |
2588 | 102 | */ | 105 | */ |
2589 | 103 | template<class StringType,class PrefixStringType> inline | 106 | template<class StringType,class PrefixStringType> inline |
2592 | 104 | bool begins_with( utf8_string<StringType> const &s, | 107 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
2593 | 105 | PrefixStringType const &ps ) { | 108 | && ZORBA_IS_STRING(PrefixStringType), |
2594 | 109 | bool>::type | ||
2595 | 110 | begins_with( utf8_string<StringType> const &s, PrefixStringType const &ps ) { | ||
2596 | 106 | return ascii::begins_with( *s.get(), ps.data(), ps.size() ); | 111 | return ascii::begins_with( *s.get(), ps.data(), ps.size() ); |
2597 | 107 | } | 112 | } |
2598 | 108 | 113 | ||
2599 | @@ -116,8 +121,10 @@ | |||
2600 | 116 | * @return Returns \c true only if \a s ends with \a ps. | 121 | * @return Returns \c true only if \a s ends with \a ps. |
2601 | 117 | */ | 122 | */ |
2602 | 118 | template<class StringType,class PrefixStringType> inline | 123 | template<class StringType,class PrefixStringType> inline |
2605 | 119 | bool begins_with( StringType const &s, | 124 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
2606 | 120 | utf8_string<PrefixStringType> const &ps ) { | 125 | && ZORBA_IS_STRING(PrefixStringType), |
2607 | 126 | bool>::type | ||
2608 | 127 | begins_with( StringType const &s, utf8_string<PrefixStringType> const &ps ) { | ||
2609 | 121 | return ascii::begins_with( s, *ps.get() ); | 128 | return ascii::begins_with( s, *ps.get() ); |
2610 | 122 | } | 129 | } |
2611 | 123 | 130 | ||
2612 | @@ -131,8 +138,11 @@ | |||
2613 | 131 | * @return Returns \c true only if \a s ends with \a ps. | 138 | * @return Returns \c true only if \a s ends with \a ps. |
2614 | 132 | */ | 139 | */ |
2615 | 133 | template<class StringType,class PrefixStringType> inline | 140 | template<class StringType,class PrefixStringType> inline |
2618 | 134 | bool begins_with( utf8_string<StringType> const &s, | 141 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
2619 | 135 | utf8_string<PrefixStringType> const &ps ) { | 142 | && ZORBA_IS_STRING(PrefixStringType), |
2620 | 143 | bool>::type | ||
2621 | 144 | begins_with( utf8_string<StringType> const &s, | ||
2622 | 145 | utf8_string<PrefixStringType> const &ps ) { | ||
2623 | 136 | return ascii::begins_with( *s.get(), *ps.get() ); | 146 | return ascii::begins_with( *s.get(), *ps.get() ); |
2624 | 137 | } | 147 | } |
2625 | 138 | 148 | ||
2626 | @@ -146,7 +156,8 @@ | |||
2627 | 146 | * @return Returns \c true only if \a s ends with \a c. | 156 | * @return Returns \c true only if \a s ends with \a c. |
2628 | 147 | */ | 157 | */ |
2629 | 148 | template<class StringType> inline | 158 | template<class StringType> inline |
2631 | 149 | bool ends_with( utf8_string<StringType> const &s, char c ) { | 159 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2632 | 160 | ends_with( utf8_string<StringType> const &s, char c ) { | ||
2633 | 150 | return ascii::ends_with( *s.get(), c ); | 161 | return ascii::ends_with( *s.get(), c ); |
2634 | 151 | } | 162 | } |
2635 | 152 | 163 | ||
2636 | @@ -160,8 +171,9 @@ | |||
2637 | 160 | * @return Returns \c true only if \a s ends with \a ps. | 171 | * @return Returns \c true only if \a s ends with \a ps. |
2638 | 161 | */ | 172 | */ |
2639 | 162 | template<class StringType> inline | 173 | template<class StringType> inline |
2642 | 163 | bool ends_with( utf8_string<StringType> const &s, char const *ps, | 174 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2643 | 164 | typename StringType::size_type n ) { | 175 | ends_with( utf8_string<StringType> const &s, char const *ps, |
2644 | 176 | typename StringType::size_type n ) { | ||
2645 | 165 | return ascii::ends_with( *s.get(), ps, n ); | 177 | return ascii::ends_with( *s.get(), ps, n ); |
2646 | 166 | } | 178 | } |
2647 | 167 | 179 | ||
2648 | @@ -174,7 +186,8 @@ | |||
2649 | 174 | * @return Returns \c true only if \a s ends with \a ps. | 186 | * @return Returns \c true only if \a s ends with \a ps. |
2650 | 175 | */ | 187 | */ |
2651 | 176 | template<class StringType> inline | 188 | template<class StringType> inline |
2653 | 177 | bool ends_with( utf8_string<StringType> const &s, char const *ps ) { | 189 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2654 | 190 | ends_with( utf8_string<StringType> const &s, char const *ps ) { | ||
2655 | 178 | return ascii::ends_with( *s.get(), ps ); | 191 | return ascii::ends_with( *s.get(), ps ); |
2656 | 179 | } | 192 | } |
2657 | 180 | 193 | ||
2658 | @@ -188,8 +201,10 @@ | |||
2659 | 188 | * @return Returns \c true only if \a s ends with \a ps. | 201 | * @return Returns \c true only if \a s ends with \a ps. |
2660 | 189 | */ | 202 | */ |
2661 | 190 | template<class StringType,class SuffixStringType> inline | 203 | template<class StringType,class SuffixStringType> inline |
2664 | 191 | bool ends_with( utf8_string<StringType> const &s, | 204 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
2665 | 192 | SuffixStringType const &ps ) { | 205 | && ZORBA_IS_STRING(SuffixStringType), |
2666 | 206 | bool>::type | ||
2667 | 207 | ends_with( utf8_string<StringType> const &s, SuffixStringType const &ps ) { | ||
2668 | 193 | return ascii::ends_with( *s.get(), ps.data(), ps.size() ); | 208 | return ascii::ends_with( *s.get(), ps.data(), ps.size() ); |
2669 | 194 | } | 209 | } |
2670 | 195 | 210 | ||
2671 | @@ -203,8 +218,10 @@ | |||
2672 | 203 | * @return Returns \c true only if \a s ends with \a ps. | 218 | * @return Returns \c true only if \a s ends with \a ps. |
2673 | 204 | */ | 219 | */ |
2674 | 205 | template<class StringType,class SuffixStringType> inline | 220 | template<class StringType,class SuffixStringType> inline |
2677 | 206 | bool ends_with( StringType const &s, | 221 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
2678 | 207 | utf8_string<SuffixStringType> const &ps ) { | 222 | && ZORBA_IS_STRING(SuffixStringType), |
2679 | 223 | bool>::type | ||
2680 | 224 | ends_with( StringType const &s, utf8_string<SuffixStringType> const &ps ) { | ||
2681 | 208 | return ascii::ends_with( s, *ps.get() ); | 225 | return ascii::ends_with( s, *ps.get() ); |
2682 | 209 | } | 226 | } |
2683 | 210 | 227 | ||
2684 | @@ -218,8 +235,11 @@ | |||
2685 | 218 | * @return Returns \c true only if \a s ends with \a ps. | 235 | * @return Returns \c true only if \a s ends with \a ps. |
2686 | 219 | */ | 236 | */ |
2687 | 220 | template<class StringType,class SuffixStringType> inline | 237 | template<class StringType,class SuffixStringType> inline |
2690 | 221 | bool ends_with( utf8_string<StringType> const &s, | 238 | typename std::enable_if<ZORBA_IS_STRING(StringType) |
2691 | 222 | utf8_string<SuffixStringType> const &ps ) { | 239 | && ZORBA_IS_STRING(SuffixStringType), |
2692 | 240 | bool>::type | ||
2693 | 241 | ends_with( utf8_string<StringType> const &s, | ||
2694 | 242 | utf8_string<SuffixStringType> const &ps ) { | ||
2695 | 223 | return ascii::ends_with( *s.get(), *ps.get() ); | 243 | return ascii::ends_with( *s.get(), *ps.get() ); |
2696 | 224 | } | 244 | } |
2697 | 225 | 245 | ||
2698 | @@ -235,7 +255,10 @@ | |||
2699 | 235 | * contents are overwritten. | 255 | * contents are overwritten. |
2700 | 236 | */ | 256 | */ |
2701 | 237 | template<class InputStringType,class OutputStringType> | 257 | template<class InputStringType,class OutputStringType> |
2703 | 238 | void to_lower( InputStringType const &in, OutputStringType *out ); | 258 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2704 | 259 | && ZORBA_IS_STRING(OutputStringType), | ||
2705 | 260 | void>::type | ||
2706 | 261 | to_lower( InputStringType const &in, OutputStringType *out ); | ||
2707 | 239 | 262 | ||
2708 | 240 | /** | 263 | /** |
2709 | 241 | * Converts a string to lower-case. | 264 | * Converts a string to lower-case. |
2710 | @@ -244,7 +267,8 @@ | |||
2711 | 244 | * @param s The string. | 267 | * @param s The string. |
2712 | 245 | */ | 268 | */ |
2713 | 246 | template<class StringType> inline | 269 | template<class StringType> inline |
2715 | 247 | void to_lower( StringType &s ) { | 270 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2716 | 271 | to_lower( StringType &s ) { | ||
2717 | 248 | StringType temp; | 272 | StringType temp; |
2718 | 249 | to_lower( s, &temp ); | 273 | to_lower( s, &temp ); |
2719 | 250 | s = temp; | 274 | s = temp; |
2720 | @@ -260,7 +284,10 @@ | |||
2721 | 260 | * contents are overwritten. | 284 | * contents are overwritten. |
2722 | 261 | */ | 285 | */ |
2723 | 262 | template<class InputStringType,class OutputStringType> | 286 | template<class InputStringType,class OutputStringType> |
2725 | 263 | void to_upper( InputStringType const &in, OutputStringType *out ); | 287 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2726 | 288 | && ZORBA_IS_STRING(OutputStringType), | ||
2727 | 289 | void>::type | ||
2728 | 290 | to_upper( InputStringType const &in, OutputStringType *out ); | ||
2729 | 264 | 291 | ||
2730 | 265 | /** | 292 | /** |
2731 | 266 | * Converts a string to upper-case. | 293 | * Converts a string to upper-case. |
2732 | @@ -269,7 +296,8 @@ | |||
2733 | 269 | * @param s The string. | 296 | * @param s The string. |
2734 | 270 | */ | 297 | */ |
2735 | 271 | template<class StringType> inline | 298 | template<class StringType> inline |
2737 | 272 | void to_upper( StringType &s ) { | 299 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2738 | 300 | to_upper( StringType &s ) { | ||
2739 | 273 | StringType temp; | 301 | StringType temp; |
2740 | 274 | to_upper( s, &temp ); | 302 | to_upper( s, &temp ); |
2741 | 275 | s = temp; | 303 | s = temp; |
2742 | @@ -286,7 +314,8 @@ | |||
2743 | 286 | * @param s A pointer to the string to be appended to. | 314 | * @param s A pointer to the string to be appended to. |
2744 | 287 | */ | 315 | */ |
2745 | 288 | template<class InputIterator,class StringType> inline | 316 | template<class InputIterator,class StringType> inline |
2747 | 289 | void append_codepoints( InputIterator i, InputIterator j, StringType *s ) { | 317 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2748 | 318 | append_codepoints( InputIterator i, InputIterator j, StringType *s ) { | ||
2749 | 290 | typename utf8_stringify<StringType>::type u( *s ); | 319 | typename utf8_stringify<StringType>::type u( *s ); |
2750 | 291 | std::copy( i, j, std::back_inserter( u ) ); | 320 | std::copy( i, j, std::back_inserter( u ) ); |
2751 | 292 | } | 321 | } |
2752 | @@ -301,7 +330,8 @@ | |||
2753 | 301 | * container's contents are appended to. | 330 | * container's contents are appended to. |
2754 | 302 | */ | 331 | */ |
2755 | 303 | template<class StringType,class ContainerType> inline | 332 | template<class StringType,class ContainerType> inline |
2757 | 304 | void to_codepoints( StringType const &s, ContainerType *c ) { | 333 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2758 | 334 | to_codepoints( StringType const &s, ContainerType *c ) { | ||
2759 | 305 | typename utf8_stringify<StringType const>::type const u( s ); | 335 | typename utf8_stringify<StringType const>::type const u( s ); |
2760 | 306 | std::copy( u.begin(), u.end(), std::back_inserter( *c ) ); | 336 | std::copy( u.begin(), u.end(), std::back_inserter( *c ) ); |
2761 | 307 | } | 337 | } |
2762 | @@ -391,8 +421,8 @@ | |||
2763 | 391 | * @return Returns \c true only if the conversion succeeded. | 421 | * @return Returns \c true only if the conversion succeeded. |
2764 | 392 | */ | 422 | */ |
2765 | 393 | template<class StringType> | 423 | template<class StringType> |
2768 | 394 | bool to_string( unicode::char_type const *in, size_type in_len, | 424 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2769 | 395 | StringType *out ); | 425 | to_string( unicode::char_type const *in, size_type in_len, StringType *out ); |
2770 | 396 | 426 | ||
2771 | 397 | /** | 427 | /** |
2772 | 398 | * Converts a unicode::char_type array into a UTF-8 encoded string. | 428 | * Converts a unicode::char_type array into a UTF-8 encoded string. |
2773 | @@ -402,7 +432,8 @@ | |||
2774 | 402 | * @return Returns \c true only if the conversion succeeded. | 432 | * @return Returns \c true only if the conversion succeeded. |
2775 | 403 | */ | 433 | */ |
2776 | 404 | template<class StringType> inline | 434 | template<class StringType> inline |
2778 | 405 | bool to_string( unicode::char_type const *in, StringType *out ) { | 435 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2779 | 436 | to_string( unicode::char_type const *in, StringType *out ) { | ||
2780 | 406 | return to_string( in, u_strlen( in ), out ); | 437 | return to_string( in, u_strlen( in ), out ); |
2781 | 407 | } | 438 | } |
2782 | 408 | 439 | ||
2783 | @@ -416,7 +447,8 @@ | |||
2784 | 416 | * @return Returns \c true only if the conversion succeeded. | 447 | * @return Returns \c true only if the conversion succeeded. |
2785 | 417 | */ | 448 | */ |
2786 | 418 | template<class StringType> inline | 449 | template<class StringType> inline |
2788 | 419 | bool to_string( unicode::string const &in, StringType *out ) { | 450 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2789 | 451 | to_string( unicode::string const &in, StringType *out ) { | ||
2790 | 420 | #ifndef ZORBA_NO_ICU | 452 | #ifndef ZORBA_NO_ICU |
2791 | 421 | return to_string( in.getBuffer(), in.length(), out ); | 453 | return to_string( in.getBuffer(), in.length(), out ); |
2792 | 422 | #else | 454 | #else |
2793 | @@ -472,7 +504,8 @@ | |||
2794 | 472 | * @return Returns \c true only if the conversion succeeded. | 504 | * @return Returns \c true only if the conversion succeeded. |
2795 | 473 | */ | 505 | */ |
2796 | 474 | template<class StringType> | 506 | template<class StringType> |
2798 | 475 | bool to_string( wchar_t const *in, size_type in_len, StringType *out ); | 507 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2799 | 508 | to_string( wchar_t const *in, size_type in_len, StringType *out ); | ||
2800 | 476 | 509 | ||
2801 | 477 | /** | 510 | /** |
2802 | 478 | * Converts a wide-character string into a UTF-8 encoded string. | 511 | * Converts a wide-character string into a UTF-8 encoded string. |
2803 | @@ -483,7 +516,8 @@ | |||
2804 | 483 | * @return Returns \c true only if the conversion succeeded. | 516 | * @return Returns \c true only if the conversion succeeded. |
2805 | 484 | */ | 517 | */ |
2806 | 485 | template<class StringType> inline | 518 | template<class StringType> inline |
2808 | 486 | bool to_string( wchar_t const *in, StringType *out ) { | 519 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2809 | 520 | to_string( wchar_t const *in, StringType *out ) { | ||
2810 | 487 | return to_string( in, std::wcslen( in ), out ); | 521 | return to_string( in, std::wcslen( in ), out ); |
2811 | 488 | } | 522 | } |
2812 | 489 | 523 | ||
2813 | @@ -498,7 +532,8 @@ | |||
2814 | 498 | * @return Returns \c true only if the conversion succeeded. | 532 | * @return Returns \c true only if the conversion succeeded. |
2815 | 499 | */ | 533 | */ |
2816 | 500 | template<class StringType> inline | 534 | template<class StringType> inline |
2818 | 501 | bool to_string( std::wstring const &in, StringType *out ) { | 535 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2819 | 536 | to_string( std::wstring const &in, StringType *out ) { | ||
2820 | 502 | return to_string( in.data(), in.size(), out ); | 537 | return to_string( in.data(), in.size(), out ); |
2821 | 503 | } | 538 | } |
2822 | 504 | 539 | ||
2823 | @@ -543,8 +578,8 @@ | |||
2824 | 543 | * @return Returns \c true only if the conversion succeeded. | 578 | * @return Returns \c true only if the conversion succeeded. |
2825 | 544 | */ | 579 | */ |
2826 | 545 | template<class StringType> inline | 580 | template<class StringType> inline |
2829 | 546 | bool to_wchar_t( StringType const &in, wchar_t **out, | 581 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
2830 | 547 | unicode::size_type *out_len ) { | 582 | to_wchar_t( StringType const &in, wchar_t **out, unicode::size_type *out_len ) { |
2831 | 548 | return to_wchar_t( in.data(), in.size(), out, out_len ); | 583 | return to_wchar_t( in.data(), in.size(), out, out_len ); |
2832 | 549 | } | 584 | } |
2833 | 550 | 585 | ||
2834 | @@ -577,7 +612,7 @@ | |||
2835 | 577 | * | 612 | * |
2836 | 578 | * @param s The string to append to. | 613 | * @param s The string to append to. |
2837 | 579 | */ | 614 | */ |
2839 | 580 | explicit back_html_uri_insert_iterator( StringType &s ) : base_type( s ) { | 615 | explicit back_html_uri_insert_iterator( StringType *s ) : base_type( s ) { |
2840 | 581 | buf_[0] = '%'; | 616 | buf_[0] = '%'; |
2841 | 582 | } | 617 | } |
2842 | 583 | 618 | ||
2843 | @@ -593,8 +628,10 @@ | |||
2844 | 593 | * @tparam StringType The string type. | 628 | * @tparam StringType The string type. |
2845 | 594 | * @param out The output string. | 629 | * @param out The output string. |
2846 | 595 | */ | 630 | */ |
2849 | 596 | template<class StringType> inline back_html_uri_insert_iterator<StringType> | 631 | template<class StringType> inline |
2850 | 597 | back_html_uri_inserter( StringType &out ) { | 632 | typename std::enable_if<ZORBA_IS_STRING(StringType), |
2851 | 633 | back_html_uri_insert_iterator<StringType> >::type | ||
2852 | 634 | back_html_uri_inserter( StringType *out ) { | ||
2853 | 598 | return back_html_uri_insert_iterator<StringType>( out ); | 635 | return back_html_uri_insert_iterator<StringType>( out ); |
2854 | 599 | } | 636 | } |
2855 | 600 | 637 | ||
2856 | @@ -607,10 +644,13 @@ | |||
2857 | 607 | * @param out The output string (which must be different from \a in). | 644 | * @param out The output string (which must be different from \a in). |
2858 | 608 | */ | 645 | */ |
2859 | 609 | template<class InputStringType,class OutputStringType> inline | 646 | template<class InputStringType,class OutputStringType> inline |
2861 | 610 | void to_html_uri( InputStringType const &in, OutputStringType *out ) { | 647 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2862 | 648 | && ZORBA_IS_STRING(OutputStringType), | ||
2863 | 649 | void>::type | ||
2864 | 650 | to_html_uri( InputStringType const &in, OutputStringType *out ) { | ||
2865 | 611 | typename utf8_stringify<InputStringType const>::type const u_in( in ); | 651 | typename utf8_stringify<InputStringType const>::type const u_in( in ); |
2866 | 612 | typename utf8_stringify<OutputStringType>::type u_out( *out ); | 652 | typename utf8_stringify<OutputStringType>::type u_out( *out ); |
2868 | 613 | std::copy( u_in.begin(), u_in.end(), back_html_uri_inserter( u_out ) ); | 653 | std::copy( u_in.begin(), u_in.end(), back_html_uri_inserter( &u_out ) ); |
2869 | 614 | } | 654 | } |
2870 | 615 | 655 | ||
2871 | 616 | /** | 656 | /** |
2872 | @@ -620,7 +660,8 @@ | |||
2873 | 620 | * @param s The string. | 660 | * @param s The string. |
2874 | 621 | */ | 661 | */ |
2875 | 622 | template<class StringType> inline | 662 | template<class StringType> inline |
2877 | 623 | void to_html_uri( StringType &s ) { | 663 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2878 | 664 | to_html_uri( StringType &s ) { | ||
2879 | 624 | StringType temp; | 665 | StringType temp; |
2880 | 625 | to_html_uri( s, &temp ); | 666 | to_html_uri( s, &temp ); |
2881 | 626 | s = temp; | 667 | s = temp; |
2882 | @@ -653,7 +694,7 @@ | |||
2883 | 653 | * | 694 | * |
2884 | 654 | * @param s The string to append to. | 695 | * @param s The string to append to. |
2885 | 655 | */ | 696 | */ |
2887 | 656 | explicit back_iri_insert_iterator( StringType &s ) : base_type( s ) { | 697 | explicit back_iri_insert_iterator( StringType *s ) : base_type( s ) { |
2888 | 657 | buf_[0] = '%'; | 698 | buf_[0] = '%'; |
2889 | 658 | } | 699 | } |
2890 | 659 | 700 | ||
2891 | @@ -669,8 +710,10 @@ | |||
2892 | 669 | * @tparam StringType The string type. | 710 | * @tparam StringType The string type. |
2893 | 670 | * @param out The output string. | 711 | * @param out The output string. |
2894 | 671 | */ | 712 | */ |
2897 | 672 | template<class StringType> inline back_iri_insert_iterator<StringType> | 713 | template<class StringType> inline |
2898 | 673 | back_iri_inserter( StringType &out ) { | 714 | typename std::enable_if<ZORBA_IS_STRING(StringType), |
2899 | 715 | back_iri_insert_iterator<StringType> >::type | ||
2900 | 716 | back_iri_inserter( StringType *out ) { | ||
2901 | 674 | return back_iri_insert_iterator<StringType>( out ); | 717 | return back_iri_insert_iterator<StringType>( out ); |
2902 | 675 | } | 718 | } |
2903 | 676 | 719 | ||
2904 | @@ -684,10 +727,13 @@ | |||
2905 | 684 | * See RFC 3987. | 727 | * See RFC 3987. |
2906 | 685 | */ | 728 | */ |
2907 | 686 | template<class InputStringType,class OutputStringType> inline | 729 | template<class InputStringType,class OutputStringType> inline |
2909 | 687 | void iri_to_uri( InputStringType const &in, OutputStringType *out ) { | 730 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2910 | 731 | && ZORBA_IS_STRING(OutputStringType), | ||
2911 | 732 | void>::type | ||
2912 | 733 | iri_to_uri( InputStringType const &in, OutputStringType *out ) { | ||
2913 | 688 | typename utf8_stringify<InputStringType const>::type const u_in( in ); | 734 | typename utf8_stringify<InputStringType const>::type const u_in( in ); |
2914 | 689 | typename utf8_stringify<OutputStringType>::type u_out( *out ); | 735 | typename utf8_stringify<OutputStringType>::type u_out( *out ); |
2916 | 690 | std::copy( u_in.begin(), u_in.end(), back_iri_inserter( u_out ) ); | 736 | std::copy( u_in.begin(), u_in.end(), back_iri_inserter( &u_out ) ); |
2917 | 691 | } | 737 | } |
2918 | 692 | 738 | ||
2919 | 693 | /** | 739 | /** |
2920 | @@ -698,7 +744,8 @@ | |||
2921 | 698 | * See RFC 3987. | 744 | * See RFC 3987. |
2922 | 699 | */ | 745 | */ |
2923 | 700 | template<class StringType> inline | 746 | template<class StringType> inline |
2925 | 701 | void iri_to_uri( StringType &s ) { | 747 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2926 | 748 | iri_to_uri( StringType &s ) { | ||
2927 | 702 | StringType temp; | 749 | StringType temp; |
2928 | 703 | iri_to_uri( s, &temp ); | 750 | iri_to_uri( s, &temp ); |
2929 | 704 | s = temp; | 751 | s = temp; |
2930 | @@ -716,8 +763,11 @@ | |||
2931 | 716 | * @param out The output String (which may be the same as \a in). | 763 | * @param out The output String (which may be the same as \a in). |
2932 | 717 | */ | 764 | */ |
2933 | 718 | template<class InputStringType,class OutputStringType> | 765 | template<class InputStringType,class OutputStringType> |
2936 | 719 | bool normalize( InputStringType const &in, unicode::normalization::type n, | 766 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2937 | 720 | OutputStringType *out ); | 767 | && ZORBA_IS_STRING(OutputStringType), |
2938 | 768 | bool>::type | ||
2939 | 769 | normalize( InputStringType const &in, unicode::normalization::type n, | ||
2940 | 770 | OutputStringType *out ); | ||
2941 | 721 | #endif /* ZORBA_NO_ICU */ | 771 | #endif /* ZORBA_NO_ICU */ |
2942 | 722 | 772 | ||
2943 | 723 | ////////// Whitespace ///////////////////////////////////////////////////////// | 773 | ////////// Whitespace ///////////////////////////////////////////////////////// |
2944 | @@ -732,9 +782,12 @@ | |||
2945 | 732 | * @param out The output string. | 782 | * @param out The output string. |
2946 | 733 | */ | 783 | */ |
2947 | 734 | template<class InputStringType,class OutputStringType> inline | 784 | template<class InputStringType,class OutputStringType> inline |
2951 | 735 | void normalize_whitespace( utf8_string<InputStringType> const &in, | 785 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2952 | 736 | utf8_string<OutputStringType> *out ) { | 786 | && ZORBA_IS_STRING(OutputStringType), |
2953 | 737 | ascii::normalize_whitespace( *in.get(), out->get() ); | 787 | void>::type |
2954 | 788 | normalize_space( utf8_string<InputStringType> const &in, | ||
2955 | 789 | utf8_string<OutputStringType> *out ) { | ||
2956 | 790 | ascii::normalize_space( *in.get(), out->get() ); | ||
2957 | 738 | } | 791 | } |
2958 | 739 | 792 | ||
2959 | 740 | /** | 793 | /** |
2960 | @@ -746,9 +799,12 @@ | |||
2961 | 746 | * @param out The output string (which must be different from \a in). | 799 | * @param out The output string (which must be different from \a in). |
2962 | 747 | */ | 800 | */ |
2963 | 748 | template<class InputStringType,class OutputStringType> inline | 801 | template<class InputStringType,class OutputStringType> inline |
2967 | 749 | void trim_whitespace( utf8_string<InputStringType> const &in, | 802 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
2968 | 750 | utf8_string<OutputStringType> *out ) { | 803 | && ZORBA_IS_STRING(OutputStringType), |
2969 | 751 | ascii::trim_whitespace( *in.get(), out->get() ); | 804 | void>::type |
2970 | 805 | trim_space( utf8_string<InputStringType> const &in, | ||
2971 | 806 | utf8_string<OutputStringType> *out ) { | ||
2972 | 807 | ascii::trim_space( *in.get(), out->get() ); | ||
2973 | 752 | } | 808 | } |
2974 | 753 | 809 | ||
2975 | 754 | /** | 810 | /** |
2976 | @@ -758,8 +814,9 @@ | |||
2977 | 758 | * @param s The string. | 814 | * @param s The string. |
2978 | 759 | */ | 815 | */ |
2979 | 760 | template<class StringType> inline | 816 | template<class StringType> inline |
2982 | 761 | void trim_whitespace( utf8_string<StringType> &s ) { | 817 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
2983 | 762 | ascii::trim_whitespace( *s.get() ); | 818 | trim_space( utf8_string<StringType> &s ) { |
2984 | 819 | ascii::trim_space( *s.get() ); | ||
2985 | 763 | } | 820 | } |
2986 | 764 | 821 | ||
2987 | 765 | ////////// Miscellaneous ////////////////////////////////////////////////////// | 822 | ////////// Miscellaneous ////////////////////////////////////////////////////// |
2988 | @@ -774,8 +831,9 @@ | |||
2989 | 774 | * @return Returns \c *s. | 831 | * @return Returns \c *s. |
2990 | 775 | */ | 832 | */ |
2991 | 776 | template<class StringType> inline | 833 | template<class StringType> inline |
2994 | 777 | StringType& left_pad( StringType *s, typename StringType::size_type width, | 834 | typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type |
2995 | 778 | unicode::code_point cp ) { | 835 | left_pad( StringType *s, typename StringType::size_type width, |
2996 | 836 | unicode::code_point cp ) { | ||
2997 | 779 | typedef typename utf8_stringify<StringType>::type u_type; | 837 | typedef typename utf8_stringify<StringType>::type u_type; |
2998 | 780 | typedef typename u_type::size_type u_size_type; | 838 | typedef typename u_type::size_type u_size_type; |
2999 | 781 | u_type u( *s ); | 839 | u_type u( *s ); |
3000 | @@ -795,8 +853,9 @@ | |||
3001 | 795 | * @return Returns \c *s. | 853 | * @return Returns \c *s. |
3002 | 796 | */ | 854 | */ |
3003 | 797 | template<class StringType> inline | 855 | template<class StringType> inline |
3006 | 798 | StringType& right_pad( StringType *s, typename StringType::size_type width, | 856 | typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type |
3007 | 799 | unicode::code_point cp ) { | 857 | right_pad( StringType *s, typename StringType::size_type width, |
3008 | 858 | unicode::code_point cp ) { | ||
3009 | 800 | typedef typename utf8_stringify<StringType>::type u_type; | 859 | typedef typename utf8_stringify<StringType>::type u_type; |
3010 | 801 | typedef typename u_type::size_type u_size_type; | 860 | typedef typename u_type::size_type u_size_type; |
3011 | 802 | u_type u( *s ); | 861 | u_type u( *s ); |
3012 | @@ -815,7 +874,10 @@ | |||
3013 | 815 | * @param out The output string. | 874 | * @param out The output string. |
3014 | 816 | */ | 875 | */ |
3015 | 817 | template<class InputStringType,class OutputStringType> inline | 876 | template<class InputStringType,class OutputStringType> inline |
3017 | 818 | void reverse( InputStringType const &in, OutputStringType *out ) { | 877 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3018 | 878 | && ZORBA_IS_STRING(OutputStringType), | ||
3019 | 879 | void>::type | ||
3020 | 880 | reverse( InputStringType const &in, OutputStringType *out ) { | ||
3021 | 819 | typename utf8_stringify<InputStringType const>::type const u_in( in ); | 881 | typename utf8_stringify<InputStringType const>::type const u_in( in ); |
3022 | 820 | typename utf8_stringify<OutputStringType>::type u_out( *out ); | 882 | typename utf8_stringify<OutputStringType>::type u_out( *out ); |
3023 | 821 | std::reverse_copy( u_in.begin(), u_in.end(), std::back_inserter( u_out ) ); | 883 | std::reverse_copy( u_in.begin(), u_in.end(), std::back_inserter( u_out ) ); |
3024 | @@ -832,14 +894,20 @@ | |||
3025 | 832 | * @return Returns \c true only if the strip succeeded. | 894 | * @return Returns \c true only if the strip succeeded. |
3026 | 833 | */ | 895 | */ |
3027 | 834 | template<class InputStringType,class OutputStringType> | 896 | template<class InputStringType,class OutputStringType> |
3029 | 835 | bool strip_diacritics( InputStringType const &in, OutputStringType *out ); | 897 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3030 | 898 | && ZORBA_IS_STRING(OutputStringType), | ||
3031 | 899 | bool>::type | ||
3032 | 900 | strip_diacritics( InputStringType const &in, OutputStringType *out ); | ||
3033 | 836 | 901 | ||
3034 | 837 | /** | 902 | /** |
3035 | 838 | * | 903 | * |
3036 | 839 | */ | 904 | */ |
3037 | 840 | template<class StringType1,class StringType2> inline | 905 | template<class StringType1,class StringType2> inline |
3040 | 841 | int compare(const StringType1 &s1, const StringType2 &s2, | 906 | typename std::enable_if<ZORBA_IS_STRING(StringType1) |
3041 | 842 | const XQPCollator* collation) | 907 | && ZORBA_IS_STRING(StringType2), |
3042 | 908 | int>::type | ||
3043 | 909 | compare(const StringType1 &s1, const StringType2 &s2, | ||
3044 | 910 | const XQPCollator* collation) | ||
3045 | 843 | { | 911 | { |
3046 | 844 | #ifndef ZORBA_NO_ICU | 912 | #ifndef ZORBA_NO_ICU |
3047 | 845 | if (collation == NULL || collation->doMemCmp()) | 913 | if (collation == NULL || collation->doMemCmp()) |
3048 | @@ -862,7 +930,8 @@ | |||
3049 | 862 | * | 930 | * |
3050 | 863 | */ | 931 | */ |
3051 | 864 | template<class StringType> inline | 932 | template<class StringType> inline |
3053 | 865 | uint32_t hash(const StringType& s, const XQPCollator* collation = NULL) | 933 | typename std::enable_if<ZORBA_IS_STRING(StringType),uint32_t>::type |
3054 | 934 | hash(const StringType& s, const XQPCollator* collation = NULL) | ||
3055 | 866 | { | 935 | { |
3056 | 867 | #ifndef ZORBA_NO_ICU | 936 | #ifndef ZORBA_NO_ICU |
3057 | 868 | if (!collation || collation->doMemCmp()) | 937 | if (!collation || collation->doMemCmp()) |
3058 | 869 | 938 | ||
3059 | === modified file 'src/util/utf8_util.tcc' | |||
3060 | --- src/util/utf8_util.tcc 2013-05-01 03:57:57 +0000 | |||
3061 | +++ src/util/utf8_util.tcc 2013-05-09 00:49:28 +0000 | |||
3062 | @@ -105,8 +105,11 @@ | |||
3063 | 105 | #ifndef ZORBA_NO_ICU | 105 | #ifndef ZORBA_NO_ICU |
3064 | 106 | 106 | ||
3065 | 107 | template<class InputStringType,class OutputStringType> | 107 | template<class InputStringType,class OutputStringType> |
3068 | 108 | bool normalize( InputStringType const &in, unicode::normalization::type n, | 108 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3069 | 109 | OutputStringType *out ) { | 109 | && ZORBA_IS_STRING(OutputStringType), |
3070 | 110 | bool>::type | ||
3071 | 111 | normalize( InputStringType const &in, unicode::normalization::type n, | ||
3072 | 112 | OutputStringType *out ) { | ||
3073 | 110 | unicode::string u_in; | 113 | unicode::string u_in; |
3074 | 111 | if ( !unicode::to_string( in, &u_in ) ) | 114 | if ( !unicode::to_string( in, &u_in ) ) |
3075 | 112 | return false; | 115 | return false; |
3076 | @@ -126,7 +129,10 @@ | |||
3077 | 126 | #endif /* ZORBA_NO_ICU */ | 129 | #endif /* ZORBA_NO_ICU */ |
3078 | 127 | 130 | ||
3079 | 128 | template<class InputStringType,class OutputStringType> | 131 | template<class InputStringType,class OutputStringType> |
3081 | 129 | bool strip_diacritics( InputStringType const &in, OutputStringType *out ) { | 132 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3082 | 133 | && ZORBA_IS_STRING(OutputStringType), | ||
3083 | 134 | bool>::type | ||
3084 | 135 | strip_diacritics( InputStringType const &in, OutputStringType *out ) { | ||
3085 | 130 | #ifndef ZORBA_NO_ICU | 136 | #ifndef ZORBA_NO_ICU |
3086 | 131 | unicode::string u_in; | 137 | unicode::string u_in; |
3087 | 132 | if ( !unicode::to_string( in, &u_in ) ) | 138 | if ( !unicode::to_string( in, &u_in ) ) |
3088 | @@ -143,7 +149,7 @@ | |||
3089 | 143 | #else | 149 | #else |
3090 | 144 | out->clear(); | 150 | out->clear(); |
3091 | 145 | out->reserve( in.size() ); | 151 | out->reserve( in.size() ); |
3093 | 146 | std::copy( in.begin(), in.end(), ascii::back_ascii_inserter( *out ) ); | 152 | std::copy( in.begin(), in.end(), ascii::back_ascii_inserter( out ) ); |
3094 | 147 | #endif /* ZORBA_NO_ICU */ | 153 | #endif /* ZORBA_NO_ICU */ |
3095 | 148 | return true; | 154 | return true; |
3096 | 149 | } | 155 | } |
3097 | @@ -151,8 +157,8 @@ | |||
3098 | 151 | #ifndef ZORBA_NO_ICU | 157 | #ifndef ZORBA_NO_ICU |
3099 | 152 | 158 | ||
3100 | 153 | template<class StringType> | 159 | template<class StringType> |
3103 | 154 | bool to_string( unicode::char_type const *in, size_type in_len, | 160 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
3104 | 155 | StringType *out ) { | 161 | to_string( unicode::char_type const *in, size_type in_len, StringType *out ) { |
3105 | 156 | storage_type *temp; | 162 | storage_type *temp; |
3106 | 157 | size_type temp_len; | 163 | size_type temp_len; |
3107 | 158 | if ( to_string( in, in_len, &temp, &temp_len ) ) { | 164 | if ( to_string( in, in_len, &temp, &temp_len ) ) { |
3108 | @@ -166,7 +172,8 @@ | |||
3109 | 166 | 172 | ||
3110 | 167 | #ifndef WIN32 | 173 | #ifndef WIN32 |
3111 | 168 | template<class StringType> | 174 | template<class StringType> |
3113 | 169 | bool to_string( wchar_t const *in, size_type in_len, StringType *out ) { | 175 | typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type |
3114 | 176 | to_string( wchar_t const *in, size_type in_len, StringType *out ) { | ||
3115 | 170 | storage_type *temp; | 177 | storage_type *temp; |
3116 | 171 | size_type temp_len; | 178 | size_type temp_len; |
3117 | 172 | if ( utf8::to_string( in, in_len, &temp, &temp_len ) ) { | 179 | if ( utf8::to_string( in, in_len, &temp, &temp_len ) ) { |
3118 | @@ -182,7 +189,10 @@ | |||
3119 | 182 | #endif /* ZORBA_NO_ICU */ | 189 | #endif /* ZORBA_NO_ICU */ |
3120 | 183 | 190 | ||
3121 | 184 | template<class InputStringType,class OutputStringType> | 191 | template<class InputStringType,class OutputStringType> |
3123 | 185 | void to_lower( InputStringType const &in, OutputStringType *out ) { | 192 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3124 | 193 | && ZORBA_IS_STRING(OutputStringType), | ||
3125 | 194 | void>::type | ||
3126 | 195 | to_lower( InputStringType const &in, OutputStringType *out ) { | ||
3127 | 186 | typename utf8_stringify<InputStringType const>::type const u_in( in ); | 196 | typename utf8_stringify<InputStringType const>::type const u_in( in ); |
3128 | 187 | typename utf8_stringify<OutputStringType>::type u_out( *out ); | 197 | typename utf8_stringify<OutputStringType>::type u_out( *out ); |
3129 | 188 | out->clear(); // TODO: should this be here? | 198 | out->clear(); // TODO: should this be here? |
3130 | @@ -192,7 +202,10 @@ | |||
3131 | 192 | } | 202 | } |
3132 | 193 | 203 | ||
3133 | 194 | template<class InputStringType,class OutputStringType> | 204 | template<class InputStringType,class OutputStringType> |
3135 | 195 | void to_upper( InputStringType const &in, OutputStringType *out ) { | 205 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3136 | 206 | && ZORBA_IS_STRING(OutputStringType), | ||
3137 | 207 | void>::type | ||
3138 | 208 | to_upper( InputStringType const &in, OutputStringType *out ) { | ||
3139 | 196 | typename utf8_stringify<InputStringType const>::type const u_in( in ); | 209 | typename utf8_stringify<InputStringType const>::type const u_in( in ); |
3140 | 197 | typename utf8_stringify<OutputStringType>::type u_out( *out ); | 210 | typename utf8_stringify<OutputStringType>::type u_out( *out ); |
3141 | 198 | out->clear(); // TODO: should this be here? | 211 | out->clear(); // TODO: should this be here? |
3142 | @@ -201,6 +214,8 @@ | |||
3143 | 201 | ); | 214 | ); |
3144 | 202 | } | 215 | } |
3145 | 203 | 216 | ||
3146 | 217 | /////////////////////////////////////////////////////////////////////////////// | ||
3147 | 218 | |||
3148 | 204 | } // namespace utf8 | 219 | } // namespace utf8 |
3149 | 205 | } // namespace zorba | 220 | } // namespace zorba |
3150 | 206 | 221 | ||
3151 | 207 | 222 | ||
3152 | === modified file 'src/util/utf8_util_base.h' | |||
3153 | --- src/util/utf8_util_base.h 2013-04-22 23:57:31 +0000 | |||
3154 | +++ src/util/utf8_util_base.h 2013-05-09 00:49:28 +0000 | |||
3155 | @@ -315,10 +315,7 @@ | |||
3156 | 315 | * @return Returns said number of characters or 0 if any byte is invalid. | 315 | * @return Returns said number of characters or 0 if any byte is invalid. |
3157 | 316 | */ | 316 | */ |
3158 | 317 | template<class StringType> inline | 317 | template<class StringType> inline |
3163 | 318 | typename std::enable_if< | 318 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),size_type>::type |
3160 | 319 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
3161 | 320 | size_type | ||
3162 | 321 | >::type | ||
3164 | 322 | length( StringType const &s ) { | 319 | length( StringType const &s ) { |
3165 | 323 | return length( s.c_str() ); | 320 | return length( s.c_str() ); |
3166 | 324 | } | 321 | } |
3167 | 325 | 322 | ||
3168 | === modified file 'src/util/xml_util.h' | |||
3169 | --- src/util/xml_util.h 2013-02-07 17:24:36 +0000 | |||
3170 | +++ src/util/xml_util.h 2013-05-09 00:49:28 +0000 | |||
3171 | @@ -55,7 +55,10 @@ | |||
3172 | 55 | * @return Returns \c true only if the extraction was successful. | 55 | * @return Returns \c true only if the extraction was successful. |
3173 | 56 | */ | 56 | */ |
3174 | 57 | template<class InputStringType,class OutputStringType> inline | 57 | template<class InputStringType,class OutputStringType> inline |
3176 | 58 | bool clark_localname( InputStringType const &uname, OutputStringType *local ) { | 58 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3177 | 59 | && ZORBA_IS_STRING(OutputStringType), | ||
3178 | 60 | bool>::type | ||
3179 | 61 | clark_localname( InputStringType const &uname, OutputStringType *local ) { | ||
3180 | 59 | typename InputStringType::size_type const rbrace = uname.find( '}' ); | 62 | typename InputStringType::size_type const rbrace = uname.find( '}' ); |
3181 | 60 | if ( rbrace != InputStringType::npos && rbrace + 1 < uname.size() ) { | 63 | if ( rbrace != InputStringType::npos && rbrace + 1 < uname.size() ) { |
3182 | 61 | *local = uname.substr( rbrace + 1 ); | 64 | *local = uname.substr( rbrace + 1 ); |
3183 | @@ -75,7 +78,10 @@ | |||
3184 | 75 | * @return Returns \c true only if the extraction was successful. | 78 | * @return Returns \c true only if the extraction was successful. |
3185 | 76 | */ | 79 | */ |
3186 | 77 | template<class InputStringType,class OutputStringType> inline | 80 | template<class InputStringType,class OutputStringType> inline |
3188 | 78 | bool clark_uri( InputStringType const &uname, OutputStringType *uri ) { | 81 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3189 | 82 | && ZORBA_IS_STRING(OutputStringType), | ||
3190 | 83 | bool>::type | ||
3191 | 84 | clark_uri( InputStringType const &uname, OutputStringType *uri ) { | ||
3192 | 79 | if ( uname.size() > 2 && uname[0] == '{' ) { | 85 | if ( uname.size() > 2 && uname[0] == '{' ) { |
3193 | 80 | typename InputStringType::size_type const rbrace = uname.find( '}', 1 ); | 86 | typename InputStringType::size_type const rbrace = uname.find( '}', 1 ); |
3194 | 81 | if ( rbrace != InputStringType::npos ) { | 87 | if ( rbrace != InputStringType::npos ) { |
3195 | @@ -99,8 +105,13 @@ | |||
3196 | 99 | * become empty, returns \c false; otherwise returns \a true. | 105 | * become empty, returns \c false; otherwise returns \a true. |
3197 | 100 | */ | 106 | */ |
3198 | 101 | template<class InputStringType,class PrefixStringType,class LocalStringType> | 107 | template<class InputStringType,class PrefixStringType,class LocalStringType> |
3201 | 102 | inline bool split_name( InputStringType const &name, PrefixStringType *prefix, | 108 | inline |
3202 | 103 | LocalStringType *local ) { | 109 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3203 | 110 | && ZORBA_IS_STRING(PrefixStringType) | ||
3204 | 111 | && ZORBA_IS_STRING(LocalStringType), | ||
3205 | 112 | bool>::type | ||
3206 | 113 | split_name( InputStringType const &name, PrefixStringType *prefix, | ||
3207 | 114 | LocalStringType *local ) { | ||
3208 | 104 | typename InputStringType::size_type const colon = name.find( ':' ); | 115 | typename InputStringType::size_type const colon = name.find( ':' ); |
3209 | 105 | if ( colon != InputStringType::npos ) { | 116 | if ( colon != InputStringType::npos ) { |
3210 | 106 | prefix->assign( name, 0, colon ); | 117 | prefix->assign( name, 0, colon ); |
3211 | @@ -166,7 +177,7 @@ | |||
3212 | 166 | * | 177 | * |
3213 | 167 | * @param s The string to append to. | 178 | * @param s The string to append to. |
3214 | 168 | */ | 179 | */ |
3216 | 169 | explicit back_xml_insert_iterator( StringType &s ) : base_type( s ) { | 180 | explicit back_xml_insert_iterator( StringType *s ) : base_type( s ) { |
3217 | 170 | buf_[0] = '&'; | 181 | buf_[0] = '&'; |
3218 | 171 | buf_[1] = '#'; | 182 | buf_[1] = '#'; |
3219 | 172 | } | 183 | } |
3220 | @@ -183,8 +194,10 @@ | |||
3221 | 183 | * @tparam StringType The string type. | 194 | * @tparam StringType The string type. |
3222 | 184 | * @param out The output string. | 195 | * @param out The output string. |
3223 | 185 | */ | 196 | */ |
3226 | 186 | template<class StringType> inline back_xml_insert_iterator<StringType> | 197 | template<class StringType> inline |
3227 | 187 | back_xml_inserter( StringType &out ) { | 198 | typename std::enable_if<ZORBA_IS_STRING(StringType), |
3228 | 199 | back_xml_insert_iterator<StringType> >::type | ||
3229 | 200 | back_xml_inserter( StringType *out ) { | ||
3230 | 188 | return back_xml_insert_iterator<StringType>( out ); | 201 | return back_xml_insert_iterator<StringType>( out ); |
3231 | 189 | } | 202 | } |
3232 | 190 | 203 | ||
3233 | @@ -199,8 +212,11 @@ | |||
3234 | 199 | * contents are appended to. | 212 | * contents are appended to. |
3235 | 200 | */ | 213 | */ |
3236 | 201 | template<class InputStringType,class OutputStringType> inline | 214 | template<class InputStringType,class OutputStringType> inline |
3239 | 202 | void escape( InputStringType const &in, OutputStringType *out ) { | 215 | typename std::enable_if<ZORBA_IS_STRING(InputStringType) |
3240 | 203 | std::copy( in.begin(), in.end(), back_xml_inserter( *out ) ); | 216 | && ZORBA_IS_STRING(OutputStringType), |
3241 | 217 | void>::type | ||
3242 | 218 | escape( InputStringType const &in, OutputStringType *out ) { | ||
3243 | 219 | std::copy( in.begin(), in.end(), back_xml_inserter( out ) ); | ||
3244 | 204 | } | 220 | } |
3245 | 205 | 221 | ||
3246 | 206 | /** | 222 | /** |
3247 | @@ -211,9 +227,10 @@ | |||
3248 | 211 | * @param s The string. | 227 | * @param s The string. |
3249 | 212 | */ | 228 | */ |
3250 | 213 | template<class StringType> inline | 229 | template<class StringType> inline |
3252 | 214 | void escape( StringType &s ) { | 230 | typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type |
3253 | 231 | escape( StringType &s ) { | ||
3254 | 215 | StringType temp; | 232 | StringType temp; |
3256 | 216 | std::copy( s.begin(), s.end(), back_xml_inserter( temp ) ); | 233 | std::copy( s.begin(), s.end(), back_xml_inserter( &temp ) ); |
3257 | 217 | s = temp; | 234 | s = temp; |
3258 | 218 | } | 235 | } |
3259 | 219 | 236 | ||
3260 | @@ -239,7 +256,8 @@ | |||
3261 | 239 | * returns -1. | 256 | * returns -1. |
3262 | 240 | */ | 257 | */ |
3263 | 241 | template<class StringType> inline | 258 | template<class StringType> inline |
3265 | 242 | int parse_entity( StringType const &ref, unicode::code_point *c ) { | 259 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),int>::type |
3266 | 260 | parse_entity( StringType const &ref, unicode::code_point *c ) { | ||
3267 | 243 | return parse_entity( ref.c_str(), c ); | 261 | return parse_entity( ref.c_str(), c ); |
3268 | 244 | } | 262 | } |
3269 | 245 | 263 | ||
3270 | @@ -254,7 +272,8 @@ | |||
3271 | 254 | * returns -1. | 272 | * returns -1. |
3272 | 255 | */ | 273 | */ |
3273 | 256 | template<class StringType> inline | 274 | template<class StringType> inline |
3275 | 257 | int parse_entity( char const *ref, StringType *out ) { | 275 | typename std::enable_if<ZORBA_IS_STRING(StringType),int>::type |
3276 | 276 | parse_entity( char const *ref, StringType *out ) { | ||
3277 | 258 | unicode::code_point c; | 277 | unicode::code_point c; |
3278 | 259 | int const result = parse_entity( ref, &c ); | 278 | int const result = parse_entity( ref, &c ); |
3279 | 260 | if ( result != -1 ) | 279 | if ( result != -1 ) |
3280 | @@ -274,7 +293,10 @@ | |||
3281 | 274 | * returns -1. | 293 | * returns -1. |
3282 | 275 | */ | 294 | */ |
3283 | 276 | template<class InputStringType,class OutputStringType> inline | 295 | template<class InputStringType,class OutputStringType> inline |
3285 | 277 | int parse_entity( InputStringType const &ref, OutputStringType *out ) { | 296 | typename std::enable_if<ZORBA_HAS_C_STR(InputStringType) |
3286 | 297 | && ZORBA_IS_STRING(OutputStringType), | ||
3287 | 298 | int>::type | ||
3288 | 299 | parse_entity( InputStringType const &ref, OutputStringType *out ) { | ||
3289 | 278 | return parse_entity( ref.c_str(), out ); | 300 | return parse_entity( ref.c_str(), out ); |
3290 | 279 | } | 301 | } |
3291 | 280 | 302 | ||
3292 | 281 | 303 | ||
3293 | === modified file 'src/zorbatypes/URI.cpp' | |||
3294 | --- src/zorbatypes/URI.cpp 2013-05-07 21:21:56 +0000 | |||
3295 | +++ src/zorbatypes/URI.cpp 2013-05-09 00:49:28 +0000 | |||
3296 | @@ -577,8 +577,8 @@ | |||
3297 | 577 | // first, we need to normalize the spaces in the uri | 577 | // first, we need to normalize the spaces in the uri |
3298 | 578 | // and only work with the normalized version from this point on | 578 | // and only work with the normalized version from this point on |
3299 | 579 | zstring lTrimmedURI; | 579 | zstring lTrimmedURI; |
3302 | 580 | ascii::normalize_whitespace(uri, &lTrimmedURI); | 580 | ascii::normalize_space(uri, &lTrimmedURI); |
3303 | 581 | ascii::trim_whitespace(lTrimmedURI); | 581 | ascii::trim_space(lTrimmedURI); |
3304 | 582 | 582 | ||
3305 | 583 | zstring::size_type lTrimmedURILength = lTrimmedURI.size(); | 583 | zstring::size_type lTrimmedURILength = lTrimmedURI.size(); |
3306 | 584 | 584 | ||
3307 | 585 | 585 | ||
3308 | === modified file 'src/zorbatypes/binary.cpp' | |||
3309 | --- src/zorbatypes/binary.cpp 2013-03-19 06:13:13 +0000 | |||
3310 | +++ src/zorbatypes/binary.cpp 2013-05-09 00:49:28 +0000 | |||
3311 | @@ -282,7 +282,7 @@ | |||
3312 | 282 | 282 | ||
3313 | 283 | void Base16::insertData(char const *s, size_t len) | 283 | void Base16::insertData(char const *s, size_t len) |
3314 | 284 | { | 284 | { |
3316 | 285 | s = ascii::trim_whitespace( s, &len ); | 285 | s = ascii::trim_space( s, &len ); |
3317 | 286 | try { | 286 | try { |
3318 | 287 | hexbinary::encode( s, len, &theData ); | 287 | hexbinary::encode( s, len, &theData ); |
3319 | 288 | } | 288 | } |
3320 | 289 | 289 | ||
3321 | === modified file 'src/zorbatypes/datetime/datetimetype.cpp' | |||
3322 | --- src/zorbatypes/datetime/datetimetype.cpp 2013-05-08 20:14:47 +0000 | |||
3323 | +++ src/zorbatypes/datetime/datetimetype.cpp 2013-05-09 00:49:28 +0000 | |||
3324 | @@ -355,7 +355,7 @@ | |||
3325 | 355 | 355 | ||
3326 | 356 | // DateTime is of form: '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)? | 356 | // DateTime is of form: '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)? |
3327 | 357 | 357 | ||
3329 | 358 | ascii::skip_whitespace(str, len, &pos); | 358 | ascii::skip_space(str, len, &pos); |
3330 | 359 | 359 | ||
3331 | 360 | dt.facet = DATETIME_FACET; | 360 | dt.facet = DATETIME_FACET; |
3332 | 361 | 361 | ||
3333 | @@ -381,7 +381,7 @@ | |||
3334 | 381 | 381 | ||
3335 | 382 | ascii::size_type savepos = pos; | 382 | ascii::size_type savepos = pos; |
3336 | 383 | 383 | ||
3338 | 384 | ascii::skip_whitespace(str, len, &pos); | 384 | ascii::skip_space(str, len, &pos); |
3339 | 385 | 385 | ||
3340 | 386 | if (savepos != pos && pos != len) | 386 | if (savepos != pos && pos != len) |
3341 | 387 | return 1; | 387 | return 1; |
3342 | @@ -414,7 +414,7 @@ | |||
3343 | 414 | ascii::size_type pos = 0; | 414 | ascii::size_type pos = 0; |
3344 | 415 | int err = 1; | 415 | int err = 1; |
3345 | 416 | 416 | ||
3347 | 417 | ascii::skip_whitespace(str, len, &pos); | 417 | ascii::skip_space(str, len, &pos); |
3348 | 418 | 418 | ||
3349 | 419 | dt.facet = DATE_FACET; | 419 | dt.facet = DATE_FACET; |
3350 | 420 | 420 | ||
3351 | @@ -428,7 +428,7 @@ | |||
3352 | 428 | 428 | ||
3353 | 429 | ascii::size_type savepos = pos; | 429 | ascii::size_type savepos = pos; |
3354 | 430 | 430 | ||
3356 | 431 | ascii::skip_whitespace(str, len, &pos); | 431 | ascii::skip_space(str, len, &pos); |
3357 | 432 | 432 | ||
3358 | 433 | if (savepos != pos && pos != len) | 433 | if (savepos != pos && pos != len) |
3359 | 434 | return 1; | 434 | return 1; |
3360 | @@ -451,7 +451,7 @@ | |||
3361 | 451 | int err = 1; | 451 | int err = 1; |
3362 | 452 | ascii::size_type pos = 0; | 452 | ascii::size_type pos = 0; |
3363 | 453 | 453 | ||
3365 | 454 | ascii::skip_whitespace(str, len, &pos); | 454 | ascii::skip_space(str, len, &pos); |
3366 | 455 | 455 | ||
3367 | 456 | dt.facet = TIME_FACET; | 456 | dt.facet = TIME_FACET; |
3368 | 457 | 457 | ||
3369 | @@ -464,7 +464,7 @@ | |||
3370 | 464 | 464 | ||
3371 | 465 | ascii::size_type savepos = pos; | 465 | ascii::size_type savepos = pos; |
3372 | 466 | 466 | ||
3374 | 467 | ascii::skip_whitespace(str, len, &pos); | 467 | ascii::skip_space(str, len, &pos); |
3375 | 468 | 468 | ||
3376 | 469 | if (savepos != pos && pos != len) | 469 | if (savepos != pos && pos != len) |
3377 | 470 | return 1; | 470 | return 1; |
3378 | @@ -494,7 +494,7 @@ | |||
3379 | 494 | 494 | ||
3380 | 495 | // GYearMonth of form: '-'? yyyy '-' mm zzzzzz? | 495 | // GYearMonth of form: '-'? yyyy '-' mm zzzzzz? |
3381 | 496 | 496 | ||
3383 | 497 | ascii::skip_whitespace(str, len, &pos); | 497 | ascii::skip_space(str, len, &pos); |
3384 | 498 | 498 | ||
3385 | 499 | dt.facet = GYEARMONTH_FACET; | 499 | dt.facet = GYEARMONTH_FACET; |
3386 | 500 | 500 | ||
3387 | @@ -522,7 +522,7 @@ | |||
3388 | 522 | 522 | ||
3389 | 523 | ascii::size_type savepos = pos; | 523 | ascii::size_type savepos = pos; |
3390 | 524 | 524 | ||
3392 | 525 | ascii::skip_whitespace(str, len, &pos); | 525 | ascii::skip_space(str, len, &pos); |
3393 | 526 | 526 | ||
3394 | 527 | if (savepos != pos && pos != len) | 527 | if (savepos != pos && pos != len) |
3395 | 528 | return 1; | 528 | return 1; |
3396 | @@ -548,7 +548,7 @@ | |||
3397 | 548 | 548 | ||
3398 | 549 | // GYear of form: '-'? yyyy zzzzzz? | 549 | // GYear of form: '-'? yyyy zzzzzz? |
3399 | 550 | 550 | ||
3401 | 551 | ascii::skip_whitespace(str, len, &pos); | 551 | ascii::skip_space(str, len, &pos); |
3402 | 552 | 552 | ||
3403 | 553 | dt.facet = GYEAR_FACET; | 553 | dt.facet = GYEAR_FACET; |
3404 | 554 | 554 | ||
3405 | @@ -578,7 +578,7 @@ | |||
3406 | 578 | 578 | ||
3407 | 579 | ascii::size_type savepos = pos; | 579 | ascii::size_type savepos = pos; |
3408 | 580 | 580 | ||
3410 | 581 | ascii::skip_whitespace(str, len, &pos); | 581 | ascii::skip_space(str, len, &pos); |
3411 | 582 | 582 | ||
3412 | 583 | if (savepos != pos && pos != len) | 583 | if (savepos != pos && pos != len) |
3413 | 584 | return 1; | 584 | return 1; |
3414 | @@ -606,7 +606,7 @@ | |||
3415 | 606 | // GMonth of form: --MM zzzzzz? | 606 | // GMonth of form: --MM zzzzzz? |
3416 | 607 | // preceding - is not allowed. | 607 | // preceding - is not allowed. |
3417 | 608 | 608 | ||
3419 | 609 | ascii::skip_whitespace(str, len, &pos); | 609 | ascii::skip_space(str, len, &pos); |
3420 | 610 | 610 | ||
3421 | 611 | dt.facet = GMONTH_FACET; | 611 | dt.facet = GMONTH_FACET; |
3422 | 612 | 612 | ||
3423 | @@ -630,7 +630,7 @@ | |||
3424 | 630 | 630 | ||
3425 | 631 | ascii::size_type savepos = pos; | 631 | ascii::size_type savepos = pos; |
3426 | 632 | 632 | ||
3428 | 633 | ascii::skip_whitespace(str, len, &pos); | 633 | ascii::skip_space(str, len, &pos); |
3429 | 634 | 634 | ||
3430 | 635 | if (savepos != pos && pos != len) | 635 | if (savepos != pos && pos != len) |
3431 | 636 | return 1; | 636 | return 1; |
3432 | @@ -658,7 +658,7 @@ | |||
3433 | 658 | // GMonthDay of form: --MM-DD zzzzzz? | 658 | // GMonthDay of form: --MM-DD zzzzzz? |
3434 | 659 | // preceding - is not allowed. | 659 | // preceding - is not allowed. |
3435 | 660 | 660 | ||
3437 | 661 | ascii::skip_whitespace(str, len, &pos); | 661 | ascii::skip_space(str, len, &pos); |
3438 | 662 | 662 | ||
3439 | 663 | dt.facet = GMONTHDAY_FACET; | 663 | dt.facet = GMONTHDAY_FACET; |
3440 | 664 | 664 | ||
3441 | @@ -683,7 +683,7 @@ | |||
3442 | 683 | 683 | ||
3443 | 684 | ascii::size_type savepos = pos; | 684 | ascii::size_type savepos = pos; |
3444 | 685 | 685 | ||
3446 | 686 | ascii::skip_whitespace(str, len, &pos); | 686 | ascii::skip_space(str, len, &pos); |
3447 | 687 | 687 | ||
3448 | 688 | if (savepos != pos && pos != len) | 688 | if (savepos != pos && pos != len) |
3449 | 689 | return 1; | 689 | return 1; |
3450 | @@ -711,7 +711,7 @@ | |||
3451 | 711 | // GDay of form: ---DD zzzzzz? | 711 | // GDay of form: ---DD zzzzzz? |
3452 | 712 | // preceding - is not allowed. | 712 | // preceding - is not allowed. |
3453 | 713 | 713 | ||
3455 | 714 | ascii::skip_whitespace(str, len, &pos); | 714 | ascii::skip_space(str, len, &pos); |
3456 | 715 | 715 | ||
3457 | 716 | dt.facet = GDAY_FACET; | 716 | dt.facet = GDAY_FACET; |
3458 | 717 | 717 | ||
3459 | @@ -736,7 +736,7 @@ | |||
3460 | 736 | 736 | ||
3461 | 737 | ascii::size_type savepos = pos; | 737 | ascii::size_type savepos = pos; |
3462 | 738 | 738 | ||
3464 | 739 | ascii::skip_whitespace(str, len, &pos); | 739 | ascii::skip_space(str, len, &pos); |
3465 | 740 | 740 | ||
3466 | 741 | if (savepos != pos && pos != len) | 741 | if (savepos != pos && pos != len) |
3467 | 742 | return 1; | 742 | return 1; |
3468 | 743 | 743 | ||
3469 | === modified file 'src/zorbatypes/datetime/duration.cpp' | |||
3470 | --- src/zorbatypes/datetime/duration.cpp 2013-04-30 00:12:10 +0000 | |||
3471 | +++ src/zorbatypes/datetime/duration.cpp 2013-05-09 00:49:28 +0000 | |||
3472 | @@ -58,7 +58,7 @@ | |||
3473 | 58 | long& frac_seconds) | 58 | long& frac_seconds) |
3474 | 59 | { | 59 | { |
3475 | 60 | ascii::size_type savepos = pos; | 60 | ascii::size_type savepos = pos; |
3477 | 61 | ascii::skip_whitespace(str, len, &pos); | 61 | ascii::skip_space(str, len, &pos); |
3478 | 62 | int err; | 62 | int err; |
3479 | 63 | 63 | ||
3480 | 64 | if (pos != savepos) { | 64 | if (pos != savepos) { |
3481 | @@ -111,7 +111,7 @@ | |||
3482 | 111 | long& frac_seconds) | 111 | long& frac_seconds) |
3483 | 112 | { | 112 | { |
3484 | 113 | ascii::size_type savepos = pos; | 113 | ascii::size_type savepos = pos; |
3486 | 114 | ascii::skip_whitespace(str, len, &pos); | 114 | ascii::skip_space(str, len, &pos); |
3487 | 115 | int err; | 115 | int err; |
3488 | 116 | 116 | ||
3489 | 117 | if (pos != savepos) | 117 | if (pos != savepos) |
3490 | @@ -246,7 +246,7 @@ | |||
3491 | 246 | return err; | 246 | return err; |
3492 | 247 | 247 | ||
3493 | 248 | ascii::size_type pos = ym_pos+1; | 248 | ascii::size_type pos = ym_pos+1; |
3495 | 249 | ascii::skip_whitespace(str, len, &pos); | 249 | ascii::skip_space(str, len, &pos); |
3496 | 250 | 250 | ||
3497 | 251 | if (pos > ym_pos + 1 && pos != len) | 251 | if (pos > ym_pos + 1 && pos != len) |
3498 | 252 | return 1; | 252 | return 1; |
3499 | @@ -282,7 +282,7 @@ | |||
3500 | 282 | long months = 0; | 282 | long months = 0; |
3501 | 283 | int err; | 283 | int err; |
3502 | 284 | 284 | ||
3504 | 285 | ascii::skip_whitespace(str, len, &pos); | 285 | ascii::skip_space(str, len, &pos); |
3505 | 286 | 286 | ||
3506 | 287 | if (pos == len) | 287 | if (pos == len) |
3507 | 288 | return 1; | 288 | return 1; |
3508 | @@ -327,7 +327,7 @@ | |||
3509 | 327 | return 1; | 327 | return 1; |
3510 | 328 | } | 328 | } |
3511 | 329 | 329 | ||
3513 | 330 | ascii::skip_whitespace(str, len, &pos); | 330 | ascii::skip_space(str, len, &pos); |
3514 | 331 | 331 | ||
3515 | 332 | if (len != pos) | 332 | if (len != pos) |
3516 | 333 | return 1; | 333 | return 1; |
3517 | @@ -352,7 +352,7 @@ | |||
3518 | 352 | long days = 0, hours = 0, minutes = 0, seconds = 0, frac_seconds = 0; | 352 | long days = 0, hours = 0, minutes = 0, seconds = 0, frac_seconds = 0; |
3519 | 353 | int err; | 353 | int err; |
3520 | 354 | 354 | ||
3522 | 355 | ascii::skip_whitespace(str, len, &pos); | 355 | ascii::skip_space(str, len, &pos); |
3523 | 356 | 356 | ||
3524 | 357 | if (pos == len) | 357 | if (pos == len) |
3525 | 358 | return 1; | 358 | return 1; |
3526 | @@ -392,7 +392,7 @@ | |||
3527 | 392 | return err; | 392 | return err; |
3528 | 393 | } | 393 | } |
3529 | 394 | 394 | ||
3531 | 395 | ascii::skip_whitespace(str, len, &pos); | 395 | ascii::skip_space(str, len, &pos); |
3532 | 396 | 396 | ||
3533 | 397 | if (len != pos) | 397 | if (len != pos) |
3534 | 398 | return 1; | 398 | return 1; |
3535 | 399 | 399 | ||
3536 | === modified file 'src/zorbatypes/datetime/timezone.cpp' | |||
3537 | --- src/zorbatypes/datetime/timezone.cpp 2013-05-08 20:14:47 +0000 | |||
3538 | +++ src/zorbatypes/datetime/timezone.cpp 2013-05-09 00:49:28 +0000 | |||
3539 | @@ -48,14 +48,14 @@ | |||
3540 | 48 | { | 48 | { |
3541 | 49 | ascii::size_type pos = 0; | 49 | ascii::size_type pos = 0; |
3542 | 50 | 50 | ||
3544 | 51 | ascii::skip_whitespace(str, strlen, &pos); | 51 | ascii::skip_space(str, strlen, &pos); |
3545 | 52 | 52 | ||
3546 | 53 | // A time zone is of form: (('+' | '-') hh ':' mm) | 'Z' | 53 | // A time zone is of form: (('+' | '-') hh ':' mm) | 'Z' |
3547 | 54 | 54 | ||
3548 | 55 | if (str[pos] == 'Z') | 55 | if (str[pos] == 'Z') |
3549 | 56 | { | 56 | { |
3550 | 57 | ++pos; | 57 | ++pos; |
3552 | 58 | ascii::skip_whitespace(str, strlen, &pos); | 58 | ascii::skip_space(str, strlen, &pos); |
3553 | 59 | 59 | ||
3554 | 60 | if (pos != strlen) | 60 | if (pos != strlen) |
3555 | 61 | return 1; | 61 | return 1; |
3556 | @@ -94,7 +94,7 @@ | |||
3557 | 94 | if (tz.data[HOUR_DATA]*60 + tz.data[MINUTE_DATA] > 14*60) | 94 | if (tz.data[HOUR_DATA]*60 + tz.data[MINUTE_DATA] > 14*60) |
3558 | 95 | return 1; | 95 | return 1; |
3559 | 96 | 96 | ||
3561 | 97 | ascii::skip_whitespace(str, strlen, &pos); | 97 | ascii::skip_space(str, strlen, &pos); |
3562 | 98 | 98 | ||
3563 | 99 | if (pos != strlen) | 99 | if (pos != strlen) |
3564 | 100 | return 1; | 100 | return 1; |
3565 | 101 | 101 | ||
3566 | === modified file 'src/zorbatypes/decimal.cpp' | |||
3567 | --- src/zorbatypes/decimal.cpp 2013-05-05 03:16:33 +0000 | |||
3568 | +++ src/zorbatypes/decimal.cpp 2013-05-09 00:49:28 +0000 | |||
3569 | @@ -37,7 +37,7 @@ | |||
3570 | 37 | if ( !*s ) | 37 | if ( !*s ) |
3571 | 38 | throw std::invalid_argument( "empty string" ); | 38 | throw std::invalid_argument( "empty string" ); |
3572 | 39 | 39 | ||
3574 | 40 | s = ascii::trim_start_whitespace( s ); | 40 | s = ascii::trim_start_space( s ); |
3575 | 41 | char const *const first_non_ws = s; | 41 | char const *const first_non_ws = s; |
3576 | 42 | 42 | ||
3577 | 43 | if ( *s == '+' || *s == '-' ) | 43 | if ( *s == '+' || *s == '-' ) |
3578 | 44 | 44 | ||
3579 | === modified file 'src/zorbatypes/floatimpl.cpp' | |||
3580 | --- src/zorbatypes/floatimpl.cpp 2013-05-04 17:29:21 +0000 | |||
3581 | +++ src/zorbatypes/floatimpl.cpp 2013-05-09 00:49:28 +0000 | |||
3582 | @@ -69,7 +69,7 @@ | |||
3583 | 69 | 69 | ||
3584 | 70 | int significant_digits = 0; | 70 | int significant_digits = 0; |
3585 | 71 | 71 | ||
3587 | 72 | s = ascii::trim_start_whitespace( s ); | 72 | s = ascii::trim_start_space( s ); |
3588 | 73 | 73 | ||
3589 | 74 | if ( !parse_etc( s ) ) { | 74 | if ( !parse_etc( s ) ) { |
3590 | 75 | char const *const first_non_ws = s; | 75 | char const *const first_non_ws = s; |
3591 | @@ -136,7 +136,7 @@ | |||
3592 | 136 | } else | 136 | } else |
3593 | 137 | return false; | 137 | return false; |
3594 | 138 | 138 | ||
3596 | 139 | return !*ascii::trim_start_whitespace( s ); | 139 | return !*ascii::trim_start_space( s ); |
3597 | 140 | } | 140 | } |
3598 | 141 | 141 | ||
3599 | 142 | ////////// constructors /////////////////////////////////////////////////////// | 142 | ////////// constructors /////////////////////////////////////////////////////// |
3600 | 143 | 143 | ||
3601 | === modified file 'src/zorbautils/locale.h' | |||
3602 | --- src/zorbautils/locale.h 2013-03-24 15:21:50 +0000 | |||
3603 | +++ src/zorbautils/locale.h 2013-05-09 00:49:28 +0000 | |||
3604 | @@ -55,10 +55,7 @@ | |||
3605 | 55 | // Template version of find(). | 55 | // Template version of find(). |
3606 | 56 | // | 56 | // |
3607 | 57 | template<class StringType> inline | 57 | template<class StringType> inline |
3612 | 58 | typename std::enable_if< | 58 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type |
3609 | 59 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
3610 | 60 | type | ||
3611 | 61 | >::type | ||
3613 | 62 | find( StringType const &country ) { | 59 | find( StringType const &country ) { |
3614 | 63 | return find( country.c_str() ); | 60 | return find( country.c_str() ); |
3615 | 64 | } | 61 | } |
3616 | @@ -101,10 +98,7 @@ | |||
3617 | 101 | // Template version of find(). | 98 | // Template version of find(). |
3618 | 102 | // | 99 | // |
3619 | 103 | template<class StringType> inline | 100 | template<class StringType> inline |
3624 | 104 | typename std::enable_if< | 101 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type |
3621 | 105 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
3622 | 106 | type | ||
3623 | 107 | >::type | ||
3625 | 108 | find( StringType const &lang ) { | 102 | find( StringType const &lang ) { |
3626 | 109 | return find( lang.c_str() ); | 103 | return find( lang.c_str() ); |
3627 | 110 | } | 104 | } |
3628 | @@ -265,10 +259,7 @@ | |||
3629 | 265 | // Template version of find(). | 259 | // Template version of find(). |
3630 | 266 | // | 260 | // |
3631 | 267 | template<class StringType> inline | 261 | template<class StringType> inline |
3636 | 268 | typename std::enable_if< | 262 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type |
3633 | 269 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
3634 | 270 | type | ||
3635 | 271 | >::type | ||
3637 | 272 | find( StringType const &lang ) { | 263 | find( StringType const &lang ) { |
3638 | 273 | return find( lang.c_str() ); | 264 | return find( lang.c_str() ); |
3639 | 274 | } | 265 | } |
3640 | @@ -288,10 +279,7 @@ | |||
3641 | 288 | // Template version of find_lang(). | 279 | // Template version of find_lang(). |
3642 | 289 | // | 280 | // |
3643 | 290 | template<class StringType> inline | 281 | template<class StringType> inline |
3648 | 291 | typename std::enable_if< | 282 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),iso639_1::type>::type |
3645 | 292 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
3646 | 293 | iso639_1::type | ||
3647 | 294 | >::type | ||
3649 | 295 | find_lang( StringType const &lang ) { | 283 | find_lang( StringType const &lang ) { |
3650 | 296 | return find_lang( lang.c_str() ); | 284 | return find_lang( lang.c_str() ); |
3651 | 297 | } | 285 | } |
3652 | @@ -436,10 +424,7 @@ | |||
3653 | 436 | // Template version of parse(). | 424 | // Template version of parse(). |
3654 | 437 | // | 425 | // |
3655 | 438 | template<class StringType> inline | 426 | template<class StringType> inline |
3660 | 439 | typename std::enable_if< | 427 | typename std::enable_if<ZORBA_HAS_C_STR(StringType),bool>::type |
3657 | 440 | ztd::has_c_str<StringType,char const* (StringType::*)() const>::value, | ||
3658 | 441 | bool | ||
3659 | 442 | >::type | ||
3661 | 443 | parse( StringType const &locale_str, iso639_1::type *lang = nullptr, | 428 | parse( StringType const &locale_str, iso639_1::type *lang = nullptr, |
3662 | 444 | iso3166_1::type *country = nullptr ) { | 429 | iso3166_1::type *country = nullptr ) { |
3663 | 445 | return parse( locale_str.c_str(), lang, country ); | 430 | return parse( locale_str.c_str(), lang, country ); |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ pjl-misc- 2013-05- 09T00-53- 05.805Z/ log.html
Log at: http://