diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:25:44 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:25:44 +0200 |
commit | 8286ac511144e4f17d34eac9affb97e50646344a (patch) | |
tree | f1af7320d7b6be6be059216d0ad08ac7b4f73fd0 /xsd/xsd/cxx/tree/tree-source.cxx | |
parent | a15cf65c44d5c224169c32ef5495b68c758134b7 (diff) |
Imported Upstream version 4.0.0upstream/4.0.0
Diffstat (limited to 'xsd/xsd/cxx/tree/tree-source.cxx')
-rw-r--r-- | xsd/xsd/cxx/tree/tree-source.cxx | 1100 |
1 files changed, 756 insertions, 344 deletions
diff --git a/xsd/xsd/cxx/tree/tree-source.cxx b/xsd/xsd/cxx/tree/tree-source.cxx index 4a17b00..8a01c5a 100644 --- a/xsd/xsd/cxx/tree/tree-source.cxx +++ b/xsd/xsd/cxx/tree/tree-source.cxx @@ -1,9 +1,9 @@ // file : xsd/cxx/tree/tree-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include <cult/containers/list.hxx> +#include <map> +#include <list> #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> @@ -11,6 +11,8 @@ #include <cxx/tree/tree-source.hxx> #include <cxx/tree/default-value.hxx> +using namespace std; + namespace CXX { namespace Tree @@ -24,7 +26,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String name (ename (l)); @@ -39,7 +41,7 @@ namespace CXX << "//" << endl << endl; - if (!options.value<CLI::suppress_parsing> ()) + if (!options.suppress_parsing ()) { SemanticGraph::Type& item_type (l.argumented ().type ()); String base (L"::xsd::cxx::tree::list< " + @@ -105,27 +107,35 @@ namespace CXX // Register with type factory map. // - if (polymorphic && polymorphic_p (l) && !anonymous_p (l)) + if (polymorphic && polymorphic_p (l)) { // Note that we are using the original type name. // String const& name (ename (l)); - if (!options.value<CLI::suppress_parsing> ()) + // If this type is anonymous but substitutes, then it will + // be registered as part of the substitution registration. + // + if (!anonymous_p (l) && !options.suppress_parsing ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::type_factory_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::type_factory_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_type_factory_init (" << endl << strlit (l.name ()) << "," << endl << strlit (xml_ns_name (l)) << ");" << endl; + } - if (options.value<CLI::generate_comparison> ()) + if ((!anonymous_p (l) || anonymous_substitutes_p (l)) && + options.generate_comparison ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::comparison_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::comparison_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_comparison_init;" << endl; + } } } @@ -150,7 +160,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String name (ename (u)); @@ -167,7 +177,7 @@ namespace CXX << "//" << endl << endl; - if (!options.value<CLI::suppress_parsing> ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -212,27 +222,35 @@ namespace CXX // Register with type factory map. // - if (polymorphic && polymorphic_p (u) && !anonymous_p (u)) + if (polymorphic && polymorphic_p (u)) { // Note that we are using the original type name. // String const& name (ename (u)); - if (!options.value<CLI::suppress_parsing> ()) + // If this type is anonymous but substitutes, then it will + // be registered as part of the substitution registration. + // + if (!anonymous_p (u) && !options.suppress_parsing ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::type_factory_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::type_factory_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_type_factory_init (" << endl << strlit (u.name ()) << "," << endl << strlit (xml_ns_name (u)) << ");" << endl; + } - if (options.value<CLI::generate_comparison> ()) + if ((!anonymous_p (u) || anonymous_substitutes_p (u)) && + options.generate_comparison ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::comparison_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::comparison_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_comparison_init;" << endl; + } } } }; @@ -248,7 +266,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { os << strlit (e.name ()); @@ -269,13 +287,13 @@ namespace CXX String name_; }; - Boolean + bool operator< (LiteralInfo const& x, LiteralInfo const& y) { return x.value_ < y.value_; } - typedef Cult::Containers::List<LiteralInfo> LiteralInfoList; + typedef list<LiteralInfo> LiteralInfoList; // Populate LiteralInfoList @@ -288,7 +306,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { list_.push_back (LiteralInfo (e.name (), ename (e))); @@ -307,7 +325,7 @@ namespace CXX names_enumerator_literal_ >> enumerator_literal_; } - virtual Void + virtual void traverse (Type& e) { String name (ename (e)); @@ -318,14 +336,14 @@ namespace CXX if (renamed_type (e, name) && !name) return; - Boolean string_based (false); + bool string_based (false); { IsStringBasedType t (string_based); t.dispatch (e); } SemanticGraph::Enumeration* be (0); - Boolean enum_based (false); + bool enum_based (false); if (string_based) { IsEnumBasedType t (be); @@ -338,7 +356,7 @@ namespace CXX if (string_based) value = evalue (e); - UnsignedLong enum_count (0); + size_t enum_count (0); for (Type::NamesIterator i (e.names_begin ()), end (e.names_end ()); i != end; ++i) @@ -359,7 +377,7 @@ namespace CXX << "//" << endl << endl; - if (!options.value<CLI::suppress_parsing> ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -490,7 +508,7 @@ namespace CXX String fq_name (ns_scope + L"::" + name); - for (LiteralInfoList::Iterator + for (LiteralInfoList::iterator b (l.begin ()), i (b), end (l.end ()); i != end; ++i) { if (i != b) @@ -504,31 +522,39 @@ namespace CXX // Register with type factory map. // - if (polymorphic && polymorphic_p (e) && !anonymous_p (e)) + if (polymorphic && polymorphic_p (e)) { // Note that we are using the original type name. // String const& name (ename (e)); - if (!options.value<CLI::suppress_parsing> ()) + // If this type is anonymous but substitutes, then it will + // be registered as part of the substitution registration. + // + if (!anonymous_p (e) && !options.suppress_parsing ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::type_factory_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::type_factory_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_type_factory_init (" << endl << strlit (e.name ()) << "," << endl << strlit (xml_ns_name (e)) << ");" << endl; + } - if (options.value<CLI::generate_comparison> ()) + if ((!anonymous_p (e) || anonymous_substitutes_p (e)) && + options.generate_comparison ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::comparison_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::comparison_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_comparison_init;" << endl; + } } } - virtual Void + virtual void comma (Type&) { os << "," << endl; @@ -549,7 +575,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -560,7 +586,7 @@ namespace CXX if (m.default_p ()) { SemanticGraph::Type& t (m.type ()); - Boolean simple (true); + bool simple (true); if (m.is_a<SemanticGraph::Element> ()) { @@ -570,7 +596,7 @@ namespace CXX if (simple) { - Boolean lit (false); + bool lit (false); { IsLiteralValue test (lit); test.dispatch (t); @@ -661,12 +687,15 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (skip (e)) return; + SemanticGraph::Complex& c ( + dynamic_cast<SemanticGraph::Complex&> (e.scope ())); + String const& member (emember (e)); String tr (etraits (e)); // traits type name @@ -674,7 +703,7 @@ namespace CXX SemanticGraph::Type& t (e.type ()); - Boolean fund (false); + bool fund (false); { IsFundamentalType traverser (fund); traverser.dispatch (t); @@ -686,23 +715,17 @@ namespace CXX // derived from which makes it impossible to substitute or // dynamically-type with xsi:type. // - Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t)); + bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t)); os << "// " << comment (e.name ()) << endl << "//" << endl; if (poly) { - // aCC cannot handle an inline call to type_factory_map_instance. - // os << "{" - << "::xsd::cxx::tree::type_factory_map< " << char_type << - " >& tfm (" << endl - << "::xsd::cxx::tree::type_factory_map_instance< 0, " << - char_type << " > ());" - << endl - << "::std::auto_ptr< ::xsd::cxx::tree::type > tmp (" << endl - << "tfm.create (" << endl + << auto_ptr << "< ::xsd::cxx::tree::type > tmp (" << endl + << "::xsd::cxx::tree::type_factory_map_instance< " << + poly_plate << ", " << char_type << " > ().create (" << endl << strlit (e.name ()) << "," << endl << (e.qualified_p () ? strlit (e.namespace_ ().name ()) @@ -732,8 +755,14 @@ namespace CXX if (!fund) { - os << "::std::auto_ptr< " << type << " > r (" << endl - << tr << "::create (i, f, this));" + os << auto_ptr << "< " << type << " > r (" << endl + << tr << "::create (i, f"; + + if (t.is_a<SemanticGraph::AnyType> () && + options.generate_any_type ()) + os << " | " << flags_type << "::extract_content"; + + os << ", this));" << endl; } } @@ -772,7 +801,7 @@ namespace CXX { // Cast to static type. // - os << "::std::auto_ptr< " << type << " > r (" << endl + os << auto_ptr << "< " << type << " > r (" << endl << "dynamic_cast< " << type << "* > (tmp.get ()));" << endl << "if (r.get ())" << endl @@ -783,23 +812,25 @@ namespace CXX << endl; } + char const* r (std >= cxx_version::cxx11 ? "::std::move (r)" : "r"); + if (max (e) != 1) { // sequence // - os << "this->" << member << ".push_back (r);"; + os << "this->" << member << ".push_back (" << r << ");"; } else if (min (e) == 0) { // optional // - os << "this->" << member << ".set (r);"; + os << "this->" << member << ".set (" << r << ");"; } else { // one // - os << "this->" << member << ".set (r);"; + os << "this->" << member << ".set (" << r << ");"; } } else @@ -827,6 +858,27 @@ namespace CXX } } + // Capture order. + // + if (ordered_p (c)) + { + SemanticGraph::Context& ctx (c.context ()); + + String const& t (ctx.get<String> ("order-type")); + String const& m (ctx.get<String> ("order-member")); + + os << "this->" << m << ".push_back (" << endl + << t << " (" << + e.context ().get<String> ("ordered-id-name"); + + // sequence + // + if (max (e) != 1) + os << ", " << "this->" << member << ".size () - 1"; + + os << "));"; + } + os << "continue;"; // End of check block. @@ -863,7 +915,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (skip (e)) @@ -893,15 +945,16 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& member (emember (a)); + SemanticGraph::Complex& c ( + dynamic_cast<SemanticGraph::Complex&> (a.scope ())); + String const& ns (a.definition_namespace ().name ()); - String const& dom_doc ( - edom_document ( - dynamic_cast<SemanticGraph::Complex&> (a.scope ()))); + String const& dom_doc (edom_document (c)); os << "// " << ename (a) << endl << "//" << endl @@ -982,7 +1035,7 @@ namespace CXX { // sequence // - os << "this->" << member << " .push_back (r);"; + os << "this->" << member << ".push_back (r);"; } else if (min (a) == 0) { @@ -997,6 +1050,31 @@ namespace CXX os << "this->" << member << ".set (r);"; } + // Capture order. + // + if (ordered_p (c)) + { + SemanticGraph::Context& ctx (c.context ()); + + String const& t (ctx.get<String> ("order-type")); + String const& m (ctx.get<String> ("order-member")); + + os << "this->" << m << ".push_back (" << endl + << t << " (" << + a.context ().get<String> ("ordered-id-name") << ", "; + + if (max (a) != 1) + // sequence + // + os << "this->" << member << ".size () - 1"; + else + // optional & one + // + os << "0"; + + os << "));"; + } + os << "continue;"; // End of check block. @@ -1030,7 +1108,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (max (a) == 1 && min (a) == 1) @@ -1055,7 +1133,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& member (emember (a)); @@ -1075,26 +1153,8 @@ namespace CXX << "{"; } - Boolean fund (false); - { - IsFundamentalType traverser (fund); - traverser.dispatch (a.type ()); - } - - if (fund) - { - os << "this->" << member << ".set (" << tr << - "::create (i, f, this));"; - } - else - { - String type (etype (a)); - - os << "::std::auto_ptr< " << type << " > r (" << endl - << tr << "::create (i, f, this));" - << endl - << "this->" << member << ".set (r);"; - } + os << "this->" << member << ".set (" << tr << + "::create (i, f, this));"; os << "continue;" << "}"; @@ -1109,7 +1169,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& member (emember (a)); @@ -1202,7 +1262,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& member (emember (a)); @@ -1238,33 +1298,31 @@ namespace CXX Traversal::Type, Context { - // If base_arg is empty then no base argument is - // generated. + // If base_arg is empty then no base argument is generated. // - CtorBase (Context& c, String const& base_arg) - : Context (c), base_arg_ (base_arg) + CtorBase (Context& c, CtorArgType at, String const& base_arg) + : Context (c), args_ (c, at, base_arg) { } - virtual Void + virtual void traverse (SemanticGraph::Type&) { - if (base_arg_) - os << base_arg_; + if (args_.base_arg_) + os << args_.base_arg_; } - virtual Void + virtual void traverse (SemanticGraph::Enumeration&) { - if (base_arg_) - os << base_arg_; + if (args_.base_arg_) + os << args_.base_arg_; } - Void + void traverse (SemanticGraph::Complex& c) { - Args args (*this, base_arg_); - args.traverse (c); + args_.traverse (c); } private: @@ -1279,31 +1337,32 @@ namespace CXX Traversal::Attribute, Context { - Args (Context& c, String const& base_arg) - : Context (c), base_arg_ (base_arg), first_ (true) + Args (Context& c, CtorArgType at, String const& base_arg) + : Context (c), + arg_type_ (at), base_arg_ (base_arg), first_ (true) { *this >> inherits_ >> *this; *this >> names_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Type&) { if (base_arg_) os << comma () << base_arg_; } - virtual Void + virtual void traverse (SemanticGraph::Enumeration&) { if (base_arg_) os << comma () << base_arg_; } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { - if (!options.value<CLI::generate_wildcard> ()) + if (!options.generate_wildcard ()) return; if (min (a) == 1 && max (a) == 1) @@ -1314,18 +1373,43 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (!skip (e) && min (e) == 1 && max (e) == 1) { // one // - os << comma () << ename (e); + bool move (false); + + if (std >= cxx_version::cxx11) + { + switch (arg_type_) + { + case CtorArgType::complex_auto_ptr: + { + bool simple (true); + IsSimpleType t (simple); + t.dispatch (e.type ()); + move = !simple; + break; + } + case CtorArgType::poly_auto_ptr: + { + move = polymorphic && polymorphic_p (e.type ()); + break; + } + case CtorArgType::type: + break; + } + } + + os << comma () << (move ? "std::move (" : "") << ename (e) << + (move ? ")" : ""); } } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { // Note that we are not including attributes with default @@ -1345,20 +1429,23 @@ namespace CXX String comma () { - Boolean tmp (first_); + bool tmp (first_); first_ = false; return tmp ? "" : ",\n"; } - private: + public: + CtorArgType arg_type_; String base_arg_; - Boolean first_; + + private: + bool first_; Traversal::Inherits inherits_; Traversal::Names names_; }; - String base_arg_; + Args args_; }; @@ -1366,12 +1453,12 @@ namespace CXX Traversal::Attribute, Context { - CtorMember (Context& c) - : Context (c) + CtorMember (Context& c, CtorArgType at) + : Context (c), arg_type_ (at) { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -1384,38 +1471,62 @@ namespace CXX // sequence // os << "," << endl - << " " << member << " (" << flags_type << " (), this)"; + << " " << member << " (this)"; } else if (min (e) == 0) { // optional // os << "," << endl - << " " << member << " (" << flags_type << " (), this)"; + << " " << member << " (this)"; } else { // one // + bool move (false); + + if (std >= cxx_version::cxx11) + { + switch (arg_type_) + { + case CtorArgType::complex_auto_ptr: + { + bool simple (true); + IsSimpleType t (simple); + t.dispatch (e.type ()); + move = !simple; + break; + } + case CtorArgType::poly_auto_ptr: + { + move = polymorphic && polymorphic_p (e.type ()); + break; + } + case CtorArgType::type: + break; + } + } + os << "," << endl - << " " << member << " (" << ename (e) << ", " << - flags_type << " (), this)"; + << " " << member << " (" << (move ? "std::move (" : "") << + ename (e) << (move ? ")" : "") << ", this)"; } } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { String const& member (emember (a)); - Boolean def (a.default_p ()); + bool def (a.default_p ()); if (min (a) == 0 && !def) { // optional // os << "," << endl - << " " << member << " (" << flags_type << " (), this)"; + << " " << member << " (this)"; } else { @@ -1429,16 +1540,18 @@ namespace CXX // os << "," << endl << " " << member << " (" << - edefault_value (a) << " (), " << flags_type << " (), this)"; + edefault_value (a) << " (), this)"; } else { os << "," << endl - << " " << member << " (" << ename (a) << ", " << - flags_type << " (), this)"; + << " " << member << " (" << ename (a) << ", this)"; } } } + + private: + CtorArgType arg_type_; }; struct CtorAny: Traversal::Any, @@ -1450,7 +1563,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& member (emember (a)); @@ -1482,7 +1595,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& dom_doc ( @@ -1502,7 +1615,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Member& m) { if (skip (m)) @@ -1528,7 +1641,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& member (emember (a)); @@ -1541,7 +1654,7 @@ namespace CXX arg_name << "." << member << ", this->" << dom_doc << " ())"; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& member (emember (a)); @@ -1558,6 +1671,48 @@ namespace CXX String arg_name; }; + struct AssignMember: Traversal::Member, Context + { + AssignMember (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::Member& m) + { + if (skip (m)) + return; + + String const& member (emember (m)); + os << "this->" << member << " = x." << member << ";"; + } + }; + + struct AssignAny: Traversal::Any, + Traversal::AnyAttribute, + Context + { + AssignAny (Context& c) + : Context (c) + { + } + + virtual void + traverse (SemanticGraph::Any& a) + { + String const& member (emember (a)); + os << "this->" << member << " = x." << member << ";"; + } + + virtual void + traverse (SemanticGraph::AnyAttribute& a) + { + String const& member (emember (a)); + os << "this->" << member << " = x." << member << ";"; + } + }; + // Element parsing c-tor initializers. // @@ -1568,7 +1723,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -1577,7 +1732,7 @@ namespace CXX String const& member (emember (m)); os << "," << endl - << " " << member << " (f, this)"; + << " " << member << " (this)"; } }; @@ -1590,7 +1745,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& member (emember (a)); @@ -1602,7 +1757,7 @@ namespace CXX << " " << member << " (this->" << dom_doc << " ())"; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& member (emember (a)); @@ -1627,7 +1782,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -1636,10 +1791,10 @@ namespace CXX String const& member (emember (e)); os << "," << endl - << " " << member << " (" << flags_type << " (), this)"; + << " " << member << " (this)"; } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { String const& member (emember (a)); @@ -1651,11 +1806,11 @@ namespace CXX // os << "," << endl << " " << member << " (" << - edefault_value (a) << " (), " << flags_type << " (), this)"; + edefault_value (a) << " (), this)"; } else os << "," << endl - << " " << member << " (" << flags_type << " (), this)"; + << " " << member << " (this)"; } }; @@ -1668,7 +1823,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& member (emember (a)); @@ -1680,7 +1835,7 @@ namespace CXX << " " << member << " (this->" << dom_doc << " ())"; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& member (emember (a)); @@ -1707,39 +1862,39 @@ namespace CXX { // generate should initially be false. // - HasComparisonOperator (Context& c, Boolean& generate) + HasComparisonOperator (Context& c, bool& generate) : Context (c), generate_ (generate) { *this >> inherits_ >> *this; *this >> names_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Type&) { // All built-in types are comparable. generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::List&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Union&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Enumeration& e) { Traversal::Enumeration::inherits (e); } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { Complex::names (c); @@ -1748,29 +1903,29 @@ namespace CXX Complex::inherits (c); } - virtual Void + virtual void traverse (SemanticGraph::Member& m) { if (!skip (m)) generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Any&) { - if (options.value<CLI::generate_wildcard> ()) + if (options.generate_wildcard ()) generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute&) { - if (options.value<CLI::generate_wildcard> ()) + if (options.generate_wildcard ()) generate_ = true; } private: - Boolean& generate_; + bool& generate_; Traversal::Inherits inherits_; Traversal::Names names_; @@ -1787,7 +1942,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -1802,7 +1957,7 @@ namespace CXX // dynamically-type with xsi:type. // SemanticGraph::Type& t (e.type ()); - Boolean poly (polymorphic && polymorphic_p (t) && !anonymous_p (t)); + bool poly (polymorphic && polymorphic_p (t) && !anonymous_p (t)); if (!poly) { @@ -1812,13 +1967,11 @@ namespace CXX } else { - // aCC cannot handle an inline call to comparison_map_instance. - // os << "{" << "::xsd::cxx::tree::comparison_map< " << char_type << " >& cm (" << endl - << "::xsd::cxx::tree::comparison_map_instance< 0, " << - char_type << " > ());" + << "::xsd::cxx::tree::comparison_map_instance< " << + poly_plate << ", " << char_type << " > ());" << endl; if (max (e) != 1) @@ -1878,7 +2031,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { String const& aname (eaname (a)); @@ -1898,7 +2051,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& aname (eaname (a)); @@ -1914,7 +2067,7 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& aname (eaname (a)); @@ -1935,50 +2088,53 @@ namespace CXX Traversal::AnyAttribute, Context { - HasParseFunction (Context& c, Boolean& has_el, Boolean& has_at) + HasParseFunction (Context& c, bool& has_el, bool& has_at) : Context (c), has_el_ (has_el), has_at_ (has_at) { *this >> names_ >> *this; *this >> inherits_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { + if (mixed_p (c) && !c.context ().count ("mixed-in-base")) + has_el_ = true; + names (c); if (!(has_el_ && has_at_)) inherits (c); } - virtual Void + virtual void traverse (SemanticGraph::Element&) { has_el_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Any&) { has_el_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Attribute&) { has_at_ = true; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute&) { - if (options.value<CLI::generate_wildcard> ()) + if (options.generate_wildcard ()) has_at_ = true; } private: - Boolean& has_el_; - Boolean& has_at_; + bool& has_el_; + bool& has_at_; Traversal::Names names_; Traversal::Inherits inherits_; @@ -1993,14 +2149,14 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { Facets f; FacetCollector col (f); col.traverse (c); - for (Facets::ConstIterator i (f.begin ()); i != f.end (); ++i) + for (Facets::const_iterator i (f.begin ()); i != f.end (); ++i) { if (i->first == L"fractionDigits") os << "{::xsd::cxx::tree::facet::fraction_digits, " << @@ -2012,7 +2168,7 @@ namespace CXX } private: - typedef Cult::Containers::Map<String, String> Facets; + typedef map<String, String> Facets; struct FacetCollector: Traversal::Complex { @@ -2022,7 +2178,7 @@ namespace CXX *this >> inherits_ >> *this; } - virtual Void + virtual void traverse (Type& c) { if (c.inherits_p ()) @@ -2075,21 +2231,25 @@ namespace CXX default_ctor_any_init_ (c), default_ctor_member_init_ (c), ctor_any_ (c), - ctor_member_ (c), + ctor_member_ (c, CtorArgType::type), element_ctor_any_ (c), element_ctor_member_ (c), + assign_any_ (c), + assign_member_ (c), comparison_any_ (c), comparison_member_ (c), facet_array_ (c) { + bool gen_wildcard (options.generate_wildcard ()); + inherits_member_ >> member_name_; names_element_ >> element_; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) names_element_ >> any_; names_element_test_ >> element_test_; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) names_element_test_ >> any_test_; names_attribute_ >> attribute_; @@ -2097,26 +2257,32 @@ namespace CXX names_any_attribute_ >> any_attribute_; default_ctor_init_names_ >> default_ctor_member_init_; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) default_ctor_init_names_ >> default_ctor_any_init_; ctor_names_ >> ctor_member_; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) ctor_names_ >> ctor_any_; element_ctor_names_ >> element_ctor_member_; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) element_ctor_names_ >> element_ctor_any_; + assign_names_ >> assign_member_; + if (gen_wildcard) + assign_names_ >> assign_any_; + comparison_names_ >> comparison_member_; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) comparison_names_ >> comparison_any_; } - virtual Void + virtual void traverse (Type& c) { + bool gen_wildcard (options.generate_wildcard ()); + String name (ename (c)); // If renamed name is empty then we do not need to generate @@ -2125,7 +2291,12 @@ namespace CXX if (renamed_type (c, name) && !name) return; - Boolean string_based (false); + SemanticGraph::Context& ctx (c.context ()); + + bool mixed (mixed_p (c) && !ctx.count ("mixed-in-base")); + bool ordered (ordered_p (c) && !ctx.count ("order-in-base")); + + bool string_based (false); { IsStringBasedType t (string_based); t.dispatch (c); @@ -2137,7 +2308,7 @@ namespace CXX t.dispatch (c); } - Boolean facets (false); + bool facets (false); String base; // base type name if (c.inherits_p ()) { @@ -2200,15 +2371,15 @@ namespace CXX // c-tors // - Boolean generate_no_base_ctor (false); + bool generate_no_base_ctor (false); { GenerateWithoutBaseCtor t (generate_no_base_ctor); t.traverse (c); } - Boolean has_complex_non_op_args (false); - Boolean has_poly_non_op_args (false); - Boolean complex_poly_args_clash (true); + bool has_complex_non_op_args (false); + bool has_poly_non_op_args (false); + bool complex_poly_args_clash (true); { HasComplexPolyNonOptArgs t (*this, true, has_complex_non_op_args, @@ -2219,9 +2390,9 @@ namespace CXX // default c-tor // - if (options.value<CLI::generate_default_ctor> ()) + if (options.generate_default_ctor ()) { - Boolean generate (false); + bool generate (false); { GenerateDefaultCtor t (*this, generate, generate_no_base_ctor); t.traverse (c); @@ -2241,6 +2412,12 @@ namespace CXX " > ())"; } + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + names (c, default_ctor_init_names_); os << "{"; @@ -2252,9 +2429,9 @@ namespace CXX // c-tor (base, all-non-optional-members) // - if (options.value<CLI::generate_from_base_ctor> ()) + if (options.generate_from_base_ctor ()) { - Boolean generate (false); + bool generate (false); { GenerateFromBaseCtor t (*this, generate); t.traverse (c); @@ -2262,9 +2439,9 @@ namespace CXX if (generate) { - Boolean has_complex_non_op_args (false); - Boolean has_poly_non_op_args (false); - Boolean complex_poly_args_clash (true); + bool has_complex_non_op_args (false); + bool has_poly_non_op_args (false); + bool complex_poly_args_clash (true); { HasComplexPolyNonOptArgs t (*this, false, has_complex_non_op_args, @@ -2281,7 +2458,7 @@ namespace CXX inherits (c, inherits_member_); os << "& " << base_arg; { - FromBaseCtorArg args (*this, FromBaseCtorArg::arg_type, true); + FromBaseCtorArg args (*this, CtorArgType::type, true); Traversal::Names args_names (args); names (c, args_names); } @@ -2296,6 +2473,12 @@ namespace CXX " > ())"; } + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + names (c, ctor_names_); os << "{"; @@ -2308,13 +2491,14 @@ namespace CXX // if (has_complex_non_op_args) { + CtorArgType const at (CtorArgType::complex_auto_ptr); + os << name << "::" << endl << name << " (const "; inherits (c, inherits_member_); os << "& " << base_arg; { - FromBaseCtorArg args ( - *this, FromBaseCtorArg::arg_complex_auto_ptr, true); + FromBaseCtorArg args (*this, at, true); Traversal::Names args_names (args); names (c, args_names); } @@ -2329,7 +2513,21 @@ namespace CXX " > ())"; } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + + { + CtorMember t (*this, at); + Traversal::Names n (t); + + if (gen_wildcard) + n >> ctor_any_; + + names (c, n); + } os << "{"; if (facets) @@ -2343,13 +2541,14 @@ namespace CXX if (polymorphic && has_poly_non_op_args && !complex_poly_args_clash) { + CtorArgType const at (CtorArgType::poly_auto_ptr); + os << name << "::" << endl << name << " (const "; inherits (c, inherits_member_); os << "& " << base_arg; { - FromBaseCtorArg args ( - *this, FromBaseCtorArg::arg_poly_auto_ptr, true); + FromBaseCtorArg args (*this, at, true); Traversal::Names args_names (args); names (c, args_names); } @@ -2364,7 +2563,21 @@ namespace CXX " > ())"; } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + + { + CtorMember t (*this, at); + Traversal::Names n (t); + + if (gen_wildcard) + n >> ctor_any_; + + names (c, n); + } os << "{"; if (facets) @@ -2378,17 +2591,18 @@ namespace CXX // if (generate_no_base_ctor) { + CtorArgType const at (CtorArgType::type); + os << name << "::" << endl << name << " ("; { - CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, true, true); + CtorArgsWithoutBase ctor_args (*this, at, true, true); ctor_args.dispatch (c); } os << ")" << endl << ": " << base << " ("; { - CtorBase base (*this, ""); + CtorBase base (*this, at, ""); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2403,6 +2617,12 @@ namespace CXX " > ())"; } + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + names (c, ctor_names_); os << "{"; @@ -2416,17 +2636,18 @@ namespace CXX // if (has_complex_non_op_args) { + CtorArgType const at (CtorArgType::complex_auto_ptr); + os << name << "::" << endl << name << " ("; { - CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_complex_auto_ptr, true, true); + CtorArgsWithoutBase ctor_args (*this, at, true, true); ctor_args.dispatch (c); } os << ")" << endl << ": " << base << " ("; { - CtorBase base (*this, ""); + CtorBase base (*this, at, ""); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2441,7 +2662,21 @@ namespace CXX " > ())"; } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + + { + CtorMember t (*this, at); + Traversal::Names n (t); + + if (gen_wildcard) + n >> ctor_any_; + + names (c, n); + } os << "{"; if (facets) @@ -2455,17 +2690,18 @@ namespace CXX if (polymorphic && has_poly_non_op_args && !complex_poly_args_clash) { + CtorArgType const at (CtorArgType::poly_auto_ptr); + os << name << "::" << endl << name << " ("; { - CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_poly_auto_ptr, true, true); + CtorArgsWithoutBase ctor_args (*this, at, true, true); ctor_args.dispatch (c); } os << ")" << endl << ": " << base << " ("; { - CtorBase base (*this, ""); + CtorBase base (*this, at, ""); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2480,7 +2716,21 @@ namespace CXX " > ())"; } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + + { + CtorMember t (*this, at); + Traversal::Names n (t); + + if (gen_wildcard) + n >> ctor_any_; + + names (c, n); + } os << "{"; if (facets) @@ -2497,6 +2747,7 @@ namespace CXX { // c-tor (enum-value, all-non-optional-members) // + CtorArgType const at (CtorArgType::type); String base_arg (L"_xsd_" + ename (*enum_base) + L"_base"); os << name << "::" << endl @@ -2504,8 +2755,7 @@ namespace CXX evalue (*enum_base) << " " << base_arg; { - CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, true, false); + CtorArgsWithoutBase ctor_args (*this, at, true, false); ctor_args.dispatch (c); } @@ -2513,7 +2763,7 @@ namespace CXX << ": " << base << " ("; { - CtorBase base (*this, base_arg); + CtorBase base (*this, at, base_arg); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2529,6 +2779,8 @@ namespace CXX " > ())"; } + // Cannot be mixed. + names (c, ctor_names_); os << "{"; @@ -2537,6 +2789,7 @@ namespace CXX os << "}"; } + CtorArgType const at (CtorArgType::type); String base_arg (L"_xsd_" + ename (ultimate_base (c)) + L"_base"); // c-tor (const char*, all-non-optional-members) @@ -2545,8 +2798,7 @@ namespace CXX << name << " (const " << char_type << "* " << base_arg; { - CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, true, false); + CtorArgsWithoutBase ctor_args (*this, at, true, false); ctor_args.dispatch (c); } @@ -2554,7 +2806,7 @@ namespace CXX << ": " << base << " ("; { - CtorBase base (*this, base_arg); + CtorBase base (*this, at, base_arg); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2570,6 +2822,8 @@ namespace CXX " > ())"; } + // Cannot be mixed. + names (c, ctor_names_); os << "{"; @@ -2584,8 +2838,7 @@ namespace CXX << name << " (const " << string_type << "& " << base_arg; { - CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, true, false); + CtorArgsWithoutBase ctor_args (*this, at, true, false); ctor_args.dispatch (c); } @@ -2593,7 +2846,7 @@ namespace CXX << ": " << base << " ("; { - CtorBase base (*this, base_arg); + CtorBase base (*this, at, base_arg); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2609,6 +2862,8 @@ namespace CXX " > ())"; } + // Cannot be mixed. + names (c, ctor_names_); os << "{"; @@ -2619,57 +2874,66 @@ namespace CXX // c-tor (ultimate-base, all-non-optional-members) // + { + CtorArgType const at (CtorArgType::type); - os << name << "::" << endl - << name << " ("; + os << name << "::" << endl + << name << " ("; - String base_arg; + String base_arg; - { - CtorArgs ctor_args (*this, CtorArgs::arg_type, base_arg); - ctor_args.dispatch (c); - } + { + CtorArgs ctor_args (*this, at, base_arg); + ctor_args.dispatch (c); + } - os << ")" << endl - << ": " << base << " ("; + os << ")" << endl + << ": " << base << " ("; - { - CtorBase base (*this, base_arg); - Traversal::Inherits inherits_base (base); + { + CtorBase base (*this, at, base_arg); + Traversal::Inherits inherits_base (base); - inherits (c, inherits_base); - } + inherits (c, inherits_base); + } - os << ")"; + os << ")"; - if (edom_document_member_p (c)) - { - os << "," << endl - << " " << edom_document_member (c) << " (" << - "::xsd::cxx::xml::dom::create_document< " << char_type << - " > ())"; - } + if (edom_document_member_p (c)) + { + os << "," << endl + << " " << edom_document_member (c) << " (" << + "::xsd::cxx::xml::dom::create_document< " << char_type << + " > ())"; + } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } - os << "{"; - if (facets) - os << "this->_facet_table (_xsd_" << name << "_facet_table);"; - os << "}"; + names (c, ctor_names_); + + os << "{"; + if (facets) + os << "this->_facet_table (_xsd_" << name << "_facet_table);"; + os << "}"; + } // If we have any complex arguments in the previous c-tor // then also generate the auto_ptr version. // if (has_complex_non_op_args) { + CtorArgType const at (CtorArgType::complex_auto_ptr); + String base_arg; + os << name << "::" << endl << name << " ("; - String base_arg; - { - CtorArgs ctor_args ( - *this, CtorArgs::arg_complex_auto_ptr, base_arg); + CtorArgs ctor_args (*this, at, base_arg); ctor_args.dispatch (c); } @@ -2677,7 +2941,7 @@ namespace CXX << ": " << base << " ("; { - CtorBase base (*this, base_arg); + CtorBase base (*this, at, base_arg); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2693,7 +2957,21 @@ namespace CXX " > ())"; } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + + { + CtorMember t (*this, at); + Traversal::Names n (t); + + if (gen_wildcard) + n >> ctor_any_; + + names (c, n); + } os << "{"; if (facets) @@ -2707,14 +2985,14 @@ namespace CXX if (polymorphic && has_poly_non_op_args && !complex_poly_args_clash) { + CtorArgType const at (CtorArgType::poly_auto_ptr); + String base_arg; + os << name << "::" << endl << name << " ("; - String base_arg; - { - CtorArgs ctor_args ( - *this, CtorArgs::arg_poly_auto_ptr, base_arg); + CtorArgs ctor_args (*this, at, base_arg); ctor_args.dispatch (c); } @@ -2722,7 +3000,7 @@ namespace CXX << ": " << base << " ("; { - CtorBase base (*this, base_arg); + CtorBase base (*this, at, base_arg); Traversal::Inherits inherits_base (base); inherits (c, inherits_base); @@ -2738,7 +3016,21 @@ namespace CXX " > ())"; } - names (c, ctor_names_); + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + + { + CtorMember t (*this, at); + Traversal::Names n (t); + + if (gen_wildcard) + n >> ctor_any_; + + names (c, n); + } os << "{"; if (facets) @@ -2764,6 +3056,20 @@ namespace CXX " > ())"; } + if (mixed) + { + String const& m (ctx.get<String> ("mixed-member")); + os << "," << endl + << " " << m << " (x." << m << ", f, this)"; + } + + if (ordered) + { + String const& m (ctx.get<String> ("order-member")); + os << "," << endl + << " " << m << " (x." << m << ")"; + } + { CopyAny copy_any (*this, "x"); CopyMember copy_member (*this, "x"); @@ -2771,7 +3077,7 @@ namespace CXX names >> copy_member; - if (options.value<CLI::generate_wildcard> ()) + if (gen_wildcard) names >> copy_any; Complex::names (c, names); @@ -2784,17 +3090,15 @@ namespace CXX // // - Boolean he (has<Traversal::Element> (c)); - Boolean hae (has<Traversal::Any> (c)); + bool he (has<Traversal::Element> (c)); + bool hae (has<Traversal::Any> (c)); - Boolean ha (has<Traversal::Attribute> (c)); - Boolean haa (has<Traversal::AnyAttribute> (c)); - - Boolean gen_wildcard (options.value<CLI::generate_wildcard> ()); + bool ha (has<Traversal::Attribute> (c)); + bool haa (has<Traversal::AnyAttribute> (c)); // // - if (!options.value<CLI::suppress_parsing> ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -2804,7 +3108,7 @@ namespace CXX << container << "* c)" << endl << ": " << base << " (e, f"; - if (he || ha || hae || (haa && gen_wildcard)) + if (he || ha || hae || (haa && gen_wildcard) || mixed) os << " | " << flags_type << "::base"; os << ", c)"; @@ -2817,6 +3121,12 @@ namespace CXX " > ())"; } + if (mixed) + { + os << "," << endl + << " " << ctx.get<String> ("mixed-member") << " (this)"; + } + names (c, element_ctor_names_); os << "{"; @@ -2825,12 +3135,12 @@ namespace CXX os << "this->_facet_table (_xsd_" << name << "_facet_table);" << endl; - Boolean base_has_el (false), base_has_at (false); + bool base_has_el (false), base_has_at (false); // We are only interested in this information if we are - // generating out own parse(). + // generating our own parse(). // - if (he || ha || hae || (haa && gen_wildcard)) + if (he || ha || hae || (haa && gen_wildcard) || mixed) { if (c.inherits_p ()) { @@ -2839,13 +3149,14 @@ namespace CXX } } - //@@ throw if p is no exhausted at the end. + //@@ Throw if p is not exhausted at the end. // - if (he || ha || hae || (haa && gen_wildcard)) + if (he || ha || hae || (haa && gen_wildcard) || mixed) os << "if ((f & " << flags_type << "::base) == 0)" << "{" << parser_type << " p (e, " << - (he || hae || base_has_el ? "true, " : "false, ") << + (he || hae || base_has_el || mixed_p (c) ? "true, " : "false, ") << + (mixed_p (c) ? "true, " : "false, ") << (ha || (haa && gen_wildcard) || base_has_at ? "true" : "false") << ");" << "this->" << unclash (name, "parse") << " (p, f);" @@ -2853,7 +3164,7 @@ namespace CXX os << "}"; - Boolean simple (true); + bool simple (true); { IsSimpleType t (simple); t.dispatch (c); @@ -2891,7 +3202,7 @@ namespace CXX os << "}"; } - if (he || ha || hae || (haa && gen_wildcard)) + if (he || ha || hae || (haa && gen_wildcard) || mixed) { os << "void " << name << "::" << endl << unclash (name, "parse") << " (" << @@ -2906,17 +3217,45 @@ namespace CXX os << "this->" << base << "::parse (p, f);" << endl; - if (he || hae) + if (he || hae || mixed_p (c)) { - os << "for (; p.more_elements (); p.next_element ())" - << "{" - << "const " << xerces_ns << "::DOMElement& i (" << - "p.cur_element ());" - << "const " << qname_type << " n (" << endl - << "::xsd::cxx::xml::dom::name< " << char_type << " > (i));" - << endl; + bool m (mixed_p (c)); + + os << "for (; p.more_content (); p.next_content (" << + (m ? "true" : "false") << "))" + << "{"; - names (c, names_element_); + if (m) + { + String const& ma (ctx.get<String> ("mixed-aname")); + String const& mi (ctx.get<String> ("mixed-ordered-id-name")); + String const& oa (ctx.get<String> ("order-aname")); + String const& ot (ctx.get<String> ("order-type")); + + os << "if (p.cur_is_text ())" + << "{" + << "const " << xerces_ns << "::DOMText& t (" << + "p.cur_text ());" + << "this->" << ma << " ().push_back (" << endl + << "::xsd::cxx::xml::transcode< " << char_type << " > (" << + "t.getData (), t.getLength ()));" + << "this->" << oa << " ().push_back (" << endl + << ot << " (" << mi << "," << endl + << "this->" << ma << " ().size () - 1));" + << "continue;" + << "}"; + } + + if (he || hae) + { + os << "const " << xerces_ns << "::DOMElement& i (" << + "p.cur_element ());" + << "const " << qname_type << " n (" << endl + << "::xsd::cxx::xml::dom::name< " << char_type << " > (i));" + << endl; + + names (c, names_element_); + } os << "break;" << "}"; @@ -2977,6 +3316,45 @@ namespace CXX << "return new class " << name << " (*this, f, c);" << "}"; + // operator= + // + if (!options.suppress_assignment () && + (he || ha || (gen_wildcard && (hae || haa)))) + { + os << name << "& " << name << "::" << endl + << "operator= (const " << name << "& x)" + << "{" + << "if (this != &x)" + << "{" + << "static_cast< " << base << "& > (*this) = x;"; + + // Note that here we don't assign the DOMDocument that is + // used to hold wildcard fragments. Each document has its + // own copy. + + // Mixed text content. + // + if (mixed) + { + String const& m (ctx.get<String> ("mixed-member")); + os << "this->" << m << " = x." << m << ";"; + } + + // Order container. + // + if (ordered) + { + String const& m (ctx.get<String> ("order-member")); + os << "this->" << m << " = x." << m << ";"; + } + + names (c, assign_names_); + + os << "}" + << "return *this;" + << "}"; + } + // d-tor // os << name << "::" << endl @@ -2986,36 +3364,44 @@ namespace CXX // Register with type factory map. // - if (polymorphic && polymorphic_p (c) && !anonymous_p (c)) + if (polymorphic && polymorphic_p (c)) { // Note that we are using the original type name. // String const& name (ename (c)); - if (!options.value<CLI::suppress_parsing> ()) + // If this type is anonymous but substitutes, then it will + // be registered as part of the substitution registration. + // + if (!anonymous_p (c) && !options.suppress_parsing ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::type_factory_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::type_factory_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_type_factory_init (" << endl << strlit (c.name ()) << "," << endl << strlit (xml_ns_name (c)) << ");" << endl; + } - if (options.value<CLI::generate_comparison> ()) + if ((!anonymous_p (c) || anonymous_substitutes_p (c)) && + options.generate_comparison ()) + { os << "static" << endl - << "const ::xsd::cxx::tree::comparison_initializer< 0, " << - char_type << ", " << name << " >" << endl + << "const ::xsd::cxx::tree::comparison_initializer< " << + poly_plate << ", " << char_type << ", " << name << " >" << endl << "_xsd_" << name << "_comparison_init;" << endl; + } } // Comparison operators. // - if (options.value<CLI::generate_comparison> () && - (he || ha || !c.inherits_p () || + if (options.generate_comparison () && + (he || ha || mixed || ordered || !c.inherits_p () || ((hae || haa) && gen_wildcard))) { - Boolean base_comp (false); + bool base_comp (false); if (c.inherits_p ()) { @@ -3023,8 +3409,8 @@ namespace CXX test.dispatch (c.inherits ().base ()); } - Boolean has_body (he || ha || base_comp || - ((hae || haa) && gen_wildcard)); + bool has_body (he || ha || ordered || mixed || base_comp || + ((hae || haa) && gen_wildcard)); os << "bool" << endl << "operator== (const " << name << "&" << @@ -3042,6 +3428,22 @@ namespace CXX Complex::names (c, comparison_names_); } + if (mixed) + { + String const& an (ctx.get<String> ("mixed-aname")); + os << "if (!(x." << an << " () == y." << an << " ()))" << endl + << "return false;" + << endl; + } + + if (ordered) + { + String const& an (ctx.get<String> ("order-aname")); + os << "if (!(x." << an << " () == y." << an << " ()))" << endl + << "return false;" + << endl; + } + os << "return true;" << "}"; @@ -3088,6 +3490,10 @@ namespace CXX ElementCtorMember element_ctor_member_; Traversal::Names element_ctor_names_; + AssignAny assign_any_; + AssignMember assign_member_; + Traversal::Names assign_names_; + AnyComparison comparison_any_; MemberComparison comparison_member_; Traversal::Names comparison_names_; @@ -3105,27 +3511,27 @@ namespace CXX GlobalElement (Context& c) : GlobalElementBase (c), Context (c), - element_type_ (c.options.value<CLI::generate_element_type> ()), - element_map_ (c.options.value<CLI::generate_element_map> ()), + element_type_ (c.options.generate_element_type ()), + element_map_ (c.options.generate_element_map ()), type_name_ (c) { belongs_ >> type_name_; } - virtual Void + virtual void traverse (Type& e) { if (element_type_ && doc_root_p (e)) { SemanticGraph::Type& t (e.type ()); - Boolean fund (false); + bool fund (false); { IsFundamentalType test (fund); test.dispatch (t); } - Boolean simple (true); + bool simple (true); if (!fund) { IsSimpleType test (simple); @@ -3166,11 +3572,11 @@ namespace CXX // default c-tor // - if (options.value<CLI::generate_default_ctor> ()) + if (options.generate_default_ctor ()) { os << name << "::" << endl << name << " ()" << endl - << ": " << member << " (0, 0)" + << ": " << member << " (0)" << "{" << "}"; } @@ -3179,7 +3585,7 @@ namespace CXX // os << name << "::" << endl << name << " (const " << type << "& x)" << endl - << ": " << member << " (x, 0, 0)" + << ": " << member << " (x, 0)" << "{" << "}"; @@ -3189,8 +3595,8 @@ namespace CXX if (!simple || (polymorphic && polymorphic_p (t))) { os << name << "::" << endl - << name << " (::std::auto_ptr< " << type << " > p)" << endl - << ": " << member << " (p, 0, 0)" + << name << " (" << auto_ptr << "< " << type << " > p)" << endl + << ": " << member << " (p, 0)" << "{" << "}"; } @@ -3201,7 +3607,7 @@ namespace CXX String const& name_member (ec.get<String> ("element-name-member")); String const& ns_member (ec.get<String> ("element-ns-member")); - Boolean parsing (!options.value<CLI::suppress_parsing> ()); + bool parsing (!options.suppress_parsing ()); if (parsing) { String const& tr (etraits (e)); @@ -3209,7 +3615,7 @@ namespace CXX os << name << "::" << endl << name << " (const " << xerces_ns << "::DOMElement& e, " << flags_type << " f)" << endl - << ": " << member << " (f, 0)" + << ": " << member << " (0)" << "{" << "const " << qname_type << " n (" << endl << "::xsd::cxx::xml::dom::name< " << char_type << " > (e));" @@ -3302,14 +3708,14 @@ namespace CXX } if (polymorphic && e.substitutes_p () && - !options.value<CLI::suppress_parsing> ()) + !options.suppress_parsing ()) { String const& name (ename (e)); Type& r (e.substitutes ().root ()); os << "static" << endl - << "const ::xsd::cxx::tree::element_factory_initializer< 0, " << - char_type << ", "; + << "const ::xsd::cxx::tree::element_factory_initializer< " << + poly_plate << ", " << char_type << ", "; belongs (e, belongs_); @@ -3325,32 +3731,30 @@ namespace CXX } private: - Boolean element_type_; - Boolean element_map_; + bool element_type_; + bool element_map_; Traversal::Belongs belongs_; MemberTypeName type_name_; }; } - Void - generate_tree_source (Context& ctx, - UnsignedLong first, - UnsignedLong last) + void + generate_tree_source (Context& ctx, size_t first, size_t last) { - if (ctx.options.value<CLI::generate_wildcard> ()) + if (ctx.options.generate_wildcard ()) { ctx.os << "#include <xsd/cxx/xml/dom/wildcard-source.hxx>" << endl << endl; } - if (!ctx.options.value<CLI::suppress_parsing> ()) + if (!ctx.options.suppress_parsing ()) ctx.os << "#include <xsd/cxx/xml/dom/parsing-source.hxx>" << endl << endl; if (ctx.polymorphic) { - Boolean parsing (!ctx.options.value<CLI::suppress_parsing> ()); - Boolean comparison (ctx.options.value<CLI::generate_comparison> ()); + bool parsing (!ctx.options.suppress_parsing ()); + bool comparison (ctx.options.generate_comparison ()); if (parsing) ctx.os << "#include <xsd/cxx/tree/type-factory-map.hxx>" << endl @@ -3362,8 +3766,8 @@ namespace CXX if (parsing || comparison) { - Boolean import_maps (ctx.options.value<CLI::import_maps> ()); - Boolean export_maps (ctx.options.value<CLI::export_maps> ()); + bool import_maps (ctx.options.import_maps ()); + bool export_maps (ctx.options.export_maps ()); if (import_maps || export_maps) { @@ -3379,39 +3783,47 @@ namespace CXX if (parsing && export_maps) ctx.os << "template struct __declspec (dllexport) " << - "type_factory_plate< 0, " << ctx.char_type << " >;"; + "type_factory_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; if (parsing && import_maps) ctx.os << "template struct __declspec (dllimport) " << - "type_factory_plate< 0, " << ctx.char_type << " >;"; + "type_factory_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; if (comparison && export_maps) ctx.os << "template struct __declspec (dllexport) " << - "comparison_plate< 0, " << ctx.char_type << " >;"; + "comparison_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; if (comparison && import_maps) ctx.os << "template struct __declspec (dllimport) " << - "comparison_plate< 0, " << ctx.char_type << " >;"; + "comparison_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; ctx.os << "#elif defined(__GNUC__) && __GNUC__ >= 4" << endl; if (parsing) ctx.os << "template struct __attribute__ ((visibility(\"default\"))) " << - "type_factory_plate< 0, " << ctx.char_type << " >;"; + "type_factory_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; if (comparison) ctx.os << "template struct __attribute__ ((visibility(\"default\"))) " << - "comparison_plate< 0, " << ctx.char_type << " >;"; + "comparison_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; ctx.os << "#elif defined(XSD_MAP_VISIBILITY)" << endl; if (parsing) ctx.os << "template struct XSD_MAP_VISIBILITY " << - "type_factory_plate< 0, " << ctx.char_type << " >;"; + "type_factory_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; if (comparison) ctx.os << "template struct XSD_MAP_VISIBILITY " << - "comparison_plate< 0, " << ctx.char_type << " >;"; + "comparison_plate< " << ctx.poly_plate << ", " << + ctx.char_type << " >;"; ctx.os << "#endif" << endl << "}" // tree @@ -3426,15 +3838,15 @@ namespace CXX if (parsing) ctx.os << "static" << endl - << "const ::xsd::cxx::tree::type_factory_plate< 0, " << - ctx.char_type << " >" << endl + << "const ::xsd::cxx::tree::type_factory_plate< " << + ctx.poly_plate << ", " << ctx.char_type << " >" << endl << "type_factory_plate_init;" << endl; if (comparison) ctx.os << "static" << endl - << "const ::xsd::cxx::tree::comparison_plate< 0, " << - ctx.char_type << " >" << endl + << "const ::xsd::cxx::tree::comparison_plate< " << + ctx.poly_plate << ", " << ctx.char_type << " >" << endl << "comparison_plate_init;" << endl; @@ -3443,7 +3855,7 @@ namespace CXX } Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names names_ns, names; Namespace ns (ctx, first, last); |