diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-13 15:38:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-13 15:38:11 +0200 |
commit | 6f395f9f769866a04f6949cb7ed14f93d90cf728 (patch) | |
tree | d1f8343e7b41fc1895676ad4248a5e4942f9172b | |
parent | c1f49aa87678c512ac37575365a6676727e5f20a (diff) |
Map anySimpleType to a string
77 files changed, 1020 insertions, 313 deletions
@@ -48,6 +48,9 @@ Version 3.2.0 for variable-length types. These functions allow you to make dynamically- allocated copies of variable-length objects. + * The anySimpleType build-in type is now mapped to std::string or a C-string, + depending on whether STL is enabled or not. + * New configuration parameter, XSDE_STL_ITERATOR, makes iterators provided by the mapping conform to the STL requirements. This feature requires working <iterator> header and allows you to use the standard @@ -87,6 +90,9 @@ Version 3.2.0 For more information on the pattern facet validation, see the XSDE_REGEXP parameter in the configuration files. + * The anySimpleType build-in type is now mapped to std::string or a C-string, + depending on whether STL is enabled or not. + C++/Serializer * Support for the following XML Schema facets: @@ -107,6 +113,9 @@ Version 3.2.0 For more information on the pattern facet validation, see the XSDE_REGEXP parameter in the configuration files. + * The anySimpleType build-in type is now mapped to std::string or a C-string, + depending on whether STL is enabled or not. + Version 3.1.0 C++/Hybrid diff --git a/dist/libxsde/xsde/makefile b/dist/libxsde/xsde/makefile index 1e3db26..af6cfe9 100644 --- a/dist/libxsde/xsde/makefile +++ b/dist/libxsde/xsde/makefile @@ -157,6 +157,7 @@ endif ifeq ($(XSDE_STL),y) src += \ +cxx/parser/validating/any-simple-type-stl.cxx \ cxx/parser/validating/string-stl.cxx \ cxx/parser/validating/normalized-string-stl.cxx \ cxx/parser/validating/token-stl.cxx \ @@ -174,6 +175,7 @@ cxx/parser/validating/qname-stl.cxx else src += \ +cxx/parser/validating/any-simple-type.cxx \ cxx/parser/validating/string.cxx \ cxx/parser/validating/normalized-string.cxx \ cxx/parser/validating/token.cxx \ @@ -242,6 +244,7 @@ endif ifeq ($(XSDE_STL),y) src += \ +cxx/parser/non-validating/any-simple-type-stl.cxx \ cxx/parser/non-validating/string-stl.cxx \ cxx/parser/non-validating/normalized-string-stl.cxx \ cxx/parser/non-validating/token-stl.cxx \ @@ -259,6 +262,7 @@ cxx/parser/non-validating/qname-stl.cxx else src += \ +cxx/parser/non-validating/any-simple-type.cxx \ cxx/parser/non-validating/string.cxx \ cxx/parser/non-validating/normalized-string.cxx \ cxx/parser/non-validating/token.cxx \ @@ -350,6 +354,7 @@ endif ifeq ($(XSDE_STL),y) src += \ +cxx/serializer/validating/any-simple-type-stl.cxx \ cxx/serializer/validating/string-stl.cxx \ cxx/serializer/validating/normalized-string-stl.cxx \ cxx/serializer/validating/token-stl.cxx \ @@ -367,6 +372,7 @@ cxx/serializer/validating/qname-stl.cxx else src += \ +cxx/serializer/validating/any-simple-type.cxx \ cxx/serializer/validating/string.cxx \ cxx/serializer/validating/normalized-string.cxx \ cxx/serializer/validating/token.cxx \ @@ -433,6 +439,7 @@ endif ifeq ($(XSDE_STL),y) src += \ +cxx/serializer/non-validating/any-simple-type-stl.cxx \ cxx/serializer/non-validating/string-stl.cxx \ cxx/serializer/non-validating/normalized-string-stl.cxx \ cxx/serializer/non-validating/token-stl.cxx \ @@ -450,6 +457,7 @@ cxx/serializer/non-validating/qname-stl.cxx else src += \ +cxx/serializer/non-validating/any-simple-type.cxx \ cxx/serializer/non-validating/string.cxx \ cxx/serializer/non-validating/normalized-string.cxx \ cxx/serializer/non-validating/token.cxx \ diff --git a/dist/libxsde/xsde/nmakefile b/dist/libxsde/xsde/nmakefile index da40ece..aaffe74 100644 --- a/dist/libxsde/xsde/nmakefile +++ b/dist/libxsde/xsde/nmakefile @@ -163,6 +163,7 @@ cxx\parser\validating\unsigned-long.cxx !if "$(XSDE_STL)" == "y" src = $(src) \ +cxx\parser\validating\any-simple-type-stl.cxx \ cxx\parser\validating\string-stl.cxx \ cxx\parser\validating\normalized-string-stl.cxx \ cxx\parser\validating\token-stl.cxx \ @@ -180,6 +181,7 @@ cxx\parser\validating\qname-stl.cxx !else src = $(src) \ +cxx\parser\validating\any-simple-type.cxx \ cxx\parser\validating\string.cxx \ cxx\parser\validating\normalized-string.cxx \ cxx\parser\validating\token.cxx \ @@ -248,6 +250,7 @@ cxx\parser\non-validating\unsigned-long.cxx !if "$(XSDE_STL)" == "y" src = $(src) \ +cxx\parser\non-validating\any-simple-type-stl.cxx \ cxx\parser\non-validating\string-stl.cxx \ cxx\parser\non-validating\normalized-string-stl.cxx \ cxx\parser\non-validating\token-stl.cxx \ @@ -265,6 +268,7 @@ cxx\parser\non-validating\qname-stl.cxx !else src = $(src) \ +cxx\parser\non-validating\any-simple-type.cxx \ cxx\parser\non-validating\string.cxx \ cxx\parser\non-validating\normalized-string.cxx \ cxx\parser\non-validating\token.cxx \ @@ -361,6 +365,7 @@ cxx\serializer\validating\unsigned-long.cxx !if "$(XSDE_STL)" == "y" src = $(src) \ +cxx\serializer\validating\any-simple-type-stl.cxx \ cxx\serializer\validating\string-stl.cxx \ cxx\serializer\validating\normalized-string-stl.cxx \ cxx\serializer\validating\token-stl.cxx \ @@ -378,6 +383,7 @@ cxx\serializer\validating\qname-stl.cxx !else src = $(src) \ +cxx\serializer\validating\any-simple-type.cxx \ cxx\serializer\validating\string.cxx \ cxx\serializer\validating\normalized-string.cxx \ cxx\serializer\validating\token.cxx \ @@ -444,6 +450,7 @@ cxx\serializer\non-validating\unsigned-long.cxx !if "$(XSDE_STL)" == "y" src = $(src) \ +cxx\serializer\non-validating\any-simple-type-stl.cxx \ cxx\serializer\non-validating\string-stl.cxx \ cxx\serializer\non-validating\normalized-string-stl.cxx \ cxx\serializer\non-validating\token-stl.cxx \ @@ -461,6 +468,7 @@ cxx\serializer\non-validating\qname-stl.cxx !else src = $(src) \ +cxx\serializer\non-validating\any-simple-type.cxx \ cxx\serializer\non-validating\string.cxx \ cxx\serializer\non-validating\normalized-string.cxx \ cxx\serializer\non-validating\token.cxx \ diff --git a/documentation/cxx/parser/guide/index.xhtml b/documentation/cxx/parser/guide/index.xhtml index 90da54a..9dc9764 100644 --- a/documentation/cxx/parser/guide/index.xhtml +++ b/documentation/cxx/parser/guide/index.xhtml @@ -1712,6 +1712,8 @@ namespace http://www.w3.org/2001/XMLSchema { include <string>; + anySimpleType std::string; + string std::string; normalizedString std::string; token std::string; @@ -1732,6 +1734,8 @@ namespace http://www.w3.org/2001/XMLSchema <pre class="type-map"> namespace http://www.w3.org/2001/XMLSchema { + anySimpleType char*; + string char*; normalizedString char*; token char*; @@ -3169,7 +3173,8 @@ main (int argc, char* argv[]) <tr> <td><code>anySimpleType</code></td> <td><code>any_simple_type_pimpl</code></td> - <td><code>void</code></td> + <td><code>std::string</code> or <code>char*</code><br/> + <a href="#5.1">Section 5.1, "Standard Template Library"</a></td> </tr> <tr> diff --git a/documentation/cxx/serializer/guide/index.xhtml b/documentation/cxx/serializer/guide/index.xhtml index 5e1dca1..e04667f 100644 --- a/documentation/cxx/serializer/guide/index.xhtml +++ b/documentation/cxx/serializer/guide/index.xhtml @@ -1789,6 +1789,8 @@ namespace http://www.w3.org/2001/XMLSchema { include <string>; + anySimpleType std::string; + string std::string; normalizedString std::string; token std::string; @@ -1809,6 +1811,8 @@ namespace http://www.w3.org/2001/XMLSchema <pre class="type-map"> namespace http://www.w3.org/2001/XMLSchema { + anySimpleType "const char*"; + string "const char*"; normalizedString "const char*"; token "const char*"; @@ -4057,7 +4061,8 @@ main () <tr> <td><code>anySimpleType</code></td> <td><code>any_simple_type_simpl</code></td> - <td><code>void</code></td> + <td><code>const std::string&</code> or<br/> <code>const char*</code><br/> + <a href="#7.2">Section 7.2, "String-Based Type Serializers"</a></td> </tr> <tr> @@ -4428,7 +4433,8 @@ namespace xml_schema <code>normalizedString</code>, <code>token</code>, <code>Name</code>, <code>NMTOKEN</code>, <code>NCName</code>, <code>ID</code>, <code>IDREF</code>, <code>language</code>, - and <code>anyURI</code> built-in XML Schema types is + <code>anyURI</code>, and <code>anySimpleType</code> built-in XML Schema + types is <code>const std::string&</code>. When STL is disabled, the value is passed as a constant C-string: <code>const char*</code>. In this case, you can also instruct the serializer diff --git a/examples/cxx/hybrid/binary/custom/irawstream.hxx b/examples/cxx/hybrid/binary/custom/irawstream.hxx index e4292a7..7df4d8a 100644 --- a/examples/cxx/hybrid/binary/custom/irawstream.hxx +++ b/examples/cxx/hybrid/binary/custom/irawstream.hxx @@ -62,7 +62,6 @@ private: }; void operator>> (irawstream&, xml_schema::any_type&); -void operator>> (irawstream&, xml_schema::any_simple_type&); void operator>> (irawstream&, xml_schema::qname&); void operator>> (irawstream&, xml_schema::time_zone&); void operator>> (irawstream&, xml_schema::date&); diff --git a/examples/cxx/hybrid/binary/custom/irawstream.ixx b/examples/cxx/hybrid/binary/custom/irawstream.ixx index 31574eb..fa73d39 100644 --- a/examples/cxx/hybrid/binary/custom/irawstream.ixx +++ b/examples/cxx/hybrid/binary/custom/irawstream.ixx @@ -103,8 +103,3 @@ inline void operator>> (irawstream&, xml_schema::any_type&) { } - -inline void -operator>> (irawstream&, xml_schema::any_simple_type&) -{ -} diff --git a/examples/cxx/hybrid/binary/custom/orawstream.hxx b/examples/cxx/hybrid/binary/custom/orawstream.hxx index 04b5ace..c3faec8 100644 --- a/examples/cxx/hybrid/binary/custom/orawstream.hxx +++ b/examples/cxx/hybrid/binary/custom/orawstream.hxx @@ -61,7 +61,6 @@ private: }; void operator<< (orawstream&, const xml_schema::any_type&); -void operator<< (orawstream&, const xml_schema::any_simple_type&); void operator<< (orawstream&, const xml_schema::qname&); void operator<< (orawstream&, const xml_schema::time_zone&); void operator<< (orawstream&, const xml_schema::date&); diff --git a/examples/cxx/hybrid/binary/custom/orawstream.ixx b/examples/cxx/hybrid/binary/custom/orawstream.ixx index 577eb1b..62eaff4 100644 --- a/examples/cxx/hybrid/binary/custom/orawstream.ixx +++ b/examples/cxx/hybrid/binary/custom/orawstream.ixx @@ -103,8 +103,3 @@ inline void operator<< (orawstream&, const xml_schema::any_type&) { } - -inline void -operator<< (orawstream&, const xml_schema::any_simple_type&) -{ -} diff --git a/libxsde/xsde/cxx/hybrid/any-type.hxx b/libxsde/xsde/cxx/hybrid/any-type.hxx index 0517292..a356564 100644 --- a/libxsde/xsde/cxx/hybrid/any-type.hxx +++ b/libxsde/xsde/cxx/hybrid/any-type.hxx @@ -43,22 +43,6 @@ namespace xsde #endif */ }; - - struct any_simple_type - { - }; - - inline bool - operator== (const any_simple_type&, const any_simple_type&) - { - return true; - } - - inline bool - operator!= (const any_simple_type&, const any_simple_type&) - { - return false; - } } } } diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.hxx b/libxsde/xsde/cxx/hybrid/cdr/istream.hxx index 9dc5cb6..740cfc4 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/istream.hxx +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.hxx @@ -123,7 +123,6 @@ namespace xsde #ifdef XSDE_EXCEPTIONS void operator>> (icdrstream&, any_type&); - void operator>> (icdrstream&, any_simple_type&); void operator>> (icdrstream&, qname&); void operator>> (icdrstream&, string_sequence&); void operator>> (icdrstream&, time_zone&); @@ -138,7 +137,6 @@ namespace xsde void operator>> (icdrstream&, time&); #else bool operator>> (icdrstream&, any_type&); - bool operator>> (icdrstream&, any_simple_type&); bool operator>> (icdrstream&, qname&); bool operator>> (icdrstream&, string_sequence&); bool operator>> (icdrstream&, time_zone&); diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.ixx b/libxsde/xsde/cxx/hybrid/cdr/istream.ixx index 53a9575..53e7cbf 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/istream.ixx +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.ixx @@ -187,11 +187,6 @@ namespace xsde { } - inline void - operator>> (icdrstream&, any_simple_type&) - { - } - #else // XSDE_EXCEPTIONS inline bool icdrstream:: @@ -373,12 +368,6 @@ namespace xsde return true; } - inline bool - operator>> (icdrstream&, any_simple_type&) - { - return true; - } - #endif // XSDE_EXCEPTIONS } } diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx b/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx index 8485241..2c58907 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx +++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.hxx @@ -123,7 +123,6 @@ namespace xsde #ifdef XSDE_EXCEPTIONS void operator<< (ocdrstream&, const any_type&); - void operator<< (ocdrstream&, const any_simple_type&); void operator<< (ocdrstream&, const qname&); void operator<< (ocdrstream&, const string_sequence&); void operator<< (ocdrstream&, const time_zone&); @@ -138,7 +137,6 @@ namespace xsde void operator<< (ocdrstream&, const time&); #else bool operator<< (ocdrstream&, const any_type&); - bool operator<< (ocdrstream&, const any_simple_type&); bool operator<< (ocdrstream&, const qname&); bool operator<< (ocdrstream&, const string_sequence&); bool operator<< (ocdrstream&, const time_zone&); diff --git a/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx b/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx index aa01ad1..d2b38b4 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx +++ b/libxsde/xsde/cxx/hybrid/cdr/ostream.ixx @@ -131,11 +131,6 @@ namespace xsde { } - inline void - operator<< (ocdrstream&, const any_simple_type&) - { - } - #else // XSDE_EXCEPTIONS inline bool ocdrstream:: @@ -233,12 +228,6 @@ namespace xsde return true; } - inline bool - operator<< (ocdrstream&, const any_simple_type&) - { - return true; - } - #endif // XSDE_EXCEPTIONS } } diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.hxx b/libxsde/xsde/cxx/hybrid/xdr/istream.hxx index 188ee58..b7185c3 100644 --- a/libxsde/xsde/cxx/hybrid/xdr/istream.hxx +++ b/libxsde/xsde/cxx/hybrid/xdr/istream.hxx @@ -124,7 +124,6 @@ namespace xsde #ifdef XSDE_EXCEPTIONS void operator>> (ixdrstream&, any_type&); - void operator>> (ixdrstream&, any_simple_type&); void operator>> (ixdrstream&, qname&); void operator>> (ixdrstream&, string_sequence&); void operator>> (ixdrstream&, time_zone&); @@ -139,7 +138,6 @@ namespace xsde void operator>> (ixdrstream&, time&); #else bool operator>> (ixdrstream&, any_type&); - bool operator>> (ixdrstream&, any_simple_type&); bool operator>> (ixdrstream&, qname&); bool operator>> (ixdrstream&, string_sequence&); bool operator>> (ixdrstream&, time_zone&); diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.ixx b/libxsde/xsde/cxx/hybrid/xdr/istream.ixx index f11fd5c..4c9c585 100644 --- a/libxsde/xsde/cxx/hybrid/xdr/istream.ixx +++ b/libxsde/xsde/cxx/hybrid/xdr/istream.ixx @@ -163,11 +163,6 @@ namespace xsde { } - inline void - operator>> (ixdrstream&, any_simple_type&) - { - } - #else // XSDE_EXCEPTIONS inline bool ixdrstream:: @@ -301,12 +296,6 @@ namespace xsde return true; } - inline bool - operator>> (ixdrstream&, any_simple_type&) - { - return true; - } - #endif // XSDE_EXCEPTIONS } } diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx b/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx index bf6a3fe..1af22dd 100644 --- a/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx +++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.hxx @@ -124,7 +124,6 @@ namespace xsde #ifdef XSDE_EXCEPTIONS void operator<< (oxdrstream&, const any_type&); - void operator<< (oxdrstream&, const any_simple_type&); void operator<< (oxdrstream&, const qname&); void operator<< (oxdrstream&, const string_sequence&); void operator<< (oxdrstream&, const time_zone&); @@ -139,7 +138,6 @@ namespace xsde void operator<< (oxdrstream&, const time&); #else bool operator<< (oxdrstream&, const any_type&); - bool operator<< (oxdrstream&, const any_simple_type&); bool operator<< (oxdrstream&, const qname&); bool operator<< (oxdrstream&, const string_sequence&); bool operator<< (oxdrstream&, const time_zone&); diff --git a/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx b/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx index f31968f..4dc9bd9 100644 --- a/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx +++ b/libxsde/xsde/cxx/hybrid/xdr/ostream.ixx @@ -153,11 +153,6 @@ namespace xsde { } - inline void - operator<< (oxdrstream&, const any_simple_type&) - { - } - #else // XSDE_EXCEPTIONS inline bool oxdrstream:: @@ -265,12 +260,6 @@ namespace xsde return true; } - inline bool - operator<< (oxdrstream&, const any_simple_type&) - { - return true; - } - #endif // XSDE_EXCEPTIONS } } diff --git a/libxsde/xsde/cxx/parser/non-validating/any-simple-type-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/any-simple-type-stl.cxx new file mode 100644 index 0000000..5ebccaf --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/any-simple-type-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/parser/non-validating/any-simple-type-stl.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/any-simple-type-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void any_simple_type_pimpl:: + _pre () + { + str_.erase (); + } + + void any_simple_type_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + std::string any_simple_type_pimpl:: + post_any_simple_type () + { + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/any-simple-type-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/any-simple-type-stl.hxx new file mode 100644 index 0000000..94c061f --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/any-simple-type-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/any-simple-type-stl.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_ANY_SIMPLE_TYPE_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX + +#include <string> + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_pimpl: virtual any_simple_type_pskel +#else + struct any_simple_type_pimpl: any_simple_type_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_any_simple_type (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/any-simple-type.cxx b/libxsde/xsde/cxx/parser/non-validating/any-simple-type.cxx new file mode 100644 index 0000000..342f98c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/any-simple-type.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/any-simple-type.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/config.hxx> + +#include <xsde/cxx/parser/non-validating/any-simple-type.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void any_simple_type_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void any_simple_type_pimpl:: + _characters (const ro_string& s) + { +#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* any_simple_type_pimpl:: + post_any_simple_type () + { + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/any-simple-type.hxx b/libxsde/xsde/cxx/parser/non-validating/any-simple-type.hxx new file mode 100644 index 0000000..612f976 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/any-simple-type.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/any-simple-type.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_ANY_SIMPLE_TYPE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_ANY_SIMPLE_TYPE_HXX + +#include <xsde/cxx/string.hxx> + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_pimpl: virtual any_simple_type_pskel +#else + struct any_simple_type_pimpl: any_simple_type_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_any_simple_type (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_ANY_SIMPLE_TYPE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/any-type.hxx b/libxsde/xsde/cxx/parser/non-validating/any-type.hxx index 3b7b68e..0587872 100644 --- a/libxsde/xsde/cxx/parser/non-validating/any-type.hxx +++ b/libxsde/xsde/cxx/parser/non-validating/any-type.hxx @@ -16,8 +16,6 @@ namespace xsde { namespace non_validating { - // any_type - // #ifdef XSDE_REUSE_STYLE_MIXIN struct any_type_pimpl: virtual any_type_pskel #else @@ -25,16 +23,6 @@ namespace xsde #endif { }; - - // any_simple_type - // -#ifdef XSDE_REUSE_STYLE_MIXIN - struct any_simple_type_pimpl: virtual any_simple_type_pskel -#else - struct any_simple_type_pimpl: any_simple_type_pskel -#endif - { - }; } } } diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx index c150fdf..756e11a 100644 --- a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx @@ -9,6 +9,13 @@ #include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> #include <xsde/cxx/parser/non-validating/any-type.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/parser/non-validating/any-simple-type-stl.hxx> +#else +# include <xsde/cxx/parser/non-validating/any-simple-type.hxx> +#endif + #include <xsde/cxx/parser/non-validating/boolean.hxx> #include <xsde/cxx/parser/non-validating/byte.hxx> #include <xsde/cxx/parser/non-validating/unsigned-byte.hxx> diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.cxx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.cxx index 67ac5c8..e673a65 100644 --- a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.cxx @@ -67,24 +67,6 @@ namespace xsde #endif } - // any_simple_type - // - - bool any_simple_type_pskel:: - _characters_impl (const ro_string&) - { - return false; - } - - void any_simple_type_pskel:: - post_any_simple_type () - { -#ifdef XSDE_REUSE_STYLE_TIEIN - if (any_simple_type_impl_) - any_simple_type_impl_->post_any_simple_type (); -#endif - } - // static/dynamic_type function implementations. // @@ -609,4 +591,3 @@ namespace xsde } } } - 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 6b98277..17e4578 100644 --- a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx @@ -74,11 +74,12 @@ namespace xsde struct any_simple_type_pskel: simple_content { - virtual bool - _characters_impl (const ro_string&); - - virtual void - post_any_simple_type (); +#ifdef XSDE_STL + virtual std::string +#else + virtual char* +#endif + post_any_simple_type () = 0; #ifdef XSDE_POLYMORPHIC static const char* @@ -97,7 +98,6 @@ namespace xsde #endif }; - // Boolean. // diff --git a/libxsde/xsde/cxx/parser/validating/any-simple-type-stl.cxx b/libxsde/xsde/cxx/parser/validating/any-simple-type-stl.cxx new file mode 100644 index 0000000..b8fef17 --- /dev/null +++ b/libxsde/xsde/cxx/parser/validating/any-simple-type-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/parser/validating/any-simple-type-stl.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/validating/any-simple-type-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace validating + { + void any_simple_type_pimpl:: + _pre () + { + str_.erase (); + } + + void any_simple_type_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + std::string any_simple_type_pimpl:: + post_any_simple_type () + { + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/validating/any-simple-type-stl.hxx b/libxsde/xsde/cxx/parser/validating/any-simple-type-stl.hxx new file mode 100644 index 0000000..71931b8 --- /dev/null +++ b/libxsde/xsde/cxx/parser/validating/any-simple-type-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/validating/any-simple-type-stl.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_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX +#define XSDE_CXX_PARSER_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX + +#include <string> + +#include <xsde/cxx/parser/validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_pimpl: virtual any_simple_type_pskel +#else + struct any_simple_type_pimpl: any_simple_type_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_any_simple_type (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX diff --git a/libxsde/xsde/cxx/parser/validating/any-simple-type.cxx b/libxsde/xsde/cxx/parser/validating/any-simple-type.cxx new file mode 100644 index 0000000..943e600 --- /dev/null +++ b/libxsde/xsde/cxx/parser/validating/any-simple-type.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/validating/any-simple-type.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/config.hxx> + +#include <xsde/cxx/parser/validating/any-simple-type.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace validating + { + void any_simple_type_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void any_simple_type_pimpl:: + _characters (const ro_string& s) + { +#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* any_simple_type_pimpl:: + post_any_simple_type () + { + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/validating/any-simple-type.hxx b/libxsde/xsde/cxx/parser/validating/any-simple-type.hxx new file mode 100644 index 0000000..2aa6b9a --- /dev/null +++ b/libxsde/xsde/cxx/parser/validating/any-simple-type.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/validating/any-simple-type.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_VALIDATING_ANY_SIMPLE_TYPE_HXX +#define XSDE_CXX_PARSER_VALIDATING_ANY_SIMPLE_TYPE_HXX + +#include <xsde/cxx/string.hxx> + +#include <xsde/cxx/parser/validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_pimpl: virtual any_simple_type_pskel +#else + struct any_simple_type_pimpl: any_simple_type_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_any_simple_type (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_VALIDATING_ANY_SIMPLE_TYPE_HXX diff --git a/libxsde/xsde/cxx/parser/validating/any-type.hxx b/libxsde/xsde/cxx/parser/validating/any-type.hxx index a8b2cb5..f8d1c08 100644 --- a/libxsde/xsde/cxx/parser/validating/any-type.hxx +++ b/libxsde/xsde/cxx/parser/validating/any-type.hxx @@ -16,8 +16,6 @@ namespace xsde { namespace validating { - // any_type - // #ifdef XSDE_REUSE_STYLE_MIXIN struct any_type_pimpl: virtual any_type_pskel #else @@ -25,16 +23,6 @@ namespace xsde #endif { }; - - // any_simple_type - // -#ifdef XSDE_REUSE_STYLE_MIXIN - struct any_simple_type_pimpl: virtual any_simple_type_pskel -#else - struct any_simple_type_pimpl: any_simple_type_pskel -#endif - { - }; } } } diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pimpl.hxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pimpl.hxx index 6353607..4a898ce 100644 --- a/libxsde/xsde/cxx/parser/validating/xml-schema-pimpl.hxx +++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pimpl.hxx @@ -9,6 +9,13 @@ #include <xsde/cxx/parser/validating/xml-schema-pskel.hxx> #include <xsde/cxx/parser/validating/any-type.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/parser/validating/any-simple-type-stl.hxx> +#else +# include <xsde/cxx/parser/validating/any-simple-type.hxx> +#endif + #include <xsde/cxx/parser/validating/boolean.hxx> #include <xsde/cxx/parser/validating/byte.hxx> #include <xsde/cxx/parser/validating/unsigned-byte.hxx> diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.cxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.cxx index a94766c..2e0a02c 100644 --- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.cxx +++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.cxx @@ -73,24 +73,6 @@ namespace xsde #endif } - // any_simple_type - // - bool any_simple_type_pskel:: - _characters_impl (const ro_string& s) - { - _any_characters (s); - return true; - } - - void any_simple_type_pskel:: - post_any_simple_type () - { -#ifdef XSDE_REUSE_STYLE_TIEIN - if (any_simple_type_impl_) - any_simple_type_impl_->post_any_simple_type (); -#endif - } - // static/dynamic_type function implementations. // #ifdef XSDE_POLYMORPHIC @@ -614,4 +596,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx index f794188..0879bb3 100644 --- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx +++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx @@ -76,11 +76,12 @@ namespace xsde struct any_simple_type_pskel: simple_content { - virtual bool - _characters_impl (const ro_string&); - - virtual void - post_any_simple_type (); +#ifdef XSDE_STL + virtual std::string +#else + virtual char* +#endif + post_any_simple_type () = 0; #ifdef XSDE_POLYMORPHIC static const char* @@ -99,7 +100,6 @@ namespace xsde #endif }; - // Boolean. // struct boolean_pskel: simple_content diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-simple-type-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type-stl.cxx new file mode 100644 index 0000000..f7f16c9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/non-validating/any-simple-type-stl.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/serializer/non-validating/any-simple-type-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + void any_simple_type_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void any_simple_type_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-simple-type-stl.hxx b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type-stl.hxx new file mode 100644 index 0000000..a97609d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/non-validating/any-simple-type-stl.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_SERIALIZER_NON_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.cxx b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.cxx new file mode 100644 index 0000000..e81c9c6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.cxx @@ -0,0 +1,59 @@ +// file : xsde/cxx/serializer/non-validating/any-simple-type.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/serializer/non-validating/any-simple-type.hxx> + +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + any_simple_type_simpl:: + ~any_simple_type_simpl () + { + if (free_ && value_) + { + char* v = const_cast<char*> (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } + } + + void any_simple_type_simpl:: + pre (const char* value) + { + value_ = value; + } + + void any_simple_type_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + char* v = const_cast<char*> (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.hxx b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.hxx new file mode 100644 index 0000000..d41660c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/non-validating/any-simple-type.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_SERIALIZER_NON_VALIDATING_ANY_SIMPLE_TYPE_HXX +#define XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_SIMPLE_TYPE_HXX + +#include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + virtual + ~any_simple_type_simpl (); + + any_simple_type_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/non-validating/any-simple-type.ixx> + +#endif // XSDE_CXX_SERIALIZER_NON_VALIDATING_ANY_SIMPLE_TYPE_HXX diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.ixx b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.ixx new file mode 100644 index 0000000..e94c905 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/non-validating/any-simple-type.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/non-validating/any-simple-type.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace non_validating + { + inline any_simple_type_simpl:: + any_simple_type_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx b/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx index 7eb966d..6795abc 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx +++ b/libxsde/xsde/cxx/serializer/non-validating/any-type.hxx @@ -25,16 +25,6 @@ namespace xsde #endif { }; - - // any_simple_type - // -#ifdef XSDE_REUSE_STYLE_MIXIN - struct any_simple_type_simpl: virtual any_simple_type_sskel -#else - struct any_simple_type_simpl: any_simple_type_sskel -#endif - { - }; } } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx index 98b3d38..c8e8baf 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-simpl.hxx @@ -9,6 +9,13 @@ #include <xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx> #include <xsde/cxx/serializer/non-validating/any-type.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/serializer/non-validating/any-simple-type-stl.hxx> +#else +# include <xsde/cxx/serializer/non-validating/any-simple-type.hxx> +#endif + #include <xsde/cxx/serializer/non-validating/boolean.hxx> #include <xsde/cxx/serializer/non-validating/byte.hxx> #include <xsde/cxx/serializer/non-validating/unsigned-byte.hxx> diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx index 0eda610..ab9dd98 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.cxx @@ -24,17 +24,6 @@ namespace xsde #endif } - // any_simple_type_sskel - // - void any_simple_type_sskel:: - pre () - { -#ifdef XSDE_REUSE_STYLE_TIEIN - if (any_simple_type_impl_) - any_simple_type_impl_->pre (); -#endif - } - // static/dynamic_type function implementations. // #ifdef XSDE_POLYMORPHIC diff --git a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx index 9a72338..508197a 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx +++ b/libxsde/xsde/cxx/serializer/non-validating/xml-schema-sskel.hxx @@ -61,14 +61,11 @@ namespace xsde struct any_simple_type_sskel: simple_content { virtual void - pre (); - - // Override the following function to implement your - // logic. - // - - // virtual void - // _serialize_content (); +#ifdef XSDE_STL + pre (const std::string&) = 0; +#else + pre (const char*) = 0; +#endif #ifdef XSDE_POLYMORPHIC static const char* diff --git a/libxsde/xsde/cxx/serializer/validating/any-simple-type-stl.cxx b/libxsde/xsde/cxx/serializer/validating/any-simple-type-stl.cxx new file mode 100644 index 0000000..f308e6c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-simple-type-stl.cxx @@ -0,0 +1,34 @@ +// file : xsde/cxx/serializer/validating/any-simple-type-stl.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/serializer/validating/any-simple-type-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void any_simple_type_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void any_simple_type_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/any-simple-type-stl.hxx b/libxsde/xsde/cxx/serializer/validating/any-simple-type-stl.hxx new file mode 100644 index 0000000..0990b85 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-simple-type-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/validating/any-simple-type-stl.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_SERIALIZER_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ANY_SIMPLE_TYPE_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/any-simple-type.cxx b/libxsde/xsde/cxx/serializer/validating/any-simple-type.cxx new file mode 100644 index 0000000..6de1db8 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-simple-type.cxx @@ -0,0 +1,59 @@ +// file : xsde/cxx/serializer/validating/any-simple-type.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/serializer/validating/any-simple-type.hxx> + +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + any_simple_type_simpl:: + ~any_simple_type_simpl () + { + if (free_ && value_) + { + char* v = const_cast<char*> (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } + } + + void any_simple_type_simpl:: + pre (const char* value) + { + value_ = value; + } + + void any_simple_type_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + char* v = const_cast<char*> (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/any-simple-type.hxx b/libxsde/xsde/cxx/serializer/validating/any-simple-type.hxx new file mode 100644 index 0000000..7499a21 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-simple-type.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/validating/any-simple-type.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_SERIALIZER_VALIDATING_ANY_SIMPLE_TYPE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ANY_SIMPLE_TYPE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + virtual + ~any_simple_type_simpl (); + + any_simple_type_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/any-simple-type.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ANY_SIMPLE_TYPE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/any-simple-type.ixx b/libxsde/xsde/cxx/serializer/validating/any-simple-type.ixx new file mode 100644 index 0000000..f5fea6a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-simple-type.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/any-simple-type.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inline any_simple_type_simpl:: + any_simple_type_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/any-type.hxx b/libxsde/xsde/cxx/serializer/validating/any-type.hxx index dfa0b87..e1df6e1 100644 --- a/libxsde/xsde/cxx/serializer/validating/any-type.hxx +++ b/libxsde/xsde/cxx/serializer/validating/any-type.hxx @@ -25,16 +25,6 @@ namespace xsde #endif { }; - - // any_simple_type - // -#ifdef XSDE_REUSE_STYLE_MIXIN - struct any_simple_type_simpl: virtual any_simple_type_sskel -#else - struct any_simple_type_simpl: any_simple_type_sskel -#endif - { - }; } } } diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx index 9a81eed..d2bc3a7 100644 --- a/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx @@ -9,6 +9,13 @@ #include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> #include <xsde/cxx/serializer/validating/any-type.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/serializer/validating/any-simple-type-stl.hxx> +#else +# include <xsde/cxx/serializer/validating/any-simple-type.hxx> +#endif + #include <xsde/cxx/serializer/validating/boolean.hxx> #include <xsde/cxx/serializer/validating/byte.hxx> #include <xsde/cxx/serializer/validating/unsigned-byte.hxx> diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx index 6ca2101..6154746 100644 --- a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx @@ -24,17 +24,6 @@ namespace xsde #endif } - // any_simple_type_sskel - // - void any_simple_type_sskel:: - pre () - { -#ifdef XSDE_REUSE_STYLE_TIEIN - if (any_simple_type_impl_) - any_simple_type_impl_->pre (); -#endif - } - // static/dynamic_type function implementations. // #ifdef XSDE_POLYMORPHIC diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx index c8e7466..7ccb233 100644 --- a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx @@ -65,14 +65,11 @@ namespace xsde struct any_simple_type_sskel: simple_content { virtual void - pre (); - - // Override the following function to implement your - // logic. - // - - // virtual void - // _serialize_content (); +#ifdef XSDE_STL + pre (const std::string&) = 0; +#else + pre (const char*) = 0; +#endif #ifdef XSDE_POLYMORPHIC static const char* diff --git a/libxsde/xsde/makefile b/libxsde/xsde/makefile index 9787855..ce95980 100644 --- a/libxsde/xsde/makefile +++ b/libxsde/xsde/makefile @@ -168,6 +168,7 @@ endif ifeq ($(xsde_stl),y) cxx_tun += \ +cxx/parser/validating/any-simple-type-stl.cxx \ cxx/parser/validating/string-stl.cxx \ cxx/parser/validating/normalized-string-stl.cxx \ cxx/parser/validating/token-stl.cxx \ @@ -185,6 +186,7 @@ cxx/parser/validating/qname-stl.cxx else cxx_tun += \ +cxx/parser/validating/any-simple-type.cxx \ cxx/parser/validating/string.cxx \ cxx/parser/validating/normalized-string.cxx \ cxx/parser/validating/token.cxx \ @@ -253,6 +255,7 @@ endif ifeq ($(xsde_stl),y) cxx_tun += \ +cxx/parser/non-validating/any-simple-type-stl.cxx \ cxx/parser/non-validating/string-stl.cxx \ cxx/parser/non-validating/normalized-string-stl.cxx \ cxx/parser/non-validating/token-stl.cxx \ @@ -270,6 +273,7 @@ cxx/parser/non-validating/qname-stl.cxx else cxx_tun += \ +cxx/parser/non-validating/any-simple-type.cxx \ cxx/parser/non-validating/string.cxx \ cxx/parser/non-validating/normalized-string.cxx \ cxx/parser/non-validating/token.cxx \ @@ -362,6 +366,7 @@ endif ifeq ($(xsde_stl),y) cxx_tun += \ +cxx/serializer/validating/any-simple-type-stl.cxx \ cxx/serializer/validating/string-stl.cxx \ cxx/serializer/validating/normalized-string-stl.cxx \ cxx/serializer/validating/token-stl.cxx \ @@ -379,6 +384,7 @@ cxx/serializer/validating/qname-stl.cxx else cxx_tun += \ +cxx/serializer/validating/any-simple-type.cxx \ cxx/serializer/validating/string.cxx \ cxx/serializer/validating/normalized-string.cxx \ cxx/serializer/validating/token.cxx \ @@ -445,6 +451,7 @@ endif ifeq ($(xsde_stl),y) cxx_tun += \ +cxx/serializer/non-validating/any-simple-type-stl.cxx \ cxx/serializer/non-validating/string-stl.cxx \ cxx/serializer/non-validating/normalized-string-stl.cxx \ cxx/serializer/non-validating/token-stl.cxx \ @@ -462,6 +469,7 @@ cxx/serializer/non-validating/qname-stl.cxx else cxx_tun += \ +cxx/serializer/non-validating/any-simple-type.cxx \ cxx/serializer/non-validating/string.cxx \ cxx/serializer/non-validating/normalized-string.cxx \ cxx/serializer/non-validating/token.cxx \ diff --git a/tests/cxx/hybrid/built-in/driver.cxx b/tests/cxx/hybrid/built-in/driver.cxx index ddffcfa..0993bc9 100644 --- a/tests/cxx/hybrid/built-in/driver.cxx +++ b/tests/cxx/hybrid/built-in/driver.cxx @@ -49,7 +49,7 @@ main (int argc, char* argv[]) doc_s.add_prefix ("t", "test"); root_s.pre (*r); - doc_s.serialize (cout); + doc_s.serialize (cout, xml_schema::document_simpl::pretty_print); root_s.post (); delete r; diff --git a/tests/cxx/hybrid/built-in/test-000.std b/tests/cxx/hybrid/built-in/test-000.std index 6798590..c9a79c7 100644 --- a/tests/cxx/hybrid/built-in/test-000.std +++ b/tests/cxx/hybrid/built-in/test-000.std @@ -1,5 +1,25 @@ -<t:root xmlns:t="test"><any></any><any-res x="x"><a>123</a><b>abc</b></any-res><any-simple></any-simple><any-simple-ext x="x"></any-simple-ext><int>123</int><simple-int>456</simple-int><int-base x="x">789</int-base><int-derived x="x" y="y">123</int-derived><bin>YmFzZTY0IGJpbmFyeQ== -</bin><simple-bin>YmFzZTY0IGJpbmFyeQ== -</simple-bin><bin-base x="x">YmFzZTY0IGJpbmFyeQ== -</bin-base><bin-derived x="x" y="y">YmFzZTY0IGJpbmFyeQ== -</bin-derived><string>abc</string><simple-string>def</simple-string><string-base x="x">ghi</string-base><string-derived x="x" y="y">jkl</string-derived></t:root>
\ No newline at end of file +<t:root xmlns:t="test" any-simple-attr="abc123"> + <any></any> + <any-res x="x"> + <a>123</a> + <b>abc</b> + </any-res> + <any-simple>abc123</any-simple> + <any-simple-ext x="x">abc123</any-simple-ext> + <int>123</int> + <simple-int>456</simple-int> + <int-base x="x">789</int-base> + <int-derived x="x" y="y">123</int-derived> + <bin>YmFzZTY0IGJpbmFyeQ== +</bin> + <simple-bin>YmFzZTY0IGJpbmFyeQ== +</simple-bin> + <bin-base x="x">YmFzZTY0IGJpbmFyeQ== +</bin-base> + <bin-derived x="x" y="y">YmFzZTY0IGJpbmFyeQ== +</bin-derived> + <string>abc</string> + <simple-string>def</simple-string> + <string-base x="x">ghi</string-base> + <string-derived x="x" y="y">jkl</string-derived> +</t:root>
\ No newline at end of file diff --git a/tests/cxx/hybrid/built-in/test-000.xml b/tests/cxx/hybrid/built-in/test-000.xml index ae72e80..cc9b8c8 100644 --- a/tests/cxx/hybrid/built-in/test-000.xml +++ b/tests/cxx/hybrid/built-in/test-000.xml @@ -1,10 +1,10 @@ -<t:root xmlns:t="test" any-simple-attr=""> +<t:root xmlns:t="test" any-simple-attr="abc123"> <any></any> <any-res x="x"><a>123</a><b>abc</b></any-res> - <any-simple></any-simple> - <any-simple-ext x="x"></any-simple-ext> + <any-simple>abc123</any-simple> + <any-simple-ext x="x">abc123</any-simple-ext> <int>123</int> <simple-int>456</simple-int> diff --git a/tests/cxx/parser/built-in/driver.cxx b/tests/cxx/parser/built-in/driver.cxx index 1ec5e15..1ac8823 100644 --- a/tests/cxx/parser/built-in/driver.cxx +++ b/tests/cxx/parser/built-in/driver.cxx @@ -64,28 +64,6 @@ struct any_type_pimpl: xml_schema::any_type_pimpl } }; -struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_simple_type () - { - cout << "}" << endl - << endl; - } -}; - struct type_pimpl: type_pskel { virtual void @@ -208,6 +186,12 @@ struct type_pimpl: type_pskel #ifdef XSDE_STL virtual void + any_simple_type (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void string (std::string const& v) { cout << "'" << v << "'" << endl; @@ -302,6 +286,13 @@ struct type_pimpl: type_pskel #else // XSDE_STL virtual void + any_simple_type (char* v) + { + cout << "'" << v << "'" << endl; + delete[] v; + } + + virtual void string (char* v) { cout << "'" << v << "'" << endl; @@ -571,7 +562,7 @@ main (int argc, char* argv[]) try { any_type_pimpl any_type_p; - any_simple_type_pimpl any_simple_type_p; + xml_schema::any_simple_type_pimpl any_simple_type_p; xml_schema::boolean_pimpl boolean_p; diff --git a/tests/cxx/parser/built-in/test-001.std b/tests/cxx/parser/built-in/test-001.std index 3b80787..7f1990e 100644 --- a/tests/cxx/parser/built-in/test-001.std +++ b/tests/cxx/parser/built-in/test-001.std @@ -22,10 +22,7 @@ any text: ' ' } -{ - any text: '123abc' -} - +'123abc' 1 0 1 diff --git a/tests/cxx/parser/generated-impl/test-000.std b/tests/cxx/parser/generated-impl/test-000.std index 7c58647..8fd9e30 100644 --- a/tests/cxx/parser/generated-impl/test-000.std +++ b/tests/cxx/parser/generated-impl/test-000.std @@ -19,6 +19,7 @@ x: x y: y a: aaa b: bbb +any-simple-type: abc123 boolean: 1 boolean: 0 boolean: 1 diff --git a/tests/cxx/parser/validation/built-in/any-type/driver.cxx b/tests/cxx/parser/validation/built-in/any-type/driver.cxx index b60beed..3ffffa6 100644 --- a/tests/cxx/parser/validation/built-in/any-type/driver.cxx +++ b/tests/cxx/parser/validation/built-in/any-type/driver.cxx @@ -61,28 +61,6 @@ struct any_type_pimpl: xml_schema::any_type_pimpl } }; -struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl -{ - virtual void - pre () - { - cout << "{" << endl; - } - - virtual void - _any_characters (ro_string const& s) - { - cout << " any text: '" << s << "'" << endl; - } - - virtual void - post_any_simple_type () - { - cout << "}" << endl - << endl; - } -}; - struct any_extension_pimpl: any_extension_pskel { any_extension_pimpl () @@ -103,7 +81,7 @@ struct any_extension_pimpl: any_extension_pskel cout << " x = " << v << endl; delete[] v; } -#endif +#endif private: any_type_pimpl base_impl_; @@ -122,6 +100,12 @@ struct any_simple_extension_pimpl: any_simple_extension_pskel { cout << " x = " << v << endl; } + + virtual void + post_any_simple_extension () + { + cout << "'" << post_any_simple_type () << "'" << endl; + } #else virtual void x (char* v) @@ -129,14 +113,36 @@ struct any_simple_extension_pimpl: any_simple_extension_pskel cout << " x = " << v << endl; delete[] v; } -#endif + + virtual void + post_any_simple_extension () + { + char& v = post_any_simple_type (); + cout << "'" << b << "'" << endl; + delete[] v; + } +#endif private: - any_simple_type_pimpl base_impl_; + xml_schema::any_simple_type_pimpl base_impl_; }; struct type_pimpl: type_pskel { +#ifdef XSDE_STL + virtual void + as (std::string const& v) + { + cout << "'" << v << "'" << endl; + } +#else // XSDE_STL + virtual void + as (char* v) + { + cout << "'" << v << "'" << endl; + delete[] v; + } +#endif }; int @@ -153,7 +159,7 @@ main (int argc, char* argv[]) xml_schema::string_pimpl string_p; any_type_pimpl any_type_p; - any_simple_type_pimpl any_simple_type_p; + xml_schema::any_simple_type_pimpl any_simple_type_p; any_extension_pimpl any_extension_p; any_simple_extension_pimpl any_simple_extension_p; diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.std b/tests/cxx/parser/validation/built-in/any-type/test-000.std index 9e263c0..c1996cb 100644 --- a/tests/cxx/parser/validation/built-in/any-type/test-000.std +++ b/tests/cxx/parser/validation/built-in/any-type/test-000.std @@ -1,7 +1,4 @@ -{ - any text: '123abc' -} - +'123abc' { any text: ' ' @@ -106,8 +103,5 @@ any text: ' ' } -{ x = x - any text: 'abc123' -} - +'abc123' diff --git a/tests/cxx/serializer/built-in/driver.cxx b/tests/cxx/serializer/built-in/driver.cxx index f7ea95f..c2ddea0 100644 --- a/tests/cxx/serializer/built-in/driver.cxx +++ b/tests/cxx/serializer/built-in/driver.cxx @@ -33,7 +33,7 @@ struct any_type_simpl: xml_schema::any_type_simpl _end_element (); } }; - +/* struct any_simple_type_simpl: xml_schema::any_simple_type_simpl { virtual void @@ -42,6 +42,7 @@ struct any_simple_type_simpl: xml_schema::any_simple_type_simpl _characters ("hello"); } }; +*/ struct root_simpl: root_sskel { @@ -401,6 +402,12 @@ struct root_simpl: root_sskel #ifdef XSDE_STL + virtual std::string + any_simple_type () + { + return "hello"; + } + virtual bool string_next () { @@ -615,6 +622,12 @@ struct root_simpl: root_sskel #else + virtual const char* + any_simple_type () + { + return "hello"; + } + virtual bool string_next () { @@ -1242,7 +1255,7 @@ main (int argc, char* argv[]) } any_type_simpl any_type_s; - any_simple_type_simpl any_simple_type_s; + xml_schema::any_simple_type_simpl any_simple_type_s; xml_schema::boolean_simpl boolean_s; diff --git a/xsde/cxx/elements.cxx b/xsde/cxx/elements.cxx index 7fe8b3f..2289e32 100644 --- a/xsde/cxx/elements.cxx +++ b/xsde/cxx/elements.cxx @@ -1339,6 +1339,13 @@ namespace CXX return literal_; } + Void LiteralValue:: + traverse (SemanticGraph::AnySimpleType&) + { + if (str_) + literal_ = strlit (value_); + } + // Boolean. // Void LiteralValue:: diff --git a/xsde/cxx/elements.hxx b/xsde/cxx/elements.hxx index c9f79f2..5952e68 100644 --- a/xsde/cxx/elements.hxx +++ b/xsde/cxx/elements.hxx @@ -617,7 +617,9 @@ namespace CXX } }; - struct LiteralValue: Traversal::Fundamental::Byte, + struct LiteralValue: Traversal::AnySimpleType, + + Traversal::Fundamental::Byte, Traversal::Fundamental::UnsignedByte, Traversal::Fundamental::Short, Traversal::Fundamental::UnsignedShort, @@ -657,6 +659,9 @@ namespace CXX String dispatch (SemanticGraph::Node& type, String const& value); + virtual Void + traverse (SemanticGraph::AnySimpleType&); + // Boolean. // virtual Void diff --git a/xsde/cxx/hybrid/default-value.cxx b/xsde/cxx/hybrid/default-value.cxx index d63c636..712f405 100644 --- a/xsde/cxx/hybrid/default-value.cxx +++ b/xsde/cxx/hybrid/default-value.cxx @@ -229,8 +229,9 @@ namespace CXX // anySimpleType. // Void InitValue:: - traverse (SemanticGraph::AnySimpleType&) + traverse (SemanticGraph::AnySimpleType& t) { + string_type (t); } // Strings. @@ -741,7 +742,7 @@ namespace CXX } Void InitValue:: - string_type (SemanticGraph::Fundamental::Type& t) + string_type (SemanticGraph::Type& t) { // In case STL is disabled, strings are returned as literals // so we end up here only if the type is derived from a string. diff --git a/xsde/cxx/hybrid/default-value.hxx b/xsde/cxx/hybrid/default-value.hxx index aef9049..00bd2e0 100644 --- a/xsde/cxx/hybrid/default-value.hxx +++ b/xsde/cxx/hybrid/default-value.hxx @@ -177,7 +177,7 @@ namespace CXX private: Void - string_type (SemanticGraph::Fundamental::Type&); + string_type (SemanticGraph::Type&); Void string_sequence_type (); diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx index 7bd8bd1..50f0931 100644 --- a/xsde/cxx/hybrid/elements.hxx +++ b/xsde/cxx/hybrid/elements.hxx @@ -798,7 +798,9 @@ namespace CXX // // - struct StringType: Traversal::Fundamental::String, + struct StringType: Traversal::AnySimpleType, + + Traversal::Fundamental::String, Traversal::Fundamental::NormalizedString, Traversal::Fundamental::Token, Traversal::Fundamental::Name, @@ -816,6 +818,12 @@ namespace CXX } virtual Void + traverse (SemanticGraph::AnySimpleType&) + { + r_ = true; + } + + virtual Void traverse (SemanticGraph::Fundamental::String&) { r_ = true; @@ -1098,9 +1106,12 @@ namespace CXX } virtual Void - traverse (SemanticGraph::AnySimpleType& t) + traverse (SemanticGraph::AnySimpleType&) { - type (t); + if (stl || use_ != base) + string_type (); + else + os << xs_ns_ << "::any_simple_type_base"; } // Boolean. @@ -1688,7 +1699,7 @@ namespace CXX virtual Void traverse (SemanticGraph::AnySimpleType& t) { - type (t); + string_type (t); } // Boolean. diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx index 99a350a..c610101 100644 --- a/xsde/cxx/hybrid/parser-source.cxx +++ b/xsde/cxx/hybrid/parser-source.cxx @@ -1836,11 +1836,9 @@ namespace CXX // The following code is similar to what we have in post(). // - // Default parser implementations for anyType and - // anySimpleType return void. + // Default parser implementation for anyType returns void. // - if (!b.is_a<SemanticGraph::AnyType> () && - !b.is_a<SemanticGraph::AnySimpleType> ()) + if (!b.is_a<SemanticGraph::AnyType> ()) { // If our base is a fixed-length type then copy the data // over. Note that it cannot be a C-string. @@ -1999,11 +1997,9 @@ namespace CXX { SemanticGraph::Type& b (c.inherits ().base ()); - // Default parser implementations for anyType and - // anySimpleType return void. + // Default parser implementation for anyType returns void. // - if (!b.is_a<SemanticGraph::AnyType> () && - !b.is_a<SemanticGraph::AnySimpleType> ()) + if (!b.is_a<SemanticGraph::AnyType> ()) { // If we are recursive but our base is not, we only call // base post() if it is the first post call. diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx index 9377c5f..ef9eae9 100644 --- a/xsde/cxx/hybrid/serializer-source.cxx +++ b/xsde/cxx/hybrid/serializer-source.cxx @@ -1234,11 +1234,10 @@ namespace CXX << endl; } - // Call base pre(). Default serializer implementations for - // anyType and anySimpleType return void. + // Call base pre(). Default serializer implementation for + // anyType takes void. // - if (!b.is_a<SemanticGraph::AnyType> () && - !b.is_a<SemanticGraph::AnySimpleType> ()) + if (!b.is_a<SemanticGraph::AnyType> ()) { if (tiein) os << "this->base_impl_.pre ("; diff --git a/xsde/cxx/hybrid/tree-forward.cxx b/xsde/cxx/hybrid/tree-forward.cxx index dbfdd7e..c9df43c 100644 --- a/xsde/cxx/hybrid/tree-forward.cxx +++ b/xsde/cxx/hybrid/tree-forward.cxx @@ -243,7 +243,12 @@ namespace CXX virtual Void traverse (SemanticGraph::AnySimpleType&) { - gen_using ("::xsde::cxx::hybrid::any_simple_type"); + gen_typedef ("any_simple_type", string_type_); + + if (!stl) + gen_typedef ("any_simple_type_base", + "::xsde::cxx::hybrid::string_base"); + os << endl; } // Boolean. diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx index c596ab0..b82cb7b 100644 --- a/xsde/cxx/hybrid/tree-header.cxx +++ b/xsde/cxx/hybrid/tree-header.cxx @@ -740,7 +740,7 @@ namespace CXX virtual Void traverse (SemanticGraph::AnySimpleType&) { - align_type ("char", 1); + align_type ("size_t", 5); // std::string } // Boolean. diff --git a/xsde/cxx/hybrid/tree-size-processor.cxx b/xsde/cxx/hybrid/tree-size-processor.cxx index bf7b328..e56b828 100644 --- a/xsde/cxx/hybrid/tree-size-processor.cxx +++ b/xsde/cxx/hybrid/tree-size-processor.cxx @@ -559,7 +559,7 @@ namespace CXX virtual Void traverse (SemanticGraph::AnySimpleType& t) { - set (t, true); + set (t, stl); } // Boolean. diff --git a/xsde/cxx/parser/generator.cxx b/xsde/cxx/parser/generator.cxx index 74ba2ea..b6f91ee 100644 --- a/xsde/cxx/parser/generator.cxx +++ b/xsde/cxx/parser/generator.cxx @@ -718,6 +718,8 @@ namespace CXX String qname (xns + L"::qname*"); String string_seq (xns + L"::string_sequence*"); + xsd_std.types_push_back ("anySimpleType", "char*", "char*"); + xsd_std.types_push_back ("string", "char*", "char*"); xsd_std.types_push_back ("normalizedString", "char*", "char*"); xsd_std.types_push_back ("token", "char*", "char*"); @@ -743,6 +745,8 @@ namespace CXX String qname (xns + L"::qname"); String string_seq (xns + L"::string_sequence*"); + xsd_std.types_push_back ("anySimpleType", "::std::string"); + xsd_std.types_push_back ("string", "::std::string"); xsd_std.types_push_back ("normalizedString", "::std::string"); xsd_std.types_push_back ("token", "::std::string"); diff --git a/xsde/cxx/parser/parser-header.cxx b/xsde/cxx/parser/parser-header.cxx index 11176f9..fe6d67b 100644 --- a/xsde/cxx/parser/parser-header.cxx +++ b/xsde/cxx/parser/parser-header.cxx @@ -1222,7 +1222,7 @@ namespace CXX virtual Void traverse (SemanticGraph::AnySimpleType& t) { - gen_typedef (t, "void"); + gen_typedef (t, string_type_); } // Boolean. diff --git a/xsde/cxx/parser/print-impl-common.hxx b/xsde/cxx/parser/print-impl-common.hxx index 13325bd..4dba38f 100644 --- a/xsde/cxx/parser/print-impl-common.hxx +++ b/xsde/cxx/parser/print-impl-common.hxx @@ -17,6 +17,8 @@ namespace CXX { struct PrintCall: Traversal::Type, + Traversal::AnySimpleType, + Traversal::Fundamental::Boolean, Traversal::Fundamental::Byte, @@ -80,6 +82,12 @@ namespace CXX gen_user_type (); } + virtual Void + traverse (SemanticGraph::AnySimpleType& t) + { + gen_string (t); + } + // Boolean. // virtual Void @@ -885,7 +893,9 @@ namespace CXX String arg_; }; - struct DeleteCall: Traversal::Fundamental::String, + struct DeleteCall: Traversal::AnySimpleType, + + Traversal::Fundamental::String, Traversal::Fundamental::NormalizedString, Traversal::Fundamental::Token, Traversal::Fundamental::Name, @@ -912,6 +922,12 @@ namespace CXX { } + virtual Void + traverse (SemanticGraph::AnySimpleType& t) + { + gen_string (t); + } + // Strings. // virtual Void diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx index 5c94c98..36539f4 100644 --- a/xsde/cxx/serializer/generator.cxx +++ b/xsde/cxx/serializer/generator.cxx @@ -703,6 +703,8 @@ namespace CXX String qname (L"const " + xns + L"::qname*"); String string_seq (L"const " + xns + L"::string_sequence*"); + xsd_std.types_push_back ("anySimpleType", "const char*", "const char*"); + xsd_std.types_push_back ("string", "const char*", "const char*"); xsd_std.types_push_back ("normalizedString", "const char*", "const char*"); xsd_std.types_push_back ("token", "const char*", "const char*"); @@ -728,6 +730,8 @@ namespace CXX String qname (xns + L"::qname"); String string_seq (L"const " + xns + L"::string_sequence*"); + xsd_std.types_push_back ("anySimpleType", "::std::string"); + xsd_std.types_push_back ("string", "::std::string"); xsd_std.types_push_back ("normalizedString", "::std::string"); xsd_std.types_push_back ("token", "::std::string"); diff --git a/xsde/cxx/serializer/serializer-header.cxx b/xsde/cxx/serializer/serializer-header.cxx index 9f0c1f3..e8fd2f5 100644 --- a/xsde/cxx/serializer/serializer-header.cxx +++ b/xsde/cxx/serializer/serializer-header.cxx @@ -1384,7 +1384,7 @@ namespace CXX virtual Void traverse (SemanticGraph::AnySimpleType& t) { - gen_typedef (t, "void"); + gen_typedef (t, string_type_); } // Boolean. |