aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/serializer/serializer-inline.cxx
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 /xsde/cxx/serializer/serializer-inline.cxx
parent3ac8660a6e084014d047e1c121305094eace9bfa (diff)
Partial support for simple type facet validation
For now only certain types and facets are supported.
Diffstat (limited to 'xsde/cxx/serializer/serializer-inline.cxx')
-rw-r--r--xsde/cxx/serializer/serializer-inline.cxx91
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);";
+ }
}
}