From bada6666c70977a058755ccf232e7d67b24adeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:21:29 +0200 Subject: New upstream release --- xsd/xsd/cxx/tree/tree-header.cxx | 689 +++++++++++++++++++++++++++++++-------- 1 file changed, 552 insertions(+), 137 deletions(-) (limited to 'xsd/xsd/cxx/tree/tree-header.cxx') diff --git a/xsd/xsd/cxx/tree/tree-header.cxx b/xsd/xsd/cxx/tree/tree-header.cxx index 9b5acc6..f0c3560 100644 --- a/xsd/xsd/cxx/tree/tree-header.cxx +++ b/xsd/xsd/cxx/tree/tree-header.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/tree/tree-header.cxx -// author : Boris Kolpackov -// 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 @@ -16,8 +15,6 @@ namespace CXX { namespace { - typedef Containers::Vector Streams; - // List mapping. // struct List: Traversal::List, Context @@ -27,7 +24,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String name (ename (l)); @@ -142,8 +139,9 @@ namespace CXX // c-tor (istream&) // - Streams const& st (options.value ()); - for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i) + NarrowStrings const& st (options.generate_extraction ()); + for (NarrowStrings::const_iterator i (st.begin ()); i != st.end (); + ++i) { if (doxygen) { @@ -167,7 +165,7 @@ namespace CXX << endl; } - if (!options.value ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -293,6 +291,22 @@ namespace CXX << "~" << name << " ();"; os << "};"; + + // Comparison operators. + // + if (options.generate_comparison ()) + { + os << inst_exp + << "bool" << endl + << "operator== (const " << name << "&, const " << name << "&);" + << endl; + + os << inst_exp + << "bool" << endl + << "operator!= (const " << name << "&, const " << name << "&);" + << endl + << endl; + } } private: @@ -318,7 +332,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String name (ename (u)); @@ -353,7 +367,7 @@ namespace CXX << "public:" << endl << endl; - if (options.value ()) + if (options.generate_default_ctor ()) { // c-tor () // @@ -400,8 +414,9 @@ namespace CXX // c-tor (istream&) // - Streams const& st (options.value ()); - for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i) + NarrowStrings const& st (options.generate_extraction ()); + for (NarrowStrings::const_iterator i (st.begin ()); i != st.end (); + ++i) { if (doxygen) { @@ -425,7 +440,7 @@ namespace CXX << endl; } - if (!options.value ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -551,7 +566,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (doxygen && e.annotated_p ()) @@ -579,7 +594,7 @@ namespace CXX names_ >> enumerator_; } - virtual Void + virtual void traverse (Type& e) { String name (ename (e)); @@ -590,13 +605,13 @@ namespace CXX if (renamed_type (e, name) && !name) return; - Boolean string_based (false); + bool string_based (false); { IsStringBasedType t (string_based); t.dispatch (e); } - Boolean enum_based (false); + bool enum_based (false); SemanticGraph::Enumeration* base_enum (0); if (string_based) @@ -614,7 +629,7 @@ namespace CXX // Get to the ultimate base and see if is a fundamental type. // - Boolean fund_based (false); + bool fund_based (false); SemanticGraph::Type& ult_base (ultimate_base (e)); { IsFundamentalType t (fund_based); @@ -623,7 +638,7 @@ namespace CXX // Count enumerators. // - UnsignedLong enum_count (0); + size_t enum_count (0); for (Type::NamesIterator i (e.names_begin ()), end (e.names_end ()); i != end; ++i) @@ -688,7 +703,7 @@ namespace CXX // default c-tor // - if (options.value ()) + if (options.generate_default_ctor ()) { if (doxygen) { @@ -808,8 +823,9 @@ namespace CXX // c-tor (istream&) // - Streams const& st (options.value ()); - for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i) + NarrowStrings const& st (options.generate_extraction ()); + for (NarrowStrings::const_iterator i (st.begin ()); i != st.end (); + ++i) { if (doxygen) { @@ -833,7 +849,7 @@ namespace CXX << endl; } - if (!options.value ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -1031,7 +1047,7 @@ namespace CXX os << "};"; } - virtual Void + virtual void comma (Type&) { os << "," << endl; @@ -1058,7 +1074,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -1069,14 +1085,14 @@ namespace CXX String kind (m.is_a () ? "element" : "attribute"); - Boolean fund (false); + bool fund (false); { IsFundamentalType t (fund); t.dispatch (m.type ()); } - Boolean def_attr (m.default_p () && - m.is_a ()); + bool def_attr (m.default_p () && + m.is_a ()); if (max (m) != 1) { @@ -1249,7 +1265,7 @@ namespace CXX } os << "void" << endl - << mname << " (::std::auto_ptr< " << type << " > p);" + << mname << " (" << auto_ptr << "< " << type << " > p);" << endl; } } @@ -1338,7 +1354,7 @@ namespace CXX } os << "void" << endl - << mname << " (::std::auto_ptr< " << type << " > p);" + << mname << " (" << auto_ptr << "< " << type << " > p);" << endl; } @@ -1362,7 +1378,7 @@ namespace CXX << " */" << endl; } - os << "::std::auto_ptr< " << type << " >" << endl + os << auto_ptr << "< " << type << " >" << endl << edname (m) << " ();" << endl; } @@ -1373,7 +1389,7 @@ namespace CXX // if (m.default_p ()) { - Boolean simple (true); + bool simple (true); if (m.is_a ()) { @@ -1383,7 +1399,7 @@ namespace CXX if (simple) { - Boolean lit (false); + bool lit (false); { IsLiteralValue test (lit); test.dispatch (m.type ()); @@ -1425,7 +1441,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& aname (eaname (a)); @@ -1698,7 +1714,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& aname (eaname (a)); @@ -1778,16 +1794,19 @@ namespace CXX belongs_ >> type_name_; } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; + SemanticGraph::Complex& c ( + dynamic_cast (m.scope ())); + String const& type (etype (m)); - Boolean el (m.is_a ()); + bool el (m.is_a ()); - Boolean def_attr (m.default_p () && !el); + bool def_attr (m.default_p () && !el); if (doxygen) { @@ -1826,7 +1845,7 @@ namespace CXX else { os << "// " << comment (m.name ()) << endl - << "// " << endl; + << "//" << endl; } // Typedefs. @@ -1849,7 +1868,7 @@ namespace CXX if (max (m) != 1) { String const& container (econtainer (m)); - Boolean isense (options.value ()); + bool isense (options.generate_intellisense ()); // sequence // @@ -1872,7 +1891,7 @@ namespace CXX << " */" << endl; } - // IntelliSense does not not like aliases and fully-qualified + // IntelliSense does not like aliases and fully-qualified // names here. // if (!isense) @@ -1941,6 +1960,24 @@ namespace CXX os << " > " << etraits (m) << ";" << endl; + + // Element id. + // + if (el && ordered_p (c)) + { + if (doxygen) + os << "/**" << endl + << " * @brief Element id used for capturing content " << + "order." << endl + << " */" << endl; + + SemanticGraph::Context& ctx (m.context ()); + + os << "static const ::std::size_t " << + ctx.get ("ordered-id-name") << " = " << + ctx.get ("ordered-id") << "UL;" << endl; + } + member_function_.traverse (m); if (doxygen) @@ -1967,9 +2004,12 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { + SemanticGraph::Complex& c ( + dynamic_cast (a.scope ())); + if (doxygen) { os << "/**" << endl @@ -1990,7 +2030,7 @@ namespace CXX else { os << "// " << ename (a) << endl - << "// " << endl; + << "//" << endl; } // Typedefs. @@ -2060,6 +2100,23 @@ namespace CXX os << endl; } + // Wildcard id. + // + if (ordered_p (c)) + { + if (doxygen) + os << "/**" << endl + << " * @brief Wildcard id used for capturing content " << + "order." << endl + << " */" << endl; + + SemanticGraph::Context& ctx (a.context ()); + + os << "static const ::std::size_t " << + ctx.get ("ordered-id-name") << " = " << + ctx.get ("ordered-id") << "UL;" << endl; + } + any_function_.traverse (a); if (doxygen) @@ -2069,7 +2126,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& container (econtainer (a)); @@ -2095,7 +2152,7 @@ namespace CXX else { os << "// " << ename (a) << endl - << "// " << endl; + << "//" << endl; } if (doxygen) @@ -2152,14 +2209,14 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; String const& member (emember (m)); - Boolean def_attr (m.default_p () && + bool def_attr (m.default_p () && m.is_a ()); if (max (m) != 1) @@ -2186,7 +2243,7 @@ namespace CXX // if (m.default_p ()) { - Boolean simple (true); + bool simple (true); if (m.is_a ()) { @@ -2196,7 +2253,7 @@ namespace CXX if (simple) { - Boolean lit (false); + bool lit (false); { IsLiteralValue test (lit); test.dispatch (m.type ()); @@ -2221,7 +2278,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& member (emember (a)); @@ -2246,7 +2303,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { os << econtainer (a) << " " << emember (a) << ";"; @@ -2269,15 +2326,15 @@ namespace CXX inherits_member_ >> member_name_; names_ >> member_; - if (options.value ()) + if (options.generate_wildcard ()) names_ >> any_; names_data_ >> data_member_; - if (options.value ()) + if (options.generate_wildcard ()) names_data_ >> data_any_; } - virtual Void + virtual void traverse (Type& c) { String name (ename (c)); @@ -2288,20 +2345,25 @@ namespace CXX if (renamed_type (c, name) && !name) return; - Boolean has_members (has (c)); + SemanticGraph::Context& ctx (c.context ()); + + bool has_members (has (c)); - Boolean hae (has (c)); - Boolean haa (has (c)); + bool hae (has (c)); + bool haa (has (c)); - Boolean gen_wildcard (options.value ()); + bool gen_wildcard (options.generate_wildcard ()); - Boolean simple (true); + bool mixed (mixed_p (c) && !ctx.count ("mixed-in-base")); + bool ordered (ordered_p (c) && !ctx.count ("order-in-base")); + + bool simple (true); { IsSimpleType t (simple); t.dispatch (c); } - Boolean string_based (false); + bool string_based (false); { IsStringBasedType t (string_based); t.dispatch (c); @@ -2344,17 +2406,148 @@ namespace CXX // names (c, names_); - // dom_document accessors. + // Mixed content. // - if (edom_document_member_p (c)) + if (mixed) { + String const& type (ctx.get ("mixed-type")); + String const& cont (ctx.get ("mixed-container")); + String const& iter (ctx.get ("mixed-iterator")); + String const& citer (ctx.get ("mixed-const-iterator")); - if (!doxygen) - { - os << "// DOMDocument for wildcard content." << endl + if (doxygen) + os << "/**" << endl + << " * @name " << comment ("text_content") << endl + << " *" << endl + << " * @brief Accessor and modifier functions for text " << + "content." << endl + << " */" << endl + << "//@{" << endl; + else + os << "// text_content" << endl << "//" << endl; - } + // Typedefs. + // + bool isense (options.generate_intellisense ()); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Text content type." << endl + << " */" << endl; + + os << "typedef " << xs_string_type << " " << type << ";"; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Text content sequence container type." << endl + << " */" << endl; + + os << "typedef ::xsd::cxx::tree::sequence< " << type << + " > " << cont << ";"; + + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Text content iterator type." << endl + << " */" << endl; + + // IntelliSense does not like aliases and fully-qualified + // names here. + // + if (!isense) + os << "typedef " << cont << "::iterator " << iter<< ";"; + else + os << "typedef ::xsd::cxx::tree::sequence< " << type << + " >::iterator " << iter << ";"; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Text content constant iterator type." << endl + << " */" << endl; + + if (!isense) + os << "typedef " << cont << "::const_iterator " << citer<< ";"; + else + os << "typedef ::xsd::cxx::tree::sequence< " << type << + " >::const_iterator " << citer << ";"; + + os << endl; + + // Content id. + // + if (doxygen) + os << "/**" << endl + << " * @brief Text content id used for capturing content " << + "order." << endl + << " */" << endl; + + os << "static const ::std::size_t " << + ctx.get ("mixed-ordered-id-name") << " = " << + ctx.get ("mixed-ordered-id") << "UL;" << endl; + + // Accessors and modifiers. + // + String const& aname (ctx.get ("mixed-aname")); + String const& mname (ctx.get ("mixed-mname")); + + if (doxygen) + os << "/**" << endl + << " * @brief Return a read-only (constant) reference " << + "to the text" << endl + << " * content sequence." << endl + << " *" << endl + << " * @return A constant reference to the sequence " << + "container." << endl + << " */" << endl; + + os << "const " << cont << "&" << endl + << aname << " () const;" + << endl; + + if (doxygen) + os << "/**" << endl + << " * @brief Return a read-write reference to the " << + "text content" << endl + << " * sequence." << endl + << " *" << endl + << " * @return A reference to the sequence container." << endl + << " */" << endl; + + os << cont << "&" << endl + << aname << " ();" + << endl; + + if (doxygen) + os << "/**" << endl + << " * @brief Copy elements from a given sequence." << endl + << " *" << endl + << " * @param s A sequence to copy entries from." << endl + << " *" << endl + << " * For each element in @a s this function " << + "add it to the sequence." << endl + << " * Note that this operation " << + "completely changes the sequence and" << endl + << " * all old elements will be lost." << endl + << " */" << endl; + + os << "void" << endl + << mname << " (const " << cont << "& s);" + << endl; + + if (doxygen) + os << "//@}" << endl + << endl; + } + + // dom_document accessors. + // + if (edom_document_member_p (c)) + { if (doxygen) { os << "/**" << endl @@ -2369,6 +2562,9 @@ namespace CXX << " * the raw XML content corresponding to wildcards." << endl << " */" << endl; } + else + os << "// DOMDocument for wildcard content." << endl + << "//" << endl; os << "const " << xerces_ns << "::DOMDocument&" << endl << edom_document (c) << " () const;" @@ -2393,6 +2589,137 @@ namespace CXX << endl; } + // Order container. + // + if (ordered) + { + String const& type (ctx.get ("order-type")); + String const& cont (ctx.get ("order-container")); + String const& iter (ctx.get ("order-iterator")); + String const& citer (ctx.get ("order-const-iterator")); + + String const ct (options.order_container_specified () + ? options.order_container () + : "::std::vector"); + + if (doxygen) + os << "/**" << endl + << " * @name " << comment ("content_order") << endl + << " *" << endl + << " * @brief Accessor and modifier functions for content " << + "order." << endl + << " */" << endl + << "//@{" << endl; + else + os << "// content_order" << endl + << "//" << endl; + + // Typedefs. + // + bool isense (options.generate_intellisense ()); + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Content order entry type." << endl + << " */" << endl; + + os << "typedef " << ns_name (xs_ns ()) << "::" << + xs_ns ().context ().get ("content-order") << " " << + type << ";"; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Content order sequence container type." << endl + << " */" << endl; + + os << "typedef " << ct << "< " << type << " > " << cont << ";"; + + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Content order iterator type." << endl + << " */" << endl; + + // IntelliSense does not like aliases and fully-qualified + // names here. + // + if (!isense) + os << "typedef " << cont << "::iterator " << iter<< ";"; + else + os << "typedef " << ct << "< " << type << " >::iterator " << + iter << ";"; + + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Content order constant iterator type." << endl + << " */" << endl; + + if (!isense) + os << "typedef " << cont << "::const_iterator " << citer<< ";"; + else + os << "typedef " << ct << "< " << type << + " >::const_iterator " << citer << ";"; + + os << endl; + + // Accessors and modifiers. + // + String const& aname (ctx.get ("order-aname")); + String const& mname (ctx.get ("order-mname")); + + if (doxygen) + os << "/**" << endl + << " * @brief Return a read-only (constant) reference " << + "to the content" << endl + << " * order sequence." << endl + << " *" << endl + << " * @return A constant reference to the sequence " << + "container." << endl + << " */" << endl; + + os << "const " << cont << "&" << endl + << aname << " () const;" + << endl; + + if (doxygen) + os << "/**" << endl + << " * @brief Return a read-write reference to the " << + "content order" << endl + << " * sequence." << endl + << " *" << endl + << " * @return A reference to the sequence container." << endl + << " */" << endl; + + os << cont << "&" << endl + << aname << " ();" + << endl; + + if (doxygen) + os << "/**" << endl + << " * @brief Copy elements from a given sequence." << endl + << " *" << endl + << " * @param s A sequence to copy entries from." << endl + << " *" << endl + << " * For each element in @a s this function " << + "add it to the sequence." << endl + << " * Note that this operation " << + "completely changes the sequence and" << endl + << " * all old elements will be lost." << endl + << " */" << endl; + + os << "void" << endl + << mname << " (const " << cont << "& s);" + << endl; + + if (doxygen) + os << "//@}" << endl + << endl; + } + if (doxygen) { os << "/**" << endl @@ -2407,15 +2734,15 @@ namespace CXX << "//" << endl; } - 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, @@ -2426,7 +2753,7 @@ namespace CXX // default c-tor // - if (options.value ()) + if (options.generate_default_ctor ()) { // c-tor (ultimate-base, all-non-optional-members) will become // default c-tor if our inheritance hierarchy has no required @@ -2434,7 +2761,7 @@ namespace CXX // c-tor (all-non-optional-members) if we have no required // members. // - Boolean generate (false); + bool generate (false); { GenerateDefaultCtor t (*this, generate, generate_no_base_ctor); t.traverse (c); @@ -2460,7 +2787,7 @@ namespace CXX // c-tor (base, all-non-optional-members) // - if (options.value ()) + if (options.generate_from_base_ctor ()) { // c-tor (base, all-non-optional-members) will be equivalent to // c-tor (ultimate-base, all-non-optional-members) unless our @@ -2470,7 +2797,7 @@ namespace CXX // customized version may not necessarily be convertible to // the base without loss of information. // - Boolean generate (false); + bool generate (false); { GenerateFromBaseCtor t (*this, generate); t.traverse (c); @@ -2478,9 +2805,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, @@ -2505,7 +2832,7 @@ namespace CXX inherits (c, inherits_member_); os << "&"; { - FromBaseCtorArg args (*this, FromBaseCtorArg::arg_type, false); + FromBaseCtorArg args (*this, CtorArgType::type, false); Traversal::Names args_names (args); names (c, args_names); } @@ -2524,7 +2851,7 @@ namespace CXX "base and" << endl << " * initializers for required elements and " << "attributes" << endl - << " * (auto_ptr version)." << endl + << " * (" << auto_ptr << " version)." << endl << " *" << endl << " * This constructor will try to use the passed " << "values directly" << endl @@ -2537,7 +2864,7 @@ namespace CXX os << "&"; { FromBaseCtorArg args ( - *this, FromBaseCtorArg::arg_complex_auto_ptr, false); + *this, CtorArgType::complex_auto_ptr, false); Traversal::Names args_names (args); names (c, args_names); } @@ -2558,7 +2885,7 @@ namespace CXX "base and" << endl << " * initializers for required elements and " << "attributes" << endl - << " * (auto_ptr version)." << endl + << " * (" << auto_ptr << " version)." << endl << " *" << endl << " * This constructor will try to use the passed " << "values directly" << endl @@ -2571,7 +2898,7 @@ namespace CXX os << "&"; { FromBaseCtorArg args ( - *this, FromBaseCtorArg::arg_poly_auto_ptr, false); + *this, CtorArgType::poly_auto_ptr, false); Traversal::Names args_names (args); names (c, args_names); } @@ -2597,7 +2924,7 @@ namespace CXX os << name << " ("; { CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, false, true); + *this, CtorArgType::type, false, true); ctor_args.dispatch (c); } os << ");" @@ -2615,7 +2942,8 @@ namespace CXX os << "/**" << endl << " * @brief Create an instance from initializers " << "for required " << endl - << " * elements and attributes (auto_ptr version)." << endl + << " * elements and attributes (" << auto_ptr << + " version)." << endl << " *" << endl << " * This constructor will try to use the passed " << "values directly" << endl @@ -2626,7 +2954,7 @@ namespace CXX os << name << " ("; { CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_complex_auto_ptr, false, true); + *this, CtorArgType::complex_auto_ptr, false, true); ctor_args.dispatch (c); } os << ");" @@ -2644,7 +2972,8 @@ namespace CXX os << "/**" << endl << " * @brief Create an instance from initializers " << "for required " << endl - << " * elements and attributes (auto_ptr version)." << endl + << " * elements and attributes (" << auto_ptr << + " version)." << endl << " *" << endl << " * This constructor will try to use the passed " << "values directly" << endl @@ -2655,7 +2984,7 @@ namespace CXX os << name << " ("; { CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_poly_auto_ptr, false, true); + *this, CtorArgType::poly_auto_ptr, false, true); ctor_args.dispatch (c); } os << ");" @@ -2686,7 +3015,7 @@ namespace CXX { CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, false, false); + *this, CtorArgType::type, false, false); ctor_args.dispatch (c); } @@ -2709,7 +3038,7 @@ namespace CXX { CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, false, false); + *this, CtorArgType::type, false, false); ctor_args.dispatch (c); } @@ -2731,7 +3060,7 @@ namespace CXX { CtorArgsWithoutBase ctor_args ( - *this, CtorArgsWithoutBase::arg_type, false, false); + *this, CtorArgType::type, false, false); ctor_args.dispatch (c); } @@ -2755,7 +3084,7 @@ namespace CXX os << name << " ("; { - CtorArgs ctor_args (*this, CtorArgs::arg_type); + CtorArgs ctor_args (*this, CtorArgType::type); ctor_args.dispatch (c); } @@ -2774,7 +3103,7 @@ namespace CXX "base and" << endl << " * initializers for required elements and " << "attributes" << endl - << " * (auto_ptr version)." << endl + << " * (" << auto_ptr << " version)." << endl << " *" << endl << " * This constructor will try to use the passed " << "values directly" << endl @@ -2785,7 +3114,7 @@ namespace CXX os << name << " ("; { - CtorArgs ctor_args (*this, CtorArgs::arg_complex_auto_ptr); + CtorArgs ctor_args (*this, CtorArgType::complex_auto_ptr); ctor_args.dispatch (c); } @@ -2805,7 +3134,7 @@ namespace CXX "base and" << endl << " * initializers for required elements and " << "attributes" << endl - << " * (auto_ptr version)." << endl + << " * (" << auto_ptr << " version)." << endl << " *" << endl << " * This constructor will try to use the passed " << "values directly" << endl @@ -2816,7 +3145,7 @@ namespace CXX os << name << " ("; { - CtorArgs ctor_args (*this, CtorArgs::arg_poly_auto_ptr); + CtorArgs ctor_args (*this, CtorArgType::poly_auto_ptr); ctor_args.dispatch (c); } @@ -2826,8 +3155,9 @@ namespace CXX // c-tor (istream&) // - Streams const& st (options.value ()); - for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i) + NarrowStrings const& st (options.generate_extraction ()); + for (NarrowStrings::const_iterator i (st.begin ()); i != st.end (); + ++i) { if (doxygen) { @@ -2852,7 +3182,7 @@ namespace CXX } - if (!options.value ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -2969,12 +3299,61 @@ namespace CXX << container << "* c = 0) const;" << endl; + // operator= + // + bool priv (false); + + if (!simple) + { + if (options.suppress_assignment ()) + { + priv = true; + os << "private:" << endl; + + if (doxygen) + { + os << "/**" << endl + << " * @brief Disabled copy assignment operator." << endl + << " *" << endl + << " * @param x An instance to make a copy of." << endl + << " * @return A reference to itself." << endl + << " */" << endl; + } + + os << name << "&" << endl + << "operator= (const " << name << "& x);" + << endl; + } + else if (has_members || (gen_wildcard && (hae || haa))) + { + if (doxygen) + { + os << "/**" << endl + << " * @brief Copy assignment operator." << endl + << " *" << endl + << " * @param x An instance to make a copy of." << endl + << " * @return A reference to itself." << endl + << " *" << endl + << " * For polymorphic object models use the @c _clone " << + "function instead." << endl + << " */" << endl; + } + + os << name << "&" << endl + << "operator= (const " << name << "& x);" + << endl; + } + } + if (doxygen) { os << "//@}" << endl << endl; } + if (priv) + os << "public:" << endl; + // d-tor // if (doxygen) @@ -2990,7 +3369,7 @@ namespace CXX // Data members and implementation functions. // - if (has_members || hae || (haa && gen_wildcard)) + if (has_members || hae || (haa && gen_wildcard) || ordered || mixed) { os << "// Implementation." << endl << "//" << endl; @@ -3000,9 +3379,10 @@ namespace CXX << "//@cond" << endl << endl; - if (!options.value ()) + if (!options.suppress_parsing () && + (has_members || hae || (haa && gen_wildcard) || mixed)) { - // parse (xercesc::DOMElement) + // parse () // os << "protected:" << endl << "void" << endl @@ -3019,7 +3399,8 @@ namespace CXX // if (has_members) { - for (Streams::ConstIterator i (st.begin ()); i != st.end (); ++i) + for (NarrowStrings::const_iterator i (st.begin ()); i != st.end (); + ++i) { os << "void" << endl << unclash (name, "parse") << " (" << @@ -3029,7 +3410,7 @@ namespace CXX } } - // + // DOM document. // if (edom_document_member_p (c)) { @@ -3038,6 +3419,24 @@ namespace CXX << endl; } + // Mixed text content. + // + if (mixed) + { + os << ctx.get ("mixed-container") << " " << + ctx.get ("mixed-member") << ";" + << endl; + } + + // Order container. + // + if (ordered) + { + os << ctx.get ("order-container") << " " << + ctx.get ("order-member") << ";" + << endl; + } + // // names (c, names_data_); @@ -3051,7 +3450,7 @@ namespace CXX // Comparison operators. // - if (options.value () && + if (options.generate_comparison () && (has_members || !c.inherits_p () || ((hae || haa) && gen_wildcard))) { @@ -3095,7 +3494,7 @@ namespace CXX belongs_ >> type_name_; } - virtual Void + virtual void traverse (Type& e) { if (!doc_root_p (e)) @@ -3103,13 +3502,13 @@ namespace CXX 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); @@ -3274,7 +3673,7 @@ namespace CXX } os << "void" << endl - << mname << " (::std::auto_ptr< " << type << " > p);" + << mname << " (" << auto_ptr << "< " << type << " > p);" << endl; } @@ -3296,7 +3695,7 @@ namespace CXX << " */" << endl; } - os << "::std::auto_ptr< " << type << " >" << endl + os << auto_ptr << "< " << type << " >" << endl << edname (e) << " ();" << endl; } @@ -3357,7 +3756,7 @@ namespace CXX // default c-tor // - if (options.value ()) + if (options.generate_default_ctor ()) { if (doxygen) { @@ -3403,7 +3802,8 @@ namespace CXX os << "/**" << endl << " * @brief Create an instance from an initializer " << "for" << endl - << " * the element value (auto_ptr version)." << endl + << " * the element value (" << auto_ptr << + " version)." << endl << " *" << endl << " * @param p Element value to use." << endl << " *" << endl @@ -3413,11 +3813,11 @@ namespace CXX << " */" << endl; } - os << name << " (::std::auto_ptr< " << type << " > p);" + os << name << " (" << auto_ptr << "< " << type << " > p);" << endl; } - if (!options.value ()) + if (!options.suppress_parsing ()) { // c-tor (xercesc::DOMElement) // @@ -3608,7 +4008,7 @@ namespace CXX }; } - Void + void generate_tree_header (Context& ctx) { if (ctx.generate_xml_schema) @@ -3625,21 +4025,21 @@ namespace CXX << "#include " << endl << endl; - if (!ctx.options.value () || - ctx.options.value ()) + if (!ctx.options.suppress_parsing () || + ctx.options.generate_serialization ()) { ctx.os << "#include " << endl << endl; } - if (!ctx.options.value () || - ctx.options.value ()) + if (!ctx.options.suppress_parsing () || + ctx.options.generate_serialization ()) { ctx.os << "#include " << endl << endl; } - Boolean element_map (ctx.options.value ()); + bool element_map (ctx.options.generate_element_map ()); if (element_map) ctx.os << "#include " << endl @@ -3649,7 +4049,7 @@ namespace CXX // later in the individual generators for each feature because // those headers provide implementation for the fundamental types. // - if (!ctx.options.value ()) + if (!ctx.options.suppress_parsing ()) { ctx.os << "#include " << endl; @@ -3670,7 +4070,7 @@ namespace CXX ctx.os << endl; } - if (ctx.options.value ()) + if (ctx.options.generate_serialization ()) { ctx.os << "#include " << endl << "#include " << endl; @@ -3692,16 +4092,17 @@ namespace CXX ctx.os << endl; } - if (ctx.options.value ()) + if (ctx.options.generate_ostream ()) { ctx.os << "#include " << endl << endl; } - Streams const& ist (ctx.options.value ()); + NarrowStrings const& ist (ctx.options.generate_insertion ()); if (!ist.empty ()) { - for (Streams::ConstIterator i (ist.begin ()); i != ist.end (); ++i) + for (NarrowStrings::const_iterator i (ist.begin ()); i != ist.end (); + ++i) { if (*i == "ACE_OutputCDR") ctx.os << "#include " @@ -3715,10 +4116,11 @@ namespace CXX << endl; } - Streams const& est (ctx.options.value ()); + NarrowStrings const& est (ctx.options.generate_extraction ()); if (!est.empty ()) { - for (Streams::ConstIterator i (est.begin ()); i != est.end (); ++i) + for (NarrowStrings::const_iterator i (est.begin ()); i != est.end (); + ++i) { if (*i == "ACE_InputCDR") ctx.os << "#include " @@ -3746,12 +4148,25 @@ namespace CXX } else { - Boolean inline_ (ctx.options.value ()); + bool inline_ (ctx.options.generate_inline ()); - ctx.os << "#include // std::auto_ptr" << endl + ctx.os << "#include // " << ctx.auto_ptr << endl << "#include // std::numeric_limits" << endl - << "#include // std::binary_search" << endl - << endl; + << "#include // std::binary_search" << endl; + + if (ctx.std >= cxx_version::cxx11) + ctx.os << "#include // std::move" << endl; + + if (!ctx.options.ordered_type ().empty () || + ctx.options.ordered_type_all ()) + { + ctx.os << "#include // std::size_t" << endl; + + if (!ctx.options.order_container_specified ()) + ctx.os << "#include " << endl; + } + + ctx.os << endl; if (ctx.char_type == L"char" && ctx.char_encoding != L"custom") { @@ -3766,23 +4181,23 @@ namespace CXX << "#include " << endl << endl; - if (!ctx.options.value ()) + if (!ctx.options.suppress_parsing ()) { ctx.os << "#include " << endl << endl; } - if (ctx.options.value ()) + if (ctx.options.generate_wildcard ()) { - if (ctx.options.value () || - !ctx.options.value ()) + if (ctx.options.suppress_parsing () || + !ctx.options.generate_serialization ()) ctx.os << "#include " << endl; ctx.os << "#include " << endl << endl; } - if (!ctx.options.value ().empty ()) + if (!ctx.options.generate_extraction ().empty ()) ctx.os << "#include " << endl << endl; @@ -3820,7 +4235,7 @@ namespace CXX { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names names_ns, names; DocumentedNamespace ns (ctx); @@ -3839,7 +4254,7 @@ namespace CXX names >> complex; names >> enumeration; - if (ctx.options.value ()) + if (ctx.options.generate_element_type ()) names >> element; schema.dispatch (ctx.schema_root); -- cgit v1.2.3