Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

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
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-2013-05-09T00-53-05.805Z is finished. The final status was:

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 :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job pjl-misc-2013-05-09T14-41-54.794Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp 2013-03-21 23:41:00 +0000
+++ bin/zorbacmd.cpp 2013-05-09 00:49:28 +0000
@@ -662,7 +662,6 @@
662 TimingInfo& timing)662 TimingInfo& timing)
663{663{
664 unsigned long lNumExecutions = properties.multiple();664 unsigned long lNumExecutions = properties.multiple();
665 bool lIndent = properties.indent();
666 bool doTiming = properties.timing();665 bool doTiming = properties.timing();
667 bool serializePlan = properties.serializePlan();666 bool serializePlan = properties.serializePlan();
668 bool savePlan = properties.savePlan();667 bool savePlan = properties.savePlan();
669668
=== modified file 'include/zorba/internal/ztd.h'
--- include/zorba/internal/ztd.h 2013-02-07 17:24:36 +0000
+++ include/zorba/internal/ztd.h 2013-05-09 00:49:28 +0000
@@ -258,6 +258,11 @@
258ZORBA_DECL_HAS_MEM_FN( str );258ZORBA_DECL_HAS_MEM_FN( str );
259ZORBA_DECL_HAS_MEM_FN( toString );259ZORBA_DECL_HAS_MEM_FN( toString );
260260
261#define ZORBA_HAS_C_STR(T) \
262 ::zorba::internal::ztd::has_c_str<T,char const* (T::*)() const>::value
263
264#define ZORBA_IS_STRING(T) ZORBA_HAS_C_STR(T)
265
261/**266/**
262 * \internal267 * \internal
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.
@@ -310,7 +315,7 @@
310 */315 */
311template<class T> inline316template<class T> inline
312typename std::enable_if<!has_insertion_operator<T>::value317typename std::enable_if<!has_insertion_operator<T>::value
313 && has_c_str<T,char const* (T::*)() const>::value,318 && ZORBA_HAS_C_STR(T),
314 std::string>::type319 std::string>::type
315to_string( T const &t ) {320to_string( T const &t ) {
316 return t.c_str();321 return t.c_str();
@@ -331,7 +336,7 @@
331 */336 */
332template<class T> inline337template<class T> inline
333typename std::enable_if<!has_insertion_operator<T>::value338typename std::enable_if<!has_insertion_operator<T>::value
334 && !has_c_str<T,char const* (T::*)() const>::value339 && !ZORBA_HAS_C_STR(T)
335 && has_str<T,std::string (T::*)() const>::value340 && has_str<T,std::string (T::*)() const>::value
336 && !has_toString<T,std::string (T::*)() const>::value,341 && !has_toString<T,std::string (T::*)() const>::value,
337 std::string>::type342 std::string>::type
@@ -354,7 +359,7 @@
354 */359 */
355template<class T> inline360template<class T> inline
356typename std::enable_if<!has_insertion_operator<T>::value361typename std::enable_if<!has_insertion_operator<T>::value
357 && !has_c_str<T,char const* (T::*)() const>::value362 && !ZORBA_HAS_C_STR(T)
358 && !has_str<T,std::string (T::*)() const>::value363 && !has_str<T,std::string (T::*)() const>::value
359 && has_toString<T,std::string (T::*)() const>::value,364 && has_toString<T,std::string (T::*)() const>::value,
360 std::string>::type365 std::string>::type
361366
=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp 2013-05-08 20:14:47 +0000
+++ src/api/serialization/serializer.cpp 2013-05-09 00:49:28 +0000
@@ -568,7 +568,7 @@
568568
569 // Put a space between consecutive text nodes (or a text node and an569 // Put a space between consecutive text nodes (or a text node and an
570 // atomic item), unless the text node contains whitespace only.570 // atomic item), unless the text node contains whitespace only.
571 if (!ascii::is_whitespace(text.c_str()))571 if (!ascii::is_space(text.c_str()))
572 {572 {
573 thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;573 thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
574 }574 }
@@ -729,7 +729,7 @@
729 // Ignore whitespace text nodes when doing indentation729 // Ignore whitespace text nodes when doing indentation
730 if (!ser->indent ||730 if (!ser->indent ||
731 child->getNodeKind() != store::StoreConsts::textNode ||731 child->getNodeKind() != store::StoreConsts::textNode ||
732 !ascii::is_whitespace(child->getStringValue().c_str()))732 !ascii::is_space(child->getStringValue().c_str()))
733 {733 {
734 emit_node(child, depth);734 emit_node(child, depth);
735 prev_node_kind = child->getNodeKind();735 prev_node_kind = child->getNodeKind();
736736
=== modified file 'src/api/zorba_functions.cpp'
--- src/api/zorba_functions.cpp 2013-02-07 17:24:36 +0000
+++ src/api/zorba_functions.cpp 2013-05-09 00:49:28 +0000
@@ -28,7 +28,7 @@
28///////////////////////////////////////////////////////////////////////////////28///////////////////////////////////////////////////////////////////////////////
2929
30void trim( String &s ) {30void trim( String &s ) {
31 ascii::trim_whitespace( s );31 ascii::trim_space( s );
32}32}
3333
34void trim( String &s, char const *chars ) {34void trim( String &s, char const *chars ) {
3535
=== modified file 'src/compiler/parser/symbol_table.cpp'
--- src/compiler/parser/symbol_table.cpp 2013-05-08 20:14:47 +0000
+++ src/compiler/parser/symbol_table.cpp 2013-05-09 00:49:28 +0000
@@ -113,12 +113,12 @@
113{113{
114 if (do_trim_start)114 if (do_trim_start)
115 {115 {
116 text = ascii::trim_start_whitespace(text, &length);116 text = ascii::trim_start_space(text, &length);
117 }117 }
118118
119 if (do_trim_end)119 if (do_trim_end)
120 {120 {
121 length = ascii::trim_end_whitespace(text, length);121 length = ascii::trim_end_space(text, length);
122 }122 }
123123
124 if (!is_eqname)124 if (!is_eqname)
@@ -146,13 +146,13 @@
146off_t symbol_table::put_uri(char const* text, size_t length)146off_t symbol_table::put_uri(char const* text, size_t length)
147{147{
148 // trim whitespace148 // trim whitespace
149 text = ascii::trim_whitespace(text, &length);149 text = ascii::trim_space(text, &length);
150150
151 // normalize whitespace151 // normalize whitespace
152 string result;152 string result;
153 if (! decode_string (text, length, &result))153 if (! decode_string (text, length, &result))
154 return -1;154 return -1;
155 ascii::normalize_whitespace( result );155 ascii::normalize_space( result );
156156
157 return heap.put (result.c_str (), 0, result.length ());157 return heap.put (result.c_str (), 0, result.length ());
158}158}
159159
=== modified file 'src/compiler/parser/xqdoc_comment.cpp'
--- src/compiler/parser/xqdoc_comment.cpp 2013-02-07 17:24:36 +0000
+++ src/compiler/parser/xqdoc_comment.cpp 2013-05-09 00:49:28 +0000
@@ -78,7 +78,7 @@
7878
79 // if the line contains an annotation, than we finish the description79 // if the line contains an annotation, than we finish the description
80 zstring lTmp;80 zstring lTmp;
81 ascii::trim_whitespace( lLine, &lTmp );81 ascii::trim_space( lLine, &lTmp );
82 if ( !lTmp.empty() && lTmp[0] == '@' ) {82 if ( !lTmp.empty() && lTmp[0] == '@' ) {
83 lDescriptionState = false;83 lDescriptionState = false;
84 if (!lAnntotation.empty()) {84 if (!lAnntotation.empty()) {
@@ -102,7 +102,7 @@
102XQDocComment::startsWithColon(zstring& aLine)102XQDocComment::startsWithColon(zstring& aLine)
103{103{
104 zstring temp;104 zstring temp;
105 ascii::trim_whitespace( aLine, &temp );105 ascii::trim_space( aLine, &temp );
106106
107 if ( !temp.empty() && temp[0] == ':' ) {107 if ( !temp.empty() && temp[0] == ':' ) {
108 aLine = temp.substr(1);108 aLine = temp.substr(1);
@@ -126,7 +126,7 @@
126 }126 }
127127
128 ascii::to_lower( lName );128 ascii::to_lower( lName );
129 ascii::normalize_whitespace( lValue );129 ascii::normalize_space( lValue );
130130
131 if ("version" == lName) {131 if ("version" == lName) {
132 theVersion = lValue;132 theVersion = lValue;
133133
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-05-08 20:14:47 +0000
+++ src/compiler/translator/translator.cpp 2013-05-09 00:49:28 +0000
@@ -13567,7 +13567,7 @@
13567 if (lPrevIsBoundary)13567 if (lPrevIsBoundary)
13568 {13568 {
13569 zstring content = v.get_elem_content().str();13569 zstring content = v.get_elem_content().str();
13570 utf8::trim_whitespace(content);13570 utf8::trim_space(content);
1357113571
13572 // Filtering out of whitespaces13572 // Filtering out of whitespaces
13573 if (content.empty())13573 if (content.empty())
@@ -14800,7 +14800,7 @@
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]
1480114801
14802 zstring lNormalizedTarget;14802 zstring lNormalizedTarget;
14803 ascii::normalize_whitespace(target, &lNormalizedTarget);14803 ascii::normalize_space(target, &lNormalizedTarget);
1480414804
14805 if (!GenericCast::castableToNCName(lNormalizedTarget))14805 if (!GenericCast::castableToNCName(lNormalizedTarget))
14806 {14806 {
1480714807
=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp 2013-03-15 08:22:41 +0000
+++ src/runtime/core/constructors.cpp 2013-05-09 00:49:28 +0000
@@ -687,7 +687,7 @@
687 // normalize value of xml:id687 // normalize value of xml:id
688 if (isId)688 if (isId)
689 {689 {
690 ascii::normalize_whitespace(lexicalValue);690 ascii::normalize_space(lexicalValue);
691 }691 }
692692
693 GENV_ITEMFACTORY->createUntypedAtomic(typedValue, lexicalValue);693 GENV_ITEMFACTORY->createUntypedAtomic(typedValue, lexicalValue);
694694
=== modified file 'src/runtime/durations_dates_times/format_dateTime.cpp'
--- src/runtime/durations_dates_times/format_dateTime.cpp 2013-05-04 20:23:57 +0000
+++ src/runtime/durations_dates_times/format_dateTime.cpp 2013-05-09 00:49:28 +0000
@@ -630,7 +630,7 @@
630 zstring::const_iterator *i,630 zstring::const_iterator *i,
631 modifier *mod, QueryLoc const &loc ) {631 modifier *mod, QueryLoc const &loc ) {
632 zstring::const_iterator &j = *i;632 zstring::const_iterator &j = *i;
633 ascii::skip_whitespace( picture_str, &j );633 ascii::skip_space( picture_str, &j );
634 if ( j == picture_str.end() || *j == ',' ) {634 if ( j == picture_str.end() || *j == ',' ) {
635 //635 //
636 // Assume that the ',' is the start of the width modifier (hence there is636 // Assume that the ',' is the start of the width modifier (hence there is
@@ -875,7 +875,7 @@
875 zstring::const_iterator *i, modifier *mod,875 zstring::const_iterator *i, modifier *mod,
876 QueryLoc const &loc ) {876 QueryLoc const &loc ) {
877 zstring::const_iterator &j = *i;877 zstring::const_iterator &j = *i;
878 ascii::skip_whitespace( picture_str, &j );878 ascii::skip_space( picture_str, &j );
879 if ( j == picture_str.end() )879 if ( j == picture_str.end() )
880 return;880 return;
881881
@@ -965,10 +965,10 @@
965 QueryLoc const &loc ) {965 QueryLoc const &loc ) {
966 zstring::const_iterator &j = *i;966 zstring::const_iterator &j = *i;
967967
968 ascii::skip_whitespace( picture_str, &j );968 ascii::skip_space( picture_str, &j );
969 if ( j == picture_str.end() || (*j != ',' && *j != ';') )969 if ( j == picture_str.end() || (*j != ',' && *j != ';') )
970 return;970 return;
971 ascii::skip_whitespace( picture_str, &++j );971 ascii::skip_space( picture_str, &++j );
972 if ( j == picture_str.end() )972 if ( j == picture_str.end() )
973 goto bad_width_modifier;973 goto bad_width_modifier;
974 if ( *j == '*' ) {974 if ( *j == '*' ) {
@@ -987,10 +987,10 @@
987987
988 mod->max_width = 0;988 mod->max_width = 0;
989989
990 ascii::skip_whitespace( picture_str, &j );990 ascii::skip_space( picture_str, &j );
991 if ( j == picture_str.end() || *j != '-' )991 if ( j == picture_str.end() || *j != '-' )
992 return;992 return;
993 ascii::skip_whitespace( picture_str, &++j );993 ascii::skip_space( picture_str, &++j );
994 if ( j == picture_str.end() )994 if ( j == picture_str.end() )
995 goto bad_width_modifier;995 goto bad_width_modifier;
996 if ( *j == '*' )996 if ( *j == '*' )
997997
=== modified file 'src/runtime/numerics/format_number.cpp'
--- src/runtime/numerics/format_number.cpp 2013-05-04 14:06:36 +0000
+++ src/runtime/numerics/format_number.cpp 2013-05-09 00:49:28 +0000
@@ -786,7 +786,7 @@
786 } else {786 } else {
787787
788 zstring format_name( format_name_item->getStringValue() );788 zstring format_name( format_name_item->getStringValue() );
789 ascii::trim_whitespace( format_name );789 ascii::trim_space( format_name );
790 zstring prefix, local;790 zstring prefix, local;
791 if ( !xml::split_name( format_name, &prefix, &local ) ||791 if ( !xml::split_name( format_name, &prefix, &local ) ||
792 prefix.empty() ) {792 prefix.empty() ) {
793793
=== modified file 'src/runtime/qnames/qnames_impl.cpp'
--- src/runtime/qnames/qnames_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/qnames/qnames_impl.cpp 2013-05-09 00:49:28 +0000
@@ -58,7 +58,7 @@
58 {58 {
59 itemQName->getStringValue2(qname);59 itemQName->getStringValue2(qname);
6060
61 ascii::trim_whitespace(qname);61 ascii::trim_space(qname);
6262
63 index = qname.find(":", 0, 1);63 index = qname.find(":", 0, 1);
6464
@@ -135,14 +135,14 @@
135 {135 {
136 itemURI->getStringValue2(resNs);136 itemURI->getStringValue2(resNs);
137137
138 ascii::trim_whitespace(resNs);138 ascii::trim_space(resNs);
139 }139 }
140140
141 consumeNext(itemQName, theChild1.getp(), planState );141 consumeNext(itemQName, theChild1.getp(), planState );
142142
143 itemQName->getStringValue2(qname);143 itemQName->getStringValue2(qname);
144144
145 ascii::trim_whitespace(qname);145 ascii::trim_space(qname);
146146
147 index = qname.find(":", 0, 1);147 index = qname.find(":", 0, 1);
148148
@@ -295,7 +295,7 @@
295 else295 else
296 {296 {
297 itemPrefix->getStringValue2(prefix);297 itemPrefix->getStringValue2(prefix);
298 ascii::trim_whitespace(prefix);298 ascii::trim_space(prefix);
299 }299 }
300300
301 if (!consumeNext(itemElem, theChildren[1].getp(), planState ))301 if (!consumeNext(itemElem, theChildren[1].getp(), planState ))
302302
=== modified file 'src/runtime/strings/strings_impl.cpp'
--- src/runtime/strings/strings_impl.cpp 2013-05-06 14:27:15 +0000
+++ src/runtime/strings/strings_impl.cpp 2013-05-09 00:49:28 +0000
@@ -767,7 +767,7 @@
767 if (consumeNext(item, theChildren [0].getp(), planState))767 if (consumeNext(item, theChildren [0].getp(), planState))
768 {768 {
769 item->getStringValue2(resStr);769 item->getStringValue2(resStr);
770 ascii::normalize_whitespace(resStr);770 ascii::normalize_space(resStr);
771 STACK_PUSH(GENV_ITEMFACTORY->createString(result, resStr), state);771 STACK_PUSH(GENV_ITEMFACTORY->createString(result, resStr), state);
772 }772 }
773 else773 else
@@ -811,7 +811,7 @@
811 ZORBA_ASSERT(false);811 ZORBA_ASSERT(false);
812812
813 item1->getStringValue2(normForm);813 item1->getStringValue2(normForm);
814 ascii::trim_whitespace(normForm);814 ascii::trim_space(normForm);
815 zstring tmp(normForm);815 zstring tmp(normForm);
816 utf8::to_upper(tmp, &normForm);816 utf8::to_upper(tmp, &normForm);
817 }817 }
818818
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2013-05-08 20:14:47 +0000
+++ src/store/naive/atomic_items.cpp 2013-05-09 00:49:28 +0000
@@ -570,7 +570,7 @@
570bool UntypedAtomicItem::castToBoolean(store::Item_t& result) const570bool UntypedAtomicItem::castToBoolean(store::Item_t& result) const
571{571{
572 zstring str;572 zstring str;
573 ascii::trim_whitespace(theValue, &str);573 ascii::trim_space(theValue, &str);
574 bool value = true;574 bool value = true;
575575
576 if (ZSTREQ(str, "false") || ZSTREQ(str, "0"))576 if (ZSTREQ(str, "false") || ZSTREQ(str, "0"))
577577
=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp 2013-04-17 18:37:33 +0000
+++ src/store/naive/simple_item_factory.cpp 2013-05-09 00:49:28 +0000
@@ -1222,7 +1222,7 @@
1222 zstring prefix;1222 zstring prefix;
1223 zstring local;1223 zstring local;
12241224
1225 ascii::trim_whitespace(str);1225 ascii::trim_space(str);
1226 zstring::size_type pos = str.rfind(":", str.size(), 1);1226 zstring::size_type pos = str.rfind(":", str.size(), 1);
12271227
1228 if (pos != zstring::npos)1228 if (pos != zstring::npos)
@@ -2202,7 +2202,7 @@
2202 zstring& textValue,2202 zstring& textValue,
2203 std::vector<zstring>& atomicTextValues)2203 std::vector<zstring>& atomicTextValues)
2204{2204{
2205 ascii::normalize_whitespace(textValue);2205 ascii::normalize_space(textValue);
22062206
2207 zstring::size_type start = 0;2207 zstring::size_type start = 0;
2208 zstring::size_type i = 0;2208 zstring::size_type i = 0;
22092209
=== modified file 'src/types/casting.cpp'
--- src/types/casting.cpp 2013-05-08 20:14:47 +0000
+++ src/types/casting.cpp 2013-05-09 00:49:28 +0000
@@ -576,7 +576,7 @@
576 zstring::size_type len = strval.size();576 zstring::size_type len = strval.size();
577 zstring::size_type pos = 0;577 zstring::size_type pos = 0;
578578
579 ascii::skip_whitespace(str, len, &pos);579 ascii::skip_space(str, len, &pos);
580580
581 str += pos;581 str += pos;
582582
@@ -606,7 +606,7 @@
606 }606 }
607607
608 pos = str - strval.c_str();608 pos = str - strval.c_str();
609 ascii::skip_whitespace(strval.c_str(), len, &pos);609 ascii::skip_space(strval.c_str(), len, &pos);
610610
611 if (pos != len)611 if (pos != len)
612 {612 {
@@ -661,7 +661,7 @@
661661
662T1_TO_T2(str, QN)662T1_TO_T2(str, QN)
663{663{
664 ascii::trim_whitespace(strval);664 ascii::trim_space(strval);
665665
666 zstring::size_type idx = strval.find(":");666 zstring::size_type idx = strval.find(":");
667 zstring::size_type lidx = strval.rfind(":", strval.size(), 1);667 zstring::size_type lidx = strval.rfind(":", strval.size(), 1);
@@ -713,7 +713,7 @@
713713
714T1_TO_T2(str, NOT)714T1_TO_T2(str, NOT)
715{715{
716 ascii::trim_whitespace(strval);716 ascii::trim_space(strval);
717717
718 zstring uri;718 zstring uri;
719 zstring prefix;719 zstring prefix;
@@ -1736,7 +1736,7 @@
1736 char ch;1736 char ch;
1737 zstring::size_type sz = strval.size();1737 zstring::size_type sz = strval.size();
17381738
1739 ascii::trim_whitespace(strval);1739 ascii::trim_space(strval);
17401740
1741 bool spaceSeen = false;1741 bool spaceSeen = false;
17421742
@@ -1783,7 +1783,7 @@
1783 }1783 }
1784 case store::XS_NMTOKEN:1784 case store::XS_NMTOKEN:
1785 {1785 {
1786 ascii::trim_whitespace(strval);1786 ascii::trim_space(strval);
17871787
1788 if (GenericCast::instance()->castableToNMToken(strval))1788 if (GenericCast::instance()->castableToNMToken(strval))
1789 {1789 {
@@ -1794,7 +1794,7 @@
1794 }1794 }
1795 case store::XS_NAME:1795 case store::XS_NAME:
1796 {1796 {
1797 ascii::trim_whitespace(strval);1797 ascii::trim_space(strval);
17981798
1799 if (GenericCast::instance()->castableToName(strval))1799 if (GenericCast::instance()->castableToName(strval))
1800 {1800 {
@@ -1805,8 +1805,8 @@
1805 }1805 }
1806 case store::XS_NCNAME:1806 case store::XS_NCNAME:
1807 {1807 {
1808 ascii::normalize_whitespace(strval);1808 ascii::normalize_space(strval);
1809 ascii::trim_whitespace(strval);1809 ascii::trim_space(strval);
18101810
1811 if (GenericCast::castableToNCName(strval))1811 if (GenericCast::castableToNCName(strval))
1812 {1812 {
@@ -2665,7 +2665,7 @@
2665 zstring strval;2665 zstring strval;
2666 item->getStringValue2(strval);2666 item->getStringValue2(strval);
26672667
2668 ascii::trim_whitespace(strval);2668 ascii::trim_space(strval);
26692669
2670 zstring::size_type idx = strval.find(":");2670 zstring::size_type idx = strval.find(":");
2671 zstring::size_type lidx = strval.rfind(":", strval.size(), 1);2671 zstring::size_type lidx = strval.rfind(":", strval.size(), 1);
26722672
=== modified file 'src/types/schema/XercesParseUtils.cpp'
--- src/types/schema/XercesParseUtils.cpp 2013-05-08 20:14:47 +0000
+++ src/types/schema/XercesParseUtils.cpp 2013-05-09 00:49:28 +0000
@@ -463,7 +463,7 @@
463 // remove following if xs:float will be represented by a C float463 // remove following if xs:float will be represented by a C float
464 //textValue = textValue.trim(" \n\r\t",4);464 //textValue = textValue.trim(" \n\r\t",4);
465 zstring textValue2;465 zstring textValue2;
466 utf8::normalize_whitespace(textValue, &textValue2);466 utf8::normalize_space(textValue, &textValue2);
467 try467 try
468 {468 {
469 xs_float const n(textValue2.c_str());469 xs_float const n(textValue2.c_str());
@@ -501,7 +501,7 @@
501 // remove following if xs:float will be represented by a C float501 // remove following if xs:float will be represented by a C float
502 //textValue = textValue.trim(" \n\r\t",4);502 //textValue = textValue.trim(" \n\r\t",4);
503 zstring textValue2;503 zstring textValue2;
504 utf8::normalize_whitespace(textValue, &textValue2);504 utf8::normalize_space(textValue, &textValue2);
505 store::ItemFactory* factory = GENV_ITEMFACTORY;505 store::ItemFactory* factory = GENV_ITEMFACTORY;
506 try {506 try {
507 xs_double const n(textValue2.c_str());507 xs_double const n(textValue2.c_str());
@@ -550,7 +550,7 @@
550{550{
551 // optimization posible since there is no pattern to be checked551 // optimization posible since there is no pattern to be checked
552 zstring textValue2;552 zstring textValue2;
553 utf8::normalize_whitespace(textValue, &textValue2);553 utf8::normalize_space(textValue, &textValue2);
554 store::ItemFactory* factory = GENV_ITEMFACTORY;554 store::ItemFactory* factory = GENV_ITEMFACTORY;
555 return factory->createString(result, textValue2);555 return factory->createString(result, textValue2);
556}556}
@@ -562,7 +562,7 @@
562{562{
563 // optimization posible since there is no pattern to be checked563 // optimization posible since there is no pattern to be checked
564 zstring textValue2;564 zstring textValue2;
565 utf8::normalize_whitespace(textValue, &textValue2);565 utf8::normalize_space(textValue, &textValue2);
566 store::ItemFactory* factory = GENV_ITEMFACTORY;566 store::ItemFactory* factory = GENV_ITEMFACTORY;
567 567
568 return factory->createNormalizedString(result, textValue2);568 return factory->createNormalizedString(result, textValue2);
@@ -580,7 +580,7 @@
580 //return true; 580 //return true;
581581
582 zstring textValue2;582 zstring textValue2;
583 utf8::normalize_whitespace(textValue, &textValue2);583 utf8::normalize_space(textValue, &textValue2);
584 XMLCh* content = XMLString::transcode(textValue2.c_str()); 584 XMLCh* content = XMLString::transcode(textValue2.c_str());
585 XSValue::DataType datatype = XSValue::dt_token;585 XSValue::DataType datatype = XSValue::dt_token;
586 XSValue::Status status = XSValue::st_Init;586 XSValue::Status status = XSValue::st_Init;
@@ -607,7 +607,7 @@
607 store::Item_t &result)607 store::Item_t &result)
608{608{
609 zstring textValue2;609 zstring textValue2;
610 utf8::normalize_whitespace(textValue, &textValue2);610 utf8::normalize_space(textValue, &textValue2);
611611
612 XMLCh* content = XMLString::transcode(textValue2.c_str()); 612 XMLCh* content = XMLString::transcode(textValue2.c_str());
613 XSValue::DataType datatype = XSValue::dt_NMTOKEN;613 XSValue::DataType datatype = XSValue::dt_NMTOKEN;
@@ -635,7 +635,7 @@
635 store::Item_t &result)635 store::Item_t &result)
636{636{
637 zstring textValue2;637 zstring textValue2;
638 utf8::normalize_whitespace(textValue, &textValue2);638 utf8::normalize_space(textValue, &textValue2);
639639
640 XMLCh* content = XMLString::transcode(textValue2.c_str()); 640 XMLCh* content = XMLString::transcode(textValue2.c_str());
641 XSValue::DataType datatype = XSValue::dt_Name;641 XSValue::DataType datatype = XSValue::dt_Name;
@@ -664,7 +664,7 @@
664 store::Item_t &result)664 store::Item_t &result)
665{665{
666 zstring textValue2;666 zstring textValue2;
667 utf8::normalize_whitespace(textValue, &textValue2);667 utf8::normalize_space(textValue, &textValue2);
668668
669 XMLCh* content = XMLString::transcode(textValue2.c_str()); 669 XMLCh* content = XMLString::transcode(textValue2.c_str());
670 XSValue::DataType datatype = XSValue::dt_NCName;670 XSValue::DataType datatype = XSValue::dt_NCName;
@@ -692,7 +692,7 @@
692 store::Item_t &result)692 store::Item_t &result)
693{693{
694 zstring textValue2;694 zstring textValue2;
695 utf8::normalize_whitespace(textValue, &textValue2);695 utf8::normalize_space(textValue, &textValue2);
696696
697 XMLCh* content = XMLString::transcode(textValue.c_str()); 697 XMLCh* content = XMLString::transcode(textValue.c_str());
698 XSValue::DataType datatype = XSValue::dt_ID;698 XSValue::DataType datatype = XSValue::dt_ID;
@@ -720,7 +720,7 @@
720 store::Item_t &result)720 store::Item_t &result)
721{721{
722 zstring textValue2;722 zstring textValue2;
723 utf8::normalize_whitespace(textValue, &textValue2);723 utf8::normalize_space(textValue, &textValue2);
724724
725 XMLCh* content = XMLString::transcode(textValue.c_str()); 725 XMLCh* content = XMLString::transcode(textValue.c_str());
726 XSValue::DataType datatype = XSValue::dt_IDREF;726 XSValue::DataType datatype = XSValue::dt_IDREF;
@@ -748,7 +748,7 @@
748 store::Item_t &result)748 store::Item_t &result)
749{749{
750 zstring textValue2;750 zstring textValue2;
751 utf8::normalize_whitespace(textValue, &textValue2);751 utf8::normalize_space(textValue, &textValue2);
752752
753 XMLCh* content = XMLString::transcode(textValue2.c_str()); 753 XMLCh* content = XMLString::transcode(textValue2.c_str());
754 XSValue::DataType datatype = XSValue::dt_ENTITY;754 XSValue::DataType datatype = XSValue::dt_ENTITY;
@@ -776,7 +776,7 @@
776 store::Item_t &result)776 store::Item_t &result)
777{777{
778 zstring textValue2;778 zstring textValue2;
779 utf8::normalize_whitespace(textValue, &textValue2);779 utf8::normalize_space(textValue, &textValue2);
780780
781 XMLCh* content = XMLString::transcode(textValue2.c_str()); 781 XMLCh* content = XMLString::transcode(textValue2.c_str());
782 XSValue::DataType datatype = XSValue::dt_NOTATION;782 XSValue::DataType datatype = XSValue::dt_NOTATION;
@@ -834,7 +834,7 @@
834 //return factory->createDateTime(result, year, month, day, hour, minute, sec);834 //return factory->createDateTime(result, year, month, day, hour, minute, sec);
835 xs_dateTime dt;835 xs_dateTime dt;
836 zstring textValue2;836 zstring textValue2;
837 utf8::normalize_whitespace(textValue, &textValue2);837 utf8::normalize_space(textValue, &textValue2);
838838
839 // Warning: parsing code is not using Xerces839 // Warning: parsing code is not using Xerces
840 if (0 == DateTime::parseDateTime(textValue2.c_str(), textValue2.size(), dt)) 840 if (0 == DateTime::parseDateTime(textValue2.c_str(), textValue2.size(), dt))
@@ -874,7 +874,7 @@
874 //return factory->createDate(result, tValue);874 //return factory->createDate(result, tValue);
875 xs_date d;875 xs_date d;
876 zstring textValue2;876 zstring textValue2;
877 utf8::normalize_whitespace(textValue, &textValue2);877 utf8::normalize_space(textValue, &textValue2);
878878
879 // Warning: parsing code is not using Xerces879 // Warning: parsing code is not using Xerces
880 if (0 == DateTime::parseDate(textValue2.c_str(), textValue2.size(), d)) 880 if (0 == DateTime::parseDate(textValue2.c_str(), textValue2.size(), d))
@@ -919,7 +919,7 @@
919 //return factory->createTime(result, tValue);919 //return factory->createTime(result, tValue);
920 xs_time t;920 xs_time t;
921 zstring textValue2;921 zstring textValue2;
922 utf8::normalize_whitespace(textValue, &textValue2);922 utf8::normalize_space(textValue, &textValue2);
923923
924 // Warning: parsing code is not using Xerces924 // Warning: parsing code is not using Xerces
925 if (0 == DateTime::parseTime(textValue2.c_str(), textValue2.size(), t))925 if (0 == DateTime::parseTime(textValue2.c_str(), textValue2.size(), t))
@@ -954,7 +954,7 @@
954 xs_gYearMonth tValue;954 xs_gYearMonth tValue;
955 955
956 zstring textValue2;956 zstring textValue2;
957 utf8::normalize_whitespace(textValue, &textValue2);957 utf8::normalize_space(textValue, &textValue2);
958958
959 // Warning: parsing code is not using Xerces959 // Warning: parsing code is not using Xerces
960 if (DateTime::parseGYearMonth(textValue2.c_str(), textValue2.size(), tValue))960 if (DateTime::parseGYearMonth(textValue2.c_str(), textValue2.size(), tValue))
@@ -988,7 +988,7 @@
988 xs_gYear tValue;988 xs_gYear tValue;
989 989
990 zstring textValue2;990 zstring textValue2;
991 utf8::normalize_whitespace(textValue, &textValue2);991 utf8::normalize_space(textValue, &textValue2);
992992
993 // Warning: parsing code is not using Xerces993 // Warning: parsing code is not using Xerces
994 if (DateTime::parseGYear(textValue2.c_str(), textValue2.size(), tValue))994 if (DateTime::parseGYear(textValue2.c_str(), textValue2.size(), tValue))
@@ -1022,7 +1022,7 @@
1022 store::ItemFactory* factory = GENV_ITEMFACTORY;1022 store::ItemFactory* factory = GENV_ITEMFACTORY;
1023 xs_gMonthDay tValue;1023 xs_gMonthDay tValue;
1024 zstring textValue2;1024 zstring textValue2;
1025 utf8::normalize_whitespace(textValue, &textValue2);1025 utf8::normalize_space(textValue, &textValue2);
10261026
1027 // Warning: parsing code is not using Xerces1027 // Warning: parsing code is not using Xerces
1028 if (DateTime::parseGMonthDay(textValue2.c_str(), textValue2.size(), tValue))1028 if (DateTime::parseGMonthDay(textValue2.c_str(), textValue2.size(), tValue))
@@ -1055,7 +1055,7 @@
1055 store::ItemFactory* factory = GENV_ITEMFACTORY;1055 store::ItemFactory* factory = GENV_ITEMFACTORY;
1056 xs_gDay tValue;1056 xs_gDay tValue;
1057 zstring textValue2;1057 zstring textValue2;
1058 utf8::normalize_whitespace(textValue, &textValue2);1058 utf8::normalize_space(textValue, &textValue2);
10591059
1060 // Warning: parsing code is not using Xerces1060 // Warning: parsing code is not using Xerces
1061 if (DateTime::parseGDay(textValue2.c_str(), textValue2.size(), tValue))1061 if (DateTime::parseGDay(textValue2.c_str(), textValue2.size(), tValue))
@@ -1088,7 +1088,7 @@
1088 store::ItemFactory* factory = GENV_ITEMFACTORY;1088 store::ItemFactory* factory = GENV_ITEMFACTORY;
1089 xs_gMonth tValue;1089 xs_gMonth tValue;
1090 zstring textValue2;1090 zstring textValue2;
1091 utf8::normalize_whitespace(textValue, &textValue2);1091 utf8::normalize_space(textValue, &textValue2);
10921092
1093 // Warning: parsing code is not using Xerces1093 // Warning: parsing code is not using Xerces
1094 if (DateTime::parseGMonth(textValue2.c_str(), textValue2.size(), tValue))1094 if (DateTime::parseGMonth(textValue2.c_str(), textValue2.size(), tValue))
@@ -1127,7 +1127,7 @@
1127 store::ItemFactory* factory = GENV_ITEMFACTORY;1127 store::ItemFactory* factory = GENV_ITEMFACTORY;
1128 Duration tValue;1128 Duration tValue;
1129 zstring textValue2;1129 zstring textValue2;
1130 utf8::normalize_whitespace(textValue, &textValue2);1130 utf8::normalize_space(textValue, &textValue2);
11311131
1132 // Warning: parsing code is not using Xerces1132 // Warning: parsing code is not using Xerces
1133 if (0 == Duration::parseDuration(textValue2.c_str(), textValue2.size(), tValue))1133 if (0 == Duration::parseDuration(textValue2.c_str(), textValue2.size(), tValue))
@@ -1263,7 +1263,7 @@
12631263
1264 store::ItemFactory* factory = GENV_ITEMFACTORY;1264 store::ItemFactory* factory = GENV_ITEMFACTORY;
1265 zstring textValue2;1265 zstring textValue2;
1266 utf8::normalize_whitespace(textValue, &textValue2);1266 utf8::normalize_space(textValue, &textValue2);
12671267
1268 return factory->createAnyURI(result, textValue2);1268 return factory->createAnyURI(result, textValue2);
1269 }1269 }
@@ -1289,7 +1289,7 @@
12891289
1290 store::ItemFactory* factory = GENV_ITEMFACTORY;1290 store::ItemFactory* factory = GENV_ITEMFACTORY;
1291 zstring textValue2;1291 zstring textValue2;
1292 utf8::normalize_whitespace(textValue, &textValue2);1292 utf8::normalize_space(textValue, &textValue2);
1293 1293
1294 // todo: get the right namespace from the current context1294 // todo: get the right namespace from the current context
1295 zstring lNamespace;1295 zstring lNamespace;
12961296
=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp 2013-05-02 00:18:56 +0000
+++ src/types/schema/schema.cpp 2013-05-09 00:49:28 +0000
@@ -1839,7 +1839,7 @@
1839 std::vector<zstring>& atomicTextValues)1839 std::vector<zstring>& atomicTextValues)
1840{1840{
1841 zstring normalizedTextValue;1841 zstring normalizedTextValue;
1842 utf8::normalize_whitespace(textValue, &normalizedTextValue);1842 utf8::normalize_space(textValue, &normalizedTextValue);
18431843
1844 size_t start = 0;1844 size_t start = 0;
1845 size_t i = 0;1845 size_t i = 0;
18461846
=== modified file 'src/types/schema/validate.cpp'
--- src/types/schema/validate.cpp 2013-04-23 20:38:23 +0000
+++ src/types/schema/validate.cpp 2013-05-09 00:49:28 +0000
@@ -732,7 +732,7 @@
732732
733 // XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/733 // XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/
734 // section 6.7.4 Construction from a PSVI734 // section 6.7.4 Construction from a PSVI
735 if ( !utf8::is_whitespace(textNodeValue) )735 if ( !utf8::is_space(textNodeValue) )
736 {736 {
737 zstring empty;737 zstring empty;
738 GENV_ITEMFACTORY->createTextNode(validatedTextNode,738 GENV_ITEMFACTORY->createTextNode(validatedTextNode,
739739
=== modified file 'src/unit_tests/test_string.cpp'
--- src/unit_tests/test_string.cpp 2013-02-07 17:24:36 +0000
+++ src/unit_tests/test_string.cpp 2013-05-09 00:49:28 +0000
@@ -330,16 +330,16 @@
330}330}
331331
332template<class StringType>332template<class StringType>
333static void test_normalize_whitespace() {333static void test_normalize_space() {
334 StringType const s( " hello world " );334 StringType const s( " hello world " );
335 StringType u;335 StringType u;
336336
337 ascii::normalize_whitespace( s, &u );337 ascii::normalize_space( s, &u );
338 ASSERT_TRUE( u == "hello world" );338 ASSERT_TRUE( u == "hello world" );
339339
340 utf8_string<StringType const> const s8( s );340 utf8_string<StringType const> const s8( s );
341 utf8_string<StringType> u8( u );341 utf8_string<StringType> u8( u );
342 utf8::normalize_whitespace( s8, &u8 );342 utf8::normalize_space( s8, &u8 );
343 ASSERT_TRUE( u8 == "hello world" );343 ASSERT_TRUE( u8 == "hello world" );
344}344}
345345
@@ -493,14 +493,14 @@
493 ASSERT_TRUE( !utf8::ends_with( u_ab, "a" ) );493 ASSERT_TRUE( !utf8::ends_with( u_ab, "a" ) );
494}494}
495495
496static void test_skip_whitespace() {496static void test_skip_space() {
497 char const s[] = " hello world";497 char const s[] = " hello world";
498 ascii::size_type const s_len = ::strlen( s );498 ascii::size_type const s_len = ::strlen( s );
499 ascii::size_type pos = 0;499 ascii::size_type pos = 0;
500 ascii::skip_whitespace( s, s_len, &pos );500 ascii::skip_space( s, s_len, &pos );
501 ASSERT_TRUE( pos == 2 );501 ASSERT_TRUE( pos == 2 );
502 pos = 7;502 pos = 7;
503 ascii::skip_whitespace( s, s_len, &pos );503 ascii::skip_space( s, s_len, &pos );
504 ASSERT_TRUE( pos == 8 );504 ASSERT_TRUE( pos == 8 );
505}505}
506506
@@ -673,16 +673,16 @@
673}673}
674674
675template<class StringType>675template<class StringType>
676static void test_trim_whitespace() {676static void test_trim_space() {
677 StringType const s( " hello world " );677 StringType const s( " hello world " );
678 StringType u;678 StringType u;
679679
680 ascii::trim_whitespace( s, &u );680 ascii::trim_space( s, &u );
681 ASSERT_TRUE( u == "hello world" );681 ASSERT_TRUE( u == "hello world" );
682682
683 utf8_string<StringType const> const s8( s );683 utf8_string<StringType const> const s8( s );
684 utf8_string<StringType> u8( u );684 utf8_string<StringType> u8( u );
685 utf8::trim_whitespace( s8, &u8 );685 utf8::trim_space( s8, &u8 );
686 ASSERT_TRUE( u8 == "hello world" );686 ASSERT_TRUE( u8 == "hello world" );
687}687}
688688
@@ -854,10 +854,10 @@
854 test_next_match();854 test_next_match();
855 test_next_token();855 test_next_token();
856856
857 test_normalize_whitespace<string>();857 test_normalize_space<string>();
858 test_normalize_whitespace<zstring>();858 test_normalize_space<zstring>();
859 test_normalize_whitespace<zstring_p>();859 test_normalize_space<zstring_p>();
860 test_normalize_whitespace<String>();860 test_normalize_space<String>();
861861
862 test_replace_all<string>();862 test_replace_all<string>();
863 test_replace_all<String>();863 test_replace_all<String>();
@@ -872,7 +872,7 @@
872 test_reverse<zstring_p>( utf8_aeiou_acute );872 test_reverse<zstring_p>( utf8_aeiou_acute );
873 test_reverse<String>( utf8_aeiou_acute );873 test_reverse<String>( utf8_aeiou_acute );
874874
875 test_skip_whitespace();875 test_skip_space();
876876
877 test_split<string>( "a", "b" );877 test_split<string>( "a", "b" );
878 test_split<zstring>( "a", "b" );878 test_split<zstring>( "a", "b" );
@@ -911,9 +911,9 @@
911911
912 test_trim_start();912 test_trim_start();
913 test_trim_end();913 test_trim_end();
914 test_trim_whitespace<string>();914 test_trim_space<string>();
915 test_trim_whitespace<zstring>();915 test_trim_space<zstring>();
916 test_trim_whitespace<String>();916 test_trim_space<String>();
917917
918 test_uri_encode<string>();918 test_uri_encode<string>();
919 test_uri_encode<String>();919 test_uri_encode<String>();
920920
=== modified file 'src/util/ascii_util.cpp'
--- src/util/ascii_util.cpp 2013-03-19 04:22:49 +0000
+++ src/util/ascii_util.cpp 2013-05-09 00:49:28 +0000
@@ -30,7 +30,7 @@
3030
31///////////////////////////////////////////////////////////////////////////////31///////////////////////////////////////////////////////////////////////////////
3232
33bool is_whitespace( char const *s ) {33bool is_space( char const *s ) {
34 for ( ; *s; ++s ) {34 for ( ; *s; ++s ) {
35 if ( !is_space( *s ) )35 if ( !is_space( *s ) )
36 return false;36 return false;
3737
=== modified file 'src/util/ascii_util.h'
--- src/util/ascii_util.h 2013-05-06 22:57:08 +0000
+++ src/util/ascii_util.h 2013-05-09 00:49:28 +0000
@@ -73,7 +73,7 @@
73 *73 *
74 * @param s The string to append to.74 * @param s The string to append to.
75 */75 */
76 explicit back_ascii_insert_iterator( StringType &s ) : base_type( s ) {76 explicit back_ascii_insert_iterator( StringType *s ) : base_type( s ) {
77 }77 }
7878
79 back_ascii_insert_iterator& operator=( value_type c );79 back_ascii_insert_iterator& operator=( value_type c );
@@ -86,7 +86,7 @@
86 * @param out The output string.86 * @param out The output string.
87 */87 */
88template<class StringType> inline back_ascii_insert_iterator<StringType>88template<class StringType> inline back_ascii_insert_iterator<StringType>
89back_ascii_inserter( StringType &out ) {89back_ascii_inserter( StringType *out ) {
90 return back_ascii_insert_iterator<StringType>( out );90 return back_ascii_insert_iterator<StringType>( out );
91}91}
9292
@@ -102,7 +102,8 @@
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.
103 */103 */
104template<typename CharType> inline104template<typename CharType> inline
105bool is_ascii( CharType c ) {105typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
106is_ascii( CharType c ) {
106#ifdef WIN32107#ifdef WIN32
107 return __isascii( c );108 return __isascii( c );
108#else109#else
@@ -120,7 +121,8 @@
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.
121 */122 */
122template<typename CharType> inline123template<typename CharType> inline
123bool is_alpha( CharType c ) {124typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
125is_alpha( CharType c ) {
124 return is_ascii( c ) && isalpha( c );126 return is_ascii( c ) && isalpha( c );
125}127}
126128
@@ -134,7 +136,8 @@
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.
135 */137 */
136template<typename CharType> inline138template<typename CharType> inline
137bool is_alnum( CharType c ) {139typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
140is_alnum( CharType c ) {
138 return is_ascii( c ) && isalnum( c );141 return is_ascii( c ) && isalnum( c );
139}142}
140143
@@ -148,7 +151,8 @@
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.
149 */152 */
150template<typename CharType> inline153template<typename CharType> inline
151bool is_cntrl( CharType c ) {154typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
155is_cntrl( CharType c ) {
152 return is_ascii( c ) && iscntrl( c );156 return is_ascii( c ) && iscntrl( c );
153}157}
154158
@@ -162,7 +166,8 @@
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.
163 */167 */
164template<typename CharType> inline168template<typename CharType> inline
165bool is_digit( CharType c ) {169typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
170is_digit( CharType c ) {
166 return is_ascii( c ) && isdigit( c );171 return is_ascii( c ) && isdigit( c );
167}172}
168173
@@ -176,7 +181,8 @@
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.
177 */182 */
178template<typename CharType> inline183template<typename CharType> inline
179bool is_print( CharType c ) {184typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
185is_print( CharType c ) {
180 return is_ascii( c ) && isprint( c );186 return is_ascii( c ) && isprint( c );
181}187}
182188
@@ -190,7 +196,8 @@
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.
191 */197 */
192template<typename CharType> inline198template<typename CharType> inline
193bool is_punct( CharType c ) {199typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
200is_punct( CharType c ) {
194 return is_ascii( c ) && ispunct( c );201 return is_ascii( c ) && ispunct( c );
195}202}
196203
@@ -199,12 +206,13 @@
199 * exists to make a proper function out of the standard isspace(3) that may be206 * exists to make a proper function out of the standard isspace(3) that may be
200 * implemented as a macro.207 * implemented as a macro.
201 *208 *
202 * @param CharType The character type.209 * @tparam CharType The character type.
203 * @param c The character to check.210 * @param c The character to check.
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.
205 */212 */
206template<typename CharType> inline213template<typename CharType> inline
207bool is_space( CharType c ) {214typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
215is_space( CharType c ) {
208 return is_ascii( c ) && isspace( c );216 return is_ascii( c ) && isspace( c );
209}217}
210218
@@ -214,17 +222,19 @@
214 * @param s The NULL-terminated C string to check.222 * @param s The NULL-terminated C string to check.
215 * @return Returns \c true only if the entire string is whitespace.223 * @return Returns \c true only if the entire string is whitespace.
216 */224 */
217bool is_whitespace( char const *s );225bool is_space( char const *s );
218226
219/**227/**
220 * Checks whether an entire string is whitespace.228 * Checks whether an entire string is whitespace.
221 *229 *
230 * @tparam StringType The string type.
222 * @param s The string to check.231 * @param s The string to check.
223 * @return Returns \c true only if the entire string is whitespace.232 * @return Returns \c true only if the entire string is whitespace.
224 */233 */
225template<class StringType> inline234template<class StringType> inline
226bool is_whitespace( StringType const &s ) {235typename std::enable_if<ZORBA_HAS_C_STR(StringType),bool>::type
227 return is_whitespace( s.c_str() );236is_space( StringType const &s ) {
237 return is_space( s.c_str() );
228}238}
229239
230/**240/**
@@ -237,7 +247,8 @@
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.
238 */248 */
239template<typename CharType> inline249template<typename CharType> inline
240bool is_xdigit( CharType c ) {250typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
251is_xdigit( CharType c ) {
241 return is_ascii( c ) && isxdigit( c );252 return is_ascii( c ) && isxdigit( c );
242}253}
243254
@@ -263,7 +274,8 @@
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.
264 */275 */
265template<class StringType> inline276template<class StringType> inline
266bool begins_with( StringType const &s, char c ) {277typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
278begins_with( StringType const &s, char c ) {
267 return !s.empty() && s[0] == c;279 return !s.empty() && s[0] == c;
268}280}
269281
@@ -300,8 +312,9 @@
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.
301 */313 */
302template<class StringType> inline314template<class StringType> inline
303bool begins_with( StringType const &s, char const *ps,315typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
304 typename StringType::size_type n ) {316begins_with( StringType const &s, char const *ps,
317 typename StringType::size_type n ) {
305 typedef typename StringType::traits_type traits_type;318 typedef typename StringType::traits_type traits_type;
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;
307}320}
@@ -315,7 +328,8 @@
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.
316 */329 */
317template<class StringType> inline330template<class StringType> inline
318bool begins_with( StringType const &s, char const *ps ) {331typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
332begins_with( StringType const &s, char const *ps ) {
319 return begins_with( s, ps, std::strlen( ps ) );333 return begins_with( s, ps, std::strlen( ps ) );
320}334}
321335
@@ -329,7 +343,10 @@
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.
330 */344 */
331template<class StringType,class PrefixStringType> inline345template<class StringType,class PrefixStringType> inline
332bool begins_with( StringType const &s, PrefixStringType const &ps ) {346typename std::enable_if<ZORBA_IS_STRING(StringType)
347 && ZORBA_IS_STRING(PrefixStringType),
348 bool>::type
349begins_with( StringType const &s, PrefixStringType const &ps ) {
333 return begins_with( s, ps.data(), ps.size() );350 return begins_with( s, ps.data(), ps.size() );
334}351}
335352
@@ -354,7 +371,8 @@
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.
355 */372 */
356template<class StringType> inline373template<class StringType> inline
357bool ends_with( StringType const &s, char c ) {374typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
375ends_with( StringType const &s, char c ) {
358 return !s.empty() && s[ s.size() - 1 ] == c;376 return !s.empty() && s[ s.size() - 1 ] == c;
359}377}
360378
@@ -392,8 +410,9 @@
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.
393 */411 */
394template<class StringType> inline412template<class StringType> inline
395bool ends_with( StringType const &s, char const *ss,413typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
396 typename StringType::size_type ss_len ) {414ends_with( StringType const &s, char const *ss,
415 typename StringType::size_type ss_len ) {
397 typename StringType::size_type const result = s.rfind( ss );416 typename StringType::size_type const result = s.rfind( ss );
398 return result != StringType::npos && result + ss_len == s.size();417 return result != StringType::npos && result + ss_len == s.size();
399}418}
@@ -407,7 +426,8 @@
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.
408 */427 */
409template<class StringType> inline428template<class StringType> inline
410bool ends_with( StringType const &s, char const *ss ) {429typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
430ends_with( StringType const &s, char const *ss ) {
411 return ends_with( s, ss, std::strlen( ss ) );431 return ends_with( s, ss, std::strlen( ss ) );
412}432}
413433
@@ -421,7 +441,10 @@
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.
422 */442 */
423template<class StringType,class SuffixStringType> inline443template<class StringType,class SuffixStringType> inline
424bool ends_with( StringType const &s, SuffixStringType const &ss ) {444typename std::enable_if<ZORBA_IS_STRING(StringType)
445 && ZORBA_IS_STRING(SuffixStringType),
446 bool>::type
447ends_with( StringType const &s, SuffixStringType const &ss ) {
425 return ends_with( s, ss.data(), ss.size() );448 return ends_with( s, ss.data(), ss.size() );
426}449}
427450
@@ -467,7 +490,8 @@
467 * @param s The string to convert.490 * @param s The string to convert.
468 */491 */
469template<class StringType> inline492template<class StringType> inline
470void to_lower( StringType &s ) {493typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
494to_lower( StringType &s ) {
471 std::transform(495 std::transform(
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 )
473 );497 );
@@ -483,7 +507,10 @@
483 * contents are overwritten.507 * contents are overwritten.
484 */508 */
485template<class InputStringType,class OutputStringType> inline509template<class InputStringType,class OutputStringType> inline
486void to_lower( InputStringType const &in, OutputStringType *out ) {510typename std::enable_if<ZORBA_IS_STRING(InputStringType)
511 && ZORBA_IS_STRING(OutputStringType),
512 void>::type
513to_lower( InputStringType const &in, OutputStringType *out ) {
487 std::transform(514 std::transform(
488 in.begin(), in.end(), std::back_inserter( *out ),515 in.begin(), in.end(), std::back_inserter( *out ),
489 static_cast<char (*)(char)>( to_lower )516 static_cast<char (*)(char)>( to_lower )
@@ -530,7 +557,8 @@
530 * @param s The string to convert.557 * @param s The string to convert.
531 */558 */
532template<class StringType> inline559template<class StringType> inline
533void to_upper( StringType &s ) {560typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
561to_upper( StringType &s ) {
534 std::transform(562 std::transform(
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 )
536 );564 );
@@ -546,7 +574,10 @@
546 * contents are overwritten.574 * contents are overwritten.
547 */575 */
548template<class InputStringType,class OutputStringType> inline576template<class InputStringType,class OutputStringType> inline
549void to_upper( InputStringType const &in, OutputStringType *out ) {577typename std::enable_if<ZORBA_IS_STRING(InputStringType)
578 && ZORBA_IS_STRING(OutputStringType),
579 void>::type
580to_upper( InputStringType const &in, OutputStringType *out ) {
550 std::transform(581 std::transform(
551 in.begin(), in.end(), std::back_inserter( *out ),582 in.begin(), in.end(), std::back_inserter( *out ),
552 static_cast<char (*)(char)>( to_upper )583 static_cast<char (*)(char)>( to_upper )
@@ -588,7 +619,8 @@
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.
589 */620 */
590template<class StringType>621template<class StringType>
591bool replace_all( StringType &s, char from, char to );622typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
623replace_all( StringType &s, char from, char to );
592624
593/**625/**
594 * Replaces all occurrences of one substring with another.626 * Replaces all occurrences of one substring with another.
@@ -602,9 +634,10 @@
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.
603 */635 */
604template<class StringType>636template<class StringType>
605bool replace_all( StringType &s,637typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
606 char const *from, typename StringType::size_type from_len,638replace_all( StringType &s,
607 char const *to, typename StringType::size_type to_len );639 char const *from, typename StringType::size_type from_len,
640 char const *to, typename StringType::size_type to_len );
608641
609/**642/**
610 * Replaces all occurrences of one substring with another.643 * Replaces all occurrences of one substring with another.
@@ -616,7 +649,8 @@
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.
617 */650 */
618template<class StringType> inline651template<class StringType> inline
619bool replace_all( StringType &s, char const *from, char const *to ) {652typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
653replace_all( StringType &s, char const *from, char const *to ) {
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 ) );
621}655}
622656
@@ -630,7 +664,10 @@
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.
631 */665 */
632template<class StringType,class ToStringType> inline666template<class StringType,class ToStringType> inline
633bool replace_all( StringType &s, char const *from, ToStringType const &to ) {667typename std::enable_if<ZORBA_IS_STRING(StringType)
668 && ZORBA_IS_STRING(ToStringType),
669 bool>::type
670replace_all( StringType &s, char const *from, ToStringType const &to ) {
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() );
635}672}
636673
@@ -644,8 +681,12 @@
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.
645 */682 */
646template<class StringType,class FromStringType,class ToStringType> inline683template<class StringType,class FromStringType,class ToStringType> inline
647bool replace_all( StringType &s, FromStringType const &from,684typename std::enable_if<ZORBA_IS_STRING(StringType)
648 ToStringType const &to ) {685 && ZORBA_IS_STRING(FromStringType)
686 && ZORBA_IS_STRING(ToStringType),
687 bool>::type
688replace_all( StringType &s, FromStringType const &from,
689 ToStringType const &to ) {
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() );
650}691}
651692
@@ -797,7 +838,10 @@
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).
798 */839 */
799template<class InputStringType,class OutputStringType>840template<class InputStringType,class OutputStringType>
800void normalize_whitespace( InputStringType const &in, OutputStringType *out );841typename std::enable_if<ZORBA_IS_STRING(InputStringType)
842 && ZORBA_IS_STRING(OutputStringType),
843 void>::type
844normalize_space( InputStringType const &in, OutputStringType *out );
801845
802/**846/**
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.
@@ -807,9 +851,10 @@
807 * @param s The string.851 * @param s The string.
808 */852 */
809template<class StringType> inline853template<class StringType> inline
810void normalize_whitespace( StringType &s ) {854typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
855normalize_space( StringType &s ) {
811 StringType temp;856 StringType temp;
812 normalize_whitespace( s, &temp );857 normalize_space( s, &temp );
813 s = temp;858 s = temp;
814}859}
815860
@@ -827,11 +872,13 @@
827/**872/**
828 * Removes all characters that are not among the specified characters.873 * Removes all characters that are not among the specified characters.
829 *874 *
875 * @tparam StringType The string type.
830 * @param s The string to remove characters from.876 * @param s The string to remove characters from.
831 * @param keep_chars The characters to keep.877 * @param keep_chars The characters to keep.
832 */878 */
833template<class StringType>879template<class StringType>
834void remove_not_chars( StringType &s, char const *keep_chars );880typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
881remove_not_chars( StringType &s, char const *keep_chars );
835882
836/**883/**
837 * Removes all whitespace characters by shifting the contents of the buffer to884 * Removes all whitespace characters by shifting the contents of the buffer to
@@ -841,7 +888,7 @@
841 * @param s_len The length of \a s.888 * @param s_len The length of \a s.
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.
843 */890 */
844inline size_type remove_whitespace( char *s, size_type s_len ) {891inline size_type remove_space( char *s, size_type s_len ) {
845 return remove_chars( s, s_len, whitespace );892 return remove_chars( s, s_len, whitespace );
846}893}
847894
@@ -855,8 +902,10 @@
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).
856 */903 */
857template<class InputStringType,class OutputStringType>904template<class InputStringType,class OutputStringType>
858void trim( InputStringType const &in, char const *chars,905typename std::enable_if<ZORBA_IS_STRING(InputStringType)
859 OutputStringType *out );906 && ZORBA_IS_STRING(OutputStringType),
907 void>::type
908trim( InputStringType const &in, char const *chars, OutputStringType *out );
860909
861/**910/**
862 * Removes all leading and trailing specified characters.911 * Removes all leading and trailing specified characters.
@@ -865,7 +914,8 @@
865 * @param s The string.914 * @param s The string.
866 */915 */
867template<class StringType> inline916template<class StringType> inline
868void trim( StringType &s, char const *chars ) {917typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
918trim( StringType &s, char const *chars ) {
869 StringType temp;919 StringType temp;
870 trim( s, chars, &temp );920 trim( s, chars, &temp );
871 s = temp;921 s = temp;
@@ -917,8 +967,11 @@
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).
918 */968 */
919template<class InputStringType,class OutputStringType>969template<class InputStringType,class OutputStringType>
920void trim_start( InputStringType const &in, char const *chars,970typename std::enable_if<ZORBA_IS_STRING(InputStringType)
921 OutputStringType *out );971 && ZORBA_IS_STRING(OutputStringType),
972 void>::type
973trim_start( InputStringType const &in, char const *chars,
974 OutputStringType *out );
922975
923/**976/**
924 * Removes all leading specified characters.977 * Removes all leading specified characters.
@@ -928,7 +981,8 @@
928 * @param chars The characters to trim.981 * @param chars The characters to trim.
929 */982 */
930template<class StringType> inline983template<class StringType> inline
931void trim_start( StringType &s, char const *chars ) {984typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
985trim_start( StringType &s, char const *chars ) {
932 StringType temp;986 StringType temp;
933 trim_start( s, chars, &temp );987 trim_start( s, chars, &temp );
934 s = temp;988 s = temp;
@@ -941,7 +995,7 @@
941 * @return Returns a pointer to the first character in \a s that is not a995 * @return Returns a pointer to the first character in \a s that is not a
942 * whitespace character.996 * whitespace character.
943 */997 */
944inline char const* trim_start_whitespace( char const *s ) {998inline char const* trim_start_space( char const *s ) {
945 return trim_start( s, whitespace );999 return trim_start( s, whitespace );
946}1000}
9471001
@@ -954,7 +1008,7 @@
954 * @return Returns a pointer to the first character in \a s that is not a1008 * @return Returns a pointer to the first character in \a s that is not a
955 * whitespace character.1009 * whitespace character.
956 */1010 */
957inline char const* trim_start_whitespace( char const *s, size_type *s_len ) {1011inline char const* trim_start_space( char const *s, size_type *s_len ) {
958 return trim_start( s, s_len, whitespace );1012 return trim_start( s, s_len, whitespace );
959}1013}
9601014
@@ -966,7 +1020,7 @@
966 * @return Returns a pointer to the first character in \a s that is not a1020 * @return Returns a pointer to the first character in \a s that is not a
967 * whitespace character.1021 * whitespace character.
968 */1022 */
969inline char const* trim_start_whitespace( char const *s, size_type s_len ) {1023inline char const* trim_start_space( char const *s, size_type s_len ) {
970 return trim_start( s, s_len, whitespace );1024 return trim_start( s, s_len, whitespace );
971}1025}
9721026
@@ -979,7 +1033,10 @@
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).
980 */1034 */
981template<class InputStringType,class OutputStringType> inline1035template<class InputStringType,class OutputStringType> inline
982void trim_start_whitespace( InputStringType const &in, OutputStringType *out ) {1036typename std::enable_if<ZORBA_IS_STRING(InputStringType)
1037 && ZORBA_IS_STRING(OutputStringType),
1038 void>::type
1039trim_start_space( InputStringType const &in, OutputStringType *out ) {
983 trim_start( in, whitespace, out );1040 trim_start( in, whitespace, out );
984}1041}
9851042
@@ -990,9 +1047,10 @@
990 * @param s The string.1047 * @param s The string.
991 */1048 */
992template<class StringType> inline1049template<class StringType> inline
993void trim_start_whitespace( StringType &s ) {1050typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
1051trim_start_space( StringType &s ) {
994 StringType temp;1052 StringType temp;
995 trim_start_whitespace( s, &temp );1053 trim_start_space( s, &temp );
996 s = temp;1054 s = temp;
997}1055}
9981056
@@ -1027,8 +1085,10 @@
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).
1028 */1086 */
1029template<class InputStringType,class OutputStringType>1087template<class InputStringType,class OutputStringType>
1030void trim_end( InputStringType const &in, char const *chars,1088typename std::enable_if<ZORBA_IS_STRING(InputStringType)
1031 OutputStringType *out );1089 && ZORBA_IS_STRING(OutputStringType),
1090 void>::type
1091trim_end( InputStringType const &in, char const *chars, OutputStringType *out );
10321092
1033/**1093/**
1034 * Removes all trailing specified characters.1094 * Removes all trailing specified characters.
@@ -1037,7 +1097,8 @@
1037 * @param s The string.1097 * @param s The string.
1038 */1098 */
1039template<class StringType> inline1099template<class StringType> inline
1040void trim_end( StringType &s, char const *chars ) {1100typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
1101trim_end( StringType &s, char const *chars ) {
1041 StringType temp;1102 StringType temp;
1042 trim_end( s, chars, &temp );1103 trim_end( s, chars, &temp );
1043 s = temp;1104 s = temp;
@@ -1050,7 +1111,7 @@
1050 * @param s_len The length of \a s.1111 * @param s_len The length of \a s.
1051 * @return Returns the new length of \a s.1112 * @return Returns the new length of \a s.
1052 */1113 */
1053inline size_type trim_end_whitespace( char const *s, size_type s_len ) {1114inline size_type trim_end_space( char const *s, size_type s_len ) {
1054 return trim_end( s, s_len, whitespace );1115 return trim_end( s, s_len, whitespace );
1055}1116}
10561117
@@ -1060,7 +1121,7 @@
1060 * @param s The string to trim.1121 * @param s The string to trim.
1061 * @return Returns the new length of \a s.1122 * @return Returns the new length of \a s.
1062 */1123 */
1063inline size_type trim_end_whitespace( char const *s ) {1124inline size_type trim_end_space( char const *s ) {
1064 return trim_end( s, whitespace );1125 return trim_end( s, whitespace );
1065}1126}
10661127
@@ -1073,7 +1134,10 @@
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).
1074 */1135 */
1075template<class InputStringType,class OutputStringType>1136template<class InputStringType,class OutputStringType>
1076void trim_end_whitespace( InputStringType const &in, OutputStringType *out ) {1137typename std::enable_if<ZORBA_IS_STRING(InputStringType)
1138 && ZORBA_IS_STRING(OutputStringType),
1139 void>::type
1140trim_end_space( InputStringType const &in, OutputStringType *out ) {
1077 return trim_end( in, whitespace, out );1141 return trim_end( in, whitespace, out );
1078}1142}
10791143
@@ -1084,12 +1148,13 @@
1084 * @param s The string.1148 * @param s The string.
1085 */1149 */
1086template<class StringType> inline1150template<class StringType> inline
1087void trim_end_whitespace( StringType &s ) {1151typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
1152trim_end_space( StringType &s ) {
1088 trim_end( s, whitespace );1153 trim_end( s, whitespace );
1089}1154}
10901155
1091/**1156/**
1092 * Removed sll leading and trailing whitespace.1157 * Removes all leading and trailing whitespace.
1093 *1158 *
1094 * @param s The input C string.1159 * @param s The input C string.
1095 * @param s_len A pointer to the length of \a s. It is updated with the new1160 * @param s_len A pointer to the length of \a s. It is updated with the new
@@ -1097,9 +1162,9 @@
1097 * @return Returns a pointer to the first character in \a s that is not1162 * @return Returns a pointer to the first character in \a s that is not
1098 * whitespace.1163 * whitespace.
1099 */1164 */
1100inline char const* trim_whitespace( char const *s, size_type *s_len ) {1165inline char const* trim_space( char const *s, size_type *s_len ) {
1101 s = trim_start_whitespace( s, s_len );1166 s = trim_start_space( s, s_len );
1102 *s_len = trim_end_whitespace( s, *s_len );1167 *s_len = trim_end_space( s, *s_len );
1103 return s;1168 return s;
1104}1169}
11051170
@@ -1112,7 +1177,10 @@
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).
1113 */1178 */
1114template<class InputStringType,class OutputStringType> inline1179template<class InputStringType,class OutputStringType> inline
1115void trim_whitespace( InputStringType const &in, OutputStringType *out ) {1180typename std::enable_if<ZORBA_IS_STRING(InputStringType)
1181 && ZORBA_IS_STRING(OutputStringType),
1182 void>::type
1183trim_space( InputStringType const &in, OutputStringType *out ) {
1116 trim( in, whitespace, out );1184 trim( in, whitespace, out );
1117}1185}
11181186
@@ -1123,9 +1191,10 @@
1123 * @param s The string.1191 * @param s The string.
1124 */1192 */
1125template<class StringType> inline1193template<class StringType> inline
1126void trim_whitespace( StringType &s ) {1194typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
1195trim_space( StringType &s ) {
1127 StringType temp;1196 StringType temp;
1128 trim_whitespace( s, &temp );1197 trim_space( s, &temp );
1129 s = temp;1198 s = temp;
1130}1199}
11311200
@@ -1138,10 +1207,10 @@
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.
1139 * On return, \a pos is updated with the position of the 1st non-whitespace1208 * On return, \a pos is updated with the position of the 1st non-whitespace
1140 * char.1209 * char.
1141 * @deprecated Use trim_start_whitespace() instead.1210 * @deprecated Use trim_start_space() instead.
1142 */1211 */
1143inline void skip_whitespace( char const *s, size_type s_len, size_type *pos ) {1212inline void skip_space( char const *s, size_type s_len, size_type *pos ) {
1144 *pos = trim_start_whitespace( s + *pos, s_len - *pos ) - s;1213 *pos = trim_start_space( s + *pos, s_len - *pos ) - s;
1145}1214}
11461215
1147/**1216/**
@@ -1155,11 +1224,11 @@
1155 * char.1224 * char.
1156 */1225 */
1157template<class StringType> inline1226template<class StringType> inline
1158void skip_whitespace( StringType const &s,1227typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
1159 typename StringType::const_iterator *i ) {1228skip_space( StringType const &s, typename StringType::const_iterator *i ) {
1160 typename StringType::difference_type const d = *i - s.begin();1229 typename StringType::difference_type const d = *i - s.begin();
1161 char const *const sd = s.data() + d;1230 char const *const sd = s.data() + d;
1162 std::advance( *i, trim_start_whitespace( sd, s.size() - d ) - sd );1231 std::advance( *i, trim_start_space( sd, s.size() - d ) - sd );
1163}1232}
11641233
1165////////// Miscellaneous //////////////////////////////////////////////////////1234////////// Miscellaneous //////////////////////////////////////////////////////
@@ -1174,8 +1243,8 @@
1174 * @return Returns \c *s.1243 * @return Returns \c *s.
1175 */1244 */
1176template<class StringType> inline1245template<class StringType> inline
1177StringType& left_pad( StringType *s, typename StringType::size_type width,1246typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
1178 char c ) {1247left_pad( StringType *s, typename StringType::size_type width, char c ) {
1179 typedef typename StringType::size_type size_type;1248 typedef typename StringType::size_type size_type;
1180 if ( s->size() < width )1249 if ( s->size() < width )
1181 s->insert( static_cast<size_type>( 0 ), width - s->size(), c );1250 s->insert( static_cast<size_type>( 0 ), width - s->size(), c );
@@ -1192,8 +1261,8 @@
1192 * @return Returns \c *s.1261 * @return Returns \c *s.
1193 */1262 */
1194template<class StringType> inline1263template<class StringType> inline
1195StringType& right_pad( StringType *s, typename StringType::size_type width,1264typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
1196 char c ) {1265right_pad( StringType *s, typename StringType::size_type width, char c ) {
1197 if ( s->size() < width )1266 if ( s->size() < width )
1198 s->append( width - s->size(), c );1267 s->append( width - s->size(), c );
1199 return *s;1268 return *s;
@@ -1222,7 +1291,10 @@
1222 * @param out The output string.1291 * @param out The output string.
1223 */1292 */
1224template<class InputStringType,class OutputStringType> inline1293template<class InputStringType,class OutputStringType> inline
1225void reverse( InputStringType const &in, OutputStringType *out ) {1294typename std::enable_if<ZORBA_IS_STRING(InputStringType)
1295 && ZORBA_IS_STRING(OutputStringType),
1296 void>::type
1297reverse( InputStringType const &in, OutputStringType *out ) {
1226 std::reverse_copy( in.begin(), in.end(), std::back_inserter( *out ) );1298 std::reverse_copy( in.begin(), in.end(), std::back_inserter( *out ) );
1227}1299}
12281300
12291301
=== modified file 'src/util/ascii_util.tcc'
--- src/util/ascii_util.tcc 2013-05-06 22:57:08 +0000
+++ src/util/ascii_util.tcc 2013-05-09 00:49:28 +0000
@@ -36,7 +36,10 @@
36///////////////////////////////////////////////////////////////////////////////36///////////////////////////////////////////////////////////////////////////////
3737
38template<class InputStringType,class OutputStringType>38template<class InputStringType,class OutputStringType>
39void normalize_whitespace( InputStringType const &in, OutputStringType *out ) {39typename std::enable_if<ZORBA_IS_STRING(InputStringType)
40 && ZORBA_IS_STRING(OutputStringType),
41 void>::type
42normalize_space( InputStringType const &in, OutputStringType *out ) {
40 typedef typename InputStringType::const_iterator const_iterator;43 typedef typename InputStringType::const_iterator const_iterator;
41 const_iterator i( in.begin() );44 const_iterator i( in.begin() );
42 const_iterator const j( in.end() );45 const_iterator const j( in.end() );
@@ -56,14 +59,16 @@
56}59}
5760
58template<class StringType>61template<class StringType>
59void remove_not_chars( StringType &s, char const *keep_chars ) {62typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
63remove_not_chars( StringType &s, char const *keep_chars ) {
60 typename StringType::size_type pos = 0;64 typename StringType::size_type pos = 0;
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 )
62 s.erase( pos, 1 );66 s.erase( pos, 1 );
63}67}
6468
65template<class StringType>69template<class StringType>
66bool replace_all( StringType &s, char from, char to ) {70typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
71replace_all( StringType &s, char from, char to ) {
67 bool replaced_any = false;72 bool replaced_any = false;
68 for ( typename StringType::size_type pos = 0; pos < s.size(); ++pos ) {73 for ( typename StringType::size_type pos = 0; pos < s.size(); ++pos ) {
69 if ( (pos = s.find( from, pos )) == StringType::npos )74 if ( (pos = s.find( from, pos )) == StringType::npos )
@@ -75,9 +80,10 @@
75}80}
7681
77template<class StringType>82template<class StringType>
78bool replace_all( StringType &s,83typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
79 char const *from, typename StringType::size_type from_len,84replace_all( StringType &s,
80 char const *to, typename StringType::size_type to_len ) {85 char const *from, typename StringType::size_type from_len,
86 char const *to, typename StringType::size_type to_len ) {
81 bool replaced_any = false;87 bool replaced_any = false;
82 for ( typename StringType::size_type pos = 0;88 for ( typename StringType::size_type pos = 0;
83 pos + from_len <= s.size(); pos += to_len ) {89 pos + from_len <= s.size(); pos += to_len ) {
@@ -90,8 +96,10 @@
90}96}
9197
92template<class InputStringType,class OutputStringType>98template<class InputStringType,class OutputStringType>
93void trim( InputStringType const &in, char const *chars,99typename std::enable_if<ZORBA_IS_STRING(InputStringType)
94 OutputStringType *out ) {100 && ZORBA_IS_STRING(OutputStringType),
101 void>::type
102trim( InputStringType const &in, char const *chars, OutputStringType *out ) {
95 *out = in;103 *out = in;
96 typename OutputStringType::size_type pos = out->find_first_not_of( chars );104 typename OutputStringType::size_type pos = out->find_first_not_of( chars );
97 out->erase( 0, pos );105 out->erase( 0, pos );
@@ -101,52 +109,28 @@
101}109}
102110
103template<class InputStringType,class OutputStringType>111template<class InputStringType,class OutputStringType>
104void trim_start( InputStringType const &in, char const *chars,112typename std::enable_if<ZORBA_IS_STRING(InputStringType)
105 OutputStringType *out ) {113 && ZORBA_IS_STRING(OutputStringType),
114 void>::type
115trim_start( InputStringType const &in, char const *chars,
116 OutputStringType *out ) {
106 *out = in;117 *out = in;
107 typename OutputStringType::size_type pos = out->find_first_not_of( chars );118 typename OutputStringType::size_type pos = out->find_first_not_of( chars );
108 out->erase( 0, pos );119 out->erase( 0, pos );
109}120}
110121
111template<class InputStringType,class OutputStringType>122template<class InputStringType,class OutputStringType>
112void trim_end( InputStringType const &in, char const *chars,123typename std::enable_if<ZORBA_IS_STRING(InputStringType)
113 OutputStringType *out ) {124 && ZORBA_IS_STRING(OutputStringType),
125 void>::type
126trim_end( InputStringType const &in, char const *chars,
127 OutputStringType *out ) {
114 *out = in;128 *out = in;
115 typename OutputStringType::size_type pos = out->find_last_not_of( chars );129 typename OutputStringType::size_type pos = out->find_last_not_of( chars );
116 if ( pos != OutputStringType::npos && ++pos < out->size() )130 if ( pos != OutputStringType::npos && ++pos < out->size() )
117 out->erase( pos );131 out->erase( pos );
118}132}
119133
120template<class InputStringType,class OutputStringType>
121void uri_decode( InputStringType const &in, OutputStringType *out ) {
122 extern signed char const hex2dec[];
123
124 typedef typename InputStringType::const_iterator const_iterator;
125 const_iterator i( in.begin() );
126 const_iterator const j( in.end() );
127
128 out->reserve( out->size() + in.size() );
129 for ( ; i != j; ++i ) {
130 char c = *i;
131 if ( c == '%' ) {
132 const_iterator k = i;
133 do {
134 if ( ++k == j )
135 break;
136 signed char const c1 = hex2dec[ static_cast<unsigned>( *k ) & 0xFF ];
137 if ( c1 == -1 || ++k == j )
138 break;
139 signed char const c2 = hex2dec[ static_cast<unsigned>( *k ) & 0xFF ];
140 if ( c2 == -1 )
141 break;
142 c = static_cast<char>( (c1 << 4) | c2 );
143 i = k;
144 } while ( false );
145 }
146 out->push_back( c );
147 }
148}
149
150///////////////////////////////////////////////////////////////////////////////134///////////////////////////////////////////////////////////////////////////////
151135
152} // namespace ascii136} // namespace ascii
153137
=== modified file 'src/util/base64_util.h'
--- src/util/base64_util.h 2013-04-16 22:12:03 +0000
+++ src/util/base64_util.h 2013-05-09 00:49:28 +0000
@@ -18,11 +18,14 @@
18#ifndef ZORBA_BASE64_UTIL_H18#ifndef ZORBA_BASE64_UTIL_H
19#define ZORBA_BASE64_UTIL_H19#define ZORBA_BASE64_UTIL_H
2020
21// standard
21#include <iostream>22#include <iostream>
22#include <stdexcept>23#include <stdexcept>
23#include <sys/types.h> /* for size_t */24#include <sys/types.h> /* for size_t */
24#include <vector>25#include <vector>
2526
27// Zorba
28#include <zorba/internal/ztd.h>
26#include "cxx_util.h"29#include "cxx_util.h"
27#include "stream_util.h"30#include "stream_util.h"
2831
@@ -132,8 +135,9 @@
132 * invalid byte is encountered.135 * invalid byte is encountered.
133 */136 */
134template<class ToStringType>137template<class ToStringType>
135size_type decode( char const *from, size_type from_len, ToStringType *to,138typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
136 int options = dopt_none ) {139decode( char const *from, size_type from_len, ToStringType *to,
140 int options = dopt_none ) {
137 size_type decoded = 0;141 size_type decoded = 0;
138 if ( from_len ) {142 if ( from_len ) {
139 typename ToStringType::size_type const orig_size = to->size();143 typename ToStringType::size_type const orig_size = to->size();
@@ -175,8 +179,8 @@
175 * invalid byte is encountered.179 * invalid byte is encountered.
176 */180 */
177template<class ToStringType>181template<class ToStringType>
178size_type decode( std::istream &from, ToStringType *to,182typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
179 int options = dopt_none ) {183decode( std::istream &from, ToStringType *to, int options = dopt_none ) {
180 bool const ignore_ws = !!(options & dopt_ignore_ws);184 bool const ignore_ws = !!(options & dopt_ignore_ws);
181 size_type total_decoded = 0;185 size_type total_decoded = 0;
182 while ( !from.eof() ) {186 while ( !from.eof() ) {
@@ -279,7 +283,8 @@
279 * @return Returns the number of encoded bytes.283 * @return Returns the number of encoded bytes.
280 */284 */
281template<class ToStringType>285template<class ToStringType>
282size_type encode( char const *from, size_type from_len, ToStringType *to ) {286typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
287encode( char const *from, size_type from_len, ToStringType *to ) {
283 size_type encoded = 0;288 size_type encoded = 0;
284 if ( from_len ) {289 if ( from_len ) {
285 typename ToStringType::size_type const orig_size = to->size();290 typename ToStringType::size_type const orig_size = to->size();
@@ -307,7 +312,8 @@
307 * @return Returns the number of encoded bytes.312 * @return Returns the number of encoded bytes.
308 */313 */
309template<class ToStringType>314template<class ToStringType>
310size_type encode( std::istream &from, ToStringType *to ) {315typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
316encode( std::istream &from, ToStringType *to ) {
311 size_type total_encoded = 0;317 size_type total_encoded = 0;
312 while ( !from.eof() ) {318 while ( !from.eof() ) {
313 char from_buf[ 1024 * 3 ], to_buf[ 1024 * 4 ];319 char from_buf[ 1024 * 3 ], to_buf[ 1024 * 4 ];
314320
=== modified file 'src/util/error_util.h'
--- src/util/error_util.h 2013-02-07 17:24:36 +0000
+++ src/util/error_util.h 2013-05-09 00:49:28 +0000
@@ -151,10 +151,7 @@
151 * @return Returns said error string.151 * @return Returns said error string.
152 */152 */
153template<class StringType> inline153template<class StringType> inline
154typename std::enable_if<154typename std::enable_if<ZORBA_HAS_C_STR(StringType),std::string>::type
155 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
156 std::string
157>::type
158get_err_string( StringType const &function, code_type code = get_err_code() ) {155get_err_string( StringType const &function, code_type code = get_err_code() ) {
159 return get_err_string( function.c_str(), code );156 return get_err_string( function.c_str(), code );
160}157}
161158
=== modified file 'src/util/fs_util.h'
--- src/util/fs_util.h 2013-03-06 01:45:25 +0000
+++ src/util/fs_util.h 2013-05-09 00:49:28 +0000
@@ -123,9 +123,7 @@
123 * @param path The full path of the directory to change to.123 * @param path The full path of the directory to change to.
124 */124 */
125template<class PathStringType> inline125template<class PathStringType> inline
126typename std::enable_if<ztd::has_c_str<PathStringType,126typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
127 char const* (PathStringType::*)() const>::value,
128 void>::type
129chdir( PathStringType const &path ) {127chdir( PathStringType const &path ) {
130 chdir( path.c_str() );128 chdir( path.c_str() );
131}129}
@@ -158,9 +156,7 @@
158 * @throws fs::exception if the creation fails.156 * @throws fs::exception if the creation fails.
159 */157 */
160template<class PathStringType> inline158template<class PathStringType> inline
161typename std::enable_if<ztd::has_c_str<PathStringType,159typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
162 char const* (PathStringType::*)() const>::value,
163 void>::type
164mkdir( PathStringType const &path ) {160mkdir( PathStringType const &path ) {
165 mkdir( path.c_str() );161 mkdir( path.c_str() );
166}162}
@@ -191,10 +187,8 @@
191 */187 */
192 template<class PathStringType>188 template<class PathStringType>
193 iterator( PathStringType const &path,189 iterator( PathStringType const &path,
194 typename std::enable_if<190 typename std::enable_if<ZORBA_HAS_C_STR(PathStringType)
195 ztd::has_c_str<PathStringType,191 >::type* = 0 ) : dir_path_( path.c_str() ) {
196 char const* (PathStringType::*)() const>::value
197 >::type* = 0 ) : dir_path_( path.c_str() ) {
198 ctor_impl();192 ctor_impl();
199 }193 }
200194
@@ -292,9 +286,7 @@
292 * @throws fs::exception if the creation failed.286 * @throws fs::exception if the creation failed.
293 */287 */
294template<class PathStringType> inline288template<class PathStringType> inline
295typename std::enable_if<ztd::has_c_str<PathStringType,289typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
296 char const* (PathStringType::*)() const>::value,
297 void>::type
298create( PathStringType const &path ) {290create( PathStringType const &path ) {
299 create( path.c_str() );291 create( path.c_str() );
300}292}
@@ -321,9 +313,7 @@
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.
322 */314 */
323template<class PathStringType> inline315template<class PathStringType> inline
324typename std::enable_if<ztd::has_c_str<PathStringType,316typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),bool>::type
325 char const* (PathStringType::*)() const>::value,
326 bool>::type
327remove( PathStringType const &path ) {317remove( PathStringType const &path ) {
328 return remove( path.c_str() );318 return remove( path.c_str() );
329}319}
@@ -510,9 +500,7 @@
510 * then returns \a path.500 * then returns \a path.
511 */501 */
512template<class PathStringType> inline502template<class PathStringType> inline
513typename std::enable_if<ztd::has_c_str<PathStringType,503typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),char const*>::type
514 char const* (PathStringType::*)() const>::value,
515 char const*>::type
516base_name( PathStringType const &path ) {504base_name( PathStringType const &path ) {
517 return base_name( path.c_str() );505 return base_name( path.c_str() );
518}506}
@@ -546,9 +534,7 @@
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.
547 */535 */
548template<class PathStringType> inline536template<class PathStringType> inline
549typename std::enable_if<ztd::has_c_str<PathStringType,537typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),type>::type
550 char const* (PathStringType::*)() const>::value,
551 type>::type
552get_type( PathStringType const &path, bool follow_symlink = true,538get_type( PathStringType const &path, bool follow_symlink = true,
553 size_type *size = nullptr ) {539 size_type *size = nullptr ) {
554 return get_type( path.c_str(), follow_symlink, size );540 return get_type( path.c_str(), follow_symlink, size );
@@ -580,9 +566,7 @@
580 * @return Returns \c true only if the path is absolute.566 * @return Returns \c true only if the path is absolute.
581 */567 */
582template<class PathStringType> inline568template<class PathStringType> inline
583typename std::enable_if<ztd::has_c_str<PathStringType,569typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),bool>::type
584 char const* (PathStringType::*)() const>::value,
585 bool>::type
586is_absolute( PathStringType const &path ) {570is_absolute( PathStringType const &path ) {
587 return is_absolute( path.c_str() );571 return is_absolute( path.c_str() );
588}572}
@@ -609,9 +593,7 @@
609 * @throws fs::exception if the rename fails.593 * @throws fs::exception if the rename fails.
610 */594 */
611template<class FromStringType> inline595template<class FromStringType> inline
612typename std::enable_if<ztd::has_c_str<FromStringType,596typename std::enable_if<ZORBA_HAS_C_STR(FromStringType),void>::type
613 char const* (FromStringType::*)() const>::value,
614 void>::type
615rename( FromStringType const &from, char const *to ) {597rename( FromStringType const &from, char const *to ) {
616 rename( from.c_str(), to );598 rename( from.c_str(), to );
617}599}
@@ -625,9 +607,7 @@
625 * @throws fs::exception if the rename fails.607 * @throws fs::exception if the rename fails.
626 */608 */
627template<class ToStringType> inline609template<class ToStringType> inline
628typename std::enable_if<ztd::has_c_str<ToStringType,610typename std::enable_if<ZORBA_HAS_C_STR(ToStringType),void>::type
629 char const* (ToStringType::*)() const>::value,
630 void>::type
631rename( char const *from, ToStringType const &to ) {611rename( char const *from, ToStringType const &to ) {
632 rename( from, to.c_str() );612 rename( from, to.c_str() );
633}613}
@@ -642,10 +622,8 @@
642 * @throws fs::exception if the rename fails.622 * @throws fs::exception if the rename fails.
643 */623 */
644template<class FromStringType,class ToStringType> inline624template<class FromStringType,class ToStringType> inline
645typename std::enable_if<ztd::has_c_str<FromStringType,625typename std::enable_if<ZORBA_HAS_C_STR(FromStringType)
646 char const* (FromStringType::*)() const>::value626 && ZORBA_HAS_C_STR(ToStringType),
647 && ztd::has_c_str<ToStringType,
648 char const* (ToStringType::*)() const>::value,
649 void>::type627 void>::type
650rename( FromStringType const &from, ToStringType const &to ) {628rename( FromStringType const &from, ToStringType const &to ) {
651 rename( from.c_str(), to.c_str() );629 rename( from.c_str(), to.c_str() );
@@ -675,9 +653,7 @@
675 * @throws XQueryException err::XPTY0004 for malformed paths.653 * @throws XQueryException err::XPTY0004 for malformed paths.
676 */654 */
677template<class PathStringType> inline655template<class PathStringType> inline
678typename std::enable_if<ztd::has_c_str<PathStringType,656typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),zstring>::type
679 char const* (PathStringType::*)() const>::value,
680 zstring>::type
681get_normalized_path( PathStringType const &path,657get_normalized_path( PathStringType const &path,
682 PathStringType const &base = "" ) {658 PathStringType const &base = "" ) {
683 return get_normalized_path( path.c_str(), base.c_str() );659 return get_normalized_path( path.c_str(), base.c_str() );
@@ -693,9 +669,7 @@
693 * @throws XQueryException err::XPTY0004 for malformed paths.669 * @throws XQueryException err::XPTY0004 for malformed paths.
694 */670 */
695template<class PathStringType> inline671template<class PathStringType> inline
696typename std::enable_if<ztd::has_c_str<PathStringType,672typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
697 char const* (PathStringType::*)() const>::value,
698 void>::type
699normalize_path( PathStringType &path, PathStringType const &base = "" ) {673normalize_path( PathStringType &path, PathStringType const &base = "" ) {
700 path = get_normalized_path( path, base );674 path = get_normalized_path( path, base );
701}675}
@@ -711,9 +685,7 @@
711 * @param path2 The path to append.685 * @param path2 The path to append.
712 */686 */
713template<class PathStringType1> inline687template<class PathStringType1> inline
714typename std::enable_if<ztd::has_c_str<PathStringType1,688typename std::enable_if<ZORBA_IS_STRING(PathStringType1),void>::type
715 char const* (PathStringType1::*)() const>::value,
716 void>::type
717append( PathStringType1 &path1, char const *path2 ) {689append( PathStringType1 &path1, char const *path2 ) {
718 if ( !ascii::ends_with( path1, dir_separator ) )690 if ( !ascii::ends_with( path1, dir_separator ) )
719 path1 += dir_separator;691 path1 += dir_separator;
@@ -729,10 +701,8 @@
729 * @param path2 The path to append.701 * @param path2 The path to append.
730 */702 */
731template<class PathStringType1,class PathStringType2> inline703template<class PathStringType1,class PathStringType2> inline
732typename std::enable_if<ztd::has_c_str<PathStringType1,704typename std::enable_if<ZORBA_IS_STRING(PathStringType1)
733 char const* (PathStringType1::*)() const>::value705 && ZORBA_HAS_C_STR(PathStringType2),
734 && ztd::has_c_str<PathStringType2,
735 char const* (PathStringType2::*)() const>::value,
736 void>::type706 void>::type
737append( PathStringType1 &path1, PathStringType2 const &path2 ) {707append( PathStringType1 &path1, PathStringType2 const &path2 ) {
738 append( path1, path2.c_str() );708 append( path1, path2.c_str() );
@@ -745,9 +715,7 @@
745 * @param path The path to make absolute.715 * @param path The path to make absolute.
746 */716 */
747template<class PathStringType> inline717template<class PathStringType> inline
748typename std::enable_if<ztd::has_c_str<PathStringType,718typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
749 char const* (PathStringType::*)() const>::value,
750 void>::type
751make_absolute( PathStringType &path ) {719make_absolute( PathStringType &path ) {
752 if ( !is_absolute( path ) ) {720 if ( !is_absolute( path ) ) {
753#ifndef WIN32721#ifndef WIN32
@@ -783,9 +751,7 @@
783 * @throws fs::exception if the operation fails.751 * @throws fs::exception if the operation fails.
784 */752 */
785template<class PathStringType> inline753template<class PathStringType> inline
786typename std::enable_if<ztd::has_c_str<PathStringType,754typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
787 char const* (PathStringType::*)() const>::value,
788 void>::type
789get_temp_file( PathStringType *path ) {755get_temp_file( PathStringType *path ) {
790 char path_buf[ MAX_PATH ];756 char path_buf[ MAX_PATH ];
791 get_temp_file( path_buf );757 get_temp_file( path_buf );
792758
=== modified file 'src/util/hexbinary_util.cpp'
--- src/util/hexbinary_util.cpp 2013-04-16 22:12:03 +0000
+++ src/util/hexbinary_util.cpp 2013-05-09 00:49:28 +0000
@@ -75,7 +75,7 @@
75 int options ) {75 int options ) {
76 bool const ignore_ws = !!(options & dopt_ignore_ws);76 bool const ignore_ws = !!(options & dopt_ignore_ws);
77 if ( ignore_ws )77 if ( ignore_ws )
78 from = ascii::trim_whitespace( from, &from_len );78 from = ascii::trim_space( from, &from_len );
79 if ( from_len % 2 )79 if ( from_len % 2 )
80 throw invalid_argument( "HexBinary length is not a multiple of 2" );80 throw invalid_argument( "HexBinary length is not a multiple of 2" );
8181
@@ -107,7 +107,7 @@
107 std::vector<char> *to, int options ) {107 std::vector<char> *to, int options ) {
108 bool const ignore_ws = !!(options & dopt_ignore_ws);108 bool const ignore_ws = !!(options & dopt_ignore_ws);
109 if ( ignore_ws )109 if ( ignore_ws )
110 from = ascii::trim_whitespace( from, &from_len );110 from = ascii::trim_space( from, &from_len );
111 if ( from_len % 2 )111 if ( from_len % 2 )
112 throw invalid_argument( "HexBinary length is not a multiple of 2" );112 throw invalid_argument( "HexBinary length is not a multiple of 2" );
113 size_type decoded = 0;113 size_type decoded = 0;
114114
=== modified file 'src/util/hexbinary_util.h'
--- src/util/hexbinary_util.h 2013-04-16 22:12:03 +0000
+++ src/util/hexbinary_util.h 2013-05-09 00:49:28 +0000
@@ -128,8 +128,9 @@
128 * @throws hexbinary::exception if an invalid byte is encountered.128 * @throws hexbinary::exception if an invalid byte is encountered.
129 */129 */
130template<class ToStringType>130template<class ToStringType>
131size_type decode( char const *from, size_type from_len, ToStringType *to,131typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
132 int options = dopt_none ) {132decode( char const *from, size_type from_len, ToStringType *to,
133 int options = dopt_none ) {
133 size_type decoded = 0;134 size_type decoded = 0;
134 if ( from_len ) {135 if ( from_len ) {
135 typename ToStringType::size_type const orig_size = to->size();136 typename ToStringType::size_type const orig_size = to->size();
@@ -168,7 +169,8 @@
168 * @throws hexbinary::exception if an invalid byte is encountered.169 * @throws hexbinary::exception if an invalid byte is encountered.
169 */170 */
170template<class ToStringType>171template<class ToStringType>
171size_type decode( std::istream &from, ToStringType *to,172typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
173decode( std::istream &from, ToStringType *to,
172 int options = dopt_none ) {174 int options = dopt_none ) {
173 bool const ignore_ws = !!(options & dopt_ignore_ws);175 bool const ignore_ws = !!(options & dopt_ignore_ws);
174 size_type total_decoded = 0;176 size_type total_decoded = 0;
@@ -269,7 +271,8 @@
269 * @return Returns the number of encoded bytes.271 * @return Returns the number of encoded bytes.
270 */272 */
271template<class ToStringType>273template<class ToStringType>
272size_type encode( char const *from, size_type from_len, ToStringType *to ) {274typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
275encode( char const *from, size_type from_len, ToStringType *to ) {
273 size_type encoded = 0;276 size_type encoded = 0;
274 if ( from_len ) {277 if ( from_len ) {
275 typename ToStringType::size_type const orig_size = to->size();278 typename ToStringType::size_type const orig_size = to->size();
@@ -296,7 +299,8 @@
296 * @return Returns the number of encoded bytes.299 * @return Returns the number of encoded bytes.
297 */300 */
298template<class ToStringType>301template<class ToStringType>
299size_type encode( std::istream &from, ToStringType *to ) {302typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
303encode( std::istream &from, ToStringType *to ) {
300 size_type total_encoded = 0;304 size_type total_encoded = 0;
301 while ( !from.eof() ) {305 while ( !from.eof() ) {
302 char from_buf[ 1024 * 2 ], to_buf[ 1024 ];306 char from_buf[ 1024 * 2 ], to_buf[ 1024 ];
303307
=== modified file 'src/util/icu_streambuf.cpp'
--- src/util/icu_streambuf.cpp 2013-04-16 22:12:03 +0000
+++ src/util/icu_streambuf.cpp 2013-05-09 00:49:28 +0000
@@ -110,7 +110,7 @@
110 // "ASCII", so check for "US-ASCII" ourselves.110 // "ASCII", so check for "US-ASCII" ourselves.
111 //111 //
112 zstring charset( cc_charset );112 zstring charset( cc_charset );
113 ascii::trim_whitespace( charset );113 ascii::trim_space( charset );
114 ascii::to_upper( charset );114 ascii::to_upper( charset );
115 if ( charset == "US-ASCII" )115 if ( charset == "US-ASCII" )
116 cc_charset += 3; // skip "US-"116 cc_charset += 3; // skip "US-"
117117
=== modified file 'src/util/json_util.h'
--- src/util/json_util.h 2012-07-25 23:20:47 +0000
+++ src/util/json_util.h 2013-05-09 00:49:28 +0000
@@ -52,9 +52,7 @@
52 * @return Returns \a os.52 * @return Returns \a os.
53 */53 */
54template<class StringType> inline54template<class StringType> inline
55typename std::enable_if<ztd::has_c_str<StringType,55typename std::enable_if<ZORBA_HAS_C_STR(StringType),std::ostream&>::type
56 char const* (StringType::*)() const>::value,
57 std::ostream&>::type
58serialize( std::ostream &os, StringType const &s ) {56serialize( std::ostream &os, StringType const &s ) {
59 return serialize( os, s.c_str() );57 return serialize( os, s.c_str() );
60}58}
6159
=== modified file 'src/util/passthru_streambuf.cpp'
--- src/util/passthru_streambuf.cpp 2013-04-12 04:34:41 +0000
+++ src/util/passthru_streambuf.cpp 2013-05-09 00:49:28 +0000
@@ -44,7 +44,7 @@
44 if ( !*cc_charset )44 if ( !*cc_charset )
45 throw invalid_argument( "empty charset" );45 throw invalid_argument( "empty charset" );
46 zstring charset( cc_charset );46 zstring charset( cc_charset );
47 ascii::trim_whitespace( charset );47 ascii::trim_space( charset );
48 ascii::to_upper( charset );48 ascii::to_upper( charset );
49 return charset != "ASCII"49 return charset != "ASCII"
50 && charset != "US-ASCII"50 && charset != "US-ASCII"
5151
=== modified file 'src/util/stl_util.h'
--- src/util/stl_util.h 2013-05-08 20:14:47 +0000
+++ src/util/stl_util.h 2013-05-09 00:49:28 +0000
@@ -80,7 +80,7 @@
80 }80 }
8181
82protected:82protected:
83 back_insert_iterator_base( ContainerType &c ) : container( &c ) {83 back_insert_iterator_base( ContainerType *c ) : container( c ) {
84 }84 }
8585
86 /**86 /**
8787
=== modified file 'src/util/stream_util.cpp'
--- src/util/stream_util.cpp 2013-04-16 22:12:03 +0000
+++ src/util/stream_util.cpp 2013-05-09 00:49:28 +0000
@@ -62,7 +62,7 @@
62 while ( buf < buf_end ) {62 while ( buf < buf_end ) {
63 is.read( buf, n );63 is.read( buf, n );
64 if ( streamsize read = is.gcount() ) {64 if ( streamsize read = is.gcount() ) {
65 read = ascii::remove_whitespace(65 read = ascii::remove_space(
66 buf, static_cast<ascii::size_type>( read )66 buf, static_cast<ascii::size_type>( read )
67 );67 );
68 buf += read, n -= read;68 buf += read, n -= read;
6969
=== modified file 'src/util/string_util.cpp'
--- src/util/string_util.cpp 2013-04-16 03:48:46 +0000
+++ src/util/string_util.cpp 2013-05-09 00:49:28 +0000
@@ -131,7 +131,7 @@
131 //131 //
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).
133 //133 //
134 buf = ascii::trim_start_whitespace( buf );134 buf = ascii::trim_start_space( buf );
135 bool const minus = *buf == '-';135 bool const minus = *buf == '-';
136136
137 unsigned long long const result = std::strtoull( buf, (char**)last, 10 );137 unsigned long long const result = std::strtoull( buf, (char**)last, 10 );
@@ -153,7 +153,7 @@
153long long atoll( char const *buf, char const *end, char const **last ) {153long long atoll( char const *buf, char const *end, char const **last ) {
154 aton_context const ctx( last );154 aton_context const ctx( last );
155 long long n = 0;155 long long n = 0;
156 char const *s0 = ascii::trim_start_whitespace( buf, end - buf );156 char const *s0 = ascii::trim_start_space( buf, end - buf );
157 char const *s = s0;157 char const *s = s0;
158158
159 if ( s < end ) {159 if ( s < end ) {
@@ -190,7 +190,7 @@
190 char const **last ) {190 char const **last ) {
191 aton_context const ctx( last );191 aton_context const ctx( last );
192 unsigned long long n = 0;192 unsigned long long n = 0;
193 char const *s0 = ascii::trim_start_whitespace( buf, end - buf );193 char const *s0 = ascii::trim_start_space( buf, end - buf );
194 char const *s = s0;194 char const *s = s0;
195195
196 if ( s < end ) {196 if ( s < end ) {
197197
=== modified file 'src/util/string_util.h'
--- src/util/string_util.h 2013-04-16 02:30:37 +0000
+++ src/util/string_util.h 2013-05-09 00:49:28 +0000
@@ -171,8 +171,9 @@
171 * @return Returns \c true only if \a s1 \c == \a s2.171 * @return Returns \c true only if \a s1 \c == \a s2.
172 */172 */
173template<class StringType> inline173template<class StringType> inline
174bool equals( StringType const &s1, char const *s2,174typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
175 typename StringType::size_type s2_n ) {175equals( StringType const &s1, char const *s2,
176 typename StringType::size_type s2_n ) {
176 typedef typename StringType::traits_type traits_type;177 typedef typename StringType::traits_type traits_type;
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;
178}179}
@@ -186,8 +187,9 @@
186 * @return Returns \c true only if \a s1 \c == \a s2.187 * @return Returns \c true only if \a s1 \c == \a s2.
187 */188 */
188template<class StringType> inline189template<class StringType> inline
189bool equals( char const *s1, typename StringType::size_type s1_n,190typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
190 StringType const &s2 ) {191equals( char const *s1, typename StringType::size_type s1_n,
192 StringType const &s2 ) {
191 typedef typename StringType::traits_type traits_type;193 typedef typename StringType::traits_type traits_type;
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;
193}195}
@@ -215,8 +217,11 @@
215 * present in \a in).217 * present in \a in).
216 */218 */
217template<class OutputStringType1,class OutputStringType2>219template<class OutputStringType1,class OutputStringType2>
218bool split( char const *in, char delim, OutputStringType1 *out1,220typename std::enable_if<ZORBA_IS_STRING(OutputStringType1)
219 OutputStringType2 *out2 ) {221 && ZORBA_IS_STRING(OutputStringType2),
222 bool>::type
223split( char const *in, char delim, OutputStringType1 *out1,
224 OutputStringType2 *out2 ) {
220 if ( char const *const pos = std::strchr( in, delim ) ) {225 if ( char const *const pos = std::strchr( in, delim ) ) {
221 if ( out1 )226 if ( out1 )
222 *out1 = OutputStringType1( in, pos - in );227 *out1 = OutputStringType1( in, pos - in );
@@ -229,13 +234,15 @@
229234
230// Allows out1 to be nullptr.235// Allows out1 to be nullptr.
231template<class OutputStringType2> inline236template<class OutputStringType2> inline
232bool split( char const *in, char delim, void*, OutputStringType2 *out2 ) {237typename std::enable_if<ZORBA_IS_STRING(OutputStringType2),bool>::type
238split( char const *in, char delim, void*, OutputStringType2 *out2 ) {
233 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );239 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
234}240}
235241
236// Allows out2 to be nullptr.242// Allows out2 to be nullptr.
237template<class OutputStringType1> inline243template<class OutputStringType1> inline
238bool split( char const *in, char delim, OutputStringType1 *out1, void* ) {244typename std::enable_if<ZORBA_IS_STRING(OutputStringType1),bool>::type
245split( char const *in, char delim, OutputStringType1 *out1, void* ) {
239 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );246 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
240}247}
241248
@@ -255,22 +262,31 @@
255 * present in \a in).262 * present in \a in).
256 */263 */
257template<class InputStringType,class OutputStringType1,class OutputStringType2>264template<class InputStringType,class OutputStringType1,class OutputStringType2>
258inline bool split( InputStringType const &in, char delim,265inline
266typename std::enable_if<ZORBA_IS_STRING(InputStringType)
267 && ZORBA_IS_STRING(OutputStringType1)
268 && ZORBA_IS_STRING(OutputStringType2),
269 bool>::type
270split( InputStringType const &in, char delim,
259 OutputStringType1 *out1, OutputStringType2 *out2 ) {271 OutputStringType1 *out1, OutputStringType2 *out2 ) {
260 return split( in.c_str(), delim, out1, out2 );272 return split( in.c_str(), delim, out1, out2 );
261}273}
262274
263// Allows out1 to be nullptr.275// Allows out1 to be nullptr.
264template<class InputStringType,class OutputStringType2> inline276template<class InputStringType,class OutputStringType2> inline
265bool split( InputStringType const &in, char delim, void*,277typename std::enable_if<ZORBA_IS_STRING(InputStringType)
266 OutputStringType2 *out2 ) {278 && ZORBA_IS_STRING(OutputStringType2),
279 bool>::type
280split( InputStringType const &in, char delim, void*, OutputStringType2 *out2 ) {
267 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );281 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
268}282}
269283
270// Allows out2 to be nullptr.284// Allows out2 to be nullptr.
271template<class InputStringType,class OutputStringType1> inline285template<class InputStringType,class OutputStringType1> inline
272bool split( InputStringType const &in, char delim, OutputStringType1 *out1,286typename std::enable_if<ZORBA_IS_STRING(InputStringType)
273 void* ) {287 && ZORBA_IS_STRING(OutputStringType1),
288 bool>::type
289split( InputStringType const &in, char delim, OutputStringType1 *out1, void* ) {
274 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );290 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
275}291}
276292
@@ -289,8 +305,11 @@
289 * present in \a in).305 * present in \a in).
290 */306 */
291template<class OutputStringType1,class OutputStringType2>307template<class OutputStringType1,class OutputStringType2>
292bool split( char const *in, char const *delim, OutputStringType1 *out1,308typename std::enable_if<ZORBA_IS_STRING(OutputStringType1)
293 OutputStringType2 *out2 ) {309 && ZORBA_IS_STRING(OutputStringType2),
310 bool>::type
311split( char const *in, char const *delim, OutputStringType1 *out1,
312 OutputStringType2 *out2 ) {
294 if ( *delim )313 if ( *delim )
295 if ( char const *const pos = std::strstr( in, delim ) ) {314 if ( char const *const pos = std::strstr( in, delim ) ) {
296 if ( out1 )315 if ( out1 )
@@ -304,15 +323,15 @@
304323
305// Allows out1 to be nullptr.324// Allows out1 to be nullptr.
306template<class OutputStringType2> inline325template<class OutputStringType2> inline
307bool split( char const *in, char const *delim, void*,326typename std::enable_if<ZORBA_IS_STRING(OutputStringType2),bool>::type
308 OutputStringType2 *out2 ) {327split( char const *in, char const *delim, void*, OutputStringType2 *out2 ) {
309 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );328 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
310}329}
311330
312// Allows out2 to be nullptr.331// Allows out2 to be nullptr.
313template<class OutputStringType1> inline332template<class OutputStringType1> inline
314bool split( char const *in, char const *delim, OutputStringType1 *out1,333typename std::enable_if<ZORBA_IS_STRING(OutputStringType1),bool>::type
315 void* ) {334split( char const *in, char const *delim, OutputStringType1 *out1, void* ) {
316 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );335 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
317}336}
318337
@@ -332,22 +351,33 @@
332 * present in \a in).351 * present in \a in).
333 */352 */
334template<class InputStringType,class OutputStringType1,class OutputStringType2>353template<class InputStringType,class OutputStringType1,class OutputStringType2>
335inline bool split( InputStringType const &in, char const *delim,354inline
336 OutputStringType1 *out1, OutputStringType2 *out2 ) {355typename std::enable_if<ZORBA_IS_STRING(InputStringType)
356 && ZORBA_IS_STRING(OutputStringType1)
357 && ZORBA_IS_STRING(OutputStringType2),
358 bool>::type
359split( InputStringType const &in, char const *delim, OutputStringType1 *out1,
360 OutputStringType2 *out2 ) {
337 return split( in.c_str(), delim, out1, out2 );361 return split( in.c_str(), delim, out1, out2 );
338}362}
339363
340// Allows out1 to be nullptr.364// Allows out1 to be nullptr.
341template<class InputStringType,class OutputStringType2> inline365template<class InputStringType,class OutputStringType2> inline
342bool split( InputStringType const &in, char const *delim, void*,366typename std::enable_if<ZORBA_IS_STRING(InputStringType)
367 && ZORBA_IS_STRING(OutputStringType2),
368 bool>::type
369split( InputStringType const &in, char const *delim, void*,
343 OutputStringType2 *out2 ) {370 OutputStringType2 *out2 ) {
344 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );371 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
345}372}
346373
347// Allows out2 to be nullptr.374// Allows out2 to be nullptr.
348template<class InputStringType,class OutputStringType1> inline375template<class InputStringType,class OutputStringType1> inline
349bool split( InputStringType const &in, char const *delim,376typename std::enable_if<ZORBA_IS_STRING(InputStringType)
350 OutputStringType1 *out1, void* ) {377 && ZORBA_IS_STRING(OutputStringType1),
378 bool>::type
379split( InputStringType const &in, char const *delim, OutputStringType1 *out1,
380 void* ) {
351 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );381 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
352}382}
353383
@@ -373,8 +403,13 @@
373 class OutputStringType1,403 class OutputStringType1,
374 class OutputStringType2404 class OutputStringType2
375>405>
376bool split( InputStringType const &in, DelimStringType const &delim,406typename std::enable_if<ZORBA_IS_STRING(InputStringType)
377 OutputStringType1 *out1, OutputStringType2 *out2 ) {407 && ZORBA_IS_STRING(DelimStringType)
408 && ZORBA_IS_STRING(OutputStringType1)
409 && ZORBA_IS_STRING(OutputStringType2),
410 bool>::type
411split( InputStringType const &in, DelimStringType const &delim,
412 OutputStringType1 *out1, OutputStringType2 *out2 ) {
378 typename InputStringType::size_type const pos = in.find( delim );413 typename InputStringType::size_type const pos = in.find( delim );
379 if ( pos != InputStringType::npos ) {414 if ( pos != InputStringType::npos ) {
380 if ( out1 )415 if ( out1 )
@@ -387,24 +422,26 @@
387}422}
388423
389// Allows out1 to be nullptr.424// Allows out1 to be nullptr.
390template<425template<class InputStringType,class DelimStringType,class OutputStringType2>
391 class InputStringType,426inline
392 class DelimStringType,427typename std::enable_if<ZORBA_IS_STRING(InputStringType)
393 class OutputStringType2428 && ZORBA_IS_STRING(DelimStringType)
394>429 && ZORBA_IS_STRING(OutputStringType2),
395inline bool split( InputStringType const &in, DelimStringType const &delim,430 bool>::type
396 void*, OutputStringType2 *out2 ) {431split( InputStringType const &in, DelimStringType const &delim, void*,
432 OutputStringType2 *out2 ) {
397 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );433 return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
398}434}
399435
400// Allows out2 to be nullptr.436// Allows out2 to be nullptr.
401template<437template<class InputStringType,class DelimStringType,class OutputStringType1>
402 class InputStringType,438inline
403 class DelimStringType,439typename std::enable_if<ZORBA_IS_STRING(InputStringType)
404 class OutputStringType1440 && ZORBA_IS_STRING(DelimStringType)
405>441 && ZORBA_IS_STRING(OutputStringType1),
406inline bool split( InputStringType const &in, DelimStringType const &delim,442 bool>::type
407 OutputStringType1 *out1, void* ) {443split( InputStringType const &in, DelimStringType const &delim,
444 OutputStringType1 *out1, void* ) {
408 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );445 return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
409}446}
410447
@@ -846,7 +883,8 @@
846template<typename T,class OutputStringType> inline883template<typename T,class OutputStringType> inline
847typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value884typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value
848 && !ZORBA_TR1_NS::is_integral<T>::value885 && !ZORBA_TR1_NS::is_integral<T>::value
849 && has_insertion_operator<T>::value,886 && has_insertion_operator<T>::value
887 && ZORBA_IS_STRING(OutputStringType),
850 void>::type888 void>::type
851to_string( T const &t, OutputStringType *out ) {889to_string( T const &t, OutputStringType *out ) {
852 std::ostringstream o;890 std::ostringstream o;
@@ -863,7 +901,9 @@
863 * @param out The output string.901 * @param out The output string.
864 */902 */
865template<typename T,class OutputStringType> inline903template<typename T,class OutputStringType> inline
866typename std::enable_if<ZORBA_TR1_NS::is_integral<T>::value,void>::type904typename std::enable_if<ZORBA_TR1_NS::is_integral<T>::value
905 && ZORBA_IS_STRING(OutputStringType),
906 void>::type
867to_string( T t, OutputStringType *out ) {907to_string( T t, OutputStringType *out ) {
868 ascii::itoa_buf_type buf;908 ascii::itoa_buf_type buf;
869 *out = ascii::itoa( t, buf );909 *out = ascii::itoa( t, buf );
@@ -882,7 +922,8 @@
882 */922 */
883template<class T,class OutputStringType> inline923template<class T,class OutputStringType> inline
884typename std::enable_if<!has_insertion_operator<T>::value924typename std::enable_if<!has_insertion_operator<T>::value
885 && has_c_str<T,char const* (T::*)() const>::value,925 && ZORBA_HAS_C_STR(T)
926 && ZORBA_IS_STRING(OutputStringType),
886 void>::type927 void>::type
887to_string( T const &t, OutputStringType *out ) {928to_string( T const &t, OutputStringType *out ) {
888 *out = t.c_str();929 *out = t.c_str();
@@ -903,9 +944,10 @@
903 */944 */
904template<class T,class OutputStringType> inline945template<class T,class OutputStringType> inline
905typename std::enable_if<!has_insertion_operator<T>::value946typename std::enable_if<!has_insertion_operator<T>::value
906 && !has_c_str<T,char const* (T::*)() const>::value947 && !ZORBA_HAS_C_STR(T)
907 && has_str<T,std::string (T::*)() const>::value948 && has_str<T,std::string (T::*)() const>::value
908 && !has_toString<T,std::string (T::*)() const>::value,949 && !has_toString<T,std::string (T::*)() const>::value
950 && ZORBA_IS_STRING(OutputStringType),
909 void>::type951 void>::type
910to_string( T const &t, OutputStringType *out ) {952to_string( T const &t, OutputStringType *out ) {
911 *out = t.str();953 *out = t.str();
@@ -926,9 +968,10 @@
926 */968 */
927template<class T,class OutputStringType> inline969template<class T,class OutputStringType> inline
928typename std::enable_if<!has_insertion_operator<T>::value970typename std::enable_if<!has_insertion_operator<T>::value
929 && !has_c_str<T,char const* (T::*)() const>::value971 && !ZORBA_HAS_C_STR(T)
930 && !has_str<T,std::string (T::*)() const>::value972 && !has_str<T,std::string (T::*)() const>::value
931 && has_toString<T,std::string (T::*)() const>::value,973 && has_toString<T,std::string (T::*)() const>::value
974 && ZORBA_IS_STRING(OutputStringType),
932 void>::type975 void>::type
933to_string( T const &t, OutputStringType *out ) {976to_string( T const &t, OutputStringType *out ) {
934 *out = t.toString();977 *out = t.toString();
@@ -944,7 +987,9 @@
944 * the result of \c to_string(*p); otherwise \c "<null>".987 * the result of \c to_string(*p); otherwise \c "<null>".
945 */988 */
946template<typename T,class OutputStringType> inline989template<typename T,class OutputStringType> inline
947typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value,void>::type990typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value
991 && ZORBA_IS_STRING(OutputStringType),
992 void>::type
948to_string( T p, OutputStringType *out ) {993to_string( T p, OutputStringType *out ) {
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;
950 if ( p )995 if ( p )
@@ -961,7 +1006,8 @@
961 * @param out The output string.1006 * @param out The output string.
962 */1007 */
963template<class OutputStringType> inline1008template<class OutputStringType> inline
964void to_string( char const *s, OutputStringType *out ) {1009typename std::enable_if<ZORBA_IS_STRING(OutputStringType),void>::type
1010to_string( char const *s, OutputStringType *out ) {
965 *out = s ? s : "<null>";1011 *out = s ? s : "<null>";
966}1012}
9671013
9681014
=== modified file 'src/util/time_parse.cpp'
--- src/util/time_parse.cpp 2013-03-22 19:04:27 +0000
+++ src/util/time_parse.cpp 2013-05-09 00:49:28 +0000
@@ -93,7 +93,7 @@
93invalid_value_value::invalid_value_value( char const *buf, size_t len ) :93invalid_value_value::invalid_value_value( char const *buf, size_t len ) :
94 value_( buf, min_len( buf, len ) )94 value_( buf, min_len( buf, len ) )
95{95{
96 ascii::trim_end_whitespace( value_ );96 ascii::trim_end_space( value_ );
97}97}
9898
99template<typename ValueType>99template<typename ValueType>
@@ -308,7 +308,7 @@
308 throw insufficient_buffer();308 throw insufficient_buffer();
309309
310 if ( ascii::is_space( c ) ) {310 if ( ascii::is_space( c ) ) {
311 bp = ascii::trim_start_whitespace( bp );311 bp = ascii::trim_start_space( bp );
312 continue;312 continue;
313 }313 }
314314
@@ -441,7 +441,7 @@
441 case 'n': // newline441 case 'n': // newline
442 case 't': // tab442 case 't': // tab
443 CHECK_ALT(0);443 CHECK_ALT(0);
444 bp = ascii::trim_start_whitespace( bp );444 bp = ascii::trim_start_space( bp );
445 break;445 break;
446446
447 case 'O': // "%O?" alternative conversion modifier447 case 'O': // "%O?" alternative conversion modifier
448448
=== modified file 'src/util/time_parse.h'
--- src/util/time_parse.h 2013-01-04 16:08:03 +0000
+++ src/util/time_parse.h 2013-05-09 00:49:28 +0000
@@ -406,10 +406,7 @@
406// Template version of parse().406// Template version of parse().
407//407//
408template<class BufferType> inline408template<class BufferType> inline
409typename std::enable_if<409typename std::enable_if<ZORBA_HAS_C_STR(BufferType),char const*>::type
410 ztd::has_c_str<BufferType,char const* (BufferType::*)() const>::value,
411 char const*
412>::type
413parse( BufferType const &buf, char const *fmt,410parse( BufferType const &buf, char const *fmt,
414 locale::iso639_1::type lang, locale::iso3166_1::type country,411 locale::iso639_1::type lang, locale::iso3166_1::type country,
415 ztm *tm, unsigned *set_fields = nullptr ) {412 ztm *tm, unsigned *set_fields = nullptr ) {
@@ -420,10 +417,7 @@
420// Template version of parse().417// Template version of parse().
421//418//
422template<class FormatType> inline419template<class FormatType> inline
423typename std::enable_if<420typename std::enable_if<ZORBA_HAS_C_STR(FormatType),char const*>::type
424 ztd::has_c_str<FormatType,char const* (FormatType::*)() const>::value,
425 char const*
426>::type
427parse( char const *buf, FormatType const &fmt,421parse( char const *buf, FormatType const &fmt,
428 locale::iso639_1::type lang, locale::iso3166_1::type country,422 locale::iso639_1::type lang, locale::iso3166_1::type country,
429 ztm *tm, unsigned *set_fields = nullptr ) {423 ztm *tm, unsigned *set_fields = nullptr ) {
@@ -434,11 +428,9 @@
434// Template version of parse().428// Template version of parse().
435//429//
436template<class BufferType,class FormatType> inline430template<class BufferType,class FormatType> inline
437typename std::enable_if<431typename std::enable_if<ZORBA_HAS_C_STR(BufferType)
438 ztd::has_c_str<BufferType,char const* (BufferType::*)() const>::value &&432 && ZORBA_HAS_C_STR(FormatType),
439 ztd::has_c_str<FormatType,char const* (FormatType::*)() const>::value,433 char const*>::type
440 char const*
441>::type
442parse( BufferType const &buf, FormatType const &fmt,434parse( BufferType const &buf, FormatType const &fmt,
443 locale::iso639_1::type lang, locale::iso3166_1::type country,435 locale::iso639_1::type lang, locale::iso3166_1::type country,
444 ztm *tm, unsigned *set_fields = nullptr ) {436 ztm *tm, unsigned *set_fields = nullptr ) {
445437
=== modified file 'src/util/time_util.h'
--- src/util/time_util.h 2013-05-04 18:47:13 +0000
+++ src/util/time_util.h 2013-05-09 00:49:28 +0000
@@ -164,10 +164,7 @@
164 // Template version of find().164 // Template version of find().
165 //165 //
166 template<class StringType> inline166 template<class StringType> inline
167 typename std::enable_if<167 typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
168 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
169 type
170 >::type
171 find( StringType const &calendar ) {168 find( StringType const &calendar ) {
172 return find( calendar.c_str() );169 return find( calendar.c_str() );
173 } 170 }
174171
=== modified file 'src/util/unicode_util.h'
--- src/util/unicode_util.h 2013-04-22 23:57:31 +0000
+++ src/util/unicode_util.h 2013-05-09 00:49:28 +0000
@@ -397,8 +397,9 @@
397 * @param out The Unicode string result.397 * @param out The Unicode string result.
398 * @return Returns \c true only if the conversion succeeded.398 * @return Returns \c true only if the conversion succeeded.
399 */399 */
400template<class StringType>400template<class StringType> inline
401inline bool to_string( StringType const &in, string *out ) {401typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
402to_string( StringType const &in, string *out ) {
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 );
403}404}
404405
405406
=== modified file 'src/util/uri_util.h'
--- src/util/uri_util.h 2013-02-07 17:24:36 +0000
+++ src/util/uri_util.h 2013-05-09 00:49:28 +0000
@@ -70,7 +70,8 @@
70 * or scheme::none (if none).70 * or scheme::none (if none).
71 */71 */
72template<class StringType> inline72template<class StringType> inline
73scheme get_scheme( StringType const &uri, StringType *sname = nullptr ) {73typename std::enable_if<ZORBA_IS_STRING(StringType),scheme>::type
74get_scheme( StringType const &uri, StringType *sname = nullptr ) {
74 char const *colon;75 char const *colon;
75 scheme const s = get_scheme( uri.c_str(), &colon );76 scheme const s = get_scheme( uri.c_str(), &colon );
76 if ( sname && s )77 if ( sname && s )
@@ -109,7 +110,7 @@
109 * @param s The string to append to.110 * @param s The string to append to.
110 * @param encode_slash If \c true, encodes the '/' character also.111 * @param encode_slash If \c true, encodes the '/' character also.
111 */112 */
112 explicit back_insert_iterator( StringType &s, bool encode_slash = false )113 explicit back_insert_iterator( StringType *s, bool encode_slash = false )
113 : base_type( s ), encode_slash_( encode_slash )114 : base_type( s ), encode_slash_( encode_slash )
114 {115 {
115 buf_[0] = '%';116 buf_[0] = '%';
@@ -129,8 +130,10 @@
129 * @param out The output string.130 * @param out The output string.
130 * @param encode_slash If \c true, encodes the '/' character also.131 * @param encode_slash If \c true, encodes the '/' character also.
131 */132 */
132template<class StringType> inline back_insert_iterator<StringType>133template<class StringType> inline
133back_inserter( StringType &out, bool encode_slash = false ) {134typename std::enable_if<ZORBA_IS_STRING(StringType),
135 back_insert_iterator<StringType> >::type
136back_inserter( StringType *out, bool encode_slash = false ) {
134 return back_insert_iterator<StringType>( out, encode_slash );137 return back_insert_iterator<StringType>( out, encode_slash );
135}138}
136139
@@ -144,7 +147,10 @@
144 * contents are appended to.147 * contents are appended to.
145 */148 */
146template<class InputStringType,class OutputStringType>149template<class InputStringType,class OutputStringType>
147void decode( InputStringType const &in, OutputStringType *out );150typename std::enable_if<ZORBA_IS_STRING(InputStringType)
151 && ZORBA_IS_STRING(OutputStringType),
152 void>::type
153decode( InputStringType const &in, OutputStringType *out );
148154
149/**155/**
150 * Percent-decodes (%xx) illegal URI characters.156 * Percent-decodes (%xx) illegal URI characters.
@@ -153,7 +159,8 @@
153 * @param s The string.159 * @param s The string.
154 */160 */
155template<class StringType> inline161template<class StringType> inline
156void decode( StringType &s ) {162typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
163decode( StringType &s ) {
157 StringType temp;164 StringType temp;
158 decode( s, &temp );165 decode( s, &temp );
159 s = temp;166 s = temp;
@@ -170,9 +177,12 @@
170 * @param encode_slash Encodes the slash character ("/") only if \c true.177 * @param encode_slash Encodes the slash character ("/") only if \c true.
171 */178 */
172template<class InputStringType,class OutputStringType> inline179template<class InputStringType,class OutputStringType> inline
173void encode( InputStringType const &in, OutputStringType *out,180typename std::enable_if<ZORBA_IS_STRING(InputStringType)
174 bool encode_slash = true ) {181 && ZORBA_IS_STRING(OutputStringType),
175 std::copy( in.begin(), in.end(), back_inserter( *out, encode_slash ) );182 void>::type
183encode( InputStringType const &in, OutputStringType *out,
184 bool encode_slash = true ) {
185 std::copy( in.begin(), in.end(), back_inserter( out, encode_slash ) );
176}186}
177187
178/**188/**
@@ -183,7 +193,8 @@
183 * @param encode_slash Encodes the slash character ("/") only if \c true.193 * @param encode_slash Encodes the slash character ("/") only if \c true.
184 */194 */
185template<class StringType> inline195template<class StringType> inline
186void encode( StringType &s, bool encode_slash = true ) {196typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
197encode( StringType &s, bool encode_slash = true ) {
187 StringType temp;198 StringType temp;
188 encode( s, &temp, encode_slash );199 encode( s, &temp, encode_slash );
189 s = temp;200 s = temp;
@@ -204,7 +215,8 @@
204 * local file is a created temporary file; \c false otherwise.215 * local file is a created temporary file; \c false otherwise.
205 */216 */
206template<class PathStringType> inline217template<class PathStringType> inline
207void fetch( char const *uri, PathStringType *path, bool *is_temp = nullptr ) {218typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
219fetch( char const *uri, PathStringType *path, bool *is_temp = nullptr ) {
208 char path_buf[ MAX_PATH ];220 char path_buf[ MAX_PATH ];
209 fetch_to_path_impl( uri, path_buf, is_temp );221 fetch_to_path_impl( uri, path_buf, is_temp );
210 *path = path_buf;222 *path = path_buf;
@@ -221,8 +233,11 @@
221 * local file is a created temporary file; \c false otherwise.233 * local file is a created temporary file; \c false otherwise.
222 */234 */
223template<class URIStringType,class PathStringType> inline235template<class URIStringType,class PathStringType> inline
224void fetch( URIStringType const &uri, PathStringType *file,236typename std::enable_if<ZORBA_HAS_C_STR(URIStringType)
225 bool *is_temp = nullptr ) {237 && ZORBA_IS_STRING(PathStringType),
238 void>::type
239fetch( URIStringType const &uri, PathStringType *file,
240 bool *is_temp = nullptr ) {
226 fetch( uri.c_str(), file, is_temp );241 fetch( uri.c_str(), file, is_temp );
227}242}
228243
229244
=== modified file 'src/util/uri_util.tcc'
--- src/util/uri_util.tcc 2013-02-07 17:24:36 +0000
+++ src/util/uri_util.tcc 2013-05-09 00:49:28 +0000
@@ -43,7 +43,10 @@
43///////////////////////////////////////////////////////////////////////////////43///////////////////////////////////////////////////////////////////////////////
4444
45template<class InputStringType,class OutputStringType>45template<class InputStringType,class OutputStringType>
46void decode( InputStringType const &in, OutputStringType *out ) {46typename std::enable_if<ZORBA_IS_STRING(InputStringType)
47 && ZORBA_IS_STRING(OutputStringType),
48 void>::type
49decode( InputStringType const &in, OutputStringType *out ) {
47 extern signed char const hex2dec[];50 extern signed char const hex2dec[];
4851
49 typedef typename InputStringType::const_iterator const_iterator;52 typedef typename InputStringType::const_iterator const_iterator;
5053
=== modified file 'src/util/utf8_util.h'
--- src/util/utf8_util.h 2013-04-22 14:32:41 +0000
+++ src/util/utf8_util.h 2013-05-09 00:49:28 +0000
@@ -43,9 +43,9 @@
4343
44using ascii::begins_with;44using ascii::begins_with;
45using ascii::ends_with;45using ascii::ends_with;
46using ascii::is_whitespace;46using ascii::is_space;
47using ascii::normalize_whitespace;47using ascii::normalize_space;
48using ascii::trim_whitespace;48using ascii::trim_space;
4949
50////////// begins/ends_with ///////////////////////////////////////////////////50////////// begins/ends_with ///////////////////////////////////////////////////
5151
@@ -59,7 +59,8 @@
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.
60 */60 */
61template<class StringType> inline61template<class StringType> inline
62bool begins_with( utf8_string<StringType> const &s, char c ) {62typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
63begins_with( utf8_string<StringType> const &s, char c ) {
63 return ascii::begins_with( *s.get(), c );64 return ascii::begins_with( *s.get(), c );
64}65}
6566
@@ -73,8 +74,9 @@
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.
74 */75 */
75template<class StringType> inline76template<class StringType> inline
76bool begins_with( utf8_string<StringType> const &s, char const *ps,77typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
77 typename StringType::size_type n ) {78begins_with( utf8_string<StringType> const &s, char const *ps,
79 typename StringType::size_type n ) {
78 return ascii::begins_with( *s.get(), ps, n );80 return ascii::begins_with( *s.get(), ps, n );
79}81}
8082
@@ -87,7 +89,8 @@
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.
88 */90 */
89template<class StringType> inline91template<class StringType> inline
90bool begins_with( utf8_string<StringType> const &s, char const *ps ) {92typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
93begins_with( utf8_string<StringType> const &s, char const *ps ) {
91 return ascii::begins_with( *s.get(), ps );94 return ascii::begins_with( *s.get(), ps );
92}95}
9396
@@ -101,8 +104,10 @@
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.
102 */105 */
103template<class StringType,class PrefixStringType> inline106template<class StringType,class PrefixStringType> inline
104bool begins_with( utf8_string<StringType> const &s,107typename std::enable_if<ZORBA_IS_STRING(StringType)
105 PrefixStringType const &ps ) {108 && ZORBA_IS_STRING(PrefixStringType),
109 bool>::type
110begins_with( utf8_string<StringType> const &s, PrefixStringType const &ps ) {
106 return ascii::begins_with( *s.get(), ps.data(), ps.size() );111 return ascii::begins_with( *s.get(), ps.data(), ps.size() );
107}112}
108113
@@ -116,8 +121,10 @@
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.
117 */122 */
118template<class StringType,class PrefixStringType> inline123template<class StringType,class PrefixStringType> inline
119bool begins_with( StringType const &s,124typename std::enable_if<ZORBA_IS_STRING(StringType)
120 utf8_string<PrefixStringType> const &ps ) {125 && ZORBA_IS_STRING(PrefixStringType),
126 bool>::type
127begins_with( StringType const &s, utf8_string<PrefixStringType> const &ps ) {
121 return ascii::begins_with( s, *ps.get() );128 return ascii::begins_with( s, *ps.get() );
122}129}
123130
@@ -131,8 +138,11 @@
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.
132 */139 */
133template<class StringType,class PrefixStringType> inline140template<class StringType,class PrefixStringType> inline
134bool begins_with( utf8_string<StringType> const &s,141typename std::enable_if<ZORBA_IS_STRING(StringType)
135 utf8_string<PrefixStringType> const &ps ) {142 && ZORBA_IS_STRING(PrefixStringType),
143 bool>::type
144begins_with( utf8_string<StringType> const &s,
145 utf8_string<PrefixStringType> const &ps ) {
136 return ascii::begins_with( *s.get(), *ps.get() );146 return ascii::begins_with( *s.get(), *ps.get() );
137}147}
138148
@@ -146,7 +156,8 @@
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.
147 */157 */
148template<class StringType> inline158template<class StringType> inline
149bool ends_with( utf8_string<StringType> const &s, char c ) {159typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
160ends_with( utf8_string<StringType> const &s, char c ) {
150 return ascii::ends_with( *s.get(), c );161 return ascii::ends_with( *s.get(), c );
151}162}
152163
@@ -160,8 +171,9 @@
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.
161 */172 */
162template<class StringType> inline173template<class StringType> inline
163bool ends_with( utf8_string<StringType> const &s, char const *ps,174typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
164 typename StringType::size_type n ) {175ends_with( utf8_string<StringType> const &s, char const *ps,
176 typename StringType::size_type n ) {
165 return ascii::ends_with( *s.get(), ps, n );177 return ascii::ends_with( *s.get(), ps, n );
166}178}
167179
@@ -174,7 +186,8 @@
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.
175 */187 */
176template<class StringType> inline188template<class StringType> inline
177bool ends_with( utf8_string<StringType> const &s, char const *ps ) {189typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
190ends_with( utf8_string<StringType> const &s, char const *ps ) {
178 return ascii::ends_with( *s.get(), ps );191 return ascii::ends_with( *s.get(), ps );
179}192}
180193
@@ -188,8 +201,10 @@
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.
189 */202 */
190template<class StringType,class SuffixStringType> inline203template<class StringType,class SuffixStringType> inline
191bool ends_with( utf8_string<StringType> const &s,204typename std::enable_if<ZORBA_IS_STRING(StringType)
192 SuffixStringType const &ps ) {205 && ZORBA_IS_STRING(SuffixStringType),
206 bool>::type
207ends_with( utf8_string<StringType> const &s, SuffixStringType const &ps ) {
193 return ascii::ends_with( *s.get(), ps.data(), ps.size() );208 return ascii::ends_with( *s.get(), ps.data(), ps.size() );
194}209}
195210
@@ -203,8 +218,10 @@
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.
204 */219 */
205template<class StringType,class SuffixStringType> inline220template<class StringType,class SuffixStringType> inline
206bool ends_with( StringType const &s,221typename std::enable_if<ZORBA_IS_STRING(StringType)
207 utf8_string<SuffixStringType> const &ps ) {222 && ZORBA_IS_STRING(SuffixStringType),
223 bool>::type
224ends_with( StringType const &s, utf8_string<SuffixStringType> const &ps ) {
208 return ascii::ends_with( s, *ps.get() );225 return ascii::ends_with( s, *ps.get() );
209}226}
210227
@@ -218,8 +235,11 @@
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.
219 */236 */
220template<class StringType,class SuffixStringType> inline237template<class StringType,class SuffixStringType> inline
221bool ends_with( utf8_string<StringType> const &s,238typename std::enable_if<ZORBA_IS_STRING(StringType)
222 utf8_string<SuffixStringType> const &ps ) {239 && ZORBA_IS_STRING(SuffixStringType),
240 bool>::type
241ends_with( utf8_string<StringType> const &s,
242 utf8_string<SuffixStringType> const &ps ) {
223 return ascii::ends_with( *s.get(), *ps.get() );243 return ascii::ends_with( *s.get(), *ps.get() );
224}244}
225245
@@ -235,7 +255,10 @@
235 * contents are overwritten.255 * contents are overwritten.
236 */256 */
237template<class InputStringType,class OutputStringType>257template<class InputStringType,class OutputStringType>
238void to_lower( InputStringType const &in, OutputStringType *out );258typename std::enable_if<ZORBA_IS_STRING(InputStringType)
259 && ZORBA_IS_STRING(OutputStringType),
260 void>::type
261to_lower( InputStringType const &in, OutputStringType *out );
239262
240/**263/**
241 * Converts a string to lower-case.264 * Converts a string to lower-case.
@@ -244,7 +267,8 @@
244 * @param s The string.267 * @param s The string.
245 */268 */
246template<class StringType> inline269template<class StringType> inline
247void to_lower( StringType &s ) {270typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
271to_lower( StringType &s ) {
248 StringType temp;272 StringType temp;
249 to_lower( s, &temp );273 to_lower( s, &temp );
250 s = temp;274 s = temp;
@@ -260,7 +284,10 @@
260 * contents are overwritten.284 * contents are overwritten.
261 */285 */
262template<class InputStringType,class OutputStringType>286template<class InputStringType,class OutputStringType>
263void to_upper( InputStringType const &in, OutputStringType *out );287typename std::enable_if<ZORBA_IS_STRING(InputStringType)
288 && ZORBA_IS_STRING(OutputStringType),
289 void>::type
290to_upper( InputStringType const &in, OutputStringType *out );
264291
265/**292/**
266 * Converts a string to upper-case.293 * Converts a string to upper-case.
@@ -269,7 +296,8 @@
269 * @param s The string.296 * @param s The string.
270 */297 */
271template<class StringType> inline298template<class StringType> inline
272void to_upper( StringType &s ) {299typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
300to_upper( StringType &s ) {
273 StringType temp;301 StringType temp;
274 to_upper( s, &temp );302 to_upper( s, &temp );
275 s = temp;303 s = temp;
@@ -286,7 +314,8 @@
286 * @param s A pointer to the string to be appended to.314 * @param s A pointer to the string to be appended to.
287 */315 */
288template<class InputIterator,class StringType> inline316template<class InputIterator,class StringType> inline
289void append_codepoints( InputIterator i, InputIterator j, StringType *s ) {317typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
318append_codepoints( InputIterator i, InputIterator j, StringType *s ) {
290 typename utf8_stringify<StringType>::type u( *s );319 typename utf8_stringify<StringType>::type u( *s );
291 std::copy( i, j, std::back_inserter( u ) );320 std::copy( i, j, std::back_inserter( u ) );
292}321}
@@ -301,7 +330,8 @@
301 * container's contents are appended to.330 * container's contents are appended to.
302 */331 */
303template<class StringType,class ContainerType> inline332template<class StringType,class ContainerType> inline
304void to_codepoints( StringType const &s, ContainerType *c ) {333typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
334to_codepoints( StringType const &s, ContainerType *c ) {
305 typename utf8_stringify<StringType const>::type const u( s );335 typename utf8_stringify<StringType const>::type const u( s );
306 std::copy( u.begin(), u.end(), std::back_inserter( *c ) );336 std::copy( u.begin(), u.end(), std::back_inserter( *c ) );
307}337}
@@ -391,8 +421,8 @@
391 * @return Returns \c true only if the conversion succeeded.421 * @return Returns \c true only if the conversion succeeded.
392 */422 */
393template<class StringType>423template<class StringType>
394bool to_string( unicode::char_type const *in, size_type in_len,424typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
395 StringType *out );425to_string( unicode::char_type const *in, size_type in_len, StringType *out );
396426
397/**427/**
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.
@@ -402,7 +432,8 @@
402 * @return Returns \c true only if the conversion succeeded.432 * @return Returns \c true only if the conversion succeeded.
403 */433 */
404template<class StringType> inline434template<class StringType> inline
405bool to_string( unicode::char_type const *in, StringType *out ) {435typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
436to_string( unicode::char_type const *in, StringType *out ) {
406 return to_string( in, u_strlen( in ), out );437 return to_string( in, u_strlen( in ), out );
407}438}
408439
@@ -416,7 +447,8 @@
416 * @return Returns \c true only if the conversion succeeded.447 * @return Returns \c true only if the conversion succeeded.
417 */448 */
418template<class StringType> inline449template<class StringType> inline
419bool to_string( unicode::string const &in, StringType *out ) {450typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
451to_string( unicode::string const &in, StringType *out ) {
420#ifndef ZORBA_NO_ICU452#ifndef ZORBA_NO_ICU
421 return to_string( in.getBuffer(), in.length(), out );453 return to_string( in.getBuffer(), in.length(), out );
422#else454#else
@@ -472,7 +504,8 @@
472 * @return Returns \c true only if the conversion succeeded.504 * @return Returns \c true only if the conversion succeeded.
473 */505 */
474template<class StringType>506template<class StringType>
475bool to_string( wchar_t const *in, size_type in_len, StringType *out );507typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
508to_string( wchar_t const *in, size_type in_len, StringType *out );
476509
477/**510/**
478 * Converts a wide-character string into a UTF-8 encoded string.511 * Converts a wide-character string into a UTF-8 encoded string.
@@ -483,7 +516,8 @@
483 * @return Returns \c true only if the conversion succeeded.516 * @return Returns \c true only if the conversion succeeded.
484 */517 */
485template<class StringType> inline518template<class StringType> inline
486bool to_string( wchar_t const *in, StringType *out ) {519typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
520to_string( wchar_t const *in, StringType *out ) {
487 return to_string( in, std::wcslen( in ), out );521 return to_string( in, std::wcslen( in ), out );
488}522}
489523
@@ -498,7 +532,8 @@
498 * @return Returns \c true only if the conversion succeeded.532 * @return Returns \c true only if the conversion succeeded.
499 */533 */
500template<class StringType> inline534template<class StringType> inline
501bool to_string( std::wstring const &in, StringType *out ) {535typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
536to_string( std::wstring const &in, StringType *out ) {
502 return to_string( in.data(), in.size(), out );537 return to_string( in.data(), in.size(), out );
503}538}
504539
@@ -543,8 +578,8 @@
543 * @return Returns \c true only if the conversion succeeded.578 * @return Returns \c true only if the conversion succeeded.
544 */579 */
545template<class StringType> inline580template<class StringType> inline
546bool to_wchar_t( StringType const &in, wchar_t **out,581typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
547 unicode::size_type *out_len ) {582to_wchar_t( StringType const &in, wchar_t **out, unicode::size_type *out_len ) {
548 return to_wchar_t( in.data(), in.size(), out, out_len );583 return to_wchar_t( in.data(), in.size(), out, out_len );
549}584}
550585
@@ -577,7 +612,7 @@
577 *612 *
578 * @param s The string to append to.613 * @param s The string to append to.
579 */614 */
580 explicit back_html_uri_insert_iterator( StringType &s ) : base_type( s ) {615 explicit back_html_uri_insert_iterator( StringType *s ) : base_type( s ) {
581 buf_[0] = '%';616 buf_[0] = '%';
582 }617 }
583618
@@ -593,8 +628,10 @@
593 * @tparam StringType The string type.628 * @tparam StringType The string type.
594 * @param out The output string.629 * @param out The output string.
595 */630 */
596template<class StringType> inline back_html_uri_insert_iterator<StringType>631template<class StringType> inline
597back_html_uri_inserter( StringType &out ) {632typename std::enable_if<ZORBA_IS_STRING(StringType),
633 back_html_uri_insert_iterator<StringType> >::type
634back_html_uri_inserter( StringType *out ) {
598 return back_html_uri_insert_iterator<StringType>( out );635 return back_html_uri_insert_iterator<StringType>( out );
599}636}
600637
@@ -607,10 +644,13 @@
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).
608 */645 */
609template<class InputStringType,class OutputStringType> inline646template<class InputStringType,class OutputStringType> inline
610void to_html_uri( InputStringType const &in, OutputStringType *out ) {647typename std::enable_if<ZORBA_IS_STRING(InputStringType)
648 && ZORBA_IS_STRING(OutputStringType),
649 void>::type
650to_html_uri( InputStringType const &in, OutputStringType *out ) {
611 typename utf8_stringify<InputStringType const>::type const u_in( in );651 typename utf8_stringify<InputStringType const>::type const u_in( in );
612 typename utf8_stringify<OutputStringType>::type u_out( *out );652 typename utf8_stringify<OutputStringType>::type u_out( *out );
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 ) );
614}654}
615655
616/**656/**
@@ -620,7 +660,8 @@
620 * @param s The string.660 * @param s The string.
621 */661 */
622template<class StringType> inline662template<class StringType> inline
623void to_html_uri( StringType &s ) {663typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
664to_html_uri( StringType &s ) {
624 StringType temp;665 StringType temp;
625 to_html_uri( s, &temp );666 to_html_uri( s, &temp );
626 s = temp;667 s = temp;
@@ -653,7 +694,7 @@
653 *694 *
654 * @param s The string to append to.695 * @param s The string to append to.
655 */696 */
656 explicit back_iri_insert_iterator( StringType &s ) : base_type( s ) {697 explicit back_iri_insert_iterator( StringType *s ) : base_type( s ) {
657 buf_[0] = '%';698 buf_[0] = '%';
658 }699 }
659700
@@ -669,8 +710,10 @@
669 * @tparam StringType The string type.710 * @tparam StringType The string type.
670 * @param out The output string.711 * @param out The output string.
671 */712 */
672template<class StringType> inline back_iri_insert_iterator<StringType>713template<class StringType> inline
673back_iri_inserter( StringType &out ) {714typename std::enable_if<ZORBA_IS_STRING(StringType),
715 back_iri_insert_iterator<StringType> >::type
716back_iri_inserter( StringType *out ) {
674 return back_iri_insert_iterator<StringType>( out );717 return back_iri_insert_iterator<StringType>( out );
675}718}
676719
@@ -684,10 +727,13 @@
684 * See RFC 3987.727 * See RFC 3987.
685 */728 */
686template<class InputStringType,class OutputStringType> inline729template<class InputStringType,class OutputStringType> inline
687void iri_to_uri( InputStringType const &in, OutputStringType *out ) {730typename std::enable_if<ZORBA_IS_STRING(InputStringType)
731 && ZORBA_IS_STRING(OutputStringType),
732 void>::type
733iri_to_uri( InputStringType const &in, OutputStringType *out ) {
688 typename utf8_stringify<InputStringType const>::type const u_in( in );734 typename utf8_stringify<InputStringType const>::type const u_in( in );
689 typename utf8_stringify<OutputStringType>::type u_out( *out );735 typename utf8_stringify<OutputStringType>::type u_out( *out );
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 ) );
691}737}
692738
693/**739/**
@@ -698,7 +744,8 @@
698 * See RFC 3987.744 * See RFC 3987.
699 */745 */
700template<class StringType> inline746template<class StringType> inline
701void iri_to_uri( StringType &s ) {747typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
748iri_to_uri( StringType &s ) {
702 StringType temp;749 StringType temp;
703 iri_to_uri( s, &temp );750 iri_to_uri( s, &temp );
704 s = temp;751 s = temp;
@@ -716,8 +763,11 @@
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).
717 */764 */
718template<class InputStringType,class OutputStringType>765template<class InputStringType,class OutputStringType>
719bool normalize( InputStringType const &in, unicode::normalization::type n,766typename std::enable_if<ZORBA_IS_STRING(InputStringType)
720 OutputStringType *out );767 && ZORBA_IS_STRING(OutputStringType),
768 bool>::type
769normalize( InputStringType const &in, unicode::normalization::type n,
770 OutputStringType *out );
721#endif /* ZORBA_NO_ICU */771#endif /* ZORBA_NO_ICU */
722772
723////////// Whitespace /////////////////////////////////////////////////////////773////////// Whitespace /////////////////////////////////////////////////////////
@@ -732,9 +782,12 @@
732 * @param out The output string.782 * @param out The output string.
733 */783 */
734template<class InputStringType,class OutputStringType> inline784template<class InputStringType,class OutputStringType> inline
735void normalize_whitespace( utf8_string<InputStringType> const &in,785typename std::enable_if<ZORBA_IS_STRING(InputStringType)
736 utf8_string<OutputStringType> *out ) {786 && ZORBA_IS_STRING(OutputStringType),
737 ascii::normalize_whitespace( *in.get(), out->get() );787 void>::type
788normalize_space( utf8_string<InputStringType> const &in,
789 utf8_string<OutputStringType> *out ) {
790 ascii::normalize_space( *in.get(), out->get() );
738}791}
739792
740/**793/**
@@ -746,9 +799,12 @@
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).
747 */800 */
748template<class InputStringType,class OutputStringType> inline801template<class InputStringType,class OutputStringType> inline
749void trim_whitespace( utf8_string<InputStringType> const &in,802typename std::enable_if<ZORBA_IS_STRING(InputStringType)
750 utf8_string<OutputStringType> *out ) {803 && ZORBA_IS_STRING(OutputStringType),
751 ascii::trim_whitespace( *in.get(), out->get() );804 void>::type
805trim_space( utf8_string<InputStringType> const &in,
806 utf8_string<OutputStringType> *out ) {
807 ascii::trim_space( *in.get(), out->get() );
752}808}
753809
754/**810/**
@@ -758,8 +814,9 @@
758 * @param s The string.814 * @param s The string.
759 */815 */
760template<class StringType> inline816template<class StringType> inline
761void trim_whitespace( utf8_string<StringType> &s ) {817typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
762 ascii::trim_whitespace( *s.get() );818trim_space( utf8_string<StringType> &s ) {
819 ascii::trim_space( *s.get() );
763}820}
764821
765////////// Miscellaneous //////////////////////////////////////////////////////822////////// Miscellaneous //////////////////////////////////////////////////////
@@ -774,8 +831,9 @@
774 * @return Returns \c *s.831 * @return Returns \c *s.
775 */832 */
776template<class StringType> inline833template<class StringType> inline
777StringType& left_pad( StringType *s, typename StringType::size_type width,834typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
778 unicode::code_point cp ) {835left_pad( StringType *s, typename StringType::size_type width,
836 unicode::code_point cp ) {
779 typedef typename utf8_stringify<StringType>::type u_type;837 typedef typename utf8_stringify<StringType>::type u_type;
780 typedef typename u_type::size_type u_size_type;838 typedef typename u_type::size_type u_size_type;
781 u_type u( *s );839 u_type u( *s );
@@ -795,8 +853,9 @@
795 * @return Returns \c *s.853 * @return Returns \c *s.
796 */854 */
797template<class StringType> inline855template<class StringType> inline
798StringType& right_pad( StringType *s, typename StringType::size_type width,856typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
799 unicode::code_point cp ) {857right_pad( StringType *s, typename StringType::size_type width,
858 unicode::code_point cp ) {
800 typedef typename utf8_stringify<StringType>::type u_type;859 typedef typename utf8_stringify<StringType>::type u_type;
801 typedef typename u_type::size_type u_size_type;860 typedef typename u_type::size_type u_size_type;
802 u_type u( *s );861 u_type u( *s );
@@ -815,7 +874,10 @@
815 * @param out The output string.874 * @param out The output string.
816 */875 */
817template<class InputStringType,class OutputStringType> inline876template<class InputStringType,class OutputStringType> inline
818void reverse( InputStringType const &in, OutputStringType *out ) {877typename std::enable_if<ZORBA_IS_STRING(InputStringType)
878 && ZORBA_IS_STRING(OutputStringType),
879 void>::type
880reverse( InputStringType const &in, OutputStringType *out ) {
819 typename utf8_stringify<InputStringType const>::type const u_in( in );881 typename utf8_stringify<InputStringType const>::type const u_in( in );
820 typename utf8_stringify<OutputStringType>::type u_out( *out );882 typename utf8_stringify<OutputStringType>::type u_out( *out );
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 ) );
@@ -832,14 +894,20 @@
832 * @return Returns \c true only if the strip succeeded.894 * @return Returns \c true only if the strip succeeded.
833 */895 */
834template<class InputStringType,class OutputStringType>896template<class InputStringType,class OutputStringType>
835bool strip_diacritics( InputStringType const &in, OutputStringType *out );897typename std::enable_if<ZORBA_IS_STRING(InputStringType)
898 && ZORBA_IS_STRING(OutputStringType),
899 bool>::type
900strip_diacritics( InputStringType const &in, OutputStringType *out );
836901
837/**902/**
838 *903 *
839 */904 */
840template<class StringType1,class StringType2> inline905template<class StringType1,class StringType2> inline
841int compare(const StringType1 &s1, const StringType2 &s2,906typename std::enable_if<ZORBA_IS_STRING(StringType1)
842 const XQPCollator* collation)907 && ZORBA_IS_STRING(StringType2),
908 int>::type
909compare(const StringType1 &s1, const StringType2 &s2,
910 const XQPCollator* collation)
843{911{
844#ifndef ZORBA_NO_ICU912#ifndef ZORBA_NO_ICU
845 if (collation == NULL || collation->doMemCmp())913 if (collation == NULL || collation->doMemCmp())
@@ -862,7 +930,8 @@
862 *930 *
863 */931 */
864template<class StringType> inline932template<class StringType> inline
865uint32_t hash(const StringType& s, const XQPCollator* collation = NULL)933typename std::enable_if<ZORBA_IS_STRING(StringType),uint32_t>::type
934hash(const StringType& s, const XQPCollator* collation = NULL)
866{935{
867#ifndef ZORBA_NO_ICU936#ifndef ZORBA_NO_ICU
868 if (!collation || collation->doMemCmp())937 if (!collation || collation->doMemCmp())
869938
=== modified file 'src/util/utf8_util.tcc'
--- src/util/utf8_util.tcc 2013-05-01 03:57:57 +0000
+++ src/util/utf8_util.tcc 2013-05-09 00:49:28 +0000
@@ -105,8 +105,11 @@
105#ifndef ZORBA_NO_ICU105#ifndef ZORBA_NO_ICU
106106
107template<class InputStringType,class OutputStringType>107template<class InputStringType,class OutputStringType>
108bool normalize( InputStringType const &in, unicode::normalization::type n,108typename std::enable_if<ZORBA_IS_STRING(InputStringType)
109 OutputStringType *out ) {109 && ZORBA_IS_STRING(OutputStringType),
110 bool>::type
111normalize( InputStringType const &in, unicode::normalization::type n,
112 OutputStringType *out ) {
110 unicode::string u_in;113 unicode::string u_in;
111 if ( !unicode::to_string( in, &u_in ) )114 if ( !unicode::to_string( in, &u_in ) )
112 return false;115 return false;
@@ -126,7 +129,10 @@
126#endif /* ZORBA_NO_ICU */129#endif /* ZORBA_NO_ICU */
127130
128template<class InputStringType,class OutputStringType>131template<class InputStringType,class OutputStringType>
129bool strip_diacritics( InputStringType const &in, OutputStringType *out ) {132typename std::enable_if<ZORBA_IS_STRING(InputStringType)
133 && ZORBA_IS_STRING(OutputStringType),
134 bool>::type
135strip_diacritics( InputStringType const &in, OutputStringType *out ) {
130#ifndef ZORBA_NO_ICU136#ifndef ZORBA_NO_ICU
131 unicode::string u_in;137 unicode::string u_in;
132 if ( !unicode::to_string( in, &u_in ) )138 if ( !unicode::to_string( in, &u_in ) )
@@ -143,7 +149,7 @@
143#else149#else
144 out->clear();150 out->clear();
145 out->reserve( in.size() );151 out->reserve( in.size() );
146 std::copy( in.begin(), in.end(), ascii::back_ascii_inserter( *out ) );152 std::copy( in.begin(), in.end(), ascii::back_ascii_inserter( out ) );
147#endif /* ZORBA_NO_ICU */153#endif /* ZORBA_NO_ICU */
148 return true;154 return true;
149}155}
@@ -151,8 +157,8 @@
151#ifndef ZORBA_NO_ICU157#ifndef ZORBA_NO_ICU
152158
153template<class StringType>159template<class StringType>
154bool to_string( unicode::char_type const *in, size_type in_len,160typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
155 StringType *out ) {161to_string( unicode::char_type const *in, size_type in_len, StringType *out ) {
156 storage_type *temp;162 storage_type *temp;
157 size_type temp_len;163 size_type temp_len;
158 if ( to_string( in, in_len, &temp, &temp_len ) ) {164 if ( to_string( in, in_len, &temp, &temp_len ) ) {
@@ -166,7 +172,8 @@
166172
167#ifndef WIN32173#ifndef WIN32
168template<class StringType>174template<class StringType>
169bool to_string( wchar_t const *in, size_type in_len, StringType *out ) {175typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
176to_string( wchar_t const *in, size_type in_len, StringType *out ) {
170 storage_type *temp;177 storage_type *temp;
171 size_type temp_len;178 size_type temp_len;
172 if ( utf8::to_string( in, in_len, &temp, &temp_len ) ) {179 if ( utf8::to_string( in, in_len, &temp, &temp_len ) ) {
@@ -182,7 +189,10 @@
182#endif /* ZORBA_NO_ICU */189#endif /* ZORBA_NO_ICU */
183190
184template<class InputStringType,class OutputStringType>191template<class InputStringType,class OutputStringType>
185void to_lower( InputStringType const &in, OutputStringType *out ) {192typename std::enable_if<ZORBA_IS_STRING(InputStringType)
193 && ZORBA_IS_STRING(OutputStringType),
194 void>::type
195to_lower( InputStringType const &in, OutputStringType *out ) {
186 typename utf8_stringify<InputStringType const>::type const u_in( in );196 typename utf8_stringify<InputStringType const>::type const u_in( in );
187 typename utf8_stringify<OutputStringType>::type u_out( *out );197 typename utf8_stringify<OutputStringType>::type u_out( *out );
188 out->clear(); // TODO: should this be here?198 out->clear(); // TODO: should this be here?
@@ -192,7 +202,10 @@
192}202}
193203
194template<class InputStringType,class OutputStringType>204template<class InputStringType,class OutputStringType>
195void to_upper( InputStringType const &in, OutputStringType *out ) {205typename std::enable_if<ZORBA_IS_STRING(InputStringType)
206 && ZORBA_IS_STRING(OutputStringType),
207 void>::type
208to_upper( InputStringType const &in, OutputStringType *out ) {
196 typename utf8_stringify<InputStringType const>::type const u_in( in );209 typename utf8_stringify<InputStringType const>::type const u_in( in );
197 typename utf8_stringify<OutputStringType>::type u_out( *out );210 typename utf8_stringify<OutputStringType>::type u_out( *out );
198 out->clear(); // TODO: should this be here?211 out->clear(); // TODO: should this be here?
@@ -201,6 +214,8 @@
201 );214 );
202}215}
203216
217///////////////////////////////////////////////////////////////////////////////
218
204} // namespace utf8219} // namespace utf8
205} // namespace zorba220} // namespace zorba
206221
207222
=== modified file 'src/util/utf8_util_base.h'
--- src/util/utf8_util_base.h 2013-04-22 23:57:31 +0000
+++ src/util/utf8_util_base.h 2013-05-09 00:49:28 +0000
@@ -315,10 +315,7 @@
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.
316 */316 */
317template<class StringType> inline317template<class StringType> inline
318typename std::enable_if<318typename std::enable_if<ZORBA_HAS_C_STR(StringType),size_type>::type
319 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
320 size_type
321>::type
322length( StringType const &s ) {319length( StringType const &s ) {
323 return length( s.c_str() );320 return length( s.c_str() );
324}321}
325322
=== modified file 'src/util/xml_util.h'
--- src/util/xml_util.h 2013-02-07 17:24:36 +0000
+++ src/util/xml_util.h 2013-05-09 00:49:28 +0000
@@ -55,7 +55,10 @@
55 * @return Returns \c true only if the extraction was successful.55 * @return Returns \c true only if the extraction was successful.
56 */56 */
57template<class InputStringType,class OutputStringType> inline57template<class InputStringType,class OutputStringType> inline
58bool clark_localname( InputStringType const &uname, OutputStringType *local ) {58typename std::enable_if<ZORBA_IS_STRING(InputStringType)
59 && ZORBA_IS_STRING(OutputStringType),
60 bool>::type
61clark_localname( InputStringType const &uname, OutputStringType *local ) {
59 typename InputStringType::size_type const rbrace = uname.find( '}' );62 typename InputStringType::size_type const rbrace = uname.find( '}' );
60 if ( rbrace != InputStringType::npos && rbrace + 1 < uname.size() ) {63 if ( rbrace != InputStringType::npos && rbrace + 1 < uname.size() ) {
61 *local = uname.substr( rbrace + 1 );64 *local = uname.substr( rbrace + 1 );
@@ -75,7 +78,10 @@
75 * @return Returns \c true only if the extraction was successful.78 * @return Returns \c true only if the extraction was successful.
76 */79 */
77template<class InputStringType,class OutputStringType> inline80template<class InputStringType,class OutputStringType> inline
78bool clark_uri( InputStringType const &uname, OutputStringType *uri ) {81typename std::enable_if<ZORBA_IS_STRING(InputStringType)
82 && ZORBA_IS_STRING(OutputStringType),
83 bool>::type
84clark_uri( InputStringType const &uname, OutputStringType *uri ) {
79 if ( uname.size() > 2 && uname[0] == '{' ) {85 if ( uname.size() > 2 && uname[0] == '{' ) {
80 typename InputStringType::size_type const rbrace = uname.find( '}', 1 );86 typename InputStringType::size_type const rbrace = uname.find( '}', 1 );
81 if ( rbrace != InputStringType::npos ) {87 if ( rbrace != InputStringType::npos ) {
@@ -99,8 +105,13 @@
99 * become empty, returns \c false; otherwise returns \a true.105 * become empty, returns \c false; otherwise returns \a true.
100 */106 */
101template<class InputStringType,class PrefixStringType,class LocalStringType>107template<class InputStringType,class PrefixStringType,class LocalStringType>
102inline bool split_name( InputStringType const &name, PrefixStringType *prefix,108inline
103 LocalStringType *local ) {109typename std::enable_if<ZORBA_IS_STRING(InputStringType)
110 && ZORBA_IS_STRING(PrefixStringType)
111 && ZORBA_IS_STRING(LocalStringType),
112 bool>::type
113split_name( InputStringType const &name, PrefixStringType *prefix,
114 LocalStringType *local ) {
104 typename InputStringType::size_type const colon = name.find( ':' );115 typename InputStringType::size_type const colon = name.find( ':' );
105 if ( colon != InputStringType::npos ) {116 if ( colon != InputStringType::npos ) {
106 prefix->assign( name, 0, colon );117 prefix->assign( name, 0, colon );
@@ -166,7 +177,7 @@
166 *177 *
167 * @param s The string to append to.178 * @param s The string to append to.
168 */179 */
169 explicit back_xml_insert_iterator( StringType &s ) : base_type( s ) {180 explicit back_xml_insert_iterator( StringType *s ) : base_type( s ) {
170 buf_[0] = '&';181 buf_[0] = '&';
171 buf_[1] = '#';182 buf_[1] = '#';
172 }183 }
@@ -183,8 +194,10 @@
183 * @tparam StringType The string type.194 * @tparam StringType The string type.
184 * @param out The output string.195 * @param out The output string.
185 */196 */
186template<class StringType> inline back_xml_insert_iterator<StringType>197template<class StringType> inline
187back_xml_inserter( StringType &out ) {198typename std::enable_if<ZORBA_IS_STRING(StringType),
199 back_xml_insert_iterator<StringType> >::type
200back_xml_inserter( StringType *out ) {
188 return back_xml_insert_iterator<StringType>( out );201 return back_xml_insert_iterator<StringType>( out );
189}202}
190203
@@ -199,8 +212,11 @@
199 * contents are appended to.212 * contents are appended to.
200 */213 */
201template<class InputStringType,class OutputStringType> inline214template<class InputStringType,class OutputStringType> inline
202void escape( InputStringType const &in, OutputStringType *out ) {215typename std::enable_if<ZORBA_IS_STRING(InputStringType)
203 std::copy( in.begin(), in.end(), back_xml_inserter( *out ) );216 && ZORBA_IS_STRING(OutputStringType),
217 void>::type
218escape( InputStringType const &in, OutputStringType *out ) {
219 std::copy( in.begin(), in.end(), back_xml_inserter( out ) );
204}220}
205221
206/**222/**
@@ -211,9 +227,10 @@
211 * @param s The string.227 * @param s The string.
212 */228 */
213template<class StringType> inline229template<class StringType> inline
214void escape( StringType &s ) {230typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
231escape( StringType &s ) {
215 StringType temp;232 StringType temp;
216 std::copy( s.begin(), s.end(), back_xml_inserter( temp ) );233 std::copy( s.begin(), s.end(), back_xml_inserter( &temp ) );
217 s = temp;234 s = temp;
218}235}
219236
@@ -239,7 +256,8 @@
239 * returns -1.256 * returns -1.
240 */257 */
241template<class StringType> inline258template<class StringType> inline
242int parse_entity( StringType const &ref, unicode::code_point *c ) {259typename std::enable_if<ZORBA_HAS_C_STR(StringType),int>::type
260parse_entity( StringType const &ref, unicode::code_point *c ) {
243 return parse_entity( ref.c_str(), c );261 return parse_entity( ref.c_str(), c );
244}262}
245263
@@ -254,7 +272,8 @@
254 * returns -1.272 * returns -1.
255 */273 */
256template<class StringType> inline274template<class StringType> inline
257int parse_entity( char const *ref, StringType *out ) {275typename std::enable_if<ZORBA_IS_STRING(StringType),int>::type
276parse_entity( char const *ref, StringType *out ) {
258 unicode::code_point c;277 unicode::code_point c;
259 int const result = parse_entity( ref, &c );278 int const result = parse_entity( ref, &c );
260 if ( result != -1 )279 if ( result != -1 )
@@ -274,7 +293,10 @@
274 * returns -1.293 * returns -1.
275 */294 */
276template<class InputStringType,class OutputStringType> inline295template<class InputStringType,class OutputStringType> inline
277int parse_entity( InputStringType const &ref, OutputStringType *out ) {296typename std::enable_if<ZORBA_HAS_C_STR(InputStringType)
297 && ZORBA_IS_STRING(OutputStringType),
298 int>::type
299parse_entity( InputStringType const &ref, OutputStringType *out ) {
278 return parse_entity( ref.c_str(), out );300 return parse_entity( ref.c_str(), out );
279}301}
280302
281303
=== modified file 'src/zorbatypes/URI.cpp'
--- src/zorbatypes/URI.cpp 2013-05-07 21:21:56 +0000
+++ src/zorbatypes/URI.cpp 2013-05-09 00:49:28 +0000
@@ -577,8 +577,8 @@
577 // first, we need to normalize the spaces in the uri577 // first, we need to normalize the spaces in the uri
578 // and only work with the normalized version from this point on578 // and only work with the normalized version from this point on
579 zstring lTrimmedURI;579 zstring lTrimmedURI;
580 ascii::normalize_whitespace(uri, &lTrimmedURI);580 ascii::normalize_space(uri, &lTrimmedURI);
581 ascii::trim_whitespace(lTrimmedURI);581 ascii::trim_space(lTrimmedURI);
582582
583 zstring::size_type lTrimmedURILength = lTrimmedURI.size();583 zstring::size_type lTrimmedURILength = lTrimmedURI.size();
584584
585585
=== modified file 'src/zorbatypes/binary.cpp'
--- src/zorbatypes/binary.cpp 2013-03-19 06:13:13 +0000
+++ src/zorbatypes/binary.cpp 2013-05-09 00:49:28 +0000
@@ -282,7 +282,7 @@
282282
283void Base16::insertData(char const *s, size_t len)283void Base16::insertData(char const *s, size_t len)
284{284{
285 s = ascii::trim_whitespace( s, &len );285 s = ascii::trim_space( s, &len );
286 try {286 try {
287 hexbinary::encode( s, len, &theData );287 hexbinary::encode( s, len, &theData );
288 }288 }
289289
=== modified file 'src/zorbatypes/datetime/datetimetype.cpp'
--- src/zorbatypes/datetime/datetimetype.cpp 2013-05-08 20:14:47 +0000
+++ src/zorbatypes/datetime/datetimetype.cpp 2013-05-09 00:49:28 +0000
@@ -355,7 +355,7 @@
355355
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)?
357357
358 ascii::skip_whitespace(str, len, &pos);358 ascii::skip_space(str, len, &pos);
359359
360 dt.facet = DATETIME_FACET;360 dt.facet = DATETIME_FACET;
361361
@@ -381,7 +381,7 @@
381381
382 ascii::size_type savepos = pos;382 ascii::size_type savepos = pos;
383383
384 ascii::skip_whitespace(str, len, &pos);384 ascii::skip_space(str, len, &pos);
385385
386 if (savepos != pos && pos != len)386 if (savepos != pos && pos != len)
387 return 1;387 return 1;
@@ -414,7 +414,7 @@
414 ascii::size_type pos = 0;414 ascii::size_type pos = 0;
415 int err = 1;415 int err = 1;
416416
417 ascii::skip_whitespace(str, len, &pos);417 ascii::skip_space(str, len, &pos);
418418
419 dt.facet = DATE_FACET;419 dt.facet = DATE_FACET;
420420
@@ -428,7 +428,7 @@
428428
429 ascii::size_type savepos = pos;429 ascii::size_type savepos = pos;
430430
431 ascii::skip_whitespace(str, len, &pos);431 ascii::skip_space(str, len, &pos);
432432
433 if (savepos != pos && pos != len)433 if (savepos != pos && pos != len)
434 return 1;434 return 1;
@@ -451,7 +451,7 @@
451 int err = 1;451 int err = 1;
452 ascii::size_type pos = 0;452 ascii::size_type pos = 0;
453453
454 ascii::skip_whitespace(str, len, &pos);454 ascii::skip_space(str, len, &pos);
455455
456 dt.facet = TIME_FACET;456 dt.facet = TIME_FACET;
457457
@@ -464,7 +464,7 @@
464464
465 ascii::size_type savepos = pos;465 ascii::size_type savepos = pos;
466466
467 ascii::skip_whitespace(str, len, &pos);467 ascii::skip_space(str, len, &pos);
468468
469 if (savepos != pos && pos != len)469 if (savepos != pos && pos != len)
470 return 1;470 return 1;
@@ -494,7 +494,7 @@
494494
495 // GYearMonth of form: '-'? yyyy '-' mm zzzzzz?495 // GYearMonth of form: '-'? yyyy '-' mm zzzzzz?
496496
497 ascii::skip_whitespace(str, len, &pos);497 ascii::skip_space(str, len, &pos);
498498
499 dt.facet = GYEARMONTH_FACET;499 dt.facet = GYEARMONTH_FACET;
500500
@@ -522,7 +522,7 @@
522522
523 ascii::size_type savepos = pos;523 ascii::size_type savepos = pos;
524524
525 ascii::skip_whitespace(str, len, &pos);525 ascii::skip_space(str, len, &pos);
526526
527 if (savepos != pos && pos != len)527 if (savepos != pos && pos != len)
528 return 1;528 return 1;
@@ -548,7 +548,7 @@
548548
549 // GYear of form: '-'? yyyy zzzzzz?549 // GYear of form: '-'? yyyy zzzzzz?
550550
551 ascii::skip_whitespace(str, len, &pos);551 ascii::skip_space(str, len, &pos);
552552
553 dt.facet = GYEAR_FACET;553 dt.facet = GYEAR_FACET;
554554
@@ -578,7 +578,7 @@
578578
579 ascii::size_type savepos = pos;579 ascii::size_type savepos = pos;
580580
581 ascii::skip_whitespace(str, len, &pos);581 ascii::skip_space(str, len, &pos);
582582
583 if (savepos != pos && pos != len)583 if (savepos != pos && pos != len)
584 return 1;584 return 1;
@@ -606,7 +606,7 @@
606 // GMonth of form: --MM zzzzzz?606 // GMonth of form: --MM zzzzzz?
607 // preceding - is not allowed.607 // preceding - is not allowed.
608608
609 ascii::skip_whitespace(str, len, &pos);609 ascii::skip_space(str, len, &pos);
610610
611 dt.facet = GMONTH_FACET;611 dt.facet = GMONTH_FACET;
612612
@@ -630,7 +630,7 @@
630630
631 ascii::size_type savepos = pos;631 ascii::size_type savepos = pos;
632632
633 ascii::skip_whitespace(str, len, &pos);633 ascii::skip_space(str, len, &pos);
634634
635 if (savepos != pos && pos != len)635 if (savepos != pos && pos != len)
636 return 1;636 return 1;
@@ -658,7 +658,7 @@
658 // GMonthDay of form: --MM-DD zzzzzz?658 // GMonthDay of form: --MM-DD zzzzzz?
659 // preceding - is not allowed.659 // preceding - is not allowed.
660660
661 ascii::skip_whitespace(str, len, &pos);661 ascii::skip_space(str, len, &pos);
662662
663 dt.facet = GMONTHDAY_FACET;663 dt.facet = GMONTHDAY_FACET;
664664
@@ -683,7 +683,7 @@
683683
684 ascii::size_type savepos = pos;684 ascii::size_type savepos = pos;
685685
686 ascii::skip_whitespace(str, len, &pos);686 ascii::skip_space(str, len, &pos);
687687
688 if (savepos != pos && pos != len)688 if (savepos != pos && pos != len)
689 return 1;689 return 1;
@@ -711,7 +711,7 @@
711 // GDay of form: ---DD zzzzzz?711 // GDay of form: ---DD zzzzzz?
712 // preceding - is not allowed.712 // preceding - is not allowed.
713713
714 ascii::skip_whitespace(str, len, &pos);714 ascii::skip_space(str, len, &pos);
715715
716 dt.facet = GDAY_FACET;716 dt.facet = GDAY_FACET;
717717
@@ -736,7 +736,7 @@
736736
737 ascii::size_type savepos = pos;737 ascii::size_type savepos = pos;
738738
739 ascii::skip_whitespace(str, len, &pos);739 ascii::skip_space(str, len, &pos);
740740
741 if (savepos != pos && pos != len)741 if (savepos != pos && pos != len)
742 return 1;742 return 1;
743743
=== modified file 'src/zorbatypes/datetime/duration.cpp'
--- src/zorbatypes/datetime/duration.cpp 2013-04-30 00:12:10 +0000
+++ src/zorbatypes/datetime/duration.cpp 2013-05-09 00:49:28 +0000
@@ -58,7 +58,7 @@
58 long& frac_seconds)58 long& frac_seconds)
59{59{
60 ascii::size_type savepos = pos;60 ascii::size_type savepos = pos;
61 ascii::skip_whitespace(str, len, &pos);61 ascii::skip_space(str, len, &pos);
62 int err;62 int err;
6363
64 if (pos != savepos) {64 if (pos != savepos) {
@@ -111,7 +111,7 @@
111 long& frac_seconds)111 long& frac_seconds)
112{112{
113 ascii::size_type savepos = pos;113 ascii::size_type savepos = pos;
114 ascii::skip_whitespace(str, len, &pos);114 ascii::skip_space(str, len, &pos);
115 int err;115 int err;
116116
117 if (pos != savepos)117 if (pos != savepos)
@@ -246,7 +246,7 @@
246 return err;246 return err;
247247
248 ascii::size_type pos = ym_pos+1;248 ascii::size_type pos = ym_pos+1;
249 ascii::skip_whitespace(str, len, &pos);249 ascii::skip_space(str, len, &pos);
250250
251 if (pos > ym_pos + 1 && pos != len)251 if (pos > ym_pos + 1 && pos != len)
252 return 1;252 return 1;
@@ -282,7 +282,7 @@
282 long months = 0;282 long months = 0;
283 int err;283 int err;
284284
285 ascii::skip_whitespace(str, len, &pos);285 ascii::skip_space(str, len, &pos);
286286
287 if (pos == len)287 if (pos == len)
288 return 1;288 return 1;
@@ -327,7 +327,7 @@
327 return 1;327 return 1;
328 }328 }
329329
330 ascii::skip_whitespace(str, len, &pos);330 ascii::skip_space(str, len, &pos);
331331
332 if (len != pos)332 if (len != pos)
333 return 1;333 return 1;
@@ -352,7 +352,7 @@
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;
353 int err;353 int err;
354354
355 ascii::skip_whitespace(str, len, &pos);355 ascii::skip_space(str, len, &pos);
356356
357 if (pos == len)357 if (pos == len)
358 return 1;358 return 1;
@@ -392,7 +392,7 @@
392 return err;392 return err;
393 }393 }
394394
395 ascii::skip_whitespace(str, len, &pos);395 ascii::skip_space(str, len, &pos);
396396
397 if (len != pos)397 if (len != pos)
398 return 1;398 return 1;
399399
=== modified file 'src/zorbatypes/datetime/timezone.cpp'
--- src/zorbatypes/datetime/timezone.cpp 2013-05-08 20:14:47 +0000
+++ src/zorbatypes/datetime/timezone.cpp 2013-05-09 00:49:28 +0000
@@ -48,14 +48,14 @@
48{48{
49 ascii::size_type pos = 0;49 ascii::size_type pos = 0;
50 50
51 ascii::skip_whitespace(str, strlen, &pos);51 ascii::skip_space(str, strlen, &pos);
5252
53 // A time zone is of form: (('+' | '-') hh ':' mm) | 'Z'53 // A time zone is of form: (('+' | '-') hh ':' mm) | 'Z'
5454
55 if (str[pos] == 'Z')55 if (str[pos] == 'Z')
56 {56 {
57 ++pos;57 ++pos;
58 ascii::skip_whitespace(str, strlen, &pos);58 ascii::skip_space(str, strlen, &pos);
5959
60 if (pos != strlen)60 if (pos != strlen)
61 return 1;61 return 1;
@@ -94,7 +94,7 @@
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)
95 return 1;95 return 1;
9696
97 ascii::skip_whitespace(str, strlen, &pos);97 ascii::skip_space(str, strlen, &pos);
9898
99 if (pos != strlen)99 if (pos != strlen)
100 return 1;100 return 1;
101101
=== modified file 'src/zorbatypes/decimal.cpp'
--- src/zorbatypes/decimal.cpp 2013-05-05 03:16:33 +0000
+++ src/zorbatypes/decimal.cpp 2013-05-09 00:49:28 +0000
@@ -37,7 +37,7 @@
37 if ( !*s )37 if ( !*s )
38 throw std::invalid_argument( "empty string" );38 throw std::invalid_argument( "empty string" );
3939
40 s = ascii::trim_start_whitespace( s );40 s = ascii::trim_start_space( s );
41 char const *const first_non_ws = s;41 char const *const first_non_ws = s;
4242
43 if ( *s == '+' || *s == '-' )43 if ( *s == '+' || *s == '-' )
4444
=== modified file 'src/zorbatypes/floatimpl.cpp'
--- src/zorbatypes/floatimpl.cpp 2013-05-04 17:29:21 +0000
+++ src/zorbatypes/floatimpl.cpp 2013-05-09 00:49:28 +0000
@@ -69,7 +69,7 @@
6969
70 int significant_digits = 0;70 int significant_digits = 0;
7171
72 s = ascii::trim_start_whitespace( s );72 s = ascii::trim_start_space( s );
7373
74 if ( !parse_etc( s ) ) {74 if ( !parse_etc( s ) ) {
75 char const *const first_non_ws = s;75 char const *const first_non_ws = s;
@@ -136,7 +136,7 @@
136 } else136 } else
137 return false;137 return false;
138138
139 return !*ascii::trim_start_whitespace( s );139 return !*ascii::trim_start_space( s );
140}140}
141141
142////////// constructors ///////////////////////////////////////////////////////142////////// constructors ///////////////////////////////////////////////////////
143143
=== modified file 'src/zorbautils/locale.h'
--- src/zorbautils/locale.h 2013-03-24 15:21:50 +0000
+++ src/zorbautils/locale.h 2013-05-09 00:49:28 +0000
@@ -55,10 +55,7 @@
55 // Template version of find().55 // Template version of find().
56 //56 //
57 template<class StringType> inline57 template<class StringType> inline
58 typename std::enable_if<58 typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
59 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
60 type
61 >::type
62 find( StringType const &country ) {59 find( StringType const &country ) {
63 return find( country.c_str() );60 return find( country.c_str() );
64 }61 }
@@ -101,10 +98,7 @@
101 // Template version of find().98 // Template version of find().
102 //99 //
103 template<class StringType> inline100 template<class StringType> inline
104 typename std::enable_if<101 typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
105 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
106 type
107 >::type
108 find( StringType const &lang ) {102 find( StringType const &lang ) {
109 return find( lang.c_str() );103 return find( lang.c_str() );
110 }104 }
@@ -265,10 +259,7 @@
265 // Template version of find().259 // Template version of find().
266 //260 //
267 template<class StringType> inline261 template<class StringType> inline
268 typename std::enable_if<262 typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
269 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
270 type
271 >::type
272 find( StringType const &lang ) {263 find( StringType const &lang ) {
273 return find( lang.c_str() );264 return find( lang.c_str() );
274 }265 }
@@ -288,10 +279,7 @@
288 // Template version of find_lang().279 // Template version of find_lang().
289 //280 //
290 template<class StringType> inline281 template<class StringType> inline
291 typename std::enable_if<282 typename std::enable_if<ZORBA_HAS_C_STR(StringType),iso639_1::type>::type
292 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
293 iso639_1::type
294 >::type
295 find_lang( StringType const &lang ) {283 find_lang( StringType const &lang ) {
296 return find_lang( lang.c_str() );284 return find_lang( lang.c_str() );
297 }285 }
@@ -436,10 +424,7 @@
436 // Template version of parse().424 // Template version of parse().
437 //425 //
438 template<class StringType> inline426 template<class StringType> inline
439 typename std::enable_if<427 typename std::enable_if<ZORBA_HAS_C_STR(StringType),bool>::type
440 ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
441 bool
442 >::type
443 parse( StringType const &locale_str, iso639_1::type *lang = nullptr,428 parse( StringType const &locale_str, iso639_1::type *lang = nullptr,
444 iso3166_1::type *country = nullptr ) {429 iso3166_1::type *country = nullptr ) {
445 return parse( locale_str.c_str(), lang, country );430 return parse( locale_str.c_str(), lang, country );

Subscribers

People subscribed via source and target branches