From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx (limited to 'libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx') diff --git a/libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx b/libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx new file mode 100644 index 0000000..7896f9e --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/unsigned-short.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_PARSING_UNSIGNED_SHORT_HXX +#define XSD_CXX_TREE_PARSING_UNSIGNED_SHORT_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef unsigned short 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& s, + const xercesc::DOMElement*, + flags, + container*); + }; + + template + unsigned short traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + unsigned short traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + unsigned short traits:: + create (const std::basic_string& 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 tmp (s); + trim (tmp); + + zc_istream is (tmp); + + type t; + is >> t; + + return t; + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_UNSIGNED_SHORT_HXX -- cgit v1.1