diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
commit | bada6666c70977a058755ccf232e7d67b24adeed (patch) | |
tree | 1e92d50cebce96abaf9bce19e36026c47f77b9ba /xsd/xsd/cxx/tree/name-processor.cxx | |
parent | eaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff) |
New upstream release
Diffstat (limited to 'xsd/xsd/cxx/tree/name-processor.cxx')
-rw-r--r-- | xsd/xsd/cxx/tree/name-processor.cxx | 622 |
1 files changed, 441 insertions, 181 deletions
diff --git a/xsd/xsd/cxx/tree/name-processor.cxx b/xsd/xsd/cxx/tree/name-processor.cxx index 4949bed..1f3844b 100644 --- a/xsd/xsd/cxx/tree/name-processor.cxx +++ b/xsd/xsd/cxx/tree/name-processor.cxx @@ -1,51 +1,45 @@ // file : xsd/cxx/tree/name-processor.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <set> +#include <map> +#include <vector> #include <sstream> #include <iostream> -#include <cult/containers/set.hxx> -#include <cult/containers/map.hxx> -#include <cult/containers/vector.hxx> - -#include <backend-elements/regex.hxx> +#include <cutl/re.hxx> #include <cxx/tree/default-value.hxx> #include <cxx/tree/name-processor.hxx> +using namespace std; + namespace CXX { namespace Tree { - NameProcessor:: - NameProcessor () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - namespace { // // - typedef Cult::Containers::Set<String> NameSet; + typedef set<String> NameSet; class Context: public Tree::Context { public: struct Failed {}; - Context (CLI::Options const& options, + Context (Tree::options const& ops, Counts const& counts, - Boolean generate_xml_schema, + bool generate_xml_schema, SemanticGraph::Schema& root, SemanticGraph::Path const& path, StringLiteralMap const& map) : Tree::Context (std::wcerr, root, path, - options, + ops, counts, generate_xml_schema, &map, @@ -54,7 +48,7 @@ namespace CXX 0), global_type_names (global_type_names_), global_element_names (global_element_names_), - detach (options.value<CLI::generate_detach> ()), + detach (ops.generate_detach ()), type_regex (type_regex_), accessor_regex (accessor_regex_), one_accessor_regex (one_accessor_regex_), @@ -66,14 +60,12 @@ namespace CXX seq_modifier_regex (seq_modifier_regex_), parser_regex (parser_regex_), serializer_regex (serializer_regex_), + const_regex (const_regex_), enumerator_regex (enumerator_regex_), element_type_regex (element_type_regex_) { - typedef Containers::Vector<NarrowString> Vector; - - NarrowString tn (options.value<CLI::type_naming> ()); - NarrowString fn (options.value<CLI::function_naming> ()); - + NarrowString tn (options.type_naming ()); + NarrowString fn (options.function_naming ()); // Type name regex. // @@ -116,9 +108,7 @@ namespace CXX } - compile_regex (options.value<CLI::type_regex> (), - type_regex, - "type"); + compile_regex (options.type_regex (), type_regex, "type"); } // Accessor name regex. @@ -149,24 +139,23 @@ namespace CXX accessor_regex.push_back ("/([^,]+)/get\\u$1/"); } - compile_regex (options.value<CLI::accessor_regex> (), + compile_regex (options.accessor_regex (), accessor_regex, "accessor"); - compile_regex (options.value<CLI::one_accessor_regex> (), + compile_regex (options.one_accessor_regex (), one_accessor_regex, "one accessor"); - compile_regex (options.value<CLI::opt_accessor_regex> (), + compile_regex (options.opt_accessor_regex (), opt_accessor_regex, "optional accessor"); - compile_regex (options.value<CLI::seq_accessor_regex> (), + compile_regex (options.seq_accessor_regex (), seq_accessor_regex, "sequence accessor"); } - // Modifier name regex. // { @@ -190,24 +179,23 @@ namespace CXX modifier_regex.push_back ("/detach,([^,]+)/detach\\u$1/"); } - compile_regex (options.value<CLI::modifier_regex> (), + compile_regex (options.modifier_regex (), modifier_regex, "modifier"); - compile_regex (options.value<CLI::one_modifier_regex> (), + compile_regex (options.one_modifier_regex (), one_modifier_regex, "one modifier"); - compile_regex (options.value<CLI::opt_modifier_regex> (), + compile_regex (options.opt_modifier_regex (), opt_modifier_regex, "optional modifier"); - compile_regex (options.value<CLI::seq_modifier_regex> (), + compile_regex (options.seq_modifier_regex (), seq_modifier_regex, "sequence modifier"); } - // Parser name regex. // { @@ -222,9 +210,7 @@ namespace CXX parser_regex.push_back ("/(.+)/parse\\u$1/"); } - compile_regex (options.value<CLI::parser_regex> (), - parser_regex, - "parser"); + compile_regex (options.parser_regex (), parser_regex, "parser"); } // Serializer name regex. @@ -241,11 +227,35 @@ namespace CXX serializer_regex.push_back ("/(.+)/serialize\\u$1/"); } - compile_regex (options.value<CLI::serializer_regex> (), + compile_regex (options.serializer_regex (), serializer_regex, "serializer"); } + // Const regex. + // + { + if (fn == "knr") + { + const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/$1_$2_$3/"); + const_regex.push_back ("/([^,]+),([^,]+)/$1_$2/"); + } + else if (fn == "lcc") + { + const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1_\\u$2_\\u$3/"); + const_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/"); + } + else + { + // Java: all uppercase. + // + const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\U$1_$2_$3/"); + const_regex.push_back ("/([^,]+),([^,]+)/\\U$1_$2/"); + } + + compile_regex (options.const_regex (), const_regex, "const"); + } + // Enumerator name regex. // { @@ -253,14 +263,14 @@ namespace CXX // enumerator_regex.push_back ("/^$/empty/"); - compile_regex (options.value<CLI::enumerator_regex> (), + compile_regex (options.enumerator_regex (), enumerator_regex, "enumerator"); } // Element type regex. // - compile_regex (options.value<CLI::element_type_regex> (), + compile_regex (options.element_type_regex (), element_type_regex, "element_type"); } @@ -282,35 +292,44 @@ namespace CXX seq_modifier_regex (c.seq_modifier_regex), parser_regex (c.parser_regex), serializer_regex (c.serializer_regex), + const_regex (c.const_regex), enumerator_regex (c.enumerator_regex), element_type_regex (c.element_type_regex) { } public: - typedef BackendElements::Regex::Expression<WideChar> Regex; - typedef BackendElements::Regex::Format<WideChar> RegexFormat; - typedef Cult::Containers::Vector<Regex> RegexVector; + typedef cutl::re::wregexsub Regex; + typedef cutl::re::wformat RegexFormat; + + struct RegexVector: vector<Regex> + { + void + push_back (String const& r) + { + vector<Regex>::push_back (Regex (r)); + } + }; String process_regex (String const& name, RegexVector const& rv, String const& id) { - Boolean trace (options.value<CLI::name_regex_trace> ()); + bool trace (options.name_regex_trace ()); if (trace) os << id << " name: '" << name << "'" << endl; - for (RegexVector::ConstReverseIterator i (rv.rbegin ()); + for (RegexVector::const_reverse_iterator i (rv.rbegin ()); i != rv.rend (); ++i) { if (trace) - os << "try: '" << i->pattern () << "' : "; + os << "try: '" << i->regex () << "' : "; if (i->match (name)) { - String r (i->merge (name)); + String r (i->replace (name)); if (trace) os << "'" << r << "' : +" << endl; @@ -331,20 +350,20 @@ namespace CXX RegexVector const& backup, String const& id) { - Boolean trace (options.value<CLI::name_regex_trace> ()); + bool trace (options.name_regex_trace ()); if (trace) os << id << " name: '" << name << "'" << endl; - for (RegexVector::ConstReverseIterator i (primary.rbegin ()); + for (RegexVector::const_reverse_iterator i (primary.rbegin ()); i != primary.rend (); ++i) { if (trace) - os << "try: '" << i->pattern () << "' : "; + os << "try: '" << i->regex () << "' : "; if (i->match (name)) { - String r (i->merge (name)); + String r (i->replace (name)); if (trace) os << "'" << r << "' : +" << endl; @@ -356,15 +375,15 @@ namespace CXX os << '-' << endl; } - for (RegexVector::ConstReverseIterator i (backup.rbegin ()); + for (RegexVector::const_reverse_iterator i (backup.rbegin ()); i != backup.rend (); ++i) { if (trace) - os << "try: '" << i->pattern () << "' : "; + os << "try: '" << i->regex () << "' : "; if (i->match (name)) { - String r (i->merge (name)); + String r (i->replace (name)); if (trace) os << "'" << r << "' : +" << endl; @@ -386,20 +405,20 @@ namespace CXX String const& id) { String s (ns + L' ' + name); - Boolean trace (options.value<CLI::name_regex_trace> ()); + bool trace (options.name_regex_trace ()); if (trace) os << id << " name: '" << s << "'" << endl; - for (RegexVector::ConstReverseIterator i (rv.rbegin ()); + for (RegexVector::const_reverse_iterator i (rv.rbegin ()); i != rv.rend (); ++i) { if (trace) - os << "try: '" << i->pattern () << "' : "; + os << "try: '" << i->regex () << "' : "; if (i->match (s)) { - String r (i->merge (s)); + String r (i->replace (s)); if (trace) os << "'" << r << "' : +" << endl; @@ -422,20 +441,20 @@ namespace CXX String const& id) { String s (ns + L' ' + name); - Boolean trace (options.value<CLI::name_regex_trace> ()); + bool trace (options.name_regex_trace ()); if (trace) os << id << " name: '" << s << "'" << endl; - for (RegexVector::ConstReverseIterator i (primary.rbegin ()); + for (RegexVector::const_reverse_iterator i (primary.rbegin ()); i != primary.rend (); ++i) { if (trace) - os << "try: '" << i->pattern () << "' : "; + os << "try: '" << i->regex () << "' : "; if (i->match (s)) { - String r (i->merge (s)); + String r (i->replace (s)); if (trace) os << "'" << r << "' : +" << endl; @@ -447,15 +466,15 @@ namespace CXX os << '-' << endl; } - for (RegexVector::ConstReverseIterator i (backup.rbegin ()); + for (RegexVector::const_reverse_iterator i (backup.rbegin ()); i != backup.rend (); ++i) { if (trace) - os << "try: '" << i->pattern () << "' : "; + os << "try: '" << i->regex () << "' : "; if (i->match (s)) { - String r (i->merge (s)); + String r (i->replace (s)); if (trace) os << "'" << r << "' : +" << endl; @@ -474,11 +493,11 @@ namespace CXX String find_name (String const& base_name, NameSet& set, - Boolean insert = true) + bool insert = true) { String name (base_name); - for (UnsignedLong i (1); set.find (name) != set.end (); ++i) + for (size_t i (1); set.find (name) != set.end (); ++i) { std::wostringstream os; os << i; @@ -492,23 +511,22 @@ namespace CXX } private: - Void - compile_regex (Containers::Vector<NarrowString> const& sv, + void + compile_regex (NarrowStrings const& sv, RegexVector& rv, String const& id) { - typedef Containers::Vector<NarrowString> Vector; - - for (Vector::ConstIterator i (sv.begin ()); i != sv.end (); ++i) + for (NarrowStrings::const_iterator i (sv.begin ()); i != sv.end (); + ++i) { try { - rv.push_back (Regex (*i)); + rv.push_back (*i); } catch (RegexFormat const& e) { os << "error: invalid " << id << " name regex: '" << - e.expression () << "': " << e.description () << endl; + e.regex () << "': " << e.description ().c_str () << endl; throw Failed (); } @@ -516,8 +534,8 @@ namespace CXX } private: - Cult::Containers::Map<String, NameSet> global_type_names_; - Cult::Containers::Map<String, NameSet> global_element_names_; + map<String, NameSet> global_type_names_; + map<String, NameSet> global_element_names_; RegexVector type_regex_; RegexVector accessor_regex_; @@ -530,14 +548,15 @@ namespace CXX RegexVector seq_modifier_regex_; RegexVector parser_regex_; RegexVector serializer_regex_; + RegexVector const_regex_; RegexVector enumerator_regex_; RegexVector element_type_regex_; public: - Cult::Containers::Map<String, NameSet>& global_type_names; - Cult::Containers::Map<String, NameSet>& global_element_names; + map<String, NameSet>& global_type_names; + map<String, NameSet>& global_element_names; - Boolean detach; + bool detach; RegexVector& type_regex; RegexVector& accessor_regex; @@ -550,6 +569,7 @@ namespace CXX RegexVector& seq_modifier_regex; RegexVector& parser_regex; RegexVector& serializer_regex; + RegexVector& const_regex; RegexVector& enumerator_regex; RegexVector& element_type_regex; }; @@ -563,7 +583,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { // Process the name with enumerator name regex. @@ -590,7 +610,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { // Use processed name. @@ -630,7 +650,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Tree::Context::skip (m)) @@ -657,20 +677,23 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Tree::Context::skip (m)) return; - UnsignedLong max (Tree::Context::max (m)); - UnsignedLong min (Tree::Context::min (m)); + SemanticGraph::Complex& c ( + dynamic_cast<SemanticGraph::Complex&> (m.scope ())); + + size_t max (Tree::Context::max (m)); + size_t min (Tree::Context::min (m)); String const& s (m.context ().get<String> ("stem")); String const& b (m.context ().get<String> ("name")); - Boolean def_attr (m.default_p () && - m.is_a<SemanticGraph::Attribute> ()); + bool def_attr (m.default_p () && + m.is_a<SemanticGraph::Attribute> ()); // Accessors/modifiers. Note that we postpone inserting // the names into the name_set to avoid over-escaping. @@ -809,7 +832,7 @@ namespace CXX // if (m.default_p ()) { - Boolean simple (true); + bool simple (true); if (m.is_a<SemanticGraph::Element> ()) { @@ -824,9 +847,9 @@ namespace CXX process_regex ( s + L",default,value", accessor_regex, L"accessor"))); - m.context ().set ( "default-value", find_name (an, name_set_)); + m.context ().set ("default-value", find_name (an, name_set_)); - Boolean lit (false); + bool lit (false); { IsLiteralValue test (lit); test.dispatch (m.type ()); @@ -840,6 +863,18 @@ namespace CXX } } } + + // Element id. + // + if (m.is_a<SemanticGraph::Element> () && ordered_p (c)) + { + String id ( + escape ( + process_regex ( + s + L",id", const_regex, L"const"))); + + m.context ().set ("ordered-id-name", find_name (id, name_set_)); + } } private: @@ -854,7 +889,7 @@ namespace CXX Any (Context& c, NameSet& name_set, NameSet& stem_set, - Boolean& has_wildcard) + bool& has_wildcard) : Context (c), name_set_ (name_set), stem_set_ (stem_set), @@ -862,11 +897,14 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { - UnsignedLong max (Tree::Context::max (a)); - UnsignedLong min (Tree::Context::min (a)); + SemanticGraph::Complex& c ( + dynamic_cast<SemanticGraph::Complex&> (a.scope ())); + + size_t max (Tree::Context::max (a)); + size_t min (Tree::Context::min (a)); String s (find_name (L"any", stem_set_)); @@ -980,11 +1018,23 @@ namespace CXX // a.context ().set ("member", find_name (b + L"_", name_set_)); + // Wildcard id. + // + if (ordered_p (c)) + { + String id ( + escape ( + process_regex ( + s + L",id", const_regex, L"const"))); + + a.context ().set ("ordered-id-name", find_name (id, name_set_)); + } + if (!has_wildcard_) has_wildcard_ = true; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String s (find_name (L"any,attribute", stem_set_)); @@ -1050,7 +1100,7 @@ namespace CXX private: NameSet& name_set_; NameSet& stem_set_; - Boolean& has_wildcard_; + bool& has_wildcard_; }; // @@ -1062,20 +1112,20 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { - SemanticGraph::Context& cc (c.context ()); + SemanticGraph::Context& ctx (c.context ()); // We leave this set around to allow other mappings to use // this information. // - cc.set ("cxx-tree-name-processor-stem-set", NameSet ()); - cc.set ("cxx-tree-name-processor-member-set", NameSet ()); + ctx.set ("cxx-tree-name-processor-stem-set", NameSet ()); + ctx.set ("cxx-tree-name-processor-member-set", NameSet ()); // Use processed name. // - String name (cc.get<String> ("name")); + String name (ctx.get<String> ("name")); // If renamed name is empty then we are not generating // anything for this type and name processing is not @@ -1085,10 +1135,10 @@ namespace CXX return; NameSet& stem_set ( - cc.get<NameSet> ("cxx-tree-name-processor-stem-set")); + ctx.get<NameSet> ("cxx-tree-name-processor-stem-set")); NameSet& member_set ( - cc.get<NameSet> ("cxx-tree-name-processor-member-set")); + ctx.get<NameSet> ("cxx-tree-name-processor-member-set")); stem_set.insert (c.name ()); member_set.insert (name); @@ -1144,11 +1194,121 @@ namespace CXX Complex::names (c, names); } + // Names for the mixed content. + // + if (mixed_p (c)) + { + // Check if we already have the mixed content down inheritance + // hierarchy. + // + using SemanticGraph::Complex; + + for (Complex* p (&c); p->inherits_p ();) + { + if (Complex* b = dynamic_cast<Complex*> ( + &p->inherits ().base ())) + { + if (mixed_p (*b)) + { + SemanticGraph::Context& bctx (b->context ()); + ctx.set ("mixed-type", bctx.get<String> ("mixed-type")); + ctx.set ("mixed-const-iterator", + bctx.get<String> ("mixed-const-iterator")); + ctx.set ("mixed-ordered-id-name", + bctx.get<String> ("mixed-ordered-id-name")); + ctx.set ("mixed-aname", bctx.get<String> ("mixed-aname")); + ctx.set ("mixed-member", bctx.get<String> ("mixed-member")); + ctx.set ("mixed-in-base", true); + break; + } + + p = b; + } + else + break; + } + + // If not, set up the names. + // + if (!ctx.count ("mixed-in-base")) + { + String s (find_name (L"text,content", stem_set)); + String n (find_name (escape (s), member_set, false)); + + String an (find_name ( + escape (process_regex (s, + seq_accessor_regex, + accessor_regex, + L"sequence accessor")), + member_set, + false)); + + String mn (find_name ( + escape (process_regex (s, + seq_modifier_regex, + modifier_regex, + L"sequence modifier")), + member_set, + false)); + + ctx.set ("mixed-aname", an); + ctx.set ("mixed-mname", mn); + + member_set.insert (name); + + if (an != n) + member_set.insert (an); + + if (mn != n && mn != an) + member_set.insert (mn); + + // Types. + // + ctx.set ( + "mixed-type", + find_name ( + escape (process_regex (s + L",type", type_regex, L"type")), + member_set)); + + ctx.set ( + "mixed-container", + find_name ( + escape (process_regex (s + L",sequence", type_regex, L"type")), + member_set)); + + ctx.set ( + "mixed-iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + member_set)); + + ctx.set ( + "mixed-const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + member_set)); + + // Text content id. + // + ctx.set ( + "mixed-ordered-id-name", + find_name ( + escape ( + process_regex (s + L",id", const_regex, L"const")), + member_set)); + + // Data member. + // + ctx.set ("mixed-member", find_name (n + L"_", member_set)); + } + } + // Names for wildcards. // - if (options.value<CLI::generate_wildcard> ()) + if (options.generate_wildcard ()) { - Boolean has_wildcard (false); + bool has_wildcard (false); Any any (*this, member_set, stem_set, has_wildcard); Traversal::Names names (any); Complex::names (c, names); @@ -1198,6 +1358,105 @@ namespace CXX } } } + + // Names for the order container. + // + if (ordered_p (c)) + { + // Check if we already have the order container down + // inheritance hierarchy. + // + using SemanticGraph::Complex; + + for (Complex* p (&c); p->inherits_p ();) + { + if (Complex* b = dynamic_cast<Complex*> ( + &p->inherits ().base ())) + { + if (ordered_p (*b)) + { + SemanticGraph::Context& bctx (b->context ()); + ctx.set ("order-type", bctx.get<String> ("order-type")); + ctx.set ("order-const-iterator", + bctx.get<String> ("order-const-iterator")); + ctx.set ("order-aname", bctx.get<String> ("order-aname")); + ctx.set ("order-member", bctx.get<String> ("order-member")); + ctx.set ("order-in-base", true); + break; + } + + p = b; + } + else + break; + } + + // If not, set up the names. + // + if (!ctx.count ("order-in-base")) + { + String s (find_name (L"content,order", stem_set)); + String n (find_name (escape (s), member_set, false)); + + String an (find_name ( + escape (process_regex (s, + seq_accessor_regex, + accessor_regex, + L"sequence accessor")), + member_set, + false)); + + String mn (find_name ( + escape (process_regex (s, + seq_modifier_regex, + modifier_regex, + L"sequence modifier")), + member_set, + false)); + + ctx.set ("order-aname", an); + ctx.set ("order-mname", mn); + + member_set.insert (name); + + if (an != n) + member_set.insert (an); + + if (mn != n && mn != an) + member_set.insert (mn); + + // Types. + // + ctx.set ( + "order-type", + find_name ( + escape (process_regex (s + L",type", type_regex, L"type")), + member_set)); + + ctx.set ( + "order-container", + find_name ( + escape (process_regex (s + L",sequence", type_regex, L"type")), + member_set)); + + ctx.set ( + "order-iterator", + find_name ( + escape (process_regex (s + L",iterator", type_regex, L"type")), + member_set)); + + ctx.set ( + "order-const-iterator", + find_name ( + escape ( + process_regex (s + L",const,iterator", type_regex, L"type")), + member_set)); + + // Data member. + // + ctx.set ("order-member", find_name (n + L"_", member_set)); + } + } } }; @@ -1211,7 +1470,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { // Process the name with type name regex. @@ -1254,7 +1513,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { // First we need to figure out if we need to process this @@ -1263,7 +1522,7 @@ namespace CXX if (!generate_p (e)) return; - if (options.value<CLI::generate_element_type> ()) + if (options.generate_element_type ()) { SemanticGraph::Context& ec (e.context ()); @@ -1379,7 +1638,7 @@ namespace CXX // String p; - if (!options.value<CLI::suppress_parsing> () && doc_root_p (e)) + if (!options.suppress_parsing () && doc_root_p (e)) { p = find_name ( escape ( @@ -1392,8 +1651,7 @@ namespace CXX // String s; - if (options.value<CLI::generate_serialization> () && - doc_root_p (e)) + if (options.generate_serialization () && doc_root_p (e)) { s = find_name ( escape ( @@ -1430,7 +1688,7 @@ namespace CXX if (type_set_.find (r) != type_set_.end ()) r += L"_"; - for (UnsignedLong i (1); + for (size_t i (1); element_set_.find (r) != element_set_.end () || type_set_.find (r) != type_set_.end (); ++i) { @@ -1454,7 +1712,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& ns) { NameSet& type_set (global_type_names[ns.name ()]); @@ -1475,7 +1733,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& ns) { String const& name (ns.name ()); @@ -1557,7 +1815,7 @@ namespace CXX *this >> names_ >> *this; } - Void + void process_name (SemanticGraph::Type& t, String const& name) { String r ( @@ -1567,10 +1825,10 @@ namespace CXX t.context ().set ("name", escape (r)); } - Void + void process_name (SemanticGraph::Namespace& n, String const& name, - Char const* key) + char const* key) { String r (process_regex (name, type_regex, L"type")); n.context ().set (key, escape (r)); @@ -1578,13 +1836,13 @@ namespace CXX // anyType and anySimpleType // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { process_name (t, "type"); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { process_name (t, "simple,type"); @@ -1592,79 +1850,79 @@ namespace CXX // Integrals. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { process_name (t, "byte"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { process_name (t, "unsigned,byte"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { process_name (t, "short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { process_name (t, "unsigned,short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { process_name (t, "int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { process_name (t, "unsigned,int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { process_name (t, "long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { process_name (t, "unsigned,long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { process_name (t, "integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { process_name (t, "non,positive,integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { process_name (t, "non,negative,integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { process_name (t, "positive,integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { process_name (t, "negative,integer"); @@ -1672,7 +1930,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { process_name (t, "boolean"); @@ -1680,19 +1938,19 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { process_name (t, "float"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { process_name (t, "double"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { process_name (t, "decimal"); @@ -1700,49 +1958,49 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { process_name (t, "string"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { process_name (t, "normalized,string"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { process_name (t, "token"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { process_name (t, "nmtoken"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { process_name (t, "nmtokens"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { process_name (t, "name"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { process_name (t, "ncname"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { process_name (t, "language"); @@ -1750,19 +2008,19 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { process_name (t, "id"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { process_name (t, "idref"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { process_name (t, "idrefs"); @@ -1771,7 +2029,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { process_name (t, "uri"); @@ -1779,7 +2037,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { process_name (t, "qname"); @@ -1787,13 +2045,13 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { process_name (t, "base64,binary"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { process_name (t, "hex,binary"); @@ -1802,55 +2060,55 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { process_name (t, "date"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { process_name (t, "date,time"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { process_name (t, "duration"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { process_name (t, "gday"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { process_name (t, "gmonth"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { process_name (t, "gmonth,day"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { process_name (t, "gyear"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { process_name (t, "gyear,month"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { process_name (t, "time"); @@ -1858,19 +2116,19 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { process_name (t, "entity"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { process_name (t, "entities"); } - virtual Void + virtual void post (SemanticGraph::Namespace& n) { // Assign names to extra stuff in the XML Schema namespace. @@ -1879,13 +2137,15 @@ namespace CXX process_name (n, "buffer", "buffer"); process_name (n, "time,zone", "time-zone"); - if (options.value<CLI::generate_element_type> ()) + process_name (n, "content,order", "content-order"); + + if (options.generate_element_type ()) process_name (n, "element,type", "element-type"); - if (options.value<CLI::generate_element_map> ()) + if (options.generate_element_map ()) process_name (n, "element,map", "element-map"); - if (options.value<CLI::generate_serialization> ()) + if (options.generate_serialization ()) { process_name (n, "namespace,info", "namespace-info"); process_name (n, "namespace,infomap", "namespace-infomap"); @@ -1895,12 +2155,12 @@ namespace CXX process_name (n, "facet", "facet"); } - if (!options.value<CLI::generate_insertion> ().empty ()) + if (!options.generate_insertion ().empty ()) { process_name (n, "ostream", "ostream"); } - if (!options.value<CLI::generate_extraction> ().empty ()) + if (!options.generate_extraction ().empty ()) { process_name (n, "istream", "istream"); } @@ -1908,7 +2168,7 @@ namespace CXX process_name (n, "flags", "flags"); process_name (n, "properties", "properties"); - NarrowString fn (options.value<CLI::function_naming> ()); + NarrowString fn (options.function_naming ()); if (fn == "knr") n.context ().set ("tree-node-key", String ("tree_node_key")); @@ -1936,8 +2196,8 @@ namespace CXX process_name (n, "error", "error"); process_name (n, "diagnostics", "diagnostics"); - if (!options.value<CLI::suppress_parsing> () || - options.value<CLI::generate_serialization> ()) + if (!options.suppress_parsing () || + options.generate_serialization ()) { process_name (n, "error,handler", "error-handler"); } @@ -1955,7 +2215,7 @@ namespace CXX // struct UsesPassOne: Traversal::Uses { - virtual Void + virtual void traverse (Type& u) { SemanticGraph::Schema& s (u.schema ()); @@ -1970,7 +2230,7 @@ namespace CXX struct UsesPassThree: Traversal::Uses { - virtual Void + virtual void traverse (Type& u) { SemanticGraph::Schema& s (u.schema ()); @@ -1988,7 +2248,7 @@ namespace CXX // struct Implies: Traversal::Implies { - virtual Void + virtual void traverse (SemanticGraph::Implies& i) { SemanticGraph::Schema& s (i.schema ()); @@ -2001,8 +2261,8 @@ namespace CXX } }; - Boolean - process_impl (CLI::Options const& ops, + bool + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, StringLiteralMap const& map) @@ -2064,7 +2324,7 @@ namespace CXX // { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; @@ -2128,8 +2388,8 @@ namespace CXX } } - Boolean NameProcessor:: - process (CLI::Options const& ops, + bool NameProcessor:: + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, StringLiteralMap const& map) |