diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
commit | a15cf65c44d5c224169c32ef5495b68c758134b7 (patch) | |
tree | 3419f58fc8e1b315ba8171910ee044c5d467c162 /xsd/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx |
Imported Upstream version 3.3.0.2upstream/3.3.0.2
Diffstat (limited to 'xsd/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx')
-rw-r--r-- | xsd/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/xsd/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx b/xsd/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx new file mode 100644 index 0000000..e908dd0 --- /dev/null +++ b/xsd/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/unsigned-int.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 XSD_CXX_TREE_PARSING_UNSIGNED_INT_HXX +#define XSD_CXX_TREE_PARSING_UNSIGNED_INT_HXX + +#include <xsd/cxx/ro-string.hxx> +#include <xsd/cxx/zc-istream.hxx> + +#include <xsd/cxx/xml/string.hxx> // xml::transcode + +#include <xsd/cxx/tree/text.hxx> // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template <typename C> + struct traits<unsigned int, C, schema_type::other> + { + typedef unsigned int type; + + static type + create (const xercesc::DOMElement& e, flags f, container* c); + + static type + create (const xercesc::DOMAttr& a, flags f, container* c); + + static type + create (const std::basic_string<C>& s, + const xercesc::DOMElement*, + flags, + container*); + }; + + template <typename C> + unsigned int traits<unsigned int, C, schema_type::other>:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content<C> (e), 0, f, c); + } + + template <typename C> + unsigned int traits<unsigned int, C, schema_type::other>:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode<C> (a.getValue ()), 0, f, c); + } + + template <typename C> + unsigned int traits<unsigned int, C, schema_type::other>:: + create (const std::basic_string<C>& s, + const xercesc::DOMElement*, + flags, + container*) + { + // This type cannot have whitespaces in its values. As result we + // don't need to waste time collapsing whitespaces. All we need to + // do is trim the string representation which can be done without + // copying. + // + ro_string<C> tmp (s); + trim (tmp); + + zc_istream<C> is (tmp); + + type t; + is >> t; + + return t; + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_UNSIGNED_INT_HXX |