diff options
Diffstat (limited to 'libxsde/xsde/cxx/serializer/validating')
157 files changed, 10089 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/serializer/validating/any-type.hxx b/libxsde/xsde/cxx/serializer/validating/any-type.hxx new file mode 100644 index 0000000..ca80572 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/any-type.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_ANY_TYPE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ANY_TYPE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // any_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_type_simpl: virtual any_type_sskel +#else + struct any_type_simpl: any_type_sskel +#endif + { + }; + + // any_simple_type + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct any_simple_type_simpl: virtual any_simple_type_sskel +#else + struct any_simple_type_simpl: any_simple_type_sskel +#endif + { + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ANY_TYPE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx b/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx new file mode 100644 index 0000000..a649433 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx @@ -0,0 +1,166 @@ +// file : xsde/cxx/serializer/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/serializer/validating/base64-binary.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + base64_binary_simpl:: + ~base64_binary_simpl () + { + if (free_) + delete const_cast<buffer*> (value_); + } + + void base64_binary_simpl:: + pre (const buffer* value) + { + value_ = value; + } + + static const char base64_tab[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '/', '\0' + }; + + inline void + split_1 (char b, unsigned char& b1, unsigned char& b2) + { + unsigned char ub = static_cast<unsigned char> (b); + b1 = ub >> 2; + b2 = (ub & 0x3) << 4; + } + + inline void + split_2 (char b, unsigned char& b2, unsigned char& b3) + { + unsigned char ub = static_cast<unsigned char> (b); + b2 |= ub >> 4; + b3 = (ub & 0x0F) << 2; + } + + inline void + split_3 (char b, unsigned char& b3, unsigned char& b4) + { + unsigned char ub = static_cast<unsigned char> (b); + b3 |= ub >> 6; + b4 = ( ub & 0x3F ); + } + + void base64_binary_simpl:: + _serialize_content () + { + // Maximum 76 characters per line, 76/4 = 19 + // + const size_t quads_per_line = 19; + char buf[quads_per_line * 4 + 1]; + + if (size_t size = value_->size ()) + { + const char* data = value_->data (); + size_t quads = (size + 2) / 3; + + // Process all quadruplets except the last, one line at a time. + // + size_t i = 0; + size_t j = 0; + unsigned char b1, b2, b3, b4; + + for (; j < (quads - 1);) + { + for (; i < quads_per_line && j < (quads - 1); ++i, ++j) + { + split_1 (*data++, b1, b2); + split_2 (*data++, b2, b3); + split_3 (*data++, b3, b4); + + buf[i * 4] = base64_tab[b1]; + buf[i * 4 + 1] = base64_tab[b2]; + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = base64_tab[b4]; + } + + if (i == quads_per_line) + { + buf[i * 4] = '\n'; + +#ifdef XSDE_EXCEPTIONS + _characters (buf, i * 4 + 1); +#else + if (!_characters (buf, i * 4 + 1)) + break; +#endif + i = 0; + } + } + +#ifndef XSDE_EXCEPTIONS + if (j == (quads - 1)) + { +#endif + // Process last quadruplet. The first byte is always present. + // + split_1 (*data++, b1, b2); + buf[i * 4] = base64_tab[b1]; + + if (data != value_->end ()) + { + // Second byte is present. + // + split_2 (*data++, b2, b3); + buf[i * 4 + 1] = base64_tab[b2]; + + if(data != value_->end ()) + { + // Third byte is present. + // + split_3 (*data++, b3, b4); + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = base64_tab[b4]; + } + else + { + buf[i * 4 + 2] = base64_tab[b3]; + buf[i * 4 + 3] = '='; + } + } + else + { + buf[i * 4 + 1] = base64_tab[b2]; + buf[i * 4 + 2] = '='; + buf[i * 4 + 3] = '='; + } + + i++; + + buf[i * 4] = '\n'; + _characters (buf, i * 4 + 1); + +#ifndef XSDE_EXCEPTIONS + } +#endif + } + + if (free_) + { + delete const_cast<buffer*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.hxx b/libxsde/xsde/cxx/serializer/validating/base64-binary.hxx new file mode 100644 index 0000000..9b8b050 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_BASE64_BINARY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_BASE64_BINARY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct base64_binary_simpl: virtual base64_binary_sskel +#else + struct base64_binary_simpl: base64_binary_sskel +#endif + { + virtual + ~base64_binary_simpl (); + + base64_binary_simpl (bool free = false); + + virtual void + pre (const buffer*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const buffer* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/base64-binary.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_BASE64_BINARY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.ixx b/libxsde/xsde/cxx/serializer/validating/base64-binary.ixx new file mode 100644 index 0000000..5da3828 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/base64-binary.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 serializer + { + namespace validating + { + inline base64_binary_simpl:: + base64_binary_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/boolean.cxx b/libxsde/xsde/cxx/serializer/validating/boolean.cxx new file mode 100644 index 0000000..82e8ed5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/boolean.cxx @@ -0,0 +1,30 @@ +// file : xsde/cxx/serializer/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/serializer/validating/boolean.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void boolean_simpl:: + pre (bool value) + { + value_ = value; + } + + void boolean_simpl:: + _serialize_content () + { + _characters ((value_ ? "true" : "false"), (value_ ? 4 : 5)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/boolean.hxx b/libxsde/xsde/cxx/serializer/validating/boolean.hxx new file mode 100644 index 0000000..d6b698a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/boolean.hxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_BOOLEAN_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_BOOLEAN_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct boolean_simpl: virtual boolean_sskel +#else + struct boolean_simpl: boolean_sskel +#endif + { + virtual void + pre (bool); + + virtual void + _serialize_content (); + + protected: + bool value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_BOOLEAN_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/byte.cxx b/libxsde/xsde/cxx/serializer/validating/byte.cxx new file mode 100644 index 0000000..c5e5726 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/byte.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void byte_simpl:: + pre (signed char value) + { + value_ = value; + } + + void byte_simpl:: + _serialize_content () + { + // We only need strlen("-128") + 1 characters to hold all + // representations of signed byte. + // + char str[5]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 5, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 5) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_byte_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/byte.hxx b/libxsde/xsde/cxx/serializer/validating/byte.hxx new file mode 100644 index 0000000..be7e683 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/byte.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_BYTE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_BYTE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 8-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct byte_simpl: virtual byte_sskel +#else + struct byte_simpl: byte_sskel +#endif + { + virtual void + pre (signed char); + + virtual void + _serialize_content (); + + protected: + signed char value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_BYTE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/date-time.cxx b/libxsde/xsde/cxx/serializer/validating/date-time.cxx new file mode 100644 index 0000000..cacc6ea --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date-time.cxx @@ -0,0 +1,87 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/date-time.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void date_time_simpl:: + pre (const date_time& value) + { + value_ = value; + } + + void date_time_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM-DDThh:mm:ss.ssssss-hh:mm") + // + 1 characters to hold all representations of date_time. We + // know that the seconds part (represented as double) has + // default precision of 6. + // + char str[40]; + + int y = value_.year (); + unsigned short m = value_.month (); + unsigned short d = value_.day (); + + unsigned short h = value_.hours (); + unsigned short tm = value_.minutes (); + double s = value_.seconds (); + + if (y != 0 && m > 0 && m < 13 && d > 0 && d < 32 && + ((h < 24 && tm < 60 && s >= 0.0 && s < 60.0) || + (h == 24 && tm == 0 && s == 0.0)) && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 34, "%.4d-%.2u-%.2uT%.2u:%.2u:%09f", + y, m, d, h, tm, s); +#else + int n = sprintf (str, "%.4d-%.2u-%.2uT%.2u:%.2u:%09f", + y, m, d, h, tm, s); +#endif + if (n > 0 && n < 34) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_date_time_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_date_time_value); + } + else + _schema_error (schema_error::invalid_date_time_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/date-time.hxx b/libxsde/xsde/cxx/serializer/validating/date-time.hxx new file mode 100644 index 0000000..0cfcab1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date-time.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_DATE_TIME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DATE_TIME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct date_time_simpl: virtual date_time_sskel +#else + struct date_time_simpl: date_time_sskel +#endif + { + date_time_simpl (); + + virtual void + pre (const date_time&); + + virtual void + _serialize_content (); + + protected: + date_time value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/date-time.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DATE_TIME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/date-time.ixx b/libxsde/xsde/cxx/serializer/validating/date-time.ixx new file mode 100644 index 0000000..e5e5813 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date-time.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/date-time.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 serializer + { + namespace validating + { + inline date_time_simpl:: + date_time_simpl () + : value_ (1, 0, 0, 0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/date.cxx b/libxsde/xsde/cxx/serializer/validating/date.cxx new file mode 100644 index 0000000..b374c1c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date.cxx @@ -0,0 +1,71 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/date.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void date_simpl:: + pre (const date& value) + { + value_ = value; + } + + void date_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM-DD+hh:mm") + 1 characters to + // hold all representations of date. + // + char str[24]; + + int y = value_.year (); + unsigned short m = value_.month (); + unsigned short d = value_.day (); + + if (y != 0 && m > 0 && m < 13 && d > 0 && d < 32 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 18, "%.4d-%.2u-%.2u", + value_.year (), value_.month (), value_.day ()); +#else + int n = sprintf (str, "%.4d-%.2u-%.2u", + value_.year (), value_.month (), value_.day ()); +#endif + if (n > 0 && n < 18) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_date_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_date_value); + } + else + _schema_error (schema_error::invalid_date_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/date.hxx b/libxsde/xsde/cxx/serializer/validating/date.hxx new file mode 100644 index 0000000..caaf4a5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_DATE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DATE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct date_simpl: virtual date_sskel +#else + struct date_simpl: date_sskel +#endif + { + date_simpl (); + + virtual void + pre (const date&); + + virtual void + _serialize_content (); + + protected: + date value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/date.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DATE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/date.ixx b/libxsde/xsde/cxx/serializer/validating/date.ixx new file mode 100644 index 0000000..f5c3706 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/date.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/date.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 serializer + { + namespace validating + { + inline date_simpl:: + date_simpl () + : value_ (1, 1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.cxx b/libxsde/xsde/cxx/serializer/validating/decimal.cxx new file mode 100644 index 0000000..7383025 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/decimal.cxx @@ -0,0 +1,66 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/decimal.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void decimal_simpl:: + pre (double value) + { + value_ = value; + } + + void decimal_simpl:: + _serialize_content () + { + // Assume double values cannot be longer than 127 characters. + // + char str[128]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, "%.*f", + static_cast<int> (precision_), value_); +#else + int n = sprintf (str, "%.*f", + static_cast<int> (precision_), value_); +#endif + if (n > 0 && n < 128) + { + // For decimal, NaN and INF are not allowed. + // + int i = (str[0] == '-' ? 1 : 0); + if ((str[i] == 'i' && str[i + 1] == 'n' && str[i + 2] == 'f') || + (str[i] == 'n' && str[i + 1] == 'a' && str[i + 2] == 'n')) + { + _schema_error (schema_error::invalid_decimal_value); + return; + } + + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_decimal_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.hxx b/libxsde/xsde/cxx/serializer/validating/decimal.hxx new file mode 100644 index 0000000..af2c0f1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/decimal.hxx @@ -0,0 +1,50 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_DECIMAL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DECIMAL_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct decimal_simpl: virtual decimal_sskel +#else + struct decimal_simpl: decimal_sskel +#endif + { +#ifdef DBL_DIG + decimal_simpl (unsigned int precision = DBL_DIG); +#else + decimal_simpl (unsigned int precision = 15) +#endif + + virtual void + pre (double); + + virtual void + _serialize_content (); + + protected: + unsigned int precision_; + double value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/decimal.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DECIMAL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.ixx b/libxsde/xsde/cxx/serializer/validating/decimal.ixx new file mode 100644 index 0000000..803253d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/decimal.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/decimal.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 serializer + { + namespace validating + { + inline decimal_simpl:: + decimal_simpl (unsigned int p) + : precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/double.cxx b/libxsde/xsde/cxx/serializer/validating/double.cxx new file mode 100644 index 0000000..526eba0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/double.cxx @@ -0,0 +1,105 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/double.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void double_simpl:: + pre (double value) + { + value_ = value; + } + + void double_simpl:: + _serialize_content () + { + // Assume double values cannot be longer than 127 characters. + // + char str[128]; + + const char* fmt = 0; + + switch (notation_) + { + case notation_auto: + { + fmt = "%.*g"; + break; + } + case notation_fixed: + { + fmt = "%.*f"; + break; + } + case notation_scientific: + { + fmt = "%.*e"; + break; + } + } + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, fmt, precision_, value_); +#else + int n = sprintf (str, fmt, precision_, value_); +#endif + if (n > 0 && n < 128) + { + if (str[0] == '-') + { + if (str[1] == 'n' && str[2] == 'a' && str[3] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[1] == 'i' && str[2] == 'n' && str[3] == 'f') + { + _characters ("-INF", 4); + return; + } + } + else + { + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[0] == 'i' && str[1] == 'n' && str[2] == 'f') + { + _characters ("INF", 3); + return; + } + } + + if (notation_ == notation_fixed) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_double_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/double.hxx b/libxsde/xsde/cxx/serializer/validating/double.hxx new file mode 100644 index 0000000..e7d1324 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/double.hxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_DOUBLE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DOUBLE_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct double_simpl: virtual double_sskel +#else + struct double_simpl: double_sskel +#endif + { + enum notation + { + notation_auto, + notation_fixed, + notation_scientific + }; + +#ifdef DBL_DIG + double_simpl (notation = notation_auto, + unsigned int precision = DBL_DIG); +#else + double_simpl (notation = notation_auto, + unsigned int precision = 15) +#endif + + virtual void + pre (double); + + virtual void + _serialize_content (); + + protected: + notation notation_; + unsigned int precision_; + double value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/double.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DOUBLE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/double.ixx b/libxsde/xsde/cxx/serializer/validating/double.ixx new file mode 100644 index 0000000..8ae69e6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/double.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/double.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 serializer + { + namespace validating + { + inline double_simpl:: + double_simpl (notation n, unsigned int p) + : notation_ (n), precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/duration.cxx b/libxsde/xsde/cxx/serializer/validating/duration.cxx new file mode 100644 index 0000000..7187da5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/duration.cxx @@ -0,0 +1,195 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/duration.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void duration_simpl:: + pre (const duration& value) + { + value_ = value; + } + + void duration_simpl:: + _serialize_content () + { + if (value_.seconds () < 0.0) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + // duration := -PnYnMnDTnHnMnS + // + // The years, months, days, hours, and minutes components are + // represented as 32 unsigned integers with maximum string + // representation being strlen ("4294967295") = 10. + // + // We assume that the seconds part (double) cannot be longer + // than 128 chars. + // + // The total representation thus cannot exceed 10*5 + 128 + + // 9 + 1 = 188 characters. + // + char str[188]; + char* p = str; + + if (value_.negative ()) + *p++ = '-'; + + *p++ = 'P'; + + // years + // + // In case it is 0-duration, use the years field to handle + // this case. + // + if (value_.years () != 0 || + (value_.months () == 0 && + value_.days () == 0 && + value_.hours () == 0 && + value_.minutes () == 0 && + value_.seconds () == 0.0)) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.years ()); +#else + int n = sprintf (p, "%u", value_.years ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'Y'; + } + + // months + // + if (value_.months () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.months ()); +#else + int n = sprintf (p, "%u", value_.months ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'M'; + } + + // days + // + if (value_.days () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.days ()); +#else + int n = sprintf (p, "%u", value_.days ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'D'; + } + + // Figure out if we need the 'T' delimiter. + // + if (value_.hours () != 0 || + value_.minutes () != 0 || + value_.seconds () != 0.0) + *p++ = 'T'; + + // hours + // + if (value_.hours () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.hours ()); +#else + int n = sprintf (p, "%u", value_.hours ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'H'; + } + + // minutes + // + if (value_.minutes () != 0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 11, "%u", value_.minutes ()); +#else + int n = sprintf (p, "%u", value_.minutes ()); +#endif + if (n < 0 || n >= 11) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + p += n; + *p++ = 'M'; + } + + // seconds + // + if (value_.seconds () > 0.0) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (p, 128, "%f", value_.seconds ()); +#else + int n = sprintf (p, "%f", value_.seconds ()); +#endif + if (n < 0 || n >= 128) + { + _schema_error (schema_error::invalid_duration_value); + return; + } + + // Remove trailing '0' and '.' if necessary. + // + while (p[n - 1] == '0') + n--; + + if (p[n - 1] == '.') + n--; + + p += n; + *p++ = 'S'; + } + + _characters (str, static_cast<size_t> (p - str)); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/duration.hxx b/libxsde/xsde/cxx/serializer/validating/duration.hxx new file mode 100644 index 0000000..edc5473 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/duration.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_DURATION_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_DURATION_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct duration_simpl: virtual duration_sskel +#else + struct duration_simpl: duration_sskel +#endif + { + duration_simpl (); + + virtual void + pre (const duration&); + + virtual void + _serialize_content (); + + protected: + duration value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/duration.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_DURATION_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/duration.ixx b/libxsde/xsde/cxx/serializer/validating/duration.ixx new file mode 100644 index 0000000..334a288 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/duration.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/duration.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 serializer + { + namespace validating + { + inline duration_simpl:: + duration_simpl () + : value_ (false, 1, 0, 0, 0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/float.cxx b/libxsde/xsde/cxx/serializer/validating/float.cxx new file mode 100644 index 0000000..d9ee49c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/float.cxx @@ -0,0 +1,105 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/float.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void float_simpl:: + pre (float value) + { + value_ = value; + } + + void float_simpl:: + _serialize_content () + { + // Assume float values cannot be longer than 127 characters. + // + char str[128]; + + const char* fmt = 0; + + switch (notation_) + { + case notation_auto: + { + fmt = "%.*g"; + break; + } + case notation_fixed: + { + fmt = "%.*f"; + break; + } + case notation_scientific: + { + fmt = "%.*e"; + break; + } + } + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 128, fmt, precision_, value_); +#else + int n = sprintf (str, fmt, precision_, value_); +#endif + if (n > 0 && n < 128) + { + if (str[0] == '-') + { + if (str[1] == 'n' && str[2] == 'a' && str[3] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[1] == 'i' && str[2] == 'n' && str[3] == 'f') + { + _characters ("-INF", 4); + return; + } + } + else + { + if (str[0] == 'n' && str[1] == 'a' && str[2] == 'n') + { + _characters ("NaN", 3); + return; + } + else if (str[0] == 'i' && str[1] == 'n' && str[2] == 'f') + { + _characters ("INF", 3); + return; + } + } + + if (notation_ == notation_fixed) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_float_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/float.hxx b/libxsde/xsde/cxx/serializer/validating/float.hxx new file mode 100644 index 0000000..6a9b9df --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/float.hxx @@ -0,0 +1,60 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_FLOAT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_FLOAT_HXX + +#include <float.h> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct float_simpl: virtual float_sskel +#else + struct float_simpl: float_sskel +#endif + { + enum notation + { + notation_auto, + notation_fixed, + notation_scientific + }; + +#ifdef FLT_DIG + float_simpl (notation = notation_auto, + unsigned int precision = FLT_DIG); +#else + float_simpl (notation = notation_auto, + unsigned int precision = 6) +#endif + + virtual void + pre (float); + + virtual void + _serialize_content (); + + protected: + notation notation_; + unsigned int precision_; + float value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/float.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_FLOAT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/float.ixx b/libxsde/xsde/cxx/serializer/validating/float.ixx new file mode 100644 index 0000000..b240b6e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/float.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/float.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 serializer + { + namespace validating + { + inline float_simpl:: + float_simpl (notation n, unsigned int p) + : notation_ (n), precision_ (p) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gday.cxx b/libxsde/xsde/cxx/serializer/validating/gday.cxx new file mode 100644 index 0000000..363757b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gday.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gday.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gday_simpl:: + pre (const gday& value) + { + value_ = value; + } + + void gday_simpl:: + _serialize_content () + { + // We only need strlen("---DD+hh:mm") + 1 characters to hold all + // representations of gDay. + // + char str[12]; + + unsigned short d = value_.day (); + + if (d > 0 && d < 32 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 6, "---%.2u", d); +#else + int n = sprintf (str, "---%.2u", d); +#endif + if (n > 0 && n < 6) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gday_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gday_value); + } + else + _schema_error (schema_error::invalid_gday_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gday.hxx b/libxsde/xsde/cxx/serializer/validating/gday.hxx new file mode 100644 index 0000000..856229b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gday.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_GDAY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GDAY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gday_simpl: virtual gday_sskel +#else + struct gday_simpl: gday_sskel +#endif + { + gday_simpl (); + + virtual void + pre (const gday&); + + virtual void + _serialize_content (); + + protected: + gday value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gday.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GDAY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gday.ixx b/libxsde/xsde/cxx/serializer/validating/gday.ixx new file mode 100644 index 0000000..04e6261 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gday.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gday.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 serializer + { + namespace validating + { + inline gday_simpl:: + gday_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth-day.cxx b/libxsde/xsde/cxx/serializer/validating/gmonth-day.cxx new file mode 100644 index 0000000..fd8f461 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth-day.cxx @@ -0,0 +1,68 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gmonth-day.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gmonth_day_simpl:: + pre (const gmonth_day& value) + { + value_ = value; + } + + void gmonth_day_simpl:: + _serialize_content () + { + // We only need strlen("--MM-DD+hh:mm") + 1 characters to hold all + // representations of gMonthDay. + // + char str[14]; + + unsigned short m = value_.month (); + unsigned short d = value_.day (); + + if (m > 0 && m < 13 && d > 0 && d < 32 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 8, "--%.2u-%.2u", m, d); +#else + int n = sprintf (str, "--%.2u-%.2u", m, d); +#endif + if (n > 0 && n < 8) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gmonth_day_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gmonth_day_value); + } + else + _schema_error (schema_error::invalid_gmonth_day_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth-day.hxx b/libxsde/xsde/cxx/serializer/validating/gmonth-day.hxx new file mode 100644 index 0000000..60d5d11 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth-day.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_GMONTH_DAY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_DAY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gmonth_day_simpl: virtual gmonth_day_sskel +#else + struct gmonth_day_simpl: gmonth_day_sskel +#endif + { + gmonth_day_simpl (); + + virtual void + pre (const gmonth_day&); + + virtual void + _serialize_content (); + + protected: + gmonth_day value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gmonth-day.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_DAY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth-day.ixx b/libxsde/xsde/cxx/serializer/validating/gmonth-day.ixx new file mode 100644 index 0000000..23581ee --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth-day.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gmonth-day.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 serializer + { + namespace validating + { + inline gmonth_day_simpl:: + gmonth_day_simpl () + : value_ (1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth.cxx b/libxsde/xsde/cxx/serializer/validating/gmonth.cxx new file mode 100644 index 0000000..ad5cf27 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gmonth.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gmonth_simpl:: + pre (const gmonth& value) + { + value_ = value; + } + + void gmonth_simpl:: + _serialize_content () + { + // We only need strlen("--MM+hh:mm") + 1 characters to hold all + // representations of gMonth. + // + char str[11]; + + unsigned short m = value_.month (); + + if (m > 0 && m < 13 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 5, "--%.2u", m); +#else + int n = sprintf (str, "--%.2u", m); +#endif + if (n > 0 && n < 5) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gmonth_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gmonth_value); + } + else + _schema_error (schema_error::invalid_gmonth_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth.hxx b/libxsde/xsde/cxx/serializer/validating/gmonth.hxx new file mode 100644 index 0000000..10d9575 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_GMONTH_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gmonth_simpl: virtual gmonth_sskel +#else + struct gmonth_simpl: gmonth_sskel +#endif + { + gmonth_simpl (); + + virtual void + pre (const gmonth&); + + virtual void + _serialize_content (); + + protected: + gmonth value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gmonth.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GMONTH_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gmonth.ixx b/libxsde/xsde/cxx/serializer/validating/gmonth.ixx new file mode 100644 index 0000000..ae0a8dc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gmonth.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gmonth.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 serializer + { + namespace validating + { + inline gmonth_simpl:: + gmonth_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear-month.cxx b/libxsde/xsde/cxx/serializer/validating/gyear-month.cxx new file mode 100644 index 0000000..ab4ab15 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear-month.cxx @@ -0,0 +1,68 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gyear-month.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gyear_month_simpl:: + pre (const gyear_month& value) + { + value_ = value; + } + + void gyear_month_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649-MM+hh:mm") + 1 characters to + // hold all representations of gYearMonth. + // + char str[21]; + + int y = value_.year (); + unsigned short m = value_.month (); + + if (y != 0 && m > 0 && m < 13 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 15, "%.4d-%.2u", y, m); +#else + int n = sprintf (str, "%.4d-%.2u", y, m); +#endif + if (n > 0 && n < 15) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gyear_month_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gyear_month_value); + } + else + _schema_error (schema_error::invalid_gyear_month_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear-month.hxx b/libxsde/xsde/cxx/serializer/validating/gyear-month.hxx new file mode 100644 index 0000000..9a0107e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear-month.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_GYEAR_MONTH_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_MONTH_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gyear_month_simpl: virtual gyear_month_sskel +#else + struct gyear_month_simpl: gyear_month_sskel +#endif + { + gyear_month_simpl (); + + virtual void + pre (const gyear_month&); + + virtual void + _serialize_content (); + + protected: + gyear_month value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gyear-month.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_MONTH_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gyear-month.ixx b/libxsde/xsde/cxx/serializer/validating/gyear-month.ixx new file mode 100644 index 0000000..5aea7eb --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear-month.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gyear-month.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 serializer + { + namespace validating + { + inline gyear_month_simpl:: + gyear_month_simpl () + : value_ (1, 1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear.cxx b/libxsde/xsde/cxx/serializer/validating/gyear.cxx new file mode 100644 index 0000000..6b34506 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear.cxx @@ -0,0 +1,67 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/gyear.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void gyear_simpl:: + pre (const gyear& value) + { + value_ = value; + } + + void gyear_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649+hh:mm") + 1 characters to + // hold all representations of gYear. + // + char str[18]; + + int y = value_.year (); + + if (y != 0 && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 12, "%.4d", y); +#else + int n = sprintf (str, "%.4d", y); +#endif + if (n > 0 && n < 12) + { + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_gyear_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_gyear_value); + } + else + _schema_error (schema_error::invalid_gyear_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/gyear.hxx b/libxsde/xsde/cxx/serializer/validating/gyear.hxx new file mode 100644 index 0000000..0ae7e1a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_GYEAR_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct gyear_simpl: virtual gyear_sskel +#else + struct gyear_simpl: gyear_sskel +#endif + { + gyear_simpl (); + + virtual void + pre (const gyear&); + + virtual void + _serialize_content (); + + protected: + gyear value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/gyear.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_GYEAR_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/gyear.ixx b/libxsde/xsde/cxx/serializer/validating/gyear.ixx new file mode 100644 index 0000000..7502a6b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/gyear.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/gyear.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 serializer + { + namespace validating + { + inline gyear_simpl:: + gyear_simpl () + : value_ (1) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx b/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx new file mode 100644 index 0000000..0250e71 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx @@ -0,0 +1,70 @@ +// file : xsde/cxx/serializer/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/serializer/validating/hex-binary.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + hex_binary_simpl:: + ~hex_binary_simpl () + { + if (free_) + delete const_cast<buffer*> (value_); + } + + void hex_binary_simpl:: + pre (const buffer* value) + { + value_ = value; + } + + static const char hex_tab[] = "0123456789ABCDEF"; + + void hex_binary_simpl:: + _serialize_content () + { + char buf[512]; + + size_t size = value_->size (); + const char* data = value_->data (); + + // Covert the data in 256-byte chunks. + // + for (size_t j = 0; j < size;) + { + size_t i = 0; + + for (; i < 512 && j < size; ++j) + { + unsigned char byte = static_cast<unsigned char> (data[j]); + + buf[i++] = hex_tab[byte >> 4]; + buf[i++] = hex_tab[byte & 0x0F]; + } + +#ifdef XSDE_EXCEPTIONS + _characters (buf, i); +#else + if (!_characters (buf, i)) + break; +#endif + } + + if (free_) + { + delete const_cast<buffer*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.hxx b/libxsde/xsde/cxx/serializer/validating/hex-binary.hxx new file mode 100644 index 0000000..524d9a9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_HEX_BINARY_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_HEX_BINARY_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct hex_binary_simpl: virtual hex_binary_sskel +#else + struct hex_binary_simpl: hex_binary_sskel +#endif + { + virtual + ~hex_binary_simpl (); + + hex_binary_simpl (bool free = false); + + virtual void + pre (const buffer*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const buffer* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/hex-binary.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_HEX_BINARY_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.ixx b/libxsde/xsde/cxx/serializer/validating/hex-binary.ixx new file mode 100644 index 0000000..134d30a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/hex-binary.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 serializer + { + namespace validating + { + inline hex_binary_simpl:: + hex_binary_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/id-stl.cxx b/libxsde/xsde/cxx/serializer/validating/id-stl.cxx new file mode 100644 index 0000000..0166069 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/serializer/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/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/id-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void id_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void id_simpl:: + _serialize_content () + { + std::string tmp; + tmp.swap (value_); + + if (xml::valid_ncname (tmp.c_str (), tmp.size ())) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_id_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/id-stl.hxx b/libxsde/xsde/cxx/serializer/validating/id-stl.hxx new file mode 100644 index 0000000..f804eac --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_ID_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ID_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_simpl: virtual id_sskel +#else + struct id_simpl: id_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ID_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/id.cxx b/libxsde/xsde/cxx/serializer/validating/id.cxx new file mode 100644 index 0000000..2926ffe --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id.cxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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 <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/id.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + id_simpl:: + ~id_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void id_simpl:: + pre (const char* value) + { + value_ = value; + } + + void id_simpl:: + _serialize_content () + { + size_t n = strlen (value_); + + if (xml::valid_ncname (value_, n)) + _characters (value_, n); + else + _schema_error (schema_error::invalid_id_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/id.hxx b/libxsde/xsde/cxx/serializer/validating/id.hxx new file mode 100644 index 0000000..dac47f3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_ID_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_ID_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_simpl: virtual id_sskel +#else + struct id_simpl: id_sskel +#endif + { + virtual + ~id_simpl (); + + id_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/id.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_ID_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/id.ixx b/libxsde/xsde/cxx/serializer/validating/id.ixx new file mode 100644 index 0000000..d771919 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/id.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/id.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 serializer + { + namespace validating + { + inline id_simpl:: + id_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idref-stl.cxx b/libxsde/xsde/cxx/serializer/validating/idref-stl.cxx new file mode 100644 index 0000000..620b16f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/serializer/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/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void idref_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void idref_simpl:: + _serialize_content () + { + std::string tmp; + tmp.swap (value_); + + if (xml::valid_ncname (tmp.c_str (), tmp.size ())) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_idref_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idref-stl.hxx b/libxsde/xsde/cxx/serializer/validating/idref-stl.hxx new file mode 100644 index 0000000..e90443e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_IDREF_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREF_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_simpl: virtual idref_sskel +#else + struct idref_simpl: idref_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREF_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idref.cxx b/libxsde/xsde/cxx/serializer/validating/idref.cxx new file mode 100644 index 0000000..87d6c5c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref.cxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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 <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + idref_simpl:: + ~idref_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void idref_simpl:: + pre (const char* value) + { + value_ = value; + } + + void idref_simpl:: + _serialize_content () + { + size_t n = strlen (value_); + + if (xml::valid_ncname (value_, n)) + _characters (value_, n); + else + _schema_error (schema_error::invalid_idref_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idref.hxx b/libxsde/xsde/cxx/serializer/validating/idref.hxx new file mode 100644 index 0000000..b8d82ce --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_IDREF_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREF_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_simpl: virtual idref_sskel +#else + struct idref_simpl: idref_sskel +#endif + { + virtual + ~idref_simpl (); + + idref_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/idref.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREF_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idref.ixx b/libxsde/xsde/cxx/serializer/validating/idref.ixx new file mode 100644 index 0000000..34a6838 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idref.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/idref.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 serializer + { + namespace validating + { + inline idref_simpl:: + idref_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx new file mode 100644 index 0000000..bdcf937 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx @@ -0,0 +1,109 @@ +// file : xsde/cxx/serializer/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/serializer/validating/idrefs-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + idrefs_simpl:: + ~idrefs_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void idrefs_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void idrefs_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_idrefs_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void idrefs_simpl:: + _reset () + { + idrefs_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.hxx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.hxx new file mode 100644 index 0000000..03cd1da --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_IDREFS_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_STL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/idref-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_simpl: virtual idrefs_sskel +#else + struct idrefs_simpl: idrefs_sskel +#endif + { + virtual + ~idrefs_simpl (); + + idrefs_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + idref_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/idrefs-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.ixx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.ixx new file mode 100644 index 0000000..9c6e46c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/idrefs-stl.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 serializer + { + namespace validating + { + inline idrefs_simpl:: + idrefs_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.cxx b/libxsde/xsde/cxx/serializer/validating/idrefs.cxx new file mode 100644 index 0000000..e6548c4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.cxx @@ -0,0 +1,110 @@ +// file : xsde/cxx/serializer/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/serializer/validating/idrefs.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + idrefs_simpl:: + ~idrefs_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void idrefs_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void idrefs_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_idrefs_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void idrefs_simpl:: + _reset () + { + idrefs_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.hxx b/libxsde/xsde/cxx/serializer/validating/idrefs.hxx new file mode 100644 index 0000000..23386dd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_IDREFS_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/idref.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idrefs_simpl: virtual idrefs_sskel +#else + struct idrefs_simpl: idrefs_sskel +#endif + { + virtual + ~idrefs_simpl (); + + idrefs_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + idref_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/idrefs.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_IDREFS_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.ixx b/libxsde/xsde/cxx/serializer/validating/idrefs.ixx new file mode 100644 index 0000000..b077e58 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/idrefs.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 serializer + { + namespace validating + { + inline idrefs_simpl:: + idrefs_simpl (bool free) + : free_ (free), value_ (0), serializer_ (false) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map-load.hxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map-load.hxx new file mode 100644 index 0000000..abdcd43 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map-load.hxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/validating/inheritance-map-load.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_SERIALIZER_VALIDATING_INHERITANCE_MAP_LOAD_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_LOAD_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + size_t + serializer_imap_elements (); + + inline size_t + serializer_imap_buckets () + { + return XSDE_SERIALIZER_IMAP_BUCKETS; + } + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_LOAD_HXX + diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx new file mode 100644 index 0000000..94fdabc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx @@ -0,0 +1,111 @@ +// file : xsde/cxx/serializer/validating/inheritance-map.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 <string.h> // strcmp + +#ifndef XSDE_EXCEPTIONS +# include <assert.h> // assert +# include <stdlib.h> // exit +#endif + +#include <xsde/cxx/serializer/validating/inheritance-map.hxx> +#include <xsde/cxx/serializer/validating/inheritance-map-load.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + inheritance_map* inheritance_map_init::map = 0; + size_t inheritance_map_init::count = 0; + + bool inheritance_map:: + check (const char* derived, const char* base) const + { + if (strcmp (derived, base) == 0) + return true; + + const void* p = find (derived); + + if (p) + { + const char* b = *static_cast<const char* const*> (p); + return strcmp (base, b) == 0 ? true : check (b, base); + } + + return false; + } + + // inheritance_map_init + // + inheritance_map_init:: + inheritance_map_init () + { + if (count == 0) + { + map = new inheritance_map (XSDE_SERIALIZER_IMAP_BUCKETS); + +#ifndef XSDE_EXCEPTIONS + if (map == 0 || map->_error () != inheritance_map::error_none) + { + // This is static initialization so there is nothing we can do. + // The best thing is to fail fast. abort() would have probably + // been the better choice here but it is not available on some + // platforms (notably, WinCE). + // + assert (false); + exit (1); + } +#endif + } + + ++count; + } + + inheritance_map_init:: + ~inheritance_map_init () + { + if (--count == 0) + delete map; + } + + // inheritance_map_entry + // + inheritance_map_entry:: + inheritance_map_entry (const char* derived, const char* base) + { + inheritance_map& m = inheritance_map_instance (); + m.insert (derived, base); + +#ifndef XSDE_EXCEPTIONS + if (m._error () != inheritance_map::error_none) + { + // This is static initialization so there is nothing we can do. + // The best thing is to fail fast. abort() would have probably + // been the better choice here but it is not available on some + // platforms (notably, WinCE). + // + assert (false); + exit (1); + } +#endif + } + + // + // + size_t + serializer_imap_elements () + { + return inheritance_map_instance ().size (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.hxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.hxx new file mode 100644 index 0000000..051dbfc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.hxx @@ -0,0 +1,63 @@ +// file : xsde/cxx/serializer/validating/inheritance-map.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_SERIALIZER_VALIDATING_INHERITANCE_MAP_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> +#include <xsde/cxx/ro-string.hxx> +#include <xsde/cxx/hashmap.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + struct inheritance_map: hashmap + { + inheritance_map (size_t buckets); + + void + insert (const char* derived, const char* base); + + bool + check (const char* derived, const char* base) const; + }; + + + // Translation unit initializer. + // + struct inheritance_map_init + { + static inheritance_map* map; + static size_t count; + + inheritance_map_init (); + ~inheritance_map_init (); + }; + + inline inheritance_map& + inheritance_map_instance (); + + // Map entry initializer. + // + struct inheritance_map_entry + { + inheritance_map_entry (const char* derived, const char* base); + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/inheritance-map.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INHERITANCE_MAP_HXX + diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.ixx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.ixx new file mode 100644 index 0000000..2ae6fcf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.ixx @@ -0,0 +1,34 @@ +// file : xsde/cxx/serializer/validating/inheritance-map.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 serializer + { + namespace validating + { + inline inheritance_map:: + inheritance_map (size_t buckets) + : hashmap (buckets, sizeof (const char*)) + { + } + + inline void inheritance_map:: + insert (const char* derived, const char* base) + { + hashmap::insert (derived, &base); + } + + inline inheritance_map& + inheritance_map_instance () + { + return *inheritance_map_init::map; + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/int.cxx b/libxsde/xsde/cxx/serializer/validating/int.cxx new file mode 100644 index 0000000..780abbe --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/int.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void int_simpl:: + pre (int value) + { + value_ = value; + } + + void int_simpl:: + _serialize_content () + { + // We only need strlen("-2147483649") + 1 characters to hold all + // representations of int. + // + char str[12]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 12, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 12) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_int_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/int.hxx b/libxsde/xsde/cxx/serializer/validating/int.hxx new file mode 100644 index 0000000..6d798d6 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/int.hxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_INT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct int_simpl: virtual int_sskel +#else + struct int_simpl: int_sskel +#endif + { + virtual void + pre (int); + + virtual void + _serialize_content (); + + protected: + int value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/integer.cxx b/libxsde/xsde/cxx/serializer/validating/integer.cxx new file mode 100644 index 0000000..8df6c55 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/integer.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void integer_simpl:: + pre (long value) + { + value_ = value; + } + + void integer_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/integer.hxx b/libxsde/xsde/cxx/serializer/validating/integer.hxx new file mode 100644 index 0000000..ada9796 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct integer_simpl: virtual integer_sskel +#else + struct integer_simpl: integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/language-stl.cxx b/libxsde/xsde/cxx/serializer/validating/language-stl.cxx new file mode 100644 index 0000000..cd4e1d2 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language-stl.cxx @@ -0,0 +1,73 @@ +// file : xsde/cxx/serializer/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/serializer/validating/language-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void language_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void language_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + bool ok = true; + const char* s = tmp.c_str (); + + // language := ALPHA{1,8} *(-(ALPHA | DIGIT){1,8}) + // + for (size_t tag = 0; ; ++tag) + { + size_t n = 0; + + for (; *s != '\0' && n < 8; ++n, ++s) + { + char c = *s; + + if (!((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (tag != 0 && c >= '0' && c <= '9'))) + break; + } + + if (n == 0) + { + ok = false; + break; + } + + if (*s == '\0') + break; + + if (*s++ != '-') + { + ok = false; + break; + } + } + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_language_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/language-stl.hxx b/libxsde/xsde/cxx/serializer/validating/language-stl.hxx new file mode 100644 index 0000000..2216bff --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_LANGUAGE_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_simpl: virtual language_sskel +#else + struct language_simpl: language_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/language.cxx b/libxsde/xsde/cxx/serializer/validating/language.cxx new file mode 100644 index 0000000..14f69fc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language.cxx @@ -0,0 +1,81 @@ +// file : xsde/cxx/serializer/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/serializer/validating/language.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + language_simpl:: + ~language_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void language_simpl:: + pre (const char* value) + { + value_ = value; + } + + void language_simpl:: + _serialize_content () + { + bool ok = true; + const char* s = value_; + + // language := ALPHA{1,8} *(-(ALPHA | DIGIT){1,8}) + // + for (size_t tag = 0; ; ++tag) + { + size_t n = 0; + + for (; *s != '\0' && n < 8; ++n, ++s) + { + char c = *s; + + if (!((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (tag != 0 && c >= '0' && c <= '9'))) + break; + } + + if (n == 0) + { + ok = false; + break; + } + + if (*s == '\0') + break; + + if (*s++ != '-') + { + ok = false; + break; + } + } + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_language_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/language.hxx b/libxsde/xsde/cxx/serializer/validating/language.hxx new file mode 100644 index 0000000..708a5b0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_LANGUAGE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_simpl: virtual language_sskel +#else + struct language_simpl: language_sskel +#endif + { + virtual + ~language_simpl (); + + language_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/language.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LANGUAGE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/language.ixx b/libxsde/xsde/cxx/serializer/validating/language.ixx new file mode 100644 index 0000000..3385220 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/language.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/language.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 serializer + { + namespace validating + { + inline language_simpl:: + language_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/long-long.cxx b/libxsde/xsde/cxx/serializer/validating/long-long.cxx new file mode 100644 index 0000000..2773ec7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long-long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void long_simpl:: + pre (long long value) + { + value_ = value; + } + + void long_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of long long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lld", value_); +#else + int n = sprintf (str, "%lld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/long-long.hxx b/libxsde/xsde/cxx/serializer/validating/long-long.hxx new file mode 100644 index 0000000..97e14d1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_LONG_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LONG_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 64-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_simpl: virtual long_sskel +#else + struct long_simpl: long_sskel +#endif + { + virtual void + pre (long long); + + virtual void + _serialize_content (); + + protected: + long long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/long.cxx b/libxsde/xsde/cxx/serializer/validating/long.cxx new file mode 100644 index 0000000..574a22e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void long_simpl:: + pre (long value) + { + value_ = value; + } + + void long_simpl:: + _serialize_content () + { + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/long.hxx b/libxsde/xsde/cxx/serializer/validating/long.hxx new file mode 100644 index 0000000..7ffadc7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct long_simpl: virtual long_sskel +#else + struct long_simpl: long_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/name-stl.cxx b/libxsde/xsde/cxx/serializer/validating/name-stl.cxx new file mode 100644 index 0000000..e80bf9b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name-stl.cxx @@ -0,0 +1,62 @@ +// file : xsde/cxx/serializer/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/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/name-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void name_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void name_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + const char* s = tmp.c_str (); + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + if (ok) + { + // First character. + // + unsigned char c = static_cast<unsigned char> (*s); + + ok = c >= 0x80 || (xml::char_table[c] & xml::name_first_char_mask); + + for (++s; ok && *s != '\0'; ++s) + { + c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + } + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_name_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/name-stl.hxx b/libxsde/xsde/cxx/serializer/validating/name-stl.hxx new file mode 100644 index 0000000..8e67a28 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NAME_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NAME_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_simpl: virtual name_sskel +#else + struct name_simpl: name_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/name.cxx b/libxsde/xsde/cxx/serializer/validating/name.cxx new file mode 100644 index 0000000..7c916d8 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name.cxx @@ -0,0 +1,70 @@ +// file : xsde/cxx/serializer/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/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/name.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + name_simpl:: + ~name_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void name_simpl:: + pre (const char* value) + { + value_ = value; + } + + void name_simpl:: + _serialize_content () + { + const char* s = value_; + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + if (ok) + { + // First character. + // + unsigned char c = static_cast<unsigned char> (*s); + + ok = c >= 0x80 || (xml::char_table[c] & xml::name_first_char_mask); + + for (++s; ok && *s != '\0'; ++s) + { + c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + } + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_name_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/name.hxx b/libxsde/xsde/cxx/serializer/validating/name.hxx new file mode 100644 index 0000000..3c4fe2e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NAME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NAME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_simpl: virtual name_sskel +#else + struct name_simpl: name_sskel +#endif + { + virtual + ~name_simpl (); + + name_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/name.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NAME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/name.ixx b/libxsde/xsde/cxx/serializer/validating/name.ixx new file mode 100644 index 0000000..84fbdf3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/name.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/name.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 serializer + { + namespace validating + { + inline name_simpl:: + name_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/ncname-stl.cxx b/libxsde/xsde/cxx/serializer/validating/ncname-stl.cxx new file mode 100644 index 0000000..4dec901 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname-stl.cxx @@ -0,0 +1,38 @@ +// file : xsde/cxx/serializer/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/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/ncname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void ncname_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void ncname_simpl:: + _serialize_content () + { + std::string tmp; + tmp.swap (value_); + + if (xml::valid_ncname (tmp.c_str (), tmp.size ())) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_ncname_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/ncname-stl.hxx b/libxsde/xsde/cxx/serializer/validating/ncname-stl.hxx new file mode 100644 index 0000000..f9bd61d --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NCNAME_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_simpl: virtual ncname_sskel +#else + struct ncname_simpl: ncname_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.cxx b/libxsde/xsde/cxx/serializer/validating/ncname.cxx new file mode 100644 index 0000000..9f74a59 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname.cxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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 <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/ncname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + ncname_simpl:: + ~ncname_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void ncname_simpl:: + pre (const char* value) + { + value_ = value; + } + + void ncname_simpl:: + _serialize_content () + { + size_t n = strlen (value_); + + if (xml::valid_ncname (value_, n)) + _characters (value_, n); + else + _schema_error (schema_error::invalid_ncname_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.hxx b/libxsde/xsde/cxx/serializer/validating/ncname.hxx new file mode 100644 index 0000000..baafaa4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NCNAME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_simpl: virtual ncname_sskel +#else + struct ncname_simpl: ncname_sskel +#endif + { + virtual + ~ncname_simpl (); + + ncname_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/ncname.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NCNAME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.ixx b/libxsde/xsde/cxx/serializer/validating/ncname.ixx new file mode 100644 index 0000000..5d6bf02 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/ncname.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/ncname.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 serializer + { + namespace validating + { + inline ncname_simpl:: + ncname_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx b/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx new file mode 100644 index 0000000..bb41770 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void negative_integer_simpl:: + pre (long value) + { + value_ = value; + } + + void negative_integer_simpl:: + _serialize_content () + { + if (value_ >= 0) + { + _schema_error (schema_error::invalid_negative_integer_value); + return; + } + + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_negative_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/negative-integer.hxx b/libxsde/xsde/cxx/serializer/validating/negative-integer.hxx new file mode 100644 index 0000000..40fcd80 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/negative-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length negative integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct negative_integer_simpl: virtual negative_integer_sskel +#else + struct negative_integer_simpl: negative_integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.cxx b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.cxx new file mode 100644 index 0000000..c0cf793 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.cxx @@ -0,0 +1,53 @@ +// file : xsde/cxx/serializer/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/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void nmtoken_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void nmtoken_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + const char* s = tmp.c_str (); + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + for (; ok && *s != '\0'; ++s) + { + unsigned char c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_nmtoken_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.hxx b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.hxx new file mode 100644 index 0000000..3de2784 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NMTOKEN_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_simpl: virtual nmtoken_sskel +#else + struct nmtoken_simpl: nmtoken_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx b/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx new file mode 100644 index 0000000..2563023 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx @@ -0,0 +1,61 @@ +// file : xsde/cxx/serializer/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/xml/char-table.hxx> + +#include <xsde/cxx/serializer/validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + nmtoken_simpl:: + ~nmtoken_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void nmtoken_simpl:: + pre (const char* value) + { + value_ = value; + } + + void nmtoken_simpl:: + _serialize_content () + { + const char* s = value_; + bool ok = (*s != '\0'); + + // For now we are only checking the US-ASCII characters. + // + for (; ok && *s != '\0'; ++s) + { + unsigned char c = static_cast<unsigned char> (*s); + + if (c < 0x80 && !(xml::char_table[c] & xml::name_char_mask)) + ok = false; + } + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_nmtoken_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.hxx b/libxsde/xsde/cxx/serializer/validating/nmtoken.hxx new file mode 100644 index 0000000..7951384 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NMTOKEN_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_simpl: virtual nmtoken_sskel +#else + struct nmtoken_simpl: nmtoken_sskel +#endif + { + virtual + ~nmtoken_simpl (); + + nmtoken_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/nmtoken.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKEN_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.ixx b/libxsde/xsde/cxx/serializer/validating/nmtoken.ixx new file mode 100644 index 0000000..4559310 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/nmtoken.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 serializer + { + namespace validating + { + inline nmtoken_simpl:: + nmtoken_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx new file mode 100644 index 0000000..6607177 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx @@ -0,0 +1,109 @@ +// file : xsde/cxx/serializer/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/serializer/validating/nmtokens-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + nmtokens_simpl:: + ~nmtokens_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void nmtokens_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void nmtokens_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_nmtokens_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void nmtokens_simpl:: + _reset () + { + nmtokens_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.hxx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.hxx new file mode 100644 index 0000000..aab3fae --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NMTOKENS_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_STL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/nmtoken-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_simpl: virtual nmtokens_sskel +#else + struct nmtokens_simpl: nmtokens_sskel +#endif + { + virtual + ~nmtokens_simpl (); + + nmtokens_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + nmtoken_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/nmtokens-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.ixx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.ixx new file mode 100644 index 0000000..988c9cd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/nmtokens-stl.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 serializer + { + namespace validating + { + inline nmtokens_simpl:: + nmtokens_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx b/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx new file mode 100644 index 0000000..74e111b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx @@ -0,0 +1,110 @@ +// file : xsde/cxx/serializer/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/serializer/validating/nmtokens.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + nmtokens_simpl:: + ~nmtokens_simpl () + { + if (free_) + delete const_cast<string_sequence*> (value_); + } + + void nmtokens_simpl:: + pre (const string_sequence* value) + { + value_ = value; + } + + void nmtokens_simpl:: + _serialize_content () + { + // Should have at least one element. + // + if (!value_->empty ()) + { + bool first = true; + context& ctx = _context (); + + for (string_sequence::const_iterator i (value_->begin ()), + e (value_->end ()); i != e; ++i) + { + serializer_.pre (*i); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + + if (!first) + { +#ifdef XSDE_EXCEPTIONS + _characters (" ", 1); +#else + if (!_characters (" ", 1)) + break; +#endif + } + else + first = false; + + serializer_._pre_impl (ctx); + + if (ctx.error_type ()) + break; + + serializer_._serialize_content (); + + if (ctx.error_type ()) + break; + + serializer_._post_impl (); + + if (ctx.error_type ()) + break; + + serializer_.post (); + +#ifndef XSDE_EXCEPTIONS + if (serializer_._error_type ()) + serializer_._copy_error (ctx); + + if (ctx.error_type ()) + break; +#endif + } + } + else + _schema_error (schema_error::invalid_nmtokens_value); + + if (free_) + { + delete const_cast<string_sequence*> (value_); + value_ = 0; + } + } + + void nmtokens_simpl:: + _reset () + { + nmtokens_sskel::_reset (); + serializer_._reset (); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.hxx b/libxsde/xsde/cxx/serializer/validating/nmtokens.hxx new file mode 100644 index 0000000..525ab13 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.hxx @@ -0,0 +1,52 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NMTOKENS_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> +#include <xsde/cxx/serializer/validating/nmtoken.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtokens_simpl: virtual nmtokens_sskel +#else + struct nmtokens_simpl: nmtokens_sskel +#endif + { + virtual + ~nmtokens_simpl (); + + nmtokens_simpl (bool free = false); + + virtual void + pre (const string_sequence*); + + virtual void + _serialize_content (); + + virtual void + _reset (); + + protected: + bool free_; + const string_sequence* value_; + nmtoken_simpl serializer_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/nmtokens.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NMTOKENS_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.ixx b/libxsde/xsde/cxx/serializer/validating/nmtokens.ixx new file mode 100644 index 0000000..0526e30 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/nmtokens.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 serializer + { + namespace validating + { + inline nmtokens_simpl:: + nmtokens_simpl (bool free) + : free_ (free), value_ (0), serializer_ (false) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx new file mode 100644 index 0000000..87a6e22 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/non-negative-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void non_negative_integer_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void non_negative_integer_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_non_negative_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/non-negative-integer.hxx b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.hxx new file mode 100644 index 0000000..8d5b769 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NON_NEGATIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NON_NEGATIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length non-negative integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_negative_integer_simpl: virtual non_negative_integer_sskel +#else + struct non_negative_integer_simpl: non_negative_integer_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NON_NEGATIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx new file mode 100644 index 0000000..bbd2854 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/non-positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void non_positive_integer_simpl:: + pre (long value) + { + value_ = value; + } + + void non_positive_integer_simpl:: + _serialize_content () + { + if (value_ > 0) + { + _schema_error (schema_error::invalid_non_positive_integer_value); + return; + } + + // We only need strlen("-9223372036854775808") + 1 characters to + // hold all representations of (possibly 64-bit) long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%ld", value_); +#else + int n = sprintf (str, "%ld", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_non_positive_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/non-positive-integer.hxx b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.hxx new file mode 100644 index 0000000..9defbba --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NON_POSITIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NON_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length non-positive integer. Mapped to long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct non_positive_integer_simpl: virtual non_positive_integer_sskel +#else + struct non_positive_integer_simpl: non_positive_integer_sskel +#endif + { + virtual void + pre (long); + + virtual void + _serialize_content (); + + protected: + long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NON_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.cxx b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.cxx new file mode 100644 index 0000000..7c945da --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.cxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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/serializer/validating/normalized-string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void normalized_string_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void normalized_string_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + const char* s = tmp.c_str (); + + for (; *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09) + break; + } + + if (*s == '\0') + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_normalized_string_value); + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.hxx b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.hxx new file mode 100644 index 0000000..98ae359 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NORMALIZED_STRING_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_simpl: virtual normalized_string_sskel +#else + struct normalized_string_simpl: normalized_string_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx b/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx new file mode 100644 index 0000000..1e29376 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx @@ -0,0 +1,55 @@ +// file : xsde/cxx/serializer/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/serializer/validating/normalized-string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + normalized_string_simpl:: + ~normalized_string_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void normalized_string_simpl:: + pre (const char* value) + { + value_ = value; + } + + void normalized_string_simpl:: + _serialize_content () + { + const char* s = value_; + + for (; *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09) + break; + } + + if (*s == '\0') + _characters (value_); + else + _schema_error (schema_error::invalid_normalized_string_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} + diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.hxx b/libxsde/xsde/cxx/serializer/validating/normalized-string.hxx new file mode 100644 index 0000000..6496ab9 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_NORMALIZED_STRING_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_simpl: virtual normalized_string_sskel +#else + struct normalized_string_simpl: normalized_string_sskel +#endif + { + virtual + ~normalized_string_simpl (); + + normalized_string_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/normalized-string.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_NORMALIZED_STRING_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.ixx b/libxsde/xsde/cxx/serializer/validating/normalized-string.ixx new file mode 100644 index 0000000..dc9085f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/normalized-string.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 serializer + { + namespace validating + { + inline normalized_string_simpl:: + normalized_string_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx b/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx new file mode 100644 index 0000000..dbb83cd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx @@ -0,0 +1,51 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/positive-integer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void positive_integer_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void positive_integer_simpl:: + _serialize_content () + { + if (value_ == 0) + { + _schema_error (schema_error::invalid_positive_integer_value); + return; + } + + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_positive_integer_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/positive-integer.hxx b/libxsde/xsde/cxx/serializer/validating/positive-integer.hxx new file mode 100644 index 0000000..329145e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/positive-integer.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_POSITIVE_INTEGER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_POSITIVE_INTEGER_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Arbitrary-length positive integer. Mapped to unsigned long. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct positive_integer_simpl: virtual positive_integer_sskel +#else + struct positive_integer_simpl: positive_integer_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_POSITIVE_INTEGER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/qname-stl.cxx b/libxsde/xsde/cxx/serializer/validating/qname-stl.cxx new file mode 100644 index 0000000..0e48748 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname-stl.cxx @@ -0,0 +1,68 @@ +// file : xsde/cxx/serializer/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/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/qname-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void qname_simpl:: + pre (const qname& value) + { + value_ = value; + } + + void qname_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the qname. + // + qname tmp ("a"); + tmp.swap (value_); + + const char* ns = tmp.name ().c_str (); + size_t nn = tmp.name ().size (); + + if (!tmp.prefix ().empty ()) + { + const char* ps = tmp.prefix ().c_str (); + size_t pn = tmp.prefix ().size (); + + if (xml::valid_ncname (ps, pn) && xml::valid_ncname (ns, nn)) + { +#ifdef XSDE_EXCEPTIONS + _characters (ps, pn); + _characters (":", 1); + _characters (ns, nn); +#else + if (_characters (ps, pn)) + { + if (_characters (":", 1)) + _characters (ns, nn); + } +#endif + } + else + _schema_error (schema_error::invalid_qname_value); + } + else + { + if (xml::valid_ncname (ns, nn)) + _characters (ns, nn); + else + _schema_error (schema_error::invalid_qname_value); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/qname-stl.hxx b/libxsde/xsde/cxx/serializer/validating/qname-stl.hxx new file mode 100644 index 0000000..8d87a4b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname-stl.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_QNAME_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_QNAME_STL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct qname_simpl: virtual qname_sskel +#else + struct qname_simpl: qname_sskel +#endif + { + qname_simpl (); + + virtual void + pre (const qname&); + + virtual void + _serialize_content (); + + protected: + qname value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/qname-stl.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_QNAME_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/qname-stl.ixx b/libxsde/xsde/cxx/serializer/validating/qname-stl.ixx new file mode 100644 index 0000000..99edfdd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname-stl.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/qname-stl.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 serializer + { + namespace validating + { + inline qname_simpl:: + qname_simpl () + : value_ ("a") + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/qname.cxx b/libxsde/xsde/cxx/serializer/validating/qname.cxx new file mode 100644 index 0000000..b69eb54 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname.cxx @@ -0,0 +1,79 @@ +// file : xsde/cxx/serializer/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 <string.h> // strlen + +#include <xsde/cxx/xml/ncname.hxx> + +#include <xsde/cxx/serializer/validating/qname.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + qname_simpl:: + ~qname_simpl () + { + if (free_) + delete const_cast<qname*> (value_); + } + + void qname_simpl:: + pre (const qname* value) + { + value_ = value; + } + + void qname_simpl:: + _serialize_content () + { + const char* ns = value_->name (); + size_t nn = strlen (ns); + + const char* ps = value_->prefix (); + + if (ps != 0 && *ps != '\0') + { + size_t pn = strlen (ps); + + if (xml::valid_ncname (ps, pn) && xml::valid_ncname (ns, nn)) + { +#ifdef XSDE_EXCEPTIONS + _characters (ps, pn); + _characters (":", 1); + _characters (ns, nn); +#else + if (_characters (ps, pn)) + { + if (_characters (":", 1)) + _characters (ns, nn); + } +#endif + } + else + _schema_error (schema_error::invalid_qname_value); + } + else + { + if (xml::valid_ncname (ns, nn)) + _characters (ns, nn); + else + _schema_error (schema_error::invalid_qname_value); + } + + if (free_) + { + delete const_cast<qname*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/qname.hxx b/libxsde/xsde/cxx/serializer/validating/qname.hxx new file mode 100644 index 0000000..e9790f5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_QNAME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_QNAME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct qname_simpl: virtual qname_sskel +#else + struct qname_simpl: qname_sskel +#endif + { + virtual + ~qname_simpl (); + + qname_simpl (bool free = false); + + virtual void + pre (const qname*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const qname* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/qname.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_QNAME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/qname.ixx b/libxsde/xsde/cxx/serializer/validating/qname.ixx new file mode 100644 index 0000000..08d69d1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/qname.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/qname.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 serializer + { + namespace validating + { + inline qname_simpl:: + qname_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/serializer.cxx b/libxsde/xsde/cxx/serializer/validating/serializer.cxx new file mode 100644 index 0000000..280c09f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/serializer.cxx @@ -0,0 +1,29 @@ +// file : xsde/cxx/serializer/validating/serializer.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/serializer/validating/serializer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // simple_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + void simple_content:: + _serialize_content () + { + if (impl_) + impl_->_serialize_content (); + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/serializer.hxx b/libxsde/xsde/cxx/serializer/validating/serializer.hxx new file mode 100644 index 0000000..d8ba64c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/serializer.hxx @@ -0,0 +1,58 @@ +// file : xsde/cxx/serializer/validating/serializer.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_SERIALIZER_VALIDATING_SERIALIZER_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_SERIALIZER_HXX + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/serializer/elements.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + struct empty_content: serializer_base + { +#ifdef XSDE_REUSE_STYLE_TIEIN + empty_content (); + empty_content (empty_content* impl, void*); +#endif + }; + + // + // + struct simple_content: empty_content + { +#ifdef XSDE_REUSE_STYLE_TIEIN + virtual void + _serialize_content (); + + simple_content (); + simple_content (simple_content* impl, void*); +#endif + }; + + // + // + struct complex_content: empty_content + { +#ifdef XSDE_REUSE_STYLE_TIEIN + complex_content (); + complex_content (complex_content* impl, void*); +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/serializer.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_SERIALIZER_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/serializer.ixx b/libxsde/xsde/cxx/serializer/validating/serializer.ixx new file mode 100644 index 0000000..66b9ad7 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/serializer.ixx @@ -0,0 +1,61 @@ +// file : xsde/cxx/serializer/validating/serializer.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 serializer + { + namespace validating + { + // empty_content + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline empty_content:: + empty_content () + { + } + + inline empty_content:: + empty_content (empty_content* impl, void*) + : serializer_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 + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline complex_content:: + complex_content () + { + } + + inline complex_content:: + complex_content (complex_content* impl, void*) + : empty_content (impl, 0) + { + } +#endif + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/short.cxx b/libxsde/xsde/cxx/serializer/validating/short.cxx new file mode 100644 index 0000000..61e7132 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/short.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void short_simpl:: + pre (short value) + { + value_ = value; + } + + void short_simpl:: + _serialize_content () + { + // We only need strlen("-32768") + 1 characters to hold all + // representations of short. + // + char str[7]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 7, "%d", value_); +#else + int n = sprintf (str, "%d", value_); +#endif + if (n > 0 && n < 7) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_short_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/short.hxx b/libxsde/xsde/cxx/serializer/validating/short.hxx new file mode 100644 index 0000000..51da86f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/short.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_SHORT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_SHORT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 16-bit signed integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct short_simpl: virtual short_sskel +#else + struct short_simpl: short_sskel +#endif + { + virtual void + pre (short); + + virtual void + _serialize_content (); + + protected: + short value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_SHORT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/string-stl.cxx b/libxsde/xsde/cxx/serializer/validating/string-stl.cxx new file mode 100644 index 0000000..a70533f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string-stl.cxx @@ -0,0 +1,35 @@ +// file : xsde/cxx/serializer/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/serializer/validating/string-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void string_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void string_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/string-stl.hxx b/libxsde/xsde/cxx/serializer/validating/string-stl.hxx new file mode 100644 index 0000000..74f55cc --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_STRING_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_STRING_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct string_simpl: virtual string_sskel +#else + struct string_simpl: string_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_STRING_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/string.cxx b/libxsde/xsde/cxx/serializer/validating/string.cxx new file mode 100644 index 0000000..b8a4068 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string.cxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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/serializer/validating/string.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + string_simpl:: + ~string_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void string_simpl:: + pre (const char* value) + { + value_ = value; + } + + void string_simpl:: + _serialize_content () + { + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/string.hxx b/libxsde/xsde/cxx/serializer/validating/string.hxx new file mode 100644 index 0000000..5385355 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_STRING_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_STRING_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct string_simpl: virtual string_sskel +#else + struct string_simpl: string_sskel +#endif + { + virtual + ~string_simpl (); + + string_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/string.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_STRING_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/string.ixx b/libxsde/xsde/cxx/serializer/validating/string.ixx new file mode 100644 index 0000000..a23e517 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/string.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/string.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 serializer + { + namespace validating + { + inline string_simpl:: + string_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time-zone.cxx b/libxsde/xsde/cxx/serializer/validating/time-zone.cxx new file mode 100644 index 0000000..ae28d70 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time-zone.cxx @@ -0,0 +1,65 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/config.hxx> + +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + namespace bits + { + int + serialize_time_zone (char* s, const time_zone& z) + { + // time-zone := Z|(+|-)HH:MM + // + + short h = z.zone_hours (); + short m = z.zone_minutes (); + + if (h == 0 && m == 0) + { + *s = 'Z'; + return 1; + } + else + { + const char* fmt = "+%.2u:%.2u"; + + if (h < 0) + { + fmt = "-%.2u:%.2u"; + h = -h; + m = -m; + } + + if (h >= 0 && h <= 14 && m >= 0 && m <= 59) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (s, 7, fmt, h, m); +#else + int n = sprintf (s, fmt, h, m); +#endif + if (n > 0 && n < 7) + return n; + } + + return 0; + } + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time-zone.hxx b/libxsde/xsde/cxx/serializer/validating/time-zone.hxx new file mode 100644 index 0000000..27784cf --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time-zone.hxx @@ -0,0 +1,40 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_TIME_ZONE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TIME_ZONE_HXX + +#include <xsde/cxx/date-time.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + namespace bits + { + bool + valid_time_zone (const time_zone&); + + // Returns 0 in case of a failure and the number of + // characters written otherwise. The buffer should + // have space for at least 7 characters. Note that + // this function expects that the time zone was + // verified by valid_time_zone() above. + // + int + serialize_time_zone (char* s, const time_zone&); + } + } + } + } +} + +#include <xsde/cxx/serializer/validating/time-zone.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TIME_ZONE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/time-zone.ixx b/libxsde/xsde/cxx/serializer/validating/time-zone.ixx new file mode 100644 index 0000000..c6e80f4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time-zone.ixx @@ -0,0 +1,32 @@ +// file : xsde/cxx/serializer/validating/time-zone.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 serializer + { + namespace validating + { + namespace bits + { + inline bool + valid_time_zone (const time_zone& z) + { + short h = z.zone_hours (); + short m = z.zone_minutes (); + + unsigned short ah = h < 0 ? -h : h; + unsigned short am = m < 0 ? -m : m; + + return ((h <= 0 && m <= 0) || (h >= 0 && m >= 0)) && + ((ah < 14 && am < 60) || (ah == 14 && am == 0)); + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time.cxx b/libxsde/xsde/cxx/serializer/validating/time.cxx new file mode 100644 index 0000000..5ab5c22 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time.cxx @@ -0,0 +1,79 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/time.hxx> +#include <xsde/cxx/serializer/validating/time-zone.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void time_simpl:: + pre (const time& value) + { + value_ = value; + } + + void time_simpl:: + _serialize_content () + { + // We only need strlen("hh:mm:ss.ssssss-hh:mm") + 1 characters to + // hold all representations of time. We know that the seconds + // part (represented as double) has default precision of 6. + // + char str[22]; + + unsigned short h = value_.hours (); + unsigned short m = value_.minutes (); + double s = value_.seconds (); + + if (((h < 24 && m < 60 && s >= 0.0 && s < 60.0) || + (h == 24 && m == 0 && s == 0.0)) && + (!value_.zone_present () || bits::valid_time_zone (value_))) + { +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 16, "%.2u:%.2u:%09f", h, m, s); +#else + int n = sprintf (str, "%.2u:%.2u:%09f", h, m, s); +#endif + if (n > 0 && n < 16) + { + // Remove trailing '0' and '.' if necessary. + // + while (str[n - 1] == '0') + n--; + + if (str[n - 1] == '.') + n--; + + if (value_.zone_present ()) + { + if (int z = bits::serialize_time_zone (str + n, value_)) + n += z; + else + { + _schema_error (schema_error::invalid_time_value); + return; + } + } + + _characters (str, static_cast<size_t> (n)); + } + else + _schema_error (schema_error::invalid_time_value); + } + else + _schema_error (schema_error::invalid_time_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/time.hxx b/libxsde/xsde/cxx/serializer/validating/time.hxx new file mode 100644 index 0000000..1eedc7a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time.hxx @@ -0,0 +1,43 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_TIME_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TIME_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct time_simpl: virtual time_sskel +#else + struct time_simpl: time_sskel +#endif + { + time_simpl (); + + virtual void + pre (const time&); + + virtual void + _serialize_content (); + + protected: + time value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/time.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TIME_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/time.ixx b/libxsde/xsde/cxx/serializer/validating/time.ixx new file mode 100644 index 0000000..5262419 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/time.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/time.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 serializer + { + namespace validating + { + inline time_simpl:: + time_simpl () + : value_ (0, 0, 0.0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/token-stl.cxx b/libxsde/xsde/cxx/serializer/validating/token-stl.cxx new file mode 100644 index 0000000..0de2a54 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token-stl.cxx @@ -0,0 +1,58 @@ +// file : xsde/cxx/serializer/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/serializer/validating/token-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void token_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void token_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + bool ok = true; + const char* s = tmp.c_str (); + + // No leading whitespaces. + // + if (*s == 0x20) + ok = false; + + for (; ok && *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09 || + (*s == 0x20 && *(s + 1) == 0x20)) + ok = false; + } + + // No trailing whitespaces. + // + if (ok && s != tmp.c_str () && *(s - 1) == 0x20) + ok = false; + + if (ok) + _characters (tmp.c_str (), tmp.size ()); + else + _schema_error (schema_error::invalid_token_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/token-stl.hxx b/libxsde/xsde/cxx/serializer/validating/token-stl.hxx new file mode 100644 index 0000000..6de5f1e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_TOKEN_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_simpl: virtual token_sskel +#else + struct token_simpl: token_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/token.cxx b/libxsde/xsde/cxx/serializer/validating/token.cxx new file mode 100644 index 0000000..76bbce4 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token.cxx @@ -0,0 +1,66 @@ +// file : xsde/cxx/serializer/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/serializer/validating/token.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + token_simpl:: + ~token_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void token_simpl:: + pre (const char* value) + { + value_ = value; + } + + void token_simpl:: + _serialize_content () + { + bool ok = true; + const char* s = value_; + + // No leading whitespaces. + // + if (*s == 0x20) + ok = false; + + for (; ok && *s != '\0'; ++s) + { + if (*s == 0x0A || *s == 0x0D || *s == 0x09 || + (*s == 0x20 && *(s + 1) == 0x20)) + ok = false; + } + + // No trailing whitespaces. + // + if (ok && s != value_ && *(s - 1) == 0x20) + ok = false; + + if (ok) + _characters (value_); + else + _schema_error (schema_error::invalid_token_value); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/token.hxx b/libxsde/xsde/cxx/serializer/validating/token.hxx new file mode 100644 index 0000000..3b3c099 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_TOKEN_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_simpl: virtual token_sskel +#else + struct token_simpl: token_sskel +#endif + { + virtual + ~token_simpl (); + + token_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/token.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_TOKEN_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/token.ixx b/libxsde/xsde/cxx/serializer/validating/token.ixx new file mode 100644 index 0000000..30d119c --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/token.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/token.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 serializer + { + namespace validating + { + inline token_simpl:: + token_simpl (bool free) + : free_ (free) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx new file mode 100644 index 0000000..97b45f3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-byte.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_byte_simpl:: + pre (unsigned char value) + { + value_ = value; + } + + void unsigned_byte_simpl:: + _serialize_content () + { + // We only need strlen("256") + 1 characters to hold all + // representations of unsigned byte. + // + char str[4]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 4, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 4) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_byte_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-byte.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.hxx new file mode 100644 index 0000000..1afa8db --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_UNSIGNED_BYTE_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_BYTE_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 8-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_byte_simpl: virtual unsigned_byte_sskel +#else + struct unsigned_byte_simpl: unsigned_byte_sskel +#endif + { + virtual void + pre (unsigned char); + + virtual void + _serialize_content (); + + protected: + unsigned char value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_BYTE_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx new file mode 100644 index 0000000..14e478f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-int.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_int_simpl:: + pre (unsigned int value) + { + value_ = value; + } + + void unsigned_int_simpl:: + _serialize_content () + { + // We only need strlen("4294967295") + 1 characters to hold all + // representations of unsigned int. + // + char str[11]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 11, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 11) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_int_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-int.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-int.hxx new file mode 100644 index 0000000..fb103cd --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-int.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_UNSIGNED_INT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_INT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 32-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_int_simpl: virtual unsigned_int_sskel +#else + struct unsigned_int_simpl: unsigned_int_sskel +#endif + { + virtual void + pre (unsigned int); + + virtual void + _serialize_content (); + + protected: + unsigned int value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_INT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx new file mode 100644 index 0000000..3520b31 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-long-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_long_simpl:: + pre (unsigned long long value) + { + value_ = value; + } + + void unsigned_long_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of unsigned long long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%llu", value_); +#else + int n = sprintf (str, "%llu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.hxx new file mode 100644 index 0000000..8a746e3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_UNSIGNED_LONG_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 64-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_simpl: virtual unsigned_long_sskel +#else + struct unsigned_long_simpl: unsigned_long_sskel +#endif + { + virtual void + pre (unsigned long long); + + virtual void + _serialize_content (); + + protected: + unsigned long long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx new file mode 100644 index 0000000..b34d8aa --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-long.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_long_simpl:: + pre (unsigned long value) + { + value_ = value; + } + + void unsigned_long_simpl:: + _serialize_content () + { + // We only need strlen("18446744073709551615") + 1 characters to + // hold all representations of (possibly 64-bit) unsigned long. + // + char str[21]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 21, "%lu", value_); +#else + int n = sprintf (str, "%lu", value_); +#endif + if (n > 0 && n < 21) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_long_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long.hxx new file mode 100644 index 0000000..2659ef1 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_UNSIGNED_LONG_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // Fall-back implementation when 64 bit long long is not available. + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_long_simpl: virtual unsigned_long_sskel +#else + struct unsigned_long_simpl: unsigned_long_sskel +#endif + { + virtual void + pre (unsigned long); + + virtual void + _serialize_content (); + + protected: + unsigned long value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_LONG_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx new file mode 100644 index 0000000..d9bb308 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx @@ -0,0 +1,45 @@ +// file : xsde/cxx/serializer/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 <stdio.h> // sprintf/snprintf + +#include <xsde/cxx/serializer/validating/unsigned-short.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void unsigned_short_simpl:: + pre (unsigned short value) + { + value_ = value; + } + + void unsigned_short_simpl:: + _serialize_content () + { + // We only need strlen("65535") + 1 characters to hold all + // representations of short. + // + char str[6]; + +#ifdef XSDE_SNPRINTF + int n = snprintf (str, 6, "%u", value_); +#else + int n = sprintf (str, "%u", value_); +#endif + if (n > 0 && n < 6) + _characters (str, static_cast<size_t> (n)); + else + _schema_error (schema_error::invalid_unsigned_short_value); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-short.hxx b/libxsde/xsde/cxx/serializer/validating/unsigned-short.hxx new file mode 100644 index 0000000..902d75e --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-short.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_UNSIGNED_SHORT_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_SHORT_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // 16-bit unsigned integer + // +#ifdef XSDE_REUSE_STYLE_MIXIN + struct unsigned_short_simpl: virtual unsigned_short_sskel +#else + struct unsigned_short_simpl: unsigned_short_sskel +#endif + { + virtual void + pre (unsigned short); + + virtual void + _serialize_content (); + + protected: + unsigned short value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_UNSIGNED_SHORT_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/uri-stl.cxx b/libxsde/xsde/cxx/serializer/validating/uri-stl.cxx new file mode 100644 index 0000000..d22c992 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri-stl.cxx @@ -0,0 +1,39 @@ +// file : xsde/cxx/serializer/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/serializer/validating/uri-stl.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + void uri_simpl:: + pre (const std::string& value) + { + value_ = value; + } + + void uri_simpl:: + _serialize_content () + { + // Make sure we don't hold any references to the string. + // + std::string tmp; + tmp.swap (value_); + + // According to Datatypes 3.2.17 and RFC2396 pretty much anything + // can be a URI and conforming processors do not need to figure + // out and verify particular URI schemes. + // + _characters (tmp.c_str (), tmp.size ()); + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/uri-stl.hxx b/libxsde/xsde/cxx/serializer/validating/uri-stl.hxx new file mode 100644 index 0000000..4de5922 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri-stl.hxx @@ -0,0 +1,41 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_URI_STL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_URI_STL_HXX + +#include <string> + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct uri_simpl: virtual uri_sskel +#else + struct uri_simpl: uri_sskel +#endif + { + virtual void + pre (const std::string&); + + virtual void + _serialize_content (); + + protected: + std::string value_; + }; + } + } + } +} + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_URI_STL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/uri.cxx b/libxsde/xsde/cxx/serializer/validating/uri.cxx new file mode 100644 index 0000000..46148d3 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri.cxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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/serializer/validating/uri.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + uri_simpl:: + ~uri_simpl () + { + if (free_) + delete[] const_cast<char*> (value_); + } + + void uri_simpl:: + pre (const char* value) + { + value_ = value; + } + + void uri_simpl:: + _serialize_content () + { + // According to Datatypes 3.2.17 and RFC2396 pretty much anything + // can be a URI and conforming processors do not need to figure + // out and verify particular URI schemes. + // + _characters (value_); + + if (free_) + { + delete[] const_cast<char*> (value_); + value_ = 0; + } + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/uri.hxx b/libxsde/xsde/cxx/serializer/validating/uri.hxx new file mode 100644 index 0000000..63b502a --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri.hxx @@ -0,0 +1,47 @@ +// file : xsde/cxx/serializer/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_SERIALIZER_VALIDATING_URI_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_URI_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { +#ifdef XSDE_REUSE_STYLE_MIXIN + struct uri_simpl: virtual uri_sskel +#else + struct uri_simpl: uri_sskel +#endif + { + virtual + ~uri_simpl (); + + uri_simpl (bool free = false); + + virtual void + pre (const char*); + + virtual void + _serialize_content (); + + protected: + bool free_; + const char* value_; + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/uri.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_URI_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/uri.ixx b/libxsde/xsde/cxx/serializer/validating/uri.ixx new file mode 100644 index 0000000..6cbf6ae --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/uri.ixx @@ -0,0 +1,22 @@ +// file : xsde/cxx/serializer/validating/uri.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 serializer + { + namespace validating + { + inline uri_simpl:: + uri_simpl (bool free) + : free_ (free), value_ (0) + { + } + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx new file mode 100644 index 0000000..039722f --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-simpl.hxx @@ -0,0 +1,82 @@ +// file : xsde/cxx/serializer/validating/xml-schema-simpl.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_SERIALIZER_VALIDATING_XML_SCHEMA_SIMPL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SIMPL_HXX + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.hxx> + +#include <xsde/cxx/serializer/validating/any-type.hxx> +#include <xsde/cxx/serializer/validating/boolean.hxx> +#include <xsde/cxx/serializer/validating/byte.hxx> +#include <xsde/cxx/serializer/validating/unsigned-byte.hxx> +#include <xsde/cxx/serializer/validating/byte.hxx> +#include <xsde/cxx/serializer/validating/unsigned-byte.hxx> +#include <xsde/cxx/serializer/validating/short.hxx> +#include <xsde/cxx/serializer/validating/unsigned-short.hxx> +#include <xsde/cxx/serializer/validating/int.hxx> +#include <xsde/cxx/serializer/validating/unsigned-int.hxx> + +#ifdef XSDE_LONGLONG +# include <xsde/cxx/serializer/validating/long-long.hxx> +# include <xsde/cxx/serializer/validating/unsigned-long-long.hxx> +#else +# include <xsde/cxx/serializer/validating/long.hxx> +# include <xsde/cxx/serializer/validating/unsigned-long.hxx> +#endif + +#include <xsde/cxx/serializer/validating/integer.hxx> +#include <xsde/cxx/serializer/validating/negative-integer.hxx> +#include <xsde/cxx/serializer/validating/non-positive-integer.hxx> +#include <xsde/cxx/serializer/validating/positive-integer.hxx> +#include <xsde/cxx/serializer/validating/non-negative-integer.hxx> +#include <xsde/cxx/serializer/validating/float.hxx> +#include <xsde/cxx/serializer/validating/double.hxx> +#include <xsde/cxx/serializer/validating/decimal.hxx> + +#ifdef XSDE_STL +# include <xsde/cxx/serializer/validating/string-stl.hxx> +# include <xsde/cxx/serializer/validating/normalized-string-stl.hxx> +# include <xsde/cxx/serializer/validating/token-stl.hxx> +# include <xsde/cxx/serializer/validating/name-stl.hxx> +# include <xsde/cxx/serializer/validating/nmtoken-stl.hxx> +# include <xsde/cxx/serializer/validating/nmtokens-stl.hxx> +# include <xsde/cxx/serializer/validating/ncname-stl.hxx> +# include <xsde/cxx/serializer/validating/id-stl.hxx> +# include <xsde/cxx/serializer/validating/idref-stl.hxx> +# include <xsde/cxx/serializer/validating/idrefs-stl.hxx> +# include <xsde/cxx/serializer/validating/language-stl.hxx> +# include <xsde/cxx/serializer/validating/uri-stl.hxx> +# include <xsde/cxx/serializer/validating/qname-stl.hxx> +#else +# include <xsde/cxx/serializer/validating/string.hxx> +# include <xsde/cxx/serializer/validating/normalized-string.hxx> +# include <xsde/cxx/serializer/validating/token.hxx> +# include <xsde/cxx/serializer/validating/name.hxx> +# include <xsde/cxx/serializer/validating/nmtoken.hxx> +# include <xsde/cxx/serializer/validating/nmtokens.hxx> +# include <xsde/cxx/serializer/validating/ncname.hxx> +# include <xsde/cxx/serializer/validating/id.hxx> +# include <xsde/cxx/serializer/validating/idref.hxx> +# include <xsde/cxx/serializer/validating/idrefs.hxx> +# include <xsde/cxx/serializer/validating/language.hxx> +# include <xsde/cxx/serializer/validating/uri.hxx> +# include <xsde/cxx/serializer/validating/qname.hxx> +#endif + +#include <xsde/cxx/serializer/validating/base64-binary.hxx> +#include <xsde/cxx/serializer/validating/hex-binary.hxx> + +#include <xsde/cxx/serializer/validating/gday.hxx> +#include <xsde/cxx/serializer/validating/gmonth.hxx> +#include <xsde/cxx/serializer/validating/gyear.hxx> +#include <xsde/cxx/serializer/validating/gmonth-day.hxx> +#include <xsde/cxx/serializer/validating/gyear-month.hxx> +#include <xsde/cxx/serializer/validating/date.hxx> +#include <xsde/cxx/serializer/validating/time.hxx> +#include <xsde/cxx/serializer/validating/date-time.hxx> +#include <xsde/cxx/serializer/validating/duration.hxx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SIMPL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx new file mode 100644 index 0000000..a18141b --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.cxx @@ -0,0 +1,560 @@ +// file : xsde/cxx/serializer/validating/xml-schema-sskel.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/serializer/validating/xml-schema-sskel.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // any_type_sskel + // + void any_type_sskel:: + pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_type_impl_) + any_type_impl_->pre (); +#endif + } + + // any_simple_type_sskel + // + void any_simple_type_sskel:: + pre () + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (any_simple_type_impl_) + any_simple_type_impl_->pre (); +#endif + } + + // static/dynamic_type function implementations. + // +#ifdef XSDE_POLYMORPHIC + const char* any_type_sskel:: + _static_type () + { + return "anyType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_type_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* any_simple_type_sskel:: + _static_type () + { + return "anySimpleType http://www.w3.org/2001/XMLSchema"; + } + + const char* any_simple_type_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* boolean_sskel:: + _static_type () + { + return "boolean http://www.w3.org/2001/XMLSchema"; + } + + const char* boolean_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* byte_sskel:: + _static_type () + { + return "byte http://www.w3.org/2001/XMLSchema"; + } + + const char* byte_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_byte_sskel:: + _static_type () + { + return "unsignedByte http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_byte_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* short_sskel:: + _static_type () + { + return "short http://www.w3.org/2001/XMLSchema"; + } + + const char* short_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_short_sskel:: + _static_type () + { + return "unsignedShort http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_short_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* int_sskel:: + _static_type () + { + return "int http://www.w3.org/2001/XMLSchema"; + } + + const char* int_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_int_sskel:: + _static_type () + { + return "unsignedInt http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_int_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* long_sskel:: + _static_type () + { + return "long http://www.w3.org/2001/XMLSchema"; + } + + const char* long_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* unsigned_long_sskel:: + _static_type () + { + return "unsignedLong http://www.w3.org/2001/XMLSchema"; + } + + const char* unsigned_long_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* integer_sskel:: + _static_type () + { + return "integer http://www.w3.org/2001/XMLSchema"; + } + + const char* integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* negative_integer_sskel:: + _static_type () + { + return "negativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* negative_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_positive_integer_sskel:: + _static_type () + { + return "nonPositiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_positive_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* positive_integer_sskel:: + _static_type () + { + return "positiveInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* positive_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* non_negative_integer_sskel:: + _static_type () + { + return "nonNegativeInteger http://www.w3.org/2001/XMLSchema"; + } + + const char* non_negative_integer_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* float_sskel:: + _static_type () + { + return "float http://www.w3.org/2001/XMLSchema"; + } + + const char* float_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* double_sskel:: + _static_type () + { + return "double http://www.w3.org/2001/XMLSchema"; + } + + const char* double_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* decimal_sskel:: + _static_type () + { + return "decimal http://www.w3.org/2001/XMLSchema"; + } + + const char* decimal_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* string_sskel:: + _static_type () + { + return "string http://www.w3.org/2001/XMLSchema"; + } + + const char* string_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* normalized_string_sskel:: + _static_type () + { + return "normalizedString http://www.w3.org/2001/XMLSchema"; + } + + const char* normalized_string_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* token_sskel:: + _static_type () + { + return "token http://www.w3.org/2001/XMLSchema"; + } + + const char* token_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* name_sskel:: + _static_type () + { + return "Name http://www.w3.org/2001/XMLSchema"; + } + + const char* name_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtoken_sskel:: + _static_type () + { + return "NMTOKEN http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtoken_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* nmtokens_sskel:: + _static_type () + { + return "NMTOKENS http://www.w3.org/2001/XMLSchema"; + } + + const char* nmtokens_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* ncname_sskel:: + _static_type () + { + return "NCName http://www.w3.org/2001/XMLSchema"; + } + + const char* ncname_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* id_sskel:: + _static_type () + { + return "ID http://www.w3.org/2001/XMLSchema"; + } + + const char* id_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idref_sskel:: + _static_type () + { + return "IDREF http://www.w3.org/2001/XMLSchema"; + } + + const char* idref_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* idrefs_sskel:: + _static_type () + { + return "IDREFS http://www.w3.org/2001/XMLSchema"; + } + + const char* idrefs_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* language_sskel:: + _static_type () + { + return "language http://www.w3.org/2001/XMLSchema"; + } + + const char* language_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* uri_sskel:: + _static_type () + { + return "anyURI http://www.w3.org/2001/XMLSchema"; + } + + const char* uri_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* qname_sskel:: + _static_type () + { + return "QName http://www.w3.org/2001/XMLSchema"; + } + + const char* qname_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* base64_binary_sskel:: + _static_type () + { + return "base64Binary http://www.w3.org/2001/XMLSchema"; + } + + const char* base64_binary_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* hex_binary_sskel:: + _static_type () + { + return "hexBinary http://www.w3.org/2001/XMLSchema"; + } + + const char* hex_binary_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gday_sskel:: + _static_type () + { + return "gDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gday_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_sskel:: + _static_type () + { + return "gMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_sskel:: + _static_type () + { + return "gYear http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gmonth_day_sskel:: + _static_type () + { + return "gMonthDay http://www.w3.org/2001/XMLSchema"; + } + + const char* gmonth_day_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* gyear_month_sskel:: + _static_type () + { + return "gYearMonth http://www.w3.org/2001/XMLSchema"; + } + + const char* gyear_month_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_sskel:: + _static_type () + { + return "date http://www.w3.org/2001/XMLSchema"; + } + + const char* date_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* time_sskel:: + _static_type () + { + return "time http://www.w3.org/2001/XMLSchema"; + } + + const char* time_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* date_time_sskel:: + _static_type () + { + return "dateTime http://www.w3.org/2001/XMLSchema"; + } + + const char* date_time_sskel:: + _dynamic_type () const + { + return _static_type (); + } + + const char* duration_sskel:: + _static_type () + { + return "duration http://www.w3.org/2001/XMLSchema"; + } + + const char* duration_sskel:: + _dynamic_type () const + { + return _static_type (); + } +#endif // XSDE_POLYMORPHIC + } + } + } +} diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx new file mode 100644 index 0000000..9a158b0 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx @@ -0,0 +1,1382 @@ +// file : xsde/cxx/serializer/validating/xml-schema-sskel.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_SERIALIZER_VALIDATING_XML_SCHEMA_SSKEL_HXX +#define XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SSKEL_HXX + +#include <xsde/cxx/config.hxx> + +#ifdef XSDE_STL +# include <string> +#endif + +#include <xsde/cxx/serializer/xml-schema.hxx> + +#include <xsde/cxx/serializer/validating/serializer.hxx> + +namespace xsde +{ + namespace cxx + { + namespace serializer + { + namespace validating + { + // anyType and anySimpleType. + // + struct any_type_sskel: complex_content + { + virtual void + pre (); + + // Override the following two functions to implement + // your logic. + // + + // virtual void + // _serialize_attributes (); + + // virtual void + // _serialize_content (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_type_sskel (); + any_type_sskel (any_type_sskel* impl, void*); + + protected: + any_type_sskel* any_type_impl_; +#endif + }; + + struct any_simple_type_sskel: simple_content + { + virtual void + pre (); + + // Override the following function to implement your + // logic. + // + + // virtual void + // _serialize_content (); + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + any_simple_type_sskel (); + any_simple_type_sskel (any_simple_type_sskel* impl, void*); + + protected: + any_simple_type_sskel* any_simple_type_impl_; +#endif + }; + + // Boolean. + // + struct boolean_sskel: simple_content + { + virtual void + pre (bool) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + boolean_sskel (); + boolean_sskel (boolean_sskel* impl, void*); + + protected: + boolean_sskel* boolean_impl_; +#endif + }; + + // 8-bit + // + + struct byte_sskel: simple_content + { + virtual void + pre (signed char) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + byte_sskel (); + byte_sskel (byte_sskel* impl, void*); + + protected: + byte_sskel* byte_impl_; +#endif + }; + + struct unsigned_byte_sskel: simple_content + { + virtual void + pre (unsigned char) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_byte_sskel (); + unsigned_byte_sskel (unsigned_byte_sskel* impl, void*); + + protected: + unsigned_byte_sskel* unsigned_byte_impl_; +#endif + }; + + + // 16-bit + // + + struct short_sskel: simple_content + { + virtual void + pre (short) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + short_sskel (); + short_sskel (short_sskel* impl, void*); + + protected: + short_sskel* short_impl_; +#endif + }; + + struct unsigned_short_sskel: simple_content + { + virtual void + pre (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_sskel (); + unsigned_short_sskel (unsigned_short_sskel* impl, void*); + + protected: + unsigned_short_sskel* unsigned_short_impl_; +#endif + }; + + // 32-bit + // + + struct int_sskel: simple_content + { + virtual void + pre (int) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + int_sskel (); + int_sskel (int_sskel* impl, void*); + + protected: + int_sskel* int_impl_; +#endif + }; + + struct unsigned_int_sskel: simple_content + { + virtual void + pre (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_sskel (); + unsigned_int_sskel (unsigned_int_sskel* impl, void*); + + protected: + unsigned_int_sskel* unsigned_int_impl_; +#endif + }; + + // 64-bit + // + +#ifdef XSDE_LONGLONG + struct long_sskel: simple_content + { + virtual void + pre (long long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_sskel (); + long_sskel (long_sskel* impl, void*); + + protected: + long_sskel* long_impl_; +#endif + }; + + struct unsigned_long_sskel: simple_content + { + virtual void + pre (unsigned long long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_sskel (); + unsigned_long_sskel (unsigned_long_sskel* impl, void*); + + protected: + unsigned_long_sskel* unsigned_long_impl_; +#endif + }; +#else + struct long_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + long_sskel (); + long_sskel (long_sskel* impl, void*); + + protected: + long_sskel* long_impl_; +#endif + }; + + struct unsigned_long_sskel: simple_content + { + virtual void + pre (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_sskel (); + unsigned_long_sskel (unsigned_long_sskel* impl, void*); + + protected: + unsigned_long_sskel* unsigned_long_impl_; +#endif + }; +#endif + + // Arbitrary-length integers. + // + + struct integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + integer_sskel (); + integer_sskel (integer_sskel* impl, void*); + + protected: + integer_sskel* integer_impl_; +#endif + }; + + struct negative_integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + negative_integer_sskel (); + negative_integer_sskel (negative_integer_sskel* impl, void*); + + protected: + negative_integer_sskel* negative_integer_impl_; +#endif + }; + + struct non_positive_integer_sskel: simple_content + { + virtual void + pre (long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_positive_integer_sskel (); + non_positive_integer_sskel (non_positive_integer_sskel* impl, void*); + + protected: + non_positive_integer_sskel* non_positive_integer_impl_; +#endif + }; + + struct positive_integer_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + positive_integer_sskel (); + positive_integer_sskel (positive_integer_sskel* impl, void*); + + protected: + positive_integer_sskel* positive_integer_impl_; +#endif + }; + + struct non_negative_integer_sskel: simple_content + { + virtual void + pre (unsigned long) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + non_negative_integer_sskel (); + non_negative_integer_sskel (non_negative_integer_sskel* impl, void*); + + protected: + non_negative_integer_sskel* non_negative_integer_impl_; +#endif + }; + + // Floats. + // + + struct float_sskel: simple_content + { + virtual void + pre (float) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + float_sskel (); + float_sskel (float_sskel* impl, void*); + + protected: + float_sskel* float_impl_; +#endif + }; + + struct double_sskel: simple_content + { + virtual void + pre (double) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + double_sskel (); + double_sskel (double_sskel* impl, void*); + + protected: + double_sskel* double_impl_; +#endif + }; + + struct decimal_sskel: simple_content + { + virtual void + pre (double) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + decimal_sskel (); + decimal_sskel (decimal_sskel* impl, void*); + + protected: + decimal_sskel* decimal_impl_; +#endif + }; + + // String-based types. + // +#ifdef XSDE_STL + + struct string_sskel: simple_content + { + virtual void + pre (const std::string&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_sskel (); + string_sskel (string_sskel* impl, void*); + + protected: + string_sskel* string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_sskel: virtual string_sskel +#else + struct normalized_string_sskel: string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_sskel (); + normalized_string_sskel (normalized_string_sskel* impl, void*); + + protected: + normalized_string_sskel* normalized_string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_sskel: virtual normalized_string_sskel +#else + struct token_sskel: normalized_string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_sskel (); + token_sskel (token_sskel* impl, void*); + + protected: + token_sskel* token_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_sskel: virtual token_sskel +#else + struct name_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_sskel (); + name_sskel (name_sskel* impl, void*); + + protected: + name_sskel* name_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_sskel: virtual token_sskel +#else + struct nmtoken_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_sskel (); + nmtoken_sskel (nmtoken_sskel* impl, void*); + + protected: + nmtoken_sskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_sskel (); + nmtokens_sskel (nmtokens_sskel* impl, void*); + + protected: + nmtokens_sskel* nmtokens_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_sskel: virtual name_sskel +#else + struct ncname_sskel: name_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_sskel (); + ncname_sskel (ncname_sskel* impl, void*); + + protected: + ncname_sskel* ncname_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_sskel: virtual ncname_sskel +#else + struct id_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_sskel (); + id_sskel (id_sskel* impl, void*); + + protected: + id_sskel* id_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_sskel: virtual ncname_sskel +#else + struct idref_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_sskel (); + idref_sskel (idref_sskel* impl, void*); + + protected: + idref_sskel* idref_impl_; +#endif + }; + + struct idrefs_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_sskel (); + idrefs_sskel (idrefs_sskel* impl, void*); + + protected: + idrefs_sskel* idrefs_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_sskel: virtual token_sskel +#else + struct language_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_sskel (); + language_sskel (language_sskel* impl, void*); + + protected: + language_sskel* language_impl_; +#endif + }; + + struct uri_sskel: simple_content + { + virtual void + pre (const std::string&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_sskel (); + uri_sskel (uri_sskel* impl, void*); + + protected: + uri_sskel* uri_impl_; +#endif + }; + + struct qname_sskel: simple_content + { + virtual void + pre (const qname&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_sskel (); + qname_sskel (qname_sskel* impl, void*); + + protected: + qname_sskel* qname_impl_; +#endif + }; + +#else // XSDE_STL + + struct string_sskel: simple_content + { + virtual void + pre (const char*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + string_sskel (); + string_sskel (string_sskel* impl, void*); + + protected: + string_sskel* string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct normalized_string_sskel: virtual string_sskel +#else + struct normalized_string_sskel: string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + normalized_string_sskel (); + normalized_string_sskel (normalized_string_sskel* impl, void*); + + protected: + normalized_string_sskel* normalized_string_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct token_sskel: virtual normalized_string_sskel +#else + struct token_sskel: normalized_string_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + token_sskel (); + token_sskel (token_sskel* impl, void*); + + protected: + token_sskel* token_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct name_sskel: virtual token_sskel +#else + struct name_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + name_sskel (); + name_sskel (name_sskel* impl, void*); + + protected: + name_sskel* name_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct nmtoken_sskel: virtual token_sskel +#else + struct nmtoken_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtoken_sskel (); + nmtoken_sskel (nmtoken_sskel* impl, void*); + + protected: + nmtoken_sskel* nmtoken_impl_; +#endif + }; + + struct nmtokens_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + nmtokens_sskel (); + nmtokens_sskel (nmtokens_sskel* impl, void*); + + protected: + nmtokens_sskel* nmtokens_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct ncname_sskel: virtual name_sskel +#else + struct ncname_sskel: name_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + ncname_sskel (); + ncname_sskel (ncname_sskel* impl, void*); + + protected: + ncname_sskel* ncname_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct id_sskel: virtual ncname_sskel +#else + struct id_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + id_sskel (); + id_sskel (id_sskel* impl, void*); + + protected: + id_sskel* id_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct idref_sskel: virtual ncname_sskel +#else + struct idref_sskel: ncname_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idref_sskel (); + idref_sskel (idref_sskel* impl, void*); + + protected: + idref_sskel* idref_impl_; +#endif + }; + + struct idrefs_sskel: simple_content + { + virtual void + pre (const string_sequence*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + idrefs_sskel (); + idrefs_sskel (idrefs_sskel* impl, void*); + + protected: + idrefs_sskel* idrefs_impl_; +#endif + }; + +#ifdef XSDE_REUSE_STYLE_MIXIN + struct language_sskel: virtual token_sskel +#else + struct language_sskel: token_sskel +#endif + { +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + language_sskel (); + language_sskel (language_sskel* impl, void*); + + protected: + language_sskel* language_impl_; +#endif + }; + + struct uri_sskel: simple_content + { + virtual void + pre (const char*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + uri_sskel (); + uri_sskel (uri_sskel* impl, void*); + + protected: + uri_sskel* uri_impl_; +#endif + }; + + struct qname_sskel: simple_content + { + virtual void + pre (const qname*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + qname_sskel (); + qname_sskel (qname_sskel* impl, void*); + + protected: + qname_sskel* qname_impl_; +#endif + }; + +#endif // XSDE_STL + + + // base64Binary + // + struct base64_binary_sskel: simple_content + { + virtual void + pre (const buffer*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + base64_binary_sskel (); + base64_binary_sskel (base64_binary_sskel* impl, void*); + + protected: + base64_binary_sskel* base64_binary_impl_; +#endif + }; + + // hexBinary + // + struct hex_binary_sskel: simple_content + { + virtual void + pre (const buffer*) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + hex_binary_sskel (); + hex_binary_sskel (hex_binary_sskel* impl, void*); + + protected: + hex_binary_sskel* hex_binary_impl_; +#endif + }; + + // Time and date types. + // + struct gday_sskel: simple_content + { + virtual void + pre (const gday&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gday_sskel (); + gday_sskel (gday_sskel* impl, void*); + + protected: + gday_sskel* gday_impl_; +#endif + }; + + struct gmonth_sskel: simple_content + { + virtual void + pre (const gmonth&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gmonth_sskel (); + gmonth_sskel (gmonth_sskel* impl, void*); + + protected: + gmonth_sskel* gmonth_impl_; +#endif + }; + + struct gyear_sskel: simple_content + { + virtual void + pre (const gyear&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + gyear_sskel (); + gyear_sskel (gyear_sskel* impl, void*); + + protected: + gyear_sskel* gyear_impl_; +#endif + }; + + struct gmonth_day_sskel: simple_content + { + virtual void + pre (const 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_sskel (); + gmonth_day_sskel (gmonth_day_sskel* impl, void*); + + protected: + gmonth_day_sskel* gmonth_day_impl_; +#endif + }; + + struct gyear_month_sskel: simple_content + { + virtual void + pre (const 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_sskel (); + gyear_month_sskel (gyear_month_sskel* impl, void*); + + protected: + gyear_month_sskel* gyear_month_impl_; +#endif + }; + + struct date_sskel: simple_content + { + virtual void + pre (const date&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + date_sskel (); + date_sskel (date_sskel* impl, void*); + + protected: + date_sskel* date_impl_; +#endif + }; + + struct time_sskel: simple_content + { + virtual void + pre (const time&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + time_sskel (); + time_sskel (time_sskel* impl, void*); + + protected: + time_sskel* time_impl_; +#endif + }; + + struct date_time_sskel: simple_content + { + virtual void + pre (const 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_sskel (); + date_time_sskel (date_time_sskel* impl, void*); + + protected: + date_time_sskel* date_time_impl_; +#endif + }; + + struct duration_sskel: simple_content + { + virtual void + pre (const duration&) = 0; + +#ifdef XSDE_POLYMORPHIC + static const char* + _static_type (); + + virtual const char* + _dynamic_type () const; +#endif + +#ifdef XSDE_REUSE_STYLE_TIEIN + duration_sskel (); + duration_sskel (duration_sskel* impl, void*); + + protected: + duration_sskel* duration_impl_; +#endif + }; + } + } + } +} + +#include <xsde/cxx/serializer/validating/xml-schema-sskel.ixx> + +#endif // XSDE_CXX_SERIALIZER_VALIDATING_XML_SCHEMA_SSKEL_HXX diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx new file mode 100644 index 0000000..23647b5 --- /dev/null +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx @@ -0,0 +1,704 @@ +// file : xsde/cxx/serializer/validating/xml-schema-sskel.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 serializer + { + namespace validating + { + // any_type_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_type_sskel:: + any_type_sskel () + : any_type_impl_ (0) + { + } + + inline any_type_sskel:: + any_type_sskel (any_type_sskel* impl, void*) + : complex_content (impl, 0), any_type_impl_ (impl) + { + } +#endif + + // any_simple_type_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline any_simple_type_sskel:: + any_simple_type_sskel () + : any_simple_type_impl_ (0) + { + } + + inline any_simple_type_sskel:: + any_simple_type_sskel (any_simple_type_sskel* impl, void*) + : simple_content (impl, 0), any_simple_type_impl_ (impl) + { + } +#endif + + // boolean_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline boolean_sskel:: + boolean_sskel () + : boolean_impl_ (0) + { + } + + inline boolean_sskel:: + boolean_sskel (boolean_sskel* impl, void*) + : simple_content (impl, 0), boolean_impl_ (impl) + { + } +#endif + + // byte_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline byte_sskel:: + byte_sskel () + : byte_impl_ (0) + { + } + + inline byte_sskel:: + byte_sskel (byte_sskel* impl, void*) + : simple_content (impl, 0), byte_impl_ (impl) + { + } +#endif + + // unsigned_byte_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_byte_sskel:: + unsigned_byte_sskel () + : unsigned_byte_impl_ (0) + { + } + + inline unsigned_byte_sskel:: + unsigned_byte_sskel (unsigned_byte_sskel* impl, void*) + : simple_content (impl, 0), unsigned_byte_impl_ (impl) + { + } +#endif + + // short_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline short_sskel:: + short_sskel () + : short_impl_ (0) + { + } + + inline short_sskel:: + short_sskel (short_sskel* impl, void*) + : simple_content (impl, 0), short_impl_ (impl) + { + } +#endif + + // unsigned_short_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_short_sskel:: + unsigned_short_sskel () + : unsigned_short_impl_ (0) + { + } + + inline unsigned_short_sskel:: + unsigned_short_sskel (unsigned_short_sskel* impl, void*) + : simple_content (impl, 0), unsigned_short_impl_ (impl) + { + } +#endif + + // int_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline int_sskel:: + int_sskel () + : int_impl_ (0) + { + } + + inline int_sskel:: + int_sskel (int_sskel* impl, void*) + : simple_content (impl, 0), int_impl_ (impl) + { + } +#endif + + // unsigned_int_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_int_sskel:: + unsigned_int_sskel () + : unsigned_int_impl_ (0) + { + } + + inline unsigned_int_sskel:: + unsigned_int_sskel (unsigned_int_sskel* impl, void*) + : simple_content (impl, 0), unsigned_int_impl_ (impl) + { + } +#endif + + // long_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline long_sskel:: + long_sskel () + : long_impl_ (0) + { + } + + inline long_sskel:: + long_sskel (long_sskel* impl, void*) + : simple_content (impl, 0), long_impl_ (impl) + { + } +#endif + + // unsigned_long_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline unsigned_long_sskel:: + unsigned_long_sskel () + : unsigned_long_impl_ (0) + { + } + + inline unsigned_long_sskel:: + unsigned_long_sskel (unsigned_long_sskel* impl, void*) + : simple_content (impl, 0), unsigned_long_impl_ (impl) + { + } +#endif + + // integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline integer_sskel:: + integer_sskel () + : integer_impl_ (0) + { + } + + inline integer_sskel:: + integer_sskel (integer_sskel* impl, void*) + : simple_content (impl, 0), integer_impl_ (impl) + { + } +#endif + + // negative_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline negative_integer_sskel:: + negative_integer_sskel () + : negative_integer_impl_ (0) + { + } + + inline negative_integer_sskel:: + negative_integer_sskel (negative_integer_sskel* impl, void*) + : simple_content (impl, 0), negative_integer_impl_ (impl) + { + } +#endif + + // non_positive_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_positive_integer_sskel:: + non_positive_integer_sskel () + : non_positive_integer_impl_ (0) + { + } + + inline non_positive_integer_sskel:: + non_positive_integer_sskel (non_positive_integer_sskel* impl, void*) + : simple_content (impl, 0), non_positive_integer_impl_ (impl) + { + } +#endif + + // positive_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline positive_integer_sskel:: + positive_integer_sskel () + : positive_integer_impl_ (0) + { + } + + inline positive_integer_sskel:: + positive_integer_sskel (positive_integer_sskel* impl, void*) + : simple_content (impl, 0), positive_integer_impl_ (impl) + { + } +#endif + + // non_negative_integer_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline non_negative_integer_sskel:: + non_negative_integer_sskel () + : non_negative_integer_impl_ (0) + { + } + + inline non_negative_integer_sskel:: + non_negative_integer_sskel (non_negative_integer_sskel* impl, void*) + : simple_content (impl, 0), non_negative_integer_impl_ (impl) + { + } +#endif + + // float_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline float_sskel:: + float_sskel () + : float_impl_ (0) + { + } + + inline float_sskel:: + float_sskel (float_sskel* impl, void*) + : simple_content (impl, 0), float_impl_ (impl) + { + } +#endif + + // double_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline double_sskel:: + double_sskel () + : double_impl_ (0) + { + } + + inline double_sskel:: + double_sskel (double_sskel* impl, void*) + : simple_content (impl, 0), double_impl_ (impl) + { + } +#endif + + // decimal_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline decimal_sskel:: + decimal_sskel () + : decimal_impl_ (0) + { + } + + inline decimal_sskel:: + decimal_sskel (decimal_sskel* impl, void*) + : simple_content (impl, 0), decimal_impl_ (impl) + { + } +#endif + + // string_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline string_sskel:: + string_sskel () + : string_impl_ (0) + { + } + + inline string_sskel:: + string_sskel (string_sskel* impl, void*) + : simple_content (impl, 0), string_impl_ (impl) + { + } +#endif + + // normalized_string_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline normalized_string_sskel:: + normalized_string_sskel () + : normalized_string_impl_ (0) + { + } + + inline normalized_string_sskel:: + normalized_string_sskel (normalized_string_sskel* impl, void*) + : string_sskel (impl, 0), normalized_string_impl_ (impl) + { + } +#endif + + // token_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline token_sskel:: + token_sskel () + : token_impl_ (0) + { + } + + inline token_sskel:: + token_sskel (token_sskel* impl, void*) + : normalized_string_sskel (impl, 0), token_impl_ (impl) + { + } +#endif + + // name_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline name_sskel:: + name_sskel () + : name_impl_ (0) + { + } + + inline name_sskel:: + name_sskel (name_sskel* impl, void*) + : token_sskel (impl, 0), name_impl_ (impl) + { + } +#endif + + // nmtoken_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtoken_sskel:: + nmtoken_sskel () + : nmtoken_impl_ (0) + { + } + + inline nmtoken_sskel:: + nmtoken_sskel (nmtoken_sskel* impl, void*) + : token_sskel (impl, 0), nmtoken_impl_ (impl) + { + } +#endif + + // nmtokens_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline nmtokens_sskel:: + nmtokens_sskel () + : nmtokens_impl_ (0) + { + } + + inline nmtokens_sskel:: + nmtokens_sskel (nmtokens_sskel* impl, void*) + : simple_content (impl, 0), nmtokens_impl_ (impl) + { + } +#endif + + // ncname_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline ncname_sskel:: + ncname_sskel () + : ncname_impl_ (0) + { + } + + inline ncname_sskel:: + ncname_sskel (ncname_sskel* impl, void*) + : name_sskel (impl, 0), ncname_impl_ (impl) + { + } +#endif + + // id_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline id_sskel:: + id_sskel () + : id_impl_ (0) + { + } + + inline id_sskel:: + id_sskel (id_sskel* impl, void*) + : ncname_sskel (impl, 0), id_impl_ (impl) + { + } +#endif + + // idref_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idref_sskel:: + idref_sskel () + : idref_impl_ (0) + { + } + + inline idref_sskel:: + idref_sskel (idref_sskel* impl, void*) + : ncname_sskel (impl, 0), idref_impl_ (impl) + { + } +#endif + + // idrefs_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline idrefs_sskel:: + idrefs_sskel () + : idrefs_impl_ (0) + { + } + + inline idrefs_sskel:: + idrefs_sskel (idrefs_sskel* impl, void*) + : simple_content (impl, 0), idrefs_impl_ (impl) + { + } +#endif + + // language_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline language_sskel:: + language_sskel () + : language_impl_ (0) + { + } + + inline language_sskel:: + language_sskel (language_sskel* impl, void*) + : token_sskel (impl, 0), language_impl_ (impl) + { + } +#endif + + // uri_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline uri_sskel:: + uri_sskel () + : uri_impl_ (0) + { + } + + inline uri_sskel:: + uri_sskel (uri_sskel* impl, void*) + : simple_content (impl, 0), uri_impl_ (impl) + { + } +#endif + + // qname_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline qname_sskel:: + qname_sskel () + : qname_impl_ (0) + { + } + + inline qname_sskel:: + qname_sskel (qname_sskel* impl, void*) + : simple_content (impl, 0), qname_impl_ (impl) + { + } +#endif + + // base64_binary_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline base64_binary_sskel:: + base64_binary_sskel () + : base64_binary_impl_ (0) + { + } + + inline base64_binary_sskel:: + base64_binary_sskel (base64_binary_sskel* impl, void*) + : simple_content (impl, 0), base64_binary_impl_ (impl) + { + } +#endif + + // hex_binary_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline hex_binary_sskel:: + hex_binary_sskel () + : hex_binary_impl_ (0) + { + } + + inline hex_binary_sskel:: + hex_binary_sskel (hex_binary_sskel* impl, void*) + : simple_content (impl, 0), hex_binary_impl_ (impl) + { + } +#endif + + // gday_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gday_sskel:: + gday_sskel () + : gday_impl_ (0) + { + } + + inline gday_sskel:: + gday_sskel (gday_sskel* impl, void*) + : simple_content (impl, 0), gday_impl_ (impl) + { + } +#endif + + // gmonth_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_sskel:: + gmonth_sskel () + : gmonth_impl_ (0) + { + } + + inline gmonth_sskel:: + gmonth_sskel (gmonth_sskel* impl, void*) + : simple_content (impl, 0), gmonth_impl_ (impl) + { + } +#endif + + // gyear_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_sskel:: + gyear_sskel () + : gyear_impl_ (0) + { + } + + inline gyear_sskel:: + gyear_sskel (gyear_sskel* impl, void*) + : simple_content (impl, 0), gyear_impl_ (impl) + { + } +#endif + + // gmonth_day_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gmonth_day_sskel:: + gmonth_day_sskel () + : gmonth_day_impl_ (0) + { + } + + inline gmonth_day_sskel:: + gmonth_day_sskel (gmonth_day_sskel* impl, void*) + : simple_content (impl, 0), gmonth_day_impl_ (impl) + { + } +#endif + + // gyear_month_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline gyear_month_sskel:: + gyear_month_sskel () + : gyear_month_impl_ (0) + { + } + + inline gyear_month_sskel:: + gyear_month_sskel (gyear_month_sskel* impl, void*) + : simple_content (impl, 0), gyear_month_impl_ (impl) + { + } +#endif + + // date_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_sskel:: + date_sskel () + : date_impl_ (0) + { + } + + inline date_sskel:: + date_sskel (date_sskel* impl, void*) + : simple_content (impl, 0), date_impl_ (impl) + { + } +#endif + + // time_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline time_sskel:: + time_sskel () + : time_impl_ (0) + { + } + + inline time_sskel:: + time_sskel (time_sskel* impl, void*) + : simple_content (impl, 0), time_impl_ (impl) + { + } +#endif + + // date_time_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline date_time_sskel:: + date_time_sskel () + : date_time_impl_ (0) + { + } + + inline date_time_sskel:: + date_time_sskel (date_time_sskel* impl, void*) + : simple_content (impl, 0), date_time_impl_ (impl) + { + } +#endif + + // duration_sskel + // +#ifdef XSDE_REUSE_STYLE_TIEIN + inline duration_sskel:: + duration_sskel () + : duration_impl_ (0) + { + } + + inline duration_sskel:: + duration_sskel (duration_sskel* impl, void*) + : simple_content (impl, 0), duration_impl_ (impl) + { + } +#endif + } + } + } +} |