diff options
Diffstat (limited to 'xsde/cxx/parser/parser-inline.cxx')
-rw-r--r-- | xsde/cxx/parser/parser-inline.cxx | 162 |
1 files changed, 79 insertions, 83 deletions
diff --git a/xsde/cxx/parser/parser-inline.cxx b/xsde/cxx/parser/parser-inline.cxx index 528ff86..984eca6 100644 --- a/xsde/cxx/parser/parser-inline.cxx +++ b/xsde/cxx/parser/parser-inline.cxx @@ -14,6 +14,61 @@ namespace CXX { namespace { + Void + facet_calls (SemanticGraph::Complex& c, Context& ctx) + { + std::wostream& os (ctx.os); + + 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);"; + } + else if (i->first == L"whiteSpace") + { + os << "this->_whitespace_facet ("; + + if (i->second == L"preserve") + os << "0"; + else if (i->second == L"replace") + os << "1"; + else if (i->second == L"collapse") + os << "2"; + + os << ");"; + } + } + } + struct Enumeration: Traversal::Enumeration, Context { Enumeration (Context& c) @@ -26,21 +81,23 @@ namespace CXX { String const& name (ename (e)); - Boolean facets (false); // Whether we need to set facets. + Boolean enum_facets (false); // Whether we need to set enum facets. if (validation) { - StringBasedType t (facets); + StringBasedType t (enum_facets); t.dispatch (e); } UnsignedLong enum_count (0); - if (facets) + if (enum_facets) { for (Type::NamesIterator i (e.names_begin ()), end (e.names_end ()); i != end; ++i) ++enum_count; } + Boolean facets (enum_facets || has_facets (e)); + if (facets || tiein) os << "// " << name << endl << "//" << endl @@ -51,10 +108,9 @@ namespace CXX os << inl << name << "::" << endl << name << " ()" << endl - << "{" - << "this->_enumeration_facet (_xsde_" << name << "_enums_, " << - enum_count << "UL);" - << "}"; + << "{"; + facet_calls (e, enum_count); + os << "}"; } if (tiein) @@ -76,8 +132,7 @@ namespace CXX << "{"; if (facets) - os << "this->_enumeration_facet (_xsde_" << name << - "_enums_, " << enum_count << "UL);"; + facet_calls (e, enum_count); os << "}"; @@ -89,12 +144,22 @@ namespace CXX << "{"; if (facets) - os << "this->_enumeration_facet (_xsde_" << name << - "_enums_, " << enum_count << "UL);"; + facet_calls (e, enum_count); os << "}"; } } + + private: + Void + facet_calls (Type& e, UnsignedLong enum_count) + { + Parser::facet_calls (e, *this); + + if (enum_count != 0) + os << "this->_enumeration_facet (_xsde_" << ename (e) << + "_enums_, " << enum_count << "UL);"; + } }; // @@ -454,6 +519,7 @@ namespace CXX traverse (Type& c) { Boolean hb (c.inherits_p ()); + Boolean facets (has_facets (c)); Boolean he (has<Traversal::Element> (c)); Boolean ha (has<Traversal::Attribute> (c)); @@ -469,35 +535,6 @@ namespace CXX Boolean restriction (restriction_p (c)); - 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)))) @@ -643,7 +680,7 @@ namespace CXX os << "{"; if (facets) - facet_calls (c); + facet_calls (c, *this); os << "}"; @@ -721,54 +758,13 @@ namespace CXX os << "{"; if (facets) - facet_calls (c); + facet_calls (c, *this); 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);"; - } - } - } - - private: // // Traversal::Compositor compositor_accessor_; |