zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #21780
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.
Commit message:
Util function argument bullet-proofing and clean-up.
Requested reviews:
Paul J. Lucas (paul-lucas)
For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/163078
Util function argument bullet-proofing and clean-up.
--
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/163078
Your team Zorba Coders is subscribed to branch lp:zorba.
=== 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 @@
TimingInfo& timing)
{
unsigned long lNumExecutions = properties.multiple();
- bool lIndent = properties.indent();
bool doTiming = properties.timing();
bool serializePlan = properties.serializePlan();
bool savePlan = properties.savePlan();
=== 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 @@
ZORBA_DECL_HAS_MEM_FN( str );
ZORBA_DECL_HAS_MEM_FN( toString );
+#define ZORBA_HAS_C_STR(T) \
+ ::zorba::internal::ztd::has_c_str<T,char const* (T::*)() const>::value
+
+#define ZORBA_IS_STRING(T) ZORBA_HAS_C_STR(T)
+
/**
* \internal
* Tests whether a given type \a T is a C string type.
@@ -310,7 +315,7 @@
*/
template<class T> inline
typename std::enable_if<!has_insertion_operator<T>::value
- && has_c_str<T,char const* (T::*)() const>::value,
+ && ZORBA_HAS_C_STR(T),
std::string>::type
to_string( T const &t ) {
return t.c_str();
@@ -331,7 +336,7 @@
*/
template<class T> inline
typename std::enable_if<!has_insertion_operator<T>::value
- && !has_c_str<T,char const* (T::*)() const>::value
+ && !ZORBA_HAS_C_STR(T)
&& has_str<T,std::string (T::*)() const>::value
&& !has_toString<T,std::string (T::*)() const>::value,
std::string>::type
@@ -354,7 +359,7 @@
*/
template<class T> inline
typename std::enable_if<!has_insertion_operator<T>::value
- && !has_c_str<T,char const* (T::*)() const>::value
+ && !ZORBA_HAS_C_STR(T)
&& !has_str<T,std::string (T::*)() const>::value
&& has_toString<T,std::string (T::*)() const>::value,
std::string>::type
=== 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 @@
// Put a space between consecutive text nodes (or a text node and an
// atomic item), unless the text node contains whitespace only.
- if (!ascii::is_whitespace(text.c_str()))
+ if (!ascii::is_space(text.c_str()))
{
thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT;
}
@@ -729,7 +729,7 @@
// Ignore whitespace text nodes when doing indentation
if (!ser->indent ||
child->getNodeKind() != store::StoreConsts::textNode ||
- !ascii::is_whitespace(child->getStringValue().c_str()))
+ !ascii::is_space(child->getStringValue().c_str()))
{
emit_node(child, depth);
prev_node_kind = child->getNodeKind();
=== 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 @@
///////////////////////////////////////////////////////////////////////////////
void trim( String &s ) {
- ascii::trim_whitespace( s );
+ ascii::trim_space( s );
}
void trim( String &s, char const *chars ) {
=== 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 @@
{
if (do_trim_start)
{
- text = ascii::trim_start_whitespace(text, &length);
+ text = ascii::trim_start_space(text, &length);
}
if (do_trim_end)
{
- length = ascii::trim_end_whitespace(text, length);
+ length = ascii::trim_end_space(text, length);
}
if (!is_eqname)
@@ -146,13 +146,13 @@
off_t symbol_table::put_uri(char const* text, size_t length)
{
// trim whitespace
- text = ascii::trim_whitespace(text, &length);
+ text = ascii::trim_space(text, &length);
// normalize whitespace
string result;
if (! decode_string (text, length, &result))
return -1;
- ascii::normalize_whitespace( result );
+ ascii::normalize_space( result );
return heap.put (result.c_str (), 0, result.length ());
}
=== 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 @@
// if the line contains an annotation, than we finish the description
zstring lTmp;
- ascii::trim_whitespace( lLine, &lTmp );
+ ascii::trim_space( lLine, &lTmp );
if ( !lTmp.empty() && lTmp[0] == '@' ) {
lDescriptionState = false;
if (!lAnntotation.empty()) {
@@ -102,7 +102,7 @@
XQDocComment::startsWithColon(zstring& aLine)
{
zstring temp;
- ascii::trim_whitespace( aLine, &temp );
+ ascii::trim_space( aLine, &temp );
if ( !temp.empty() && temp[0] == ':' ) {
aLine = temp.substr(1);
@@ -126,7 +126,7 @@
}
ascii::to_lower( lName );
- ascii::normalize_whitespace( lValue );
+ ascii::normalize_space( lValue );
if ("version" == lName) {
theVersion = lValue;
=== 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 @@
if (lPrevIsBoundary)
{
zstring content = v.get_elem_content().str();
- utf8::trim_whitespace(content);
+ utf8::trim_space(content);
// Filtering out of whitespaces
if (content.empty())
@@ -14800,7 +14800,7 @@
// is not in the lexical space of NCName, a type error is raised [err:XPTY0004]
zstring lNormalizedTarget;
- ascii::normalize_whitespace(target, &lNormalizedTarget);
+ ascii::normalize_space(target, &lNormalizedTarget);
if (!GenericCast::castableToNCName(lNormalizedTarget))
{
=== 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 @@
// normalize value of xml:id
if (isId)
{
- ascii::normalize_whitespace(lexicalValue);
+ ascii::normalize_space(lexicalValue);
}
GENV_ITEMFACTORY->createUntypedAtomic(typedValue, lexicalValue);
=== 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 @@
zstring::const_iterator *i,
modifier *mod, QueryLoc const &loc ) {
zstring::const_iterator &j = *i;
- ascii::skip_whitespace( picture_str, &j );
+ ascii::skip_space( picture_str, &j );
if ( j == picture_str.end() || *j == ',' ) {
//
// Assume that the ',' is the start of the width modifier (hence there is
@@ -875,7 +875,7 @@
zstring::const_iterator *i, modifier *mod,
QueryLoc const &loc ) {
zstring::const_iterator &j = *i;
- ascii::skip_whitespace( picture_str, &j );
+ ascii::skip_space( picture_str, &j );
if ( j == picture_str.end() )
return;
@@ -965,10 +965,10 @@
QueryLoc const &loc ) {
zstring::const_iterator &j = *i;
- ascii::skip_whitespace( picture_str, &j );
+ ascii::skip_space( picture_str, &j );
if ( j == picture_str.end() || (*j != ',' && *j != ';') )
return;
- ascii::skip_whitespace( picture_str, &++j );
+ ascii::skip_space( picture_str, &++j );
if ( j == picture_str.end() )
goto bad_width_modifier;
if ( *j == '*' ) {
@@ -987,10 +987,10 @@
mod->max_width = 0;
- ascii::skip_whitespace( picture_str, &j );
+ ascii::skip_space( picture_str, &j );
if ( j == picture_str.end() || *j != '-' )
return;
- ascii::skip_whitespace( picture_str, &++j );
+ ascii::skip_space( picture_str, &++j );
if ( j == picture_str.end() )
goto bad_width_modifier;
if ( *j == '*' )
=== 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 @@
} else {
zstring format_name( format_name_item->getStringValue() );
- ascii::trim_whitespace( format_name );
+ ascii::trim_space( format_name );
zstring prefix, local;
if ( !xml::split_name( format_name, &prefix, &local ) ||
prefix.empty() ) {
=== 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 @@
{
itemQName->getStringValue2(qname);
- ascii::trim_whitespace(qname);
+ ascii::trim_space(qname);
index = qname.find(":", 0, 1);
@@ -135,14 +135,14 @@
{
itemURI->getStringValue2(resNs);
- ascii::trim_whitespace(resNs);
+ ascii::trim_space(resNs);
}
consumeNext(itemQName, theChild1.getp(), planState );
itemQName->getStringValue2(qname);
- ascii::trim_whitespace(qname);
+ ascii::trim_space(qname);
index = qname.find(":", 0, 1);
@@ -295,7 +295,7 @@
else
{
itemPrefix->getStringValue2(prefix);
- ascii::trim_whitespace(prefix);
+ ascii::trim_space(prefix);
}
if (!consumeNext(itemElem, theChildren[1].getp(), planState ))
=== 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 @@
if (consumeNext(item, theChildren [0].getp(), planState))
{
item->getStringValue2(resStr);
- ascii::normalize_whitespace(resStr);
+ ascii::normalize_space(resStr);
STACK_PUSH(GENV_ITEMFACTORY->createString(result, resStr), state);
}
else
@@ -811,7 +811,7 @@
ZORBA_ASSERT(false);
item1->getStringValue2(normForm);
- ascii::trim_whitespace(normForm);
+ ascii::trim_space(normForm);
zstring tmp(normForm);
utf8::to_upper(tmp, &normForm);
}
=== 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 @@
bool UntypedAtomicItem::castToBoolean(store::Item_t& result) const
{
zstring str;
- ascii::trim_whitespace(theValue, &str);
+ ascii::trim_space(theValue, &str);
bool value = true;
if (ZSTREQ(str, "false") || ZSTREQ(str, "0"))
=== 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 @@
zstring prefix;
zstring local;
- ascii::trim_whitespace(str);
+ ascii::trim_space(str);
zstring::size_type pos = str.rfind(":", str.size(), 1);
if (pos != zstring::npos)
@@ -2202,7 +2202,7 @@
zstring& textValue,
std::vector<zstring>& atomicTextValues)
{
- ascii::normalize_whitespace(textValue);
+ ascii::normalize_space(textValue);
zstring::size_type start = 0;
zstring::size_type i = 0;
=== 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 @@
zstring::size_type len = strval.size();
zstring::size_type pos = 0;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
str += pos;
@@ -606,7 +606,7 @@
}
pos = str - strval.c_str();
- ascii::skip_whitespace(strval.c_str(), len, &pos);
+ ascii::skip_space(strval.c_str(), len, &pos);
if (pos != len)
{
@@ -661,7 +661,7 @@
T1_TO_T2(str, QN)
{
- ascii::trim_whitespace(strval);
+ ascii::trim_space(strval);
zstring::size_type idx = strval.find(":");
zstring::size_type lidx = strval.rfind(":", strval.size(), 1);
@@ -713,7 +713,7 @@
T1_TO_T2(str, NOT)
{
- ascii::trim_whitespace(strval);
+ ascii::trim_space(strval);
zstring uri;
zstring prefix;
@@ -1736,7 +1736,7 @@
char ch;
zstring::size_type sz = strval.size();
- ascii::trim_whitespace(strval);
+ ascii::trim_space(strval);
bool spaceSeen = false;
@@ -1783,7 +1783,7 @@
}
case store::XS_NMTOKEN:
{
- ascii::trim_whitespace(strval);
+ ascii::trim_space(strval);
if (GenericCast::instance()->castableToNMToken(strval))
{
@@ -1794,7 +1794,7 @@
}
case store::XS_NAME:
{
- ascii::trim_whitespace(strval);
+ ascii::trim_space(strval);
if (GenericCast::instance()->castableToName(strval))
{
@@ -1805,8 +1805,8 @@
}
case store::XS_NCNAME:
{
- ascii::normalize_whitespace(strval);
- ascii::trim_whitespace(strval);
+ ascii::normalize_space(strval);
+ ascii::trim_space(strval);
if (GenericCast::castableToNCName(strval))
{
@@ -2665,7 +2665,7 @@
zstring strval;
item->getStringValue2(strval);
- ascii::trim_whitespace(strval);
+ ascii::trim_space(strval);
zstring::size_type idx = strval.find(":");
zstring::size_type lidx = strval.rfind(":", strval.size(), 1);
=== 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 @@
// remove following if xs:float will be represented by a C float
//textValue = textValue.trim(" \n\r\t",4);
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
try
{
xs_float const n(textValue2.c_str());
@@ -501,7 +501,7 @@
// remove following if xs:float will be represented by a C float
//textValue = textValue.trim(" \n\r\t",4);
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
store::ItemFactory* factory = GENV_ITEMFACTORY;
try {
xs_double const n(textValue2.c_str());
@@ -550,7 +550,7 @@
{
// optimization posible since there is no pattern to be checked
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
store::ItemFactory* factory = GENV_ITEMFACTORY;
return factory->createString(result, textValue2);
}
@@ -562,7 +562,7 @@
{
// optimization posible since there is no pattern to be checked
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
store::ItemFactory* factory = GENV_ITEMFACTORY;
return factory->createNormalizedString(result, textValue2);
@@ -580,7 +580,7 @@
//return true;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue2.c_str());
XSValue::DataType datatype = XSValue::dt_token;
XSValue::Status status = XSValue::st_Init;
@@ -607,7 +607,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue2.c_str());
XSValue::DataType datatype = XSValue::dt_NMTOKEN;
@@ -635,7 +635,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue2.c_str());
XSValue::DataType datatype = XSValue::dt_Name;
@@ -664,7 +664,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue2.c_str());
XSValue::DataType datatype = XSValue::dt_NCName;
@@ -692,7 +692,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue.c_str());
XSValue::DataType datatype = XSValue::dt_ID;
@@ -720,7 +720,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue.c_str());
XSValue::DataType datatype = XSValue::dt_IDREF;
@@ -748,7 +748,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue2.c_str());
XSValue::DataType datatype = XSValue::dt_ENTITY;
@@ -776,7 +776,7 @@
store::Item_t &result)
{
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
XMLCh* content = XMLString::transcode(textValue2.c_str());
XSValue::DataType datatype = XSValue::dt_NOTATION;
@@ -834,7 +834,7 @@
//return factory->createDateTime(result, year, month, day, hour, minute, sec);
xs_dateTime dt;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (0 == DateTime::parseDateTime(textValue2.c_str(), textValue2.size(), dt))
@@ -874,7 +874,7 @@
//return factory->createDate(result, tValue);
xs_date d;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (0 == DateTime::parseDate(textValue2.c_str(), textValue2.size(), d))
@@ -919,7 +919,7 @@
//return factory->createTime(result, tValue);
xs_time t;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (0 == DateTime::parseTime(textValue2.c_str(), textValue2.size(), t))
@@ -954,7 +954,7 @@
xs_gYearMonth tValue;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (DateTime::parseGYearMonth(textValue2.c_str(), textValue2.size(), tValue))
@@ -988,7 +988,7 @@
xs_gYear tValue;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (DateTime::parseGYear(textValue2.c_str(), textValue2.size(), tValue))
@@ -1022,7 +1022,7 @@
store::ItemFactory* factory = GENV_ITEMFACTORY;
xs_gMonthDay tValue;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (DateTime::parseGMonthDay(textValue2.c_str(), textValue2.size(), tValue))
@@ -1055,7 +1055,7 @@
store::ItemFactory* factory = GENV_ITEMFACTORY;
xs_gDay tValue;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (DateTime::parseGDay(textValue2.c_str(), textValue2.size(), tValue))
@@ -1088,7 +1088,7 @@
store::ItemFactory* factory = GENV_ITEMFACTORY;
xs_gMonth tValue;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (DateTime::parseGMonth(textValue2.c_str(), textValue2.size(), tValue))
@@ -1127,7 +1127,7 @@
store::ItemFactory* factory = GENV_ITEMFACTORY;
Duration tValue;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// Warning: parsing code is not using Xerces
if (0 == Duration::parseDuration(textValue2.c_str(), textValue2.size(), tValue))
@@ -1263,7 +1263,7 @@
store::ItemFactory* factory = GENV_ITEMFACTORY;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
return factory->createAnyURI(result, textValue2);
}
@@ -1289,7 +1289,7 @@
store::ItemFactory* factory = GENV_ITEMFACTORY;
zstring textValue2;
- utf8::normalize_whitespace(textValue, &textValue2);
+ utf8::normalize_space(textValue, &textValue2);
// todo: get the right namespace from the current context
zstring lNamespace;
=== 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 @@
std::vector<zstring>& atomicTextValues)
{
zstring normalizedTextValue;
- utf8::normalize_whitespace(textValue, &normalizedTextValue);
+ utf8::normalize_space(textValue, &normalizedTextValue);
size_t start = 0;
size_t i = 0;
=== 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 @@
// XQ XP Datamodel Spec: http://www.w3.org/TR/xpath-datamodel/
// section 6.7.4 Construction from a PSVI
- if ( !utf8::is_whitespace(textNodeValue) )
+ if ( !utf8::is_space(textNodeValue) )
{
zstring empty;
GENV_ITEMFACTORY->createTextNode(validatedTextNode,
=== 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 @@
}
template<class StringType>
-static void test_normalize_whitespace() {
+static void test_normalize_space() {
StringType const s( " hello world " );
StringType u;
- ascii::normalize_whitespace( s, &u );
+ ascii::normalize_space( s, &u );
ASSERT_TRUE( u == "hello world" );
utf8_string<StringType const> const s8( s );
utf8_string<StringType> u8( u );
- utf8::normalize_whitespace( s8, &u8 );
+ utf8::normalize_space( s8, &u8 );
ASSERT_TRUE( u8 == "hello world" );
}
@@ -493,14 +493,14 @@
ASSERT_TRUE( !utf8::ends_with( u_ab, "a" ) );
}
-static void test_skip_whitespace() {
+static void test_skip_space() {
char const s[] = " hello world";
ascii::size_type const s_len = ::strlen( s );
ascii::size_type pos = 0;
- ascii::skip_whitespace( s, s_len, &pos );
+ ascii::skip_space( s, s_len, &pos );
ASSERT_TRUE( pos == 2 );
pos = 7;
- ascii::skip_whitespace( s, s_len, &pos );
+ ascii::skip_space( s, s_len, &pos );
ASSERT_TRUE( pos == 8 );
}
@@ -673,16 +673,16 @@
}
template<class StringType>
-static void test_trim_whitespace() {
+static void test_trim_space() {
StringType const s( " hello world " );
StringType u;
- ascii::trim_whitespace( s, &u );
+ ascii::trim_space( s, &u );
ASSERT_TRUE( u == "hello world" );
utf8_string<StringType const> const s8( s );
utf8_string<StringType> u8( u );
- utf8::trim_whitespace( s8, &u8 );
+ utf8::trim_space( s8, &u8 );
ASSERT_TRUE( u8 == "hello world" );
}
@@ -854,10 +854,10 @@
test_next_match();
test_next_token();
- test_normalize_whitespace<string>();
- test_normalize_whitespace<zstring>();
- test_normalize_whitespace<zstring_p>();
- test_normalize_whitespace<String>();
+ test_normalize_space<string>();
+ test_normalize_space<zstring>();
+ test_normalize_space<zstring_p>();
+ test_normalize_space<String>();
test_replace_all<string>();
test_replace_all<String>();
@@ -872,7 +872,7 @@
test_reverse<zstring_p>( utf8_aeiou_acute );
test_reverse<String>( utf8_aeiou_acute );
- test_skip_whitespace();
+ test_skip_space();
test_split<string>( "a", "b" );
test_split<zstring>( "a", "b" );
@@ -911,9 +911,9 @@
test_trim_start();
test_trim_end();
- test_trim_whitespace<string>();
- test_trim_whitespace<zstring>();
- test_trim_whitespace<String>();
+ test_trim_space<string>();
+ test_trim_space<zstring>();
+ test_trim_space<String>();
test_uri_encode<string>();
test_uri_encode<String>();
=== 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 @@
///////////////////////////////////////////////////////////////////////////////
-bool is_whitespace( char const *s ) {
+bool is_space( char const *s ) {
for ( ; *s; ++s ) {
if ( !is_space( *s ) )
return false;
=== 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 @@
*
* @param s The string to append to.
*/
- explicit back_ascii_insert_iterator( StringType &s ) : base_type( s ) {
+ explicit back_ascii_insert_iterator( StringType *s ) : base_type( s ) {
}
back_ascii_insert_iterator& operator=( value_type c );
@@ -86,7 +86,7 @@
* @param out The output string.
*/
template<class StringType> inline back_ascii_insert_iterator<StringType>
-back_ascii_inserter( StringType &out ) {
+back_ascii_inserter( StringType *out ) {
return back_ascii_insert_iterator<StringType>( out );
}
@@ -102,7 +102,8 @@
* @return Returns \c true only if the character is an ASCII character.
*/
template<typename CharType> inline
-bool is_ascii( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_ascii( CharType c ) {
#ifdef WIN32
return __isascii( c );
#else
@@ -120,7 +121,8 @@
* @return Returns \c true only if the character is an alphabetic character.
*/
template<typename CharType> inline
-bool is_alpha( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_alpha( CharType c ) {
return is_ascii( c ) && isalpha( c );
}
@@ -134,7 +136,8 @@
* @return Returns \c true only if the character is an alpha-numeric character.
*/
template<typename CharType> inline
-bool is_alnum( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_alnum( CharType c ) {
return is_ascii( c ) && isalnum( c );
}
@@ -148,7 +151,8 @@
* @return Returns \c true only if the character is a control character.
*/
template<typename CharType> inline
-bool is_cntrl( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_cntrl( CharType c ) {
return is_ascii( c ) && iscntrl( c );
}
@@ -162,7 +166,8 @@
* @return Returns \c true only if the character is a decimal digit.
*/
template<typename CharType> inline
-bool is_digit( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_digit( CharType c ) {
return is_ascii( c ) && isdigit( c );
}
@@ -176,7 +181,8 @@
* @return Returns \c true only if the character is a printing character.
*/
template<typename CharType> inline
-bool is_print( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_print( CharType c ) {
return is_ascii( c ) && isprint( c );
}
@@ -190,7 +196,8 @@
* @return Returns \c true only if the character is a punctuation character.
*/
template<typename CharType> inline
-bool is_punct( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_punct( CharType c ) {
return is_ascii( c ) && ispunct( c );
}
@@ -199,12 +206,13 @@
* exists to make a proper function out of the standard isspace(3) that may be
* implemented as a macro.
*
- * @param CharType The character type.
+ * @tparam CharType The character type.
* @param c The character to check.
* @return Returns \c true only if the character is a whitespace character.
*/
template<typename CharType> inline
-bool is_space( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_space( CharType c ) {
return is_ascii( c ) && isspace( c );
}
@@ -214,17 +222,19 @@
* @param s The NULL-terminated C string to check.
* @return Returns \c true only if the entire string is whitespace.
*/
-bool is_whitespace( char const *s );
+bool is_space( char const *s );
/**
* Checks whether an entire string is whitespace.
*
+ * @tparam StringType The string type.
* @param s The string to check.
* @return Returns \c true only if the entire string is whitespace.
*/
template<class StringType> inline
-bool is_whitespace( StringType const &s ) {
- return is_whitespace( s.c_str() );
+typename std::enable_if<ZORBA_HAS_C_STR(StringType),bool>::type
+is_space( StringType const &s ) {
+ return is_space( s.c_str() );
}
/**
@@ -237,7 +247,8 @@
* @return Returns \c true only if the character is a hexadecimal digit.
*/
template<typename CharType> inline
-bool is_xdigit( CharType c ) {
+typename std::enable_if<ZORBA_TR1_NS::is_integral<CharType>::value,bool>::type
+is_xdigit( CharType c ) {
return is_ascii( c ) && isxdigit( c );
}
@@ -263,7 +274,8 @@
* @return Returns \c true only if \a s begins with \a c.
*/
template<class StringType> inline
-bool begins_with( StringType const &s, char c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+begins_with( StringType const &s, char c ) {
return !s.empty() && s[0] == c;
}
@@ -300,8 +312,9 @@
* @return Returns \c true only if \a s begins with \a ps.
*/
template<class StringType> inline
-bool begins_with( StringType const &s, char const *ps,
- typename StringType::size_type n ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+begins_with( StringType const &s, char const *ps,
+ typename StringType::size_type n ) {
typedef typename StringType::traits_type traits_type;
return n <= s.size() && traits_type::compare( s.data(), ps, n ) == 0;
}
@@ -315,7 +328,8 @@
* @return Returns \c true only if \a s begins with \a ps.
*/
template<class StringType> inline
-bool begins_with( StringType const &s, char const *ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+begins_with( StringType const &s, char const *ps ) {
return begins_with( s, ps, std::strlen( ps ) );
}
@@ -329,7 +343,10 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class PrefixStringType> inline
-bool begins_with( StringType const &s, PrefixStringType const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(PrefixStringType),
+ bool>::type
+begins_with( StringType const &s, PrefixStringType const &ps ) {
return begins_with( s, ps.data(), ps.size() );
}
@@ -354,7 +371,8 @@
* @return Returns \c true only if \a s ends with \a c.
*/
template<class StringType> inline
-bool ends_with( StringType const &s, char c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+ends_with( StringType const &s, char c ) {
return !s.empty() && s[ s.size() - 1 ] == c;
}
@@ -392,8 +410,9 @@
* @return Returns \c true only if \a s ends with \a ss.
*/
template<class StringType> inline
-bool ends_with( StringType const &s, char const *ss,
- typename StringType::size_type ss_len ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+ends_with( StringType const &s, char const *ss,
+ typename StringType::size_type ss_len ) {
typename StringType::size_type const result = s.rfind( ss );
return result != StringType::npos && result + ss_len == s.size();
}
@@ -407,7 +426,8 @@
* @return Returns \c true only if \a s ends with \a ss.
*/
template<class StringType> inline
-bool ends_with( StringType const &s, char const *ss ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+ends_with( StringType const &s, char const *ss ) {
return ends_with( s, ss, std::strlen( ss ) );
}
@@ -421,7 +441,10 @@
* @return Returns \c true only if \a s ends with \a ss.
*/
template<class StringType,class SuffixStringType> inline
-bool ends_with( StringType const &s, SuffixStringType const &ss ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(SuffixStringType),
+ bool>::type
+ends_with( StringType const &s, SuffixStringType const &ss ) {
return ends_with( s, ss.data(), ss.size() );
}
@@ -467,7 +490,8 @@
* @param s The string to convert.
*/
template<class StringType> inline
-void to_lower( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_lower( StringType &s ) {
std::transform(
s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_lower )
);
@@ -483,7 +507,10 @@
* contents are overwritten.
*/
template<class InputStringType,class OutputStringType> inline
-void to_lower( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_lower( InputStringType const &in, OutputStringType *out ) {
std::transform(
in.begin(), in.end(), std::back_inserter( *out ),
static_cast<char (*)(char)>( to_lower )
@@ -530,7 +557,8 @@
* @param s The string to convert.
*/
template<class StringType> inline
-void to_upper( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_upper( StringType &s ) {
std::transform(
s.begin(), s.end(), s.begin(), static_cast<char (*)(char)>( to_upper )
);
@@ -546,7 +574,10 @@
* contents are overwritten.
*/
template<class InputStringType,class OutputStringType> inline
-void to_upper( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_upper( InputStringType const &in, OutputStringType *out ) {
std::transform(
in.begin(), in.end(), std::back_inserter( *out ),
static_cast<char (*)(char)>( to_upper )
@@ -588,7 +619,8 @@
* @return Returns \c true only if at least one replacement is performed.
*/
template<class StringType>
-bool replace_all( StringType &s, char from, char to );
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+replace_all( StringType &s, char from, char to );
/**
* Replaces all occurrences of one substring with another.
@@ -602,9 +634,10 @@
* @return Returns \c true only if at least one replacement is performed.
*/
template<class StringType>
-bool replace_all( StringType &s,
- char const *from, typename StringType::size_type from_len,
- char const *to, typename StringType::size_type to_len );
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+replace_all( StringType &s,
+ char const *from, typename StringType::size_type from_len,
+ char const *to, typename StringType::size_type to_len );
/**
* Replaces all occurrences of one substring with another.
@@ -616,7 +649,8 @@
* @return Returns \c true only if at least one replacement is performed.
*/
template<class StringType> inline
-bool replace_all( StringType &s, char const *from, char const *to ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+replace_all( StringType &s, char const *from, char const *to ) {
return replace_all( s, from, std::strlen( from ), to, std::strlen( to ) );
}
@@ -630,7 +664,10 @@
* @return Returns \c true only if at least one replacement is performed.
*/
template<class StringType,class ToStringType> inline
-bool replace_all( StringType &s, char const *from, ToStringType const &to ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(ToStringType),
+ bool>::type
+replace_all( StringType &s, char const *from, ToStringType const &to ) {
return replace_all( s, from, std::strlen( from ), to.data(), to.size() );
}
@@ -644,8 +681,12 @@
* @return Returns \c true only if at least one replacement is performed.
*/
template<class StringType,class FromStringType,class ToStringType> inline
-bool replace_all( StringType &s, FromStringType const &from,
- ToStringType const &to ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(FromStringType)
+ && ZORBA_IS_STRING(ToStringType),
+ bool>::type
+replace_all( StringType &s, FromStringType const &from,
+ ToStringType const &to ) {
return replace_all( s, from.data(), from.size(), to.data(), to.size() );
}
@@ -797,7 +838,10 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType>
-void normalize_whitespace( InputStringType const &in, OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+normalize_space( InputStringType const &in, OutputStringType *out );
/**
* Converts sequences of one or more whitespace characters to a single space.
@@ -807,9 +851,10 @@
* @param s The string.
*/
template<class StringType> inline
-void normalize_whitespace( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+normalize_space( StringType &s ) {
StringType temp;
- normalize_whitespace( s, &temp );
+ normalize_space( s, &temp );
s = temp;
}
@@ -827,11 +872,13 @@
/**
* Removes all characters that are not among the specified characters.
*
+ * @tparam StringType The string type.
* @param s The string to remove characters from.
* @param keep_chars The characters to keep.
*/
template<class StringType>
-void remove_not_chars( StringType &s, char const *keep_chars );
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+remove_not_chars( StringType &s, char const *keep_chars );
/**
* Removes all whitespace characters by shifting the contents of the buffer to
@@ -841,7 +888,7 @@
* @param s_len The length of \a s.
* @return Returns the new length of \a s with all whitespace removed.
*/
-inline size_type remove_whitespace( char *s, size_type s_len ) {
+inline size_type remove_space( char *s, size_type s_len ) {
return remove_chars( s, s_len, whitespace );
}
@@ -855,8 +902,10 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType>
-void trim( InputStringType const &in, char const *chars,
- OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim( InputStringType const &in, char const *chars, OutputStringType *out );
/**
* Removes all leading and trailing specified characters.
@@ -865,7 +914,8 @@
* @param s The string.
*/
template<class StringType> inline
-void trim( StringType &s, char const *chars ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim( StringType &s, char const *chars ) {
StringType temp;
trim( s, chars, &temp );
s = temp;
@@ -917,8 +967,11 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType>
-void trim_start( InputStringType const &in, char const *chars,
- OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_start( InputStringType const &in, char const *chars,
+ OutputStringType *out );
/**
* Removes all leading specified characters.
@@ -928,7 +981,8 @@
* @param chars The characters to trim.
*/
template<class StringType> inline
-void trim_start( StringType &s, char const *chars ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim_start( StringType &s, char const *chars ) {
StringType temp;
trim_start( s, chars, &temp );
s = temp;
@@ -941,7 +995,7 @@
* @return Returns a pointer to the first character in \a s that is not a
* whitespace character.
*/
-inline char const* trim_start_whitespace( char const *s ) {
+inline char const* trim_start_space( char const *s ) {
return trim_start( s, whitespace );
}
@@ -954,7 +1008,7 @@
* @return Returns a pointer to the first character in \a s that is not a
* whitespace character.
*/
-inline char const* trim_start_whitespace( char const *s, size_type *s_len ) {
+inline char const* trim_start_space( char const *s, size_type *s_len ) {
return trim_start( s, s_len, whitespace );
}
@@ -966,7 +1020,7 @@
* @return Returns a pointer to the first character in \a s that is not a
* whitespace character.
*/
-inline char const* trim_start_whitespace( char const *s, size_type s_len ) {
+inline char const* trim_start_space( char const *s, size_type s_len ) {
return trim_start( s, s_len, whitespace );
}
@@ -979,7 +1033,10 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType> inline
-void trim_start_whitespace( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_start_space( InputStringType const &in, OutputStringType *out ) {
trim_start( in, whitespace, out );
}
@@ -990,9 +1047,10 @@
* @param s The string.
*/
template<class StringType> inline
-void trim_start_whitespace( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim_start_space( StringType &s ) {
StringType temp;
- trim_start_whitespace( s, &temp );
+ trim_start_space( s, &temp );
s = temp;
}
@@ -1027,8 +1085,10 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType>
-void trim_end( InputStringType const &in, char const *chars,
- OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_end( InputStringType const &in, char const *chars, OutputStringType *out );
/**
* Removes all trailing specified characters.
@@ -1037,7 +1097,8 @@
* @param s The string.
*/
template<class StringType> inline
-void trim_end( StringType &s, char const *chars ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim_end( StringType &s, char const *chars ) {
StringType temp;
trim_end( s, chars, &temp );
s = temp;
@@ -1050,7 +1111,7 @@
* @param s_len The length of \a s.
* @return Returns the new length of \a s.
*/
-inline size_type trim_end_whitespace( char const *s, size_type s_len ) {
+inline size_type trim_end_space( char const *s, size_type s_len ) {
return trim_end( s, s_len, whitespace );
}
@@ -1060,7 +1121,7 @@
* @param s The string to trim.
* @return Returns the new length of \a s.
*/
-inline size_type trim_end_whitespace( char const *s ) {
+inline size_type trim_end_space( char const *s ) {
return trim_end( s, whitespace );
}
@@ -1073,7 +1134,10 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType>
-void trim_end_whitespace( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_end_space( InputStringType const &in, OutputStringType *out ) {
return trim_end( in, whitespace, out );
}
@@ -1084,12 +1148,13 @@
* @param s The string.
*/
template<class StringType> inline
-void trim_end_whitespace( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim_end_space( StringType &s ) {
trim_end( s, whitespace );
}
/**
- * Removed sll leading and trailing whitespace.
+ * Removes all leading and trailing whitespace.
*
* @param s The input C string.
* @param s_len A pointer to the length of \a s. It is updated with the new
@@ -1097,9 +1162,9 @@
* @return Returns a pointer to the first character in \a s that is not
* whitespace.
*/
-inline char const* trim_whitespace( char const *s, size_type *s_len ) {
- s = trim_start_whitespace( s, s_len );
- *s_len = trim_end_whitespace( s, *s_len );
+inline char const* trim_space( char const *s, size_type *s_len ) {
+ s = trim_start_space( s, s_len );
+ *s_len = trim_end_space( s, *s_len );
return s;
}
@@ -1112,7 +1177,10 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType> inline
-void trim_whitespace( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_space( InputStringType const &in, OutputStringType *out ) {
trim( in, whitespace, out );
}
@@ -1123,9 +1191,10 @@
* @param s The string.
*/
template<class StringType> inline
-void trim_whitespace( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim_space( StringType &s ) {
StringType temp;
- trim_whitespace( s, &temp );
+ trim_space( s, &temp );
s = temp;
}
@@ -1138,10 +1207,10 @@
* @param pos The position within \a s where to start looking for whitespace.
* On return, \a pos is updated with the position of the 1st non-whitespace
* char.
- * @deprecated Use trim_start_whitespace() instead.
+ * @deprecated Use trim_start_space() instead.
*/
-inline void skip_whitespace( char const *s, size_type s_len, size_type *pos ) {
- *pos = trim_start_whitespace( s + *pos, s_len - *pos ) - s;
+inline void skip_space( char const *s, size_type s_len, size_type *pos ) {
+ *pos = trim_start_space( s + *pos, s_len - *pos ) - s;
}
/**
@@ -1155,11 +1224,11 @@
* char.
*/
template<class StringType> inline
-void skip_whitespace( StringType const &s,
- typename StringType::const_iterator *i ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+skip_space( StringType const &s, typename StringType::const_iterator *i ) {
typename StringType::difference_type const d = *i - s.begin();
char const *const sd = s.data() + d;
- std::advance( *i, trim_start_whitespace( sd, s.size() - d ) - sd );
+ std::advance( *i, trim_start_space( sd, s.size() - d ) - sd );
}
////////// Miscellaneous //////////////////////////////////////////////////////
@@ -1174,8 +1243,8 @@
* @return Returns \c *s.
*/
template<class StringType> inline
-StringType& left_pad( StringType *s, typename StringType::size_type width,
- char c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
+left_pad( StringType *s, typename StringType::size_type width, char c ) {
typedef typename StringType::size_type size_type;
if ( s->size() < width )
s->insert( static_cast<size_type>( 0 ), width - s->size(), c );
@@ -1192,8 +1261,8 @@
* @return Returns \c *s.
*/
template<class StringType> inline
-StringType& right_pad( StringType *s, typename StringType::size_type width,
- char c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
+right_pad( StringType *s, typename StringType::size_type width, char c ) {
if ( s->size() < width )
s->append( width - s->size(), c );
return *s;
@@ -1222,7 +1291,10 @@
* @param out The output string.
*/
template<class InputStringType,class OutputStringType> inline
-void reverse( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+reverse( InputStringType const &in, OutputStringType *out ) {
std::reverse_copy( in.begin(), in.end(), std::back_inserter( *out ) );
}
=== 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 @@
///////////////////////////////////////////////////////////////////////////////
template<class InputStringType,class OutputStringType>
-void normalize_whitespace( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+normalize_space( InputStringType const &in, OutputStringType *out ) {
typedef typename InputStringType::const_iterator const_iterator;
const_iterator i( in.begin() );
const_iterator const j( in.end() );
@@ -56,14 +59,16 @@
}
template<class StringType>
-void remove_not_chars( StringType &s, char const *keep_chars ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+remove_not_chars( StringType &s, char const *keep_chars ) {
typename StringType::size_type pos = 0;
while ( (pos = s.find_first_not_of( keep_chars, pos )) != StringType::npos )
s.erase( pos, 1 );
}
template<class StringType>
-bool replace_all( StringType &s, char from, char to ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+replace_all( StringType &s, char from, char to ) {
bool replaced_any = false;
for ( typename StringType::size_type pos = 0; pos < s.size(); ++pos ) {
if ( (pos = s.find( from, pos )) == StringType::npos )
@@ -75,9 +80,10 @@
}
template<class StringType>
-bool replace_all( StringType &s,
- char const *from, typename StringType::size_type from_len,
- char const *to, typename StringType::size_type to_len ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+replace_all( StringType &s,
+ char const *from, typename StringType::size_type from_len,
+ char const *to, typename StringType::size_type to_len ) {
bool replaced_any = false;
for ( typename StringType::size_type pos = 0;
pos + from_len <= s.size(); pos += to_len ) {
@@ -90,8 +96,10 @@
}
template<class InputStringType,class OutputStringType>
-void trim( InputStringType const &in, char const *chars,
- OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim( InputStringType const &in, char const *chars, OutputStringType *out ) {
*out = in;
typename OutputStringType::size_type pos = out->find_first_not_of( chars );
out->erase( 0, pos );
@@ -101,52 +109,28 @@
}
template<class InputStringType,class OutputStringType>
-void trim_start( InputStringType const &in, char const *chars,
- OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_start( InputStringType const &in, char const *chars,
+ OutputStringType *out ) {
*out = in;
typename OutputStringType::size_type pos = out->find_first_not_of( chars );
out->erase( 0, pos );
}
template<class InputStringType,class OutputStringType>
-void trim_end( InputStringType const &in, char const *chars,
- OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_end( InputStringType const &in, char const *chars,
+ OutputStringType *out ) {
*out = in;
typename OutputStringType::size_type pos = out->find_last_not_of( chars );
if ( pos != OutputStringType::npos && ++pos < out->size() )
out->erase( pos );
}
-template<class InputStringType,class OutputStringType>
-void uri_decode( InputStringType const &in, OutputStringType *out ) {
- extern signed char const hex2dec[];
-
- typedef typename InputStringType::const_iterator const_iterator;
- const_iterator i( in.begin() );
- const_iterator const j( in.end() );
-
- out->reserve( out->size() + in.size() );
- for ( ; i != j; ++i ) {
- char c = *i;
- if ( c == '%' ) {
- const_iterator k = i;
- do {
- if ( ++k == j )
- break;
- signed char const c1 = hex2dec[ static_cast<unsigned>( *k ) & 0xFF ];
- if ( c1 == -1 || ++k == j )
- break;
- signed char const c2 = hex2dec[ static_cast<unsigned>( *k ) & 0xFF ];
- if ( c2 == -1 )
- break;
- c = static_cast<char>( (c1 << 4) | c2 );
- i = k;
- } while ( false );
- }
- out->push_back( c );
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
} // namespace ascii
=== 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 @@
#ifndef ZORBA_BASE64_UTIL_H
#define ZORBA_BASE64_UTIL_H
+// standard
#include <iostream>
#include <stdexcept>
#include <sys/types.h> /* for size_t */
#include <vector>
+// Zorba
+#include <zorba/internal/ztd.h>
#include "cxx_util.h"
#include "stream_util.h"
@@ -132,8 +135,9 @@
* invalid byte is encountered.
*/
template<class ToStringType>
-size_type decode( char const *from, size_type from_len, ToStringType *to,
- int options = dopt_none ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+decode( char const *from, size_type from_len, ToStringType *to,
+ int options = dopt_none ) {
size_type decoded = 0;
if ( from_len ) {
typename ToStringType::size_type const orig_size = to->size();
@@ -175,8 +179,8 @@
* invalid byte is encountered.
*/
template<class ToStringType>
-size_type decode( std::istream &from, ToStringType *to,
- int options = dopt_none ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+decode( std::istream &from, ToStringType *to, int options = dopt_none ) {
bool const ignore_ws = !!(options & dopt_ignore_ws);
size_type total_decoded = 0;
while ( !from.eof() ) {
@@ -279,7 +283,8 @@
* @return Returns the number of encoded bytes.
*/
template<class ToStringType>
-size_type encode( char const *from, size_type from_len, ToStringType *to ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+encode( char const *from, size_type from_len, ToStringType *to ) {
size_type encoded = 0;
if ( from_len ) {
typename ToStringType::size_type const orig_size = to->size();
@@ -307,7 +312,8 @@
* @return Returns the number of encoded bytes.
*/
template<class ToStringType>
-size_type encode( std::istream &from, ToStringType *to ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+encode( std::istream &from, ToStringType *to ) {
size_type total_encoded = 0;
while ( !from.eof() ) {
char from_buf[ 1024 * 3 ], to_buf[ 1024 * 4 ];
=== 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 @@
* @return Returns said error string.
*/
template<class StringType> inline
-typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- std::string
->::type
+typename std::enable_if<ZORBA_HAS_C_STR(StringType),std::string>::type
get_err_string( StringType const &function, code_type code = get_err_code() ) {
return get_err_string( function.c_str(), code );
}
=== 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 @@
* @param path The full path of the directory to change to.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
chdir( PathStringType const &path ) {
chdir( path.c_str() );
}
@@ -158,9 +156,7 @@
* @throws fs::exception if the creation fails.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
mkdir( PathStringType const &path ) {
mkdir( path.c_str() );
}
@@ -191,10 +187,8 @@
*/
template<class PathStringType>
iterator( PathStringType const &path,
- typename std::enable_if<
- ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value
- >::type* = 0 ) : dir_path_( path.c_str() ) {
+ typename std::enable_if<ZORBA_HAS_C_STR(PathStringType)
+ >::type* = 0 ) : dir_path_( path.c_str() ) {
ctor_impl();
}
@@ -292,9 +286,7 @@
* @throws fs::exception if the creation failed.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
create( PathStringType const &path ) {
create( path.c_str() );
}
@@ -321,9 +313,7 @@
* @return Returns \c true only if the file or directory was removed.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- bool>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),bool>::type
remove( PathStringType const &path ) {
return remove( path.c_str() );
}
@@ -510,9 +500,7 @@
* then returns \a path.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- char const*>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),char const*>::type
base_name( PathStringType const &path ) {
return base_name( path.c_str() );
}
@@ -546,9 +534,7 @@
* \a path does not refer to a symbolic link, returns the type of \a path.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- type>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),type>::type
get_type( PathStringType const &path, bool follow_symlink = true,
size_type *size = nullptr ) {
return get_type( path.c_str(), follow_symlink, size );
@@ -580,9 +566,7 @@
* @return Returns \c true only if the path is absolute.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- bool>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),bool>::type
is_absolute( PathStringType const &path ) {
return is_absolute( path.c_str() );
}
@@ -609,9 +593,7 @@
* @throws fs::exception if the rename fails.
*/
template<class FromStringType> inline
-typename std::enable_if<ztd::has_c_str<FromStringType,
- char const* (FromStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_HAS_C_STR(FromStringType),void>::type
rename( FromStringType const &from, char const *to ) {
rename( from.c_str(), to );
}
@@ -625,9 +607,7 @@
* @throws fs::exception if the rename fails.
*/
template<class ToStringType> inline
-typename std::enable_if<ztd::has_c_str<ToStringType,
- char const* (ToStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_HAS_C_STR(ToStringType),void>::type
rename( char const *from, ToStringType const &to ) {
rename( from, to.c_str() );
}
@@ -642,10 +622,8 @@
* @throws fs::exception if the rename fails.
*/
template<class FromStringType,class ToStringType> inline
-typename std::enable_if<ztd::has_c_str<FromStringType,
- char const* (FromStringType::*)() const>::value
- && ztd::has_c_str<ToStringType,
- char const* (ToStringType::*)() const>::value,
+typename std::enable_if<ZORBA_HAS_C_STR(FromStringType)
+ && ZORBA_HAS_C_STR(ToStringType),
void>::type
rename( FromStringType const &from, ToStringType const &to ) {
rename( from.c_str(), to.c_str() );
@@ -675,9 +653,7 @@
* @throws XQueryException err::XPTY0004 for malformed paths.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- zstring>::type
+typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),zstring>::type
get_normalized_path( PathStringType const &path,
PathStringType const &base = "" ) {
return get_normalized_path( path.c_str(), base.c_str() );
@@ -693,9 +669,7 @@
* @throws XQueryException err::XPTY0004 for malformed paths.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
normalize_path( PathStringType &path, PathStringType const &base = "" ) {
path = get_normalized_path( path, base );
}
@@ -711,9 +685,7 @@
* @param path2 The path to append.
*/
template<class PathStringType1> inline
-typename std::enable_if<ztd::has_c_str<PathStringType1,
- char const* (PathStringType1::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_IS_STRING(PathStringType1),void>::type
append( PathStringType1 &path1, char const *path2 ) {
if ( !ascii::ends_with( path1, dir_separator ) )
path1 += dir_separator;
@@ -729,10 +701,8 @@
* @param path2 The path to append.
*/
template<class PathStringType1,class PathStringType2> inline
-typename std::enable_if<ztd::has_c_str<PathStringType1,
- char const* (PathStringType1::*)() const>::value
- && ztd::has_c_str<PathStringType2,
- char const* (PathStringType2::*)() const>::value,
+typename std::enable_if<ZORBA_IS_STRING(PathStringType1)
+ && ZORBA_HAS_C_STR(PathStringType2),
void>::type
append( PathStringType1 &path1, PathStringType2 const &path2 ) {
append( path1, path2.c_str() );
@@ -745,9 +715,7 @@
* @param path The path to make absolute.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
make_absolute( PathStringType &path ) {
if ( !is_absolute( path ) ) {
#ifndef WIN32
@@ -783,9 +751,7 @@
* @throws fs::exception if the operation fails.
*/
template<class PathStringType> inline
-typename std::enable_if<ztd::has_c_str<PathStringType,
- char const* (PathStringType::*)() const>::value,
- void>::type
+typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
get_temp_file( PathStringType *path ) {
char path_buf[ MAX_PATH ];
get_temp_file( path_buf );
=== 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 @@
int options ) {
bool const ignore_ws = !!(options & dopt_ignore_ws);
if ( ignore_ws )
- from = ascii::trim_whitespace( from, &from_len );
+ from = ascii::trim_space( from, &from_len );
if ( from_len % 2 )
throw invalid_argument( "HexBinary length is not a multiple of 2" );
@@ -107,7 +107,7 @@
std::vector<char> *to, int options ) {
bool const ignore_ws = !!(options & dopt_ignore_ws);
if ( ignore_ws )
- from = ascii::trim_whitespace( from, &from_len );
+ from = ascii::trim_space( from, &from_len );
if ( from_len % 2 )
throw invalid_argument( "HexBinary length is not a multiple of 2" );
size_type decoded = 0;
=== 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 @@
* @throws hexbinary::exception if an invalid byte is encountered.
*/
template<class ToStringType>
-size_type decode( char const *from, size_type from_len, ToStringType *to,
- int options = dopt_none ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+decode( char const *from, size_type from_len, ToStringType *to,
+ int options = dopt_none ) {
size_type decoded = 0;
if ( from_len ) {
typename ToStringType::size_type const orig_size = to->size();
@@ -168,7 +169,8 @@
* @throws hexbinary::exception if an invalid byte is encountered.
*/
template<class ToStringType>
-size_type decode( std::istream &from, ToStringType *to,
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+decode( std::istream &from, ToStringType *to,
int options = dopt_none ) {
bool const ignore_ws = !!(options & dopt_ignore_ws);
size_type total_decoded = 0;
@@ -269,7 +271,8 @@
* @return Returns the number of encoded bytes.
*/
template<class ToStringType>
-size_type encode( char const *from, size_type from_len, ToStringType *to ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+encode( char const *from, size_type from_len, ToStringType *to ) {
size_type encoded = 0;
if ( from_len ) {
typename ToStringType::size_type const orig_size = to->size();
@@ -296,7 +299,8 @@
* @return Returns the number of encoded bytes.
*/
template<class ToStringType>
-size_type encode( std::istream &from, ToStringType *to ) {
+typename std::enable_if<ZORBA_IS_STRING(ToStringType),size_type>::type
+encode( std::istream &from, ToStringType *to ) {
size_type total_encoded = 0;
while ( !from.eof() ) {
char from_buf[ 1024 * 2 ], to_buf[ 1024 ];
=== 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 @@
// "ASCII", so check for "US-ASCII" ourselves.
//
zstring charset( cc_charset );
- ascii::trim_whitespace( charset );
+ ascii::trim_space( charset );
ascii::to_upper( charset );
if ( charset == "US-ASCII" )
cc_charset += 3; // skip "US-"
=== 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 @@
* @return Returns \a os.
*/
template<class StringType> inline
-typename std::enable_if<ztd::has_c_str<StringType,
- char const* (StringType::*)() const>::value,
- std::ostream&>::type
+typename std::enable_if<ZORBA_HAS_C_STR(StringType),std::ostream&>::type
serialize( std::ostream &os, StringType const &s ) {
return serialize( os, s.c_str() );
}
=== 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 @@
if ( !*cc_charset )
throw invalid_argument( "empty charset" );
zstring charset( cc_charset );
- ascii::trim_whitespace( charset );
+ ascii::trim_space( charset );
ascii::to_upper( charset );
return charset != "ASCII"
&& charset != "US-ASCII"
=== 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 @@
}
protected:
- back_insert_iterator_base( ContainerType &c ) : container( &c ) {
+ back_insert_iterator_base( ContainerType *c ) : container( c ) {
}
/**
=== 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 @@
while ( buf < buf_end ) {
is.read( buf, n );
if ( streamsize read = is.gcount() ) {
- read = ascii::remove_whitespace(
+ read = ascii::remove_space(
buf, static_cast<ascii::size_type>( read )
);
buf += read, n -= read;
=== 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 @@
//
// We have to check for '-' ourselves since strtoull(3) allows it (oddly).
//
- buf = ascii::trim_start_whitespace( buf );
+ buf = ascii::trim_start_space( buf );
bool const minus = *buf == '-';
unsigned long long const result = std::strtoull( buf, (char**)last, 10 );
@@ -153,7 +153,7 @@
long long atoll( char const *buf, char const *end, char const **last ) {
aton_context const ctx( last );
long long n = 0;
- char const *s0 = ascii::trim_start_whitespace( buf, end - buf );
+ char const *s0 = ascii::trim_start_space( buf, end - buf );
char const *s = s0;
if ( s < end ) {
@@ -190,7 +190,7 @@
char const **last ) {
aton_context const ctx( last );
unsigned long long n = 0;
- char const *s0 = ascii::trim_start_whitespace( buf, end - buf );
+ char const *s0 = ascii::trim_start_space( buf, end - buf );
char const *s = s0;
if ( s < end ) {
=== 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 @@
* @return Returns \c true only if \a s1 \c == \a s2.
*/
template<class StringType> inline
-bool equals( StringType const &s1, char const *s2,
- typename StringType::size_type s2_n ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+equals( StringType const &s1, char const *s2,
+ typename StringType::size_type s2_n ) {
typedef typename StringType::traits_type traits_type;
return s1.size() == s2_n && traits_type::compare( s1.data(), s2, s2_n ) == 0;
}
@@ -186,8 +187,9 @@
* @return Returns \c true only if \a s1 \c == \a s2.
*/
template<class StringType> inline
-bool equals( char const *s1, typename StringType::size_type s1_n,
- StringType const &s2 ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+equals( char const *s1, typename StringType::size_type s1_n,
+ StringType const &s2 ) {
typedef typename StringType::traits_type traits_type;
return s1_n == s2.size() && traits_type::compare( s1, s2.data(), s1_n ) == 0;
}
@@ -215,8 +217,11 @@
* present in \a in).
*/
template<class OutputStringType1,class OutputStringType2>
-bool split( char const *in, char delim, OutputStringType1 *out1,
- OutputStringType2 *out2 ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType1)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( char const *in, char delim, OutputStringType1 *out1,
+ OutputStringType2 *out2 ) {
if ( char const *const pos = std::strchr( in, delim ) ) {
if ( out1 )
*out1 = OutputStringType1( in, pos - in );
@@ -229,13 +234,15 @@
// Allows out1 to be nullptr.
template<class OutputStringType2> inline
-bool split( char const *in, char delim, void*, OutputStringType2 *out2 ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType2),bool>::type
+split( char const *in, char delim, void*, OutputStringType2 *out2 ) {
return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
}
// Allows out2 to be nullptr.
template<class OutputStringType1> inline
-bool split( char const *in, char delim, OutputStringType1 *out1, void* ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType1),bool>::type
+split( char const *in, char delim, OutputStringType1 *out1, void* ) {
return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
}
@@ -255,22 +262,31 @@
* present in \a in).
*/
template<class InputStringType,class OutputStringType1,class OutputStringType2>
-inline bool split( InputStringType const &in, char delim,
+inline
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType1)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( InputStringType const &in, char delim,
OutputStringType1 *out1, OutputStringType2 *out2 ) {
return split( in.c_str(), delim, out1, out2 );
}
// Allows out1 to be nullptr.
template<class InputStringType,class OutputStringType2> inline
-bool split( InputStringType const &in, char delim, void*,
- OutputStringType2 *out2 ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( InputStringType const &in, char delim, void*, OutputStringType2 *out2 ) {
return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
}
// Allows out2 to be nullptr.
template<class InputStringType,class OutputStringType1> inline
-bool split( InputStringType const &in, char delim, OutputStringType1 *out1,
- void* ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType1),
+ bool>::type
+split( InputStringType const &in, char delim, OutputStringType1 *out1, void* ) {
return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
}
@@ -289,8 +305,11 @@
* present in \a in).
*/
template<class OutputStringType1,class OutputStringType2>
-bool split( char const *in, char const *delim, OutputStringType1 *out1,
- OutputStringType2 *out2 ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType1)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( char const *in, char const *delim, OutputStringType1 *out1,
+ OutputStringType2 *out2 ) {
if ( *delim )
if ( char const *const pos = std::strstr( in, delim ) ) {
if ( out1 )
@@ -304,15 +323,15 @@
// Allows out1 to be nullptr.
template<class OutputStringType2> inline
-bool split( char const *in, char const *delim, void*,
- OutputStringType2 *out2 ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType2),bool>::type
+split( char const *in, char const *delim, void*, OutputStringType2 *out2 ) {
return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
}
// Allows out2 to be nullptr.
template<class OutputStringType1> inline
-bool split( char const *in, char const *delim, OutputStringType1 *out1,
- void* ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType1),bool>::type
+split( char const *in, char const *delim, OutputStringType1 *out1, void* ) {
return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
}
@@ -332,22 +351,33 @@
* present in \a in).
*/
template<class InputStringType,class OutputStringType1,class OutputStringType2>
-inline bool split( InputStringType const &in, char const *delim,
- OutputStringType1 *out1, OutputStringType2 *out2 ) {
+inline
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType1)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( InputStringType const &in, char const *delim, OutputStringType1 *out1,
+ OutputStringType2 *out2 ) {
return split( in.c_str(), delim, out1, out2 );
}
// Allows out1 to be nullptr.
template<class InputStringType,class OutputStringType2> inline
-bool split( InputStringType const &in, char const *delim, void*,
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( InputStringType const &in, char const *delim, void*,
OutputStringType2 *out2 ) {
return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
}
// Allows out2 to be nullptr.
template<class InputStringType,class OutputStringType1> inline
-bool split( InputStringType const &in, char const *delim,
- OutputStringType1 *out1, void* ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType1),
+ bool>::type
+split( InputStringType const &in, char const *delim, OutputStringType1 *out1,
+ void* ) {
return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
}
@@ -373,8 +403,13 @@
class OutputStringType1,
class OutputStringType2
>
-bool split( InputStringType const &in, DelimStringType const &delim,
- OutputStringType1 *out1, OutputStringType2 *out2 ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(DelimStringType)
+ && ZORBA_IS_STRING(OutputStringType1)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( InputStringType const &in, DelimStringType const &delim,
+ OutputStringType1 *out1, OutputStringType2 *out2 ) {
typename InputStringType::size_type const pos = in.find( delim );
if ( pos != InputStringType::npos ) {
if ( out1 )
@@ -387,24 +422,26 @@
}
// Allows out1 to be nullptr.
-template<
- class InputStringType,
- class DelimStringType,
- class OutputStringType2
->
-inline bool split( InputStringType const &in, DelimStringType const &delim,
- void*, OutputStringType2 *out2 ) {
+template<class InputStringType,class DelimStringType,class OutputStringType2>
+inline
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(DelimStringType)
+ && ZORBA_IS_STRING(OutputStringType2),
+ bool>::type
+split( InputStringType const &in, DelimStringType const &delim, void*,
+ OutputStringType2 *out2 ) {
return split( in, delim, static_cast<OutputStringType2*>( nullptr ), out2 );
}
// Allows out2 to be nullptr.
-template<
- class InputStringType,
- class DelimStringType,
- class OutputStringType1
->
-inline bool split( InputStringType const &in, DelimStringType const &delim,
- OutputStringType1 *out1, void* ) {
+template<class InputStringType,class DelimStringType,class OutputStringType1>
+inline
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(DelimStringType)
+ && ZORBA_IS_STRING(OutputStringType1),
+ bool>::type
+split( InputStringType const &in, DelimStringType const &delim,
+ OutputStringType1 *out1, void* ) {
return split( in, delim, out1, static_cast<OutputStringType1*>( nullptr ) );
}
@@ -846,7 +883,8 @@
template<typename T,class OutputStringType> inline
typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value
&& !ZORBA_TR1_NS::is_integral<T>::value
- && has_insertion_operator<T>::value,
+ && has_insertion_operator<T>::value
+ && ZORBA_IS_STRING(OutputStringType),
void>::type
to_string( T const &t, OutputStringType *out ) {
std::ostringstream o;
@@ -863,7 +901,9 @@
* @param out The output string.
*/
template<typename T,class OutputStringType> inline
-typename std::enable_if<ZORBA_TR1_NS::is_integral<T>::value,void>::type
+typename std::enable_if<ZORBA_TR1_NS::is_integral<T>::value
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
to_string( T t, OutputStringType *out ) {
ascii::itoa_buf_type buf;
*out = ascii::itoa( t, buf );
@@ -882,7 +922,8 @@
*/
template<class T,class OutputStringType> inline
typename std::enable_if<!has_insertion_operator<T>::value
- && has_c_str<T,char const* (T::*)() const>::value,
+ && ZORBA_HAS_C_STR(T)
+ && ZORBA_IS_STRING(OutputStringType),
void>::type
to_string( T const &t, OutputStringType *out ) {
*out = t.c_str();
@@ -903,9 +944,10 @@
*/
template<class T,class OutputStringType> inline
typename std::enable_if<!has_insertion_operator<T>::value
- && !has_c_str<T,char const* (T::*)() const>::value
+ && !ZORBA_HAS_C_STR(T)
&& has_str<T,std::string (T::*)() const>::value
- && !has_toString<T,std::string (T::*)() const>::value,
+ && !has_toString<T,std::string (T::*)() const>::value
+ && ZORBA_IS_STRING(OutputStringType),
void>::type
to_string( T const &t, OutputStringType *out ) {
*out = t.str();
@@ -926,9 +968,10 @@
*/
template<class T,class OutputStringType> inline
typename std::enable_if<!has_insertion_operator<T>::value
- && !has_c_str<T,char const* (T::*)() const>::value
+ && !ZORBA_HAS_C_STR(T)
&& !has_str<T,std::string (T::*)() const>::value
- && has_toString<T,std::string (T::*)() const>::value,
+ && has_toString<T,std::string (T::*)() const>::value
+ && ZORBA_IS_STRING(OutputStringType),
void>::type
to_string( T const &t, OutputStringType *out ) {
*out = t.toString();
@@ -944,7 +987,9 @@
* the result of \c to_string(*p); otherwise \c "<null>".
*/
template<typename T,class OutputStringType> inline
-typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value,void>::type
+typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
to_string( T p, OutputStringType *out ) {
typedef typename ZORBA_TR1_NS::remove_pointer<T>::type const* T_const_ptr;
if ( p )
@@ -961,7 +1006,8 @@
* @param out The output string.
*/
template<class OutputStringType> inline
-void to_string( char const *s, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(OutputStringType),void>::type
+to_string( char const *s, OutputStringType *out ) {
*out = s ? s : "<null>";
}
=== 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 @@
invalid_value_value::invalid_value_value( char const *buf, size_t len ) :
value_( buf, min_len( buf, len ) )
{
- ascii::trim_end_whitespace( value_ );
+ ascii::trim_end_space( value_ );
}
template<typename ValueType>
@@ -308,7 +308,7 @@
throw insufficient_buffer();
if ( ascii::is_space( c ) ) {
- bp = ascii::trim_start_whitespace( bp );
+ bp = ascii::trim_start_space( bp );
continue;
}
@@ -441,7 +441,7 @@
case 'n': // newline
case 't': // tab
CHECK_ALT(0);
- bp = ascii::trim_start_whitespace( bp );
+ bp = ascii::trim_start_space( bp );
break;
case 'O': // "%O?" alternative conversion modifier
=== 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 @@
// Template version of parse().
//
template<class BufferType> inline
-typename std::enable_if<
- ztd::has_c_str<BufferType,char const* (BufferType::*)() const>::value,
- char const*
->::type
+typename std::enable_if<ZORBA_HAS_C_STR(BufferType),char const*>::type
parse( BufferType const &buf, char const *fmt,
locale::iso639_1::type lang, locale::iso3166_1::type country,
ztm *tm, unsigned *set_fields = nullptr ) {
@@ -420,10 +417,7 @@
// Template version of parse().
//
template<class FormatType> inline
-typename std::enable_if<
- ztd::has_c_str<FormatType,char const* (FormatType::*)() const>::value,
- char const*
->::type
+typename std::enable_if<ZORBA_HAS_C_STR(FormatType),char const*>::type
parse( char const *buf, FormatType const &fmt,
locale::iso639_1::type lang, locale::iso3166_1::type country,
ztm *tm, unsigned *set_fields = nullptr ) {
@@ -434,11 +428,9 @@
// Template version of parse().
//
template<class BufferType,class FormatType> inline
-typename std::enable_if<
- ztd::has_c_str<BufferType,char const* (BufferType::*)() const>::value &&
- ztd::has_c_str<FormatType,char const* (FormatType::*)() const>::value,
- char const*
->::type
+typename std::enable_if<ZORBA_HAS_C_STR(BufferType)
+ && ZORBA_HAS_C_STR(FormatType),
+ char const*>::type
parse( BufferType const &buf, FormatType const &fmt,
locale::iso639_1::type lang, locale::iso3166_1::type country,
ztm *tm, unsigned *set_fields = nullptr ) {
=== 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 @@
// Template version of find().
//
template<class StringType> inline
- typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- type
- >::type
+ typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
find( StringType const &calendar ) {
return find( calendar.c_str() );
}
=== 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 @@
* @param out The Unicode string result.
* @return Returns \c true only if the conversion succeeded.
*/
-template<class StringType>
-inline bool to_string( StringType const &in, string *out ) {
+template<class StringType> inline
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( StringType const &in, string *out ) {
return to_string( in.data(), static_cast<size_type>( in.size() ), out );
}
=== 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 @@
* or scheme::none (if none).
*/
template<class StringType> inline
-scheme get_scheme( StringType const &uri, StringType *sname = nullptr ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),scheme>::type
+get_scheme( StringType const &uri, StringType *sname = nullptr ) {
char const *colon;
scheme const s = get_scheme( uri.c_str(), &colon );
if ( sname && s )
@@ -109,7 +110,7 @@
* @param s The string to append to.
* @param encode_slash If \c true, encodes the '/' character also.
*/
- explicit back_insert_iterator( StringType &s, bool encode_slash = false )
+ explicit back_insert_iterator( StringType *s, bool encode_slash = false )
: base_type( s ), encode_slash_( encode_slash )
{
buf_[0] = '%';
@@ -129,8 +130,10 @@
* @param out The output string.
* @param encode_slash If \c true, encodes the '/' character also.
*/
-template<class StringType> inline back_insert_iterator<StringType>
-back_inserter( StringType &out, bool encode_slash = false ) {
+template<class StringType> inline
+typename std::enable_if<ZORBA_IS_STRING(StringType),
+ back_insert_iterator<StringType> >::type
+back_inserter( StringType *out, bool encode_slash = false ) {
return back_insert_iterator<StringType>( out, encode_slash );
}
@@ -144,7 +147,10 @@
* contents are appended to.
*/
template<class InputStringType,class OutputStringType>
-void decode( InputStringType const &in, OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+decode( InputStringType const &in, OutputStringType *out );
/**
* Percent-decodes (%xx) illegal URI characters.
@@ -153,7 +159,8 @@
* @param s The string.
*/
template<class StringType> inline
-void decode( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+decode( StringType &s ) {
StringType temp;
decode( s, &temp );
s = temp;
@@ -170,9 +177,12 @@
* @param encode_slash Encodes the slash character ("/") only if \c true.
*/
template<class InputStringType,class OutputStringType> inline
-void encode( InputStringType const &in, OutputStringType *out,
- bool encode_slash = true ) {
- std::copy( in.begin(), in.end(), back_inserter( *out, encode_slash ) );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+encode( InputStringType const &in, OutputStringType *out,
+ bool encode_slash = true ) {
+ std::copy( in.begin(), in.end(), back_inserter( out, encode_slash ) );
}
/**
@@ -183,7 +193,8 @@
* @param encode_slash Encodes the slash character ("/") only if \c true.
*/
template<class StringType> inline
-void encode( StringType &s, bool encode_slash = true ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+encode( StringType &s, bool encode_slash = true ) {
StringType temp;
encode( s, &temp, encode_slash );
s = temp;
@@ -204,7 +215,8 @@
* local file is a created temporary file; \c false otherwise.
*/
template<class PathStringType> inline
-void fetch( char const *uri, PathStringType *path, bool *is_temp = nullptr ) {
+typename std::enable_if<ZORBA_IS_STRING(PathStringType),void>::type
+fetch( char const *uri, PathStringType *path, bool *is_temp = nullptr ) {
char path_buf[ MAX_PATH ];
fetch_to_path_impl( uri, path_buf, is_temp );
*path = path_buf;
@@ -221,8 +233,11 @@
* local file is a created temporary file; \c false otherwise.
*/
template<class URIStringType,class PathStringType> inline
-void fetch( URIStringType const &uri, PathStringType *file,
- bool *is_temp = nullptr ) {
+typename std::enable_if<ZORBA_HAS_C_STR(URIStringType)
+ && ZORBA_IS_STRING(PathStringType),
+ void>::type
+fetch( URIStringType const &uri, PathStringType *file,
+ bool *is_temp = nullptr ) {
fetch( uri.c_str(), file, is_temp );
}
=== 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 @@
///////////////////////////////////////////////////////////////////////////////
template<class InputStringType,class OutputStringType>
-void decode( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+decode( InputStringType const &in, OutputStringType *out ) {
extern signed char const hex2dec[];
typedef typename InputStringType::const_iterator const_iterator;
=== 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 @@
using ascii::begins_with;
using ascii::ends_with;
-using ascii::is_whitespace;
-using ascii::normalize_whitespace;
-using ascii::trim_whitespace;
+using ascii::is_space;
+using ascii::normalize_space;
+using ascii::trim_space;
////////// begins/ends_with ///////////////////////////////////////////////////
@@ -59,7 +59,8 @@
* @return Returns \c true only if \a s begins with \a c.
*/
template<class StringType> inline
-bool begins_with( utf8_string<StringType> const &s, char c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+begins_with( utf8_string<StringType> const &s, char c ) {
return ascii::begins_with( *s.get(), c );
}
@@ -73,8 +74,9 @@
* @return Returns \c true only if \a s begins with \a ps.
*/
template<class StringType> inline
-bool begins_with( utf8_string<StringType> const &s, char const *ps,
- typename StringType::size_type n ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+begins_with( utf8_string<StringType> const &s, char const *ps,
+ typename StringType::size_type n ) {
return ascii::begins_with( *s.get(), ps, n );
}
@@ -87,7 +89,8 @@
* @return Returns \c true only if \a s begins with \a ps.
*/
template<class StringType> inline
-bool begins_with( utf8_string<StringType> const &s, char const *ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+begins_with( utf8_string<StringType> const &s, char const *ps ) {
return ascii::begins_with( *s.get(), ps );
}
@@ -101,8 +104,10 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class PrefixStringType> inline
-bool begins_with( utf8_string<StringType> const &s,
- PrefixStringType const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(PrefixStringType),
+ bool>::type
+begins_with( utf8_string<StringType> const &s, PrefixStringType const &ps ) {
return ascii::begins_with( *s.get(), ps.data(), ps.size() );
}
@@ -116,8 +121,10 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class PrefixStringType> inline
-bool begins_with( StringType const &s,
- utf8_string<PrefixStringType> const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(PrefixStringType),
+ bool>::type
+begins_with( StringType const &s, utf8_string<PrefixStringType> const &ps ) {
return ascii::begins_with( s, *ps.get() );
}
@@ -131,8 +138,11 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class PrefixStringType> inline
-bool begins_with( utf8_string<StringType> const &s,
- utf8_string<PrefixStringType> const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(PrefixStringType),
+ bool>::type
+begins_with( utf8_string<StringType> const &s,
+ utf8_string<PrefixStringType> const &ps ) {
return ascii::begins_with( *s.get(), *ps.get() );
}
@@ -146,7 +156,8 @@
* @return Returns \c true only if \a s ends with \a c.
*/
template<class StringType> inline
-bool ends_with( utf8_string<StringType> const &s, char c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+ends_with( utf8_string<StringType> const &s, char c ) {
return ascii::ends_with( *s.get(), c );
}
@@ -160,8 +171,9 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType> inline
-bool ends_with( utf8_string<StringType> const &s, char const *ps,
- typename StringType::size_type n ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+ends_with( utf8_string<StringType> const &s, char const *ps,
+ typename StringType::size_type n ) {
return ascii::ends_with( *s.get(), ps, n );
}
@@ -174,7 +186,8 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType> inline
-bool ends_with( utf8_string<StringType> const &s, char const *ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+ends_with( utf8_string<StringType> const &s, char const *ps ) {
return ascii::ends_with( *s.get(), ps );
}
@@ -188,8 +201,10 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class SuffixStringType> inline
-bool ends_with( utf8_string<StringType> const &s,
- SuffixStringType const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(SuffixStringType),
+ bool>::type
+ends_with( utf8_string<StringType> const &s, SuffixStringType const &ps ) {
return ascii::ends_with( *s.get(), ps.data(), ps.size() );
}
@@ -203,8 +218,10 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class SuffixStringType> inline
-bool ends_with( StringType const &s,
- utf8_string<SuffixStringType> const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(SuffixStringType),
+ bool>::type
+ends_with( StringType const &s, utf8_string<SuffixStringType> const &ps ) {
return ascii::ends_with( s, *ps.get() );
}
@@ -218,8 +235,11 @@
* @return Returns \c true only if \a s ends with \a ps.
*/
template<class StringType,class SuffixStringType> inline
-bool ends_with( utf8_string<StringType> const &s,
- utf8_string<SuffixStringType> const &ps ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType)
+ && ZORBA_IS_STRING(SuffixStringType),
+ bool>::type
+ends_with( utf8_string<StringType> const &s,
+ utf8_string<SuffixStringType> const &ps ) {
return ascii::ends_with( *s.get(), *ps.get() );
}
@@ -235,7 +255,10 @@
* contents are overwritten.
*/
template<class InputStringType,class OutputStringType>
-void to_lower( InputStringType const &in, OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_lower( InputStringType const &in, OutputStringType *out );
/**
* Converts a string to lower-case.
@@ -244,7 +267,8 @@
* @param s The string.
*/
template<class StringType> inline
-void to_lower( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_lower( StringType &s ) {
StringType temp;
to_lower( s, &temp );
s = temp;
@@ -260,7 +284,10 @@
* contents are overwritten.
*/
template<class InputStringType,class OutputStringType>
-void to_upper( InputStringType const &in, OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_upper( InputStringType const &in, OutputStringType *out );
/**
* Converts a string to upper-case.
@@ -269,7 +296,8 @@
* @param s The string.
*/
template<class StringType> inline
-void to_upper( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_upper( StringType &s ) {
StringType temp;
to_upper( s, &temp );
s = temp;
@@ -286,7 +314,8 @@
* @param s A pointer to the string to be appended to.
*/
template<class InputIterator,class StringType> inline
-void append_codepoints( InputIterator i, InputIterator j, StringType *s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+append_codepoints( InputIterator i, InputIterator j, StringType *s ) {
typename utf8_stringify<StringType>::type u( *s );
std::copy( i, j, std::back_inserter( u ) );
}
@@ -301,7 +330,8 @@
* container's contents are appended to.
*/
template<class StringType,class ContainerType> inline
-void to_codepoints( StringType const &s, ContainerType *c ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_codepoints( StringType const &s, ContainerType *c ) {
typename utf8_stringify<StringType const>::type const u( s );
std::copy( u.begin(), u.end(), std::back_inserter( *c ) );
}
@@ -391,8 +421,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType>
-bool to_string( unicode::char_type const *in, size_type in_len,
- StringType *out );
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( unicode::char_type const *in, size_type in_len, StringType *out );
/**
* Converts a unicode::char_type array into a UTF-8 encoded string.
@@ -402,7 +432,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType> inline
-bool to_string( unicode::char_type const *in, StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( unicode::char_type const *in, StringType *out ) {
return to_string( in, u_strlen( in ), out );
}
@@ -416,7 +447,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType> inline
-bool to_string( unicode::string const &in, StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( unicode::string const &in, StringType *out ) {
#ifndef ZORBA_NO_ICU
return to_string( in.getBuffer(), in.length(), out );
#else
@@ -472,7 +504,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType>
-bool to_string( wchar_t const *in, size_type in_len, StringType *out );
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( wchar_t const *in, size_type in_len, StringType *out );
/**
* Converts a wide-character string into a UTF-8 encoded string.
@@ -483,7 +516,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType> inline
-bool to_string( wchar_t const *in, StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( wchar_t const *in, StringType *out ) {
return to_string( in, std::wcslen( in ), out );
}
@@ -498,7 +532,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType> inline
-bool to_string( std::wstring const &in, StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( std::wstring const &in, StringType *out ) {
return to_string( in.data(), in.size(), out );
}
@@ -543,8 +578,8 @@
* @return Returns \c true only if the conversion succeeded.
*/
template<class StringType> inline
-bool to_wchar_t( StringType const &in, wchar_t **out,
- unicode::size_type *out_len ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_wchar_t( StringType const &in, wchar_t **out, unicode::size_type *out_len ) {
return to_wchar_t( in.data(), in.size(), out, out_len );
}
@@ -577,7 +612,7 @@
*
* @param s The string to append to.
*/
- explicit back_html_uri_insert_iterator( StringType &s ) : base_type( s ) {
+ explicit back_html_uri_insert_iterator( StringType *s ) : base_type( s ) {
buf_[0] = '%';
}
@@ -593,8 +628,10 @@
* @tparam StringType The string type.
* @param out The output string.
*/
-template<class StringType> inline back_html_uri_insert_iterator<StringType>
-back_html_uri_inserter( StringType &out ) {
+template<class StringType> inline
+typename std::enable_if<ZORBA_IS_STRING(StringType),
+ back_html_uri_insert_iterator<StringType> >::type
+back_html_uri_inserter( StringType *out ) {
return back_html_uri_insert_iterator<StringType>( out );
}
@@ -607,10 +644,13 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType> inline
-void to_html_uri( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_html_uri( InputStringType const &in, OutputStringType *out ) {
typename utf8_stringify<InputStringType const>::type const u_in( in );
typename utf8_stringify<OutputStringType>::type u_out( *out );
- std::copy( u_in.begin(), u_in.end(), back_html_uri_inserter( u_out ) );
+ std::copy( u_in.begin(), u_in.end(), back_html_uri_inserter( &u_out ) );
}
/**
@@ -620,7 +660,8 @@
* @param s The string.
*/
template<class StringType> inline
-void to_html_uri( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+to_html_uri( StringType &s ) {
StringType temp;
to_html_uri( s, &temp );
s = temp;
@@ -653,7 +694,7 @@
*
* @param s The string to append to.
*/
- explicit back_iri_insert_iterator( StringType &s ) : base_type( s ) {
+ explicit back_iri_insert_iterator( StringType *s ) : base_type( s ) {
buf_[0] = '%';
}
@@ -669,8 +710,10 @@
* @tparam StringType The string type.
* @param out The output string.
*/
-template<class StringType> inline back_iri_insert_iterator<StringType>
-back_iri_inserter( StringType &out ) {
+template<class StringType> inline
+typename std::enable_if<ZORBA_IS_STRING(StringType),
+ back_iri_insert_iterator<StringType> >::type
+back_iri_inserter( StringType *out ) {
return back_iri_insert_iterator<StringType>( out );
}
@@ -684,10 +727,13 @@
* See RFC 3987.
*/
template<class InputStringType,class OutputStringType> inline
-void iri_to_uri( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+iri_to_uri( InputStringType const &in, OutputStringType *out ) {
typename utf8_stringify<InputStringType const>::type const u_in( in );
typename utf8_stringify<OutputStringType>::type u_out( *out );
- std::copy( u_in.begin(), u_in.end(), back_iri_inserter( u_out ) );
+ std::copy( u_in.begin(), u_in.end(), back_iri_inserter( &u_out ) );
}
/**
@@ -698,7 +744,8 @@
* See RFC 3987.
*/
template<class StringType> inline
-void iri_to_uri( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+iri_to_uri( StringType &s ) {
StringType temp;
iri_to_uri( s, &temp );
s = temp;
@@ -716,8 +763,11 @@
* @param out The output String (which may be the same as \a in).
*/
template<class InputStringType,class OutputStringType>
-bool normalize( InputStringType const &in, unicode::normalization::type n,
- OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ bool>::type
+normalize( InputStringType const &in, unicode::normalization::type n,
+ OutputStringType *out );
#endif /* ZORBA_NO_ICU */
////////// Whitespace /////////////////////////////////////////////////////////
@@ -732,9 +782,12 @@
* @param out The output string.
*/
template<class InputStringType,class OutputStringType> inline
-void normalize_whitespace( utf8_string<InputStringType> const &in,
- utf8_string<OutputStringType> *out ) {
- ascii::normalize_whitespace( *in.get(), out->get() );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+normalize_space( utf8_string<InputStringType> const &in,
+ utf8_string<OutputStringType> *out ) {
+ ascii::normalize_space( *in.get(), out->get() );
}
/**
@@ -746,9 +799,12 @@
* @param out The output string (which must be different from \a in).
*/
template<class InputStringType,class OutputStringType> inline
-void trim_whitespace( utf8_string<InputStringType> const &in,
- utf8_string<OutputStringType> *out ) {
- ascii::trim_whitespace( *in.get(), out->get() );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+trim_space( utf8_string<InputStringType> const &in,
+ utf8_string<OutputStringType> *out ) {
+ ascii::trim_space( *in.get(), out->get() );
}
/**
@@ -758,8 +814,9 @@
* @param s The string.
*/
template<class StringType> inline
-void trim_whitespace( utf8_string<StringType> &s ) {
- ascii::trim_whitespace( *s.get() );
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+trim_space( utf8_string<StringType> &s ) {
+ ascii::trim_space( *s.get() );
}
////////// Miscellaneous //////////////////////////////////////////////////////
@@ -774,8 +831,9 @@
* @return Returns \c *s.
*/
template<class StringType> inline
-StringType& left_pad( StringType *s, typename StringType::size_type width,
- unicode::code_point cp ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
+left_pad( StringType *s, typename StringType::size_type width,
+ unicode::code_point cp ) {
typedef typename utf8_stringify<StringType>::type u_type;
typedef typename u_type::size_type u_size_type;
u_type u( *s );
@@ -795,8 +853,9 @@
* @return Returns \c *s.
*/
template<class StringType> inline
-StringType& right_pad( StringType *s, typename StringType::size_type width,
- unicode::code_point cp ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),StringType&>::type
+right_pad( StringType *s, typename StringType::size_type width,
+ unicode::code_point cp ) {
typedef typename utf8_stringify<StringType>::type u_type;
typedef typename u_type::size_type u_size_type;
u_type u( *s );
@@ -815,7 +874,10 @@
* @param out The output string.
*/
template<class InputStringType,class OutputStringType> inline
-void reverse( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+reverse( InputStringType const &in, OutputStringType *out ) {
typename utf8_stringify<InputStringType const>::type const u_in( in );
typename utf8_stringify<OutputStringType>::type u_out( *out );
std::reverse_copy( u_in.begin(), u_in.end(), std::back_inserter( u_out ) );
@@ -832,14 +894,20 @@
* @return Returns \c true only if the strip succeeded.
*/
template<class InputStringType,class OutputStringType>
-bool strip_diacritics( InputStringType const &in, OutputStringType *out );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ bool>::type
+strip_diacritics( InputStringType const &in, OutputStringType *out );
/**
*
*/
template<class StringType1,class StringType2> inline
-int compare(const StringType1 &s1, const StringType2 &s2,
- const XQPCollator* collation)
+typename std::enable_if<ZORBA_IS_STRING(StringType1)
+ && ZORBA_IS_STRING(StringType2),
+ int>::type
+compare(const StringType1 &s1, const StringType2 &s2,
+ const XQPCollator* collation)
{
#ifndef ZORBA_NO_ICU
if (collation == NULL || collation->doMemCmp())
@@ -862,7 +930,8 @@
*
*/
template<class StringType> inline
-uint32_t hash(const StringType& s, const XQPCollator* collation = NULL)
+typename std::enable_if<ZORBA_IS_STRING(StringType),uint32_t>::type
+hash(const StringType& s, const XQPCollator* collation = NULL)
{
#ifndef ZORBA_NO_ICU
if (!collation || collation->doMemCmp())
=== 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 @@
#ifndef ZORBA_NO_ICU
template<class InputStringType,class OutputStringType>
-bool normalize( InputStringType const &in, unicode::normalization::type n,
- OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ bool>::type
+normalize( InputStringType const &in, unicode::normalization::type n,
+ OutputStringType *out ) {
unicode::string u_in;
if ( !unicode::to_string( in, &u_in ) )
return false;
@@ -126,7 +129,10 @@
#endif /* ZORBA_NO_ICU */
template<class InputStringType,class OutputStringType>
-bool strip_diacritics( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ bool>::type
+strip_diacritics( InputStringType const &in, OutputStringType *out ) {
#ifndef ZORBA_NO_ICU
unicode::string u_in;
if ( !unicode::to_string( in, &u_in ) )
@@ -143,7 +149,7 @@
#else
out->clear();
out->reserve( in.size() );
- std::copy( in.begin(), in.end(), ascii::back_ascii_inserter( *out ) );
+ std::copy( in.begin(), in.end(), ascii::back_ascii_inserter( out ) );
#endif /* ZORBA_NO_ICU */
return true;
}
@@ -151,8 +157,8 @@
#ifndef ZORBA_NO_ICU
template<class StringType>
-bool to_string( unicode::char_type const *in, size_type in_len,
- StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( unicode::char_type const *in, size_type in_len, StringType *out ) {
storage_type *temp;
size_type temp_len;
if ( to_string( in, in_len, &temp, &temp_len ) ) {
@@ -166,7 +172,8 @@
#ifndef WIN32
template<class StringType>
-bool to_string( wchar_t const *in, size_type in_len, StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),bool>::type
+to_string( wchar_t const *in, size_type in_len, StringType *out ) {
storage_type *temp;
size_type temp_len;
if ( utf8::to_string( in, in_len, &temp, &temp_len ) ) {
@@ -182,7 +189,10 @@
#endif /* ZORBA_NO_ICU */
template<class InputStringType,class OutputStringType>
-void to_lower( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_lower( InputStringType const &in, OutputStringType *out ) {
typename utf8_stringify<InputStringType const>::type const u_in( in );
typename utf8_stringify<OutputStringType>::type u_out( *out );
out->clear(); // TODO: should this be here?
@@ -192,7 +202,10 @@
}
template<class InputStringType,class OutputStringType>
-void to_upper( InputStringType const &in, OutputStringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+to_upper( InputStringType const &in, OutputStringType *out ) {
typename utf8_stringify<InputStringType const>::type const u_in( in );
typename utf8_stringify<OutputStringType>::type u_out( *out );
out->clear(); // TODO: should this be here?
@@ -201,6 +214,8 @@
);
}
+///////////////////////////////////////////////////////////////////////////////
+
} // namespace utf8
} // namespace zorba
=== 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 @@
* @return Returns said number of characters or 0 if any byte is invalid.
*/
template<class StringType> inline
-typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- size_type
->::type
+typename std::enable_if<ZORBA_HAS_C_STR(StringType),size_type>::type
length( StringType const &s ) {
return length( s.c_str() );
}
=== 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 @@
* @return Returns \c true only if the extraction was successful.
*/
template<class InputStringType,class OutputStringType> inline
-bool clark_localname( InputStringType const &uname, OutputStringType *local ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ bool>::type
+clark_localname( InputStringType const &uname, OutputStringType *local ) {
typename InputStringType::size_type const rbrace = uname.find( '}' );
if ( rbrace != InputStringType::npos && rbrace + 1 < uname.size() ) {
*local = uname.substr( rbrace + 1 );
@@ -75,7 +78,10 @@
* @return Returns \c true only if the extraction was successful.
*/
template<class InputStringType,class OutputStringType> inline
-bool clark_uri( InputStringType const &uname, OutputStringType *uri ) {
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ bool>::type
+clark_uri( InputStringType const &uname, OutputStringType *uri ) {
if ( uname.size() > 2 && uname[0] == '{' ) {
typename InputStringType::size_type const rbrace = uname.find( '}', 1 );
if ( rbrace != InputStringType::npos ) {
@@ -99,8 +105,13 @@
* become empty, returns \c false; otherwise returns \a true.
*/
template<class InputStringType,class PrefixStringType,class LocalStringType>
-inline bool split_name( InputStringType const &name, PrefixStringType *prefix,
- LocalStringType *local ) {
+inline
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(PrefixStringType)
+ && ZORBA_IS_STRING(LocalStringType),
+ bool>::type
+split_name( InputStringType const &name, PrefixStringType *prefix,
+ LocalStringType *local ) {
typename InputStringType::size_type const colon = name.find( ':' );
if ( colon != InputStringType::npos ) {
prefix->assign( name, 0, colon );
@@ -166,7 +177,7 @@
*
* @param s The string to append to.
*/
- explicit back_xml_insert_iterator( StringType &s ) : base_type( s ) {
+ explicit back_xml_insert_iterator( StringType *s ) : base_type( s ) {
buf_[0] = '&';
buf_[1] = '#';
}
@@ -183,8 +194,10 @@
* @tparam StringType The string type.
* @param out The output string.
*/
-template<class StringType> inline back_xml_insert_iterator<StringType>
-back_xml_inserter( StringType &out ) {
+template<class StringType> inline
+typename std::enable_if<ZORBA_IS_STRING(StringType),
+ back_xml_insert_iterator<StringType> >::type
+back_xml_inserter( StringType *out ) {
return back_xml_insert_iterator<StringType>( out );
}
@@ -199,8 +212,11 @@
* contents are appended to.
*/
template<class InputStringType,class OutputStringType> inline
-void escape( InputStringType const &in, OutputStringType *out ) {
- std::copy( in.begin(), in.end(), back_xml_inserter( *out ) );
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ void>::type
+escape( InputStringType const &in, OutputStringType *out ) {
+ std::copy( in.begin(), in.end(), back_xml_inserter( out ) );
}
/**
@@ -211,9 +227,10 @@
* @param s The string.
*/
template<class StringType> inline
-void escape( StringType &s ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),void>::type
+escape( StringType &s ) {
StringType temp;
- std::copy( s.begin(), s.end(), back_xml_inserter( temp ) );
+ std::copy( s.begin(), s.end(), back_xml_inserter( &temp ) );
s = temp;
}
@@ -239,7 +256,8 @@
* returns -1.
*/
template<class StringType> inline
-int parse_entity( StringType const &ref, unicode::code_point *c ) {
+typename std::enable_if<ZORBA_HAS_C_STR(StringType),int>::type
+parse_entity( StringType const &ref, unicode::code_point *c ) {
return parse_entity( ref.c_str(), c );
}
@@ -254,7 +272,8 @@
* returns -1.
*/
template<class StringType> inline
-int parse_entity( char const *ref, StringType *out ) {
+typename std::enable_if<ZORBA_IS_STRING(StringType),int>::type
+parse_entity( char const *ref, StringType *out ) {
unicode::code_point c;
int const result = parse_entity( ref, &c );
if ( result != -1 )
@@ -274,7 +293,10 @@
* returns -1.
*/
template<class InputStringType,class OutputStringType> inline
-int parse_entity( InputStringType const &ref, OutputStringType *out ) {
+typename std::enable_if<ZORBA_HAS_C_STR(InputStringType)
+ && ZORBA_IS_STRING(OutputStringType),
+ int>::type
+parse_entity( InputStringType const &ref, OutputStringType *out ) {
return parse_entity( ref.c_str(), out );
}
=== 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 @@
// first, we need to normalize the spaces in the uri
// and only work with the normalized version from this point on
zstring lTrimmedURI;
- ascii::normalize_whitespace(uri, &lTrimmedURI);
- ascii::trim_whitespace(lTrimmedURI);
+ ascii::normalize_space(uri, &lTrimmedURI);
+ ascii::trim_space(lTrimmedURI);
zstring::size_type lTrimmedURILength = lTrimmedURI.size();
=== 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 @@
void Base16::insertData(char const *s, size_t len)
{
- s = ascii::trim_whitespace( s, &len );
+ s = ascii::trim_space( s, &len );
try {
hexbinary::encode( s, len, &theData );
}
=== 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 @@
// DateTime is of form: '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = DATETIME_FACET;
@@ -381,7 +381,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -414,7 +414,7 @@
ascii::size_type pos = 0;
int err = 1;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = DATE_FACET;
@@ -428,7 +428,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -451,7 +451,7 @@
int err = 1;
ascii::size_type pos = 0;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = TIME_FACET;
@@ -464,7 +464,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -494,7 +494,7 @@
// GYearMonth of form: '-'? yyyy '-' mm zzzzzz?
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = GYEARMONTH_FACET;
@@ -522,7 +522,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -548,7 +548,7 @@
// GYear of form: '-'? yyyy zzzzzz?
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = GYEAR_FACET;
@@ -578,7 +578,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -606,7 +606,7 @@
// GMonth of form: --MM zzzzzz?
// preceding - is not allowed.
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = GMONTH_FACET;
@@ -630,7 +630,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -658,7 +658,7 @@
// GMonthDay of form: --MM-DD zzzzzz?
// preceding - is not allowed.
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = GMONTHDAY_FACET;
@@ -683,7 +683,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
@@ -711,7 +711,7 @@
// GDay of form: ---DD zzzzzz?
// preceding - is not allowed.
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
dt.facet = GDAY_FACET;
@@ -736,7 +736,7 @@
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (savepos != pos && pos != len)
return 1;
=== 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 @@
long& frac_seconds)
{
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
int err;
if (pos != savepos) {
@@ -111,7 +111,7 @@
long& frac_seconds)
{
ascii::size_type savepos = pos;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
int err;
if (pos != savepos)
@@ -246,7 +246,7 @@
return err;
ascii::size_type pos = ym_pos+1;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (pos > ym_pos + 1 && pos != len)
return 1;
@@ -282,7 +282,7 @@
long months = 0;
int err;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (pos == len)
return 1;
@@ -327,7 +327,7 @@
return 1;
}
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (len != pos)
return 1;
@@ -352,7 +352,7 @@
long days = 0, hours = 0, minutes = 0, seconds = 0, frac_seconds = 0;
int err;
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (pos == len)
return 1;
@@ -392,7 +392,7 @@
return err;
}
- ascii::skip_whitespace(str, len, &pos);
+ ascii::skip_space(str, len, &pos);
if (len != pos)
return 1;
=== 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 @@
{
ascii::size_type pos = 0;
- ascii::skip_whitespace(str, strlen, &pos);
+ ascii::skip_space(str, strlen, &pos);
// A time zone is of form: (('+' | '-') hh ':' mm) | 'Z'
if (str[pos] == 'Z')
{
++pos;
- ascii::skip_whitespace(str, strlen, &pos);
+ ascii::skip_space(str, strlen, &pos);
if (pos != strlen)
return 1;
@@ -94,7 +94,7 @@
if (tz.data[HOUR_DATA]*60 + tz.data[MINUTE_DATA] > 14*60)
return 1;
- ascii::skip_whitespace(str, strlen, &pos);
+ ascii::skip_space(str, strlen, &pos);
if (pos != strlen)
return 1;
=== 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 @@
if ( !*s )
throw std::invalid_argument( "empty string" );
- s = ascii::trim_start_whitespace( s );
+ s = ascii::trim_start_space( s );
char const *const first_non_ws = s;
if ( *s == '+' || *s == '-' )
=== 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 @@
int significant_digits = 0;
- s = ascii::trim_start_whitespace( s );
+ s = ascii::trim_start_space( s );
if ( !parse_etc( s ) ) {
char const *const first_non_ws = s;
@@ -136,7 +136,7 @@
} else
return false;
- return !*ascii::trim_start_whitespace( s );
+ return !*ascii::trim_start_space( s );
}
////////// constructors ///////////////////////////////////////////////////////
=== 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 @@
// Template version of find().
//
template<class StringType> inline
- typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- type
- >::type
+ typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
find( StringType const &country ) {
return find( country.c_str() );
}
@@ -101,10 +98,7 @@
// Template version of find().
//
template<class StringType> inline
- typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- type
- >::type
+ typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
find( StringType const &lang ) {
return find( lang.c_str() );
}
@@ -265,10 +259,7 @@
// Template version of find().
//
template<class StringType> inline
- typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- type
- >::type
+ typename std::enable_if<ZORBA_HAS_C_STR(StringType),type>::type
find( StringType const &lang ) {
return find( lang.c_str() );
}
@@ -288,10 +279,7 @@
// Template version of find_lang().
//
template<class StringType> inline
- typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- iso639_1::type
- >::type
+ typename std::enable_if<ZORBA_HAS_C_STR(StringType),iso639_1::type>::type
find_lang( StringType const &lang ) {
return find_lang( lang.c_str() );
}
@@ -436,10 +424,7 @@
// Template version of parse().
//
template<class StringType> inline
- typename std::enable_if<
- ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
- bool
- >::type
+ typename std::enable_if<ZORBA_HAS_C_STR(StringType),bool>::type
parse( StringType const &locale_str, iso639_1::type *lang = nullptr,
iso3166_1::type *country = nullptr ) {
return parse( locale_str.c_str(), lang, country );
Follow ups
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: noreply, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Matthias Brantner, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-05-09
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Matthias Brantner, 2013-05-09
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Matthias Brantner, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-05-09
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-05-09
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-05-09
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-05-09