aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-03-17 13:10:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-03-17 13:10:42 +0200
commit2fc01f7a270d76177e8653e2b74f8ca1b7711cc3 (patch)
tree93fe46eb145bf8ec8654c28b7a261c01f2eba1b0
parent3ac8660a6e084014d047e1c121305094eace9bfa (diff)
Partial support for simple type facet validation
For now only certain types and facets are supported.
-rw-r--r--libxsde/xsde/cxx/parser/validating/short.cxx21
-rw-r--r--libxsde/xsde/cxx/parser/validating/string-stl.cxx26
-rw-r--r--libxsde/xsde/cxx/parser/validating/string-stl.hxx3
-rw-r--r--libxsde/xsde/cxx/parser/validating/string.cxx26
-rw-r--r--libxsde/xsde/cxx/parser/validating/string.hxx3
-rw-r--r--libxsde/xsde/cxx/parser/validating/unsigned-byte.cxx21
-rw-r--r--libxsde/xsde/cxx/parser/validating/unsigned-int.cxx21
-rw-r--r--libxsde/xsde/cxx/parser/validating/unsigned-short.cxx21
-rw-r--r--libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx180
-rw-r--r--libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx191
-rw-r--r--libxsde/xsde/cxx/schema-error.cxx5
-rw-r--r--libxsde/xsde/cxx/schema-error.hxx5
-rw-r--r--libxsde/xsde/cxx/serializer/validating/short.cxx18
-rw-r--r--libxsde/xsde/cxx/serializer/validating/string-stl.cxx22
-rw-r--r--libxsde/xsde/cxx/serializer/validating/string.cxx27
-rw-r--r--libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx18
-rw-r--r--libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx18
-rw-r--r--libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx18
-rw-r--r--libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx180
-rw-r--r--libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx192
-rw-r--r--xsde/cxx/parser/parser-header.cxx31
-rw-r--r--xsde/cxx/parser/parser-inline.cxx93
-rw-r--r--xsde/cxx/serializer/serializer-header.cxx31
-rw-r--r--xsde/cxx/serializer/serializer-inline.cxx91
24 files changed, 1216 insertions, 46 deletions
diff --git a/libxsde/xsde/cxx/parser/validating/short.cxx b/libxsde/xsde/cxx/parser/validating/short.cxx
index c4b5da0..6b8c38d 100644
--- a/libxsde/xsde/cxx/parser/validating/short.cxx
+++ b/libxsde/xsde/cxx/parser/validating/short.cxx
@@ -49,11 +49,32 @@ namespace xsde
bool neg = (sign_ == minus);
if (*p != '\0' || (neg && ul > 32768) || (!neg && ul > 32767))
+ {
_schema_error (schema_error::invalid_short_value);
+ return;
+ }
value_ = neg
? static_cast<short> (-static_cast<int> (ul))
: static_cast<short> (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_short_value);
diff --git a/libxsde/xsde/cxx/parser/validating/string-stl.cxx b/libxsde/xsde/cxx/parser/validating/string-stl.cxx
index ed91e36..d0d0e14 100644
--- a/libxsde/xsde/cxx/parser/validating/string-stl.cxx
+++ b/libxsde/xsde/cxx/parser/validating/string-stl.cxx
@@ -25,6 +25,32 @@ namespace xsde
str_ += s;
}
+ void string_pimpl::
+ _post ()
+ {
+ // Check facets.
+ //
+ const facets& f = _facets ();
+
+ if (f.length_set_ && str_.size () != f.length_)
+ {
+ _schema_error (schema_error::length_not_equal_prescribed);
+ return;
+ }
+
+ if (f.min_length_set_ && str_.size () < f.min_length_)
+ {
+ _schema_error (schema_error::length_less_than_min);
+ return;
+ }
+
+ if (f.max_length_set_ && str_.size () > f.max_length_)
+ {
+ _schema_error (schema_error::length_greater_than_max);
+ return;
+ }
+ }
+
std::string string_pimpl::
post_string ()
{
diff --git a/libxsde/xsde/cxx/parser/validating/string-stl.hxx b/libxsde/xsde/cxx/parser/validating/string-stl.hxx
index 34e1e03..6cc5798 100644
--- a/libxsde/xsde/cxx/parser/validating/string-stl.hxx
+++ b/libxsde/xsde/cxx/parser/validating/string-stl.hxx
@@ -30,6 +30,9 @@ namespace xsde
virtual void
_characters (const ro_string&);
+ virtual void
+ _post ();
+
virtual std::string
post_string ();
diff --git a/libxsde/xsde/cxx/parser/validating/string.cxx b/libxsde/xsde/cxx/parser/validating/string.cxx
index 0834dc3..c40a7c9 100644
--- a/libxsde/xsde/cxx/parser/validating/string.cxx
+++ b/libxsde/xsde/cxx/parser/validating/string.cxx
@@ -37,6 +37,32 @@ namespace xsde
#endif
}
+ void string_pimpl::
+ _post ()
+ {
+ // Check facets.
+ //
+ const facets& f = _facets ();
+
+ if (f.length_set_ && str_.size () != f.length_)
+ {
+ _schema_error (schema_error::length_not_equal_prescribed);
+ return;
+ }
+
+ if (f.min_length_set_ && str_.size () < f.min_length_)
+ {
+ _schema_error (schema_error::length_less_than_min);
+ return;
+ }
+
+ if (f.max_length_set_ && str_.size () > f.max_length_)
+ {
+ _schema_error (schema_error::length_greater_than_max);
+ return;
+ }
+ }
+
char* string_pimpl::
post_string ()
{
diff --git a/libxsde/xsde/cxx/parser/validating/string.hxx b/libxsde/xsde/cxx/parser/validating/string.hxx
index 677fc10..73d404a 100644
--- a/libxsde/xsde/cxx/parser/validating/string.hxx
+++ b/libxsde/xsde/cxx/parser/validating/string.hxx
@@ -30,6 +30,9 @@ namespace xsde
virtual void
_characters (const ro_string&);
+ virtual void
+ _post ();
+
virtual char*
post_string ();
diff --git a/libxsde/xsde/cxx/parser/validating/unsigned-byte.cxx b/libxsde/xsde/cxx/parser/validating/unsigned-byte.cxx
index 8f1e9c5..1ec4832 100644
--- a/libxsde/xsde/cxx/parser/validating/unsigned-byte.cxx
+++ b/libxsde/xsde/cxx/parser/validating/unsigned-byte.cxx
@@ -47,9 +47,30 @@ namespace xsde
unsigned long ul = strtoul (str_, &p, 10);
if (*p != '\0' || ul > 255)
+ {
_schema_error (schema_error::invalid_unsigned_byte_value);
+ return;
+ }
value_ = static_cast<unsigned char> (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_unsigned_byte_value);
diff --git a/libxsde/xsde/cxx/parser/validating/unsigned-int.cxx b/libxsde/xsde/cxx/parser/validating/unsigned-int.cxx
index 8ffd4b7..df0d0aa 100644
--- a/libxsde/xsde/cxx/parser/validating/unsigned-int.cxx
+++ b/libxsde/xsde/cxx/parser/validating/unsigned-int.cxx
@@ -47,9 +47,30 @@ namespace xsde
unsigned long ul = strtoul (str_, &p, 10);
if (*p != '\0' || get_errno () != 0 || ul > 4294967295UL)
+ {
_schema_error (schema_error::invalid_unsigned_int_value);
+ return;
+ }
value_ = static_cast<unsigned int> (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_unsigned_int_value);
diff --git a/libxsde/xsde/cxx/parser/validating/unsigned-short.cxx b/libxsde/xsde/cxx/parser/validating/unsigned-short.cxx
index 4a92139..01bfbf9 100644
--- a/libxsde/xsde/cxx/parser/validating/unsigned-short.cxx
+++ b/libxsde/xsde/cxx/parser/validating/unsigned-short.cxx
@@ -47,9 +47,30 @@ namespace xsde
unsigned long ul = strtoul (str_, &p, 10);
if (*p != '\0' || ul > 65535)
+ {
_schema_error (schema_error::invalid_unsigned_short_value);
+ return;
+ }
value_ = static_cast<unsigned short> (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_unsigned_short_value);
diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx
index 1c82e00..24a7759 100644
--- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx
+++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx
@@ -159,13 +159,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_byte_pskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_byte_pskel (unsigned_byte_pskel* impl, void*);
protected:
unsigned_byte_pskel* unsigned_byte_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (unsigned char, bool inclusive);
+
+ void
+ _min_facet (unsigned char, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ unsigned char min_;
+ unsigned 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_;
};
@@ -185,13 +212,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
short_pskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
short_pskel (short_pskel* impl, void*);
protected:
short_pskel* short_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (short, bool inclusive);
+
+ void
+ _min_facet (short, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ short min_;
+ short 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_short_pskel: simple_content
@@ -207,13 +261,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_short_pskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_short_pskel (unsigned_short_pskel* impl, void*);
protected:
unsigned_short_pskel* unsigned_short_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (unsigned short, bool inclusive);
+
+ void
+ _min_facet (unsigned short, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ unsigned short min_;
+ unsigned short 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_;
};
@@ -255,13 +336,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_int_pskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_int_pskel (unsigned_int_pskel* impl, void*);
protected:
unsigned_int_pskel* unsigned_int_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (unsigned int, bool inclusive);
+
+ void
+ _min_facet (unsigned int, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ unsigned int min_;
+ unsigned 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_;
};
@@ -562,13 +670,43 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
string_pskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
string_pskel (string_pskel* impl, void*);
protected:
string_pskel* string_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _length_facet (size_t);
+
+ void
+ _max_length_facet (size_t);
+
+ void
+ _min_length_facet (size_t);
+
+ protected:
+ struct facets
+ {
+ size_t length_;
+ size_t min_length_;
+ size_t max_length_;
+
+ unsigned int length_set_ : 1;
+ unsigned int min_length_set_ : 1;
+ unsigned int max_length_set_ : 1;
+ };
+
+ const facets&
+ _facets () const;
+
+ private:
+ facets facets_;
};
struct normalized_string_pskel: simple_content
@@ -853,13 +991,43 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
string_pskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
string_pskel (string_pskel* impl, void*);
protected:
string_pskel* string_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _length_facet (size_t);
+
+ void
+ _max_length_facet (size_t);
+
+ void
+ _min_length_facet (size_t);
+
+ protected:
+ struct facets
+ {
+ size_t length_;
+ size_t min_length_;
+ size_t max_length_;
+
+ unsigned int length_set_ : 1;
+ unsigned int min_length_set_ : 1;
+ unsigned int max_length_set_ : 1;
+ };
+
+ const facets&
+ _facets () const;
+
+ private:
+ facets facets_;
};
struct normalized_string_pskel: simple_content
diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx
index 69abb6e..3d69e15 100644
--- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx
+++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.ixx
@@ -77,51 +77,149 @@ namespace xsde
// unsigned_byte_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_byte_pskel::
unsigned_byte_pskel ()
- : unsigned_byte_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ unsigned_byte_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_byte_pskel::
unsigned_byte_pskel (unsigned_byte_pskel* impl, void*)
: simple_content (impl, 0), unsigned_byte_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
+ }
+#endif
+
+ inline void unsigned_byte_pskel::
+ _max_facet (unsigned char v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void unsigned_byte_pskel::
+ _min_facet (unsigned char v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
}
+
+ inline const unsigned_byte_pskel::facets& unsigned_byte_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const unsigned_byte_pskel&> (*parent_).facets_;
+ else
#endif
+ return facets_;
+ }
// short_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline short_pskel::
short_pskel ()
- : short_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ short_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline short_pskel::
short_pskel (short_pskel* impl, void*)
: simple_content (impl, 0), short_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
#endif
+ inline void short_pskel::
+ _max_facet (short v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void short_pskel::
+ _min_facet (short v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
+ }
+
+ inline const short_pskel::facets& short_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const short_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
+
// unsigned_short_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_short_pskel::
unsigned_short_pskel ()
- : unsigned_short_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ unsigned_short_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_short_pskel::
unsigned_short_pskel (unsigned_short_pskel* impl, void*)
: simple_content (impl, 0), unsigned_short_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
#endif
+ inline void unsigned_short_pskel::
+ _max_facet (unsigned short v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void unsigned_short_pskel::
+ _min_facet (unsigned short v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
+ }
+
+ inline const unsigned_short_pskel::facets& unsigned_short_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const unsigned_short_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
// int_pskel
//
@@ -141,20 +239,53 @@ namespace xsde
// unsigned_int_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_int_pskel::
unsigned_int_pskel ()
- : unsigned_int_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ unsigned_int_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_int_pskel::
unsigned_int_pskel (unsigned_int_pskel* impl, void*)
: simple_content (impl, 0), unsigned_int_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
#endif
+ inline void unsigned_int_pskel::
+ _max_facet (unsigned int v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void unsigned_int_pskel::
+ _min_facet (unsigned int v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
+ }
+
+ inline const unsigned_int_pskel::facets& unsigned_int_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const unsigned_int_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
+
// long_pskel
//
#ifdef XSDE_REUSE_STYLE_TIEIN
@@ -317,20 +448,60 @@ namespace xsde
// string_pskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline string_pskel::
string_pskel ()
- : string_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ string_impl_ = 0;
+#endif
+ facets_.length_set_ = 0;
+ facets_.min_length_set_ = 0;
+ facets_.max_length_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline string_pskel::
string_pskel (string_pskel* impl, void*)
: simple_content (impl, 0), string_impl_ (impl)
{
+ facets_.length_set_ = 0;
+ facets_.min_length_set_ = 0;
+ facets_.max_length_set_ = 0;
}
#endif
+ inline void string_pskel::
+ _length_facet (size_t v)
+ {
+ facets_.length_ = v;
+ facets_.length_set_ = 1;
+ }
+
+ inline void string_pskel::
+ _max_length_facet (size_t v)
+ {
+ facets_.max_length_ = v;
+ facets_.max_length_set_ = 1;
+ }
+
+ inline void string_pskel::
+ _min_length_facet (size_t v)
+ {
+ facets_.min_length_ = v;
+ facets_.min_length_set_ = 1;
+ }
+
+ inline const string_pskel::facets& string_pskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const string_pskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
+
// normalized_string_pskel
//
#ifdef XSDE_REUSE_STYLE_TIEIN
diff --git a/libxsde/xsde/cxx/schema-error.cxx b/libxsde/xsde/cxx/schema-error.cxx
index 940c9c7..c347fa1 100644
--- a/libxsde/xsde/cxx/schema-error.cxx
+++ b/libxsde/xsde/cxx/schema-error.cxx
@@ -56,6 +56,11 @@ namespace xsde
"invalid time value",
"invalid dateTime value",
"invalid duration value",
+ "value is greater than maximum allowed",
+ "value is less than minimum allowed",
+ "length is greater than maximum allowed",
+ "length is less than minimum allowed",
+ "length is not equal to prescribed length",
"invalid xsi:type attribute",
"dynamic and static types are not related by inheritance"
};
diff --git a/libxsde/xsde/cxx/schema-error.hxx b/libxsde/xsde/cxx/schema-error.hxx
index 6097e69..8569e49 100644
--- a/libxsde/xsde/cxx/schema-error.hxx
+++ b/libxsde/xsde/cxx/schema-error.hxx
@@ -59,6 +59,11 @@ namespace xsde
invalid_time_value,
invalid_date_time_value,
invalid_duration_value,
+ value_greater_than_max,
+ value_less_than_min,
+ length_greater_than_max,
+ length_less_than_min,
+ length_not_equal_prescribed,
invalid_xsi_type,
not_derived
};
diff --git a/libxsde/xsde/cxx/serializer/validating/short.cxx b/libxsde/xsde/cxx/serializer/validating/short.cxx
index 1fea40f..1189cd5 100644
--- a/libxsde/xsde/cxx/serializer/validating/short.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/short.cxx
@@ -24,6 +24,24 @@ namespace xsde
void short_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("-32768") + 1 characters to hold all
// representations of short.
//
diff --git a/libxsde/xsde/cxx/serializer/validating/string-stl.cxx b/libxsde/xsde/cxx/serializer/validating/string-stl.cxx
index fe87f7d..1e9a37b 100644
--- a/libxsde/xsde/cxx/serializer/validating/string-stl.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/string-stl.cxx
@@ -22,6 +22,28 @@ namespace xsde
void string_simpl::
_serialize_content ()
{
+ // Check facets.
+ //
+ const facets& f = _facets ();
+
+ if (f.length_set_ && value_.size () != f.length_)
+ {
+ _schema_error (schema_error::length_not_equal_prescribed);
+ return;
+ }
+
+ if (f.min_length_set_ && value_.size () < f.min_length_)
+ {
+ _schema_error (schema_error::length_less_than_min);
+ return;
+ }
+
+ if (f.max_length_set_ && value_.size () > f.max_length_)
+ {
+ _schema_error (schema_error::length_greater_than_max);
+ return;
+ }
+
// Make sure we don't hold any references to the string.
//
std::string tmp;
diff --git a/libxsde/xsde/cxx/serializer/validating/string.cxx b/libxsde/xsde/cxx/serializer/validating/string.cxx
index 8082baa..0def094 100644
--- a/libxsde/xsde/cxx/serializer/validating/string.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/string.cxx
@@ -3,6 +3,7 @@
// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <string.h> // strlen
#include <xsde/cxx/serializer/validating/string.hxx>
namespace xsde
@@ -29,6 +30,32 @@ namespace xsde
void string_simpl::
_serialize_content ()
{
+ // Check facets.
+ //
+ if (length_set_ || min_length_set_ || max_length_set_)
+ {
+ size_t n = strlen (value_);
+ const facets& f = _facets ();
+
+ if (f.length_set_ && n != f.length_)
+ {
+ _schema_error (schema_error::length_not_equal_prescribed);
+ return;
+ }
+
+ if (f.min_length_set_ && n < f.min_length_)
+ {
+ _schema_error (schema_error::length_less_than_min);
+ return;
+ }
+
+ if (f.max_length_set_ && n > f.max_length_)
+ {
+ _schema_error (schema_error::length_greater_than_max);
+ return;
+ }
+ }
+
_characters (value_);
if (free_)
diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx
index 8a8f74e..bc8e5f9 100644
--- a/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/unsigned-byte.cxx
@@ -24,6 +24,24 @@ namespace xsde
void unsigned_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("256") + 1 characters to hold all
// representations of unsigned byte.
//
diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx
index 0aece87..596dc0d 100644
--- a/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/unsigned-int.cxx
@@ -24,6 +24,24 @@ namespace xsde
void unsigned_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("4294967295") + 1 characters to hold all
// representations of unsigned int.
//
diff --git a/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx b/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx
index 4996128..3a96372 100644
--- a/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/unsigned-short.cxx
@@ -24,6 +24,24 @@ namespace xsde
void unsigned_short_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("65535") + 1 characters to hold all
// representations of short.
//
diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx
index 9f2a98e..c0b77d6 100644
--- a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx
+++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.hxx
@@ -149,13 +149,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_byte_sskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_byte_sskel (unsigned_byte_sskel* impl, void*);
protected:
unsigned_byte_sskel* unsigned_byte_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (unsigned char, bool inclusive);
+
+ void
+ _min_facet (unsigned char, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ unsigned char min_;
+ unsigned 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_;
};
@@ -175,13 +202,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
short_sskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
short_sskel (short_sskel* impl, void*);
protected:
short_sskel* short_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (short, bool inclusive);
+
+ void
+ _min_facet (short, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ short min_;
+ short 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_short_sskel: simple_content
@@ -197,13 +251,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_short_sskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_short_sskel (unsigned_short_sskel* impl, void*);
protected:
unsigned_short_sskel* unsigned_short_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (unsigned short, bool inclusive);
+
+ void
+ _min_facet (unsigned short, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ unsigned short min_;
+ unsigned short 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_;
};
// 32-bit
@@ -244,13 +325,40 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_int_sskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
unsigned_int_sskel (unsigned_int_sskel* impl, void*);
protected:
unsigned_int_sskel* unsigned_int_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _max_facet (unsigned int, bool inclusive);
+
+ void
+ _min_facet (unsigned int, bool inclusive);
+
+ protected:
+ struct facets
+ {
+ unsigned int min_;
+ unsigned 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_;
};
// 64-bit
@@ -545,13 +653,43 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
string_sskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
string_sskel (string_sskel* impl, void*);
protected:
string_sskel* string_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _length_facet (size_t);
+
+ void
+ _max_length_facet (size_t);
+
+ void
+ _min_length_facet (size_t);
+
+ protected:
+ struct facets
+ {
+ size_t length_;
+ size_t min_length_;
+ size_t max_length_;
+
+ unsigned int length_set_ : 1;
+ unsigned int min_length_set_ : 1;
+ unsigned int max_length_set_ : 1;
+ };
+
+ const facets&
+ _facets () const;
+
+ private:
+ facets facets_;
};
#ifdef XSDE_REUSE_STYLE_MIXIN
@@ -841,13 +979,43 @@ namespace xsde
_dynamic_type () const;
#endif
-#ifdef XSDE_REUSE_STYLE_TIEIN
string_sskel ();
+
+#ifdef XSDE_REUSE_STYLE_TIEIN
string_sskel (string_sskel* impl, void*);
protected:
string_sskel* string_impl_;
#endif
+ // Facets.
+ //
+ public:
+ void
+ _length_facet (size_t);
+
+ void
+ _max_length_facet (size_t);
+
+ void
+ _min_length_facet (size_t);
+
+ protected:
+ struct facets
+ {
+ size_t length_;
+ size_t min_length_;
+ size_t max_length_;
+
+ unsigned int length_set_ : 1;
+ unsigned int min_length_set_ : 1;
+ unsigned int max_length_set_ : 1;
+ };
+
+ const facets&
+ _facets () const;
+
+ private:
+ facets facets_;
};
#ifdef XSDE_REUSE_STYLE_MIXIN
diff --git a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx
index 1ea39b0..fd84bf0 100644
--- a/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx
+++ b/libxsde/xsde/cxx/serializer/validating/xml-schema-sskel.ixx
@@ -77,51 +77,150 @@ namespace xsde
// unsigned_byte_sskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_byte_sskel::
unsigned_byte_sskel ()
- : unsigned_byte_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ unsigned_byte_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_byte_sskel::
unsigned_byte_sskel (unsigned_byte_sskel* impl, void*)
: simple_content (impl, 0), unsigned_byte_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
+ }
+#endif
+
+ inline void unsigned_byte_sskel::
+ _max_facet (unsigned char v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void unsigned_byte_sskel::
+ _min_facet (unsigned char v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
}
+
+ inline const unsigned_byte_sskel::facets& unsigned_byte_sskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const unsigned_byte_sskel&> (*parent_).facets_;
+ else
#endif
+ return facets_;
+ }
// short_sskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline short_sskel::
short_sskel ()
- : short_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ short_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline short_sskel::
short_sskel (short_sskel* impl, void*)
: simple_content (impl, 0), short_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
#endif
+ inline void short_sskel::
+ _max_facet (short v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void short_sskel::
+ _min_facet (short v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
+ }
+
+ inline const short_sskel::facets& short_sskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const short_sskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
+
// unsigned_short_sskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_short_sskel::
unsigned_short_sskel ()
- : unsigned_short_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ unsigned_short_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_short_sskel::
unsigned_short_sskel (unsigned_short_sskel* impl, void*)
: simple_content (impl, 0), unsigned_short_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
+ }
+#endif
+
+ inline void unsigned_short_sskel::
+ _max_facet (unsigned short v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void unsigned_short_sskel::
+ _min_facet (unsigned short v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
}
+
+ inline const unsigned_short_sskel::facets& unsigned_short_sskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const unsigned_short_sskel&> (*parent_).facets_;
+ else
#endif
+ return facets_;
+ }
// int_sskel
//
@@ -141,20 +240,53 @@ namespace xsde
// unsigned_int_sskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_int_sskel::
unsigned_int_sskel ()
- : unsigned_int_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ unsigned_int_impl_ = 0;
+#endif
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline unsigned_int_sskel::
unsigned_int_sskel (unsigned_int_sskel* impl, void*)
: simple_content (impl, 0), unsigned_int_impl_ (impl)
{
+ facets_.min_set_ = 0;
+ facets_.max_set_ = 0;
}
#endif
+ inline void unsigned_int_sskel::
+ _max_facet (unsigned int v, bool inc)
+ {
+ facets_.max_ = v;
+ facets_.max_set_ = 1;
+ facets_.max_inc_ = inc;
+ }
+
+ inline void unsigned_int_sskel::
+ _min_facet (unsigned int v, bool inc)
+ {
+ facets_.min_ = v;
+ facets_.min_set_ = 1;
+ facets_.min_inc_ = inc;
+ }
+
+ inline const unsigned_int_sskel::facets& unsigned_int_sskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const unsigned_int_sskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
+
// long_sskel
//
#ifdef XSDE_REUSE_STYLE_TIEIN
@@ -317,20 +449,60 @@ namespace xsde
// string_sskel
//
-#ifdef XSDE_REUSE_STYLE_TIEIN
inline string_sskel::
string_sskel ()
- : string_impl_ (0)
{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ string_impl_ = 0;
+#endif
+ facets_.length_set_ = 0;
+ facets_.min_length_set_ = 0;
+ facets_.max_length_set_ = 0;
}
+#ifdef XSDE_REUSE_STYLE_TIEIN
inline string_sskel::
string_sskel (string_sskel* impl, void*)
: simple_content (impl, 0), string_impl_ (impl)
{
+ facets_.length_set_ = 0;
+ facets_.min_length_set_ = 0;
+ facets_.max_length_set_ = 0;
}
#endif
+ inline void string_sskel::
+ _length_facet (size_t v)
+ {
+ facets_.length_ = v;
+ facets_.length_set_ = 1;
+ }
+
+ inline void string_sskel::
+ _max_length_facet (size_t v)
+ {
+ facets_.max_length_ = v;
+ facets_.max_length_set_ = 1;
+ }
+
+ inline void string_sskel::
+ _min_length_facet (size_t v)
+ {
+ facets_.min_length_ = v;
+ facets_.min_length_set_ = 1;
+ }
+
+ inline const string_sskel::facets& string_sskel::
+ _facets () const
+ {
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ if (parent_ != 0)
+ return static_cast<const string_sskel&> (*parent_).facets_;
+ else
+#endif
+ return facets_;
+ }
+
// normalized_string_sskel
//
#ifdef XSDE_REUSE_STYLE_TIEIN
diff --git a/xsde/cxx/parser/parser-header.cxx b/xsde/cxx/parser/parser-header.cxx
index 6ef9578..34f2119 100644
--- a/xsde/cxx/parser/parser-header.cxx
+++ b/xsde/cxx/parser/parser-header.cxx
@@ -724,6 +724,35 @@ namespace CXX
names (c, names_test);
}
+ Boolean facets (false); // Defines facets.
+ if (validation && restriction)
+ {
+ SemanticGraph::Type& ub (ultimate_base (c));
+
+ if (ub.is_a<SemanticGraph::Fundamental::Short> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedByte> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedShort> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedInt> () ||
+ ub.is_a<SemanticGraph::Fundamental::String> ())
+ {
+ using SemanticGraph::Restricts;
+ Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
+
+ if (!r.facet_empty ())
+ {
+ Restricts::FacetIterator end (r.facet_end ());
+ facets =
+ r.facet_find (L"length") != end ||
+ r.facet_find (L"minLength") != end ||
+ r.facet_find (L"maxLength") != end ||
+ r.facet_find (L"minInclusive") != end ||
+ r.facet_find (L"minExclusive") != end ||
+ r.facet_find (L"maxInclusive") != end ||
+ r.facet_find (L"maxExclusive") != end;
+ }
+ }
+ }
+
//
//
os << "class " << name << ": public ";
@@ -824,7 +853,7 @@ namespace CXX
// Default c-tor.
//
- if (tiein ||
+ if (tiein || facets ||
(!restriction && (he || ha)) ||
(validation && (he || hae || hra)))
{
diff --git a/xsde/cxx/parser/parser-inline.cxx b/xsde/cxx/parser/parser-inline.cxx
index 31332bd..def8434 100644
--- a/xsde/cxx/parser/parser-inline.cxx
+++ b/xsde/cxx/parser/parser-inline.cxx
@@ -431,7 +431,36 @@ namespace CXX
Boolean restriction (restriction_p (c));
- if (!(tiein ||
+ Boolean facets (false); // Defines facets.
+ if (validation && restriction)
+ {
+ SemanticGraph::Type& ub (ultimate_base (c));
+
+ if (ub.is_a<SemanticGraph::Fundamental::Short> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedByte> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedShort> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedInt> () ||
+ ub.is_a<SemanticGraph::Fundamental::String> ())
+ {
+ using SemanticGraph::Restricts;
+ Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
+
+ if (!r.facet_empty ())
+ {
+ Restricts::FacetIterator end (r.facet_end ());
+ facets =
+ r.facet_find (L"length") != end ||
+ r.facet_find (L"minLength") != end ||
+ r.facet_find (L"maxLength") != end ||
+ r.facet_find (L"minInclusive") != end ||
+ r.facet_find (L"minExclusive") != end ||
+ r.facet_find (L"maxInclusive") != end ||
+ r.facet_find (L"maxExclusive") != end;
+ }
+ }
+ }
+
+ if (!(tiein || facets ||
(!restriction && (he || ha)) ||
(validation && (he || hae || hra))))
return;
@@ -498,7 +527,10 @@ namespace CXX
else
os << name << " ()" << endl;
- os << ": ";
+ if (tiein ||
+ (!restriction && (he || ha)) ||
+ (validation && (he || hae || hra)))
+ os << ": ";
Boolean comma (false);
@@ -570,8 +602,12 @@ namespace CXX
"&v_state_attr_first_)";
}
- os << "{"
- << "}";
+ os << "{";
+
+ if (facets)
+ facet_calls (c);
+
+ os << "}";
// Tiein c-tor.
//
@@ -644,8 +680,53 @@ namespace CXX
"&v_state_attr_first_)";
}
- os << "{"
- << "}";
+ os << "{";
+
+ if (facets)
+ facet_calls (c);
+
+ os << "}";
+ }
+ }
+
+ private:
+ Void
+ facet_calls (Type& c)
+ {
+ using SemanticGraph::Restricts;
+ Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
+
+ for (Restricts::FacetIterator i (r.facet_begin ());
+ i != r.facet_end (); ++i)
+ {
+ if (i->first == L"length")
+ {
+ os << "this->_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"minLength")
+ {
+ os << "this->_min_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"maxLength")
+ {
+ os << "this->_max_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"minInclusive")
+ {
+ os << "this->_min_facet (" << i->second << ", true);";
+ }
+ else if (i->first == L"minExclusive")
+ {
+ os << "this->_min_facet (" << i->second << ", false);";
+ }
+ else if (i->first == L"maxInclusive")
+ {
+ os << "this->_max_facet (" << i->second << ", true);";
+ }
+ else if (i->first == L"maxExclusive")
+ {
+ os << "this->_max_facet (" << i->second << ", false);";
+ }
}
}
diff --git a/xsde/cxx/serializer/serializer-header.cxx b/xsde/cxx/serializer/serializer-header.cxx
index 29b01a2..5459b51 100644
--- a/xsde/cxx/serializer/serializer-header.cxx
+++ b/xsde/cxx/serializer/serializer-header.cxx
@@ -1030,6 +1030,35 @@ namespace CXX
names (c, names_test);
}
+ Boolean facets (false); // Defines facets.
+ if (validation && restriction)
+ {
+ SemanticGraph::Type& ub (ultimate_base (c));
+
+ if (ub.is_a<SemanticGraph::Fundamental::Short> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedByte> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedShort> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedInt> () ||
+ ub.is_a<SemanticGraph::Fundamental::String> ())
+ {
+ using SemanticGraph::Restricts;
+ Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
+
+ if (!r.facet_empty ())
+ {
+ Restricts::FacetIterator end (r.facet_end ());
+ facets =
+ r.facet_find (L"length") != end ||
+ r.facet_find (L"minLength") != end ||
+ r.facet_find (L"maxLength") != end ||
+ r.facet_find (L"minInclusive") != end ||
+ r.facet_find (L"minExclusive") != end ||
+ r.facet_find (L"maxInclusive") != end ||
+ r.facet_find (L"maxExclusive") != end;
+ }
+ }
+ }
+
//
//
os << "class " << name << ": public ";
@@ -1148,7 +1177,7 @@ namespace CXX
// Default c-tor.
//
- if (tiein || (!restriction && (he || ha)))
+ if (tiein || facets || (!restriction && (he || ha)))
{
os << "// Constructor." << endl
<< "//" << endl;
diff --git a/xsde/cxx/serializer/serializer-inline.cxx b/xsde/cxx/serializer/serializer-inline.cxx
index b6bd696..3ff9bab 100644
--- a/xsde/cxx/serializer/serializer-inline.cxx
+++ b/xsde/cxx/serializer/serializer-inline.cxx
@@ -394,7 +394,36 @@ namespace CXX
Boolean ha (has<Traversal::Attribute> (c));
Boolean restriction (restriction_p (c));
- if (!(tiein || (!restriction && (he || ha))))
+ Boolean facets (false); // Defines facets.
+ if (validation && restriction)
+ {
+ SemanticGraph::Type& ub (ultimate_base (c));
+
+ if (ub.is_a<SemanticGraph::Fundamental::Short> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedByte> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedShort> () ||
+ ub.is_a<SemanticGraph::Fundamental::UnsignedInt> () ||
+ ub.is_a<SemanticGraph::Fundamental::String> ())
+ {
+ using SemanticGraph::Restricts;
+ Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
+
+ if (!r.facet_empty ())
+ {
+ Restricts::FacetIterator end (r.facet_end ());
+ facets =
+ r.facet_find (L"length") != end ||
+ r.facet_find (L"minLength") != end ||
+ r.facet_find (L"maxLength") != end ||
+ r.facet_find (L"minInclusive") != end ||
+ r.facet_find (L"minExclusive") != end ||
+ r.facet_find (L"maxInclusive") != end ||
+ r.facet_find (L"maxExclusive") != end;
+ }
+ }
+ }
+
+ if (!(tiein || facets || (!restriction && (he || ha))))
return;
String const& name (ename (c));
@@ -458,7 +487,8 @@ namespace CXX
else
os << name << " ()" << endl;
- os << ": ";
+ if (tiein || (!restriction && (he || ha)))
+ os << ": ";
Boolean comma (false);
@@ -507,8 +537,12 @@ namespace CXX
}
}
- os << "{"
- << "}";
+ os << "{";
+
+ if (facets)
+ facet_calls (c);
+
+ os << "}";
// Tiein c-tor.
//
@@ -558,8 +592,53 @@ namespace CXX
}
}
- os << "{"
- << "}";
+ os << "{";
+
+ if (facets)
+ facet_calls (c);
+
+ os << "}";
+ }
+ }
+
+ private:
+ Void
+ facet_calls (Type& c)
+ {
+ using SemanticGraph::Restricts;
+ Restricts& r (dynamic_cast<Restricts&> (c.inherits ()));
+
+ for (Restricts::FacetIterator i (r.facet_begin ());
+ i != r.facet_end (); ++i)
+ {
+ if (i->first == L"length")
+ {
+ os << "this->_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"minLength")
+ {
+ os << "this->_min_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"maxLength")
+ {
+ os << "this->_max_length_facet (" << i->second << "UL);";
+ }
+ else if (i->first == L"minInclusive")
+ {
+ os << "this->_min_facet (" << i->second << ", true);";
+ }
+ else if (i->first == L"minExclusive")
+ {
+ os << "this->_min_facet (" << i->second << ", false);";
+ }
+ else if (i->first == L"maxInclusive")
+ {
+ os << "this->_max_facet (" << i->second << ", true);";
+ }
+ else if (i->first == L"maxExclusive")
+ {
+ os << "this->_max_facet (" << i->second << ", false);";
+ }
}
}