diff options
Diffstat (limited to 'xsde/cxx/serializer/serializer-inline.cxx')
-rw-r--r-- | xsde/cxx/serializer/serializer-inline.cxx | 91 |
1 files changed, 85 insertions, 6 deletions
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);"; + } } } |