diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-02-24 15:16:26 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-02-24 15:16:26 +0200 |
commit | 707cc94fe52463870a9c6c8e2e66eaaa389e601d (patch) | |
tree | 13e10ff28bf4455d915f9d59b401bdbb62a393cb /libxsde/xsde/cxx/parser/non-validating |
Start tracking XSD/e with git after version 3.0.03.0.0
Diffstat (limited to 'libxsde/xsde/cxx/parser/non-validating')
124 files changed, 10716 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/parser/non-validating/any-type.hxx b/libxsde/xsde/cxx/parser/non-validating/any-type.hxx new file mode 100644 index 0000000..37e1d6f --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/any-type.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/parser/non-validating/any-type.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_ANY_TYPE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_ANY_TYPE_HXX + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // any_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_type_pimpl: virtual any_type_pskel +#else + struct any_type_pimpl: any_type_pskel +#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 + { + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_ANY_TYPE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx b/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx new file mode 100644 index 0000000..95588a2 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx @@ -0,0 +1,241 @@ +// file : xsde/cxx/parser/non-validating/base64-binary.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/base64-binary.hxx> + +static unsigned char +base64_decode (char c) +{ + unsigned char r = 0xFF; + + if (c >= 'A' && c <= 'Z') + r = static_cast<unsigned char> (c - 'A'); + else if (c >= 'a' && c <= 'z') + r = static_cast<unsigned char> (c - 'a' + 26); + else if (c >= '0' && c <= '9') + r = static_cast<unsigned char> (c - '0' + 52); + else if (c == '+') + r = 62; + else if (c == '/') + r = 63; + + return r; +} + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + base64_binary_pimpl:: + ~base64_binary_pimpl () + { + if (!base_) + delete buf_; + } + + void base64_binary_pimpl:: + _reset () + { + base64_binary_pskel::_reset (); + + if (!base_) + { + delete buf_; + buf_ = 0; + } + } + + base64_binary_pimpl:: + base64_binary_pimpl (bool base) + : base_ (base), buf_ (0) + { + } + + void base64_binary_pimpl:: + pre_impl (buffer* b) + { + buf_ = b; + } + + void base64_binary_pimpl:: + _pre () + { + if (buf_ == 0) + { + buf_ = new buffer (); + +#ifndef XSDE_EXCEPTIONS + if (buf_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void base64_binary_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + buffer* base64_binary_pimpl:: + post_base64_binary () + { + typedef string::size_type size_type; + + size_type size = str_.size (); + const char* src = str_.data (); + + // Remove all whitespaces. + // + { + size_type j = 0; + bool subs = false; + + for (size_type i = 0; i < size; ++i) + { + char c = str_[i]; + + if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09) + { + subs = true; + } + else + { + if (subs) + subs = false; + + str_[j++] = c; + } + } + + size = j; + str_.truncate (size); + } + + // Our length should be a multiple of four. + // + size_type quad_count = size / 4; + size_type capacity = quad_count * 3 + 1; + +#ifdef XSDE_EXCEPTIONS + buf_->size (capacity); +#else + if (buf_->size (capacity)) + { + _sys_error (sys_error::no_memory); + return 0; + } +#endif + char* dst = buf_->data (); + + // Source and destination indexes. + // + size_type si = 0; + size_type di = 0; + + // Process all quads except the last one. + // + unsigned char b1, b2, b3, b4; + + for (size_type q = 0; q < quad_count - 1; ++q) + { + b1 = base64_decode (src[si++]); + b2 = base64_decode (src[si++]); + b3 = base64_decode (src[si++]); + b4 = base64_decode (src[si++]); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + dst[di++] = (b3 << 6) | b4; + } + + // Process the last quad. The first two octets are always there. + // + b1 = base64_decode (src[si++]); + b2 = base64_decode (src[si++]); + + char e3 = src[si++]; + char e4 = src[si++]; + + if (e4 == '=') + { + if (e3 == '=') + { + // Two pads. Last 4 bits in b2 should be zero. + // + dst[di++] = (b1 << 2) | (b2 >> 4); + } + else + { + // One pad. Last 2 bits in b3 should be zero. + // + b3 = base64_decode (e3); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + } + } + else + { + // No pads. + // + b3 = base64_decode (e3); + b4 = base64_decode (e4); + + dst[di++] = (b1 << 2) | (b2 >> 4); + dst[di++] = (b2 << 4) | (b3 >> 2); + dst[di++] = (b3 << 6) | b4; + } + + // Set the real size. + // + buf_->size (di); + + buffer* r = buf_; + buf_ = 0; + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/base64-binary.hxx b/libxsde/xsde/cxx/parser/non-validating/base64-binary.hxx new file mode 100644 index 0000000..fef946b --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/base64-binary.hxx @@ -0,0 +1,55 @@ +// file : xsde/cxx/parser/non-validating/base64-binary.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_BASE64_BINARY_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_BASE64_BINARY_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 base64_binary_pimpl: virtual base64_binary_pskel +#else + struct base64_binary_pimpl: base64_binary_pskel +#endif + { + ~base64_binary_pimpl (); + base64_binary_pimpl (bool base = false); + + void + pre_impl (buffer*); + + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual buffer* + post_base64_binary (); + + virtual void + _reset (); + + protected: + bool base_; + string str_; + buffer* buf_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_BASE64_BINARY_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/boolean.cxx b/libxsde/xsde/cxx/parser/non-validating/boolean.cxx new file mode 100644 index 0000000..af5ee41 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/boolean.cxx @@ -0,0 +1,80 @@ +// file : xsde/cxx/parser/non-validating/boolean.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/boolean.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void boolean_pimpl:: + _pre () + { + size_ = 0; + state_ = leading_ws; + } + + void boolean_pimpl:: + _characters (const ro_string& s) + { + ro_string tmp (s.data (), s.size ()); + + size_t size = tmp.size (); + + switch (state_) + { + case leading_ws: + { + size = trim_left (tmp); + + if (size != 0) + state_ = literal; + else + break; + // Fall through. + } + case literal: + { + // If this chunk is too long then it has to be the last so trim + // trailing ws. + // + if ((5 - size_) < size) + { + size = trim_right (tmp); + state_ = trailing_ws; // It either had ws or is too large. + } + + if ((5 - size_) >= size) + { + memcpy (str_ + size_, tmp.data (), size); + size_ += size; + } + + break; + } + case trailing_ws: + { + // We don't really care if it is not. + break; + } + } + } + + bool boolean_pimpl:: + post_boolean () + { + ro_string tmp (str_, size_); + trim_right (tmp); + + return (tmp == "1" || tmp == "true"); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/boolean.hxx b/libxsde/xsde/cxx/parser/non-validating/boolean.hxx new file mode 100644 index 0000000..eeb9068 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/boolean.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/boolean.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_BOOLEAN_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_BOOLEAN_HXX + +#include <stddef.h> // size_t + +#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 boolean_pimpl: virtual boolean_pskel +#else + struct boolean_pimpl: boolean_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual bool + post_boolean (); + + protected: + // We only need strlen("false") + 1 characters to hold all valid + // and trimmed string representations of boolean. + // + char str_[6]; + size_t size_; + enum { leading_ws, literal, trailing_ws } state_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_BOOLEAN_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/byte.cxx b/libxsde/xsde/cxx/parser/non-validating/byte.cxx new file mode 100644 index 0000000..47fa839 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/byte.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/byte.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void byte_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void byte_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 4); + } + + signed char byte_pimpl:: + post_byte () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + + str_[size] = '\0'; + unsigned long ul = strtoul (str_, 0, 10); + + return (sign_ == minus) + ? static_cast<signed char> (-static_cast<short> (ul)) + : static_cast<signed char> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/byte.hxx b/libxsde/xsde/cxx/parser/non-validating/byte.hxx new file mode 100644 index 0000000..a6bbffc --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/byte.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/byte.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_BYTE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_BYTE_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 8-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct byte_pimpl: virtual byte_pskel, number +#else + struct byte_pimpl: byte_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual signed char + post_byte (); + + protected: + // We only need strlen("0128") + 1 characters to hold all valid + // and trimmed string representations of signed byte. + // + char str_[5]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_BYTE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/date-time.cxx b/libxsde/xsde/cxx/parser/non-validating/date-time.cxx new file mode 100644 index 0000000..59d8c11 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/date-time.cxx @@ -0,0 +1,154 @@ +// file : xsde/cxx/parser/non-validating/date-time.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul, strtod + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/date-time.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void date_time_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void date_time_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + date_time date_time_pimpl:: + post_date_time () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] + // + + int year = 0; + unsigned short month = 0; + unsigned short day = 0; + unsigned short hours = 0; + unsigned short minutes = 0; + double seconds = 0.0; + bool zone = false; + short zh, zm; + + if (n >= 19) + { + // Find the end of the year token. + // + ro_string::size_type yp = tmp.find ('-', s[0] == '-' ? 5 : 4); + + if (yp != ro_string::npos && (n - yp - 1) >= 14) + { + // Find the end of the seconds fragment. + // + ro_string::size_type sp = yp + 15; + for (; sp < n; ++sp) + { + char c = s[sp]; + + if (c == 'Z' || c == '+' || c == '-') + break; + } + + // Parse it backwards so that we can truncate and reuse + // the string. + // + + // zone + // + if (sp < n) + { + bits::parse_time_zone (s + sp, n - sp, zh, zm); + zone = true; + } + + // seconds + // + str_.truncate (sp); + + seconds = strtod (s + yp + 13, 0); + + // minutes + // + minutes = 10 * (s[yp + 10] - '0') + (s[yp + 11] - '0'); + + // hours + // + hours = 10 * (s[yp + 7] - '0') + (s[yp + 8] - '0'); + + // day + // + day = 10 * (s[yp + 4] - '0') + (s[yp + 5] - '0'); + + // month + // + month = 10 * (s[yp + 1] - '0') + (s[yp + 2] - '0'); + + // year + // + str_.truncate (yp); + + bool neg = (s[0] == '-'); + unsigned long ul = strtoul (neg ? s + 1 : s, 0, 10); + + year = neg + ? (ul == 2147483648UL + ? (-2147483647 - 1) + : -static_cast<int> (ul)) + : static_cast<int> (ul); + } + } + + return zone + ? date_time (year, month, day, hours, minutes, seconds, zh, zm) + : date_time (year, month, day, hours, minutes, seconds); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/date-time.hxx b/libxsde/xsde/cxx/parser/non-validating/date-time.hxx new file mode 100644 index 0000000..bb329af --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/date-time.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/date-time.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_DATE_TIME_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_DATE_TIME_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 date_time_pimpl: virtual date_time_pskel +#else + struct date_time_pimpl: date_time_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual date_time + post_date_time (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_DATE_TIME_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/date.cxx b/libxsde/xsde/cxx/parser/non-validating/date.cxx new file mode 100644 index 0000000..0364ac1 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/date.cxx @@ -0,0 +1,126 @@ +// file : xsde/cxx/parser/non-validating/date.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/date.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void date_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void date_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + date date_pimpl:: + post_date () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] + // + + int year = 0; + unsigned short month = 0; + unsigned short day = 0; + bool zone = false; + short zh, zm; + + if (n >= 10) + { + // Find the end of the year token. + // + ro_string::size_type pos = tmp.find ('-', s[0] == '-' ? 5 : 4); + + if (pos != ro_string::npos && (n - pos - 1) >= 5) + { + // Parse the month, day values and time zone first so that we + // can truncate and reuse the string. + // + + // month + // + month = 10 * (s[pos + 1] - '0') + (s[pos + 2] - '0'); + + // day + // + day = 10 * (s[pos + 4] - '0') + (s[pos + 5] - '0'); + + // zone + // + if ((pos + 6) < n) + { + bits::parse_time_zone (s + pos + 6, n - pos - 6, zh, zm); + zone = true; + } + + // year + // + str_.truncate (pos); + + bool neg = (s[0] == '-'); + unsigned long ul = strtoul (neg ? s + 1 : s, 0, 10); + + year = neg + ? (ul == 2147483648UL + ? (-2147483647 - 1) + : -static_cast<int> (ul)) + : static_cast<int> (ul); + } + } + + return zone + ? date (year, month, day, zh, zm) + : date (year, month, day); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/date.hxx b/libxsde/xsde/cxx/parser/non-validating/date.hxx new file mode 100644 index 0000000..174de7d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/date.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/date.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_DATE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_DATE_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 date_pimpl: virtual date_pskel +#else + struct date_pimpl: date_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual date + post_date (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_DATE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/decimal.cxx b/libxsde/xsde/cxx/parser/non-validating/decimal.cxx new file mode 100644 index 0000000..401800b --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/decimal.cxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/decimal.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtod + +#include <xsde/cxx/parser/non-validating/decimal.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void decimal_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void decimal_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 127); + } + + double decimal_pimpl:: + post_decimal () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + double r = strtod (str_, 0); + + if (sign_ == minus) + r = -r; + + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/decimal.hxx b/libxsde/xsde/cxx/parser/non-validating/decimal.hxx new file mode 100644 index 0000000..fd1cf4e --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/decimal.hxx @@ -0,0 +1,46 @@ +// file : xsde/cxx/parser/non-validating/decimal.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_DECIMAL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_DECIMAL_HXX + +#include <xsde/cxx/parser/non-validating/number.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 decimal_pimpl: virtual decimal_pskel, number +#else + struct decimal_pimpl: decimal_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual double + post_decimal (); + + protected: + // Assume decimal values (without leading and trailing whitespaces) + // cannot be longer than 127 characters. + // + char str_[128]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_DECIMAL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/double.cxx b/libxsde/xsde/cxx/parser/non-validating/double.cxx new file mode 100644 index 0000000..8c7ab9a --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/double.cxx @@ -0,0 +1,62 @@ +// file : xsde/cxx/parser/non-validating/double.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtod + +#include <xsde/cxx/parser/non-validating/double.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void double_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void double_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 127); + } + + double double_pimpl:: + post_double () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + double r; + + if (tmp == "INF") + { + r = strtod (sign_ == minus ? "-INF" : "INF", 0); + } + else if (tmp == "NaN") + { + r = strtod ("NAN", 0); + } + else + { + r = strtod (str_, 0); + + if (sign_ == minus) + r = -r; + } + + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/double.hxx b/libxsde/xsde/cxx/parser/non-validating/double.hxx new file mode 100644 index 0000000..1e5f299 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/double.hxx @@ -0,0 +1,46 @@ +// file : xsde/cxx/parser/non-validating/double.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_DOUBLE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_DOUBLE_HXX + +#include <xsde/cxx/parser/non-validating/number.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 double_pimpl: virtual double_pskel, number +#else + struct double_pimpl: double_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual double + post_double (); + + protected: + // Assume double values (without leading and trailing whitespaces) + // cannot be longer than 127 characters. + // + char str_[128]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_DOUBLE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/duration.cxx b/libxsde/xsde/cxx/parser/non-validating/duration.cxx new file mode 100644 index 0000000..d7cbb3b --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/duration.cxx @@ -0,0 +1,166 @@ +// file : xsde/cxx/parser/non-validating/duration.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul, strtod + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/duration.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void duration_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void duration_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + static ro_string::size_type + rfind_delim (const char* s, ro_string::size_type pos) + { + const char* p = s + pos; + for (; p >= s; --p) + { + if (*p == 'Y' || *p == 'D' || *p == 'M' || + *p == 'H' || *p == 'M' || *p == 'S' || + *p == 'T' || *p == 'P') + break; + } + + return p >= s ? p - s : ro_string::npos; + } + + duration duration_pimpl:: + post_duration () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + bool negative = false; + unsigned int years = 0; + unsigned int months = 0; + unsigned int days = 0; + unsigned int hours = 0; + unsigned int minutes = 0; + double seconds = 0.0; + + // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] + // + + if (n >= 3 && s[s[0] == '-' ? 1 : 0] == 'P') + { + if (s[0] == '-') + negative = true; + + // Parse it backwards so that we can truncate and reuse + // the string. + // + ro_string::size_type pos = n - 1; + ro_string::size_type t_pos = tmp.find ('T'); + + if (s[pos] == 'S') + { + str_.truncate (pos); + pos = rfind_delim (s, pos - 1); + + seconds = strtod (s + pos + 1, 0); + } + + if (s[pos] == 'M' && t_pos != ro_string::npos && t_pos < pos) + { + str_.truncate (pos); + pos = rfind_delim (s, pos - 1); + + minutes = + static_cast<unsigned int> (strtoul (s + pos + 1, 0, 10)); + } + + if (s[pos] == 'H') + { + str_.truncate (pos); + pos = rfind_delim (s, pos - 1); + + hours = + static_cast<unsigned int> (strtoul (s + pos + 1, 0, 10)); + } + + if (s[pos] == 'T') + pos = rfind_delim (s, pos - 1); + + if (s[pos] == 'D') + { + str_.truncate (pos); + pos = rfind_delim (s, pos - 1); + + days = + static_cast<unsigned int> (strtoul (s + pos + 1, 0, 10)); + } + + if (s[pos] == 'M') + { + str_.truncate (pos); + pos = rfind_delim (s, pos - 1); + + months = + static_cast<unsigned int> (strtoul (s + pos + 1, 0, 10)); + } + + if (s[pos] == 'Y') + { + str_.truncate (pos); + pos = rfind_delim (s, pos - 1); + + years = + static_cast<unsigned int> (strtoul (s + pos + 1, 0, 10)); + } + } + + return duration ( + negative, years, months, days, hours, minutes, seconds); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/duration.hxx b/libxsde/xsde/cxx/parser/non-validating/duration.hxx new file mode 100644 index 0000000..ebbd210 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/duration.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/duration.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_DURATION_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_DURATION_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 duration_pimpl: virtual duration_pskel +#else + struct duration_pimpl: duration_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual duration + post_duration (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_DURATION_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/float.cxx b/libxsde/xsde/cxx/parser/non-validating/float.cxx new file mode 100644 index 0000000..9c90b32 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/float.cxx @@ -0,0 +1,76 @@ +// file : xsde/cxx/parser/non-validating/float.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtof, strtod + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/float.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void float_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void float_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 127); + } + + float float_pimpl:: + post_float () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + float r; + + if (tmp == "INF") + { +#ifdef XSDE_STRTOF + r = strtof (sign_ == minus ? "-INF" : "INF", 0); +#else + r = static_cast<float> (strtod (sign_ == minus ? "-INF" : "INF", 0)); +#endif + } + else if (tmp == "NaN") + { +#ifdef XSDE_STRTOF + r = strtof ("NAN", 0); +#else + r = static_cast<float> (strtod ("NAN", 0)); +#endif + } + else + { +#ifdef XSDE_STRTOF + r = strtof (str_, 0); +#else + r = static_cast<float> (strtod (str_, 0)); +#endif + + if (sign_ == minus) + r = -r; + } + + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/float.hxx b/libxsde/xsde/cxx/parser/non-validating/float.hxx new file mode 100644 index 0000000..cae4fa7 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/float.hxx @@ -0,0 +1,46 @@ +// file : xsde/cxx/parser/non-validating/float.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_FLOAT_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_FLOAT_HXX + +#include <xsde/cxx/parser/non-validating/number.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 float_pimpl: virtual float_pskel, number +#else + struct float_pimpl: float_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual float + post_float (); + + protected: + // Assume float values (without leading and trailing whitespaces) + // cannot be longer than 127 characters. + // + char str_[128]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_FLOAT_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/gday.cxx b/libxsde/xsde/cxx/parser/non-validating/gday.cxx new file mode 100644 index 0000000..64c9cd9 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gday.cxx @@ -0,0 +1,88 @@ +// file : xsde/cxx/parser/non-validating/gday.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/gday.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void gday_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void gday_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + gday gday_pimpl:: + post_gday () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // gday := ---DD[Z|(+|-)HH:MM] + // + + unsigned short day = 0; + bool zone = false; + short zh, zm; + + if (n >= 5) + { + day = 10 * (s[3] - '0') + (s[4] - '0'); + + if (n > 5) + { + bits::parse_time_zone (s + 5, n - 5, zh, zm); + zone = true; + } + } + + return zone ? gday (day, zh, zm) : gday (day); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/gday.hxx b/libxsde/xsde/cxx/parser/non-validating/gday.hxx new file mode 100644 index 0000000..7af0c19 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gday.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/gday.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_GDAY_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_GDAY_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 gday_pimpl: virtual gday_pskel +#else + struct gday_pimpl: gday_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gday + post_gday (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_GDAY_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/gmonth-day.cxx b/libxsde/xsde/cxx/parser/non-validating/gmonth-day.cxx new file mode 100644 index 0000000..223b73f --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gmonth-day.cxx @@ -0,0 +1,100 @@ +// file : xsde/cxx/parser/non-validating/gmonth-day.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/gmonth-day.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void gmonth_day_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void gmonth_day_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + gmonth_day gmonth_day_pimpl:: + post_gmonth_day () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // gmonth_day := --MM-DD[Z|(+|-)HH:MM] + // + + unsigned short month = 0; + unsigned short day = 0; + bool zone = false; + short zh, zm; + + if (n >= 7) + { + // month + // + month = 10 * (s[2] - '0') + (s[3] - '0'); + + // day + // + day = 10 * (s[5] - '0') + (s[6] - '0'); + + // zone + // + if (n > 7) + { + bits::parse_time_zone (s + 7, n - 7, zh, zm); + zone = true; + + } + } + + return zone + ? gmonth_day (month, day, zh, zm) + : gmonth_day (month, day); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/gmonth-day.hxx b/libxsde/xsde/cxx/parser/non-validating/gmonth-day.hxx new file mode 100644 index 0000000..75fb3fb --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gmonth-day.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/gmonth-day.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_GMONTH_DAY_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_GMONTH_DAY_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 gmonth_day_pimpl: virtual gmonth_day_pskel +#else + struct gmonth_day_pimpl: gmonth_day_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gmonth_day + post_gmonth_day (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_GMONTH_DAY_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/gmonth.cxx b/libxsde/xsde/cxx/parser/non-validating/gmonth.cxx new file mode 100644 index 0000000..f203c70 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gmonth.cxx @@ -0,0 +1,88 @@ +// file : xsde/cxx/parser/non-validating/gmonth.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/gmonth.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void gmonth_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void gmonth_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + gmonth gmonth_pimpl:: + post_gmonth () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // gmonth := --MM[Z|(+|-)HH:MM] + // + + unsigned short month = 0; + bool zone = false; + short zh, zm; + + if (n >= 4) + { + month = 10 * (s[2] - '0') + (s[3] - '0'); + + if (n > 4) + { + bits::parse_time_zone (s + 4, n - 4, zh, zm); + zone = true; + } + } + + return zone ? gmonth (month, zh, zm) : gmonth (month); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/gmonth.hxx b/libxsde/xsde/cxx/parser/non-validating/gmonth.hxx new file mode 100644 index 0000000..dfa9b33 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gmonth.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/gmonth.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_GMONTH_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_GMONTH_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 gmonth_pimpl: virtual gmonth_pskel +#else + struct gmonth_pimpl: gmonth_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gmonth + post_gmonth (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_GMONTH_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/gyear-month.cxx b/libxsde/xsde/cxx/parser/non-validating/gyear-month.cxx new file mode 100644 index 0000000..4492246 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gyear-month.cxx @@ -0,0 +1,121 @@ +// file : xsde/cxx/parser/non-validating/gyear-month.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/gyear-month.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void gyear_month_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void gyear_month_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + gyear_month gyear_month_pimpl:: + post_gyear_month () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] + // + + int year = 0; + unsigned short month = 0; + bool zone = false; + short zh, zm; + + if (n >= 7) + { + // Find the end of the year token. + // + ro_string::size_type pos = tmp.find ('-', s[0] == '-' ? 5 : 4); + + if (pos != ro_string::npos && (n - pos - 1) >= 2) + { + // Parse the month value and time zone first so that we can + // truncate and reuse the string. + // + + // month + // + month = 10 * (s[pos + 1] - '0') + (s[pos + 2] - '0'); + + // zone + // + if ((pos + 3) < n) + { + bits::parse_time_zone (s + pos + 3, n - pos - 3, zh, zm); + zone = true; + } + + // year + // + str_.truncate (pos); + + bool neg = (s[0] == '-'); + unsigned long ul = strtoul (neg ? s + 1 : s, 0, 10); + + year = neg + ? (ul == 2147483648UL + ? (-2147483647 - 1) + : -static_cast<int> (ul)) + : static_cast<int> (ul); + } + } + + return zone + ? gyear_month (year, month, zh, zm) + : gyear_month (year, month); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/gyear-month.hxx b/libxsde/xsde/cxx/parser/non-validating/gyear-month.hxx new file mode 100644 index 0000000..23b7378 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gyear-month.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/gyear-month.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_GYEAR_MONTH_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_GYEAR_MONTH_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 gyear_month_pimpl: virtual gyear_month_pskel +#else + struct gyear_month_pimpl: gyear_month_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gyear_month + post_gyear_month (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_GYEAR_MONTH_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/gyear.cxx b/libxsde/xsde/cxx/parser/non-validating/gyear.cxx new file mode 100644 index 0000000..351ac4c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gyear.cxx @@ -0,0 +1,115 @@ +// file : xsde/cxx/parser/non-validating/gyear.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/gyear.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void gyear_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void gyear_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + gyear gyear_pimpl:: + post_gyear () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] + // + + int year = 0; + bool zone = false; + short zh, zm; + + if (n >= 4) + { + // Find the end of the year token. + // + ro_string::size_type pos = (s[0] == '-' ? 5 : 4); + for (; pos < n; ++pos) + { + char c = s[pos]; + + if (c == 'Z' || c == '+' || c == '-') + break; + } + + // Parse the time zone first so that we can truncate and + // reuse the string. + // + if (pos < n) + { + bits::parse_time_zone (s + pos, n - pos, zh, zm); + zone = true; + } + + // Parse the year value. + // + str_.truncate (pos); + + bool neg = (s[0] == '-'); + unsigned long ul = strtoul (neg ? s + 1 : s, 0, 10); + + year = neg + ? (ul == 2147483648UL + ? (-2147483647 - 1) + : -static_cast<int> (ul)) + : static_cast<int> (ul); + } + + return zone ? gyear (year, zh, zm) : gyear (year); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/gyear.hxx b/libxsde/xsde/cxx/parser/non-validating/gyear.hxx new file mode 100644 index 0000000..528b368 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/gyear.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/gyear.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_GYEAR_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_GYEAR_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 gyear_pimpl: virtual gyear_pskel +#else + struct gyear_pimpl: gyear_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual gyear + post_gyear (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_GYEAR_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx b/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx new file mode 100644 index 0000000..a7cc8b4 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx @@ -0,0 +1,159 @@ +// file : xsde/cxx/parser/non-validating/hex-binary.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/hex-binary.hxx> + +static unsigned char +hex_decode (char c) +{ + unsigned char r = 0xFF; + + if (c >= '0' && c <= '9') + r = static_cast<unsigned char> (c - '0'); + else if (c >= 'A' && c <= 'F') + r = static_cast<unsigned char> (10 + (c - 'A')); + else if (c >= 'a' && c <= 'f') + r = static_cast<unsigned char> (10 + (c - 'a')); + + return r; +} + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + hex_binary_pimpl:: + ~hex_binary_pimpl () + { + if (!base_) + delete buf_; + } + + void hex_binary_pimpl:: + _reset () + { + hex_binary_pskel::_reset (); + + if (!base_) + { + delete buf_; + buf_ = 0; + } + } + + hex_binary_pimpl:: + hex_binary_pimpl (bool base) + : base_ (base), buf_ (0) + { + } + + void hex_binary_pimpl:: + pre_impl (buffer* b) + { + buf_ = b; + } + + void hex_binary_pimpl:: + _pre () + { + if (buf_ == 0) + { + buf_ = new buffer (); + +#ifndef XSDE_EXCEPTIONS + if (buf_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void hex_binary_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + buffer* hex_binary_pimpl:: + post_hex_binary () + { + ro_string tmp (str_); + ro_string::size_type size = trim_right (tmp); + + size_t n = size / 2; + +#ifdef XSDE_EXCEPTIONS + buf_->size (n); +#else + if (buf_->size (n)) + { + _sys_error (sys_error::no_memory); + return 0; + } +#endif + + if (n != 0) + { + const char* src = tmp.data (); + char* dst = buf_->data (); + size_t i = 0; + + for (; i < n; ++i) + { + unsigned char h = hex_decode (src[2 * i]); + unsigned char l = hex_decode (src[2 * i + 1]); + + if (h == 0xFF || l == 0xFF) + break; + + dst[i] = (h << 4) | l; + } + } + + buffer* r = buf_; + buf_ = 0; + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/hex-binary.hxx b/libxsde/xsde/cxx/parser/non-validating/hex-binary.hxx new file mode 100644 index 0000000..3b7a4b3 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/hex-binary.hxx @@ -0,0 +1,55 @@ +// file : xsde/cxx/parser/non-validating/hex-binary.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_HEX_BINARY_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_HEX_BINARY_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 hex_binary_pimpl: virtual hex_binary_pskel +#else + struct hex_binary_pimpl: hex_binary_pskel +#endif + { + ~hex_binary_pimpl (); + hex_binary_pimpl (bool base = false); + + void + pre_impl (buffer*); + + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual buffer* + post_hex_binary (); + + virtual void + _reset (); + + protected: + bool base_; + string str_; + buffer* buf_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_HEX_BINARY_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx new file mode 100644 index 0000000..15a611b --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/id-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/id-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void id_pimpl:: + _pre () + { + str_.erase (); + } + + void id_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string id_pimpl:: + post_id () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/parser/non-validating/id-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/id-stl.hxx new file mode 100644 index 0000000..5109ba1 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/id-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/id-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_ID_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_ID_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 id_pimpl: virtual id_pskel +#else + struct id_pimpl: id_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_id (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_ID_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/id.cxx b/libxsde/xsde/cxx/parser/non-validating/id.cxx new file mode 100644 index 0000000..5230305 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/id.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/id.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/id.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void id_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void id_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* id_pimpl:: + post_id () + { + ro_string tmp (str_.data (), str_.size ()); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/id.hxx b/libxsde/xsde/cxx/parser/non-validating/id.hxx new file mode 100644 index 0000000..d762271 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/id.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/id.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_ID_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_ID_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 id_pimpl: virtual id_pskel +#else + struct id_pimpl: id_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_id (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_ID_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx new file mode 100644 index 0000000..e3be5af --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idref-stl.cxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/idref-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void idref_pimpl:: + _pre () + { + str_.erase (); + } + + void idref_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string idref_pimpl:: + post_idref () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/idref-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/idref-stl.hxx new file mode 100644 index 0000000..e65375c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idref-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/idref-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_IDREF_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_IDREF_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 idref_pimpl: virtual idref_pskel +#else + struct idref_pimpl: idref_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_idref (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_IDREF_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/idref.cxx b/libxsde/xsde/cxx/parser/non-validating/idref.cxx new file mode 100644 index 0000000..f6ac060 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idref.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/idref.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void idref_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void idref_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* idref_pimpl:: + post_idref () + { + ro_string tmp (str_.data (), str_.size ()); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/idref.hxx b/libxsde/xsde/cxx/parser/non-validating/idref.hxx new file mode 100644 index 0000000..b76318c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idref.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/idref.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_IDREF_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_IDREF_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 idref_pimpl: virtual idref_pskel +#else + struct idref_pimpl: idref_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_idref (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_IDREF_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx new file mode 100644 index 0000000..a62ea47 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx @@ -0,0 +1,94 @@ +// file : xsde/cxx/parser/non-validating/idrefs-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/pre.hxx> + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/idrefs-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + idrefs_pimpl:: + ~idrefs_pimpl () + { + if (!base_) + delete seq_; + } + + void idrefs_pimpl:: + _reset () + { + idrefs_pskel::_reset (); + + if (!base_) + { + delete seq_; + seq_ = 0; + } + + parser_._reset (); + } + + idrefs_pimpl:: + idrefs_pimpl (bool base) + : base_ (base), seq_ (0) + { + } + + void idrefs_pimpl:: + pre_impl (string_sequence* seq) + { + seq_ = seq; + } + + void idrefs_pimpl:: + _pre () + { + if (seq_ == 0) + { + seq_ = new string_sequence (); + +#ifndef XSDE_EXCEPTIONS + if (seq_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + + idrefs_pskel::_pre (); + } + + string_sequence* idrefs_pimpl:: + post_idrefs () + { + string_sequence* r = seq_; + seq_ = 0; + return r; + } + + void idrefs_pimpl:: + _xsde_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre_impl (_context ()); + parser_._characters (s); + parser_._post_impl (); + seq_->push_back (parser_.post_idref ()); + } + } + } + } +} + +#include <xsde/cxx/post.hxx> diff --git a/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.hxx new file mode 100644 index 0000000..193b764 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.hxx @@ -0,0 +1,54 @@ +// file : xsde/cxx/parser/non-validating/idrefs-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_IDREFS_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_IDREFS_STL_HXX + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> +#include <xsde/cxx/parser/non-validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_pimpl: virtual idrefs_pskel +#else + struct idrefs_pimpl: idrefs_pskel +#endif + { + ~idrefs_pimpl (); + idrefs_pimpl (bool base = false); + + void + pre_impl (string_sequence*); + + virtual void + _pre (); + + virtual void + _xsde_parse_item (const ro_string&); + + virtual string_sequence* + post_idrefs (); + + virtual void + _reset (); + + protected: + bool base_; + idref_pimpl parser_; + string_sequence* seq_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_IDREFS_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx b/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx new file mode 100644 index 0000000..15a6947 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx @@ -0,0 +1,133 @@ +// file : xsde/cxx/parser/non-validating/idrefs.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/pre.hxx> + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/idrefs.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + idrefs_pimpl:: + ~idrefs_pimpl () + { + if (!base_) + delete seq_; + } + + void idrefs_pimpl:: + _reset () + { + idrefs_pskel::_reset (); + + if (!base_) + { + delete seq_; + seq_ = 0; + } + + parser_._reset (); + } + + idrefs_pimpl:: + idrefs_pimpl (bool base) + : base_ (base), seq_ (0) + { + } + + void idrefs_pimpl:: + pre_impl (string_sequence* seq) + { + seq_ = seq; + } + + void idrefs_pimpl:: + _pre () + { + if (seq_ == 0) + { + seq_ = new string_sequence (); + +#ifndef XSDE_EXCEPTIONS + if (seq_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + + idrefs_pskel::_pre (); + } + + string_sequence* idrefs_pimpl:: + post_idrefs () + { + string_sequence* r = seq_; + seq_ = 0; + return r; + } + +#ifdef XSDE_EXCEPTIONS + void idrefs_pimpl:: + _xsde_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre_impl (_context ()); + parser_._characters (s); + parser_._post_impl (); + + // push_back() frees the string if it throws. + // + seq_->push_back (parser_.post_idref ()); + } +#else + void idrefs_pimpl:: + _xsde_parse_item (const ro_string& s) + { + context& ctx = _context (); + + parser_.pre (); + + if (!parser_._error_type ()) + parser_._pre_impl (ctx); + else + parser_._copy_error (ctx); + + if (!ctx.error_type ()) + parser_._characters (s); + + if (!ctx.error_type ()) + parser_._post_impl (); + + if (!ctx.error_type ()) + { + char* x = parser_.post_idref (); + + if (!parser_._error_type ()) + { + // push_back() frees the string if it fails. + // + if (seq_->push_back (x)) + _sys_error (sys_error::no_memory); + } + else + parser_._copy_error (ctx); + } + } +#endif + } + } + } +} + +#include <xsde/cxx/post.hxx> diff --git a/libxsde/xsde/cxx/parser/non-validating/idrefs.hxx b/libxsde/xsde/cxx/parser/non-validating/idrefs.hxx new file mode 100644 index 0000000..f3d9b99 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/idrefs.hxx @@ -0,0 +1,54 @@ +// file : xsde/cxx/parser/non-validating/idrefs.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_IDREFS_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_IDREFS_HXX + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> +#include <xsde/cxx/parser/non-validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_pimpl: virtual idrefs_pskel +#else + struct idrefs_pimpl: idrefs_pskel +#endif + { + ~idrefs_pimpl (); + idrefs_pimpl (bool base = false); + + void + pre_impl (string_sequence*); + + virtual void + _pre (); + + virtual void + _xsde_parse_item (const ro_string&); + + virtual string_sequence* + post_idrefs (); + + virtual void + _reset (); + + protected: + bool base_; + idref_pimpl parser_; + string_sequence* seq_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_IDREFS_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/int.cxx b/libxsde/xsde/cxx/parser/non-validating/int.cxx new file mode 100644 index 0000000..86a9a8b --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/int.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/int.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void int_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void int_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 11); + } + + int int_pimpl:: + post_int () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + + str_[size] = '\0'; + unsigned long ul = strtoul (str_, 0, 10); + + return (sign_ == minus) + ? (ul == 2147483648UL + ? (-2147483647 - 1) + : -static_cast<int> (ul)) + : static_cast<int> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/int.hxx b/libxsde/xsde/cxx/parser/non-validating/int.hxx new file mode 100644 index 0000000..8543909 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/int.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/int.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_INT_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_INT_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 32-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct int_pimpl: virtual int_pskel, number +#else + struct int_pimpl: int_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual int + post_int (); + + protected: + // We only need strlen("02147483648") + 1 characters to hold all + // valid and trimmed string representations of int. + // + char str_[12]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_INT_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/integer.cxx b/libxsde/xsde/cxx/parser/non-validating/integer.cxx new file mode 100644 index 0000000..dbad0e6 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/integer.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul +#include <limits.h> // LONG_MIN, LONG_MAX + +#include <xsde/cxx/parser/non-validating/integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void integer_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void integer_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 20); + } + + long integer_pimpl:: + post_integer () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + unsigned long ul = strtoul (str_, 0, 10); + + return (sign_ == minus) + ? (ul == static_cast<unsigned long> (LONG_MIN) + ? LONG_MIN : -static_cast<long> (ul)) + : static_cast<long> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/integer.hxx b/libxsde/xsde/cxx/parser/non-validating/integer.hxx new file mode 100644 index 0000000..94e1754 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/integer.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_INTEGER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_INTEGER_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Arbitrary-length integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct integer_pimpl: virtual integer_pskel, number +#else + struct integer_pimpl: integer_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long + post_integer (); + + protected: + // We only need strlen("09223372036854775808") + 1 characters to + // hold all valid and trimmed string representations of long, + // assuming we are on a 64 bit machine. + // + char str_[21]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_INTEGER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx new file mode 100644 index 0000000..80128ea --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/language-stl.cxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/language-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/language-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void language_pimpl:: + _pre () + { + str_.erase (); + } + + void language_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string language_pimpl:: + post_language () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/language-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/language-stl.hxx new file mode 100644 index 0000000..01dda2d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/language-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/language-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_LANGUAGE_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_LANGUAGE_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 language_pimpl: virtual language_pskel +#else + struct language_pimpl: language_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_language (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_LANGUAGE_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/language.cxx b/libxsde/xsde/cxx/parser/non-validating/language.cxx new file mode 100644 index 0000000..bcf41b0 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/language.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/language.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/language.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void language_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void language_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* language_pimpl:: + post_language () + { + ro_string tmp (str_); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/language.hxx b/libxsde/xsde/cxx/parser/non-validating/language.hxx new file mode 100644 index 0000000..cfefe25 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/language.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/language.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_LANGUAGE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_LANGUAGE_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 language_pimpl: virtual language_pskel +#else + struct language_pimpl: language_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_language (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_LANGUAGE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/long-long.cxx b/libxsde/xsde/cxx/parser/non-validating/long-long.cxx new file mode 100644 index 0000000..5501925 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/long-long.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/long-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoull + +#include <xsde/cxx/parser/non-validating/long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void long_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void long_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 20); + } + + long long long_pimpl:: + post_long () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + unsigned long long ull = strtoull (str_, 0, 10); + + return (sign_ == minus) + ? (ull == 9223372036854775808ULL + ? (-9223372036854775807LL - 1) + : -static_cast<long long> (ull)) + : static_cast<long long> (ull); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/long-long.hxx b/libxsde/xsde/cxx/parser/non-validating/long-long.hxx new file mode 100644 index 0000000..44669d0 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/long-long.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/long-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_LONG_LONG_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_LONG_LONG_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 64-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_pimpl: virtual long_pskel, number +#else + struct long_pimpl: long_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long long + post_long (); + + protected: + // We only need strlen("09223372036854775808") + 1 characters to + // hold all valid and trimmed string representations of long long. + // + char str_[21]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/long.cxx b/libxsde/xsde/cxx/parser/non-validating/long.cxx new file mode 100644 index 0000000..e1a3beb --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/long.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void long_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void long_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 20); + } + + long long_pimpl:: + post_long () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + unsigned long ul = strtoul (str_, 0, 10); + + return (sign_ == minus) + ? (ul == 2147483648UL + ? (-2147483647 - 1) + : -static_cast<int> (ul)) + : static_cast<int> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/long.hxx b/libxsde/xsde/cxx/parser/non-validating/long.hxx new file mode 100644 index 0000000..b51ecd0f --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/long.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_LONG_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_LONG_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_pimpl: virtual long_pskel, number +#else + struct long_pimpl: long_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long + post_long (); + + protected: + // We only need strlen("09223372036854775808") + 1 characters to + // hold all valid and trimmed string representations of long long. + // + char str_[21]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_LONG_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx new file mode 100644 index 0000000..65c3e0a --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/name-stl.cxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/name-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/name-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void name_pimpl:: + _pre () + { + str_.erase (); + } + + void name_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string name_pimpl:: + post_name () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/name-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/name-stl.hxx new file mode 100644 index 0000000..75bbf03 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/name-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/name-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NAME_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NAME_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 name_pimpl: virtual name_pskel +#else + struct name_pimpl: name_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_name (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NAME_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/name.cxx b/libxsde/xsde/cxx/parser/non-validating/name.cxx new file mode 100644 index 0000000..bbc7a2e --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/name.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/name.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/name.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void name_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void name_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* name_pimpl:: + post_name () + { + ro_string tmp (str_.data (), str_.size ()); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/name.hxx b/libxsde/xsde/cxx/parser/non-validating/name.hxx new file mode 100644 index 0000000..d10d34d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/name.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/name.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NAME_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NAME_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 name_pimpl: virtual name_pskel +#else + struct name_pimpl: name_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_name (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NAME_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx new file mode 100644 index 0000000..50f2df8 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/ncname-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/ncname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void ncname_pimpl:: + _pre () + { + str_.erase (); + } + + void ncname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string ncname_pimpl:: + post_ncname () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.hxx new file mode 100644 index 0000000..a1a1c69 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/ncname-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NCNAME_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NCNAME_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 ncname_pimpl: virtual ncname_pskel +#else + struct ncname_pimpl: ncname_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_ncname (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NCNAME_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname.cxx b/libxsde/xsde/cxx/parser/non-validating/ncname.cxx new file mode 100644 index 0000000..0fffa19 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/ncname.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/ncname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/ncname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void ncname_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void ncname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* ncname_pimpl:: + post_ncname () + { + ro_string tmp (str_.data (), str_.size ()); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname.hxx b/libxsde/xsde/cxx/parser/non-validating/ncname.hxx new file mode 100644 index 0000000..61a6a65 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/ncname.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/ncname.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NCNAME_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NCNAME_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 ncname_pimpl: virtual ncname_pskel +#else + struct ncname_pimpl: ncname_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_ncname (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NCNAME_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/negative-integer.cxx b/libxsde/xsde/cxx/parser/non-validating/negative-integer.cxx new file mode 100644 index 0000000..7121020 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/negative-integer.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/negative-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul +#include <limits.h> // LONG_MIN + +#include <xsde/cxx/parser/non-validating/negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void negative_integer_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void negative_integer_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 20); + } + + long negative_integer_pimpl:: + post_negative_integer () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + unsigned long ul = strtoul (str_, 0, 10); + + return (ul == static_cast<unsigned long> (LONG_MIN)) + ? LONG_MIN : -static_cast<long> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/negative-integer.hxx b/libxsde/xsde/cxx/parser/non-validating/negative-integer.hxx new file mode 100644 index 0000000..b7ee9e0 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/negative-integer.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/negative-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Arbitrary-length negative integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct negative_integer_pimpl: virtual negative_integer_pskel, number +#else + struct negative_integer_pimpl: negative_integer_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long + post_negative_integer (); + + protected: + // We only need strlen("09223372036854775808") + 1 characters to + // hold all valid and trimmed string representations of long, + // assuming we are on a 64 bit machine. + // + char str_[21]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx new file mode 100644 index 0000000..ce9df4b --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.cxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/nmtoken-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void nmtoken_pimpl:: + _pre () + { + str_.erase (); + } + + void nmtoken_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string nmtoken_pimpl:: + post_nmtoken () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.hxx new file mode 100644 index 0000000..770bfba --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtoken-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/nmtoken-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NMTOKEN_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NMTOKEN_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 nmtoken_pimpl: virtual nmtoken_pskel +#else + struct nmtoken_pimpl: nmtoken_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_nmtoken (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NMTOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx new file mode 100644 index 0000000..63888c7 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtoken.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/nmtoken.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void nmtoken_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void nmtoken_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* nmtoken_pimpl:: + post_nmtoken () + { + ro_string tmp (str_.data (), str_.size ()); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtoken.hxx b/libxsde/xsde/cxx/parser/non-validating/nmtoken.hxx new file mode 100644 index 0000000..a76eead --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtoken.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/nmtoken.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NMTOKEN_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NMTOKEN_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 nmtoken_pimpl: virtual nmtoken_pskel +#else + struct nmtoken_pimpl: nmtoken_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_nmtoken (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NMTOKEN_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx new file mode 100644 index 0000000..5b8186d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx @@ -0,0 +1,90 @@ +// file : xsde/cxx/parser/non-validating/nmtokens-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/nmtokens-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + nmtokens_pimpl:: + ~nmtokens_pimpl () + { + if (!base_) + delete seq_; + } + + void nmtokens_pimpl:: + _reset () + { + nmtokens_pskel::_reset (); + + if (!base_) + { + delete seq_; + seq_ = 0; + } + + parser_._reset (); + } + + nmtokens_pimpl:: + nmtokens_pimpl (bool base) + : base_ (base), seq_ (0) + { + } + + void nmtokens_pimpl:: + pre_impl (string_sequence* seq) + { + seq_ = seq; + } + + void nmtokens_pimpl:: + _pre () + { + if (seq_ == 0) + { + seq_ = new string_sequence (); + +#ifndef XSDE_EXCEPTIONS + if (seq_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + + nmtokens_pskel::_pre (); + } + + string_sequence* nmtokens_pimpl:: + post_nmtokens () + { + string_sequence* r = seq_; + seq_ = 0; + return r; + } + + void nmtokens_pimpl:: + _xsde_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre_impl (_context ()); + parser_._characters (s); + parser_._post_impl (); + seq_->push_back (parser_.post_nmtoken ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.hxx new file mode 100644 index 0000000..8c90877 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.hxx @@ -0,0 +1,54 @@ +// file : xsde/cxx/parser/non-validating/nmtokens-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NMTOKENS_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NMTOKENS_STL_HXX + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> +#include <xsde/cxx/parser/non-validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_pimpl: virtual nmtokens_pskel +#else + struct nmtokens_pimpl: nmtokens_pskel +#endif + { + ~nmtokens_pimpl (); + nmtokens_pimpl (bool base = false); + + void + pre_impl (string_sequence*); + + virtual void + _pre (); + + virtual void + _xsde_parse_item (const ro_string&); + + virtual string_sequence* + post_nmtokens (); + + virtual void + _reset (); + + protected: + bool base_; + nmtoken_pimpl parser_; + string_sequence* seq_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NMTOKENS_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx new file mode 100644 index 0000000..4cf41be --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx @@ -0,0 +1,129 @@ +// file : xsde/cxx/parser/non-validating/nmtokens.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/nmtokens.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + nmtokens_pimpl:: + ~nmtokens_pimpl () + { + if (!base_) + delete seq_; + } + + void nmtokens_pimpl:: + _reset () + { + nmtokens_pskel::_reset (); + + if (!base_) + { + delete seq_; + seq_ = 0; + } + + parser_._reset (); + } + + nmtokens_pimpl:: + nmtokens_pimpl (bool base) + : base_ (base), seq_ (0) + { + } + + void nmtokens_pimpl:: + pre_impl (string_sequence* seq) + { + seq_ = seq; + } + + void nmtokens_pimpl:: + _pre () + { + if (seq_ == 0) + { + seq_ = new string_sequence (); + +#ifndef XSDE_EXCEPTIONS + if (seq_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + + nmtokens_pskel::_pre (); + } + + string_sequence* nmtokens_pimpl:: + post_nmtokens () + { + string_sequence* r = seq_; + seq_ = 0; + return r; + } + +#ifdef XSDE_EXCEPTIONS + void nmtokens_pimpl:: + _xsde_parse_item (const ro_string& s) + { + parser_.pre (); + parser_._pre_impl (_context ()); + parser_._characters (s); + parser_._post_impl (); + + // push_back() frees the string if it throws. + // + seq_->push_back (parser_.post_nmtoken ()); + } +#else + void nmtokens_pimpl:: + _xsde_parse_item (const ro_string& s) + { + context& ctx = _context (); + + parser_.pre (); + + if (!parser_._error_type ()) + parser_._pre_impl (ctx); + else + parser_._copy_error (ctx); + + if (!ctx.error_type ()) + parser_._characters (s); + + if (!ctx.error_type ()) + parser_._post_impl (); + + if (!ctx.error_type ()) + { + char* x = parser_.post_nmtoken (); + + if (!parser_._error_type ()) + { + // push_back() frees the string if it fails. + // + if (seq_->push_back (x)) + _sys_error (sys_error::no_memory); + } + else + parser_._copy_error (ctx); + } + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtokens.hxx b/libxsde/xsde/cxx/parser/non-validating/nmtokens.hxx new file mode 100644 index 0000000..f8b3a19 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/nmtokens.hxx @@ -0,0 +1,54 @@ +// file : xsde/cxx/parser/non-validating/nmtokens.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NMTOKENS_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NMTOKENS_HXX + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> +#include <xsde/cxx/parser/non-validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_pimpl: virtual nmtokens_pskel +#else + struct nmtokens_pimpl: nmtokens_pskel +#endif + { + ~nmtokens_pimpl (); + nmtokens_pimpl (bool base = false); + + void + pre_impl (string_sequence*); + + virtual void + _pre (); + + virtual void + _xsde_parse_item (const ro_string&); + + virtual string_sequence* + post_nmtokens (); + + virtual void + _reset (); + + protected: + bool base_; + nmtoken_pimpl parser_; + string_sequence* seq_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NMTOKENS_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/non-negative-integer.cxx b/libxsde/xsde/cxx/parser/non-validating/non-negative-integer.cxx new file mode 100644 index 0000000..463c6c6 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/non-negative-integer.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/non-negative-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/non-negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void non_negative_integer_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void non_negative_integer_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 21); + } + + unsigned long non_negative_integer_pimpl:: + post_non_negative_integer () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + return strtoul (str_, 0, 10); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/non-negative-integer.hxx b/libxsde/xsde/cxx/parser/non-validating/non-negative-integer.hxx new file mode 100644 index 0000000..b7cf3f7 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/non-negative-integer.hxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/non-negative-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NON_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NON_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Arbitrary-length non-negative integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_negative_integer_pimpl: virtual non_negative_integer_pskel, +#else + struct non_negative_integer_pimpl: non_negative_integer_pskel, +#endif + number + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long + post_non_negative_integer (); + + protected: + // We only need strlen("018446744073709551615") + 1 characters to + // hold all valid and trimmed string representations of unsigned + // long, assuming we are on a 64 bit machine. + // + char str_[22]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NON_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/non-positive-integer.cxx b/libxsde/xsde/cxx/parser/non-validating/non-positive-integer.cxx new file mode 100644 index 0000000..c218a77 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/non-positive-integer.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/non-positive-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul +#include <limits.h> // LONG_MIN + +#include <xsde/cxx/parser/non-validating/non-positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void non_positive_integer_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void non_positive_integer_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 20); + } + + long non_positive_integer_pimpl:: + post_non_positive_integer () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + unsigned long ul = strtoul (str_, 0, 10); + + return (ul == static_cast<unsigned long> (LONG_MIN)) + ? LONG_MIN : -static_cast<long> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/non-positive-integer.hxx b/libxsde/xsde/cxx/parser/non-validating/non-positive-integer.hxx new file mode 100644 index 0000000..a6cefab --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/non-positive-integer.hxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/parser/non-validating/non-positive-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NON_POSITIVE_INTEGER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NON_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Arbitrary-length non-positive integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_positive_integer_pimpl: virtual non_positive_integer_pskel, +#else + struct non_positive_integer_pimpl: non_positive_integer_pskel, +#endif + number + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual long + post_non_positive_integer (); + + protected: + // We only need strlen("09223372036854775808") + 1 characters to + // hold all valid and trimmed string representations of long, + // assuming we are on a 64 bit machine. + // + char str_[21]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NON_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx new file mode 100644 index 0000000..2b1ff1a --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/normalized-string-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/normalized-string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void normalized_string_pimpl:: + _pre () + { + str_.erase (); + } + + void normalized_string_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + std::string normalized_string_pimpl:: + post_normalized_string () + { + std::string::size_type size = str_.size (); + + for (std::string::size_type i = 0; i < size; ++i) + { + char& c = str_[i]; + + if (c == 0x0A || c == 0x0D || c == 0x09) + c = 0x20; + } + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.hxx new file mode 100644 index 0000000..8544ac3 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/normalized-string-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/normalized-string-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NORMALIZED_STRING_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NORMALIZED_STRING_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 normalized_string_pimpl: virtual normalized_string_pskel +#else + struct normalized_string_pimpl: normalized_string_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_normalized_string (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NORMALIZED_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx b/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx new file mode 100644 index 0000000..b00b6c7 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/normalized-string.cxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/parser/non-validating/normalized-string.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/normalized-string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void normalized_string_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void normalized_string_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* normalized_string_pimpl:: + post_normalized_string () + { + typedef string::size_type size_type; + + size_type size = str_.size (); + + for (size_type i = 0; i < size; ++i) + { + char& c = str_[i]; + + if (c == 0x0A || c == 0x0D || c == 0x09) + c = 0x20; + } + + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/normalized-string.hxx b/libxsde/xsde/cxx/parser/non-validating/normalized-string.hxx new file mode 100644 index 0000000..8953729 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/normalized-string.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/normalized-string.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NORMALIZED_STRING_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NORMALIZED_STRING_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 normalized_string_pimpl: virtual normalized_string_pskel +#else + struct normalized_string_pimpl: normalized_string_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_normalized_string (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NORMALIZED_STRING_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/number.cxx b/libxsde/xsde/cxx/parser/non-validating/number.cxx new file mode 100644 index 0000000..c271ab5 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/number.cxx @@ -0,0 +1,127 @@ +// file : xsde/cxx/parser/non-validating/number.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <string.h> // memcpy + +#include <xsde/cxx/parser/non-validating/number.hxx> + +using xsde::cxx::ro_string; + +static bool +trim_leading_zeros (ro_string& s) +{ + ro_string::size_type size = s.size (); + + if (size != 0) + { + const char* f = s.data (); + const char* l = f + size; + const char* of = f; + + while (f < l && *f == '0') + ++f; + + if (f != of) + { + s.assign ((f <= l ? f : 0), (f <= l ? l - f : 0)); + return true; + } + } + + return false; +} + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void number:: + parse (const ro_string& s, char* str, size_t max) + { + ro_string tmp (s.data (), s.size ()); + size_t size = tmp.size (); + + switch (state_) + { + case leading_ws: + { + size = trim_left (tmp); + + if (size != 0) + state_ = sign; + else + break; + // Fall through. + } + case sign: + { + if (tmp[0] == '-') + sign_ = minus; + else if (tmp[0] == '+') + sign_ = plus; + + if (sign_ != none) + tmp.assign (tmp.data () + 1, --size); + + if (size != 0) + state_ = leading_zeros; + else + break; + + // Fall through. + } + case leading_zeros: + { + if (trim_leading_zeros (tmp)) + { + if (size_ == 0) + { + str[0] = '0'; + size_ = 1; + } + + size = tmp.size (); + } + + if (size != 0) + state_ = literal; + else + break; + // Fall through. + } + case literal: + { + // If this chunk is too long then it has to be the last so trim + // trailing ws. + // + if ((max - size_) < size) + { + size = trim_right (tmp); + state_ = trailing_ws; // It either had ws or is too large. + } + + if ((max - size_) >= size) + { + memcpy (str + size_, tmp.data (), size); + size_ += size; + } + + break; + } + case trailing_ws: + { + // We don't really care if it is not. + break; + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/number.hxx b/libxsde/xsde/cxx/parser/non-validating/number.hxx new file mode 100644 index 0000000..793f9b9 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/number.hxx @@ -0,0 +1,37 @@ +// file : xsde/cxx/parser/non-validating/number.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_NUMBER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_NUMBER_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/ro-string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + class number + { + protected: + void + parse (const ro_string&, char* str, size_t max); + + protected: + size_t size_; + enum {leading_ws, sign, leading_zeros, literal, trailing_ws} state_; + enum {none, plus, minus} sign_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_NUMBER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/parser.cxx b/libxsde/xsde/cxx/parser/non-validating/parser.cxx new file mode 100644 index 0000000..21a15e7 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/parser.cxx @@ -0,0 +1,473 @@ +// file : xsde/cxx/parser/non-validating/parser.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <assert.h> + +#include <xsde/cxx/parser/non-validating/parser.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // empty_content + // + +#ifdef XSDE_POLYMORPHIC + bool empty_content:: + _start_element_impl (const ro_string&, + const ro_string&, + const char*) + { + return false; + } +#else + bool empty_content:: + _start_element_impl (const ro_string&, + const ro_string&) + { + return false; + } +#endif + + bool empty_content:: + _end_element_impl (const ro_string&, + const ro_string&) + { + return false; + } + + bool empty_content:: + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + bool empty_content:: + _characters_impl (const ro_string&) + { + return false; + } + + // + // +#ifdef XSDE_POLYMORPHIC + void empty_content:: + _start_element (const ro_string& ns, + const ro_string& name, + const char* type) + { + if (!_start_element_impl (ns, name, type)) + _start_any_element (ns, name, type); + } +#else + void empty_content:: + _start_element (const ro_string& ns, + const ro_string& name) + { + if (!_start_element_impl (ns, name)) + _start_any_element (ns, name); + } +#endif + + void empty_content:: + _end_element (const ro_string& ns, + const ro_string& name) + { + if (!_end_element_impl (ns, name)) + _end_any_element (ns, name); + } + + static const char + xmlns_namespace_[] = "http://www.w3.org/2000/xmlns/"; + + static const char + xsi_namespace_[] = "http://www.w3.org/2001/XMLSchema-instance"; + + static const char + type_[] = "type"; + + static const char + nil_[] = "nil"; + + static const char + schema_location_[] = "schemaLocation"; + + static const char + no_namespace_schema_location_[] = "noNamespaceSchemaLocation"; + + void empty_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xsi_namespace_ && + (name == schema_location_ || + name == no_namespace_schema_location_ || + name == type_ || + name == nil_)) + return; + + // Also some parsers supply us with namespace-prefix + // mapping attributes. + // + if (ns == xmlns_namespace_) + return; + + if (!_attribute_impl (ns, name, value)) + _any_attribute (ns, name, value); + } + + void empty_content:: + _characters (const ro_string& s) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->_characters (s); + else +#endif + if (!_characters_impl (s)) + _any_characters (s); + } + + + // simple_content + // + + void simple_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xsi_namespace_ && + (name == schema_location_ || + name == no_namespace_schema_location_ || + name == type_ || + name == nil_)) + return; + + // Also some parsers supply us with namespace-prefix + // mapping attributes. + // + if (ns == xmlns_namespace_) + return; + + if (!_attribute_impl (ns, name, value)) + _any_attribute (ns, name, value); + } + + void simple_content:: + _characters (const ro_string& s) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->_characters (s); + else +#endif + if (!_characters_impl (s)) + _any_characters (s); + } + + + // complex_content + // + +#ifdef XSDE_POLYMORPHIC + void complex_content:: + _start_element (const ro_string& ns, + const ro_string& name, + const char* type) + { + if (!_start_element_impl (ns, name, type)) + { + context& c = _context (); + + c.current_.any_ = true; + c.current_.depth_++; + + _start_any_element (ns, name, type); + } + } +#else + void complex_content:: + _start_element (const ro_string& ns, + const ro_string& name) + { + if (!_start_element_impl (ns, name)) + { + context& c = _context (); + + c.current_.any_ = true; + c.current_.depth_++; + + _start_any_element (ns, name); + } + } +#endif + + void complex_content:: + _end_element (const ro_string& ns, + const ro_string& name) + { + if (!_end_element_impl (ns, name)) + _end_any_element (ns, name); + } + + void complex_content:: + _attribute (const ro_string& ns, + const ro_string& name, + const ro_string& value) + { + // Weed out special attributes: xsi:type, xsi:nil, + // xsi:schemaLocation and noNamespaceSchemaLocation. + // See section 3.2.7 in Structures for details. + // + if (ns == xsi_namespace_ && + (name == schema_location_ || + name == no_namespace_schema_location_ || + name == type_ || + name == nil_)) + return; + + // Also some parsers supply us with namespace-prefix + // mapping attributes. + // + if (ns == xmlns_namespace_) + return; + + if (!_attribute_impl (ns, name, value)) + _any_attribute (ns, name, value); + } + + void complex_content:: + _characters (const ro_string& s) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (impl_) + impl_->_characters (s); + else +#endif + if (!_characters_impl (s)) + _any_characters (s); + } + + void complex_content:: + _pre_impl (context& c) + { +#ifdef XSDE_REUSE_STYLE_TIEIN + assert (parent_ == 0); + + // Set the parent_ pointers in the tied-in implementations. + // + _set_parent_chain (); +#endif + if (depth_++ == 0) + context_ = &c; + +#ifdef XSDE_EXCEPTIONS + parser_stack_.push (c.current_); +#else + if (parser_stack_.push (c.current_)) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + c.current_.parser_ = this; + c.current_.depth_ = 0; + c.current_.any_ = false; + + _pre (); + } + + void complex_content:: + _post_impl () + { +#ifndef XSDE_EXCEPTIONS + if (!context_->error_type ()) +#endif + _post (); + + context_->current_ = parser_stack_.top (); + parser_stack_.pop (); + + if (--depth_ == 0) + context_ = 0; + } + + void complex_content:: + _reset () + { + empty_content::_reset (); + + depth_ = 0; + parser_stack_.clear (); + } + + // list_base + // + + // Find first non-space character. + // + static ro_string::size_type + find_ns (const char* s, + ro_string::size_type size, + ro_string::size_type pos) + { + while (pos < size && + (s[pos] == 0x20 || s[pos] == 0x0A || + s[pos] == 0x0D || s[pos] == 0x09)) + ++pos; + + return pos < size ? pos : ro_string::npos; + } + + // Find first space character. + // + static ro_string::size_type + find_s (const char* s, + ro_string::size_type size, + ro_string::size_type pos) + { + while (pos < size && + s[pos] != 0x20 && s[pos] != 0x0A && + s[pos] != 0x0D && s[pos] != 0x09) + ++pos; + + return pos < size ? pos : ro_string::npos; + } + + // Relevant XML Schema Part 2: Datatypes sections: 4.2.1.2, 4.3.6. + // + + void list_base:: + _pre_impl (context& c) + { + simple_content::_pre_impl (c); + +#ifdef XSDE_EXCEPTIONS + buf_.assign ("", 0); +#else + if (!c.error_type ()) + { + if (buf_.assign ("", 0)) + _sys_error (sys_error::no_memory); + } +#endif + } + + void list_base:: + _characters (const ro_string& s) + { + typedef ro_string::size_type size_type; + + const char* data = s.data (); + size_type size = s.size (); + + // Handle the previous chunk if we start with a ws. + // + if (!buf_.empty () && + (data[0] == 0x20 || data[0] == 0x0A || + data[0] == 0x0D || data[0] == 0x09)) + { + ro_string tmp (buf_); // Private copy ctor. + _xsde_parse_item (tmp); + buf_.assign ("", 0); // Can't fail. + } + +#ifndef XSDE_EXCEPTIONS + context& ctx = _context (); +#endif + + // Traverse the data while logically collapsing spaces. + // + for (size_type i = find_ns (data, size, 0); i != ro_string::npos;) + { + size_type j = find_s (data, size, i); + + if (j != ro_string::npos) + { + if (buf_.empty ()) + { + ro_string tmp (data + i, j - i); // Private copy ctor. + _xsde_parse_item (tmp); + } + else + { + // Assemble the first item in str from buf_ and s. + // + string str; + str.swap (buf_); + +#ifdef XSDE_EXCEPTIONS + str.append (data + i, j - i); +#else + if (str.append (data + i, j - i)) + { + _sys_error (sys_error::no_memory); + break; + } +#endif + ro_string tmp (str); // Private copy ctor. + _xsde_parse_item (tmp); + } + +#ifndef XSDE_EXCEPTIONS + if (ctx.error_type ()) + break; +#endif + + i = find_ns (data, size, j); + } + else + { + // Last fragment, append it to buf_. + // +#ifdef XSDE_EXCEPTIONS + buf_.append (data + i, size - i); +#else + if (buf_.append (data + i, size - i)) + _sys_error (sys_error::no_memory); +#endif + break; + } + } + } + + void list_base:: + _xsde_parse_item (const ro_string&) + { + } + + void list_base:: + _post_impl () + { + // Handle the last item. + // + if (!buf_.empty ()) + { + ro_string tmp (buf_); // Private copy ctor. + _xsde_parse_item (tmp); + } + + simple_content::_post_impl (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/parser.hxx b/libxsde/xsde/cxx/parser/non-validating/parser.hxx new file mode 100644 index 0000000..6b9889a --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/parser.hxx @@ -0,0 +1,196 @@ +// file : xsde/cxx/parser/non-validating/parser.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_PARSER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_PARSER_HXX + +#include <xsde/cxx/config.hxx> + +#include <stddef.h> // size_t + +#include <xsde/cxx/string.hxx> +#include <xsde/cxx/ro-string.hxx> + +#include <xsde/cxx/parser/elements.hxx> +#include <xsde/cxx/parser/state.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + struct empty_content: parser_base + { + // + // +#ifdef XSDE_POLYMORPHIC + virtual bool + _start_element_impl (const ro_string&, + const ro_string&, + const char*); +#else + virtual bool + _start_element_impl (const ro_string&, + const ro_string&); +#endif + + virtual bool + _end_element_impl (const ro_string&, + const ro_string&); + + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + virtual bool + _characters_impl (const ro_string&); + + + // + // +#ifdef XSDE_POLYMORPHIC + virtual void + _start_element (const ro_string&, + const ro_string&, + const char*); +#else + virtual void + _start_element (const ro_string&, + const ro_string&); +#endif + + virtual void + _end_element (const ro_string&, + const ro_string&); + + virtual void + _attribute (const ro_string&, + const ro_string&, + const ro_string&); + + virtual void + _characters (const ro_string&); + + // + // +#ifdef XSDE_REUSE_STYLE_TIEIN + empty_content (); + empty_content (empty_content* impl, void*); +#endif + }; + + + // + // + struct simple_content: empty_content + { + // + // + virtual void + _attribute (const ro_string&, + const ro_string&, + const ro_string&); + + virtual void + _characters (const ro_string&); + + // + // +#ifdef XSDE_REUSE_STYLE_TIEIN + simple_content (); + simple_content (simple_content* impl, void*); +#endif + }; + + + // + // + struct complex_content: empty_content + { +#ifdef XSDE_POLYMORPHIC + virtual void + _start_element (const ro_string&, + const ro_string&, + const char*); +#else + virtual void + _start_element (const ro_string&, + const ro_string&); +#endif + virtual void + _end_element (const ro_string&, + const ro_string&); + + virtual void + _attribute (const ro_string&, + const ro_string&, + const ro_string&); + + virtual void + _characters (const ro_string&); + + + // + // + virtual void + _pre_impl (context&); + + virtual void + _post_impl (); + + // + // + virtual void + _reset (); + + // + // + complex_content (); + +#ifdef XSDE_REUSE_STYLE_TIEIN + complex_content (complex_content* impl, void*); +#endif + protected: + size_t depth_; + parser_stack parser_stack_; + }; + + // Base for xsd:list. + // + struct list_base: simple_content + { + virtual void + _xsde_parse_item (const ro_string&); + + virtual void + _pre_impl (context&); + + virtual void + _characters (const ro_string&); + + virtual void + _post_impl (); + + // + // +#ifdef XSDE_REUSE_STYLE_TIEIN + list_base (); + list_base (list_base* impl, void*); +#endif + protected: + string buf_; + }; + } + } + } +} + +#include <xsde/cxx/parser/non-validating/parser.ixx> + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_PARSER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/parser.ixx b/libxsde/xsde/cxx/parser/non-validating/parser.ixx new file mode 100644 index 0000000..95f085d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/parser.ixx @@ -0,0 +1,77 @@ +// file : xsde/cxx/parser/non-validating/parser.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // empty_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline empty_content:: + empty_content () + { + } + + inline empty_content:: + empty_content (empty_content* impl, void*) + : parser_base (impl, 0) + { + } +#endif + + // simple_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline simple_content:: + simple_content () + { + } + + inline simple_content:: + simple_content (simple_content* impl, void*) + : empty_content (impl, 0) + { + } +#endif + + // complex_content + // + inline complex_content:: + complex_content () + : depth_ (0), parser_stack_ (previous_) + { + } + +#ifdef XSDE_REUSE_STYLE_TIEIN + inline complex_content:: + complex_content (complex_content* impl, void*) + : empty_content (impl, 0), depth_ (0), parser_stack_ (previous_) + { + } +#endif + + // list_base + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline list_base:: + list_base () + { + } + + inline list_base:: + list_base (list_base* impl, void*) + : simple_content (impl, 0) + { + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/positive-integer.cxx b/libxsde/xsde/cxx/parser/non-validating/positive-integer.cxx new file mode 100644 index 0000000..47f9852 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/positive-integer.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/positive-integer.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void positive_integer_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void positive_integer_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 21); + } + + unsigned long positive_integer_pimpl:: + post_positive_integer () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + return strtoul (str_, 0, 10); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/positive-integer.hxx b/libxsde/xsde/cxx/parser/non-validating/positive-integer.hxx new file mode 100644 index 0000000..fc326e4 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/positive-integer.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/positive-integer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_POSITIVE_INTEGER_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Arbitrary-length positive integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct positive_integer_pimpl: virtual positive_integer_pskel, number +#else + struct positive_integer_pimpl: positive_integer_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long + post_positive_integer (); + + protected: + // We only need strlen("018446744073709551615") + 1 characters to + // hold all valid and trimmed string representations of unsigned + // long, assuming we are on a 64 bit machine. + // + char str_[22]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/qname-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/qname-stl.cxx new file mode 100644 index 0000000..746959a --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/qname-stl.cxx @@ -0,0 +1,58 @@ +// file : xsde/cxx/parser/non-validating/qname-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/qname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void qname_pimpl:: + _pre () + { + str_.erase (); + } + + void qname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + qname qname_pimpl:: + post_qname () + { + ro_string tmp (str_.data (), str_.size ()); + ro_string::size_type size = trim_right (tmp); + ro_string::size_type pos = tmp.find (':'); + + if (pos != ro_string::npos) + { + std::string prefix (tmp.data (), pos); + std::string name (tmp.data () + pos + 1, size - pos - 1); + return qname (prefix, name); + } + else + { + str_.resize (size); + return qname (str_); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/qname-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/qname-stl.hxx new file mode 100644 index 0000000..7671400 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/qname-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/qname-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_QNAME_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_QNAME_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 qname_pimpl: virtual qname_pskel +#else + struct qname_pimpl: qname_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual qname + post_qname (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_QNAME_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/qname.cxx b/libxsde/xsde/cxx/parser/non-validating/qname.cxx new file mode 100644 index 0000000..87f03e8 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/qname.cxx @@ -0,0 +1,153 @@ +// file : xsde/cxx/parser/non-validating/qname.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/string.hxx> + +#include <xsde/cxx/parser/non-validating/qname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + qname_pimpl:: + ~qname_pimpl () + { + if (!base_) + delete qn_; + } + + void qname_pimpl:: + _reset () + { + qname_pskel::_reset (); + + if (!base_) + { + delete qn_; + qn_ = 0; + } + } + + qname_pimpl:: + qname_pimpl (bool base) + : base_ (base), qn_ (0) + { + } + + void qname_pimpl:: + pre_impl (qname* qn) + { + qn_ = qn; + } + + void qname_pimpl:: + _pre () + { + if (qn_ == 0) + { + qn_ = new qname (); + +#ifndef XSDE_EXCEPTIONS + if (qn_ == 0) + { + _sys_error (sys_error::no_memory); + return; + } +#endif + } + +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void qname_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + qname* qname_pimpl:: + post_qname () + { + ro_string tmp (str_.data (), str_.size ()); + ro_string::size_type size = trim_right (tmp); + ro_string::size_type pos = tmp.find (':'); + + const char* s = tmp.data (); + + string prefix; + string name; + + if (pos != ro_string::npos) + { +#ifdef XSDE_EXCEPTIONS + prefix.assign (s, pos); + name.assign (s + pos + 1, size - pos - 1); +#else + if (prefix.assign (s, pos) || + name.assign (s + pos + 1, size - pos - 1)) + { + _sys_error (sys_error::no_memory); + return 0; + } +#endif + } + else + { +#ifdef XSDE_EXCEPTIONS + prefix.assign ("", 0); +#else + if (prefix.assign ("", 0)) + { + _sys_error (sys_error::no_memory); + return 0; + } +#endif + str_.truncate (size); + name.swap (str_); + } + + qn_->prefix (prefix.detach ()); + qn_->name (name.detach ()); + + qname* r = qn_; + qn_ = 0; + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/qname.hxx b/libxsde/xsde/cxx/parser/non-validating/qname.hxx new file mode 100644 index 0000000..257eaf4 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/qname.hxx @@ -0,0 +1,55 @@ +// file : xsde/cxx/parser/non-validating/qname.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_QNAME_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_QNAME_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 qname_pimpl: virtual qname_pskel +#else + struct qname_pimpl: qname_pskel +#endif + { + ~qname_pimpl (); + qname_pimpl (bool base = false); + + void + pre_impl (qname*); + + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual qname* + post_qname (); + + virtual void + _reset (); + + protected: + bool base_; + string str_; + qname* qn_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_QNAME_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/short.cxx b/libxsde/xsde/cxx/parser/non-validating/short.cxx new file mode 100644 index 0000000..70f401d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/short.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/short.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void short_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void short_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 6); + } + + short short_pimpl:: + post_short () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + + str_[size] = '\0'; + unsigned long ul = strtoul (str_, 0, 10); + + return (sign_ == minus) + ? static_cast<short> (-static_cast<int> (ul)) + : static_cast<short> (ul); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/short.hxx b/libxsde/xsde/cxx/parser/non-validating/short.hxx new file mode 100644 index 0000000..8417a94 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/short.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/short.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_SHORT_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_SHORT_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 16-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct short_pimpl: virtual short_pskel, number +#else + struct short_pimpl: short_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual short + post_short (); + + protected: + // We only need strlen("032768") + 1 characters to hold all valid + // and trimmed string representations of short. + // + char str_[7]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_SHORT_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx new file mode 100644 index 0000000..7864648 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/string-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/parser/non-validating/string-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void string_pimpl:: + _pre () + { + str_.erase (); + } + + void string_pimpl:: + _characters (const ro_string& s) + { + str_ += s; + } + + std::string string_pimpl:: + post_string () + { + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/string-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/string-stl.hxx new file mode 100644 index 0000000..aaab4ba --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/string-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/string-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_STRING_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_STRING_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 string_pimpl: virtual string_pskel +#else + struct string_pimpl: string_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_string (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/string.cxx b/libxsde/xsde/cxx/parser/non-validating/string.cxx new file mode 100644 index 0000000..9d5f083 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/string.cxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/string.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void string_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void string_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* string_pimpl:: + post_string () + { + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/string.hxx b/libxsde/xsde/cxx/parser/non-validating/string.hxx new file mode 100644 index 0000000..de48551 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/string.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/string.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_STRING_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_STRING_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 string_pimpl: virtual string_pskel +#else + struct string_pimpl: string_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_string (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_STRING_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/time-zone.cxx b/libxsde/xsde/cxx/parser/non-validating/time-zone.cxx new file mode 100644 index 0000000..3465045 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/time-zone.cxx @@ -0,0 +1,53 @@ +// file : xsde/cxx/parser/non-validating/time-zone.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + namespace bits + { + void + parse_time_zone (const char* s, size_t n, short& h, short& m) + { + // time_zone := Z|(+|-)HH:MM + // + if (n == 0) + { + return; + } + else if (s[0] == 'Z') + { + h = 0; + m = 0; + } + else if (n == 6) + { + // Parse hours. + // + h = 10 * (s[1] - '0') + (s[2] - '0'); + + // Parse minutes. + // + m = 10 * (s[4] - '0') + (s[5] - '0'); + + if (s[0] == '-') + { + h = -h; + m = -m; + } + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/time-zone.hxx b/libxsde/xsde/cxx/parser/non-validating/time-zone.hxx new file mode 100644 index 0000000..9a3363c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/time-zone.hxx @@ -0,0 +1,32 @@ +// file : xsde/cxx/parser/non-validating/time-zone.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_TIME_ZONE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_TIME_ZONE_HXX + +#include <stddef.h> // size_t + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + namespace bits + { + void + parse_time_zone (const char* s, + size_t size, + short& hours, + short& minutes); + } + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_TIME_ZONE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/time.cxx b/libxsde/xsde/cxx/parser/non-validating/time.cxx new file mode 100644 index 0000000..a2ad5d3 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/time.cxx @@ -0,0 +1,118 @@ +// file : xsde/cxx/parser/non-validating/time.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtod + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/time.hxx> +#include <xsde/cxx/parser/non-validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void time_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void time_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + time time_pimpl:: + post_time () + { + char* s = str_.data (); + ro_string tmp (s, str_.size ()); + ro_string::size_type n = trim_right (tmp); + + // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] + // + unsigned short hours = 0; + unsigned short minutes = 0; + double seconds = 0.0; + bool zone = false; + short zh, zm; + + if (n >= 8) + { + // hours + // + hours = 10 * (s[0] - '0') + (s[1] - '0'); + + // minutes + // + minutes = 10 * (s[3] - '0') + (s[4] - '0'); + + // Find the end of the seconds fragment. + // + ro_string::size_type pos = 8; + for (; pos < n; ++pos) + { + char c = s[pos]; + + if (c == 'Z' || c == '+' || c == '-') + break; + } + + // Parse the time zone first so that we can truncate and + // reuse the string. + // + if (pos < n) + { + bits::parse_time_zone (s + pos, n - pos, zh, zm); + zone = true; + } + + // seconds + // + str_.truncate (pos); + seconds = strtod (s + 6, 0); + } + + return zone + ? time (hours, minutes, seconds, zh, zm) + : time (hours, minutes, seconds); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/time.hxx b/libxsde/xsde/cxx/parser/non-validating/time.hxx new file mode 100644 index 0000000..7526414 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/time.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/time.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_TIME_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_TIME_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 time_pimpl: virtual time_pskel +#else + struct time_pimpl: time_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual time + post_time (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_TIME_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx new file mode 100644 index 0000000..e975ae3 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/token-stl.cxx @@ -0,0 +1,73 @@ +// file : xsde/cxx/parser/non-validating/token-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/token-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void token_pimpl:: + _pre () + { + str_.erase (); + } + + void token_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string token_pimpl:: + post_token () + { + std::string::size_type size = str_.size (); + std::string::size_type j = 0; + + bool subs = false; + + for (std::string::size_type i = 0; i < size; ++i) + { + char c = str_[i]; + + if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09) + { + subs = true; + } + else + { + if (subs) + { + subs = false; + str_[j++] = 0x20; + } + + str_[j++] = c; + } + } + + str_.resize (j); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/token-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/token-stl.hxx new file mode 100644 index 0000000..0f3a288 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/token-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/token-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_TOKEN_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_TOKEN_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 token_pimpl: virtual token_pskel +#else + struct token_pimpl: token_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_token (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_TOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/token.cxx b/libxsde/xsde/cxx/parser/non-validating/token.cxx new file mode 100644 index 0000000..ffc1b4d --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/token.cxx @@ -0,0 +1,94 @@ +// file : xsde/cxx/parser/non-validating/token.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/token.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void token_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void token_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* token_pimpl:: + post_token () + { + typedef string::size_type size_type; + + size_type size = str_.size (); + size_type j = 0; + + bool subs = false; + + for (size_type i = 0; i < size; ++i) + { + char c = str_[i]; + + if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09) + { + subs = true; + } + else + { + if (subs) + { + subs = false; + str_[j++] = 0x20; + } + + str_[j++] = c; + } + } + + str_.truncate (j); + + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/token.hxx b/libxsde/xsde/cxx/parser/non-validating/token.hxx new file mode 100644 index 0000000..22d9f59 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/token.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/token.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_TOKEN_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_TOKEN_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 token_pimpl: virtual token_pskel +#else + struct token_pimpl: token_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_token (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_TOKEN_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-byte.cxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-byte.cxx new file mode 100644 index 0000000..11e6dd5 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-byte.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/unsigned-byte.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/unsigned-byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void unsigned_byte_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void unsigned_byte_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 4); + } + + unsigned char unsigned_byte_pimpl:: + post_unsigned_byte () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + + str_[size] = '\0'; + return static_cast<unsigned char> (strtoul (str_, 0, 10)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-byte.hxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-byte.hxx new file mode 100644 index 0000000..ed54cd0 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-byte.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/unsigned-byte.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_BYTE_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_BYTE_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 8-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_byte_pimpl: virtual unsigned_byte_pskel, number +#else + struct unsigned_byte_pimpl: unsigned_byte_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned char + post_unsigned_byte (); + + protected: + // We only need strlen("0256") + 1 characters to hold all valid + // and trimmed string representations of unsigned byte. + // + char str_[5]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_BYTE_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-int.cxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-int.cxx new file mode 100644 index 0000000..e14e091 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-int.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/unsigned-int.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/unsigned-int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void unsigned_int_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void unsigned_int_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 11); + } + + unsigned int unsigned_int_pimpl:: + post_unsigned_int () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + return static_cast<unsigned int> (strtoul (str_, 0, 10)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-int.hxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-int.hxx new file mode 100644 index 0000000..4cce2b0 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-int.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/unsigned-int.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_INT_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_INT_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 32-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_int_pimpl: virtual unsigned_int_pskel, number +#else + struct unsigned_int_pimpl: unsigned_int_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned int + post_unsigned_int (); + + protected: + // We only need strlen("04294967295") + 1 characters to hold all + // valid and trimmed string representations of unsigned int. + // + char str_[12]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_INT_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-long-long.cxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-long-long.cxx new file mode 100644 index 0000000..908066c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-long-long.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/unsigned-long-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoull + +#include <xsde/cxx/parser/non-validating/unsigned-long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void unsigned_long_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void unsigned_long_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 21); + } + + unsigned long long unsigned_long_pimpl:: + post_unsigned_long () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + return strtoull (str_, 0, 10); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-long-long.hxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-long-long.hxx new file mode 100644 index 0000000..8957135 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-long-long.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/unsigned-long-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_LONG_LONG_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_LONG_LONG_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 64-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_pimpl: virtual unsigned_long_pskel, number +#else + struct unsigned_long_pimpl: unsigned_long_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long long + post_unsigned_long (); + + protected: + // We only need strlen("018446744073709551615") + 1 characters to + // hold all valid and trimmed string representations of unsigned + // long long. + // + char str_[22]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-long.cxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-long.cxx new file mode 100644 index 0000000..8f70812 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-long.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/unsigned-long.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/unsigned-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void unsigned_long_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void unsigned_long_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 21); + } + + unsigned long unsigned_long_pimpl:: + post_unsigned_long () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + str_[size] = '\0'; + + return strtoul (str_, 0, 10); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-long.hxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-long.hxx new file mode 100644 index 0000000..45c976f --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-long.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/unsigned-long.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_LONG_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_LONG_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_pimpl: virtual unsigned_long_pskel, number +#else + struct unsigned_long_pimpl: unsigned_long_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned long + post_unsigned_long (); + + protected: + // We only need strlen("018446744073709551615") + 1 characters to + // hold all valid and trimmed string representations of unsigned + // long long. + // + char str_[22]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_LONG_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-short.cxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-short.cxx new file mode 100644 index 0000000..2044611 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-short.cxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/unsigned-short.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <stdlib.h> // strtoul + +#include <xsde/cxx/parser/non-validating/unsigned-short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void unsigned_short_pimpl:: + _pre () + { + size_ = 0; + sign_ = none; + state_ = leading_ws; + } + + void unsigned_short_pimpl:: + _characters (const ro_string& s) + { + parse (s, str_, 6); + } + + unsigned short unsigned_short_pimpl:: + post_unsigned_short () + { + ro_string tmp (str_, size_); + size_t size = trim_right (tmp); + + str_[size] = '\0'; + return static_cast<unsigned short> (strtoul (str_, 0, 10)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/unsigned-short.hxx b/libxsde/xsde/cxx/parser/non-validating/unsigned-short.hxx new file mode 100644 index 0000000..26b97ce --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/unsigned-short.hxx @@ -0,0 +1,48 @@ +// file : xsde/cxx/parser/non-validating/unsigned-short.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_SHORT_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_SHORT_HXX + +#include <xsde/cxx/parser/non-validating/number.hxx> +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // 16-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_short_pimpl: virtual unsigned_short_pskel, number +#else + struct unsigned_short_pimpl: unsigned_short_pskel, number +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual unsigned short + post_unsigned_short (); + + protected: + // We only need strlen("065535") + 1 characters to hold all valid + // and trimmed string representations of unsigned short. + // + char str_[7]; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_UNSIGNED_SHORT_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx new file mode 100644 index 0000000..369f448 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/uri-stl.cxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/parser/non-validating/uri-stl.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/uri-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void uri_pimpl:: + _pre () + { + str_.erase (); + } + + void uri_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + str_ += tmp; + } + else + str_ += s; + } + + std::string uri_pimpl:: + post_uri () + { + ro_string tmp (str_); + str_.resize (trim_right (tmp)); + + std::string r; + r.swap (str_); + return r; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/uri-stl.hxx b/libxsde/xsde/cxx/parser/non-validating/uri-stl.hxx new file mode 100644 index 0000000..351c513 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/uri-stl.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/uri-stl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_URI_STL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_URI_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 uri_pimpl: virtual uri_pskel +#else + struct uri_pimpl: uri_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual std::string + post_uri (); + + protected: + std::string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_URI_STL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/uri.cxx b/libxsde/xsde/cxx/parser/non-validating/uri.cxx new file mode 100644 index 0000000..2edb794 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/uri.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/parser/non-validating/uri.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/parser/non-validating/uri.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + void uri_pimpl:: + _pre () + { +#ifdef XSDE_EXCEPTIONS + str_.assign ("", 0); +#else + if (str_.assign ("", 0)) + _sys_error (sys_error::no_memory); +#endif + } + + void uri_pimpl:: + _characters (const ro_string& s) + { + if (str_.size () == 0) + { + ro_string tmp (s.data (), s.size ()); + + if (trim_left (tmp) != 0) + { +#ifdef XSDE_EXCEPTIONS + str_.append (tmp.data (), tmp.size ()); +#else + if (str_.append (tmp.data (), tmp.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + else + { +#ifdef XSDE_EXCEPTIONS + str_.append (s.data (), s.size ()); +#else + if (str_.append (s.data (), s.size ())) + _sys_error (sys_error::no_memory); +#endif + } + } + + char* uri_pimpl:: + post_uri () + { + ro_string tmp (str_); + str_.truncate (trim_right (tmp)); + return str_.detach (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/parser/non-validating/uri.hxx b/libxsde/xsde/cxx/parser/non-validating/uri.hxx new file mode 100644 index 0000000..245c493 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/uri.hxx @@ -0,0 +1,44 @@ +// file : xsde/cxx/parser/non-validating/uri.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_URI_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_URI_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 uri_pimpl: virtual uri_pskel +#else + struct uri_pimpl: uri_pskel +#endif + { + virtual void + _pre (); + + virtual void + _characters (const ro_string&); + + virtual char* + post_uri (); + + protected: + string str_; + }; + } + } + } +} + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_URI_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx new file mode 100644 index 0000000..e51cff0 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx @@ -0,0 +1,82 @@ +// file : xsde/cxx/parser/non-validating/xml-schema-pimpl.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_HXX + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +#include <xsde/cxx/parser/non-validating/any-type.hxx> +#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> +#include <xsde/cxx/parser/non-validating/byte.hxx> +#include <xsde/cxx/parser/non-validating/unsigned-byte.hxx> +#include <xsde/cxx/parser/non-validating/short.hxx> +#include <xsde/cxx/parser/non-validating/unsigned-short.hxx> +#include <xsde/cxx/parser/non-validating/int.hxx> +#include <xsde/cxx/parser/non-validating/unsigned-int.hxx> + +#ifdef XSDE_LONGLONG +# include <xsde/cxx/parser/non-validating/long-long.hxx> +# include <xsde/cxx/parser/non-validating/unsigned-long-long.hxx> +#else +# include <xsde/cxx/parser/non-validating/long.hxx> +# include <xsde/cxx/parser/non-validating/unsigned-long.hxx> +#endif + +#include <xsde/cxx/parser/non-validating/integer.hxx> +#include <xsde/cxx/parser/non-validating/negative-integer.hxx> +#include <xsde/cxx/parser/non-validating/non-positive-integer.hxx> +#include <xsde/cxx/parser/non-validating/positive-integer.hxx> +#include <xsde/cxx/parser/non-validating/non-negative-integer.hxx> +#include <xsde/cxx/parser/non-validating/float.hxx> +#include <xsde/cxx/parser/non-validating/double.hxx> +#include <xsde/cxx/parser/non-validating/decimal.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/parser/non-validating/string-stl.hxx> +# include <xsde/cxx/parser/non-validating/normalized-string-stl.hxx> +# include <xsde/cxx/parser/non-validating/token-stl.hxx> +# include <xsde/cxx/parser/non-validating/name-stl.hxx> +# include <xsde/cxx/parser/non-validating/nmtoken-stl.hxx> +# include <xsde/cxx/parser/non-validating/nmtokens-stl.hxx> +# include <xsde/cxx/parser/non-validating/ncname-stl.hxx> +# include <xsde/cxx/parser/non-validating/id-stl.hxx> +# include <xsde/cxx/parser/non-validating/idref-stl.hxx> +# include <xsde/cxx/parser/non-validating/idrefs-stl.hxx> +# include <xsde/cxx/parser/non-validating/language-stl.hxx> +# include <xsde/cxx/parser/non-validating/uri-stl.hxx> +# include <xsde/cxx/parser/non-validating/qname-stl.hxx> +#else +# include <xsde/cxx/parser/non-validating/string.hxx> +# include <xsde/cxx/parser/non-validating/normalized-string.hxx> +# include <xsde/cxx/parser/non-validating/token.hxx> +# include <xsde/cxx/parser/non-validating/name.hxx> +# include <xsde/cxx/parser/non-validating/nmtoken.hxx> +# include <xsde/cxx/parser/non-validating/nmtokens.hxx> +# include <xsde/cxx/parser/non-validating/ncname.hxx> +# include <xsde/cxx/parser/non-validating/id.hxx> +# include <xsde/cxx/parser/non-validating/idref.hxx> +# include <xsde/cxx/parser/non-validating/idrefs.hxx> +# include <xsde/cxx/parser/non-validating/language.hxx> +# include <xsde/cxx/parser/non-validating/uri.hxx> +# include <xsde/cxx/parser/non-validating/qname.hxx> +#endif + +#include <xsde/cxx/parser/non-validating/base64-binary.hxx> +#include <xsde/cxx/parser/non-validating/hex-binary.hxx> + +#include <xsde/cxx/parser/non-validating/gday.hxx> +#include <xsde/cxx/parser/non-validating/gmonth.hxx> +#include <xsde/cxx/parser/non-validating/gyear.hxx> +#include <xsde/cxx/parser/non-validating/gmonth-day.hxx> +#include <xsde/cxx/parser/non-validating/gyear-month.hxx> +#include <xsde/cxx/parser/non-validating/date.hxx> +#include <xsde/cxx/parser/non-validating/time.hxx> +#include <xsde/cxx/parser/non-validating/date-time.hxx> +#include <xsde/cxx/parser/non-validating/duration.hxx> + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PIMPL_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 new file mode 100644 index 0000000..39138a1 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.cxx @@ -0,0 +1,612 @@ +// file : xsde/cxx/parser/non-validating/xml-schema-pskel.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // any_type and any_simple_type + // + // In non-validating case we can simply return false from *_impl + // functions which will result in calls to the corresponding + // _any_* callbacks. + // + // + +#ifdef XSDE_POLYMORPHIC + bool any_type_pskel:: + _start_element_impl (const ro_string&, + const ro_string&, + const char*) + { + return false; + } +#else + bool any_type_pskel:: + _start_element_impl (const ro_string&, const ro_string&) + { + return false; + } +#endif + + + bool any_type_pskel:: + _end_element_impl (const ro_string&, const ro_string&) + { + return false; + } + + bool any_type_pskel:: + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&) + { + return false; + } + + bool any_type_pskel:: + _characters_impl (const ro_string&) + { + return false; + } + + void any_type_pskel:: + post_any_type () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_type_impl_) + any_type_impl_->post_any_type (); +#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. + // + +#ifdef XSDE_POLYMORPHIC + const char* any_type_pskel:: + _static_type () + { + return "anyType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* any_simple_type_pskel:: + _static_type () + { + return "anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_simple_type_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* boolean_pskel:: + _static_type () + { + return "boolean http://www.w3.org/2001/XMLSchema"; + } + + const char* boolean_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* byte_pskel:: + _static_type () + { + return "byte http://www.w3.org/2001/XMLSchema"; + } + + const char* byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_byte_pskel:: + _static_type () + { + return "unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_byte_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* short_pskel:: + _static_type () + { + return "short http://www.w3.org/2001/XMLSchema"; + } + + const char* short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_short_pskel:: + _static_type () + { + return "unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_short_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* int_pskel:: + _static_type () + { + return "int http://www.w3.org/2001/XMLSchema"; + } + + const char* int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_int_pskel:: + _static_type () + { + return "unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_int_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* long_pskel:: + _static_type () + { + return "long http://www.w3.org/2001/XMLSchema"; + } + + const char* long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_long_pskel:: + _static_type () + { + return "unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_long_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* integer_pskel:: + _static_type () + { + return "integer http://www.w3.org/2001/XMLSchema"; + } + + const char* integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* negative_integer_pskel:: + _static_type () + { + return "negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_positive_integer_pskel:: + _static_type () + { + return "nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* positive_integer_pskel:: + _static_type () + { + return "positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* positive_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_negative_integer_pskel:: + _static_type () + { + return "nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_negative_integer_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* float_pskel:: + _static_type () + { + return "float http://www.w3.org/2001/XMLSchema"; + } + + const char* float_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* double_pskel:: + _static_type () + { + return "double http://www.w3.org/2001/XMLSchema"; + } + + const char* double_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* decimal_pskel:: + _static_type () + { + return "decimal http://www.w3.org/2001/XMLSchema"; + } + + const char* decimal_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* string_pskel:: + _static_type () + { + return "string http://www.w3.org/2001/XMLSchema"; + } + + const char* string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* normalized_string_pskel:: + _static_type () + { + return "normalizedString http://www.w3.org/2001/XMLSchema"; + } + + const char* normalized_string_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* token_pskel:: + _static_type () + { + return "token http://www.w3.org/2001/XMLSchema"; + } + + const char* token_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* name_pskel:: + _static_type () + { + return "Name http://www.w3.org/2001/XMLSchema"; + } + + const char* name_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtoken_pskel:: + _static_type () + { + return "NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtoken_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtokens_pskel:: + _static_type () + { + return "NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtokens_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* ncname_pskel:: + _static_type () + { + return "NCName http://www.w3.org/2001/XMLSchema"; + } + + const char* ncname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* id_pskel:: + _static_type () + { + return "ID http://www.w3.org/2001/XMLSchema"; + } + + const char* id_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idref_pskel:: + _static_type () + { + return "IDREF http://www.w3.org/2001/XMLSchema"; + } + + const char* idref_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idrefs_pskel:: + _static_type () + { + return "IDREFS http://www.w3.org/2001/XMLSchema"; + } + + const char* idrefs_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* language_pskel:: + _static_type () + { + return "language http://www.w3.org/2001/XMLSchema"; + } + + const char* language_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* uri_pskel:: + _static_type () + { + return "anyURI http://www.w3.org/2001/XMLSchema"; + } + + const char* uri_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* qname_pskel:: + _static_type () + { + return "QName http://www.w3.org/2001/XMLSchema"; + } + + const char* qname_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* base64_binary_pskel:: + _static_type () + { + return "base64Binary http://www.w3.org/2001/XMLSchema"; + } + + const char* base64_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* hex_binary_pskel:: + _static_type () + { + return "hexBinary http://www.w3.org/2001/XMLSchema"; + } + + const char* hex_binary_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gday_pskel:: + _static_type () + { + return "gDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gday_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_pskel:: + _static_type () + { + return "gMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_pskel:: + _static_type () + { + return "gYear http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_day_pskel:: + _static_type () + { + return "gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_day_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_month_pskel:: + _static_type () + { + return "gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_month_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_pskel:: + _static_type () + { + return "date http://www.w3.org/2001/XMLSchema"; + } + + const char* date_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* time_pskel:: + _static_type () + { + return "time http://www.w3.org/2001/XMLSchema"; + } + + const char* time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_time_pskel:: + _static_type () + { + return "dateTime http://www.w3.org/2001/XMLSchema"; + } + + const char* date_time_pskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* duration_pskel:: + _static_type () + { + return "duration http://www.w3.org/2001/XMLSchema"; + } + + const char* duration_pskel:: + _dynamic_type () const + { + return _static_type (); + } +#endif // XSDE_POLYMORPHIC + } + } + } +} + diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx new file mode 100644 index 0000000..0792936 --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx @@ -0,0 +1,1388 @@ +// file : xsde/cxx/parser/non-validating/xml-schema-pskel.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX +#define XSDE_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX + +#include <xsde/cxx/config.hxx> + +#ifdef XSDE_STL +# include <string> +#endif + +#include <xsde/cxx/parser/xml-schema.hxx> + +#include <xsde/cxx/parser/non-validating/parser.hxx> + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // anyType and anySimpleType. All events are routed to the + // _any_* callbacks. + // + + struct any_type_pskel: complex_content + { +#ifdef XSDE_POLYMORPHIC + virtual bool + _start_element_impl (const ro_string&, + const ro_string&, + const char*); +#else + virtual bool + _start_element_impl (const ro_string&, + const ro_string&); +#endif + virtual bool + _end_element_impl (const ro_string&, + const ro_string&); + + virtual bool + _attribute_impl (const ro_string&, + const ro_string&, + const ro_string&); + + virtual bool + _characters_impl (const ro_string&); + + virtual void + post_any_type (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_type_pskel (); + any_type_pskel (any_type_pskel* impl, void*); + + protected: + any_type_pskel* any_type_impl_; +#endif + }; + + struct any_simple_type_pskel: simple_content + { + virtual bool + _characters_impl (const ro_string&); + + virtual void + post_any_simple_type (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_simple_type_pskel (); + any_simple_type_pskel (any_simple_type_pskel* impl, void*); + + protected: + any_simple_type_pskel* any_simple_type_impl_; +#endif + }; + + + // Boolean. + // + + struct boolean_pskel: simple_content + { + virtual bool + post_boolean () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + boolean_pskel (); + boolean_pskel (boolean_pskel* impl, void*); + + protected: + boolean_pskel* boolean_impl_; +#endif + }; + + + // 8-bit + // + struct byte_pskel: simple_content + { + virtual signed char + post_byte () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + byte_pskel (); + byte_pskel (byte_pskel* impl, void*); + + protected: + byte_pskel* byte_impl_; +#endif + }; + + struct unsigned_byte_pskel: simple_content + { + virtual unsigned char + post_unsigned_byte () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_byte_pskel (); + unsigned_byte_pskel (unsigned_byte_pskel* impl, void*); + + protected: + unsigned_byte_pskel* unsigned_byte_impl_; +#endif + }; + + + // 16-bit + // + + struct short_pskel: simple_content + { + virtual short + post_short () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + short_pskel (); + short_pskel (short_pskel* impl, void*); + + protected: + short_pskel* short_impl_; +#endif + }; + + struct unsigned_short_pskel: simple_content + { + virtual unsigned short + post_unsigned_short () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_short_pskel (); + unsigned_short_pskel (unsigned_short_pskel* impl, void*); + + protected: + unsigned_short_pskel* unsigned_short_impl_; +#endif + }; + + + // 32-bit + // + + struct int_pskel: simple_content + { + virtual int + post_int () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + int_pskel (); + int_pskel (int_pskel* impl, void*); + + protected: + int_pskel* int_impl_; +#endif + }; + + struct unsigned_int_pskel: simple_content + { + virtual unsigned int + post_unsigned_int () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_int_pskel (); + unsigned_int_pskel (unsigned_int_pskel* impl, void*); + + protected: + unsigned_int_pskel* unsigned_int_impl_; +#endif + }; + + + // 64-bit + // +#ifdef XSDE_LONGLONG + + struct long_pskel: simple_content + { + virtual long long + post_long () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_pskel (); + long_pskel (long_pskel* impl, void*); + + protected: + long_pskel* long_impl_; +#endif + }; + + struct unsigned_long_pskel: simple_content + { + virtual unsigned long long + post_unsigned_long () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_pskel (); + unsigned_long_pskel (unsigned_long_pskel* impl, void*); + + protected: + unsigned_long_pskel* unsigned_long_impl_; +#endif + }; + +#else + + struct long_pskel: simple_content + { + virtual long + post_long () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_pskel (); + long_pskel (long_pskel* impl, void*); + + protected: + long_pskel* long_impl_; +#endif + }; + + struct unsigned_long_pskel: simple_content + { + virtual unsigned long + post_unsigned_long () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_pskel (); + unsigned_long_pskel (unsigned_long_pskel* impl, void*); + + protected: + unsigned_long_pskel* unsigned_long_impl_; +#endif + }; +#endif + + + // Arbitrary-length integers. + // + + struct integer_pskel: simple_content + { + virtual long + post_integer () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + integer_pskel (); + integer_pskel (integer_pskel* impl, void*); + + protected: + integer_pskel* integer_impl_; +#endif + }; + + struct negative_integer_pskel: simple_content + { + virtual long + post_negative_integer () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + negative_integer_pskel (); + negative_integer_pskel (negative_integer_pskel* impl, void*); + + protected: + negative_integer_pskel* negative_integer_impl_; +#endif + }; + + struct non_positive_integer_pskel: simple_content + { + virtual long + post_non_positive_integer () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_positive_integer_pskel (); + non_positive_integer_pskel (non_positive_integer_pskel* impl, void*); + + protected: + non_positive_integer_pskel* non_positive_integer_impl_; +#endif + }; + + struct positive_integer_pskel: simple_content + { + virtual unsigned long + post_positive_integer () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + positive_integer_pskel (); + positive_integer_pskel (positive_integer_pskel* impl, void*); + + protected: + positive_integer_pskel* positive_integer_impl_; +#endif + }; + + struct non_negative_integer_pskel: simple_content + { + virtual unsigned long + post_non_negative_integer () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_negative_integer_pskel (); + non_negative_integer_pskel (non_negative_integer_pskel* impl, void*); + + protected: + non_negative_integer_pskel* non_negative_integer_impl_; +#endif + }; + + + // Floats. + // + + struct float_pskel: simple_content + { + virtual float + post_float () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + float_pskel (); + float_pskel (float_pskel* impl, void*); + + protected: + float_pskel* float_impl_; +#endif + }; + + struct double_pskel: simple_content + { + virtual double + post_double () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + double_pskel (); + double_pskel (double_pskel* impl, void*); + + protected: + double_pskel* double_impl_; +#endif + }; + + struct decimal_pskel: simple_content + { + virtual double + post_decimal () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + decimal_pskel (); + decimal_pskel (decimal_pskel* impl, void*); + + protected: + decimal_pskel* decimal_impl_; +#endif + }; + + + // String-based types. + // +#ifdef XSDE_STL + + struct string_pskel: simple_content + { + virtual std::string + post_string () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_pskel (); + string_pskel (string_pskel* impl, void*); + + protected: + string_pskel* string_impl_; +#endif + }; + + struct normalized_string_pskel: simple_content + { + virtual std::string + post_normalized_string () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_pskel (); + normalized_string_pskel (normalized_string_pskel* impl, void*); + + protected: + normalized_string_pskel* normalized_string_impl_; +#endif + }; + + struct token_pskel: simple_content + { + virtual std::string + post_token () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_pskel (); + token_pskel (token_pskel* impl, void*); + + protected: + token_pskel* token_impl_; +#endif + }; + + struct name_pskel: simple_content + { + virtual std::string + post_name () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_pskel (); + name_pskel (name_pskel* impl, void*); + + protected: + name_pskel* name_impl_; +#endif + }; + + struct nmtoken_pskel: simple_content + { + virtual std::string + post_nmtoken () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_pskel (); + nmtoken_pskel (nmtoken_pskel* impl, void*); + + protected: + nmtoken_pskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_pskel: list_base + { + virtual string_sequence* + post_nmtokens () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_pskel (); + nmtokens_pskel (nmtokens_pskel* impl, void*); + + protected: + nmtokens_pskel* nmtokens_impl_; +#endif + }; + + struct ncname_pskel: simple_content + { + virtual std::string + post_ncname () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_pskel (); + ncname_pskel (ncname_pskel* impl, void*); + + protected: + ncname_pskel* ncname_impl_; +#endif + }; + + struct id_pskel: simple_content + { + virtual std::string + post_id () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_pskel (); + id_pskel (id_pskel* impl, void*); + + protected: + id_pskel* id_impl_; +#endif + }; + + struct idref_pskel: simple_content + { + virtual std::string + post_idref () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_pskel (); + idref_pskel (idref_pskel* impl, void*); + + protected: + idref_pskel* idref_impl_; +#endif + }; + + struct idrefs_pskel: list_base + { + virtual string_sequence* + post_idrefs () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_pskel (); + idrefs_pskel (idrefs_pskel* impl, void*); + + protected: + idrefs_pskel* idrefs_impl_; +#endif + }; + + struct language_pskel: simple_content + { + virtual std::string + post_language () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_pskel (); + language_pskel (language_pskel* impl, void*); + + protected: + language_pskel* language_impl_; +#endif + }; + + struct uri_pskel: simple_content + { + virtual std::string + post_uri () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_pskel (); + uri_pskel (uri_pskel* impl, void*); + + protected: + uri_pskel* uri_impl_; +#endif + }; + + struct qname_pskel: simple_content + { + virtual qname + post_qname () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_pskel (); + qname_pskel (qname_pskel* impl, void*); + + protected: + qname_pskel* qname_impl_; +#endif + }; + +#else // XSDE_STL + + // Note that in this case you are getting a C string that you + // have to delete with delete[]. + // + + struct string_pskel: simple_content + { + virtual char* + post_string () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_pskel (); + string_pskel (string_pskel* impl, void*); + + protected: + string_pskel* string_impl_; +#endif + }; + + struct normalized_string_pskel: simple_content + { + virtual char* + post_normalized_string () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_pskel (); + normalized_string_pskel (normalized_string_pskel* impl, void*); + + protected: + normalized_string_pskel* normalized_string_impl_; +#endif + }; + + struct token_pskel: simple_content + { + virtual char* + post_token () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_pskel (); + token_pskel (token_pskel* impl, void*); + + protected: + token_pskel* token_impl_; +#endif + }; + + struct name_pskel: simple_content + { + virtual char* + post_name () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_pskel (); + name_pskel (name_pskel* impl, void*); + + protected: + name_pskel* name_impl_; +#endif + }; + + struct nmtoken_pskel: simple_content + { + virtual char* + post_nmtoken () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_pskel (); + nmtoken_pskel (nmtoken_pskel* impl, void*); + + protected: + nmtoken_pskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_pskel: list_base + { + virtual string_sequence* + post_nmtokens () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_pskel (); + nmtokens_pskel (nmtokens_pskel* impl, void*); + + protected: + nmtokens_pskel* nmtokens_impl_; +#endif + }; + + struct ncname_pskel: simple_content + { + virtual char* + post_ncname () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_pskel (); + ncname_pskel (ncname_pskel* impl, void*); + + protected: + ncname_pskel* ncname_impl_; +#endif + }; + + struct id_pskel: simple_content + { + virtual char* + post_id () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_pskel (); + id_pskel (id_pskel* impl, void*); + + protected: + id_pskel* id_impl_; +#endif + }; + + struct idref_pskel: simple_content + { + virtual char* + post_idref () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_pskel (); + idref_pskel (idref_pskel* impl, void*); + + protected: + idref_pskel* idref_impl_; +#endif + }; + + struct idrefs_pskel: list_base + { + virtual string_sequence* + post_idrefs () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_pskel (); + idrefs_pskel (idrefs_pskel* impl, void*); + + protected: + idrefs_pskel* idrefs_impl_; +#endif + }; + + struct language_pskel: simple_content + { + virtual char* + post_language () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_pskel (); + language_pskel (language_pskel* impl, void*); + + protected: + language_pskel* language_impl_; +#endif + }; + + struct uri_pskel: simple_content + { + virtual char* + post_uri () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_pskel (); + uri_pskel (uri_pskel* impl, void*); + + protected: + uri_pskel* uri_impl_; +#endif + }; + + struct qname_pskel: simple_content + { + virtual qname* + post_qname () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_pskel (); + qname_pskel (qname_pskel* impl, void*); + + protected: + qname_pskel* qname_impl_; +#endif + }; +#endif // XSDE_STL + + + // base64Binary + // + struct base64_binary_pskel: simple_content + { + virtual buffer* + post_base64_binary () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + base64_binary_pskel (); + base64_binary_pskel (base64_binary_pskel* impl, void*); + + protected: + base64_binary_pskel* base64_binary_impl_; +#endif + }; + + // hexBinary + // + struct hex_binary_pskel: simple_content + { + virtual buffer* + post_hex_binary () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + hex_binary_pskel (); + hex_binary_pskel (hex_binary_pskel* impl, void*); + + protected: + hex_binary_pskel* hex_binary_impl_; +#endif + }; + + // Time and date types. + // + struct gday_pskel: simple_content + { + virtual gday + post_gday () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gday_pskel (); + gday_pskel (gday_pskel* impl, void*); + + protected: + gday_pskel* gday_impl_; +#endif + }; + + struct gmonth_pskel: simple_content + { + virtual gmonth + post_gmonth () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_pskel (); + gmonth_pskel (gmonth_pskel* impl, void*); + + protected: + gmonth_pskel* gmonth_impl_; +#endif + }; + + struct gyear_pskel: simple_content + { + virtual gyear + post_gyear () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_pskel (); + gyear_pskel (gyear_pskel* impl, void*); + + protected: + gyear_pskel* gyear_impl_; +#endif + }; + + struct gmonth_day_pskel: simple_content + { + virtual gmonth_day + post_gmonth_day () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_day_pskel (); + gmonth_day_pskel (gmonth_day_pskel* impl, void*); + + protected: + gmonth_day_pskel* gmonth_day_impl_; +#endif + }; + + struct gyear_month_pskel: simple_content + { + virtual gyear_month + post_gyear_month () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_month_pskel (); + gyear_month_pskel (gyear_month_pskel* impl, void*); + + protected: + gyear_month_pskel* gyear_month_impl_; +#endif + }; + + struct date_pskel: simple_content + { + virtual date + post_date () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_pskel (); + date_pskel (date_pskel* impl, void*); + + protected: + date_pskel* date_impl_; +#endif + }; + + struct time_pskel: simple_content + { + virtual time + post_time () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + time_pskel (); + time_pskel (time_pskel* impl, void*); + + protected: + time_pskel* time_impl_; +#endif + }; + + struct date_time_pskel: simple_content + { + virtual date_time + post_date_time () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_time_pskel (); + date_time_pskel (date_time_pskel* impl, void*); + + protected: + date_time_pskel* date_time_impl_; +#endif + }; + + struct duration_pskel: simple_content + { + virtual duration + post_duration () = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + duration_pskel (); + duration_pskel (duration_pskel* impl, void*); + + protected: + duration_pskel* duration_impl_; +#endif + }; + } + } + } +} + +#include <xsde/cxx/parser/non-validating/xml-schema-pskel.ixx> + +#endif // XSDE_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx new file mode 100644 index 0000000..220464c --- /dev/null +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.ixx @@ -0,0 +1,704 @@ +// file : xsde/cxx/parser/non-validating/xml-schema-pskel.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsde +{ + namespace cxx + { + namespace parser + { + namespace non_validating + { + // any_type_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_type_pskel:: + any_type_pskel () + : any_type_impl_ (0) + { + } + + inline any_type_pskel:: + any_type_pskel (any_type_pskel* impl, void*) + : complex_content (impl, 0), any_type_impl_ (impl) + { + } +#endif + + // any_simple_type_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_simple_type_pskel:: + any_simple_type_pskel () + : any_simple_type_impl_ (0) + { + } + + inline any_simple_type_pskel:: + any_simple_type_pskel (any_simple_type_pskel* impl, void*) + : simple_content (impl, 0), any_simple_type_impl_ (impl) + { + } +#endif + + // boolean_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline boolean_pskel:: + boolean_pskel () + : boolean_impl_ (0) + { + } + + inline boolean_pskel:: + boolean_pskel (boolean_pskel* impl, void*) + : simple_content (impl, 0), boolean_impl_ (impl) + { + } +#endif + + // byte_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline byte_pskel:: + byte_pskel () + : byte_impl_ (0) + { + } + + inline byte_pskel:: + byte_pskel (byte_pskel* impl, void*) + : simple_content (impl, 0), byte_impl_ (impl) + { + } +#endif + + // unsigned_byte_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_byte_pskel:: + unsigned_byte_pskel () + : unsigned_byte_impl_ (0) + { + } + + inline unsigned_byte_pskel:: + unsigned_byte_pskel (unsigned_byte_pskel* impl, void*) + : simple_content (impl, 0), unsigned_byte_impl_ (impl) + { + } +#endif + + // short_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline short_pskel:: + short_pskel () + : short_impl_ (0) + { + } + + inline short_pskel:: + short_pskel (short_pskel* impl, void*) + : simple_content (impl, 0), short_impl_ (impl) + { + } +#endif + + // unsigned_short_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_short_pskel:: + unsigned_short_pskel () + : unsigned_short_impl_ (0) + { + } + + inline unsigned_short_pskel:: + unsigned_short_pskel (unsigned_short_pskel* impl, void*) + : simple_content (impl, 0), unsigned_short_impl_ (impl) + { + } +#endif + + // int_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline int_pskel:: + int_pskel () + : int_impl_ (0) + { + } + + inline int_pskel:: + int_pskel (int_pskel* impl, void*) + : simple_content (impl, 0), int_impl_ (impl) + { + } +#endif + + // unsigned_int_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_int_pskel:: + unsigned_int_pskel () + : unsigned_int_impl_ (0) + { + } + + inline unsigned_int_pskel:: + unsigned_int_pskel (unsigned_int_pskel* impl, void*) + : simple_content (impl, 0), unsigned_int_impl_ (impl) + { + } +#endif + + // long_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline long_pskel:: + long_pskel () + : long_impl_ (0) + { + } + + inline long_pskel:: + long_pskel (long_pskel* impl, void*) + : simple_content (impl, 0), long_impl_ (impl) + { + } +#endif + + // unsigned_long_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_long_pskel:: + unsigned_long_pskel () + : unsigned_long_impl_ (0) + { + } + + inline unsigned_long_pskel:: + unsigned_long_pskel (unsigned_long_pskel* impl, void*) + : simple_content (impl, 0), unsigned_long_impl_ (impl) + { + } +#endif + + // integer_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline integer_pskel:: + integer_pskel () + : integer_impl_ (0) + { + } + + inline integer_pskel:: + integer_pskel (integer_pskel* impl, void*) + : simple_content (impl, 0), integer_impl_ (impl) + { + } +#endif + + // negative_integer_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline negative_integer_pskel:: + negative_integer_pskel () + : negative_integer_impl_ (0) + { + } + + inline negative_integer_pskel:: + negative_integer_pskel (negative_integer_pskel* impl, void*) + : simple_content (impl, 0), negative_integer_impl_ (impl) + { + } +#endif + + // non_positive_integer_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_positive_integer_pskel:: + non_positive_integer_pskel () + : non_positive_integer_impl_ (0) + { + } + + inline non_positive_integer_pskel:: + non_positive_integer_pskel (non_positive_integer_pskel* impl, void*) + : simple_content (impl, 0), non_positive_integer_impl_ (impl) + { + } +#endif + + // positive_integer_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline positive_integer_pskel:: + positive_integer_pskel () + : positive_integer_impl_ (0) + { + } + + inline positive_integer_pskel:: + positive_integer_pskel (positive_integer_pskel* impl, void*) + : simple_content (impl, 0), positive_integer_impl_ (impl) + { + } +#endif + + // non_negative_integer_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_negative_integer_pskel:: + non_negative_integer_pskel () + : non_negative_integer_impl_ (0) + { + } + + inline non_negative_integer_pskel:: + non_negative_integer_pskel (non_negative_integer_pskel* impl, void*) + : simple_content (impl, 0), non_negative_integer_impl_ (impl) + { + } +#endif + + // float_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline float_pskel:: + float_pskel () + : float_impl_ (0) + { + } + + inline float_pskel:: + float_pskel (float_pskel* impl, void*) + : simple_content (impl, 0), float_impl_ (impl) + { + } +#endif + + // double_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline double_pskel:: + double_pskel () + : double_impl_ (0) + { + } + + inline double_pskel:: + double_pskel (double_pskel* impl, void*) + : simple_content (impl, 0), double_impl_ (impl) + { + } +#endif + + // decimal_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline decimal_pskel:: + decimal_pskel () + : decimal_impl_ (0) + { + } + + inline decimal_pskel:: + decimal_pskel (decimal_pskel* impl, void*) + : simple_content (impl, 0), decimal_impl_ (impl) + { + } +#endif + + // string_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline string_pskel:: + string_pskel () + : string_impl_ (0) + { + } + + inline string_pskel:: + string_pskel (string_pskel* impl, void*) + : simple_content (impl, 0), string_impl_ (impl) + { + } +#endif + + // normalized_string_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline normalized_string_pskel:: + normalized_string_pskel () + : normalized_string_impl_ (0) + { + } + + inline normalized_string_pskel:: + normalized_string_pskel (normalized_string_pskel* impl, void*) + : simple_content (impl, 0), normalized_string_impl_ (impl) + { + } +#endif + + // token_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline token_pskel:: + token_pskel () + : token_impl_ (0) + { + } + + inline token_pskel:: + token_pskel (token_pskel* impl, void*) + : simple_content (impl, 0), token_impl_ (impl) + { + } +#endif + + // name_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline name_pskel:: + name_pskel () + : name_impl_ (0) + { + } + + inline name_pskel:: + name_pskel (name_pskel* impl, void*) + : simple_content (impl, 0), name_impl_ (impl) + { + } +#endif + + // nmtoken_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtoken_pskel:: + nmtoken_pskel () + : nmtoken_impl_ (0) + { + } + + inline nmtoken_pskel:: + nmtoken_pskel (nmtoken_pskel* impl, void*) + : simple_content (impl, 0), nmtoken_impl_ (impl) + { + } +#endif + + // nmtokens_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtokens_pskel:: + nmtokens_pskel () + : nmtokens_impl_ (0) + { + } + + inline nmtokens_pskel:: + nmtokens_pskel (nmtokens_pskel* impl, void*) + : list_base (impl, 0), nmtokens_impl_ (impl) + { + } +#endif + + // ncname_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline ncname_pskel:: + ncname_pskel () + : ncname_impl_ (0) + { + } + + inline ncname_pskel:: + ncname_pskel (ncname_pskel* impl, void*) + : simple_content (impl, 0), ncname_impl_ (impl) + { + } +#endif + + // id_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline id_pskel:: + id_pskel () + : id_impl_ (0) + { + } + + inline id_pskel:: + id_pskel (id_pskel* impl, void*) + : simple_content (impl, 0), id_impl_ (impl) + { + } +#endif + + // idref_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idref_pskel:: + idref_pskel () + : idref_impl_ (0) + { + } + + inline idref_pskel:: + idref_pskel (idref_pskel* impl, void*) + : simple_content (impl, 0), idref_impl_ (impl) + { + } +#endif + + // idrefs_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idrefs_pskel:: + idrefs_pskel () + : idrefs_impl_ (0) + { + } + + inline idrefs_pskel:: + idrefs_pskel (idrefs_pskel* impl, void*) + : list_base (impl, 0), idrefs_impl_ (impl) + { + } +#endif + + // language_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline language_pskel:: + language_pskel () + : language_impl_ (0) + { + } + + inline language_pskel:: + language_pskel (language_pskel* impl, void*) + : simple_content (impl, 0), language_impl_ (impl) + { + } +#endif + + // uri_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline uri_pskel:: + uri_pskel () + : uri_impl_ (0) + { + } + + inline uri_pskel:: + uri_pskel (uri_pskel* impl, void*) + : simple_content (impl, 0), uri_impl_ (impl) + { + } +#endif + + // qname_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline qname_pskel:: + qname_pskel () + : qname_impl_ (0) + { + } + + inline qname_pskel:: + qname_pskel (qname_pskel* impl, void*) + : simple_content (impl, 0), qname_impl_ (impl) + { + } +#endif + + // base64_binary_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline base64_binary_pskel:: + base64_binary_pskel () + : base64_binary_impl_ (0) + { + } + + inline base64_binary_pskel:: + base64_binary_pskel (base64_binary_pskel* impl, void*) + : simple_content (impl, 0), base64_binary_impl_ (impl) + { + } +#endif + + // hex_binary_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline hex_binary_pskel:: + hex_binary_pskel () + : hex_binary_impl_ (0) + { + } + + inline hex_binary_pskel:: + hex_binary_pskel (hex_binary_pskel* impl, void*) + : simple_content (impl, 0), hex_binary_impl_ (impl) + { + } +#endif + + // gday_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gday_pskel:: + gday_pskel () + : gday_impl_ (0) + { + } + + inline gday_pskel:: + gday_pskel (gday_pskel* impl, void*) + : simple_content (impl, 0), gday_impl_ (impl) + { + } +#endif + + // gmonth_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_pskel:: + gmonth_pskel () + : gmonth_impl_ (0) + { + } + + inline gmonth_pskel:: + gmonth_pskel (gmonth_pskel* impl, void*) + : simple_content (impl, 0), gmonth_impl_ (impl) + { + } +#endif + + // gyear_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_pskel:: + gyear_pskel () + : gyear_impl_ (0) + { + } + + inline gyear_pskel:: + gyear_pskel (gyear_pskel* impl, void*) + : simple_content (impl, 0), gyear_impl_ (impl) + { + } +#endif + + // gmonth_day_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_day_pskel:: + gmonth_day_pskel () + : gmonth_day_impl_ (0) + { + } + + inline gmonth_day_pskel:: + gmonth_day_pskel (gmonth_day_pskel* impl, void*) + : simple_content (impl, 0), gmonth_day_impl_ (impl) + { + } +#endif + + // gyear_month_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_month_pskel:: + gyear_month_pskel () + : gyear_month_impl_ (0) + { + } + + inline gyear_month_pskel:: + gyear_month_pskel (gyear_month_pskel* impl, void*) + : simple_content (impl, 0), gyear_month_impl_ (impl) + { + } +#endif + + // date_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_pskel:: + date_pskel () + : date_impl_ (0) + { + } + + inline date_pskel:: + date_pskel (date_pskel* impl, void*) + : simple_content (impl, 0), date_impl_ (impl) + { + } +#endif + + // time_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline time_pskel:: + time_pskel () + : time_impl_ (0) + { + } + + inline time_pskel:: + time_pskel (time_pskel* impl, void*) + : simple_content (impl, 0), time_impl_ (impl) + { + } +#endif + + // date_time_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_time_pskel:: + date_time_pskel () + : date_time_impl_ (0) + { + } + + inline date_time_pskel:: + date_time_pskel (date_time_pskel* impl, void*) + : simple_content (impl, 0), date_time_impl_ (impl) + { + } +#endif + + // duration_pskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline duration_pskel:: + duration_pskel () + : duration_impl_ (0) + { + } + + inline duration_pskel:: + duration_pskel (duration_pskel* impl, void*) + : simple_content (impl, 0), duration_impl_ (impl) + { + } +#endif + } + } + } +} |