From 51231f66aee0bbbd14d361d9e8e0009e99d57974 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Oct 2010 11:26:08 +0200 Subject: Finish {min,max}{Exclusive,Inclusive} facets support New test: hybrid/facets. --- NEWS | 41 +- dist/tests/cxx/hybrid/makefile | 2 +- dist/tests/cxx/hybrid/nmakefile | 2 +- libxsde/xsde/cxx/parser/validating/byte.cxx | 19 +- libxsde/xsde/cxx/parser/validating/decimal.cxx | 18 + libxsde/xsde/cxx/parser/validating/double.cxx | 18 + libxsde/xsde/cxx/parser/validating/float.cxx | 18 + libxsde/xsde/cxx/parser/validating/int.cxx | 19 + libxsde/xsde/cxx/parser/validating/integer.cxx | 18 + libxsde/xsde/cxx/parser/validating/long-long.cxx | 18 + libxsde/xsde/cxx/parser/validating/long.cxx | 18 + .../cxx/parser/validating/negative-integer.cxx | 18 + .../cxx/parser/validating/non-negative-integer.cxx | 18 + .../cxx/parser/validating/non-positive-integer.cxx | 18 + .../cxx/parser/validating/positive-integer.cxx | 18 + .../cxx/parser/validating/unsigned-long-long.cxx | 18 + .../xsde/cxx/parser/validating/unsigned-long.cxx | 18 + .../cxx/parser/validating/xml-schema-pskel.hxx | 392 +++++++++++++++- .../cxx/parser/validating/xml-schema-pskel.ixx | 459 ++++++++++++++++++- libxsde/xsde/cxx/serializer/validating/byte.cxx | 18 + libxsde/xsde/cxx/serializer/validating/decimal.cxx | 18 + libxsde/xsde/cxx/serializer/validating/double.cxx | 18 + libxsde/xsde/cxx/serializer/validating/float.cxx | 18 + libxsde/xsde/cxx/serializer/validating/int.cxx | 18 + libxsde/xsde/cxx/serializer/validating/integer.cxx | 18 + .../xsde/cxx/serializer/validating/long-long.cxx | 18 + libxsde/xsde/cxx/serializer/validating/long.cxx | 18 + .../cxx/serializer/validating/negative-integer.cxx | 18 + .../serializer/validating/non-negative-integer.cxx | 18 + .../serializer/validating/non-positive-integer.cxx | 18 + .../cxx/serializer/validating/positive-integer.cxx | 18 + .../serializer/validating/unsigned-long-long.cxx | 18 + .../cxx/serializer/validating/unsigned-long.cxx | 18 + .../cxx/serializer/validating/xml-schema-sskel.hxx | 393 +++++++++++++++- .../cxx/serializer/validating/xml-schema-sskel.ixx | 457 ++++++++++++++++++- tests/cxx/hybrid/facets/driver.cxx | 56 +++ tests/cxx/hybrid/facets/makefile | 108 +++++ tests/cxx/hybrid/facets/test-000.std | 62 +++ tests/cxx/hybrid/facets/test-000.xml | 97 ++++ tests/cxx/hybrid/facets/test.xsd | 180 ++++++++ tests/cxx/hybrid/makefile | 3 +- xsde/cxx/elements.cxx | 409 +++++++++++++++++ xsde/cxx/elements.hxx | 161 +++++++ xsde/cxx/hybrid/default-value.cxx | 505 ++------------------- xsde/cxx/hybrid/default-value.hxx | 145 ------ xsde/cxx/hybrid/elements.cxx | 1 + xsde/cxx/hybrid/parser-name-processor.cxx | 1 + xsde/cxx/hybrid/serializer-name-processor.cxx | 1 + xsde/cxx/hybrid/tree-name-processor.cxx | 1 + xsde/cxx/hybrid/tree-source.cxx | 2 +- xsde/cxx/hybrid/tree-type-map.cxx | 1 + xsde/cxx/parser/elements.cxx | 21 +- xsde/cxx/parser/name-processor.cxx | 1 + xsde/cxx/parser/parser-inline.cxx | 34 +- xsde/cxx/serializer/elements.cxx | 21 +- xsde/cxx/serializer/name-processor.cxx | 1 + xsde/cxx/serializer/serializer-inline.cxx | 34 +- 57 files changed, 3380 insertions(+), 717 deletions(-) create mode 100644 tests/cxx/hybrid/facets/driver.cxx create mode 100644 tests/cxx/hybrid/facets/makefile create mode 100644 tests/cxx/hybrid/facets/test-000.std create mode 100644 tests/cxx/hybrid/facets/test-000.xml create mode 100644 tests/cxx/hybrid/facets/test.xsd diff --git a/NEWS b/NEWS index 44f06c9..3e2dd63 100644 --- a/NEWS +++ b/NEWS @@ -68,15 +68,44 @@ Version 3.2.0 C++/Parser - * Support for validation of the pattern XML Schema facet on string-base - types. See the XSDE_REGEXP parameter in the configuration files for - details. + * Support for the following XML Schema facets: + + String-based types: + - length + - minLength + - maxLength + - pattern + - whiteSpace + - enumeration + + Integer and floating-point types: + - minExclusive + - minInclusive + - maxExclusive + - maxInclusive + + For more information on the pattern facet validation, see the XSDE_REGEXP + parameter in the configuration files. C++/Serializer - * Support for validation of the pattern XML Schema facet on string-base - types. See the XSDE_REGEXP parameter in the configuration files for - details. + * Support for the following XML Schema facets: + + String-based types: + - length + - minLength + - maxLength + - pattern + - enumeration + + Integer and floating-point types: + - minExclusive + - minInclusive + - maxExclusive + - maxInclusive + + For more information on the pattern facet validation, see the XSDE_REGEXP + parameter in the configuration files. Version 3.1.0 diff --git a/dist/tests/cxx/hybrid/makefile b/dist/tests/cxx/hybrid/makefile index 9b5fea2..2117324 100644 --- a/dist/tests/cxx/hybrid/makefile +++ b/dist/tests/cxx/hybrid/makefile @@ -15,7 +15,7 @@ endif endif ifeq ($(XSDE_IOSTREAM),y) -dirs += built-in default enumeration list test-template union pattern +dirs += built-in default enumeration list test-template union facets pattern ifeq ($(XSDE_ENCODING),iso8859-1) dirs += iso8859-1 diff --git a/dist/tests/cxx/hybrid/nmakefile b/dist/tests/cxx/hybrid/nmakefile index 560f0b1..57d2324 100644 --- a/dist/tests/cxx/hybrid/nmakefile +++ b/dist/tests/cxx/hybrid/nmakefile @@ -15,7 +15,7 @@ dirs = $(dirs) iterator !endif !if "$(XSDE_IOSTREAM)" == "y" -dirs = $(dirs) built-in default enumeration list test-template union pattern +dirs = $(dirs) built-in default enumeration list test-template union facets pattern !if "$(XSDE_ENCODING)" == "iso8859-1" dirs = $(dirs) iso8859-1 diff --git a/libxsde/xsde/cxx/parser/validating/byte.cxx b/libxsde/xsde/cxx/parser/validating/byte.cxx index c592f43..9e611b1 100644 --- a/libxsde/xsde/cxx/parser/validating/byte.cxx +++ b/libxsde/xsde/cxx/parser/validating/byte.cxx @@ -54,6 +54,24 @@ namespace xsde value_ = neg ? static_cast (-static_cast (ul)) : static_cast (ul); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_byte_value); @@ -68,4 +86,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/parser/validating/decimal.cxx b/libxsde/xsde/cxx/parser/validating/decimal.cxx index 5ce64e5..3fa3166 100644 --- a/libxsde/xsde/cxx/parser/validating/decimal.cxx +++ b/libxsde/xsde/cxx/parser/validating/decimal.cxx @@ -58,6 +58,24 @@ namespace xsde if (sign_ == minus) value_ = -value_; } + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_decimal_value); diff --git a/libxsde/xsde/cxx/parser/validating/double.cxx b/libxsde/xsde/cxx/parser/validating/double.cxx index 0d1acfd..fbb7072 100644 --- a/libxsde/xsde/cxx/parser/validating/double.cxx +++ b/libxsde/xsde/cxx/parser/validating/double.cxx @@ -83,6 +83,24 @@ namespace xsde if (sign_ == minus) value_ = -value_; } + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_double_value); diff --git a/libxsde/xsde/cxx/parser/validating/float.cxx b/libxsde/xsde/cxx/parser/validating/float.cxx index 4a7cf72..7a5d1f6 100644 --- a/libxsde/xsde/cxx/parser/validating/float.cxx +++ b/libxsde/xsde/cxx/parser/validating/float.cxx @@ -102,6 +102,24 @@ namespace xsde if (sign_ == minus) value_ = -value_; } + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_float_value); diff --git a/libxsde/xsde/cxx/parser/validating/int.cxx b/libxsde/xsde/cxx/parser/validating/int.cxx index bf96032..531883e 100644 --- a/libxsde/xsde/cxx/parser/validating/int.cxx +++ b/libxsde/xsde/cxx/parser/validating/int.cxx @@ -59,6 +59,25 @@ namespace xsde ? (-2147483647 - 1) : -static_cast (ul)) : static_cast (ul); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + } else _schema_error (schema_error::invalid_int_value); diff --git a/libxsde/xsde/cxx/parser/validating/integer.cxx b/libxsde/xsde/cxx/parser/validating/integer.cxx index a2c3314..e85b9a2 100644 --- a/libxsde/xsde/cxx/parser/validating/integer.cxx +++ b/libxsde/xsde/cxx/parser/validating/integer.cxx @@ -59,6 +59,24 @@ namespace xsde ? (ul == static_cast (LONG_MIN) ? LONG_MIN: -static_cast (ul)) : static_cast (ul); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_integer_value); diff --git a/libxsde/xsde/cxx/parser/validating/long-long.cxx b/libxsde/xsde/cxx/parser/validating/long-long.cxx index ecb3b57..4bb3247 100644 --- a/libxsde/xsde/cxx/parser/validating/long-long.cxx +++ b/libxsde/xsde/cxx/parser/validating/long-long.cxx @@ -59,6 +59,24 @@ namespace xsde ? (-9223372036854775807LL - 1) : -static_cast (ull)) : static_cast (ull); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_long_value); diff --git a/libxsde/xsde/cxx/parser/validating/long.cxx b/libxsde/xsde/cxx/parser/validating/long.cxx index 675312f..1bafc06 100644 --- a/libxsde/xsde/cxx/parser/validating/long.cxx +++ b/libxsde/xsde/cxx/parser/validating/long.cxx @@ -59,6 +59,24 @@ namespace xsde ? (-2147483647 - 1) : -static_cast (ul)) : static_cast (ul); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_long_value); diff --git a/libxsde/xsde/cxx/parser/validating/negative-integer.cxx b/libxsde/xsde/cxx/parser/validating/negative-integer.cxx index 3087558..1cfbdcd 100644 --- a/libxsde/xsde/cxx/parser/validating/negative-integer.cxx +++ b/libxsde/xsde/cxx/parser/validating/negative-integer.cxx @@ -55,6 +55,24 @@ namespace xsde value_ = ul == static_cast (LONG_MIN) ? LONG_MIN : -static_cast (ul); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_negative_integer_value); diff --git a/libxsde/xsde/cxx/parser/validating/non-negative-integer.cxx b/libxsde/xsde/cxx/parser/validating/non-negative-integer.cxx index 215028a..531c1e2 100644 --- a/libxsde/xsde/cxx/parser/validating/non-negative-integer.cxx +++ b/libxsde/xsde/cxx/parser/validating/non-negative-integer.cxx @@ -50,6 +50,24 @@ namespace xsde get_errno () != 0 || (sign_ == minus && value_ != 0)) _schema_error (schema_error::invalid_non_negative_integer_value); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_non_negative_integer_value); diff --git a/libxsde/xsde/cxx/parser/validating/non-positive-integer.cxx b/libxsde/xsde/cxx/parser/validating/non-positive-integer.cxx index c834698..3d817e7 100644 --- a/libxsde/xsde/cxx/parser/validating/non-positive-integer.cxx +++ b/libxsde/xsde/cxx/parser/validating/non-positive-integer.cxx @@ -55,6 +55,24 @@ namespace xsde value_ = ul == static_cast (LONG_MIN) ? LONG_MIN : -static_cast (ul); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_non_positive_integer_value); diff --git a/libxsde/xsde/cxx/parser/validating/positive-integer.cxx b/libxsde/xsde/cxx/parser/validating/positive-integer.cxx index 5eb020d..bd11b3a 100644 --- a/libxsde/xsde/cxx/parser/validating/positive-integer.cxx +++ b/libxsde/xsde/cxx/parser/validating/positive-integer.cxx @@ -48,6 +48,24 @@ namespace xsde if (*p != '\0' || get_errno () != 0 || value_ == 0) _schema_error (schema_error::invalid_positive_integer_value); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_positive_integer_value); diff --git a/libxsde/xsde/cxx/parser/validating/unsigned-long-long.cxx b/libxsde/xsde/cxx/parser/validating/unsigned-long-long.cxx index 69305fe..9ab1a8a 100644 --- a/libxsde/xsde/cxx/parser/validating/unsigned-long-long.cxx +++ b/libxsde/xsde/cxx/parser/validating/unsigned-long-long.cxx @@ -48,6 +48,24 @@ namespace xsde if (*p != '\0' || get_errno () != 0) _schema_error (schema_error::invalid_unsigned_long_value); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_unsigned_long_value); diff --git a/libxsde/xsde/cxx/parser/validating/unsigned-long.cxx b/libxsde/xsde/cxx/parser/validating/unsigned-long.cxx index 7c7297b..9e90601 100644 --- a/libxsde/xsde/cxx/parser/validating/unsigned-long.cxx +++ b/libxsde/xsde/cxx/parser/validating/unsigned-long.cxx @@ -48,6 +48,24 @@ namespace xsde if (*p != '\0' || get_errno () != 0) _schema_error (schema_error::invalid_unsigned_long_value); + + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } } else _schema_error (schema_error::invalid_unsigned_long_value); diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx index 8823846..f794188 100644 --- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx +++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx @@ -140,14 +140,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + byte_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - byte_pskel (); byte_pskel (byte_pskel* impl, void*); protected: byte_pskel* byte_impl_; #endif + // Facets. + // + public: + void + _max_facet (signed char, bool inclusive); + + void + _min_facet (signed char, bool inclusive); + + protected: + struct facets + { + signed char min_; + signed char max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_byte_pskel: simple_content @@ -317,14 +343,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + int_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - int_pskel (); int_pskel (int_pskel* impl, void*); protected: int_pskel* int_impl_; #endif + // Facets. + // + public: + void + _max_facet (int, bool inclusive); + + void + _min_facet (int, bool inclusive); + + protected: + struct facets + { + int min_; + int max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_int_pskel: simple_content @@ -393,14 +445,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + long_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - long_pskel (); long_pskel (long_pskel* impl, void*); protected: long_pskel* long_impl_; #endif + // Facets. + // + public: + void + _max_facet (long long, bool inclusive); + + void + _min_facet (long long, bool inclusive); + + protected: + struct facets + { + long long min_; + long long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_long_pskel: simple_content @@ -415,14 +493,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + unsigned_long_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - unsigned_long_pskel (); unsigned_long_pskel (unsigned_long_pskel* impl, void*); protected: unsigned_long_pskel* unsigned_long_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long long, bool inclusive); + + void + _min_facet (unsigned long long, bool inclusive); + + protected: + struct facets + { + unsigned long long min_; + unsigned long long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; #else @@ -439,14 +543,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + long_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - long_pskel (); long_pskel (long_pskel* impl, void*); protected: long_pskel* long_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_long_pskel: simple_content @@ -461,14 +591,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + unsigned_long_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - unsigned_long_pskel (); unsigned_long_pskel (unsigned_long_pskel* impl, void*); protected: unsigned_long_pskel* unsigned_long_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long, bool inclusive); + + void + _min_facet (unsigned long, bool inclusive); + + protected: + struct facets + { + unsigned long min_; + unsigned long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; #endif @@ -488,14 +644,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + integer_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - integer_pskel (); integer_pskel (integer_pskel* impl, void*); protected: integer_pskel* integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct negative_integer_pskel: simple_content @@ -510,14 +692,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + negative_integer_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - negative_integer_pskel (); negative_integer_pskel (negative_integer_pskel* impl, void*); protected: negative_integer_pskel* negative_integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct non_positive_integer_pskel: simple_content @@ -532,14 +740,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + non_positive_integer_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - non_positive_integer_pskel (); non_positive_integer_pskel (non_positive_integer_pskel* impl, void*); protected: non_positive_integer_pskel* non_positive_integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct positive_integer_pskel: simple_content @@ -554,14 +788,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + positive_integer_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - positive_integer_pskel (); positive_integer_pskel (positive_integer_pskel* impl, void*); protected: positive_integer_pskel* positive_integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long, bool inclusive); + + void + _min_facet (unsigned long, bool inclusive); + + protected: + struct facets + { + unsigned long min_; + unsigned long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct non_negative_integer_pskel: simple_content @@ -576,14 +836,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + non_negative_integer_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - non_negative_integer_pskel (); non_negative_integer_pskel (non_negative_integer_pskel* impl, void*); protected: non_negative_integer_pskel* non_negative_integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long, bool inclusive); + + void + _min_facet (unsigned long, bool inclusive); + + protected: + struct facets + { + unsigned long min_; + unsigned long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; @@ -602,14 +888,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + float_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - float_pskel (); float_pskel (float_pskel* impl, void*); protected: float_pskel* float_impl_; #endif + // Facets. + // + public: + void + _max_facet (float, bool inclusive); + + void + _min_facet (float, bool inclusive); + + protected: + struct facets + { + float min_; + float max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct double_pskel: simple_content @@ -624,14 +936,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + double_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - double_pskel (); double_pskel (double_pskel* impl, void*); protected: double_pskel* double_impl_; #endif + // Facets. + // + public: + void + _max_facet (double, bool inclusive); + + void + _min_facet (double, bool inclusive); + + protected: + struct facets + { + double min_; + double max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct decimal_pskel: simple_content @@ -646,14 +984,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + decimal_pskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - decimal_pskel (); decimal_pskel (decimal_pskel* impl, void*); protected: decimal_pskel* decimal_impl_; #endif + // Facets. + // + public: + void + _max_facet (double, bool inclusive); + + void + _min_facet (double, bool inclusive); + + protected: + struct facets + { + double min_; + double max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx index a9d01f1..8cc8597 100644 --- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx +++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx @@ -61,20 +61,53 @@ namespace xsde // byte_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline byte_pskel:: byte_pskel () - : byte_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + byte_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline byte_pskel:: byte_pskel (byte_pskel* impl, void*) : simple_content (impl, 0), byte_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void byte_pskel:: + _max_facet (signed char v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void byte_pskel:: + _min_facet (signed char v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const byte_pskel::facets& byte_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } + // unsigned_byte_pskel // inline unsigned_byte_pskel:: @@ -223,20 +256,53 @@ namespace xsde // int_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline int_pskel:: int_pskel () - : int_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + int_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline int_pskel:: int_pskel (int_pskel* impl, void*) : simple_content (impl, 0), int_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void int_pskel:: + _max_facet (int v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void int_pskel:: + _min_facet (int v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const int_pskel::facets& int_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } + // unsigned_int_pskel // inline unsigned_int_pskel:: @@ -288,163 +354,508 @@ namespace xsde // long_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline long_pskel:: long_pskel () - : long_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + long_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline long_pskel:: long_pskel (long_pskel* impl, void*) : simple_content (impl, 0), long_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + + inline void long_pskel:: +#ifdef XSDE_LONGLONG + _max_facet (long long v, bool inc) +#else + _max_facet (long v, bool inc) +#endif + + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; } + + inline void long_pskel:: +#ifdef XSDE_LONGLONG + _min_facet (long long v, bool inc) +#else + _min_facet (long v, bool inc) #endif + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const long_pskel::facets& long_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } // unsigned_long_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline unsigned_long_pskel:: unsigned_long_pskel () - : unsigned_long_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline unsigned_long_pskel:: unsigned_long_pskel (unsigned_long_pskel* impl, void*) : simple_content (impl, 0), unsigned_long_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + + inline void unsigned_long_pskel:: +#ifdef XSDE_LONGLONG + _max_facet (unsigned long long v, bool inc) +#else + _max_facet (unsigned long v, bool inc) +#endif + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void unsigned_long_pskel:: +#ifdef XSDE_LONGLONG + _min_facet (unsigned long long v, bool inc) +#else + _min_facet (unsigned long v, bool inc) +#endif + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const unsigned_long_pskel::facets& unsigned_long_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // integer_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline integer_pskel:: integer_pskel () - : integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline integer_pskel:: integer_pskel (integer_pskel* impl, void*) : simple_content (impl, 0), integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void integer_pskel:: + _max_facet (long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void integer_pskel:: + _min_facet (long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const integer_pskel::facets& integer_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // negative_integer_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline negative_integer_pskel:: negative_integer_pskel () - : negative_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + negative_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline negative_integer_pskel:: negative_integer_pskel (negative_integer_pskel* impl, void*) : simple_content (impl, 0), negative_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void negative_integer_pskel:: + _max_facet (long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void negative_integer_pskel:: + _min_facet (long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const negative_integer_pskel::facets& negative_integer_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else +#endif + return facets_; + } // non_positive_integer_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline non_positive_integer_pskel:: non_positive_integer_pskel () - : non_positive_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + non_positive_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline non_positive_integer_pskel:: non_positive_integer_pskel (non_positive_integer_pskel* impl, void*) : simple_content (impl, 0), non_positive_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void non_positive_integer_pskel:: + _max_facet (long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void non_positive_integer_pskel:: + _min_facet (long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const non_positive_integer_pskel::facets& + non_positive_integer_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else #endif + return facets_; + } // positive_integer_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline positive_integer_pskel:: positive_integer_pskel () - : positive_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + positive_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline positive_integer_pskel:: positive_integer_pskel (positive_integer_pskel* impl, void*) : simple_content (impl, 0), positive_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void positive_integer_pskel:: + _max_facet (unsigned long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; } + + inline void positive_integer_pskel:: + _min_facet (unsigned long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const positive_integer_pskel::facets& positive_integer_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else #endif + return facets_; + } // non_negative_integer_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline non_negative_integer_pskel:: non_negative_integer_pskel () - : non_negative_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + non_negative_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline non_negative_integer_pskel:: non_negative_integer_pskel (non_negative_integer_pskel* impl, void*) : simple_content (impl, 0), non_negative_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void non_negative_integer_pskel:: + _max_facet (unsigned long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void non_negative_integer_pskel:: + _min_facet (unsigned long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const non_negative_integer_pskel::facets& + non_negative_integer_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else #endif + return facets_; + } // float_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline float_pskel:: float_pskel () - : float_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + float_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline float_pskel:: float_pskel (float_pskel* impl, void*) : simple_content (impl, 0), float_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void float_pskel:: + _max_facet (float v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void float_pskel:: + _min_facet (float v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const float_pskel::facets& float_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // double_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline double_pskel:: double_pskel () - : double_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + double_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline double_pskel:: double_pskel (double_pskel* impl, void*) : simple_content (impl, 0), double_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void double_pskel:: + _max_facet (double v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void double_pskel:: + _min_facet (double v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const double_pskel::facets& double_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // decimal_pskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline decimal_pskel:: decimal_pskel () - : decimal_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + decimal_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline decimal_pskel:: decimal_pskel (decimal_pskel* impl, void*) : simple_content (impl, 0), decimal_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void decimal_pskel:: + _max_facet (double v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void decimal_pskel:: + _min_facet (double v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const decimal_pskel::facets& decimal_pskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // string_facets // diff --git a/libxsde/xsde/cxx/serializer/validating/byte.cxx b/libxsde/xsde/cxx/serializer/validating/byte.cxx index 2b672b5..d3884d3 100644 --- a/libxsde/xsde/cxx/serializer/validating/byte.cxx +++ b/libxsde/xsde/cxx/serializer/validating/byte.cxx @@ -24,6 +24,24 @@ namespace xsde void byte_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-128") + 1 characters to hold all // representations of signed byte. // diff --git a/libxsde/xsde/cxx/serializer/validating/decimal.cxx b/libxsde/xsde/cxx/serializer/validating/decimal.cxx index f7fddae..70c645b 100644 --- a/libxsde/xsde/cxx/serializer/validating/decimal.cxx +++ b/libxsde/xsde/cxx/serializer/validating/decimal.cxx @@ -24,6 +24,24 @@ namespace xsde void decimal_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // Assume double values cannot be longer than 127 characters. // char str[128]; diff --git a/libxsde/xsde/cxx/serializer/validating/double.cxx b/libxsde/xsde/cxx/serializer/validating/double.cxx index 7ec2ae6..0d1ab54 100644 --- a/libxsde/xsde/cxx/serializer/validating/double.cxx +++ b/libxsde/xsde/cxx/serializer/validating/double.cxx @@ -24,6 +24,24 @@ namespace xsde void double_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // Assume double values cannot be longer than 127 characters. // char str[128]; diff --git a/libxsde/xsde/cxx/serializer/validating/float.cxx b/libxsde/xsde/cxx/serializer/validating/float.cxx index f224a25..f31b248 100644 --- a/libxsde/xsde/cxx/serializer/validating/float.cxx +++ b/libxsde/xsde/cxx/serializer/validating/float.cxx @@ -24,6 +24,24 @@ namespace xsde void float_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // Assume float values cannot be longer than 127 characters. // char str[128]; diff --git a/libxsde/xsde/cxx/serializer/validating/int.cxx b/libxsde/xsde/cxx/serializer/validating/int.cxx index a97b926..4ae17b3 100644 --- a/libxsde/xsde/cxx/serializer/validating/int.cxx +++ b/libxsde/xsde/cxx/serializer/validating/int.cxx @@ -24,6 +24,24 @@ namespace xsde void int_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-2147483649") + 1 characters to hold all // representations of int. // diff --git a/libxsde/xsde/cxx/serializer/validating/integer.cxx b/libxsde/xsde/cxx/serializer/validating/integer.cxx index ebcba69..5e26dbd 100644 --- a/libxsde/xsde/cxx/serializer/validating/integer.cxx +++ b/libxsde/xsde/cxx/serializer/validating/integer.cxx @@ -24,6 +24,24 @@ namespace xsde void integer_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-9223372036854775808") + 1 characters to // hold all representations of (possibly 64-bit) long. // diff --git a/libxsde/xsde/cxx/serializer/validating/long-long.cxx b/libxsde/xsde/cxx/serializer/validating/long-long.cxx index 8464ac3..25cbf53 100644 --- a/libxsde/xsde/cxx/serializer/validating/long-long.cxx +++ b/libxsde/xsde/cxx/serializer/validating/long-long.cxx @@ -24,6 +24,24 @@ namespace xsde void long_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-9223372036854775808") + 1 characters to // hold all representations of long long. // diff --git a/libxsde/xsde/cxx/serializer/validating/long.cxx b/libxsde/xsde/cxx/serializer/validating/long.cxx index 19c7ee4..43a8733 100644 --- a/libxsde/xsde/cxx/serializer/validating/long.cxx +++ b/libxsde/xsde/cxx/serializer/validating/long.cxx @@ -24,6 +24,24 @@ namespace xsde void long_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-9223372036854775808") + 1 characters to // hold all representations of (possibly 64-bit) long. // diff --git a/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx b/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx index adc9ead..bdbc948 100644 --- a/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx +++ b/libxsde/xsde/cxx/serializer/validating/negative-integer.cxx @@ -30,6 +30,24 @@ namespace xsde return; } + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-9223372036854775808") + 1 characters to // hold all representations of (possibly 64-bit) long. // diff --git a/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx index 53e46ea..8bf7fe7 100644 --- a/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx +++ b/libxsde/xsde/cxx/serializer/validating/non-negative-integer.cxx @@ -24,6 +24,24 @@ namespace xsde void non_negative_integer_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("18446744073709551615") + 1 characters to // hold all representations of (possibly 64-bit) unsigned long. // diff --git a/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx index f0d8d55..46c7bcd 100644 --- a/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx +++ b/libxsde/xsde/cxx/serializer/validating/non-positive-integer.cxx @@ -30,6 +30,24 @@ namespace xsde return; } + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("-9223372036854775808") + 1 characters to // hold all representations of (possibly 64-bit) long. // diff --git a/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx b/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx index d35ab15..e7ec2ff 100644 --- a/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx +++ b/libxsde/xsde/cxx/serializer/validating/positive-integer.cxx @@ -30,6 +30,24 @@ namespace xsde return; } + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("18446744073709551615") + 1 characters to // hold all representations of (possibly 64-bit) unsigned long. // diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx index f417e11..b48e205 100644 --- a/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long-long.cxx @@ -24,6 +24,24 @@ namespace xsde void unsigned_long_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("18446744073709551615") + 1 characters to // hold all representations of unsigned long long. // diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx index 903efa1..52dc5c8 100644 --- a/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx +++ b/libxsde/xsde/cxx/serializer/validating/unsigned-long.cxx @@ -24,6 +24,24 @@ namespace xsde void unsigned_long_simpl:: _serialize_content () { + // Check facets. + // + const facets& f = _facets (); + + if (f.min_set_ && + (value_ < f.min_ || (!f.min_inc_ && value_ == f.min_))) + { + _schema_error (schema_error::value_less_than_min); + return; + } + + if (f.max_set_ && + (value_ > f.max_ || (!f.max_inc_ && value_ == f.max_))) + { + _schema_error (schema_error::value_greater_than_max); + return; + } + // We only need strlen("18446744073709551615") + 1 characters to // hold all representations of (possibly 64-bit) unsigned long. // diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx index b93012d..c8e7466 100644 --- a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx @@ -130,14 +130,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + byte_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - byte_sskel (); byte_sskel (byte_sskel* impl, void*); protected: byte_sskel* byte_impl_; #endif + // Facets. + // + public: + void + _max_facet (signed char, bool inclusive); + + void + _min_facet (signed char, bool inclusive); + + protected: + struct facets + { + signed char min_; + signed char max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_byte_sskel: simple_content @@ -152,7 +178,6 @@ namespace xsde virtual const char* _dynamic_type () const; #endif - unsigned_byte_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN @@ -306,14 +331,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + int_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - int_sskel (); int_sskel (int_sskel* impl, void*); protected: int_sskel* int_impl_; #endif + // Facets. + // + public: + void + _max_facet (int, bool inclusive); + + void + _min_facet (int, bool inclusive); + + protected: + struct facets + { + int min_; + int max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_int_sskel: simple_content @@ -381,14 +432,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + long_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - long_sskel (); long_sskel (long_sskel* impl, void*); protected: long_sskel* long_impl_; #endif + // Facets. + // + public: + void + _max_facet (long long, bool inclusive); + + void + _min_facet (long long, bool inclusive); + + protected: + struct facets + { + long long min_; + long long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_long_sskel: simple_content @@ -403,14 +480,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + unsigned_long_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - unsigned_long_sskel (); unsigned_long_sskel (unsigned_long_sskel* impl, void*); protected: unsigned_long_sskel* unsigned_long_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long long, bool inclusive); + + void + _min_facet (unsigned long long, bool inclusive); + + protected: + struct facets + { + unsigned long long min_; + unsigned long long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; #else struct long_sskel: simple_content @@ -425,14 +528,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + long_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - long_sskel (); long_sskel (long_sskel* impl, void*); protected: long_sskel* long_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct unsigned_long_sskel: simple_content @@ -447,14 +576,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + unsigned_long_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - unsigned_long_sskel (); unsigned_long_sskel (unsigned_long_sskel* impl, void*); protected: unsigned_long_sskel* unsigned_long_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long, bool inclusive); + + void + _min_facet (unsigned long, bool inclusive); + + protected: + struct facets + { + unsigned long min_; + unsigned long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; #endif @@ -473,14 +628,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + integer_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - integer_sskel (); integer_sskel (integer_sskel* impl, void*); protected: integer_sskel* integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct negative_integer_sskel: simple_content @@ -495,14 +676,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + negative_integer_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - negative_integer_sskel (); negative_integer_sskel (negative_integer_sskel* impl, void*); protected: negative_integer_sskel* negative_integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct non_positive_integer_sskel: simple_content @@ -517,14 +724,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + non_positive_integer_sskel (); #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 + // Facets. + // + public: + void + _max_facet (long, bool inclusive); + + void + _min_facet (long, bool inclusive); + + protected: + struct facets + { + long min_; + long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct positive_integer_sskel: simple_content @@ -539,14 +772,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + positive_integer_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - positive_integer_sskel (); positive_integer_sskel (positive_integer_sskel* impl, void*); protected: positive_integer_sskel* positive_integer_impl_; #endif + // Facets. + // + public: + void + _max_facet (unsigned long, bool inclusive); + + void + _min_facet (unsigned long, bool inclusive); + + protected: + struct facets + { + unsigned long min_; + unsigned long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct non_negative_integer_sskel: simple_content @@ -561,14 +820,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + non_negative_integer_sskel (); #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 + // Facets. + // + public: + void + _max_facet (unsigned long, bool inclusive); + + void + _min_facet (unsigned long, bool inclusive); + + protected: + struct facets + { + unsigned long min_; + unsigned long max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; // Floats. @@ -586,14 +871,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + float_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - float_sskel (); float_sskel (float_sskel* impl, void*); protected: float_sskel* float_impl_; #endif + // Facets. + // + public: + void + _max_facet (float, bool inclusive); + + void + _min_facet (float, bool inclusive); + + protected: + struct facets + { + float min_; + float max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct double_sskel: simple_content @@ -608,14 +919,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + double_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - double_sskel (); double_sskel (double_sskel* impl, void*); protected: double_sskel* double_impl_; #endif + // Facets. + // + public: + void + _max_facet (double, bool inclusive); + + void + _min_facet (double, bool inclusive); + + protected: + struct facets + { + double min_; + double max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; struct decimal_sskel: simple_content @@ -630,14 +967,40 @@ namespace xsde virtual const char* _dynamic_type () const; #endif + decimal_sskel (); #ifdef XSDE_REUSE_STYLE_TIEIN - decimal_sskel (); decimal_sskel (decimal_sskel* impl, void*); protected: decimal_sskel* decimal_impl_; #endif + // Facets. + // + public: + void + _max_facet (double, bool inclusive); + + void + _min_facet (double, bool inclusive); + + protected: + struct facets + { + double min_; + double max_; + + unsigned int min_set_ : 1; + unsigned int min_inc_ : 1; + unsigned int max_set_ : 1; + unsigned int max_inc_ : 1; + }; + + const facets& + _facets () const; + + private: + facets facets_; }; // diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx index 35ce5d9..f7b0351 100644 --- a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx +++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx @@ -61,19 +61,51 @@ namespace xsde // byte_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline byte_sskel:: byte_sskel () - : byte_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + byte_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline byte_sskel:: byte_sskel (byte_sskel* impl, void*) : simple_content (impl, 0), byte_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void byte_sskel:: + _max_facet (signed char v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; } + + inline void byte_sskel:: + _min_facet (signed char v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const byte_sskel::facets& byte_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // unsigned_byte_sskel // @@ -224,19 +256,51 @@ namespace xsde // int_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline int_sskel:: int_sskel () - : int_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + int_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline int_sskel:: int_sskel (int_sskel* impl, void*) : simple_content (impl, 0), int_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void int_sskel:: + _max_facet (int v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void int_sskel:: + _min_facet (int v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const int_sskel::facets& int_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } // unsigned_int_sskel // @@ -289,163 +353,508 @@ namespace xsde // long_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline long_sskel:: long_sskel () - : long_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + long_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline long_sskel:: long_sskel (long_sskel* impl, void*) : simple_content (impl, 0), long_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void long_sskel:: +#ifdef XSDE_LONGLONG + _max_facet (long long v, bool inc) +#else + _max_facet (long v, bool inc) +#endif + + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void long_sskel:: +#ifdef XSDE_LONGLONG + _min_facet (long long v, bool inc) +#else + _min_facet (long v, bool inc) +#endif + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const long_sskel::facets& long_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } + // unsigned_long_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline unsigned_long_sskel:: unsigned_long_sskel () - : unsigned_long_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + unsigned_long_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline unsigned_long_sskel:: unsigned_long_sskel (unsigned_long_sskel* impl, void*) : simple_content (impl, 0), unsigned_long_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + + inline void unsigned_long_sskel:: +#ifdef XSDE_LONGLONG + _max_facet (unsigned long long v, bool inc) +#else + _max_facet (unsigned long v, bool inc) +#endif + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void unsigned_long_sskel:: +#ifdef XSDE_LONGLONG + _min_facet (unsigned long long v, bool inc) +#else + _min_facet (unsigned long v, bool inc) +#endif + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const unsigned_long_sskel::facets& unsigned_long_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // integer_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline integer_sskel:: integer_sskel () - : integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline integer_sskel:: integer_sskel (integer_sskel* impl, void*) : simple_content (impl, 0), integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void integer_sskel:: + _max_facet (long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void integer_sskel:: + _min_facet (long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const integer_sskel::facets& integer_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } // negative_integer_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline negative_integer_sskel:: negative_integer_sskel () - : negative_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + negative_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline negative_integer_sskel:: negative_integer_sskel (negative_integer_sskel* impl, void*) : simple_content (impl, 0), negative_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void negative_integer_sskel:: + _max_facet (long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void negative_integer_sskel:: + _min_facet (long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const negative_integer_sskel::facets& negative_integer_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else +#endif + return facets_; + } // non_positive_integer_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline non_positive_integer_sskel:: non_positive_integer_sskel () - : non_positive_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + non_positive_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline non_positive_integer_sskel:: non_positive_integer_sskel (non_positive_integer_sskel* impl, void*) : simple_content (impl, 0), non_positive_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void non_positive_integer_sskel:: + _max_facet (long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void non_positive_integer_sskel:: + _min_facet (long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const non_positive_integer_sskel::facets& + non_positive_integer_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else #endif + return facets_; + } // positive_integer_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline positive_integer_sskel:: positive_integer_sskel () - : positive_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + positive_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline positive_integer_sskel:: positive_integer_sskel (positive_integer_sskel* impl, void*) : simple_content (impl, 0), positive_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void positive_integer_sskel:: + _max_facet (unsigned long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void positive_integer_sskel:: + _min_facet (unsigned long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const positive_integer_sskel::facets& positive_integer_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else +#endif + return facets_; + } // non_negative_integer_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline non_negative_integer_sskel:: non_negative_integer_sskel () - : non_negative_integer_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + non_negative_integer_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline non_negative_integer_sskel:: non_negative_integer_sskel (non_negative_integer_sskel* impl, void*) : simple_content (impl, 0), non_negative_integer_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void non_negative_integer_sskel:: + _max_facet (unsigned long v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void non_negative_integer_sskel:: + _min_facet (unsigned long v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const non_negative_integer_sskel::facets& + non_negative_integer_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast ( + *parent_).facets_; + else +#endif + return facets_; + } // float_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline float_sskel:: float_sskel () - : float_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + float_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline float_sskel:: float_sskel (float_sskel* impl, void*) : simple_content (impl, 0), float_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void float_sskel:: + _max_facet (float v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void float_sskel:: + _min_facet (float v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const float_sskel::facets& float_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } // double_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline double_sskel:: double_sskel () - : double_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + double_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline double_sskel:: double_sskel (double_sskel* impl, void*) : simple_content (impl, 0), double_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; + } +#endif + inline void double_sskel:: + _max_facet (double v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void double_sskel:: + _min_facet (double v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; } + + inline const double_sskel::facets& double_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else #endif + return facets_; + } // decimal_sskel // -#ifdef XSDE_REUSE_STYLE_TIEIN inline decimal_sskel:: decimal_sskel () - : decimal_impl_ (0) { +#ifdef XSDE_REUSE_STYLE_TIEIN + decimal_impl_ = 0; +#endif + facets_.min_set_ = 0; + facets_.max_set_ = 0; } +#ifdef XSDE_REUSE_STYLE_TIEIN inline decimal_sskel:: decimal_sskel (decimal_sskel* impl, void*) : simple_content (impl, 0), decimal_impl_ (impl) { + facets_.min_set_ = 0; + facets_.max_set_ = 0; } #endif + inline void decimal_sskel:: + _max_facet (double v, bool inc) + { + facets_.max_ = v; + facets_.max_set_ = 1; + facets_.max_inc_ = inc; + } + + inline void decimal_sskel:: + _min_facet (double v, bool inc) + { + facets_.min_ = v; + facets_.min_set_ = 1; + facets_.min_inc_ = inc; + } + + inline const decimal_sskel::facets& decimal_sskel:: + _facets () const + { +#ifdef XSDE_REUSE_STYLE_TIEIN + if (parent_ != 0) + return static_cast (*parent_).facets_; + else +#endif + return facets_; + } // string_facets // diff --git a/tests/cxx/hybrid/facets/driver.cxx b/tests/cxx/hybrid/facets/driver.cxx new file mode 100644 index 0000000..b46a61c --- /dev/null +++ b/tests/cxx/hybrid/facets/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/facets/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test facets (except pattern) validation. +// + +#include + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout, xml_schema::document_simpl::pretty_print); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/facets/makefile b/tests/cxx/hybrid/facets/makefile new file mode 100644 index 0000000..ec749b3 --- /dev/null +++ b/tests/cxx/hybrid/facets/makefile @@ -0,0 +1,108 @@ +# file : tests/cxx/hybrid/facets/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := test.xsd +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,\ +$(cxx:.cxx=.o) \ +$(xsd:.xsd=.o) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.o)) + +dep := $(obj:.o=.o.d) + +xsde.l := $(out_root)/libxsde/xsde/xsde.l +xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options + +driver := $(out_base)/driver +test := $(out_base)/.test +dist := $(out_base)/.dist +dist-win := $(out_base)/.dist-win +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \ + $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \ + $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \ + $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \ + $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx) + +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen) $(dist) $(dist-win): xsde_options += --generate-parser \ +--generate-serializer --generate-aggregate + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test-000.xml $(src_base)/test-000.std + $(call message,test $$1,$$1 $(src_base)/test-000.xml | diff -u $(src_base)/test-000.std -,$(driver)) + + +# Dist. +# +$(dist) $(dist-win): opt := -src $(src_base) -cmd cxx-hybrid -xsd "$(xsd)" \ +-cxx "$(cxx)" -gen "$(genf)" -opt "$(xsde_options)" -out $(dist_prefix) + +$(dist): + $(call message,install $(src_base),$(scf_root)/dist $(opt)) + +$(dist-win): + $(call message,install $(src_base),$(scf_root)/dist -win $(opt)) + + +# Clean. +# +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(gen): | $(out_base)/.gitignore +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/facets/test-000.std b/tests/cxx/hybrid/facets/test-000.std new file mode 100644 index 0000000..e777433 --- /dev/null +++ b/tests/cxx/hybrid/facets/test-000.std @@ -0,0 +1,62 @@ + + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + 10 + 50 + 100 + -100 + -50 + -10 + -100 + -50 + -10 + 10 + 50 + 100 + 10 + 50 + 100 + 10.5 + 50 + 99.5 + 10.5 + 50 + 99.5 + 10.5 + 50 + 99.5 + 12345 + 12345 + 1234567 + 1234567890 + + +a aa + + + a aa + a aa + a aa + \ No newline at end of file diff --git a/tests/cxx/hybrid/facets/test-000.xml b/tests/cxx/hybrid/facets/test-000.xml new file mode 100644 index 0000000..814be66 --- /dev/null +++ b/tests/cxx/hybrid/facets/test-000.xml @@ -0,0 +1,97 @@ + + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10 + 50 + 100 + + -100 + -50 + -10 + + -100 + -50 + -10 + + 10 + 50 + 100 + + 10 + 50 + 100 + + 10.5 + 50.0 + 99.5 + + 10.5 + 50.0 + 99.5 + + 10.5 + 50.0 + 99.5 + + 12345 + + 12345 + 1234567 + 1234567890 + + + +a aa + + + + + +a aa + + + + + +a aa + + + + + +a aa + + + + diff --git a/tests/cxx/hybrid/facets/test.xsd b/tests/cxx/hybrid/facets/test.xsd new file mode 100644 index 0000000..86c9776 --- /dev/null +++ b/tests/cxx/hybrid/facets/test.xsd @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile index af610f5..810c9c1 100644 --- a/tests/cxx/hybrid/makefile +++ b/tests/cxx/hybrid/makefile @@ -26,7 +26,8 @@ endif endif ifeq ($(xsde_iostream),y) -build_tests += built-in default enumeration list test-template union pattern +build_tests += built-in default enumeration list test-template union facets \ +pattern ifeq ($(xsde_encoding),iso8859-1) build_tests += iso8859-1 diff --git a/xsde/cxx/elements.cxx b/xsde/cxx/elements.cxx index 3da9392..7fe8b3f 100644 --- a/xsde/cxx/elements.cxx +++ b/xsde/cxx/elements.cxx @@ -126,6 +126,7 @@ namespace CXX Boolean trace_include_regex_, Boolean inline_, Boolean custom_allocator, + Boolean ll, Containers::Vector const& reserved_name) : os (o), schema_root (root), @@ -141,6 +142,7 @@ namespace CXX inst_exp (inst_exp_), inl (inl_), custom_alloc (custom_allocator), + long_long (ll), ns_mapping_cache (ns_mapping_cache_), schema_path_ (path), xs_ns_ (0), @@ -1223,4 +1225,411 @@ namespace CXX if (st_) st_->leave (); } + + + // + // LiteralValue + // + + Void LiteralValue:: + normalize (String& s) + { + Size n (s.size ()); + + for (Size i (0); i < n; ++i) + { + WideChar& c (s[i]); + + if (c == 0x0D || // carriage return + c == 0x09 || // tab + c == 0x0A) + c = 0x20; + } + } + + Void LiteralValue:: + collapse (String& s) + { + Size n (s.size ()), j (0); + Boolean subs (false), trim (true); + + for (Size i (0); i < n; ++i) + { + WideChar c (s[i]); + + if (c == 0x20 || c == 0x09 || c == 0x0A) + subs = true; + else + { + if (subs) + { + subs = false; + + if (!trim) + s[j++] = 0x20; + } + + if (trim) + trim = false; + + s[j++] = c; + } + } + + s.resize (j); + } + + Void LiteralValue:: + strip_zeros (String& s) + { + Size n (s.size ()), i (0); + + if (n > 0 && (s[i] == '-' || s[i] == '+')) + i++; + + Size j (i); + + Boolean strip (true); + + for (; i < n; ++i) + { + WideChar c (s[i]); + + if (c == '0') + { + if (!strip) + s[j++] = c; + } + else + { + s[j++] = c; + + if (strip) + strip = false; + } + } + + if (strip && j < n) + s[j++] = '0'; // There was nothing except zeros so add one back. + + s.resize (j); + } + + Void LiteralValue:: + make_float (String& s) + { + if (s.find ('.') == String::npos && + s.find ('e') == String::npos && + s.find ('E') == String::npos) + s += L".0"; + } + + LiteralValue:: + LiteralValue (Context& c, Boolean str) + : Context (c), str_ (str) + { + } + + String LiteralValue:: + dispatch (SemanticGraph::Node& type, String const& value) + { + literal_.clear (); + value_ = value; + Traversal::NodeBase::dispatch (type); + return literal_; + } + + // Boolean. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Boolean&) + { + collapse (value_); + literal_ = (value_ == L"true" || value_ == L"1") ? "true" : "false"; + } + + // Integral types. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Byte&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedByte&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"U"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Short&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedShort&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"U"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Int&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedInt&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"U"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Long&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + literal_ += long_long ? L"LL" : L"L"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::UnsignedLong&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_; + literal_ += long_long ? L"ULL" : L"UL"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Integer&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"L"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::NonPositiveInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"L"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::NonNegativeInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"UL"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::PositiveInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"UL"; + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::NegativeInteger&) + { + collapse (value_); + strip_zeros (value_); + literal_ = value_ + L"L"; + } + + // Floats. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Float&) + { + collapse (value_); + + if (value_ == L"NaN") + { + literal_ = "static_cast< float > (strtod (\"NAN\", 0))"; + } + else if (value_ == L"INF") + { + literal_ = "static_cast< float > (strtod (\"INF\", 0))"; + } + else if (value_ == L"-INF") + { + literal_ = "static_cast< float > (strtod (\"-INF\", 0))"; + } + else + { + strip_zeros (value_); + make_float (value_); + literal_ = value_ + L"F"; + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Double&) + { + collapse (value_); + + if (value_ == L"NaN") + { + literal_ = "strtod (\"NAN\", 0)"; + } + else if (value_ == L"INF") + { + literal_ = "strtod (\"INF\", 0)"; + } + else if (value_ == L"-INF") + { + literal_ = "strtod (\"-INF\", 0)"; + } + else + { + strip_zeros (value_); + make_float (value_); + literal_ = value_; + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Decimal&) + { + collapse (value_); + strip_zeros (value_); + make_float (value_); + literal_ = value_; + } + + // Strings. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::String&) + { + if (str_) + literal_ = strlit (value_); + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::NormalizedString&) + { + if (str_) + { + normalize (value_); + literal_ = strlit (value_); + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Token&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::NameToken&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Name&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::NCName&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Language&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + + // ID/IDREF. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Id&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::IdRef&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + // URI. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::AnyURI&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } + + // Entity. + // + Void LiteralValue:: + traverse (SemanticGraph::Fundamental::Entity&) + { + if (str_) + { + collapse (value_); + literal_ = strlit (value_); + } + } } diff --git a/xsde/cxx/elements.hxx b/xsde/cxx/elements.hxx index 098bd84..c9f79f2 100644 --- a/xsde/cxx/elements.hxx +++ b/xsde/cxx/elements.hxx @@ -160,6 +160,7 @@ namespace CXX Boolean trace_include_regex_, Boolean inline_, Boolean custom_allocator, + Boolean long_long, Containers::Vector const& reserved_name); protected: @@ -178,6 +179,7 @@ namespace CXX inst_exp (c.inst_exp), inl (c.inl), custom_alloc (c.custom_alloc), + long_long (c.long_long), ns_mapping_cache (c.ns_mapping_cache), xs_ns_ (c.xs_ns_), cxx_id_expr (c.cxx_id_expr), @@ -207,6 +209,7 @@ namespace CXX inst_exp (c.inst_exp), inl (c.inl), custom_alloc (c.custom_alloc), + long_long (c.long_long), ns_mapping_cache (c.ns_mapping_cache), xs_ns_ (c.xs_ns_), cxx_id_expr (c.cxx_id_expr), @@ -342,6 +345,7 @@ namespace CXX String& inl; Boolean custom_alloc; + Boolean long_long; public: MappingCache& ns_mapping_cache; @@ -612,6 +616,163 @@ namespace CXX fundamental_template (t); } }; + + struct LiteralValue: Traversal::Fundamental::Byte, + Traversal::Fundamental::UnsignedByte, + Traversal::Fundamental::Short, + Traversal::Fundamental::UnsignedShort, + Traversal::Fundamental::Int, + Traversal::Fundamental::UnsignedInt, + Traversal::Fundamental::Long, + Traversal::Fundamental::UnsignedLong, + Traversal::Fundamental::Integer, + Traversal::Fundamental::NonPositiveInteger, + Traversal::Fundamental::NonNegativeInteger, + Traversal::Fundamental::PositiveInteger, + Traversal::Fundamental::NegativeInteger, + + Traversal::Fundamental::Boolean, + + Traversal::Fundamental::Float, + Traversal::Fundamental::Double, + Traversal::Fundamental::Decimal, + + Traversal::Fundamental::String, + Traversal::Fundamental::NormalizedString, + Traversal::Fundamental::Token, + Traversal::Fundamental::Name, + Traversal::Fundamental::NameToken, + Traversal::Fundamental::NCName, + Traversal::Fundamental::Language, + + Traversal::Fundamental::Id, + Traversal::Fundamental::IdRef, + Traversal::Fundamental::AnyURI, + Traversal::Fundamental::Entity, + + Context + { + LiteralValue (Context&, Boolean str); + + String + dispatch (SemanticGraph::Node& type, String const& value); + + // Boolean. + // + virtual Void + traverse (SemanticGraph::Fundamental::Boolean&); + + // Integral types. + // + virtual Void + traverse (SemanticGraph::Fundamental::Byte&); + + virtual Void + traverse (SemanticGraph::Fundamental::UnsignedByte&); + + virtual Void + traverse (SemanticGraph::Fundamental::Short&); + + virtual Void + traverse (SemanticGraph::Fundamental::UnsignedShort&); + + virtual Void + traverse (SemanticGraph::Fundamental::Int&); + + virtual Void + traverse (SemanticGraph::Fundamental::UnsignedInt&); + + virtual Void + traverse (SemanticGraph::Fundamental::Long&); + + virtual Void + traverse (SemanticGraph::Fundamental::UnsignedLong&); + + virtual Void + traverse (SemanticGraph::Fundamental::Integer&); + + virtual Void + traverse (SemanticGraph::Fundamental::NonPositiveInteger&); + + virtual Void + traverse (SemanticGraph::Fundamental::NonNegativeInteger&); + + virtual Void + traverse (SemanticGraph::Fundamental::PositiveInteger&); + + virtual Void + traverse (SemanticGraph::Fundamental::NegativeInteger&); + + // Floats. + // + virtual Void + traverse (SemanticGraph::Fundamental::Float&); + + virtual Void + traverse (SemanticGraph::Fundamental::Double&); + + virtual Void + traverse (SemanticGraph::Fundamental::Decimal&); + + // Strings. + // + virtual Void + traverse (SemanticGraph::Fundamental::String&); + + virtual Void + traverse (SemanticGraph::Fundamental::NormalizedString&); + + virtual Void + traverse (SemanticGraph::Fundamental::Token&); + + virtual Void + traverse (SemanticGraph::Fundamental::NameToken&); + + virtual Void + traverse (SemanticGraph::Fundamental::Name&); + + virtual Void + traverse (SemanticGraph::Fundamental::NCName&); + + virtual Void + traverse (SemanticGraph::Fundamental::Language&); + + // ID/IDREF. + // + virtual Void + traverse (SemanticGraph::Fundamental::Id&); + + virtual Void + traverse (SemanticGraph::Fundamental::IdRef&); + + // URI. + // + virtual Void + traverse (SemanticGraph::Fundamental::AnyURI&); + + // Entity. + // + virtual Void + traverse (SemanticGraph::Fundamental::Entity&); + + public: + static Void + normalize (String&); + + static Void + collapse (String&); + + static Void + strip_zeros (String&); + + static Void + make_float (String&); + + private: + Boolean str_; + String value_; + String literal_; + }; } #endif // CXX_TREE_ELEMENTS_HXX diff --git a/xsde/cxx/hybrid/default-value.cxx b/xsde/cxx/hybrid/default-value.cxx index 4375e1f..d63c636 100644 --- a/xsde/cxx/hybrid/default-value.cxx +++ b/xsde/cxx/hybrid/default-value.cxx @@ -9,421 +9,6 @@ namespace CXX { namespace Hybrid { - namespace - { - Void - normalize (String& s) - { - Size n (s.size ()); - - for (Size i (0); i < n; ++i) - { - WideChar& c (s[i]); - - if (c == 0x0D || // carriage return - c == 0x09 || // tab - c == 0x0A) - c = 0x20; - } - } - - Void - collapse (String& s) - { - Size n (s.size ()), j (0); - Boolean subs (false), trim (true); - - for (Size i (0); i < n; ++i) - { - WideChar c (s[i]); - - if (c == 0x20 || c == 0x09 || c == 0x0A) - subs = true; - else - { - if (subs) - { - subs = false; - - if (!trim) - s[j++] = 0x20; - } - - if (trim) - trim = false; - - s[j++] = c; - } - } - - s.resize (j); - } - - Void - strip_zeros (String& s) - { - Size n (s.size ()), i (0); - - if (n > 0 && (s[i] == '-' || s[i] == '+')) - i++; - - Size j (i); - - Boolean strip (true); - - for (; i < n; ++i) - { - WideChar c (s[i]); - - if (c == '0') - { - if (!strip) - s[j++] = c; - } - else - { - s[j++] = c; - - if (strip) - strip = false; - } - } - - if (strip && j < n) - s[j++] = '0'; // There was nothing except zeros so add one back. - - s.resize (j); - } - - Void - make_float (String& s) - { - if (s.find ('.') == String::npos && - s.find ('e') == String::npos && - s.find ('E') == String::npos) - s += L".0"; - } - - } - - // - // LiteralValue - // - LiteralValue:: - LiteralValue (Context& c) - : Context (c), str_ (!stl) - { - } - - LiteralValue:: - LiteralValue (Context& c, Boolean str) - : Context (c), str_ (str) - { - } - - String LiteralValue:: - dispatch (SemanticGraph::Node& type, String const& value) - { - literal_.clear (); - value_ = value; - Traversal::NodeBase::dispatch (type); - return literal_; - } - - // Boolean. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Boolean&) - { - collapse (value_); - literal_ = (value_ == L"true" || value_ == L"1") ? "true" : "false"; - } - - // Integral types. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Byte&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedByte&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"U"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Short&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedShort&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"U"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Int&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedInt&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"U"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Long&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - literal_ += options.value () ? L"L" : L"LL"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::UnsignedLong&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_; - literal_ += options.value () ? L"UL" : L"ULL"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Integer&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"L"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::NonPositiveInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"L"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::NonNegativeInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"UL"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::PositiveInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"UL"; - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::NegativeInteger&) - { - collapse (value_); - strip_zeros (value_); - literal_ = value_ + L"L"; - } - - // Floats. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Float&) - { - collapse (value_); - - if (value_ == L"NaN") - { - literal_ = "static_cast< float > (strtod (\"NAN\", 0))"; - } - else if (value_ == L"INF") - { - literal_ = "static_cast< float > (strtod (\"INF\", 0))"; - } - else if (value_ == L"-INF") - { - literal_ = "static_cast< float > (strtod (\"-INF\", 0))"; - } - else - { - strip_zeros (value_); - make_float (value_); - literal_ = value_ + L"F"; - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Double&) - { - collapse (value_); - - if (value_ == L"NaN") - { - literal_ = "strtod (\"NAN\", 0)"; - } - else if (value_ == L"INF") - { - literal_ = "strtod (\"INF\", 0)"; - } - else if (value_ == L"-INF") - { - literal_ = "strtod (\"-INF\", 0)"; - } - else - { - strip_zeros (value_); - make_float (value_); - literal_ = value_; - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Decimal&) - { - collapse (value_); - strip_zeros (value_); - make_float (value_); - literal_ = value_; - } - - // Strings. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::String&) - { - if (str_) - literal_ = strlit (value_); - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::NormalizedString&) - { - if (str_) - { - normalize (value_); - literal_ = strlit (value_); - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Token&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::NameToken&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Name&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::NCName&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Language&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - - // ID/IDREF. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Id&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::IdRef&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - // URI. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::AnyURI&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - - // Entity. - // - Void LiteralValue:: - traverse (SemanticGraph::Fundamental::Entity&) - { - if (str_) - { - collapse (value_); - literal_ = strlit (value_); - } - } - // // InitValue // @@ -435,7 +20,7 @@ namespace CXX var_ (c, TypeName::var), var_value_ (c, TypeName::var_value), literal_value_ (c, true), - literal_value_list_ (c) + literal_value_list_ (c, !stl) { } @@ -452,7 +37,7 @@ namespace CXX SemanticGraph::Type& t (l.argumented ().type ()); Boolean fl (fixed_length (t)); - collapse (value_); + LiteralValue::collapse (value_); if (!value_) return; @@ -710,7 +295,7 @@ namespace CXX if (p != String::npos) value_ = String (value_, p + 1, value_.size () - p - 1); - collapse (value_); + LiteralValue::collapse (value_); String prefix, name; p = value_.find (':'); @@ -776,7 +361,7 @@ namespace CXX Void InitValue:: traverse (SemanticGraph::Fundamental::Base64Binary&) { - collapse (value_); + LiteralValue::collapse (value_); if (value_) os << "#error base64Binary default values are not yet supported" @@ -786,7 +371,7 @@ namespace CXX Void InitValue:: traverse (SemanticGraph::Fundamental::HexBinary&) { - collapse (value_); + LiteralValue::collapse (value_); if (value_) os << "#error hexBinary default values are not yet supported" @@ -801,7 +386,7 @@ namespace CXX { // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); Size b (0); Size e (value_.find ('-', value_[0] == '-' ? 5 : 4)); @@ -813,9 +398,9 @@ namespace CXX b += 3; String day (value_, b, 2); - strip_zeros (year); - strip_zeros (month); - strip_zeros (day); + LiteralValue::strip_zeros (year); + LiteralValue::strip_zeros (month); + LiteralValue::strip_zeros (day); os << member_ << "year (" << year << ");" << member_ << "month (" << month << ");" @@ -829,7 +414,7 @@ namespace CXX { // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); Size b (0); Size e (value_.find ('-', value_[0] == '-' ? 5 : 4)); @@ -859,13 +444,13 @@ namespace CXX String seconds (value_, b, e - b); - strip_zeros (year); - strip_zeros (month); - strip_zeros (day); - strip_zeros (hours); - strip_zeros (minutes); - strip_zeros (seconds); - make_float (seconds); + LiteralValue::strip_zeros (year); + LiteralValue::strip_zeros (month); + LiteralValue::strip_zeros (day); + LiteralValue::strip_zeros (hours); + LiteralValue::strip_zeros (minutes); + LiteralValue::strip_zeros (seconds); + LiteralValue::make_float (seconds); os << member_ << "year (" << year << ");" << member_ << "month (" << month << ");" @@ -900,7 +485,7 @@ namespace CXX { // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] // - collapse (value_); + LiteralValue::collapse (value_); Size b (1), e, n (value_.size ()); @@ -915,7 +500,7 @@ namespace CXX if (e < n && value_[e] == 'Y') { String v (value_, b, e - b); - strip_zeros (v); + LiteralValue::strip_zeros (v); os << member_ << "years (" << v << ");"; b = e + 1; @@ -925,7 +510,7 @@ namespace CXX if (e < n && value_[e] == 'M') { String v (value_, b, e - b); - strip_zeros (v); + LiteralValue::strip_zeros (v); os << member_ << "months (" << v << ");"; b = e + 1; @@ -935,7 +520,7 @@ namespace CXX if (e < n && value_[e] == 'D') { String v (value_, b, e - b); - strip_zeros (v); + LiteralValue::strip_zeros (v); os << member_ << "days (" << v << ");"; b = e + 1; @@ -951,7 +536,7 @@ namespace CXX if (e < n && value_[e] == 'H') { String v (value_, b, e - b); - strip_zeros (v); + LiteralValue::strip_zeros (v); os << member_ << "hours (" << v << ");"; b = e + 1; @@ -961,7 +546,7 @@ namespace CXX if (e < n && value_[e] == 'M') { String v (value_, b, e - b); - strip_zeros (v); + LiteralValue::strip_zeros (v); os << member_ << "minutes (" << v << ");"; b = e + 1; @@ -971,8 +556,8 @@ namespace CXX if (e < n && value_[e] == 'S') { String v (value_, b, e - b); - strip_zeros (v); - make_float (v); + LiteralValue::strip_zeros (v); + LiteralValue::make_float (v); os << member_ << "seconds (" << v << ");"; b = e + 1; @@ -985,10 +570,10 @@ namespace CXX { // gday := ---DD[Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); String day (value_, 3, 2); - strip_zeros (day); + LiteralValue::strip_zeros (day); os << member_ << "day (" << day << ");"; @@ -1000,10 +585,10 @@ namespace CXX { // gmonth := --MM[Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); String month (value_, 2, 2); - strip_zeros (month); + LiteralValue::strip_zeros (month); os << member_ << "month (" << month << ");"; @@ -1015,13 +600,13 @@ namespace CXX { // gmonth_day := --MM-DD[Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); String month (value_, 2, 2); String day (value_, 5, 2); - strip_zeros (month); - strip_zeros (day); + LiteralValue::strip_zeros (month); + LiteralValue::strip_zeros (day); os << member_ << "month (" << month << ");"; os << member_ << "day (" << day << ");"; @@ -1034,7 +619,7 @@ namespace CXX { // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); Size pos (value_[0] == '-' ? 5 : 4); for (; pos < value_.size (); ++pos) @@ -1046,7 +631,7 @@ namespace CXX } String year (value_, 0, pos); - strip_zeros (year); + LiteralValue::strip_zeros (year); os << member_ << "year (" << year << ");"; @@ -1058,15 +643,15 @@ namespace CXX { // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); Size pos (value_.find ('-', value_[0] == '-' ? 5 : 4)); String year (value_, 0, pos); String month (value_, pos + 1, 2); - strip_zeros (year); - strip_zeros (month); + LiteralValue::strip_zeros (year); + LiteralValue::strip_zeros (month); os << member_ << "year (" << year << ");"; os << member_ << "month (" << month << ");"; @@ -1079,7 +664,7 @@ namespace CXX { // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] // - collapse (value_); + LiteralValue::collapse (value_); String hours (value_, 0, 2); String minutes (value_, 3, 2); @@ -1095,10 +680,10 @@ namespace CXX String seconds (value_, 6, e - 6); - strip_zeros (hours); - strip_zeros (minutes); - strip_zeros (seconds); - make_float (seconds); + LiteralValue::strip_zeros (hours); + LiteralValue::strip_zeros (minutes); + LiteralValue::strip_zeros (seconds); + LiteralValue::make_float (seconds); os << member_ << "hours (" << hours << ");" << member_ << "minutes (" << minutes << ");" @@ -1132,8 +717,8 @@ namespace CXX h.append (value_, pos + 1, 2); m.append (value_, pos + 4, 2); - strip_zeros (h); - strip_zeros (m); + LiteralValue::strip_zeros (h); + LiteralValue::strip_zeros (m); } os << member_ << "zone_hours (" << h << ");" @@ -1195,7 +780,7 @@ namespace CXX Void InitValue:: string_sequence_type () { - collapse (value_); + LiteralValue::collapse (value_); if (!value_) return; diff --git a/xsde/cxx/hybrid/default-value.hxx b/xsde/cxx/hybrid/default-value.hxx index 5d8b698..aef9049 100644 --- a/xsde/cxx/hybrid/default-value.hxx +++ b/xsde/cxx/hybrid/default-value.hxx @@ -15,151 +15,6 @@ namespace CXX { namespace Hybrid { - struct LiteralValue: Traversal::Fundamental::Byte, - Traversal::Fundamental::UnsignedByte, - Traversal::Fundamental::Short, - Traversal::Fundamental::UnsignedShort, - Traversal::Fundamental::Int, - Traversal::Fundamental::UnsignedInt, - Traversal::Fundamental::Long, - Traversal::Fundamental::UnsignedLong, - Traversal::Fundamental::Integer, - Traversal::Fundamental::NonPositiveInteger, - Traversal::Fundamental::NonNegativeInteger, - Traversal::Fundamental::PositiveInteger, - Traversal::Fundamental::NegativeInteger, - - Traversal::Fundamental::Boolean, - - Traversal::Fundamental::Float, - Traversal::Fundamental::Double, - Traversal::Fundamental::Decimal, - - Traversal::Fundamental::String, - Traversal::Fundamental::NormalizedString, - Traversal::Fundamental::Token, - Traversal::Fundamental::Name, - Traversal::Fundamental::NameToken, - Traversal::Fundamental::NCName, - Traversal::Fundamental::Language, - - Traversal::Fundamental::Id, - Traversal::Fundamental::IdRef, - Traversal::Fundamental::AnyURI, - Traversal::Fundamental::Entity, - - Context - { - LiteralValue (Context&); - LiteralValue (Context&, Boolean str); - - String - dispatch (SemanticGraph::Node& type, String const& value); - - // Boolean. - // - virtual Void - traverse (SemanticGraph::Fundamental::Boolean&); - - // Integral types. - // - virtual Void - traverse (SemanticGraph::Fundamental::Byte&); - - virtual Void - traverse (SemanticGraph::Fundamental::UnsignedByte&); - - virtual Void - traverse (SemanticGraph::Fundamental::Short&); - - virtual Void - traverse (SemanticGraph::Fundamental::UnsignedShort&); - - virtual Void - traverse (SemanticGraph::Fundamental::Int&); - - virtual Void - traverse (SemanticGraph::Fundamental::UnsignedInt&); - - virtual Void - traverse (SemanticGraph::Fundamental::Long&); - - virtual Void - traverse (SemanticGraph::Fundamental::UnsignedLong&); - - virtual Void - traverse (SemanticGraph::Fundamental::Integer&); - - virtual Void - traverse (SemanticGraph::Fundamental::NonPositiveInteger&); - - virtual Void - traverse (SemanticGraph::Fundamental::NonNegativeInteger&); - - virtual Void - traverse (SemanticGraph::Fundamental::PositiveInteger&); - - virtual Void - traverse (SemanticGraph::Fundamental::NegativeInteger&); - - // Floats. - // - virtual Void - traverse (SemanticGraph::Fundamental::Float&); - - virtual Void - traverse (SemanticGraph::Fundamental::Double&); - - virtual Void - traverse (SemanticGraph::Fundamental::Decimal&); - - // Strings. - // - virtual Void - traverse (SemanticGraph::Fundamental::String&); - - virtual Void - traverse (SemanticGraph::Fundamental::NormalizedString&); - - virtual Void - traverse (SemanticGraph::Fundamental::Token&); - - virtual Void - traverse (SemanticGraph::Fundamental::NameToken&); - - virtual Void - traverse (SemanticGraph::Fundamental::Name&); - - virtual Void - traverse (SemanticGraph::Fundamental::NCName&); - - virtual Void - traverse (SemanticGraph::Fundamental::Language&); - - // ID/IDREF. - // - virtual Void - traverse (SemanticGraph::Fundamental::Id&); - - virtual Void - traverse (SemanticGraph::Fundamental::IdRef&); - - // URI. - // - virtual Void - traverse (SemanticGraph::Fundamental::AnyURI&); - - // Entity. - // - virtual Void - traverse (SemanticGraph::Fundamental::Entity&); - - private: - Boolean str_; - String value_; - String literal_; - }; - struct InitValue: Traversal::List, Traversal::Union, Traversal::Complex, diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx index b8c109a..4d5a481 100644 --- a/xsde/cxx/hybrid/elements.cxx +++ b/xsde/cxx/hybrid/elements.cxx @@ -33,6 +33,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), options (ops), exceptions (!ops.value ()), diff --git a/xsde/cxx/hybrid/parser-name-processor.cxx b/xsde/cxx/hybrid/parser-name-processor.cxx index 3dce6fe..b55e9b8 100644 --- a/xsde/cxx/hybrid/parser-name-processor.cxx +++ b/xsde/cxx/hybrid/parser-name-processor.cxx @@ -48,6 +48,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), impl_suffix_ (ops.value ()), aggr_suffix_ (ops.value ()), diff --git a/xsde/cxx/hybrid/serializer-name-processor.cxx b/xsde/cxx/hybrid/serializer-name-processor.cxx index 41f8885..784a2af 100644 --- a/xsde/cxx/hybrid/serializer-name-processor.cxx +++ b/xsde/cxx/hybrid/serializer-name-processor.cxx @@ -47,6 +47,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), impl_suffix_ (ops.value ()), aggr_suffix_ (ops.value ()), diff --git a/xsde/cxx/hybrid/tree-name-processor.cxx b/xsde/cxx/hybrid/tree-name-processor.cxx index 8fa6aa6..bde0fb7 100644 --- a/xsde/cxx/hybrid/tree-name-processor.cxx +++ b/xsde/cxx/hybrid/tree-name-processor.cxx @@ -50,6 +50,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), stl (!ops.value ()), detach (ops.value ()), diff --git a/xsde/cxx/hybrid/tree-source.cxx b/xsde/cxx/hybrid/tree-source.cxx index 33995c5..78af09e 100644 --- a/xsde/cxx/hybrid/tree-source.cxx +++ b/xsde/cxx/hybrid/tree-source.cxx @@ -642,7 +642,7 @@ namespace CXX : Context (c), var_ (c, TypeName::var_value), ro_ret_ (c, TypeName::ro_ret), - literal_value_ (c), + literal_value_ (c, !stl), init_value_ (c) { } diff --git a/xsde/cxx/hybrid/tree-type-map.cxx b/xsde/cxx/hybrid/tree-type-map.cxx index cf36ce2..c745f05 100644 --- a/xsde/cxx/hybrid/tree-type-map.cxx +++ b/xsde/cxx/hybrid/tree-type-map.cxx @@ -41,6 +41,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()) { } diff --git a/xsde/cxx/parser/elements.cxx b/xsde/cxx/parser/elements.cxx index 25e2032..b5d0d57 100644 --- a/xsde/cxx/parser/elements.cxx +++ b/xsde/cxx/parser/elements.cxx @@ -33,6 +33,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), options (ops), xml_parser (xml_parser_), @@ -223,10 +224,22 @@ namespace CXX } } - if (ub.is_a () || - ub.is_a () || - ub.is_a () || - ub.is_a ()) + if (ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a ()) { if (validation) { diff --git a/xsde/cxx/parser/name-processor.cxx b/xsde/cxx/parser/name-processor.cxx index 42b2863..ccbfa66 100644 --- a/xsde/cxx/parser/name-processor.cxx +++ b/xsde/cxx/parser/name-processor.cxx @@ -46,6 +46,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), skel_suffix_ (ops.value ()), impl_suffix_ (ops.value ()), diff --git a/xsde/cxx/parser/parser-inline.cxx b/xsde/cxx/parser/parser-inline.cxx index d20a3e7..5ebf014 100644 --- a/xsde/cxx/parser/parser-inline.cxx +++ b/xsde/cxx/parser/parser-inline.cxx @@ -67,11 +67,25 @@ namespace CXX } } - if (ub.is_a () || - ub.is_a () || - ub.is_a () || - ub.is_a ()) + if (ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a ()) { + LiteralValue lv (ctx, false); + for (Restricts::FacetIterator i (r.facet_begin ()); i != r.facet_end (); ++i) { @@ -80,19 +94,23 @@ namespace CXX if (i->first == L"minInclusive") { - os << "this->_min_facet (" << i->second << ", true);"; + os << "this->_min_facet (" << lv.dispatch (ub, i->second) << + ", true);"; } else if (i->first == L"minExclusive") { - os << "this->_min_facet (" << i->second << ", false);"; + os << "this->_min_facet (" << lv.dispatch (ub, i->second) << + ", false);"; } else if (i->first == L"maxInclusive") { - os << "this->_max_facet (" << i->second << ", true);"; + os << "this->_max_facet (" << lv.dispatch (ub, i->second) << + ", true);"; } else if (i->first == L"maxExclusive") { - os << "this->_max_facet (" << i->second << ", false);"; + os << "this->_max_facet (" << lv.dispatch (ub, i->second) << + ", false);"; } } } diff --git a/xsde/cxx/serializer/elements.cxx b/xsde/cxx/serializer/elements.cxx index e598f8f..eb03361 100644 --- a/xsde/cxx/serializer/elements.cxx +++ b/xsde/cxx/serializer/elements.cxx @@ -33,6 +33,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), options (ops), xml_serializer (xml_serializer_), @@ -240,10 +241,22 @@ namespace CXX } } - if (ub.is_a () || - ub.is_a () || - ub.is_a () || - ub.is_a ()) + if (ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a ()) { if (validation) { diff --git a/xsde/cxx/serializer/name-processor.cxx b/xsde/cxx/serializer/name-processor.cxx index f7f63a2..e64d149 100644 --- a/xsde/cxx/serializer/name-processor.cxx +++ b/xsde/cxx/serializer/name-processor.cxx @@ -46,6 +46,7 @@ namespace CXX ops.value (), ops.value (), ops.value (), + !ops.value (), ops.value ()), skel_suffix_ (ops.value ()), impl_suffix_ (ops.value ()), diff --git a/xsde/cxx/serializer/serializer-inline.cxx b/xsde/cxx/serializer/serializer-inline.cxx index 4bebc9c..998f0f1 100644 --- a/xsde/cxx/serializer/serializer-inline.cxx +++ b/xsde/cxx/serializer/serializer-inline.cxx @@ -52,11 +52,25 @@ namespace CXX } } - if (ub.is_a () || - ub.is_a () || - ub.is_a () || - ub.is_a ()) + if (ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a () || + ub.is_a ()) { + LiteralValue lv (ctx, false); + for (Restricts::FacetIterator i (r.facet_begin ()); i != r.facet_end (); ++i) { @@ -65,19 +79,23 @@ namespace CXX if (i->first == L"minInclusive") { - os << "this->_min_facet (" << i->second << ", true);"; + os << "this->_min_facet (" << lv.dispatch (ub, i->second) << + ", true);"; } else if (i->first == L"minExclusive") { - os << "this->_min_facet (" << i->second << ", false);"; + os << "this->_min_facet (" << lv.dispatch (ub, i->second) << + ", false);"; } else if (i->first == L"maxInclusive") { - os << "this->_max_facet (" << i->second << ", true);"; + os << "this->_max_facet (" << lv.dispatch (ub, i->second) << + ", true);"; } else if (i->first == L"maxExclusive") { - os << "this->_max_facet (" << i->second << ", false);"; + os << "this->_max_facet (" << lv.dispatch (ub, i->second) << + ", false);"; } } } -- cgit v1.1