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/boolean.hxx | 76 +++ libxsd/xsd/cxx/tree/parsing/byte.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/date-time.txx | 702 +++++++++++++++++++++++++ libxsd/xsd/cxx/tree/parsing/decimal.hxx | 85 +++ libxsd/xsd/cxx/tree/parsing/double.hxx | 94 ++++ libxsd/xsd/cxx/tree/parsing/element-map.txx | 42 ++ libxsd/xsd/cxx/tree/parsing/float.hxx | 94 ++++ libxsd/xsd/cxx/tree/parsing/int.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/long.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/short.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx | 80 +++ libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx | 80 +++ 14 files changed, 1733 insertions(+) create mode 100644 libxsd/xsd/cxx/tree/parsing/boolean.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/byte.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/date-time.txx create mode 100644 libxsd/xsd/cxx/tree/parsing/decimal.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/double.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/element-map.txx create mode 100644 libxsd/xsd/cxx/tree/parsing/float.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/int.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/long.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/short.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx create mode 100644 libxsd/xsd/cxx/tree/parsing/unsigned-short.hxx (limited to 'libxsd/xsd/cxx/tree/parsing') diff --git a/libxsd/xsd/cxx/tree/parsing/boolean.hxx b/libxsd/xsd/cxx/tree/parsing/boolean.hxx new file mode 100644 index 0000000..28f1b11 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/boolean.hxx @@ -0,0 +1,76 @@ +// file : xsd/cxx/tree/parsing/boolean.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_BOOLEAN_HXX +#define XSD_CXX_TREE_PARSING_BOOLEAN_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef bool 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 + bool traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + bool traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + bool 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); + + return tmp == bits::true_ () || tmp == bits::one (); + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_BOOLEAN_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/byte.hxx b/libxsd/xsd/cxx/tree/parsing/byte.hxx new file mode 100644 index 0000000..2924ca0 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/byte.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/byte.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_BYTE_HXX +#define XSD_CXX_TREE_PARSING_BYTE_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef signed char 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 + signed char traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + signed char traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + signed char 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); + + short t; + is >> t; + + return static_cast (t); + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_BYTE_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/date-time.txx b/libxsd/xsd/cxx/tree/parsing/date-time.txx new file mode 100644 index 0000000..85fb909 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/date-time.txx @@ -0,0 +1,702 @@ +// file : xsd/cxx/tree/parsing/date-time.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + // time_zone + // + template + void time_zone:: + zone_parse (const C* s, std::size_t n) + { + // time_zone := Z|(+|-)HH:MM + // + if (n == 0) + { + return; + } + else if (s[0] == C ('Z')) + { + hours_ = 0; + minutes_ = 0; + present_ = true; + } + else if (n == 6) + { + // Parse hours. + // + hours_ = 10 * (s[1] - C ('0')) + (s[2] - C ('0')); + + // Parse minutes. + // + minutes_ = 10 * (s[4] - C ('0')) + (s[5] - C ('0')); + + if (s[0] == C ('-')) + { + hours_ = -hours_; + minutes_ = -minutes_; + } + present_ = true; + } + } + + // gday + // + template + gday:: + gday (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + gday:: + gday (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + gday:: + gday (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void gday:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // gday := ---DD[Z|(+|-)HH:MM] + // + if (n >= 5) + { + day_ = 10 * (s[3] - C ('0')) + (s[4] - C ('0')); + + if (n > 5) + zone_parse (s + 5, n - 5); + } + } + + // gmonth + // + template + gmonth:: + gmonth (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + gmonth:: + gmonth (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + gmonth:: + gmonth (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void gmonth:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // gmonth := --MM[Z|(+|-)HH:MM] + // + if (n >= 4) + { + month_ = 10 * (s[2] - C ('0')) + (s[3] - C ('0')); + + if (n > 4) + zone_parse (s + 4, n - 4); + } + } + + // gyear + // + template + gyear:: + gyear (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + gyear:: + gyear (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + gyear:: + gyear (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void gyear:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] + // + if (n >= 4) + { + // Find the end of the year token. + // + size_type pos (4); + for (; pos < n; ++pos) + { + C c (s[pos]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string year_fragment (s, pos); + zc_istream is (year_fragment); + is >> year_; + + if (pos < n) + zone_parse (s + pos, n - pos); + } + } + + // gmonth_day + // + template + gmonth_day:: + gmonth_day (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + gmonth_day:: + gmonth_day (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + gmonth_day:: + gmonth_day (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void gmonth_day:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // gmonth_day := --MM-DD[Z|(+|-)HH:MM] + // + if (n >= 7) + { + month_ = 10 * (s[2] - C ('0')) + (s[3] - C ('0')); + day_ = 10 * (s[5] - C ('0')) + (s[6] - C ('0')); + + if (n > 7) + zone_parse (s + 7, n - 7); + } + } + + // gyear_month + // + template + gyear_month:: + gyear_month (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + gyear_month:: + gyear_month (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + gyear_month:: + gyear_month (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void gyear_month:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] + // + + if (n >= 7) + { + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), 4)); + + if (pos != ro_string::npos && (n - pos - 1) >= 2) + { + ro_string year_fragment (s, pos); + zc_istream is (year_fragment); + is >> year_; + + month_ = 10 * (s[pos + 1] - C ('0')) + (s[pos + 2] - C ('0')); + + pos += 3; + + if (pos < n) + zone_parse (s + pos, n - pos); + } + } + } + + // date + // + template + date:: + date (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + date:: + date (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + date:: + date (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void date:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] + // + + if (n >= 10) + { + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), 4)); + + if (pos != ro_string::npos && (n - pos - 1) >= 5) + { + ro_string year_fragment (s, pos); + zc_istream is (year_fragment); + is >> year_; + + month_ = 10 * (s[pos + 1] - C ('0')) + (s[pos + 2] - C ('0')); + day_ = 10 * (s[pos + 4] - C ('0')) + (s[pos + 5] - C ('0')); + + pos += 6; + + if (pos < n) + zone_parse (s + pos, n - pos); + } + } + } + + // time + // + template + time:: + time (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + time:: + time (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + time:: + time (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void time:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + if (n >= 8) + { + hours_ = 10 * (s[0] - '0') + (s[1] - '0'); + minutes_ = 10 * (s[3] - '0') + (s[4] - '0'); + + // Find the end of the seconds fragment. + // + size_type pos (8); + for (; pos < n; ++pos) + { + C c (s[pos]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string seconds_fragment (s + 6, pos - 6); + zc_istream is (seconds_fragment); + is >> seconds_; + + if (pos < n) + zone_parse (s + pos, n - pos); + } + } + + // date_time + // + template + date_time:: + date_time (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + date_time:: + date_time (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + date_time:: + date_time (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + template + void date_time:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + if (n >= 19) + { + // Find the end of the year token. + // + size_type pos (tmp.find (C ('-'), 4)); + + if (pos != ro_string::npos && (n - pos - 1) >= 14) + { + ro_string year_fragment (s, pos); + zc_istream yis (year_fragment); + yis >> year_; + + month_ = 10 * (s[pos + 1] - C ('0')) + (s[pos + 2] - C ('0')); + pos += 3; + + day_ = 10 * (s[pos + 1] - C ('0')) + (s[pos + 2] - C ('0')); + pos += 3; + + hours_ = 10 * (s[pos + 1] - C ('0')) + (s[pos + 2] - C ('0')); + pos += 3; + + minutes_ = 10 * (s[pos + 1] - C ('0')) + (s[pos + 2] - C ('0')); + pos += 4; // Point to the first S. + + // Find the end of the seconds fragment. + // + size_type sec_end (pos + 2); + for (; sec_end < n; ++sec_end) + { + C c (s[sec_end]); + + if (c == C ('Z') || c == C ('+') || c == C ('-')) + break; + } + + ro_string seconds_fragment (s + pos, sec_end - pos); + zc_istream sis (seconds_fragment); + sis >> seconds_; + + if (sec_end < n) + zone_parse (s + sec_end, n - sec_end); + } + } + } + + // duration + // + template + duration:: + duration (const xercesc::DOMElement& e, flags f, container* c) + : B (e, f, c) + { + parse (text_content (e)); + } + + template + duration:: + duration (const xercesc::DOMAttr& a, flags f, container* c) + : B (a, f, c) + { + parse (xml::transcode (a.getValue ())); + } + + template + duration:: + duration (const std::basic_string& s, + const xercesc::DOMElement* e, + flags f, + container* c) + : B (s, e, f, c) + { + parse (s); + } + + namespace bits + { + template + inline typename ro_string::size_type + duration_delim (const C* s, + typename ro_string::size_type pos, + typename ro_string::size_type size) + { + const C* p (s + pos); + for (; p < (s + size); ++p) + { + if (*p == C ('Y') || *p == C ('D') || *p == C ('M') || + *p == C ('H') || *p == C ('M') || *p == C ('S') || + *p == C ('T')) + break; + } + + return p - s; + } + } + + template + void duration:: + parse (const std::basic_string& str) + { + typedef typename ro_string::size_type size_type; + + ro_string tmp (str); + size_type n (trim (tmp)); + const C* s (tmp.data ()); + + // Set all the fields since some of them may not be specified. + // + years_ = months_ = days_ = hours_ = minutes_ = 0; + seconds_ = 0.0; + + // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] + // + if (n >= 3) + { + size_type pos (0); + + if (s[0] == C ('-')) + { + negative_ = true; + pos++; + } + else + negative_ = false; + + pos++; // Skip 'P'. + + size_type del (bits::duration_delim (s, pos, n)); + + if (del != n && s[del] == C ('Y')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> years_; + + pos = del + 1; + del = bits::duration_delim (s, pos, n); + } + + if (del != n && s[del] == C ('M')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> months_; + + pos = del + 1; + del = bits::duration_delim (s, pos, n); + } + + if (del != n && s[del] == C ('D')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> days_; + + pos = del + 1; + del = bits::duration_delim (s, pos, n); + } + + if (del != n && s[del] == C ('T')) + { + pos = del + 1; + del = bits::duration_delim (s, pos, n); + + if (del != n && s[del] == C ('H')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> hours_; + + pos = del + 1; + del = bits::duration_delim (s, pos, n); + } + + if (del != n && s[del] == C ('M')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> minutes_; + + pos = del + 1; + del = bits::duration_delim (s, pos, n); + } + + if (del != n && s[del] == C ('S')) + { + ro_string fragment (s + pos, del - pos); + zc_istream is (fragment); + is >> seconds_; + } + } + } + } + } + } +} diff --git a/libxsd/xsd/cxx/tree/parsing/decimal.hxx b/libxsd/xsd/cxx/tree/parsing/decimal.hxx new file mode 100644 index 0000000..d24e7c6 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/decimal.hxx @@ -0,0 +1,85 @@ +// file : xsd/cxx/tree/parsing/decimal.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_DECIMAL_HXX +#define XSD_CXX_TREE_PARSING_DECIMAL_HXX + +#include +#include + +#include +#include + +#include // xml::transcode + +#include // text_content +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef double 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 + double traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + double traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + double 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); + is.imbue (std::locale::classic ()); + + type t; + is >> t; + + return t; + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_DECIMAL_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/double.hxx b/libxsd/xsd/cxx/tree/parsing/double.hxx new file mode 100644 index 0000000..aa83ad5 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/double.hxx @@ -0,0 +1,94 @@ +// file : xsd/cxx/tree/parsing/double.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_DOUBLE_HXX +#define XSD_CXX_TREE_PARSING_DOUBLE_HXX + +#include +#include + +#include +#include + +#include // xml::transcode + +#include // text_content +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef double 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 + double traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + double traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + double 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); + + if (tmp == bits::positive_inf ()) + return std::numeric_limits::infinity (); + + if (tmp == bits::negative_inf ()) + return -std::numeric_limits::infinity (); + + if (tmp == bits::nan ()) + return std::numeric_limits::quiet_NaN (); + + zc_istream is (tmp); + is.imbue (std::locale::classic ()); + + type t; + is >> t; + + return t; + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_DOUBLE_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/element-map.txx b/libxsd/xsd/cxx/tree/parsing/element-map.txx new file mode 100644 index 0000000..88ac26b --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/element-map.txx @@ -0,0 +1,42 @@ +// file : xsd/cxx/tree/parsing/element-map.txx +// 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_ELEMENT_MAP_TXX +#define XSD_CXX_TREE_PARSING_ELEMENT_MAP_TXX + +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + std::auto_ptr > element_map:: + parse (const xercesc::DOMElement& e, flags f) + { + const qualified_name n (xml::dom::name (e)); + typename map::const_iterator i (map_->find (n)); + + if (i != map_->end () && i->second.parser_ != 0) + return (i->second.parser_) (e, f); + else + throw no_element_info (n.name (), n.namespace_ ()); + } + + template + std::auto_ptr > + parser_impl (const xercesc::DOMElement& e, flags f) + { + return std::auto_ptr > (new T (e, f)); + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_ELEMENT_MAP_TXX diff --git a/libxsd/xsd/cxx/tree/parsing/float.hxx b/libxsd/xsd/cxx/tree/parsing/float.hxx new file mode 100644 index 0000000..294484c --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/float.hxx @@ -0,0 +1,94 @@ +// file : xsd/cxx/tree/parsing/float.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_FLOAT_HXX +#define XSD_CXX_TREE_PARSING_FLOAT_HXX + +#include +#include + +#include +#include + +#include // xml::transcode + +#include // text_content +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef float 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 + float traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + float traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + float 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); + + if (tmp == bits::positive_inf ()) + return std::numeric_limits::infinity (); + + if (tmp == bits::negative_inf ()) + return -std::numeric_limits::infinity (); + + if (tmp == bits::nan ()) + return std::numeric_limits::quiet_NaN (); + + zc_istream is (tmp); + is.imbue (std::locale::classic ()); + + type t; + is >> t; + + return t; + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_FLOAT_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/int.hxx b/libxsd/xsd/cxx/tree/parsing/int.hxx new file mode 100644 index 0000000..85b7f3a --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/int.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/int.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_INT_HXX +#define XSD_CXX_TREE_PARSING_INT_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef 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& s, + const xercesc::DOMElement*, + flags, + container*); + }; + + template + int traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + int traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + int 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_INT_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/long.hxx b/libxsd/xsd/cxx/tree/parsing/long.hxx new file mode 100644 index 0000000..e4ba3ac --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/long.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/long.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_LONG_HXX +#define XSD_CXX_TREE_PARSING_LONG_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef long long 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 + long long traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + long long traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + long long 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_LONG_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/short.hxx b/libxsd/xsd/cxx/tree/parsing/short.hxx new file mode 100644 index 0000000..dd023cf --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/short.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/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_SHORT_HXX +#define XSD_CXX_TREE_PARSING_SHORT_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef 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 + short traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + short traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + 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_SHORT_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx b/libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx new file mode 100644 index 0000000..b14b815 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/unsigned-byte.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/unsigned-byte.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_BYTE_HXX +#define XSD_CXX_TREE_PARSING_UNSIGNED_BYTE_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef unsigned char 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 char traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + unsigned char traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + unsigned char 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); + + unsigned short t; + is >> t; + + return static_cast (t); + } + } + } +} + +#endif // XSD_CXX_TREE_PARSING_UNSIGNED_BYTE_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx b/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx new file mode 100644 index 0000000..d32631a --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/unsigned-int.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/unsigned-int.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_INT_HXX +#define XSD_CXX_TREE_PARSING_UNSIGNED_INT_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + 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& s, + const xercesc::DOMElement*, + flags, + container*); + }; + + template + unsigned int traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + unsigned int traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + unsigned int 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_INT_HXX diff --git a/libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx b/libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx new file mode 100644 index 0000000..bee2eb7 --- /dev/null +++ b/libxsd/xsd/cxx/tree/parsing/unsigned-long.hxx @@ -0,0 +1,80 @@ +// file : xsd/cxx/tree/parsing/unsigned-long.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_LONG_HXX +#define XSD_CXX_TREE_PARSING_UNSIGNED_LONG_HXX + +#include +#include + +#include // xml::transcode + +#include // text_content + +namespace xsd +{ + namespace cxx + { + namespace tree + { + template + struct traits + { + typedef unsigned long long 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 long long traits:: + create (const xercesc::DOMElement& e, flags f, container* c) + { + return create (text_content (e), 0, f, c); + } + + template + unsigned long long traits:: + create (const xercesc::DOMAttr& a, flags f, container* c) + { + return create (xml::transcode (a.getValue ()), 0, f, c); + } + + template + unsigned long long 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_LONG_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