From 884dea7531962b17ef843ac2175faa050e8b0758 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Apr 2014 12:57:06 +0200 Subject: Add support for ordered types, mixed content --- xsd/cxx/tree/elements.hxx | 71 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'xsd/cxx/tree/elements.hxx') diff --git a/xsd/cxx/tree/elements.hxx b/xsd/cxx/tree/elements.hxx index f3f9f66..6874e6a 100644 --- a/xsd/cxx/tree/elements.hxx +++ b/xsd/cxx/tree/elements.hxx @@ -6,6 +6,7 @@ #define CXX_TREE_ELEMENTS_HXX #include +#include #include #include #include @@ -68,6 +69,54 @@ namespace CXX String reason_; }; + // A set of potentially qualified XML Schema type names. + // + struct TypeNameSet + { + template + TypeNameSet (I begin, I end) + { + for (; begin != end; ++begin) + insert (*begin); + } + + void + insert (String const& name) + { + size_t p (name.rfind ('#')); + + if (p == String::npos) + unames_.insert (name); + else + qnames_.insert (name); + } + + bool + find (SemanticGraph::Type& t) + { + if (!unames_.empty ()) + { + if (unames_.find (t.name ()) != unames_.end ()) + return true; + } + + if (!qnames_.empty ()) + { + if (qnames_.find (t.scope ().name () + L"#" + t.name ()) != + qnames_.end ()) + return true; + } + + return false; + } + + private: + typedef std::set StringSet; + + StringSet unames_; + StringSet qnames_; + }; + // // class Context: public CXX::Context @@ -157,6 +206,22 @@ namespace CXX // // public: + static bool + ordered_p (SemanticGraph::Type const& t) + { + return t.context ().count ("ordered") && + t.context ().get ("ordered"); + } + + // Check if we are generating mixed support for this type. We only + // do it for ordered types. + // + static bool + mixed_p (SemanticGraph::Complex const& c) + { + return c.mixed_p () && ordered_p (c); + } + bool polymorphic_p (SemanticGraph::Type&); @@ -1338,7 +1403,11 @@ namespace CXX virtual void traverse (SemanticGraph::Complex& c) { - names (c, names_); + if (c.mixed_p ()) + v_ = false; + + if (v_) + names (c, names_); if (v_) inherits (c, inherits_); -- cgit v1.1