aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/parser/non-validating
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-08 15:35:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-08 15:35:23 +0200
commit7db026e8056914d113ac0bbfd9bdc4908a9e7874 (patch)
tree0ab15cb8b0ee160a10cca21edaf0aca1e97e8921 /libxsde/xsde/cxx/parser/non-validating
parent4f38adc11ab1a3a1ab2dd3f958c917182be7d71f (diff)
Add support for the whiteSpace facet
Use the same mechanism to handle whitespace processing for build-in types and enumerations.
Diffstat (limited to 'libxsde/xsde/cxx/parser/non-validating')
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/id-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/id.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/idref.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/language-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/language.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/name-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/name.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/ncname.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx21
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx37
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/string-common.cxx84
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/string-common.hxx43
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/string-stl.cxx13
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/string.cxx25
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/token-stl.cxx28
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/token.cxx31
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/uri.cxx4
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx90
-rw-r--r--libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx187
24 files changed, 466 insertions, 149 deletions
diff --git a/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx
index 2e5ebd7..e3ebad8 100644
--- a/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/id-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string id_pimpl::
post_id ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/id.cxx b/libxsde/xsde/cxx/parser/non-validating/id.cxx
index 8431218..c54f958 100644
--- a/libxsde/xsde/cxx/parser/non-validating/id.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/id.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/id.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* id_pimpl::
post_id ()
{
- ro_string tmp (str_.data (), str_.size ());
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx
index 77bbc2a..da87469 100644
--- a/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/idref-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string idref_pimpl::
post_idref ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/idref.cxx b/libxsde/xsde/cxx/parser/non-validating/idref.cxx
index 15a2eea..ce1ef46 100644
--- a/libxsde/xsde/cxx/parser/non-validating/idref.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/idref.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/idref.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* idref_pimpl::
post_idref ()
{
- ro_string tmp (str_.data (), str_.size ());
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx
index 2c1e357..8edc8fe 100644
--- a/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/language-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string language_pimpl::
post_language ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/language.cxx b/libxsde/xsde/cxx/parser/non-validating/language.cxx
index d4d5c3d..015626d 100644
--- a/libxsde/xsde/cxx/parser/non-validating/language.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/language.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/language.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* language_pimpl::
post_language ()
{
- ro_string tmp (str_);
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx
index ce071c9..07609ab 100644
--- a/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/name-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string name_pimpl::
post_name ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/name.cxx b/libxsde/xsde/cxx/parser/non-validating/name.cxx
index b11d304..df1ba7b 100644
--- a/libxsde/xsde/cxx/parser/non-validating/name.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/name.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/name.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* name_pimpl::
post_name ()
{
- ro_string tmp (str_.data (), str_.size ());
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx
index 0ab155e..aa35ac2 100644
--- a/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/ncname-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string ncname_pimpl::
post_ncname ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname.cxx b/libxsde/xsde/cxx/parser/non-validating/ncname.cxx
index c2603a9..b972fc8 100644
--- a/libxsde/xsde/cxx/parser/non-validating/ncname.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/ncname.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/ncname.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* ncname_pimpl::
post_ncname ()
{
- ro_string tmp (str_.data (), str_.size ());
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx
index a3500c2..e76881c 100644
--- a/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/nmtoken-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string nmtoken_pimpl::
post_nmtoken ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx
index acf1ebd..14d4cce 100644
--- a/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/nmtoken.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* nmtoken_pimpl::
post_nmtoken ()
{
- ro_string tmp (str_.data (), str_.size ());
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx
index 4070244..9f16cec 100644
--- a/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/normalized-string-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -22,21 +23,21 @@ namespace xsde
void normalized_string_pimpl::
_characters (const ro_string& s)
{
- str_ += s;
+ if (_facets ().whitespace_ == 2 && str_.size () == 0)
+ {
+ ro_string tmp (s.data (), s.size ());
+
+ if (trim_left (tmp) != 0)
+ str_ += tmp;
+ }
+ else
+ str_ += s;
}
std::string normalized_string_pimpl::
post_normalized_string ()
{
- std::string::size_type size = str_.size ();
-
- for (std::string::size_type i = 0; i < size; ++i)
- {
- char& c = str_[i];
-
- if (c == 0x0A || c == 0x0D || c == 0x09)
- c = 0x20;
- }
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx b/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx
index e268d7d..20de4d8 100644
--- a/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/normalized-string.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -29,29 +30,35 @@ namespace xsde
void normalized_string_pimpl::
_characters (const ro_string& s)
{
+ if (_facets ().whitespace_ == 2 && str_.size () == 0)
+ {
+ ro_string tmp (s.data (), s.size ());
+
+ if (trim_left (tmp) != 0)
+ {
#ifdef XSDE_EXCEPTIONS
- str_.append (s.data (), s.size ());
+ str_.append (tmp.data (), tmp.size ());
#else
- if (str_.append (s.data (), s.size ()))
- _sys_error (sys_error::no_memory);
+ if (str_.append (tmp.data (), tmp.size ()))
+ _sys_error (sys_error::no_memory);
+#endif
+ }
+ }
+ else
+ {
+#ifdef XSDE_EXCEPTIONS
+ str_.append (s.data (), s.size ());
+#else
+ if (str_.append (s.data (), s.size ()))
+ _sys_error (sys_error::no_memory);
#endif
+ }
}
char* normalized_string_pimpl::
post_normalized_string ()
{
- typedef string::size_type size_type;
-
- size_type size = str_.size ();
-
- for (size_type i = 0; i < size; ++i)
- {
- char& c = str_[i];
-
- if (c == 0x0A || c == 0x0D || c == 0x09)
- c = 0x20;
- }
-
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/string-common.cxx b/libxsde/xsde/cxx/parser/non-validating/string-common.cxx
new file mode 100644
index 0000000..f4ba502
--- /dev/null
+++ b/libxsde/xsde/cxx/parser/non-validating/string-common.cxx
@@ -0,0 +1,84 @@
+// file : xsde/cxx/parser/non-validating/string-common.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace parser
+ {
+ namespace non_validating
+ {
+ void string_common::
+ process_facets (
+#ifdef XSDE_STL
+ std::string& str,
+#else
+ string& str,
+#endif
+ const string_facets::facets& f)
+ {
+#ifdef XSDE_STL
+ typedef std::string::size_type size_type;
+#else
+ typedef string::size_type size_type;
+#endif
+
+ if (f.whitespace_ == 2)
+ {
+ // Collapse. The left trimming has already been performed.
+ //
+ size_type size = str.size ();
+ size_type j = 0;
+
+ bool subs = false;
+
+ for (size_type i = 0; i < size; ++i)
+ {
+ char c = str[i];
+
+ if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09)
+ {
+ subs = true;
+ }
+ else
+ {
+ if (subs)
+ {
+ subs = false;
+ str[j++] = 0x20;
+ }
+
+ str[j++] = c;
+ }
+ }
+
+#ifdef XSDE_STL
+ str.resize (j);
+#else
+ str.truncate (j);
+#endif
+ }
+ else if (f.whitespace_ == 1)
+ {
+ // Replace.
+ //
+ size_type size = str.size ();
+
+ for (size_type i = 0; i < size; ++i)
+ {
+ char& c = str[i];
+
+ if (c == 0x0A || c == 0x0D || c == 0x09)
+ c = 0x20;
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/parser/non-validating/string-common.hxx b/libxsde/xsde/cxx/parser/non-validating/string-common.hxx
new file mode 100644
index 0000000..6935e9f
--- /dev/null
+++ b/libxsde/xsde/cxx/parser/non-validating/string-common.hxx
@@ -0,0 +1,43 @@
+// file : xsde/cxx/parser/non-validating/string-common.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_PARSER_NON_VALIDATING_STRING_COMMON_HXX
+#define XSDE_CXX_PARSER_NON_VALIDATING_STRING_COMMON_HXX
+
+#include <xsde/cxx/config.hxx>
+
+#ifdef XSDE_STL
+#include <string>
+#else
+#include <xsde/cxx/string.hxx>
+#endif
+
+#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace parser
+ {
+ namespace non_validating
+ {
+ struct string_common
+ {
+ static void
+ process_facets (
+#ifdef XSDE_STL
+ std::string& str,
+#else
+ string& str,
+#endif
+ const string_facets::facets&);
+ };
+ }
+ }
+ }
+}
+
+#endif // XSDE_CXX_PARSER_NON_VALIDATING_STRING_COMMON_HXX
diff --git a/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx
index cd82550..4e979d8 100644
--- a/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/string-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -22,12 +23,22 @@ namespace xsde
void string_pimpl::
_characters (const ro_string& s)
{
- str_ += s;
+ if (_facets ().whitespace_ == 2 && str_.size () == 0)
+ {
+ ro_string tmp (s.data (), s.size ());
+
+ if (trim_left (tmp) != 0)
+ str_ += tmp;
+ }
+ else
+ str_ += s;
}
std::string string_pimpl::
post_string ()
{
+ string_common::process_facets (str_, _facets ());
+
std::string r;
r.swap (str_);
return r;
diff --git a/libxsde/xsde/cxx/parser/non-validating/string.cxx b/libxsde/xsde/cxx/parser/non-validating/string.cxx
index 091f5b6..21b4aaf 100644
--- a/libxsde/xsde/cxx/parser/non-validating/string.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/string.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/string.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -29,17 +30,35 @@ namespace xsde
void string_pimpl::
_characters (const ro_string& s)
{
+ if (_facets ().whitespace_ == 2 && str_.size () == 0)
+ {
+ ro_string tmp (s.data (), s.size ());
+
+ if (trim_left (tmp) != 0)
+ {
#ifdef XSDE_EXCEPTIONS
- str_.append (s.data (), s.size ());
+ str_.append (tmp.data (), tmp.size ());
#else
- if (str_.append (s.data (), s.size ()))
- _sys_error (sys_error::no_memory);
+ if (str_.append (tmp.data (), tmp.size ()))
+ _sys_error (sys_error::no_memory);
+#endif
+ }
+ }
+ else
+ {
+#ifdef XSDE_EXCEPTIONS
+ str_.append (s.data (), s.size ());
+#else
+ if (str_.append (s.data (), s.size ()))
+ _sys_error (sys_error::no_memory);
#endif
+ }
}
char* string_pimpl::
post_string ()
{
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx
index 8977b0f..e2a604d 100644
--- a/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/token-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,32 +37,7 @@ namespace xsde
std::string token_pimpl::
post_token ()
{
- std::string::size_type size = str_.size ();
- std::string::size_type j = 0;
-
- bool subs = false;
-
- for (std::string::size_type i = 0; i < size; ++i)
- {
- char c = str_[i];
-
- if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09)
- {
- subs = true;
- }
- else
- {
- if (subs)
- {
- subs = false;
- str_[j++] = 0x20;
- }
-
- str_[j++] = c;
- }
- }
-
- str_.resize (j);
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/token.cxx b/libxsde/xsde/cxx/parser/non-validating/token.cxx
index 056d0f5..4a6f71f 100644
--- a/libxsde/xsde/cxx/parser/non-validating/token.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/token.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/token.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,35 +58,7 @@ namespace xsde
char* token_pimpl::
post_token ()
{
- typedef string::size_type size_type;
-
- size_type size = str_.size ();
- size_type j = 0;
-
- bool subs = false;
-
- for (size_type i = 0; i < size; ++i)
- {
- char c = str_[i];
-
- if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09)
- {
- subs = true;
- }
- else
- {
- if (subs)
- {
- subs = false;
- str_[j++] = 0x20;
- }
-
- str_[j++] = c;
- }
- }
-
- str_.truncate (j);
-
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx
index 998bc2e..47bd584 100644
--- a/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx
@@ -4,6 +4,7 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsde/cxx/parser/non-validating/uri-stl.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -36,8 +37,7 @@ namespace xsde
std::string uri_pimpl::
post_uri ()
{
- ro_string tmp (str_);
- str_.resize (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
std::string r;
r.swap (str_);
diff --git a/libxsde/xsde/cxx/parser/non-validating/uri.cxx b/libxsde/xsde/cxx/parser/non-validating/uri.cxx
index 0b60501..50ebca8 100644
--- a/libxsde/xsde/cxx/parser/non-validating/uri.cxx
+++ b/libxsde/xsde/cxx/parser/non-validating/uri.cxx
@@ -6,6 +6,7 @@
#include <xsde/cxx/config.hxx>
#include <xsde/cxx/parser/non-validating/uri.hxx>
+#include <xsde/cxx/parser/non-validating/string-common.hxx>
namespace xsde
{
@@ -57,8 +58,7 @@ namespace xsde
char* uri_pimpl::
post_uri ()
{
- ro_string tmp (str_);
- str_.truncate (trim_right (tmp));
+ string_common::process_facets (str_, _facets ());
return str_.detach ();
}
}
diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx
index 59469c6..6b98277 100644
--- a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx
+++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx
@@ -551,7 +551,29 @@ namespace xsde
// string that you have to delete with delete[] (or custom
// deallocator if enabled).
//
- struct string_pskel: simple_content
+
+ struct string_facets
+ {
+ string_facets ();
+
+ void
+ _whitespace_facet (unsigned int);
+
+ public:
+ struct facets
+ {
+ // 0 - preserve
+ // 1 - replace
+ // 2 - collapse
+ //
+ unsigned int whitespace_: 2;
+ };
+
+ protected:
+ facets facets_;
+ };
+
+ struct string_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -575,9 +597,12 @@ namespace xsde
protected:
string_pskel* string_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct normalized_string_pskel: simple_content
+ struct normalized_string_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -593,17 +618,20 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ normalized_string_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- normalized_string_pskel ();
normalized_string_pskel (normalized_string_pskel* impl, void*);
protected:
normalized_string_pskel* normalized_string_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct token_pskel: simple_content
+ struct token_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -619,17 +647,20 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ token_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- token_pskel ();
token_pskel (token_pskel* impl, void*);
protected:
token_pskel* token_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct name_pskel: simple_content
+ struct name_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -645,17 +676,20 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ name_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- name_pskel ();
name_pskel (name_pskel* impl, void*);
protected:
name_pskel* name_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct nmtoken_pskel: simple_content
+ struct nmtoken_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -671,14 +705,17 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ nmtoken_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- nmtoken_pskel ();
nmtoken_pskel (nmtoken_pskel* impl, void*);
protected:
nmtoken_pskel* nmtoken_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
struct nmtokens_pskel: list_base
@@ -703,7 +740,7 @@ namespace xsde
#endif
};
- struct ncname_pskel: simple_content
+ struct ncname_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -719,17 +756,20 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ ncname_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- ncname_pskel ();
ncname_pskel (ncname_pskel* impl, void*);
protected:
ncname_pskel* ncname_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct id_pskel: simple_content
+ struct id_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -745,17 +785,20 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ id_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- id_pskel ();
id_pskel (id_pskel* impl, void*);
protected:
id_pskel* id_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct idref_pskel: simple_content
+ struct idref_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -771,14 +814,17 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ idref_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- idref_pskel ();
idref_pskel (idref_pskel* impl, void*);
protected:
idref_pskel* idref_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
struct idrefs_pskel: list_base
@@ -803,7 +849,7 @@ namespace xsde
#endif
};
- struct language_pskel: simple_content
+ struct language_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -819,17 +865,20 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ language_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- language_pskel ();
language_pskel (language_pskel* impl, void*);
protected:
language_pskel* language_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
- struct uri_pskel: simple_content
+ struct uri_pskel: simple_content, string_facets
{
#ifdef XSDE_STL
virtual std::string
@@ -845,14 +894,17 @@ namespace xsde
virtual const char*
_dynamic_type () const;
#endif
+ uri_pskel ();
#ifdef XSDE_REUSE_STYLE_TIEIN
- uri_pskel ();
uri_pskel (uri_pskel* impl, void*);
protected:
uri_pskel* uri_impl_;
#endif
+ protected:
+ const string_facets::facets&
+ _facets () const;
};
struct qname_pskel: simple_content
diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx
index 95e3258..2be6cbf 100644
--- a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx
+++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx
@@ -315,6 +315,20 @@ namespace xsde
}
#endif
+ // string_facets
+ //
+ inline string_facets::
+ string_facets ()
+ {
+ facets_.whitespace_ = 0;
+ }
+
+ inline void string_facets::
+ _whitespace_facet (unsigned int v)
+ {
+ facets_.whitespace_ = v;
+ }
+
// string_pskel
//
#ifdef XSDE_REUSE_STYLE_TIEIN
@@ -330,70 +344,137 @@ namespace xsde
{
}
#endif
+ inline const string_facets::facets& string_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const string_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// normalized_string_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline normalized_string_pskel::
normalized_string_pskel ()
- : normalized_string_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ normalized_string_impl_ = 0;
+#endif
+ _whitespace_facet (1); // replace
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline normalized_string_pskel::
normalized_string_pskel (normalized_string_pskel* impl, void*)
: simple_content (impl, 0), normalized_string_impl_ (impl)
{
+ _whitespace_facet (1); // replace
}
#endif
+ inline const string_facets::facets& normalized_string_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const normalized_string_pskel&> (
+ *parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// token_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline token_pskel::
token_pskel ()
- : token_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ token_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline token_pskel::
token_pskel (token_pskel* impl, void*)
: simple_content (impl, 0), token_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& token_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const token_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// name_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline name_pskel::
name_pskel ()
- : name_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ name_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline name_pskel::
name_pskel (name_pskel* impl, void*)
: simple_content (impl, 0), name_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& name_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const name_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// nmtoken_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline nmtoken_pskel::
nmtoken_pskel ()
- : nmtoken_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ nmtoken_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline nmtoken_pskel::
nmtoken_pskel (nmtoken_pskel* impl, void*)
: simple_content (impl, 0), nmtoken_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& nmtoken_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const nmtoken_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// nmtokens_pskel
//
@@ -413,51 +494,93 @@ namespace xsde
// ncname_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline ncname_pskel::
ncname_pskel ()
- : ncname_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ ncname_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline ncname_pskel::
ncname_pskel (ncname_pskel* impl, void*)
: simple_content (impl, 0), ncname_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& ncname_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const ncname_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// id_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline id_pskel::
id_pskel ()
- : id_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ id_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline id_pskel::
id_pskel (id_pskel* impl, void*)
: simple_content (impl, 0), id_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& id_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const id_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// idref_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline idref_pskel::
idref_pskel ()
- : idref_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ idref_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline idref_pskel::
idref_pskel (idref_pskel* impl, void*)
: simple_content (impl, 0), idref_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& idref_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const idref_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// idrefs_pskel
//
@@ -477,35 +600,63 @@ namespace xsde
// language_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline language_pskel::
language_pskel ()
- : language_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ language_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline language_pskel::
language_pskel (language_pskel* impl, void*)
: simple_content (impl, 0), language_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& language_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const language_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// uri_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline uri_pskel::
uri_pskel ()
- : uri_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ uri_impl_ = 0;
+#endif
+ _whitespace_facet (2); // collapse
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline uri_pskel::
uri_pskel (uri_pskel* impl, void*)
: simple_content (impl, 0), uri_impl_ (impl)
{
+ _whitespace_facet (2); // collapse
}
#endif
+ inline const string_facets::facets& uri_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const uri_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// qname_pskel
//