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/elements.cxx | 237 ++-- xsd/xsd/cxx/elements.hxx | 208 +-- xsd/xsd/cxx/literal-map.cxx | 80 +- xsd/xsd/cxx/literal-map.hxx | 13 +- xsd/xsd/cxx/option-types.cxx | 48 + xsd/xsd/cxx/option-types.hxx | 35 + xsd/xsd/cxx/options.cli | 551 ++++++++ xsd/xsd/cxx/options.cxx | 638 +++++++++ xsd/xsd/cxx/options.hxx | 440 ++++++ xsd/xsd/cxx/options.ixx | 601 ++++++++ xsd/xsd/cxx/parser/attribute-validation-source.cxx | 45 +- xsd/xsd/cxx/parser/attribute-validation-source.hxx | 5 +- .../cxx/parser/characters-validation-source.cxx | 9 +- .../cxx/parser/characters-validation-source.hxx | 5 +- xsd/xsd/cxx/parser/cli.hxx | 154 -- xsd/xsd/cxx/parser/driver-source.cxx | 164 +-- xsd/xsd/cxx/parser/driver-source.hxx | 5 +- xsd/xsd/cxx/parser/element-validation-source.cxx | 213 +-- xsd/xsd/cxx/parser/element-validation-source.hxx | 5 +- xsd/xsd/cxx/parser/elements.cxx | 113 +- xsd/xsd/cxx/parser/elements.hxx | 74 +- xsd/xsd/cxx/parser/generator.cxx | 890 +++--------- xsd/xsd/cxx/parser/generator.hxx | 28 +- xsd/xsd/cxx/parser/impl-header.cxx | 17 +- xsd/xsd/cxx/parser/impl-header.hxx | 5 +- xsd/xsd/cxx/parser/impl-source.cxx | 31 +- xsd/xsd/cxx/parser/impl-source.hxx | 5 +- xsd/xsd/cxx/parser/name-processor.cxx | 197 ++- xsd/xsd/cxx/parser/name-processor.hxx | 15 +- xsd/xsd/cxx/parser/options.cli | 148 ++ xsd/xsd/cxx/parser/options.cxx | 581 ++++++++ xsd/xsd/cxx/parser/options.hxx | 183 +++ xsd/xsd/cxx/parser/options.ixx | 160 +++ xsd/xsd/cxx/parser/parser-forward.cxx | 15 +- xsd/xsd/cxx/parser/parser-forward.hxx | 5 +- xsd/xsd/cxx/parser/parser-header.cxx | 175 +-- xsd/xsd/cxx/parser/parser-header.hxx | 7 +- xsd/xsd/cxx/parser/parser-inline.cxx | 46 +- xsd/xsd/cxx/parser/parser-inline.hxx | 5 +- xsd/xsd/cxx/parser/parser-source.cxx | 139 +- xsd/xsd/cxx/parser/parser-source.hxx | 5 +- xsd/xsd/cxx/parser/print-impl-common.hxx | 89 +- xsd/xsd/cxx/parser/state-processor.cxx | 70 +- xsd/xsd/cxx/parser/state-processor.hxx | 10 +- xsd/xsd/cxx/parser/type-processor.cxx | 86 +- xsd/xsd/cxx/parser/type-processor.hxx | 19 +- xsd/xsd/cxx/parser/validator.cxx | 140 +- xsd/xsd/cxx/parser/validator.hxx | 20 +- xsd/xsd/cxx/tree/cli.hxx | 228 --- xsd/xsd/cxx/tree/counter.cxx | 64 +- xsd/xsd/cxx/tree/counter.hxx | 9 +- xsd/xsd/cxx/tree/default-value.cxx | 266 ++-- xsd/xsd/cxx/tree/default-value.hxx | 135 +- xsd/xsd/cxx/tree/elements.cxx | 428 +++--- xsd/xsd/cxx/tree/elements.hxx | 632 +++++---- xsd/xsd/cxx/tree/fundamental-header.hxx | 160 ++- xsd/xsd/cxx/tree/generator.cxx | 1470 ++++++-------------- xsd/xsd/cxx/tree/generator.hxx | 21 +- xsd/xsd/cxx/tree/name-processor.cxx | 622 ++++++--- xsd/xsd/cxx/tree/name-processor.hxx | 14 +- xsd/xsd/cxx/tree/options.cli | 480 +++++++ xsd/xsd/cxx/tree/options.cxx | 1149 +++++++++++++++ xsd/xsd/cxx/tree/options.hxx | 411 ++++++ xsd/xsd/cxx/tree/options.ixx | 502 +++++++ xsd/xsd/cxx/tree/order-processor.cxx | 244 ++++ xsd/xsd/cxx/tree/order-processor.hxx | 30 + xsd/xsd/cxx/tree/parser-header.cxx | 39 +- xsd/xsd/cxx/tree/parser-header.hxx | 5 +- xsd/xsd/cxx/tree/parser-source.cxx | 151 +- xsd/xsd/cxx/tree/parser-source.hxx | 7 +- xsd/xsd/cxx/tree/polymorphism-processor.cxx | 216 ++- xsd/xsd/cxx/tree/polymorphism-processor.hxx | 16 +- xsd/xsd/cxx/tree/serialization-header.cxx | 23 +- xsd/xsd/cxx/tree/serialization-header.hxx | 5 +- xsd/xsd/cxx/tree/serialization-source.cxx | 370 +++-- xsd/xsd/cxx/tree/serialization-source.hxx | 9 +- xsd/xsd/cxx/tree/stream-extraction-source.cxx | 231 +-- xsd/xsd/cxx/tree/stream-extraction-source.hxx | 5 +- xsd/xsd/cxx/tree/stream-header.cxx | 19 +- xsd/xsd/cxx/tree/stream-header.hxx | 5 +- xsd/xsd/cxx/tree/stream-insertion-header.cxx | 37 +- xsd/xsd/cxx/tree/stream-insertion-header.hxx | 5 +- xsd/xsd/cxx/tree/stream-insertion-source.cxx | 173 ++- xsd/xsd/cxx/tree/stream-insertion-source.hxx | 5 +- xsd/xsd/cxx/tree/stream-source.cxx | 89 +- xsd/xsd/cxx/tree/stream-source.hxx | 9 +- xsd/xsd/cxx/tree/tree-forward.cxx | 49 +- xsd/xsd/cxx/tree/tree-forward.hxx | 5 +- xsd/xsd/cxx/tree/tree-header.cxx | 689 +++++++-- xsd/xsd/cxx/tree/tree-header.hxx | 5 +- xsd/xsd/cxx/tree/tree-inline.cxx | 172 ++- xsd/xsd/cxx/tree/tree-inline.hxx | 7 +- xsd/xsd/cxx/tree/tree-source.cxx | 1100 ++++++++++----- xsd/xsd/cxx/tree/tree-source.hxx | 7 +- xsd/xsd/cxx/tree/validator.cxx | 124 +- xsd/xsd/cxx/tree/validator.hxx | 11 +- xsd/xsd/elements.hxx | 30 +- xsd/xsd/makefile | 90 +- xsd/xsd/options-parser.hxx | 30 + xsd/xsd/options.cli | 313 +++++ xsd/xsd/options.cxx | 976 +++++++++++++ xsd/xsd/options.hxx | 575 ++++++++ xsd/xsd/options.ixx | 462 ++++++ xsd/xsd/processing/cardinality/processor.cxx | 105 +- xsd/xsd/processing/cardinality/processor.hxx | 11 +- xsd/xsd/processing/inheritance/processor.cxx | 95 +- xsd/xsd/processing/inheritance/processor.hxx | 11 +- xsd/xsd/type-map/lexer.cxx | 5 +- xsd/xsd/type-map/lexer.hxx | 19 +- xsd/xsd/type-map/parser.cxx | 21 +- xsd/xsd/type-map/parser.hxx | 16 +- xsd/xsd/type-map/type-map.hxx | 57 +- xsd/xsd/types.hxx | 20 + xsd/xsd/usage.hxx | 226 --- xsd/xsd/xsd.cxx | 681 +++------ xsd/xsd/xsd.hxx | 81 +- 116 files changed, 14455 insertions(+), 6556 deletions(-) create mode 100644 xsd/xsd/cxx/option-types.cxx create mode 100644 xsd/xsd/cxx/option-types.hxx create mode 100644 xsd/xsd/cxx/options.cli create mode 100644 xsd/xsd/cxx/options.cxx create mode 100644 xsd/xsd/cxx/options.hxx create mode 100644 xsd/xsd/cxx/options.ixx delete mode 100644 xsd/xsd/cxx/parser/cli.hxx create mode 100644 xsd/xsd/cxx/parser/options.cli create mode 100644 xsd/xsd/cxx/parser/options.cxx create mode 100644 xsd/xsd/cxx/parser/options.hxx create mode 100644 xsd/xsd/cxx/parser/options.ixx delete mode 100644 xsd/xsd/cxx/tree/cli.hxx create mode 100644 xsd/xsd/cxx/tree/options.cli create mode 100644 xsd/xsd/cxx/tree/options.cxx create mode 100644 xsd/xsd/cxx/tree/options.hxx create mode 100644 xsd/xsd/cxx/tree/options.ixx create mode 100644 xsd/xsd/cxx/tree/order-processor.cxx create mode 100644 xsd/xsd/cxx/tree/order-processor.hxx create mode 100644 xsd/xsd/options-parser.hxx create mode 100644 xsd/xsd/options.cli create mode 100644 xsd/xsd/options.cxx create mode 100644 xsd/xsd/options.hxx create mode 100644 xsd/xsd/options.ixx create mode 100644 xsd/xsd/types.hxx delete mode 100644 xsd/xsd/usage.hxx (limited to 'xsd/xsd') diff --git a/xsd/xsd/cxx/elements.cxx b/xsd/xsd/cxx/elements.cxx index d2600dc..dfa2f38 100644 --- a/xsd/xsd/cxx/elements.cxx +++ b/xsd/xsd/cxx/elements.cxx @@ -1,16 +1,14 @@ // file : xsd/cxx/elements.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 -#include - #include // std::toupper #include #include #include +#include #include using std::wcerr; @@ -28,7 +26,7 @@ namespace CXX namespace { - WideChar const* keywords[] = { + wchar_t const* keywords[] = { L"NULL", L"and", L"asm", @@ -114,55 +112,47 @@ namespace CXX Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - StringLiteralMap const* string_literal_map_, - NarrowString const& char_type__, - NarrowString const& char_encoding__, - Boolean include_with_brackets__, - NarrowString const& include_prefix__, - NarrowString const& esymbol, - Containers::Vector const& nsm, - Containers::Vector const& nsr, - Boolean trace_namespace_regex_, - Containers::Vector const& ir, - Boolean trace_include_regex_, - Boolean inline_, - Containers::Vector const& reserved_name) + options_type const& ops, + StringLiteralMap const* string_literal_map_) : os (o), schema_root (root), schema_path (schema_path_), + options (ops), + std (ops.std ()), char_type (char_type_), char_encoding (char_encoding_), L (L_), string_type (string_type_), + auto_ptr (auto_ptr_), string_literal_map (string_literal_map_), - include_with_brackets (include_with_brackets_), - include_prefix (include_prefix_), type_exp (type_exp_), inst_exp (inst_exp_), inl (inl_), ns_mapping_cache (ns_mapping_cache_), schema_path_ (path), xs_ns_ (0), - char_type_ (char_type__), - char_encoding_ (char_encoding__), + char_type_ (ops.char_type ()), + char_encoding_ (ops.char_encoding ()), L_ (char_type == L"wchar_t" ? L"L" : L""), - include_with_brackets_ (include_with_brackets__), - include_prefix_ (include_prefix__), - type_exp_ (esymbol ? esymbol + " " : esymbol), - inst_exp_ (esymbol ? esymbol + "\n" : esymbol), - inl_ (inline_ ? L"inline\n" : L""), + inl_ (ops.generate_inline () ? L"inline\n" : L""), cxx_id_expr_ (L"^(::)?([a-zA-Z_]\\w*)(::[a-zA-Z_]\\w*)*$"), cxx_id_expr (cxx_id_expr_), - trace_namespace_regex (trace_namespace_regex_), urn_mapping_ (L"#^urn.*:([a-zA-Z_].*)$#$1#"), urn_mapping (urn_mapping_), nsr_mapping (nsr_mapping_), nsm_mapping (nsm_mapping_), include_mapping (include_mapping_), - trace_include_regex (trace_include_regex_), reserved_name_map (reserved_name_map_), keyword_set (keyword_set_) { + // Export symbol. + // + { + String es (ops.export_symbol ()); + type_exp_ = es ? es + L" " : es; + inst_exp_ = es ? es + L"\n" : es; + } + // Resolve and cache XML Schema namespace. // { @@ -196,6 +186,12 @@ namespace CXX else string_type_ = L"::std::basic_string< " + char_type + L" >"; + // Automatic pointer type. + // + auto_ptr_ = std >= cxx_version::cxx11 + ? "::std::unique_ptr" + : "::std::auto_ptr"; + // Default encoding. // if (!char_encoding) @@ -209,28 +205,28 @@ namespace CXX // Default mapping. // nsr_mapping_.push_back ( - Regex (L"#^.* (.*?/)??"L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#")); + Regex (L"#^.* (.*?/)??" L"(([a-zA-Z_]\\w*)(/[a-zA-Z_]\\w*)*)/?$#$2#")); nsr_mapping_.push_back ( Regex (L"#^.* http://www\\.w3\\.org/2001/XMLSchema$#xml_schema#")); // Custom regex mapping. // - for (Containers::Vector::ConstIterator - i (nsr.begin ()), e (nsr.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (ops.namespace_regex ().begin ()), + e (ops.namespace_regex ().end ()); i != e; ++i) { - nsr_mapping_.push_back (Regex (*i)); + nsr_mapping_.push_back (Regex (String (*i))); } // Custom direct mapping. // - for (Containers::Vector::ConstIterator - i (nsm.begin ()), e (nsm.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (ops.namespace_map ().begin ()), + e (ops.namespace_map ().end ()); i != e; ++i) { String s (*i); // Split the string in two parts at the last '='. // - Size pos (s.rfind ('=')); + size_t pos (s.rfind ('=')); if (pos == String::npos) throw InvalidNamespaceMapping (s, "delimiter ('=') not found"); @@ -248,22 +244,22 @@ namespace CXX // Include path regex // - for (Containers::Vector::ConstIterator - i (ir.begin ()), e (ir.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (ops.include_regex ().begin ()), + e (ops.include_regex ().end ()); i != e; ++i) { - include_mapping_.push_back (Regex (*i)); + include_mapping_.push_back (Regex (String (*i))); } // Reserved names. // - for (Containers::Vector::ConstIterator - i (reserved_name.begin ()), e (reserved_name.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (ops.reserved_name ().begin ()), + e (ops.reserved_name ().end ()); i != e; ++i) { String s (*i); // Split the string in two parts at '='. // - Size pos (s.find ('=')); + size_t pos (s.find ('=')); if (pos == String::npos) reserved_name_map_[s] = L""; @@ -273,7 +269,7 @@ namespace CXX // Populate the keyword set. // - for (Size i (0); i < sizeof (keywords) / sizeof (char*); ++i) + for (size_t i (0); i < sizeof (keywords) / sizeof (char*); ++i) keyword_set_.insert (keywords[i]); } @@ -287,7 +283,7 @@ namespace CXX using SemanticGraph::Sources; String tmp; - MapMapping::ConstIterator i (nsm_mapping.find (ns.name ())); + MapMapping::const_iterator i (nsm_mapping.find (ns.name ())); if (i != nsm_mapping.end ()) { @@ -317,20 +313,18 @@ namespace CXX if (!path.empty ()) { + path.normalize (); + // Try to use the portable representation of the path. If that // fails, fall back to the native representation. // try { - pair = path.string (); + pair = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - pair = path.native_file_string (); -#else pair = path.string (); -#endif } } @@ -338,7 +332,7 @@ namespace CXX // Check cache first // - MappingCache::ConstIterator i (ns_mapping_cache.find (pair)); + MappingCache::const_iterator i (ns_mapping_cache.find (pair)); if (i != ns_mapping_cache.end ()) { @@ -346,32 +340,34 @@ namespace CXX } else { - if (trace_namespace_regex) + bool trace (options.namespace_regex_trace ()); + + if (trace) wcerr << "namespace: '" << pair << "'" << endl; - Boolean found (false); + bool found (false); Regex colon (L"#/#::#"); - for (RegexMapping::ConstReverseIterator e (nsr_mapping.rbegin ()); + for (RegexMapping::const_reverse_iterator e (nsr_mapping.rbegin ()); e != nsr_mapping.rend (); ++e) { - if (trace_namespace_regex) - wcerr << "try: '" << e->pattern () << "' : "; + if (trace) + wcerr << "try: '" << e->regex () << "' : "; if (e->match (pair)) { - tmp = e->merge (pair); - tmp = colon.merge (tmp); // replace `/' with `::' + tmp = e->replace (pair); + tmp = colon.replace (tmp); // replace `/' with `::' // Check the result. // found = cxx_id_expr.match (tmp); - if (trace_namespace_regex) + if (trace) wcerr << "'" << tmp << "' : "; } - if (trace_namespace_regex) + if (trace) wcerr << (found ? '+' : '-') << endl; if (found) @@ -392,7 +388,7 @@ namespace CXX } else { - tmp = colon.merge (n); // replace `/' with `::' + tmp = colon.replace (n); // replace `/' with `::' if (!cxx_id_expr.match (tmp)) { @@ -401,8 +397,8 @@ namespace CXX if (urn_mapping.match (n)) { Regex filter (L"#[.:-]#_#"); - tmp = urn_mapping.merge (n); - tmp = filter.merge (tmp); + tmp = urn_mapping.replace (n); + tmp = filter.replace (tmp); if (!cxx_id_expr.match (tmp)) throw NoNamespaceMapping ( @@ -496,7 +492,7 @@ namespace CXX } String Context:: - fq_name (SemanticGraph::Nameable& n, Char const* name_key) + fq_name (SemanticGraph::Nameable& n, char const* name_key) { using namespace SemanticGraph; @@ -548,17 +544,17 @@ namespace CXX escape (String const& name) { String r; - Size n (name.size ()); + size_t n (name.size ()); // In most common cases we will have that many chars. // r.reserve (n); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - Boolean first (i == 0); + bool first (i == 0); - UnsignedLong u (unicode_char (name, i)); // May advance i. + unsigned int u (unicode_char (name, i)); // May advance i. if (first) { @@ -574,7 +570,7 @@ namespace CXX u == '_')) r.push_back ('_'); else - r.push_back (static_cast (u)); + r.push_back (static_cast (u)); } if (r.empty ()) @@ -582,7 +578,7 @@ namespace CXX // Custom reserved words. // - ReservedNameMap::ConstIterator i (reserved_name_map.find (r)); + ReservedNameMap::const_iterator i (reserved_name_map.find (r)); if (i != reserved_name_map.end ()) { @@ -618,14 +614,14 @@ namespace CXX // String - charlit (UnsignedLong u) + charlit (unsigned int u) { String r ("\\x"); - Boolean lead (true); + bool lead (true); - for (Long i (7); i >= 0; --i) + for (int i (7); i >= 0; --i) { - UnsignedLong x ((u >> (i * 4)) & 0x0F); + unsigned int x ((u >> (i * 4)) & 0x0F); if (lead) { @@ -645,7 +641,7 @@ namespace CXX strlit_ascii (String const& str) { String r; - Size n (str.size ()); + size_t n (str.size ()); // In most common cases we will have that many chars. // @@ -653,11 +649,11 @@ namespace CXX r += '"'; - Boolean escape (false); + bool escape (false); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - UnsignedLong u (Context::unicode_char (str, i)); // May advance i. + unsigned int u (Context::unicode_char (str, i)); // May advance i. // [128 - ] - unrepresentable // 127 - \x7F @@ -738,7 +734,7 @@ namespace CXX } default: { - r += static_cast (u); + r += static_cast (u); break; } } @@ -756,7 +752,7 @@ namespace CXX return r; } - const UnsignedLong utf8_first_char_mask[5] = + const unsigned int utf8_first_char_mask[5] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0 }; @@ -765,7 +761,7 @@ namespace CXX strlit_utf8 (String const& str) { String r; - Size n (str.size ()); + size_t n (str.size ()); // In most common cases we will have that many chars. // @@ -773,11 +769,11 @@ namespace CXX r += '"'; - Boolean escape (false); + bool escape (false); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - UnsignedLong u (Context::unicode_char (str, i)); // May advance i. + unsigned int u (Context::unicode_char (str, i)); // May advance i. // [128 - ] - UTF-8 // 127 - \x7F @@ -858,15 +854,15 @@ namespace CXX } default: { - r += static_cast (u); + r += static_cast (u); break; } } } else { - UnsignedLong count; - UnsignedLong tmp[4]; + unsigned int count (0); + unsigned int tmp[4]; if (u < 0x800) count = 2; @@ -895,10 +891,13 @@ namespace CXX case 1: { tmp[0] = u | utf8_first_char_mask[count]; + break; } + default: + assert (false); } - for (UnsignedLong j (0); j < count; ++j) + for (unsigned int j (0); j < count; ++j) r += charlit (tmp[j]); escape = true; @@ -914,7 +913,7 @@ namespace CXX strlit_iso8859_1 (String const& str) { String r; - Size n (str.size ()); + size_t n (str.size ()); // In most common cases we will have that many chars. // @@ -922,11 +921,11 @@ namespace CXX r += '"'; - Boolean escape (false); + bool escape (false); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - UnsignedLong u (Context::unicode_char (str, i)); // May advance i. + unsigned int u (Context::unicode_char (str, i)); // May advance i. // [256 - ] - unrepresentable // [127 - 255] - \xXX @@ -1007,7 +1006,7 @@ namespace CXX } default: { - r += static_cast (u); + r += static_cast (u); break; } } @@ -1034,7 +1033,7 @@ namespace CXX strlit_utf32 (String const& str) { String r; - Size n (str.size ()); + size_t n (str.size ()); // In most common cases we will have that many chars. // @@ -1042,11 +1041,11 @@ namespace CXX r += L"L\""; - Boolean escape (false); + bool escape (false); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - UnsignedLong u (Context::unicode_char (str, i)); // May advance i. + unsigned int u (Context::unicode_char (str, i)); // May advance i. // [128 - ] - \xUUUUUUUU // 127 - \x7F @@ -1105,9 +1104,10 @@ namespace CXX { if (escape) { - // Close and open the string so there are no clashes. + // Close and open the string so there are no clashes. C++11 + // requires a space between " and L. // - r += L"\"L\""; + r += L"\" L\""; escape = false; } @@ -1125,7 +1125,7 @@ namespace CXX } default: { - r += static_cast (u); + r += static_cast (u); break; } } @@ -1148,7 +1148,7 @@ namespace CXX // First see if we have a custom mapping. // assert (string_literal_map != 0); - StringLiteralMap::ConstIterator i (string_literal_map->find (str)); + StringLiteralMap::const_iterator i (string_literal_map->find (str)); if (i != string_literal_map->end ()) return i->second; @@ -1175,16 +1175,16 @@ namespace CXX { String r; - WideChar const* s (str.c_str ()); - Size size (str.size ()); + wchar_t const* s (str.c_str ()); + size_t size (str.size ()); // In most common cases we will have that many chars. // r.reserve (size); - for (WideChar const* p (s); p < s + size; ++p) + for (wchar_t const* p (s); p < s + size; ++p) { - UnsignedLong u (unicode_char (p)); // May advance p. + unsigned int u (unicode_char (p)); // May advance p. // We are going to treat \v, \f and \n as unrepresentable // here even though they can be present in C++ source code. @@ -1192,7 +1192,7 @@ namespace CXX if (u > 127 || (u < 32 && u != '\t')) r += L'?'; else - r += static_cast (u); + r += static_cast (u); } return r; @@ -1201,30 +1201,31 @@ namespace CXX String Context:: process_include_path (String const& name) const { - String path (include_prefix + name); + String path (String (options.include_prefix ()) + name); + bool trace (options.include_regex_trace ()); - if (trace_include_regex) + if (trace) wcerr << "include: '" << path << "'" << endl; String r; - Boolean found (false); + bool found (false); - for (RegexMapping::ConstReverseIterator e (include_mapping.rbegin ()); + for (RegexMapping::const_reverse_iterator e (include_mapping.rbegin ()); e != include_mapping.rend (); ++e) { - if (trace_include_regex) - wcerr << "try: '" << e->pattern () << "' : "; + if (trace) + wcerr << "try: '" << e->regex () << "' : "; if (e->match (path)) { - r = e->merge (path); + r = e->replace (path); found = true; - if (trace_include_regex) + if (trace) wcerr << "'" << r << "' : "; } - if (trace_include_regex) + if (trace) wcerr << (found ? '+' : '-') << endl; if (found) @@ -1236,8 +1237,8 @@ namespace CXX if (!r.empty () && r[0] != L'"' && r[0] != L'<') { - WideChar op (include_with_brackets ? L'<' : L'"'); - WideChar cl (include_with_brackets ? L'>' : L'"'); + wchar_t op (options.include_with_brackets () ? L'<' : L'"'); + wchar_t cl (options.include_with_brackets () ? L'>' : L'"'); r = op + r + cl; } @@ -1247,7 +1248,7 @@ namespace CXX // Namespace // - Void Namespace:: + void Namespace:: pre (Type& n) { String ns (ctx_.ns_name (n)); @@ -1281,7 +1282,7 @@ namespace CXX } while (true); } - Void Namespace:: + void Namespace:: post (Type& n) { String ns (ctx_.ns_name (n)); diff --git a/xsd/xsd/cxx/elements.hxx b/xsd/xsd/cxx/elements.hxx index 59938c5..4b36da9 100644 --- a/xsd/xsd/cxx/elements.hxx +++ b/xsd/xsd/cxx/elements.hxx @@ -1,31 +1,29 @@ // file : xsd/cxx/elements.hxx -// 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 #ifndef CXX_ELEMENTS_HXX #define CXX_ELEMENTS_HXX +#include +#include +#include #include -#include -#include -#include -#include - -#include +#include #include #include +#include #include + +#include #include namespace CXX { using std::endl; - typedef WideString String; - // On some platforms std::toupper can be something other than a // function with C++ linkage. @@ -39,7 +37,7 @@ namespace CXX struct UnrepresentableCharacter { - UnrepresentableCharacter (String const& str, Size pos) + UnrepresentableCharacter (String const& str, size_t pos) : str_ (str), pos_ (pos) { } @@ -50,7 +48,7 @@ namespace CXX return str_; } - Size + size_t position () const { return pos_; @@ -58,14 +56,14 @@ namespace CXX private: String str_; - Size pos_; + size_t pos_; }; struct NoNamespaceMapping { NoNamespaceMapping (SemanticGraph::Path const& file, - UnsignedLong line, - UnsignedLong column, + size_t line, + size_t column, String const& ns) : file_ (file), line_ (line), @@ -81,13 +79,13 @@ namespace CXX return file_; } - UnsignedLong + size_t line () const { return line_; } - UnsignedLong + size_t column () const { return column_; @@ -101,8 +99,8 @@ namespace CXX private: SemanticGraph::Path file_; - UnsignedLong line_; - UnsignedLong column_; + size_t line_; + size_t column_; String ns_; }; @@ -136,57 +134,47 @@ namespace CXX class Context { public: - typedef BackendElements::Regex::Pattern RegexPat; - typedef BackendElements::Regex::Expression Regex; - typedef Cult::Containers::Vector RegexMapping; - typedef Cult::Containers::Map MapMapping; - typedef Cult::Containers::Map MappingCache; + typedef cutl::re::wregex RegexPat; + typedef cutl::re::wregexsub Regex; + typedef std::vector RegexMapping; + typedef std::map MapMapping; + typedef std::map MappingCache; - typedef Cult::Containers::Map ReservedNameMap; - typedef Cult::Containers::Set KeywordSet; + typedef std::map ReservedNameMap; + typedef std::set KeywordSet; + + typedef CXX::options options_type; public: Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - StringLiteralMap const* custom_literals_map, - NarrowString const& char_type__, - NarrowString const& char_encoding__, - Boolean include_with_brackets__, - NarrowString const& include_prefix__, - NarrowString const& esymbol, - Containers::Vector const& nsm, - Containers::Vector const& nsr, - Boolean trace_namespace_regex_, - Containers::Vector const& include_regex, - Boolean trace_include_regex_, - Boolean inline_, - Containers::Vector const& reserved_name); + options_type const& ops, + StringLiteralMap const* custom_literals_map); protected: Context (Context& c) : os (c.os), schema_root (c.schema_root), schema_path (c.schema_path), + options (c.options), + std (c.std), char_type (c.char_type), char_encoding (c.char_encoding), L (c.L), string_type (c.string_type), + auto_ptr (c.auto_ptr), string_literal_map (c.string_literal_map), - include_with_brackets (c.include_with_brackets), - include_prefix (c.include_prefix), type_exp (c.type_exp), inst_exp (c.inst_exp), inl (c.inl), ns_mapping_cache (c.ns_mapping_cache), xs_ns_ (c.xs_ns_), cxx_id_expr (c.cxx_id_expr), - trace_namespace_regex (c.trace_namespace_regex), urn_mapping (c.urn_mapping), nsr_mapping (c.nsr_mapping), nsm_mapping (c.nsm_mapping), include_mapping (c.include_mapping), - trace_include_regex (c.trace_include_regex), reserved_name_map (c.reserved_name_map), keyword_set (c.keyword_set) { @@ -196,25 +184,24 @@ namespace CXX : os (o), schema_root (c.schema_root), schema_path (c.schema_path), + options (c.options), + std (c.std), char_type (c.char_type), char_encoding (c.char_encoding), L (c.L), string_type (c.string_type), + auto_ptr (c.auto_ptr), string_literal_map (c.string_literal_map), - include_with_brackets (c.include_with_brackets), - include_prefix (c.include_prefix), type_exp (c.type_exp), inst_exp (c.inst_exp), inl (c.inl), ns_mapping_cache (c.ns_mapping_cache), xs_ns_ (c.xs_ns_), cxx_id_expr (c.cxx_id_expr), - trace_namespace_regex (c.trace_namespace_regex), urn_mapping (c.urn_mapping), nsr_mapping (c.nsr_mapping), nsm_mapping (c.nsm_mapping), include_mapping (c.include_mapping), - trace_include_regex (c.trace_include_regex), reserved_name_map (c.reserved_name_map), keyword_set (c.keyword_set) { @@ -232,11 +219,11 @@ namespace CXX // advanced by 1 if this Unicode character takes more than one // underlying character. // - static UnsignedLong - unicode_char (String const& str, Size& pos); + static unsigned int + unicode_char (String const& str, size_t& pos); - static UnsignedLong - unicode_char (WideChar const*& p); + static unsigned int + unicode_char (wchar_t const*& p); // Escape C++ keywords and illegal characters. // @@ -283,7 +270,7 @@ namespace CXX // Fully-qualified C++ name. // String - fq_name (SemanticGraph::Nameable& n, Char const* name_key = "name"); + fq_name (SemanticGraph::Nameable& n, char const* name_key = "name"); public: static SemanticGraph::Type& @@ -294,7 +281,7 @@ namespace CXX process_include_path (String const&) const; public: - static Boolean + static bool skip (SemanticGraph::Member& m) { // "Subsequent" local element. @@ -303,28 +290,28 @@ namespace CXX m.context ().count ("min") == 0; } - static UnsignedLong + static size_t min (SemanticGraph::Member const& m) { - return m.context ().get ("min"); + return m.context ().get ("min"); } - static UnsignedLong + static size_t min (SemanticGraph::Any const& a) { - return a.context ().get ("min"); + return a.context ().get ("min"); } - static UnsignedLong + static size_t max (SemanticGraph::Member const& m) { - return m.context ().get ("max"); + return m.context ().get ("max"); } - static UnsignedLong + static size_t max (SemanticGraph::Any const& a) { - return a.context ().get ("max"); + return a.context ().get ("max"); } public: @@ -342,14 +329,17 @@ namespace CXX SemanticGraph::Schema& schema_root; SemanticGraph::Path const& schema_path; + options_type const& options; + + cxx_version std; + String& char_type; String& char_encoding; String& L; // string literal prefix String& string_type; - StringLiteralMap const* string_literal_map; + String& auto_ptr; - Boolean& include_with_brackets; - String& include_prefix; + StringLiteralMap const* string_literal_map; String& type_exp; String& inst_exp; @@ -367,9 +357,7 @@ namespace CXX String char_encoding_; String L_; String string_type_; - - Boolean include_with_brackets_; - String include_prefix_; + String auto_ptr_; String type_exp_; String inst_exp_; @@ -378,7 +366,6 @@ namespace CXX private: RegexPat const cxx_id_expr_; RegexPat const& cxx_id_expr; - Boolean trace_namespace_regex; Regex urn_mapping_; RegexMapping nsr_mapping_; MapMapping nsm_mapping_; @@ -389,7 +376,6 @@ namespace CXX RegexMapping include_mapping_; RegexMapping const& include_mapping; - Boolean trace_include_regex; ReservedNameMap const& reserved_name_map; ReservedNameMap reserved_name_map_; @@ -398,16 +384,16 @@ namespace CXX KeywordSet keyword_set_; }; - inline UnsignedLong Context:: - unicode_char (String const& str, Size& pos) + inline unsigned int Context:: + unicode_char (String const& str, size_t& pos) { - if (sizeof (WideChar) == 4) + if (sizeof (wchar_t) == 4) { return str[pos]; } - else if (sizeof (WideChar) == 2) + else if (sizeof (wchar_t) == 2) { - WideChar x (str[pos]); + wchar_t x (str[pos]); if (x < 0xD800 || x > 0xDBFF) return x; @@ -418,16 +404,16 @@ namespace CXX return 0; } - inline UnsignedLong Context:: - unicode_char (WideChar const*& p) + inline unsigned int Context:: + unicode_char (wchar_t const*& p) { - if (sizeof (WideChar) == 4) + if (sizeof (wchar_t) == 4) { return *p; } - else if (sizeof (WideChar) == 2) + else if (sizeof (wchar_t) == 2) { - WideChar x (*p); + wchar_t x (*p); if (x < 0xD800 || x > 0xDBFF) return x; @@ -438,6 +424,21 @@ namespace CXX return 0; } + // Sources traverser that goes into each schema only once. + // + struct Sources: Traversal::Sources + { + virtual void + traverse (SemanticGraph::Sources& s) + { + if (schemas_.insert (&s.schema ()).second) + Traversal::Sources::traverse (s); + } + + private: + std::set schemas_; + }; + // Usual namespace mapping. // struct Namespace: Traversal::Namespace @@ -447,10 +448,10 @@ namespace CXX // First scope name if always empty (global scope). The last flag // signals the last scope. // - virtual Void - enter (Type&, String const& name, Boolean last) = 0; + virtual void + enter (Type&, String const& name, bool last) = 0; - virtual Void + virtual void leave () = 0; }; @@ -465,10 +466,10 @@ namespace CXX { } - virtual Void + virtual void pre (Type&); - virtual Void + virtual void post (Type&); private: @@ -476,36 +477,35 @@ namespace CXX ScopeTracker* st_; }; - // // template struct Has : X { - Has (Boolean& result) + Has (bool& result) : result_ (result) { } - virtual Void + virtual void traverse (typename X::Type&) { result_ = true; } private: - Boolean& result_; + bool& result_; }; // Checks if scope 'Y' names any of 'X' // template - Boolean + bool has (Y& y) { using SemanticGraph::Scope; - Boolean result (false); + bool result (false); Has t (result); for (Scope::NamesIterator i (y.names_begin ()), e (y.names_end ()); @@ -518,12 +518,12 @@ namespace CXX // Checks if the compositor has any particle of 'X' // template - Boolean + bool has_particle (SemanticGraph::Compositor& y) { using SemanticGraph::Compositor; - Boolean result (false); + bool result (false); Has t (result); for (Compositor::ContainsIterator i (y.contains_begin ()), @@ -543,7 +543,7 @@ namespace CXX // Specialization for Complex // template - Boolean + bool has_particle (SemanticGraph::Complex& c) { return c.contains_compositor_p () && @@ -562,61 +562,61 @@ namespace CXX Traversal::Fundamental::Id, Traversal::Fundamental::IdRef { - virtual Void + virtual void fundamental_type (SemanticGraph::Fundamental::Type& t) = 0; - virtual Void + virtual void fundamental_template (SemanticGraph::Fundamental::Type& t) = 0; - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Type& t) { fundamental_type (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { fundamental_template (t); diff --git a/xsd/xsd/cxx/literal-map.cxx b/xsd/xsd/cxx/literal-map.cxx index c531b5e..24bfc52 100644 --- a/xsd/xsd/cxx/literal-map.cxx +++ b/xsd/xsd/cxx/literal-map.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/literal-map.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 // std::auto_ptr @@ -9,7 +8,6 @@ #include #include -#include #include @@ -45,7 +43,7 @@ namespace CXX locator_ = l; } - virtual Void + virtual void startElement (const XMLCh* const, const XMLCh* const lname, const XMLCh* const, @@ -81,7 +79,7 @@ namespace CXX } } - virtual Void + virtual void endElement (const XMLCh* const, const XMLCh* const lname, const XMLCh* const) @@ -115,13 +113,8 @@ namespace CXX state_ = s_entry; } -#if _XERCES_VERSION >= 30000 - virtual Void + virtual void characters (const XMLCh* const s, const XMLSize_t length) -#else - virtual Void - characters (const XMLCh* const s, const unsigned int length) -#endif { String str (XML::transcode (s, length)); @@ -131,9 +124,9 @@ namespace CXX lit_ += str; else { - for (Size i (0); i < str.size (); ++i) + for (size_t i (0); i < str.size (); ++i) { - WideChar c (str[i]); + wchar_t c (str[i]); if (c != 0x20 && c != 0x0A && c != 0x0D && c != 0x09) { @@ -149,44 +142,37 @@ namespace CXX // enum Severity {s_warning, s_error, s_fatal}; - virtual Void + virtual void warning (const SAXParseException& e) { handle (e, s_warning); } - virtual Void + virtual void error (const SAXParseException& e) { handle (e, s_error); } - virtual Void + virtual void fatalError (const SAXParseException& e) { handle (e, s_fatal); } - virtual Void + virtual void resetErrors () { } - Void + void handle (const SAXParseException& e, Severity s) { - wcerr << file_ << ":"; - -#if _XERCES_VERSION >= 30000 - wcerr << e.getLineNumber () << ":" << e.getColumnNumber () << ": "; -#else - XMLSSize_t l (e.getLineNumber ()); - XMLSSize_t c (e.getColumnNumber ()); - wcerr << (l == -1 ? 0 : l) << ":" << (c == -1 ? 0 : c) << ": "; -#endif - String msg (XML::transcode (e.getMessage ())); - wcerr << (s == s_warning ? "warning: " : "error: ") << msg << endl; + + wcerr << file_ << ":" + << e.getLineNumber () << ":" << e.getColumnNumber () << ": " + << (s == s_warning ? "warning: " : "error: ") << msg << endl; if (s != s_warning) throw Failed (); @@ -195,37 +181,17 @@ namespace CXX size_t line () const { - size_t r (0); - - if (locator_ != 0) - { -#if _XERCES_VERSION >= 30000 - r = static_cast (locator_->getLineNumber ()); -#else - XMLSSize_t l (locator_->getLineNumber ()); - r = l == -1 ? 0 : static_cast (l); -#endif - } - - return r; + return locator_ != 0 + ? static_cast (locator_->getLineNumber ()) + : 0; } size_t col () const { - size_t r (0); - - if (locator_ != 0) - { -#if _XERCES_VERSION >= 30000 - r = static_cast (locator_->getColumnNumber ()); -#else - XMLSSize_t c (locator_->getColumnNumber ()); - r = c == -1 ? 0 : static_cast (c); -#endif - } - - return r; + return locator_ != 0 + ? static_cast (locator_->getColumnNumber ()) + : 0; } private: @@ -243,8 +209,8 @@ namespace CXX String file_; StringLiteralMap& map_; - Boolean str_seen_; - Boolean lit_seen_; + bool str_seen_; + bool lit_seen_; String str_; String lit_; diff --git a/xsd/xsd/cxx/literal-map.hxx b/xsd/xsd/cxx/literal-map.hxx index 6edeb00..987a531 100644 --- a/xsd/xsd/cxx/literal-map.hxx +++ b/xsd/xsd/cxx/literal-map.hxx @@ -1,20 +1,17 @@ // file : xsd/cxx/literal-map.hxx -// 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 #ifndef CXX_LITERAL_MAP_HXX #define CXX_LITERAL_MAP_HXX -#include -#include +#include + +#include namespace CXX { - using namespace Cult; - typedef WideString String; - - typedef Cult::Containers::Map StringLiteralMap; + typedef std::map StringLiteralMap; bool read_literal_map (NarrowString const& file, StringLiteralMap& map); diff --git a/xsd/xsd/cxx/option-types.cxx b/xsd/xsd/cxx/option-types.cxx new file mode 100644 index 0000000..78424f0 --- /dev/null +++ b/xsd/xsd/cxx/option-types.cxx @@ -0,0 +1,48 @@ +// file : xsd/cxx/option-types.cxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +#include + +using namespace std; + +namespace CXX +{ + // + // cxx_version + // + + static const char* cxx_version_[] = + { + "c++98", + "c++11" + }; + + string cxx_version:: + string () const + { + return cxx_version_[v_]; + } + + istream& + operator>> (istream& is, cxx_version& v) + { + string s; + is >> s; + + if (!is.fail ()) + { + if (s == "c++98") + v = cxx_version::cxx98; + else if (s == "c++11") + v = cxx_version::cxx11; + else + is.setstate (istream::failbit); + } + + return is; + } +} diff --git a/xsd/xsd/cxx/option-types.hxx b/xsd/xsd/cxx/option-types.hxx new file mode 100644 index 0000000..b2377ba --- /dev/null +++ b/xsd/xsd/cxx/option-types.hxx @@ -0,0 +1,35 @@ +// file : xsd/cxx/option-types.hxx +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_OPTION_TYPES_HXX +#define XSD_OPTION_TYPES_HXX + +#include +#include + +namespace CXX +{ + struct cxx_version + { + enum value + { + cxx98, + cxx11 + }; + + cxx_version (value v = value (0)) : v_ (v) {} + operator value () const {return v_;} + + std::string + string () const; + + private: + value v_; + }; + + std::istream& + operator>> (std::istream&, cxx_version&); +} + +#endif // XSD_OPTION_TYPES_HXX diff --git a/xsd/xsd/cxx/options.cli b/xsd/xsd/cxx/options.cli new file mode 100644 index 0000000..8133b25 --- /dev/null +++ b/xsd/xsd/cxx/options.cli @@ -0,0 +1,551 @@ +// file : xsd/cxx/options.cli +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include ; // std::size_t + +include ; // NarrowString, NarrowStrings + +include ; + +include ; + +namespace CXX +{ + class options: ::options = 0 + { + // Language. + // + cxx_version --std = cxx_version::cxx98 + { + "", + "Specify the C++ standard that the generated code should conform to. + Valid values are \cb{c++98} (default) and \cb{c++11}. + + The C++ standard affects various aspects of the generated code that + are discussed in more detail in various mapping-specific + documentation. Overall, when C++11 is selected, the generated + code relies on the move semantics and uses \cb{std::unique_ptr} + instead of deprecated \cb{std::auto_ptr}. + + When the C++11 mode is selected, you normally don't need to + perform any extra steps other than enable C++11 in your C++ + compiler, if required. The XSD compiler will automatically + add the necessary macro defines to the generated header files + that will switch the header-only XSD runtime library (\cb{libxsd}) + to the C++11 mode. However, if you include any of the XSD runtime + headers directly in your application (normally you just include + the generated headers), then you will need to define the + \cb{XSD_CXX11} macro for your entire project." + }; + + // Character type and encoding. + // + NarrowString --char-type = "char" + { + "", + "Generate code using the provided character instead of the + default \cb{char}. Valid values are \cb{char} and \cb{wchar_t}." + }; + + NarrowString --char-encoding + { + "", + "Specify the character encoding that should be used in the generated + code. Valid values for the \cb{char} character type are \cb{utf8} + (default), \cb{iso8859-1}, \cb{lcp} (Xerces-C++ local code page), + and \cb{custom}. If you pass \cb{custom} as the value then you will + need to include the transcoder implementation header for your + encoding at the beginning of the generated header files (see the + \cb{--hxx-prologue} option). + + For the \cb{wchar_t} character type the only valid value is \cb{auto} + and the encoding is automatically selected between UTF-16 and + UTF-32/UCS-4, depending on the \cb{wchar_t} type size." + }; + + // Output options. + // + NarrowString --output-dir + { + "", + "Write generated files to instead of the current directory." + }; + + bool --generate-inline + { + "Generate simple functions inline. This option triggers creation of + the inline file." + }; + + // Extern XML Schema. + // + bool --generate-xml-schema + { + "Generate a C++ header file as if the schema being compiled defines the + XML Schema namespace. For the C++/Tree mapping, the resulting file will + contain definitions for all XML Schema built-in types. For the + C++/Parser mapping, the resulting file will contain definitions for + all the parser skeletons and implementations corresponding to the + XML Schema built-in types. + + The schema file provided to the compiler need not exist and is only + used to derive the name of the resulting header file. Use the + \cb{--extern-xml-schema} option to include this file in the + generated files for other schemas." + }; + + NarrowString --extern-xml-schema + { + "", + "Include a header file derived from instead of generating the + XML Schema namespace mapping inline. The provided file need not + exist and is only used to derive the name of the included header + file. Use the \cb{--generate-xml-schema} option to generate this + header file." + }; + + // Namespace mapping. + // + NarrowStrings --namespace-map + { + "=", + "Map XML Schema namespace to C++ namespace . Repeat + this option to specify mapping for more than one XML Schema namespace. + For example, the following option: + + \cb{--namespace-map http://example.com/foo/bar=foo::bar} + + Will map the \cb{http://example.com/foo/bar} XML Schema namespace to + the \cb{foo::bar} C++ namespace." + }; + + NarrowStrings --namespace-regex + { + "", + "Add to the list of regular expressions used to translate XML + Schema namespace names to C++ namespace names. is a Perl-like + regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be + used as a delimiter instead of \cb{/}. Escaping of the delimiter + character in \ci{pattern} or \ci{replacement} is not supported. + + All the regular expressions are pushed into a stack with the last + specified expression considered first. The first match that + succeeds is used. Regular expressions are applied to a string in + the form + + \c{\i{filename} \i{namespace}} + + For example, if you have file \cb{hello.xsd} with namespace + \cb{http://example.com/hello} and you run \cb{xsd} on this file, + then the string in question will be: + + \cb{hello.xsd. http://example.com/hello} + + For the built-in XML Schema namespace the string is: + + \cb{XMLSchema.xsd http://www.w3.org/2001/XMLSchema} + + The following three steps are performed for each regular expression + until the match is found: + + 1. The expression is applied and if the result is empty the next + expression is considered. + + 2. All \cb{/} are replaced with \cb{::}. + + 3. The result is verified to be a valid C++ scope name (e.g., + \cb{foo::bar}). If this test succeeds, the result is used as a + C++ namespace name. + + As an example, the following expression maps XML Schema namespaces + in the form \cb{http://example.com/foo/bar} to C++ namespaces in the + form \cb{foo::bar}: + + \cb{%.* http://example.com/(.+)%$1%} + + See also the REGEX AND SHELL QUOTING section below." + }; + + bool --namespace-regex-trace + { + "Trace the process of applying regular expressions specified with the + \cb{--namespace-regex} option. Use this option to find out why your + regular expressions don't do what you expected them to do." + }; + + // Reserved names. + // + NarrowStrings --reserved-name + { + "[=]", + "Add name to the list of names that should not be used as + identifiers. The name can optionally be followed by \cb{=} and the + replacement name that should be used instead. All the C++ keywords + are already in this list." + }; + + // Include options. + // + bool --include-with-brackets + { + "Use angle brackets (<>) instead of quotes (\"\") in generated + \cb{#include} directives." + }; + + NarrowString --include-prefix + { + "", + "Add to generated \cb{#include} directive paths. + + For example, if you had the following import element in your schema + + \cb{} + + and compiled this fragment with \cb{--include-prefix schemas/}, then + the include directive in the generated code would be: + + \cb{#include \"schemas/base.hxx\"}" + }; + + NarrowStrings --include-regex + { + "", + "Add to the list of regular expressions used to transform + \cb{#include} directive paths. is a Perl-like regular + expression in the form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. + Any character can be used as a delimiter instead of \cb{/}. Escaping + of the delimiter character in \ci{pattern} or \ci{replacement} is not + supported. + + All the regular expressions are pushed into a stack with the last + specified expression considered first. The first match that succeeds + is used. + + As an example, the following expression transforms paths in the form + \cb{schemas/foo/bar} to paths in the form \cb{generated/foo/bar}: + + \cb{%schemas/(.+)%generated/$1%} + + See also the REGEX AND SHELL QUOTING section below." + }; + + bool --include-regex-trace + { + "Trace the process of applying regular expressions specified with the + \cb{--include-regex} option. Use this option to find out why your + regular expressions don't do what you expected them to do." + }; + + NarrowString --guard-prefix + { + "", + "Add to generated header inclusion guards. The prefix is + transformed to upper case and characters that are illegal in a + preprocessor macro name are replaced with underscores. If this + option is not specified then the directory part of the input schema + file is used as a prefix." + }; + + // File suffixes. + // + NarrowString --hxx-suffix = ".hxx" + { + "", + "Use the provided instead of the default \cb{.hxx} to + construct the name of the header file. Note that this suffix is also + used to construct names of header files corresponding to + included/imported schemas." + }; + + NarrowString --ixx-suffix = ".ixx" + { + "", + "Use the provided instead of the default \cb{.ixx} to + construct the name of the inline file." + }; + + NarrowString --cxx-suffix = ".cxx" + { + "", + "Use the provided instead of the default \cb{.cxx} to + construct the name of the source file." + }; + + NarrowString --fwd-suffix = "-fwd.hxx" + { + "", + "Use the provided instead of the default \cb{-fwd.hxx} to + construct the name of the forward declaration file." + }; + + NarrowString --hxx-regex + { + "", + "Use the provided expression to construct the name of the header file. + is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. + Note that this expression is also used to construct names of header + files corresponding to included/imported schemas. See also the REGEX + AND SHELL QUOTING section below." + }; + + NarrowString --ixx-regex + { + "", + "Use the provided expression to construct the name of the inline file. + is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND + SHELL QUOTING section below." + }; + + NarrowString --cxx-regex + { + "", + "Use the provided expression to construct the name of the source file. + is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND + SHELL QUOTING section below." + }; + + NarrowString --fwd-regex + { + "", + "Use the provided expression to construct the name of the forward + declaration file. is a Perl-like regular expression in the + form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX + AND SHELL QUOTING section below." + }; + + // Prologues/epilogues. + // + NarrowStrings --hxx-prologue + { + "", + "Insert at the beginning of the header file." + }; + + NarrowStrings --ixx-prologue + { + "", + "Insert at the beginning of the inline file." + }; + + NarrowStrings --cxx-prologue + { + "", + "Insert at the beginning of the source file." + }; + + NarrowStrings --fwd-prologue + { + "", + "Insert at the beginning of the forward declaration file." + }; + + NarrowStrings --prologue + { + "", + "Insert at the beginning of each generated file for which + there is no file-specific prologue." + }; + + NarrowStrings --hxx-epilogue + { + "", + "Insert at the end of the header file." + }; + + NarrowStrings --ixx-epilogue + { + "", + "Insert at the end of the inline file." + }; + + NarrowStrings --cxx-epilogue + { + "", + "Insert at the end of the source file." + }; + + NarrowStrings --fwd-epilogue + { + "", + "Insert at the end of the forward declaration file." + }; + + NarrowStrings --epilogue + { + "", + "Insert at the end of each generated file for which there + is no file-specific epilogue." + }; + + NarrowString --hxx-prologue-file + { + "", + "Insert the content of the at the beginning of the header file." + }; + + NarrowString --ixx-prologue-file + { + "", + "Insert the content of the at the beginning of the inline file." + }; + + NarrowString --cxx-prologue-file + { + "", + "Insert the content of the at the beginning of the source file." + }; + + NarrowString --fwd-prologue-file + { + "", + "Insert the content of the at the beginning of the forward + declaration file." + }; + + NarrowString --prologue-file + { + "", + "Insert the content of the at the beginning of each generated + file for which there is no file-specific prologue file." + }; + + NarrowString --hxx-epilogue-file + { + "", + "Insert the content of the at the end of the header file." + }; + + NarrowString --ixx-epilogue-file + { + "", + "Insert the content of the at the end of the inline file." + }; + + NarrowString --cxx-epilogue-file + { + "", + "Insert the content of the at the end of the source file." + }; + + NarrowString --fwd-epilogue-file + { + "", + "Insert the content of the at the end of the forward declaration + file." + }; + + NarrowString --epilogue-file + { + "", + "Insert the content of the at the end of each generated file + for which there is no file-specific epilogue file." + }; + + // Export options. + // + NarrowString --export-symbol + { + "", + "Insert in places where DLL export/import control statements + (\cb{__declspec(dllexport/dllimport)}) are necessary." + }; + + bool --export-xml-schema + { + "Export/import types in the XML Schema namespace using the export + symbol provided with the \cb{--export-symbol} option. The + \cb{XSD_NO_EXPORT} macro can be used to omit this code during C++ + compilation, which may be useful if you would like to use the same + generated code across multiple platforms." + }; + + bool --export-maps + { + "Export polymorphism support maps from a Win32 DLL into which this + generated code is placed. This is necessary when your type hierarchy + is split across several DLLs since otherwise each DLL will have its + own set of maps. In this situation the generated code for the DLL + which contains base types and/or substitution group heads should be + compiled with this option and the generated code for all other DLLs + should be compiled with \cb{--import-maps}. This option is only valid + together with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} + macro can be used to omit this code during C++ compilation, which may + be useful if you would like to use the same generated code across + multiple platforms." + }; + + bool --import-maps + { + "Import polymorphism support maps to a Win32 DLL or executable into + which this generated code is linked. See the \cb{--export-maps} + option documentation for details. This options is only valid together + with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} macro can be + used to omit this code during C++ compilation, which may be useful if + you would like to use the same generated code across multiple + platforms." + }; + + // Make dependency generation. + // + bool --generate-dep + { + "Generate \cb{make} dependency information. This option triggers the + creation of the \cb{.d} file containing the dependencies of the + generated files on the main schema file as well as all the schema + files that it includes/imports, transitively. This dependency file + is then normally included into the main \cb{makefile} to implement + automatic dependency tracking. + + Note also that automatic dependency generation is not supported in + the file-per-type mode (\cb{--file-per-type}). In this case, all + the generated files are produced with a single compiler invocation + and depend on all the schemas. As a result, it is easier to establish + such a dependency manually, perhaps with the help of the + \cb{--file-list*} options." + }; + + bool --generate-dep-only + { + "Generate \cb{make} dependency information only." + }; + + bool --dep-phony + { + "Generate phony targets for included/imported schema files, causing + each to depend on nothing. Such dummy rules work around \cb{make} + errors caused by the removal of schema files without also updating + the dependency file to match." + }; + + NarrowStrings --dep-target + { + "", + "Change the target of the dependency rule. By default it contains + all the generated C++ files as well as the dependency file itself, + without any directory prefixes. If you require multiple targets, + then you can specify them as a single, space-separated argument or + you can repeat this option multiple times." + }; + + NarrowString --dep-suffix = ".d" + { + "", + "Use the provided instead of the default \cb{.d} to + construct the name of the dependency file." + }; + + NarrowString --dep-regex + { + "", + "Use the provided expression to construct the name of the dependency + file. is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX + AND SHELL QUOTING section below." + }; + }; +} diff --git a/xsd/xsd/cxx/options.cxx b/xsd/xsd/cxx/options.cxx new file mode 100644 index 0000000..1d2e8fd --- /dev/null +++ b/xsd/xsd/cxx/options.cxx @@ -0,0 +1,638 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +#include +// +// End prologue. + +#include + +#include +#include +#include +#include +#include +#include + +namespace cli +{ + template + struct parser + { + static void + parse (X& x, bool& xs, scanner& s) + { + std::string o (s.next ()); + + if (s.more ()) + { + std::string v (s.next ()); + std::istringstream is (v); + if (!(is >> x && is.eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + + xs = true; + } + }; + + template <> + struct parser + { + static void + parse (bool& x, scanner& s) + { + s.next (); + x = true; + } + }; + + template <> + struct parser + { + static void + parse (std::string& x, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + x = s.next (); + else + throw missing_value (o); + + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::vector& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.push_back (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::set& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.insert (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::map& m, bool& xs, scanner& s) + { + std::string o (s.next ()); + + if (s.more ()) + { + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + if (p == std::string::npos) + { + K k = K (); + + if (!ov.empty ()) + { + std::istringstream ks (ov); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + m[k] = V (); + } + else + { + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, p + 1); + + if (!kstr.empty ()) + { + std::istringstream ks (kstr); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + if (!vstr.empty ()) + { + std::istringstream vs (vstr); + + if (!(vs >> v && vs.eof ())) + throw invalid_value (o, ov); + } + + m[k] = v; + } + } + else + throw missing_value (o); + + xs = true; + } + }; + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, s); + } + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, x.*S, s); + } +} + +#include +#include + +namespace CXX +{ + // options + // + + options:: + options () + : std_ (cxx_version::cxx98), + std_specified_ (false), + char_type_ ("char"), + char_type_specified_ (false), + char_encoding_ (), + char_encoding_specified_ (false), + output_dir_ (), + output_dir_specified_ (false), + generate_inline_ (), + generate_xml_schema_ (), + extern_xml_schema_ (), + extern_xml_schema_specified_ (false), + namespace_map_ (), + namespace_map_specified_ (false), + namespace_regex_ (), + namespace_regex_specified_ (false), + namespace_regex_trace_ (), + reserved_name_ (), + reserved_name_specified_ (false), + include_with_brackets_ (), + include_prefix_ (), + include_prefix_specified_ (false), + include_regex_ (), + include_regex_specified_ (false), + include_regex_trace_ (), + guard_prefix_ (), + guard_prefix_specified_ (false), + hxx_suffix_ (".hxx"), + hxx_suffix_specified_ (false), + ixx_suffix_ (".ixx"), + ixx_suffix_specified_ (false), + cxx_suffix_ (".cxx"), + cxx_suffix_specified_ (false), + fwd_suffix_ ("-fwd.hxx"), + fwd_suffix_specified_ (false), + hxx_regex_ (), + hxx_regex_specified_ (false), + ixx_regex_ (), + ixx_regex_specified_ (false), + cxx_regex_ (), + cxx_regex_specified_ (false), + fwd_regex_ (), + fwd_regex_specified_ (false), + hxx_prologue_ (), + hxx_prologue_specified_ (false), + ixx_prologue_ (), + ixx_prologue_specified_ (false), + cxx_prologue_ (), + cxx_prologue_specified_ (false), + fwd_prologue_ (), + fwd_prologue_specified_ (false), + prologue_ (), + prologue_specified_ (false), + hxx_epilogue_ (), + hxx_epilogue_specified_ (false), + ixx_epilogue_ (), + ixx_epilogue_specified_ (false), + cxx_epilogue_ (), + cxx_epilogue_specified_ (false), + fwd_epilogue_ (), + fwd_epilogue_specified_ (false), + epilogue_ (), + epilogue_specified_ (false), + hxx_prologue_file_ (), + hxx_prologue_file_specified_ (false), + ixx_prologue_file_ (), + ixx_prologue_file_specified_ (false), + cxx_prologue_file_ (), + cxx_prologue_file_specified_ (false), + fwd_prologue_file_ (), + fwd_prologue_file_specified_ (false), + prologue_file_ (), + prologue_file_specified_ (false), + hxx_epilogue_file_ (), + hxx_epilogue_file_specified_ (false), + ixx_epilogue_file_ (), + ixx_epilogue_file_specified_ (false), + cxx_epilogue_file_ (), + cxx_epilogue_file_specified_ (false), + fwd_epilogue_file_ (), + fwd_epilogue_file_specified_ (false), + epilogue_file_ (), + epilogue_file_specified_ (false), + export_symbol_ (), + export_symbol_specified_ (false), + export_xml_schema_ (), + export_maps_ (), + import_maps_ (), + generate_dep_ (), + generate_dep_only_ (), + dep_phony_ (), + dep_target_ (), + dep_target_specified_ (false), + dep_suffix_ (".d"), + dep_suffix_specified_ (false), + dep_regex_ (), + dep_regex_specified_ (false) + { + } + + void options:: + print_usage (::std::wostream& os) + { + os << "--std Specify the C++ standard that the generated code" << ::std::endl + << " should conform to." << ::std::endl; + + os << "--char-type Generate code using the provided character " << ::std::endl + << " instead of the default 'char'." << ::std::endl; + + os << "--char-encoding Specify the character encoding that should be used" << ::std::endl + << " in the generated code." << ::std::endl; + + os << "--output-dir Write generated files to instead of the" << ::std::endl + << " current directory." << ::std::endl; + + os << "--generate-inline Generate simple functions inline." << ::std::endl; + + os << "--generate-xml-schema Generate a C++ header file as if the schema being" << ::std::endl + << " compiled defines the XML Schema namespace." << ::std::endl; + + os << "--extern-xml-schema Include a header file derived from instead" << ::std::endl + << " of generating the XML Schema namespace mapping" << ::std::endl + << " inline." << ::std::endl; + + os << "--namespace-map = Map XML Schema namespace to C++ namespace" << ::std::endl + << " ." << ::std::endl; + + os << "--namespace-regex Add to the list of regular expressions" << ::std::endl + << " used to translate XML Schema namespace names to" << ::std::endl + << " C++ namespace names." << ::std::endl; + + os << "--namespace-regex-trace Trace the process of applying regular expressions" << ::std::endl + << " specified with the '--namespace-regex' option." << ::std::endl; + + os << "--reserved-name [=] Add name to the list of names that should not" << ::std::endl + << " be used as identifiers." << ::std::endl; + + os << "--include-with-brackets Use angle brackets (<>) instead of quotes (\"\") in" << ::std::endl + << " generated '#include' directives." << ::std::endl; + + os << "--include-prefix Add to generated '#include' directive" << ::std::endl + << " paths." << ::std::endl; + + os << "--include-regex Add to the list of regular expressions" << ::std::endl + << " used to transform '#include' directive paths." << ::std::endl; + + os << "--include-regex-trace Trace the process of applying regular expressions" << ::std::endl + << " specified with the '--include-regex' option." << ::std::endl; + + os << "--guard-prefix Add to generated header inclusion guards." << ::std::endl; + + os << "--hxx-suffix Use the provided instead of the default" << ::std::endl + << " '.hxx' to construct the name of the header file." << ::std::endl; + + os << "--ixx-suffix Use the provided instead of the default" << ::std::endl + << " '.ixx' to construct the name of the inline file." << ::std::endl; + + os << "--cxx-suffix Use the provided instead of the default" << ::std::endl + << " '.cxx' to construct the name of the source file." << ::std::endl; + + os << "--fwd-suffix Use the provided instead of the default" << ::std::endl + << " '-fwd.hxx' to construct the name of the forward" << ::std::endl + << " declaration file." << ::std::endl; + + os << "--hxx-regex Use the provided expression to construct the name" << ::std::endl + << " of the header file." << ::std::endl; + + os << "--ixx-regex Use the provided expression to construct the name" << ::std::endl + << " of the inline file." << ::std::endl; + + os << "--cxx-regex Use the provided expression to construct the name" << ::std::endl + << " of the source file." << ::std::endl; + + os << "--fwd-regex Use the provided expression to construct the name" << ::std::endl + << " of the forward declaration file." << ::std::endl; + + os << "--hxx-prologue Insert at the beginning of the header file." << ::std::endl; + + os << "--ixx-prologue Insert at the beginning of the inline file." << ::std::endl; + + os << "--cxx-prologue Insert at the beginning of the source file." << ::std::endl; + + os << "--fwd-prologue Insert at the beginning of the forward" << ::std::endl + << " declaration file." << ::std::endl; + + os << "--prologue Insert at the beginning of each generated" << ::std::endl + << " file for which there is no file-specific prologue." << ::std::endl; + + os << "--hxx-epilogue Insert at the end of the header file." << ::std::endl; + + os << "--ixx-epilogue Insert at the end of the inline file." << ::std::endl; + + os << "--cxx-epilogue Insert at the end of the source file." << ::std::endl; + + os << "--fwd-epilogue Insert at the end of the forward" << ::std::endl + << " declaration file." << ::std::endl; + + os << "--epilogue Insert at the end of each generated file" << ::std::endl + << " for which there is no file-specific epilogue." << ::std::endl; + + os << "--hxx-prologue-file Insert the content of the at the beginning" << ::std::endl + << " of the header file." << ::std::endl; + + os << "--ixx-prologue-file Insert the content of the at the beginning" << ::std::endl + << " of the inline file." << ::std::endl; + + os << "--cxx-prologue-file Insert the content of the at the beginning" << ::std::endl + << " of the source file." << ::std::endl; + + os << "--fwd-prologue-file Insert the content of the at the beginning" << ::std::endl + << " of the forward declaration file." << ::std::endl; + + os << "--prologue-file Insert the content of the at the beginning" << ::std::endl + << " of each generated file for which there is no" << ::std::endl + << " file-specific prologue file." << ::std::endl; + + os << "--hxx-epilogue-file Insert the content of the at the end of the" << ::std::endl + << " header file." << ::std::endl; + + os << "--ixx-epilogue-file Insert the content of the at the end of the" << ::std::endl + << " inline file." << ::std::endl; + + os << "--cxx-epilogue-file Insert the content of the at the end of the" << ::std::endl + << " source file." << ::std::endl; + + os << "--fwd-epilogue-file Insert the content of the at the end of the" << ::std::endl + << " forward declaration file." << ::std::endl; + + os << "--epilogue-file Insert the content of the at the end of" << ::std::endl + << " each generated file for which there is no" << ::std::endl + << " file-specific epilogue file." << ::std::endl; + + os << "--export-symbol Insert in places where DLL export/import" << ::std::endl + << " control statements" << ::std::endl + << " ('__declspec(dllexport/dllimport)') are necessary." << ::std::endl; + + os << "--export-xml-schema Export/import types in the XML Schema namespace" << ::std::endl + << " using the export symbol provided with the" << ::std::endl + << " '--export-symbol' option." << ::std::endl; + + os << "--export-maps Export polymorphism support maps from a Win32 DLL" << ::std::endl + << " into which this generated code is placed." << ::std::endl; + + os << "--import-maps Import polymorphism support maps to a Win32 DLL or" << ::std::endl + << " executable into which this generated code is" << ::std::endl + << " linked." << ::std::endl; + + os << "--generate-dep Generate 'make' dependency information." << ::std::endl; + + os << "--generate-dep-only Generate 'make' dependency information only." << ::std::endl; + + os << "--dep-phony Generate phony targets for included/imported" << ::std::endl + << " schema files, causing each to depend on nothing." << ::std::endl; + + os << "--dep-target Change the target of the dependency rule." << ::std::endl; + + os << "--dep-suffix Use the provided instead of the default" << ::std::endl + << " '.d' to construct the name of the dependency file." << ::std::endl; + + os << "--dep-regex Use the provided expression to construct the name" << ::std::endl + << " of the dependency file." << ::std::endl; + } + + typedef + std::map + _cli_options_map; + + static _cli_options_map _cli_options_map_; + + struct _cli_options_map_init + { + _cli_options_map_init () + { + _cli_options_map_["--std"] = + &::cli::thunk< options, cxx_version, &options::std_, + &options::std_specified_ >; + _cli_options_map_["--char-type"] = + &::cli::thunk< options, NarrowString, &options::char_type_, + &options::char_type_specified_ >; + _cli_options_map_["--char-encoding"] = + &::cli::thunk< options, NarrowString, &options::char_encoding_, + &options::char_encoding_specified_ >; + _cli_options_map_["--output-dir"] = + &::cli::thunk< options, NarrowString, &options::output_dir_, + &options::output_dir_specified_ >; + _cli_options_map_["--generate-inline"] = + &::cli::thunk< options, bool, &options::generate_inline_ >; + _cli_options_map_["--generate-xml-schema"] = + &::cli::thunk< options, bool, &options::generate_xml_schema_ >; + _cli_options_map_["--extern-xml-schema"] = + &::cli::thunk< options, NarrowString, &options::extern_xml_schema_, + &options::extern_xml_schema_specified_ >; + _cli_options_map_["--namespace-map"] = + &::cli::thunk< options, NarrowStrings, &options::namespace_map_, + &options::namespace_map_specified_ >; + _cli_options_map_["--namespace-regex"] = + &::cli::thunk< options, NarrowStrings, &options::namespace_regex_, + &options::namespace_regex_specified_ >; + _cli_options_map_["--namespace-regex-trace"] = + &::cli::thunk< options, bool, &options::namespace_regex_trace_ >; + _cli_options_map_["--reserved-name"] = + &::cli::thunk< options, NarrowStrings, &options::reserved_name_, + &options::reserved_name_specified_ >; + _cli_options_map_["--include-with-brackets"] = + &::cli::thunk< options, bool, &options::include_with_brackets_ >; + _cli_options_map_["--include-prefix"] = + &::cli::thunk< options, NarrowString, &options::include_prefix_, + &options::include_prefix_specified_ >; + _cli_options_map_["--include-regex"] = + &::cli::thunk< options, NarrowStrings, &options::include_regex_, + &options::include_regex_specified_ >; + _cli_options_map_["--include-regex-trace"] = + &::cli::thunk< options, bool, &options::include_regex_trace_ >; + _cli_options_map_["--guard-prefix"] = + &::cli::thunk< options, NarrowString, &options::guard_prefix_, + &options::guard_prefix_specified_ >; + _cli_options_map_["--hxx-suffix"] = + &::cli::thunk< options, NarrowString, &options::hxx_suffix_, + &options::hxx_suffix_specified_ >; + _cli_options_map_["--ixx-suffix"] = + &::cli::thunk< options, NarrowString, &options::ixx_suffix_, + &options::ixx_suffix_specified_ >; + _cli_options_map_["--cxx-suffix"] = + &::cli::thunk< options, NarrowString, &options::cxx_suffix_, + &options::cxx_suffix_specified_ >; + _cli_options_map_["--fwd-suffix"] = + &::cli::thunk< options, NarrowString, &options::fwd_suffix_, + &options::fwd_suffix_specified_ >; + _cli_options_map_["--hxx-regex"] = + &::cli::thunk< options, NarrowString, &options::hxx_regex_, + &options::hxx_regex_specified_ >; + _cli_options_map_["--ixx-regex"] = + &::cli::thunk< options, NarrowString, &options::ixx_regex_, + &options::ixx_regex_specified_ >; + _cli_options_map_["--cxx-regex"] = + &::cli::thunk< options, NarrowString, &options::cxx_regex_, + &options::cxx_regex_specified_ >; + _cli_options_map_["--fwd-regex"] = + &::cli::thunk< options, NarrowString, &options::fwd_regex_, + &options::fwd_regex_specified_ >; + _cli_options_map_["--hxx-prologue"] = + &::cli::thunk< options, NarrowStrings, &options::hxx_prologue_, + &options::hxx_prologue_specified_ >; + _cli_options_map_["--ixx-prologue"] = + &::cli::thunk< options, NarrowStrings, &options::ixx_prologue_, + &options::ixx_prologue_specified_ >; + _cli_options_map_["--cxx-prologue"] = + &::cli::thunk< options, NarrowStrings, &options::cxx_prologue_, + &options::cxx_prologue_specified_ >; + _cli_options_map_["--fwd-prologue"] = + &::cli::thunk< options, NarrowStrings, &options::fwd_prologue_, + &options::fwd_prologue_specified_ >; + _cli_options_map_["--prologue"] = + &::cli::thunk< options, NarrowStrings, &options::prologue_, + &options::prologue_specified_ >; + _cli_options_map_["--hxx-epilogue"] = + &::cli::thunk< options, NarrowStrings, &options::hxx_epilogue_, + &options::hxx_epilogue_specified_ >; + _cli_options_map_["--ixx-epilogue"] = + &::cli::thunk< options, NarrowStrings, &options::ixx_epilogue_, + &options::ixx_epilogue_specified_ >; + _cli_options_map_["--cxx-epilogue"] = + &::cli::thunk< options, NarrowStrings, &options::cxx_epilogue_, + &options::cxx_epilogue_specified_ >; + _cli_options_map_["--fwd-epilogue"] = + &::cli::thunk< options, NarrowStrings, &options::fwd_epilogue_, + &options::fwd_epilogue_specified_ >; + _cli_options_map_["--epilogue"] = + &::cli::thunk< options, NarrowStrings, &options::epilogue_, + &options::epilogue_specified_ >; + _cli_options_map_["--hxx-prologue-file"] = + &::cli::thunk< options, NarrowString, &options::hxx_prologue_file_, + &options::hxx_prologue_file_specified_ >; + _cli_options_map_["--ixx-prologue-file"] = + &::cli::thunk< options, NarrowString, &options::ixx_prologue_file_, + &options::ixx_prologue_file_specified_ >; + _cli_options_map_["--cxx-prologue-file"] = + &::cli::thunk< options, NarrowString, &options::cxx_prologue_file_, + &options::cxx_prologue_file_specified_ >; + _cli_options_map_["--fwd-prologue-file"] = + &::cli::thunk< options, NarrowString, &options::fwd_prologue_file_, + &options::fwd_prologue_file_specified_ >; + _cli_options_map_["--prologue-file"] = + &::cli::thunk< options, NarrowString, &options::prologue_file_, + &options::prologue_file_specified_ >; + _cli_options_map_["--hxx-epilogue-file"] = + &::cli::thunk< options, NarrowString, &options::hxx_epilogue_file_, + &options::hxx_epilogue_file_specified_ >; + _cli_options_map_["--ixx-epilogue-file"] = + &::cli::thunk< options, NarrowString, &options::ixx_epilogue_file_, + &options::ixx_epilogue_file_specified_ >; + _cli_options_map_["--cxx-epilogue-file"] = + &::cli::thunk< options, NarrowString, &options::cxx_epilogue_file_, + &options::cxx_epilogue_file_specified_ >; + _cli_options_map_["--fwd-epilogue-file"] = + &::cli::thunk< options, NarrowString, &options::fwd_epilogue_file_, + &options::fwd_epilogue_file_specified_ >; + _cli_options_map_["--epilogue-file"] = + &::cli::thunk< options, NarrowString, &options::epilogue_file_, + &options::epilogue_file_specified_ >; + _cli_options_map_["--export-symbol"] = + &::cli::thunk< options, NarrowString, &options::export_symbol_, + &options::export_symbol_specified_ >; + _cli_options_map_["--export-xml-schema"] = + &::cli::thunk< options, bool, &options::export_xml_schema_ >; + _cli_options_map_["--export-maps"] = + &::cli::thunk< options, bool, &options::export_maps_ >; + _cli_options_map_["--import-maps"] = + &::cli::thunk< options, bool, &options::import_maps_ >; + _cli_options_map_["--generate-dep"] = + &::cli::thunk< options, bool, &options::generate_dep_ >; + _cli_options_map_["--generate-dep-only"] = + &::cli::thunk< options, bool, &options::generate_dep_only_ >; + _cli_options_map_["--dep-phony"] = + &::cli::thunk< options, bool, &options::dep_phony_ >; + _cli_options_map_["--dep-target"] = + &::cli::thunk< options, NarrowStrings, &options::dep_target_, + &options::dep_target_specified_ >; + _cli_options_map_["--dep-suffix"] = + &::cli::thunk< options, NarrowString, &options::dep_suffix_, + &options::dep_suffix_specified_ >; + _cli_options_map_["--dep-regex"] = + &::cli::thunk< options, NarrowString, &options::dep_regex_, + &options::dep_regex_specified_ >; + } + }; + + static _cli_options_map_init _cli_options_map_init_; + + bool options:: + _parse (const char* o, ::cli::scanner& s) + { + _cli_options_map::const_iterator i (_cli_options_map_.find (o)); + + if (i != _cli_options_map_.end ()) + { + (*(i->second)) (*this, s); + return true; + } + + // options base + // + if (::options::_parse (o, s)) + return true; + + return false; + } +} + +// Begin epilogue. +// +// +// End epilogue. + diff --git a/xsd/xsd/cxx/options.hxx b/xsd/xsd/cxx/options.hxx new file mode 100644 index 0000000..dea93a0 --- /dev/null +++ b/xsd/xsd/cxx/options.hxx @@ -0,0 +1,440 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef CXX_OPTIONS_HXX +#define CXX_OPTIONS_HXX + +// Begin prologue. +// +// +// End prologue. + +#include + +#include + +#include + +#include + +namespace CXX +{ + class options: public ::options + { + public: + // Option accessors. + // + const cxx_version& + std () const; + + bool + std_specified () const; + + const NarrowString& + char_type () const; + + bool + char_type_specified () const; + + const NarrowString& + char_encoding () const; + + bool + char_encoding_specified () const; + + const NarrowString& + output_dir () const; + + bool + output_dir_specified () const; + + const bool& + generate_inline () const; + + const bool& + generate_xml_schema () const; + + const NarrowString& + extern_xml_schema () const; + + bool + extern_xml_schema_specified () const; + + const NarrowStrings& + namespace_map () const; + + bool + namespace_map_specified () const; + + const NarrowStrings& + namespace_regex () const; + + bool + namespace_regex_specified () const; + + const bool& + namespace_regex_trace () const; + + const NarrowStrings& + reserved_name () const; + + bool + reserved_name_specified () const; + + const bool& + include_with_brackets () const; + + const NarrowString& + include_prefix () const; + + bool + include_prefix_specified () const; + + const NarrowStrings& + include_regex () const; + + bool + include_regex_specified () const; + + const bool& + include_regex_trace () const; + + const NarrowString& + guard_prefix () const; + + bool + guard_prefix_specified () const; + + const NarrowString& + hxx_suffix () const; + + bool + hxx_suffix_specified () const; + + const NarrowString& + ixx_suffix () const; + + bool + ixx_suffix_specified () const; + + const NarrowString& + cxx_suffix () const; + + bool + cxx_suffix_specified () const; + + const NarrowString& + fwd_suffix () const; + + bool + fwd_suffix_specified () const; + + const NarrowString& + hxx_regex () const; + + bool + hxx_regex_specified () const; + + const NarrowString& + ixx_regex () const; + + bool + ixx_regex_specified () const; + + const NarrowString& + cxx_regex () const; + + bool + cxx_regex_specified () const; + + const NarrowString& + fwd_regex () const; + + bool + fwd_regex_specified () const; + + const NarrowStrings& + hxx_prologue () const; + + bool + hxx_prologue_specified () const; + + const NarrowStrings& + ixx_prologue () const; + + bool + ixx_prologue_specified () const; + + const NarrowStrings& + cxx_prologue () const; + + bool + cxx_prologue_specified () const; + + const NarrowStrings& + fwd_prologue () const; + + bool + fwd_prologue_specified () const; + + const NarrowStrings& + prologue () const; + + bool + prologue_specified () const; + + const NarrowStrings& + hxx_epilogue () const; + + bool + hxx_epilogue_specified () const; + + const NarrowStrings& + ixx_epilogue () const; + + bool + ixx_epilogue_specified () const; + + const NarrowStrings& + cxx_epilogue () const; + + bool + cxx_epilogue_specified () const; + + const NarrowStrings& + fwd_epilogue () const; + + bool + fwd_epilogue_specified () const; + + const NarrowStrings& + epilogue () const; + + bool + epilogue_specified () const; + + const NarrowString& + hxx_prologue_file () const; + + bool + hxx_prologue_file_specified () const; + + const NarrowString& + ixx_prologue_file () const; + + bool + ixx_prologue_file_specified () const; + + const NarrowString& + cxx_prologue_file () const; + + bool + cxx_prologue_file_specified () const; + + const NarrowString& + fwd_prologue_file () const; + + bool + fwd_prologue_file_specified () const; + + const NarrowString& + prologue_file () const; + + bool + prologue_file_specified () const; + + const NarrowString& + hxx_epilogue_file () const; + + bool + hxx_epilogue_file_specified () const; + + const NarrowString& + ixx_epilogue_file () const; + + bool + ixx_epilogue_file_specified () const; + + const NarrowString& + cxx_epilogue_file () const; + + bool + cxx_epilogue_file_specified () const; + + const NarrowString& + fwd_epilogue_file () const; + + bool + fwd_epilogue_file_specified () const; + + const NarrowString& + epilogue_file () const; + + bool + epilogue_file_specified () const; + + const NarrowString& + export_symbol () const; + + bool + export_symbol_specified () const; + + const bool& + export_xml_schema () const; + + const bool& + export_maps () const; + + const bool& + import_maps () const; + + const bool& + generate_dep () const; + + const bool& + generate_dep_only () const; + + const bool& + dep_phony () const; + + const NarrowStrings& + dep_target () const; + + bool + dep_target_specified () const; + + const NarrowString& + dep_suffix () const; + + bool + dep_suffix_specified () const; + + const NarrowString& + dep_regex () const; + + bool + dep_regex_specified () const; + + // Print usage information. + // + static void + print_usage (::std::wostream&); + + // Implementation details. + // + protected: + options (); + + bool + _parse (const char*, ::cli::scanner&); + + public: + cxx_version std_; + bool std_specified_; + NarrowString char_type_; + bool char_type_specified_; + NarrowString char_encoding_; + bool char_encoding_specified_; + NarrowString output_dir_; + bool output_dir_specified_; + bool generate_inline_; + bool generate_xml_schema_; + NarrowString extern_xml_schema_; + bool extern_xml_schema_specified_; + NarrowStrings namespace_map_; + bool namespace_map_specified_; + NarrowStrings namespace_regex_; + bool namespace_regex_specified_; + bool namespace_regex_trace_; + NarrowStrings reserved_name_; + bool reserved_name_specified_; + bool include_with_brackets_; + NarrowString include_prefix_; + bool include_prefix_specified_; + NarrowStrings include_regex_; + bool include_regex_specified_; + bool include_regex_trace_; + NarrowString guard_prefix_; + bool guard_prefix_specified_; + NarrowString hxx_suffix_; + bool hxx_suffix_specified_; + NarrowString ixx_suffix_; + bool ixx_suffix_specified_; + NarrowString cxx_suffix_; + bool cxx_suffix_specified_; + NarrowString fwd_suffix_; + bool fwd_suffix_specified_; + NarrowString hxx_regex_; + bool hxx_regex_specified_; + NarrowString ixx_regex_; + bool ixx_regex_specified_; + NarrowString cxx_regex_; + bool cxx_regex_specified_; + NarrowString fwd_regex_; + bool fwd_regex_specified_; + NarrowStrings hxx_prologue_; + bool hxx_prologue_specified_; + NarrowStrings ixx_prologue_; + bool ixx_prologue_specified_; + NarrowStrings cxx_prologue_; + bool cxx_prologue_specified_; + NarrowStrings fwd_prologue_; + bool fwd_prologue_specified_; + NarrowStrings prologue_; + bool prologue_specified_; + NarrowStrings hxx_epilogue_; + bool hxx_epilogue_specified_; + NarrowStrings ixx_epilogue_; + bool ixx_epilogue_specified_; + NarrowStrings cxx_epilogue_; + bool cxx_epilogue_specified_; + NarrowStrings fwd_epilogue_; + bool fwd_epilogue_specified_; + NarrowStrings epilogue_; + bool epilogue_specified_; + NarrowString hxx_prologue_file_; + bool hxx_prologue_file_specified_; + NarrowString ixx_prologue_file_; + bool ixx_prologue_file_specified_; + NarrowString cxx_prologue_file_; + bool cxx_prologue_file_specified_; + NarrowString fwd_prologue_file_; + bool fwd_prologue_file_specified_; + NarrowString prologue_file_; + bool prologue_file_specified_; + NarrowString hxx_epilogue_file_; + bool hxx_epilogue_file_specified_; + NarrowString ixx_epilogue_file_; + bool ixx_epilogue_file_specified_; + NarrowString cxx_epilogue_file_; + bool cxx_epilogue_file_specified_; + NarrowString fwd_epilogue_file_; + bool fwd_epilogue_file_specified_; + NarrowString epilogue_file_; + bool epilogue_file_specified_; + NarrowString export_symbol_; + bool export_symbol_specified_; + bool export_xml_schema_; + bool export_maps_; + bool import_maps_; + bool generate_dep_; + bool generate_dep_only_; + bool dep_phony_; + NarrowStrings dep_target_; + bool dep_target_specified_; + NarrowString dep_suffix_; + bool dep_suffix_specified_; + NarrowString dep_regex_; + bool dep_regex_specified_; + }; +} + +#include + +// Begin epilogue. +// +// +// End epilogue. + +#endif // CXX_OPTIONS_HXX diff --git a/xsd/xsd/cxx/options.ixx b/xsd/xsd/cxx/options.ixx new file mode 100644 index 0000000..0a8cafa --- /dev/null +++ b/xsd/xsd/cxx/options.ixx @@ -0,0 +1,601 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +namespace CXX +{ + // options + // + + inline const cxx_version& options:: + std () const + { + return this->std_; + } + + inline bool options:: + std_specified () const + { + return this->std_specified_; + } + + inline const NarrowString& options:: + char_type () const + { + return this->char_type_; + } + + inline bool options:: + char_type_specified () const + { + return this->char_type_specified_; + } + + inline const NarrowString& options:: + char_encoding () const + { + return this->char_encoding_; + } + + inline bool options:: + char_encoding_specified () const + { + return this->char_encoding_specified_; + } + + inline const NarrowString& options:: + output_dir () const + { + return this->output_dir_; + } + + inline bool options:: + output_dir_specified () const + { + return this->output_dir_specified_; + } + + inline const bool& options:: + generate_inline () const + { + return this->generate_inline_; + } + + inline const bool& options:: + generate_xml_schema () const + { + return this->generate_xml_schema_; + } + + inline const NarrowString& options:: + extern_xml_schema () const + { + return this->extern_xml_schema_; + } + + inline bool options:: + extern_xml_schema_specified () const + { + return this->extern_xml_schema_specified_; + } + + inline const NarrowStrings& options:: + namespace_map () const + { + return this->namespace_map_; + } + + inline bool options:: + namespace_map_specified () const + { + return this->namespace_map_specified_; + } + + inline const NarrowStrings& options:: + namespace_regex () const + { + return this->namespace_regex_; + } + + inline bool options:: + namespace_regex_specified () const + { + return this->namespace_regex_specified_; + } + + inline const bool& options:: + namespace_regex_trace () const + { + return this->namespace_regex_trace_; + } + + inline const NarrowStrings& options:: + reserved_name () const + { + return this->reserved_name_; + } + + inline bool options:: + reserved_name_specified () const + { + return this->reserved_name_specified_; + } + + inline const bool& options:: + include_with_brackets () const + { + return this->include_with_brackets_; + } + + inline const NarrowString& options:: + include_prefix () const + { + return this->include_prefix_; + } + + inline bool options:: + include_prefix_specified () const + { + return this->include_prefix_specified_; + } + + inline const NarrowStrings& options:: + include_regex () const + { + return this->include_regex_; + } + + inline bool options:: + include_regex_specified () const + { + return this->include_regex_specified_; + } + + inline const bool& options:: + include_regex_trace () const + { + return this->include_regex_trace_; + } + + inline const NarrowString& options:: + guard_prefix () const + { + return this->guard_prefix_; + } + + inline bool options:: + guard_prefix_specified () const + { + return this->guard_prefix_specified_; + } + + inline const NarrowString& options:: + hxx_suffix () const + { + return this->hxx_suffix_; + } + + inline bool options:: + hxx_suffix_specified () const + { + return this->hxx_suffix_specified_; + } + + inline const NarrowString& options:: + ixx_suffix () const + { + return this->ixx_suffix_; + } + + inline bool options:: + ixx_suffix_specified () const + { + return this->ixx_suffix_specified_; + } + + inline const NarrowString& options:: + cxx_suffix () const + { + return this->cxx_suffix_; + } + + inline bool options:: + cxx_suffix_specified () const + { + return this->cxx_suffix_specified_; + } + + inline const NarrowString& options:: + fwd_suffix () const + { + return this->fwd_suffix_; + } + + inline bool options:: + fwd_suffix_specified () const + { + return this->fwd_suffix_specified_; + } + + inline const NarrowString& options:: + hxx_regex () const + { + return this->hxx_regex_; + } + + inline bool options:: + hxx_regex_specified () const + { + return this->hxx_regex_specified_; + } + + inline const NarrowString& options:: + ixx_regex () const + { + return this->ixx_regex_; + } + + inline bool options:: + ixx_regex_specified () const + { + return this->ixx_regex_specified_; + } + + inline const NarrowString& options:: + cxx_regex () const + { + return this->cxx_regex_; + } + + inline bool options:: + cxx_regex_specified () const + { + return this->cxx_regex_specified_; + } + + inline const NarrowString& options:: + fwd_regex () const + { + return this->fwd_regex_; + } + + inline bool options:: + fwd_regex_specified () const + { + return this->fwd_regex_specified_; + } + + inline const NarrowStrings& options:: + hxx_prologue () const + { + return this->hxx_prologue_; + } + + inline bool options:: + hxx_prologue_specified () const + { + return this->hxx_prologue_specified_; + } + + inline const NarrowStrings& options:: + ixx_prologue () const + { + return this->ixx_prologue_; + } + + inline bool options:: + ixx_prologue_specified () const + { + return this->ixx_prologue_specified_; + } + + inline const NarrowStrings& options:: + cxx_prologue () const + { + return this->cxx_prologue_; + } + + inline bool options:: + cxx_prologue_specified () const + { + return this->cxx_prologue_specified_; + } + + inline const NarrowStrings& options:: + fwd_prologue () const + { + return this->fwd_prologue_; + } + + inline bool options:: + fwd_prologue_specified () const + { + return this->fwd_prologue_specified_; + } + + inline const NarrowStrings& options:: + prologue () const + { + return this->prologue_; + } + + inline bool options:: + prologue_specified () const + { + return this->prologue_specified_; + } + + inline const NarrowStrings& options:: + hxx_epilogue () const + { + return this->hxx_epilogue_; + } + + inline bool options:: + hxx_epilogue_specified () const + { + return this->hxx_epilogue_specified_; + } + + inline const NarrowStrings& options:: + ixx_epilogue () const + { + return this->ixx_epilogue_; + } + + inline bool options:: + ixx_epilogue_specified () const + { + return this->ixx_epilogue_specified_; + } + + inline const NarrowStrings& options:: + cxx_epilogue () const + { + return this->cxx_epilogue_; + } + + inline bool options:: + cxx_epilogue_specified () const + { + return this->cxx_epilogue_specified_; + } + + inline const NarrowStrings& options:: + fwd_epilogue () const + { + return this->fwd_epilogue_; + } + + inline bool options:: + fwd_epilogue_specified () const + { + return this->fwd_epilogue_specified_; + } + + inline const NarrowStrings& options:: + epilogue () const + { + return this->epilogue_; + } + + inline bool options:: + epilogue_specified () const + { + return this->epilogue_specified_; + } + + inline const NarrowString& options:: + hxx_prologue_file () const + { + return this->hxx_prologue_file_; + } + + inline bool options:: + hxx_prologue_file_specified () const + { + return this->hxx_prologue_file_specified_; + } + + inline const NarrowString& options:: + ixx_prologue_file () const + { + return this->ixx_prologue_file_; + } + + inline bool options:: + ixx_prologue_file_specified () const + { + return this->ixx_prologue_file_specified_; + } + + inline const NarrowString& options:: + cxx_prologue_file () const + { + return this->cxx_prologue_file_; + } + + inline bool options:: + cxx_prologue_file_specified () const + { + return this->cxx_prologue_file_specified_; + } + + inline const NarrowString& options:: + fwd_prologue_file () const + { + return this->fwd_prologue_file_; + } + + inline bool options:: + fwd_prologue_file_specified () const + { + return this->fwd_prologue_file_specified_; + } + + inline const NarrowString& options:: + prologue_file () const + { + return this->prologue_file_; + } + + inline bool options:: + prologue_file_specified () const + { + return this->prologue_file_specified_; + } + + inline const NarrowString& options:: + hxx_epilogue_file () const + { + return this->hxx_epilogue_file_; + } + + inline bool options:: + hxx_epilogue_file_specified () const + { + return this->hxx_epilogue_file_specified_; + } + + inline const NarrowString& options:: + ixx_epilogue_file () const + { + return this->ixx_epilogue_file_; + } + + inline bool options:: + ixx_epilogue_file_specified () const + { + return this->ixx_epilogue_file_specified_; + } + + inline const NarrowString& options:: + cxx_epilogue_file () const + { + return this->cxx_epilogue_file_; + } + + inline bool options:: + cxx_epilogue_file_specified () const + { + return this->cxx_epilogue_file_specified_; + } + + inline const NarrowString& options:: + fwd_epilogue_file () const + { + return this->fwd_epilogue_file_; + } + + inline bool options:: + fwd_epilogue_file_specified () const + { + return this->fwd_epilogue_file_specified_; + } + + inline const NarrowString& options:: + epilogue_file () const + { + return this->epilogue_file_; + } + + inline bool options:: + epilogue_file_specified () const + { + return this->epilogue_file_specified_; + } + + inline const NarrowString& options:: + export_symbol () const + { + return this->export_symbol_; + } + + inline bool options:: + export_symbol_specified () const + { + return this->export_symbol_specified_; + } + + inline const bool& options:: + export_xml_schema () const + { + return this->export_xml_schema_; + } + + inline const bool& options:: + export_maps () const + { + return this->export_maps_; + } + + inline const bool& options:: + import_maps () const + { + return this->import_maps_; + } + + inline const bool& options:: + generate_dep () const + { + return this->generate_dep_; + } + + inline const bool& options:: + generate_dep_only () const + { + return this->generate_dep_only_; + } + + inline const bool& options:: + dep_phony () const + { + return this->dep_phony_; + } + + inline const NarrowStrings& options:: + dep_target () const + { + return this->dep_target_; + } + + inline bool options:: + dep_target_specified () const + { + return this->dep_target_specified_; + } + + inline const NarrowString& options:: + dep_suffix () const + { + return this->dep_suffix_; + } + + inline bool options:: + dep_suffix_specified () const + { + return this->dep_suffix_specified_; + } + + inline const NarrowString& options:: + dep_regex () const + { + return this->dep_regex_; + } + + inline bool options:: + dep_regex_specified () const + { + return this->dep_regex_specified_; + } +} + +// Begin epilogue. +// +// +// End epilogue. diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/xsd/cxx/parser/attribute-validation-source.cxx index 536e2da..7ed54e4 100644 --- a/xsd/xsd/cxx/parser/attribute-validation-source.cxx +++ b/xsd/xsd/cxx/parser/attribute-validation-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/attribute-validation-source.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 @@ -23,7 +22,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { String const& name (a.name ()); @@ -39,7 +38,7 @@ namespace CXX os << "n == " << strlit (name) << " && ns.empty ()"; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& ns (a.definition_namespace ().name ()); @@ -93,7 +92,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& name (ename (a)); @@ -120,10 +119,20 @@ namespace CXX os << "this->" << inst << "->" << post << " ();" << "this->" << name << " ();"; else - os << arg_type (type) << " tmp (this->" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);" - << endl; + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (std == cxx_version::cxx98) + os << arg_type (type) << " tmp (this->" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (this->" << inst << "->" << + post << " ());"; + } os << "}"; @@ -149,7 +158,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { os << "if ("; @@ -177,7 +186,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (!a.optional_p ()) @@ -195,7 +204,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (!a.optional_p ()) @@ -227,16 +236,16 @@ namespace CXX names_attribute_state_check_ >> attribute_state_check_; } - virtual Void + virtual void traverse (Type& c) { - Boolean has_att (has (c)); - Boolean has_any (has (c)); + bool has_att (has (c)); + bool has_any (has (c)); if (!has_att && !has_any) return; - Boolean has_req_att (false); + bool has_req_att (false); if (has_att) { RequiredAttributeTest test (has_req_att); @@ -380,12 +389,12 @@ namespace CXX }; } - Void + void generate_attribute_validation_source (Context& ctx) { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.hxx b/xsd/xsd/cxx/parser/attribute-validation-source.hxx index a11f434..10438fd 100644 --- a/xsd/xsd/cxx/parser/attribute-validation-source.hxx +++ b/xsd/xsd/cxx/parser/attribute-validation-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/attribute-validation-source.hxx -// 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 #ifndef CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_attribute_validation_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/characters-validation-source.cxx b/xsd/xsd/cxx/parser/characters-validation-source.cxx index 236f2f5..ddecc70 100644 --- a/xsd/xsd/cxx/parser/characters-validation-source.cxx +++ b/xsd/xsd/cxx/parser/characters-validation-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/characters-validation-source.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 @@ -23,7 +22,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { if (!c.mixed_p ()) @@ -46,7 +45,7 @@ namespace CXX }; } - Void + void generate_characters_validation_source (Context& ctx) { //@@ Most of the time there is no mixed content type so @@ -56,7 +55,7 @@ namespace CXX // Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/characters-validation-source.hxx b/xsd/xsd/cxx/parser/characters-validation-source.hxx index 2c1a1b1..219df3e 100644 --- a/xsd/xsd/cxx/parser/characters-validation-source.hxx +++ b/xsd/xsd/cxx/parser/characters-validation-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/characters-validation-source.hxx -// 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 #ifndef CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_characters_validation_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/cli.hxx b/xsd/xsd/cxx/parser/cli.hxx deleted file mode 100644 index bc7ca1a..0000000 --- a/xsd/xsd/cxx/parser/cli.hxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : xsd/cxx/parser/cli.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_CLI_HXX -#define CXX_PARSER_CLI_HXX - -#include - -#include - -#include -#include - -namespace CXX -{ - namespace Parser - { - namespace CLI - { - using namespace Cult::Types; - - typedef Char const Key[]; - - extern Key type_map; - extern Key char_encoding; - extern Key char_type; - extern Key output_dir; - extern Key xml_parser; - extern Key generate_inline; - extern Key generate_validation; - extern Key suppress_validation; - extern Key generate_polymorphic; - extern Key generate_noop_impl; - extern Key generate_print_impl; - extern Key generate_test_driver; - extern Key force_overwrite; - extern Key root_element_first; - extern Key root_element_last; - extern Key root_element; - extern Key generate_xml_schema; - extern Key extern_xml_schema; - extern Key skel_type_suffix; - extern Key skel_file_suffix; - extern Key impl_type_suffix; - extern Key impl_file_suffix; - extern Key namespace_map; - extern Key namespace_regex; - extern Key namespace_regex_trace; - extern Key reserved_name; - extern Key include_with_brackets; - extern Key include_prefix; - extern Key include_regex; - extern Key include_regex_trace; - extern Key guard_prefix; - extern Key hxx_suffix; - extern Key ixx_suffix; - extern Key cxx_suffix; - extern Key hxx_regex; - extern Key ixx_regex; - extern Key cxx_regex; - extern Key hxx_prologue; - extern Key ixx_prologue; - extern Key cxx_prologue; - extern Key prologue; - extern Key hxx_epilogue; - extern Key ixx_epilogue; - extern Key cxx_epilogue; - extern Key epilogue; - extern Key hxx_prologue_file; - extern Key ixx_prologue_file; - extern Key cxx_prologue_file; - extern Key prologue_file; - extern Key hxx_epilogue_file; - extern Key ixx_epilogue_file; - extern Key cxx_epilogue_file; - extern Key epilogue_file; - extern Key export_symbol; - extern Key export_maps; - extern Key import_maps; - extern Key show_anonymous; - extern Key show_sloc; - extern Key proprietary_license; - - typedef Cult::CLI::Options< - type_map, Cult::Containers::Vector, - char_type, NarrowString, - char_encoding, NarrowString, - output_dir, NarrowString, - xml_parser, NarrowString, - generate_inline, Boolean, - generate_validation, Boolean, - suppress_validation, Boolean, - generate_polymorphic, Boolean, - generate_noop_impl, Boolean, - generate_print_impl, Boolean, - generate_test_driver, Boolean, - force_overwrite, Boolean, - root_element_first, Boolean, - root_element_last, Boolean, - root_element, NarrowString, - generate_xml_schema, Boolean, - extern_xml_schema, NarrowString, - skel_type_suffix, NarrowString, - skel_file_suffix, NarrowString, - impl_type_suffix, NarrowString, - impl_file_suffix, NarrowString, - namespace_map, Cult::Containers::Vector, - namespace_regex, Cult::Containers::Vector, - namespace_regex_trace, Boolean, - reserved_name, Cult::Containers::Vector, - include_with_brackets, Boolean, - include_prefix, NarrowString, - include_regex, Cult::Containers::Vector, - include_regex_trace, Boolean, - guard_prefix, NarrowString, - hxx_suffix, NarrowString, - ixx_suffix, NarrowString, - cxx_suffix, NarrowString, - hxx_regex, NarrowString, - ixx_regex, NarrowString, - cxx_regex, NarrowString, - hxx_prologue, Cult::Containers::Vector, - ixx_prologue, Cult::Containers::Vector, - cxx_prologue, Cult::Containers::Vector, - prologue, Cult::Containers::Vector, - hxx_epilogue, Cult::Containers::Vector, - ixx_epilogue, Cult::Containers::Vector, - cxx_epilogue, Cult::Containers::Vector, - epilogue, Cult::Containers::Vector, - hxx_prologue_file, NarrowString, - ixx_prologue_file, NarrowString, - cxx_prologue_file, NarrowString, - prologue_file, NarrowString, - hxx_epilogue_file, NarrowString, - ixx_epilogue_file, NarrowString, - cxx_epilogue_file, NarrowString, - epilogue_file, NarrowString, - export_symbol, NarrowString, - export_maps, Boolean, - import_maps, Boolean, - show_anonymous, Boolean, - show_sloc, Boolean, - proprietary_license, Boolean - - > Options; - - struct OptionsSpec: Cult::CLI::OptionsSpec {}; - } - } -} - -#endif // CXX_PARSER_CLI_HXX diff --git a/xsd/xsd/cxx/parser/driver-source.cxx b/xsd/xsd/cxx/parser/driver-source.cxx index b48b0e0..510c965 100644 --- a/xsd/xsd/cxx/parser/driver-source.cxx +++ b/xsd/xsd/cxx/parser/driver-source.cxx @@ -1,18 +1,18 @@ // file : xsd/cxx/parser/driver-source.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 +#include +#include + #include #include #include #include -#include -#include - -#include +using namespace std; namespace CXX { @@ -20,23 +20,22 @@ namespace CXX { namespace { - typedef - Cult::Containers::Map - TypeInstanceMap; - - typedef Cult::Containers::Set InstanceSet; + typedef map TypeInstanceMap; + typedef set InstanceSet; // For base types we only want member's types, but not the // base itself. // - struct BaseType: Traversal::Complex, Context + struct BaseType: Traversal::Complex, + Traversal::List, + Context { - BaseType (Context& c) - : Context (c) + BaseType (Context& c, Traversal::NodeBase& def) + : Context (c), def_ (def) { } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c); @@ -44,6 +43,15 @@ namespace CXX if (!restriction_p (c)) names (c); } + + virtual void + traverse (SemanticGraph::List& l) + { + def_.dispatch (l.argumented ().type ()); + } + + private: + Traversal::NodeBase& def_; }; struct ParserDef: Traversal::Type, @@ -109,7 +117,7 @@ namespace CXX Context { ParserDef (Context& c, TypeInstanceMap& map, InstanceSet& set) - : Context (c), map_ (map), set_ (set), base_ (c) + : Context (c), map_ (map), set_ (set), base_ (c, *this) { *this >> inherits_ >> base_ >> inherits_; @@ -119,7 +127,7 @@ namespace CXX names_ >> member_ >> belongs_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { if (map_.find (&t) == map_.end ()) @@ -131,7 +139,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (map_.find (&l) == map_.end ()) @@ -145,7 +153,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { if (map_.find (&c) == map_.end ()) @@ -164,13 +172,13 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { fund_type (t, "any_type"); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { fund_type (t, "any_simple_type"); @@ -178,7 +186,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { fund_type (t, "boolean"); @@ -186,79 +194,79 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { fund_type (t, "byte"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { fund_type (t, "unsigned_byte"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { fund_type (t, "short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { fund_type (t, "unsigned_short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { fund_type (t, "int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { fund_type (t, "unsigned_int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { fund_type (t, "long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { fund_type (t, "unsigned_long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { fund_type (t, "integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { fund_type (t, "non_positive_integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { fund_type (t, "non_negative_integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { fund_type (t, "positive_integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { fund_type (t, "negative_integer"); @@ -266,19 +274,19 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { fund_type (t, "float"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { fund_type (t, "double"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { fund_type (t, "decimal"); @@ -286,49 +294,49 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { fund_type (t, "string"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { fund_type (t, "normalized_string"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { fund_type (t, "token"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { fund_type (t, "nmtoken"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { fund_type (t, "nmtokens"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { fund_type (t, "name"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { fund_type (t, "ncname"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { fund_type (t, "language"); @@ -337,7 +345,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { fund_type (t, "qname"); @@ -346,19 +354,19 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { fund_type (t, "id"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { fund_type (t, "idref"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { fund_type (t, "idrefs"); @@ -366,7 +374,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { fund_type (t, "uri"); @@ -374,13 +382,13 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { fund_type (t, "base64_binary"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { fund_type (t, "hex_binary"); @@ -389,55 +397,55 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { fund_type (t, "date"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { fund_type (t, "date_time"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { fund_type (t, "duration"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { fund_type (t, "day"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { fund_type (t, "month"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { fund_type (t, "month_day"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { fund_type (t, "year"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { fund_type (t, "year_month"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { fund_type (t, "time"); @@ -445,20 +453,20 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { fund_type (t, "entity"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { fund_type (t, "entities"); } private: - virtual Void + virtual void fund_type (SemanticGraph::Type& t, String const& name) { if (map_.find (&t) == map_.end ()) @@ -476,7 +484,7 @@ namespace CXX String base_name (escape (raw_name + L"_p")); 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; @@ -516,7 +524,7 @@ namespace CXX names_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -525,7 +533,7 @@ namespace CXX names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (!first_) @@ -536,7 +544,7 @@ namespace CXX os << map_[&l.argumented ().type ()]; } - virtual Void + virtual void traverse (SemanticGraph::Member& m) { if (skip (m)) @@ -556,7 +564,7 @@ namespace CXX Traversal::Inherits inherits_; Traversal::Names names_; - Boolean first_; + bool first_; }; struct ParserConnect: Traversal::List, @@ -564,7 +572,7 @@ namespace CXX Context { ParserConnect (Context& c, TypeInstanceMap& map) - : Context (c), map_ (map), base_ (c) + : Context (c), map_ (map), base_ (c, *this) { *this >> inherits_ >> base_ >> inherits_; @@ -574,7 +582,7 @@ namespace CXX names_ >> member_ >> belongs_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (type_set_.find (&l) == type_set_.end ()) @@ -587,7 +595,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { if (type_set_.find (&c) == type_set_.end ()) @@ -613,7 +621,7 @@ namespace CXX } private: - Boolean + bool has_members (SemanticGraph::Complex& c) { using SemanticGraph::Complex; @@ -636,7 +644,7 @@ namespace CXX private: TypeInstanceMap& map_; - Cult::Containers::Set type_set_; + set type_set_; BaseType base_; Traversal::Inherits inherits_; @@ -647,7 +655,7 @@ namespace CXX }; } - Void + void generate_driver_source (Context& ctx) { // Figure out the root element. Validator should have made sure @@ -656,7 +664,7 @@ namespace CXX SemanticGraph::Element* root (0); { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; @@ -740,7 +748,7 @@ namespace CXX root_p << "." << post << " ());" << endl; - if (ctx.options.value ()) + if (ctx.options.generate_print_impl ()) { PrintCall t (ctx, root->name (), "v"); t.dispatch (root_type); diff --git a/xsd/xsd/cxx/parser/driver-source.hxx b/xsd/xsd/cxx/parser/driver-source.hxx index 9b5a8b1..53e19d8 100644 --- a/xsd/xsd/cxx/parser/driver-source.hxx +++ b/xsd/xsd/cxx/parser/driver-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/driver-source.hxx -// 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 #ifndef CXX_PARSER_DRIVER_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_driver_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/element-validation-source.cxx b/xsd/xsd/cxx/parser/element-validation-source.cxx index 211a0d3..b2c244e 100644 --- a/xsd/xsd/cxx/parser/element-validation-source.cxx +++ b/xsd/xsd/cxx/parser/element-validation-source.cxx @@ -1,14 +1,15 @@ // file : xsd/cxx/parser/element-validation-source.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 + #include #include #include -#include +using namespace std; namespace CXX { @@ -16,8 +17,7 @@ namespace CXX { namespace { - typedef Cult::Containers::Vector Particles; - + typedef vector Particles; // // @@ -31,7 +31,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { String const& name (e.name ()); @@ -62,7 +62,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& ns (a.definition_namespace ().name ()); @@ -109,7 +109,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { // This compositor should already have been tested for @@ -117,9 +117,9 @@ namespace CXX // Particles const& p (c.context ().get ("prefixes")); - Boolean paren (p.size () != 1); + bool paren (p.size () != 1); - for (Particles::ConstIterator i (p.begin ()), e (p.end ()); + for (Particles::const_iterator i (p.begin ()), e (p.end ()); i != e;) { if (paren) @@ -150,21 +150,21 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); os << strlit (ns) << ", " << strlit (e.name ()); } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& ns (*a.namespace_begin ()); os << strlit (ns) << ", " << L << "\"*\""; } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { Particles const& p (c.context ().get ("prefixes")); @@ -187,7 +187,7 @@ namespace CXX // Generate sub-parser setup code as well as the pre/post calls. // - Void + void pre_post_calls (SemanticGraph::Particle& p) { using SemanticGraph::Element; @@ -196,20 +196,23 @@ namespace CXX if (Element* e = dynamic_cast (&p)) { SemanticGraph::Type& type (e->type ()); - Boolean poly (polymorphic && !anonymous (type)); + String const& fq_type (fq_name (type)); + bool poly (polymorphic && !anonymous (type)); String name, inst, def_parser, map; if (e->context ().count("name")) { name = ename (*e); - inst = poly ? emember_cache (*e) : emember (*e); if (poly) { def_parser = emember (*e); map = emember_map (*e); + inst = "p"; } + else + inst = L"this->" + emember (*e); } else { @@ -222,13 +225,15 @@ namespace CXX Element& fe (dynamic_cast(ip.first->named ())); name = ename (fe); - inst = poly ? emember_cache (fe) : emember (fe); if (poly) { def_parser = emember (fe); map = emember_map (fe); + inst = "p"; } + else + inst = L"this->" + emember (fe); } if (poly) @@ -243,8 +248,10 @@ namespace CXX type_id += type_ns; } - os << "if (t == 0 && this->" << def_parser << " != 0)" << endl - << "this->" << inst << " = this->" << def_parser << ";" + os << fq_type << "* p = 0;" + << endl + << "if (t == 0 && this->" << def_parser << " != 0)" << endl + << inst << " = this->" << def_parser << ";" << "else" << "{" << string_type << " ts (" << fq_name (type) << @@ -254,7 +261,7 @@ namespace CXX << "t = &ts;" << endl << "if (this->" << def_parser << " != 0 && *t == ts)" << endl - << "this->" << inst << " = this->" << def_parser << ";" + << inst << " = this->" << def_parser << ";" << "else" << "{"; @@ -269,36 +276,51 @@ namespace CXX " > (*t);" << endl << "if (this->" << map << " != 0)" << endl - << "this->" << inst << " = dynamic_cast< " << - fq_name (type) << "* > (" << endl + << inst << " = dynamic_cast< " << fq_type << "* > (" << endl << "this->" << map << "->find (*t));" - << "else" << endl - << "this->" << inst << " = 0;" << "}" << "}"; } os << "this->" << complex_base << "::context_.top ()." << - "parser_ = this->" << inst << ";" + "parser_ = " << inst << ";" << endl - << "if (this->" << inst << ")" << endl - << "this->" << inst << "->pre ();" + << "if (" << inst << ")" << endl + << inst << "->pre ();" << "}" << "else" // start - << "{" - << "if (this->" << inst << ")" + << "{"; + + if (poly) + os << fq_type << "* p =" << endl + << "dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << complex_base << "::context_.top ().parser_);" + << endl; + + os << "if (" << inst << ")" << "{"; String const& ret (ret_type (type)); String const& post (post_name (type)); if (ret == L"void") - os << "this->" << inst << "->" << post << " ();" + os << inst << "->" << post << " ();" << "this->" << name << " ();"; else - os << arg_type (type) << " tmp (this->" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);"; + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (std == cxx_version::cxx98) + os << arg_type (type) << " tmp (" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (" << inst << "->" << + post << " ());"; + } os << "}"; } @@ -331,10 +353,10 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { - UnsignedLong state (e.context ().get ("state")); + size_t state (e.context ().get ("state")); if (state != 0) os << "else "; @@ -382,14 +404,14 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Particle& p) { using SemanticGraph::Element; - UnsignedLong state (p.context ().get ("state")); + size_t state (p.context ().get ("state")); - UnsignedLong min (p.min ()), max (p.max ()); + size_t min (p.min ()), max (p.max ()); os << "case " << state << "UL:" << endl << "{"; @@ -465,15 +487,15 @@ namespace CXX << "}"; // case } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { using SemanticGraph::Compositor; - UnsignedLong max (c.max ()); - UnsignedLong min (c.context ().get ("effective-min")); - UnsignedLong n (c.context ().get ("comp-number")); - UnsignedLong state (c.context ().get ("state")); + size_t max (c.max ()); + size_t min (c.context ().get ("effective-min")); + size_t n (c.context ().get ("comp-number")); + size_t state (c.context ().get ("state")); String func (c.is_a () ? "choice_" : "sequence_"); @@ -483,7 +505,7 @@ namespace CXX << "unsigned long s (~0UL);" << endl; - Boolean first (true); + bool first (true); for (Compositor::ContainsIterator ci (c.contains_begin ()); ci != c.contains_end (); ++ci) @@ -496,7 +518,7 @@ namespace CXX if (!p.context ().count ("prefix")) break; - UnsignedLong state (p.context ().get ("state")); + size_t state (p.context ().get ("state")); if (first) first = false; @@ -599,8 +621,8 @@ namespace CXX ParticleInCompositor { ParticleInSequence (Context& c, - UnsignedLong state, - UnsignedLong next_state, + size_t state, + size_t next_state, SemanticGraph::Complex& type) : ParticleInCompositor (c, type), state_ (state), particle_name_ (c) @@ -617,10 +639,10 @@ namespace CXX next_state_ = L"~0"; } - virtual Void + virtual void traverse (SemanticGraph::Particle& p) { - UnsignedLong min (p.min ()), max (p.max ()); + size_t min (p.min ()), max (p.max ()); os << "case " << state_ << "UL:" << endl << "{" @@ -694,14 +716,14 @@ namespace CXX << "}"; // case } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { using SemanticGraph::Compositor; - UnsignedLong max (c.max ()); - UnsignedLong min (c.context ().get ("effective-min")); - UnsignedLong n (c.context ().get ("comp-number")); + size_t max (c.max ()); + size_t min (c.context ().get ("effective-min")); + size_t n (c.context ().get ("comp-number")); String func (c.is_a () ? "choice_" : "sequence_"); @@ -711,7 +733,7 @@ namespace CXX << "unsigned long s (~0UL);" << endl; - Boolean first (true); + bool first (true); for (Compositor::ContainsIterator ci (c.contains_begin ()); ci != c.contains_end (); ++ci) @@ -724,7 +746,7 @@ namespace CXX if (!p.context ().count ("prefix")) break; - UnsignedLong state (p.context ().get ("state")); + size_t state (p.context ().get ("state")); if (first) first = false; @@ -816,7 +838,7 @@ namespace CXX } private: - UnsignedLong state_; + size_t state_; String next_state_; ParticleName particle_name_; @@ -837,7 +859,7 @@ namespace CXX } - virtual Void + virtual void traverse (SemanticGraph::All& a) { if (!a.context().count ("comp-number")) // Empty compositor. @@ -878,7 +900,7 @@ namespace CXX Element& e (dynamic_cast (ci->particle ())); String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); - UnsignedLong state (e.context ().get ("state")); + size_t state (e.context ().get ("state")); os << "if (count[" << state << "UL] == 0)" << endl << "this->_expected_element (" << endl @@ -894,7 +916,7 @@ namespace CXX << "}"; } - virtual Void + virtual void traverse (SemanticGraph::Choice& c) { if (!c.context().count ("comp-number")) // Empty compositor. @@ -902,7 +924,7 @@ namespace CXX using SemanticGraph::Compositor; - UnsignedLong n (c.context ().get ("comp-number")); + size_t n (c.context ().get ("comp-number")); os << "void " << ename (type_) << "::" << endl << "choice_" << n << " (unsigned long& state," << endl @@ -940,7 +962,7 @@ namespace CXX Traversal::Choice::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Sequence& s) { if (!s.context().count ("comp-number")) // Empty compositor. @@ -948,7 +970,7 @@ namespace CXX using SemanticGraph::Compositor; - UnsignedLong n (s.context ().get ("comp-number")); + size_t n (s.context ().get ("comp-number")); os << "void " << ename (type_) << "::" << endl << "sequence_" << n << " (unsigned long& state," << endl @@ -963,7 +985,7 @@ namespace CXX << "switch (state)" << "{"; - UnsignedLong state (0); + size_t state (0); for (Compositor::ContainsIterator ci (s.contains_begin ()), ce (s.contains_end ()); ci != ce;) @@ -986,7 +1008,7 @@ namespace CXX ci->particle ().is_a () && !ci->particle ().context().count ("comp-number")); - UnsignedLong next (ci == ce ? 0 : state + 1); + size_t next (ci == ce ? 0 : state + 1); ParticleInSequence t (*this, state++, next, type_); t.dispatch (p); @@ -1014,12 +1036,12 @@ namespace CXX Traversal::Compositor, Context { - CompositorPre (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type) + CompositorPre (Context& c) + : Context (c) { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { // Clear the counts and push the initial state. @@ -1031,7 +1053,7 @@ namespace CXX traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Compositor&) // Choice and sequence. { os << "v_state_& vs = *static_cast< v_state_* > (" << @@ -1042,9 +1064,6 @@ namespace CXX << "vd.state = 0;" << "vd.count = 0;"; } - - private: - SemanticGraph::Complex& type_; }; @@ -1060,7 +1079,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::All&) { // The 'all' state machine reaches the final state only @@ -1078,14 +1097,14 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) // Choice and sequence. { using SemanticGraph::Compositor; - UnsignedLong max (c.max ()); - UnsignedLong min (c.context ().get ("effective-min")); - UnsignedLong n (c.context ().get ("comp-number")); + size_t max (c.max ()); + size_t min (c.context ().get ("effective-min")); + size_t n (c.context ().get ("comp-number")); String func (c.is_a () ? "choice_" : "sequence_"); @@ -1117,7 +1136,7 @@ namespace CXX << "unsigned long s = ~0UL;" << endl; - Boolean first (true); + bool first (true); // Note that we don't need to worry about the compositor // being empty - this case is handled by our caller. @@ -1133,7 +1152,7 @@ namespace CXX if (!p.context ().count ("prefix")) break; - UnsignedLong state (p.context ().get ("state")); + size_t state (p.context ().get ("state")); if (first) first = false; @@ -1230,12 +1249,12 @@ namespace CXX Traversal::Compositor, Context { - CompositorEndElement (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type) + CompositorEndElement (Context& c) + : Context (c) { } - virtual Void + virtual void traverse (SemanticGraph::All&) { os << "all_0 (vd.state, v_all_count_.top (), " << @@ -1243,7 +1262,7 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::Compositor&) // Choice and sequence. { os << "assert (vd.func != 0);" @@ -1253,9 +1272,6 @@ namespace CXX << "vs.size--;" // pop << endl; } - - private: - SemanticGraph::Complex& type_; }; @@ -1265,12 +1281,12 @@ namespace CXX Traversal::Compositor, Context { - CompositorPost (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type), particle_name_ (c) + CompositorPost (Context& c) + : Context (c), particle_name_ (c) { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { using SemanticGraph::Element; @@ -1289,7 +1305,7 @@ namespace CXX << "all_0 (vd.state, v_all_count_.top (), empty, empty, 0, true);" << "}"; - if (a.context ().get ("effective-min") != 0) + if (a.context ().get ("effective-min") != 0) { os << "else" << endl << "this->_expected_element (" << endl; @@ -1304,10 +1320,10 @@ namespace CXX << "v_all_count_.pop ();"; } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) // Choice and sequence. { - UnsignedLong min (c.context ().get ("effective-min")); + size_t min (c.context ().get ("effective-min")); os << "v_state_& vs = *static_cast< v_state_* > (" << "this->v_state_stack_.top ());" @@ -1343,7 +1359,6 @@ namespace CXX } private: - SemanticGraph::Complex& type_; ParticleName particle_name_; }; @@ -1357,7 +1372,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { // Nothing to generate if we don't have any elements and wildcards. @@ -1374,7 +1389,7 @@ namespace CXX // Don't use restriction_p here since we don't want special // treatment of anyType. // - Boolean restriction ( + bool restriction ( c.inherits_p () && c.inherits ().is_a ()); @@ -1476,7 +1491,7 @@ namespace CXX } { - CompositorEndElement t (*this, c); + CompositorEndElement t (*this); t.dispatch (comp); } @@ -1495,7 +1510,7 @@ namespace CXX << endl; { - CompositorPre t (*this, c); + CompositorPre t (*this); t.dispatch (comp); } @@ -1543,7 +1558,7 @@ namespace CXX } { - CompositorPost t (*this, c); + CompositorPost t (*this); t.dispatch (c.contains_compositor ().compositor ()); } @@ -1559,7 +1574,7 @@ namespace CXX }; } - Void + void generate_element_validation_source (Context& ctx) { ctx.os << "#include " << endl @@ -1567,7 +1582,7 @@ namespace CXX Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/element-validation-source.hxx b/xsd/xsd/cxx/parser/element-validation-source.hxx index 544b8f1..b9bd70b 100644 --- a/xsd/xsd/cxx/parser/element-validation-source.hxx +++ b/xsd/xsd/cxx/parser/element-validation-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/element-validation-source.hxx -// 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 #ifndef CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_element_validation_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/elements.cxx b/xsd/xsd/cxx/parser/elements.cxx index b3458c7..889eea4 100644 --- a/xsd/xsd/cxx/parser/elements.cxx +++ b/xsd/xsd/cxx/parser/elements.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/elements.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 @@ -9,60 +8,16 @@ namespace CXX { namespace Parser { - // Keep this symbol first to help HP-UX linker (long symbols?). - // - Content::Value Context:: - content (SemanticGraph::Complex& c) - { - using namespace SemanticGraph; - - if (c.mixed_p ()) - return Content::mixed; - - if (c.inherits_p ()) - { - Type& base (c.inherits ().base ()); - - if (Complex* cb = dynamic_cast (&base)) - return content (*cb); - - if (base.is_a ()) - return Content::complex; - - // Everyhting else (built-in type and AnySimpleType) is simple - // content. - // - return Content::simple; - } - else - return Content::complex; - } - Context:: Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& ops, + options_type const& ops, StringLiteralMap const* map, Regex const* he, Regex const* ie, Regex const* hie) - : CXX::Context (o, - root, - path, - map, - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value ()), + : CXX::Context (o, root, path, ops, map), options (ops), xml_parser (xml_parser_), simple_base (simple_base_), @@ -77,11 +32,11 @@ namespace CXX hxx_expr (he), ixx_expr (ie), hxx_impl_expr (hie), - xml_parser_ (ops.value ()), - validation_ ((ops.value () == "expat" || - ops.value ()) && - !ops.value ()), - polymorphic_ (ops.value ()) + xml_parser_ (ops.xml_parser ()), + validation_ ((ops.xml_parser () == "expat" || + ops.generate_validation ()) && + !ops.suppress_validation ()), + polymorphic_ (ops.generate_polymorphic ()) { if (char_type == L"char") std_string_type = L"::std::string"; @@ -144,7 +99,34 @@ namespace CXX { } - Boolean Context:: + Content::Value Context:: + content (SemanticGraph::Complex& c) + { + using namespace SemanticGraph; + + if (c.mixed_p ()) + return Content::mixed; + + if (c.inherits_p ()) + { + Type& base (c.inherits ().base ()); + + if (Complex* cb = dynamic_cast (&base)) + return content (*cb); + + if (base.is_a ()) + return Content::complex; + + // Everyhting else (built-in type and AnySimpleType) is simple + // content. + // + return Content::simple; + } + else + return Content::complex; + } + + bool Context:: anonymous (SemanticGraph::Type& t) { return t.context ().count ("anonymous"); @@ -180,12 +162,6 @@ namespace CXX return m.context ().get ("member"); } - String const& Context:: - emember_cache (SemanticGraph::Member& m) - { - return m.context ().get ("member-cache"); - } - String const& Context:: emember_map (SemanticGraph::Member& m) { @@ -200,20 +176,20 @@ namespace CXX // Includes // - Void TypeForward:: + void TypeForward:: traverse (SemanticGraph::Type& t) { os << "class " << t.context ().get (name_key_) << ";"; } - Void Includes:: + void Includes:: traverse_ (SemanticGraph::Uses& u) { // Support for weak (forward) inclusion used in the file-per-type // compilation model. // SemanticGraph::Schema& s (u.schema ()); - Boolean weak (u.context ().count ("weak")); + bool weak (u.context ().count ("weak")); if (weak && (type_ == header || type_ == impl_header)) { @@ -233,6 +209,7 @@ namespace CXX s.context ().count ("renamed") ? s.context ().get ("renamed") : u.path ()); + path.normalize (); // Try to use the portable representation of the path. If that // fails, fall back to the native representation. @@ -240,15 +217,11 @@ namespace CXX NarrowString path_str; try { - path_str = path.string (); + path_str = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - path_str = path.native_file_string (); -#else path_str = path.string (); -#endif } String inc_path; @@ -258,12 +231,12 @@ namespace CXX case header: case source: { - inc_path = ctx_.hxx_expr->merge (path_str); + inc_path = ctx_.hxx_expr->replace (path_str); break; } case impl_header: { - inc_path = ctx_.hxx_impl_expr->merge (path_str); + inc_path = ctx_.hxx_impl_expr->replace (path_str); break; } } diff --git a/xsd/xsd/cxx/parser/elements.hxx b/xsd/xsd/cxx/parser/elements.hxx index ee5ca86..31f5d87 100644 --- a/xsd/xsd/cxx/parser/elements.hxx +++ b/xsd/xsd/cxx/parser/elements.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/elements.hxx -// 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 #ifndef CXX_PARSER_ELEMENTS_HXX @@ -8,11 +7,13 @@ #include -#include +#include + +#include #include -#include +#include namespace CXX { @@ -33,13 +34,15 @@ namespace CXX class Context: public CXX::Context { public: - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; + + typedef Parser::options options_type; public: Context (std::wostream&, SemanticGraph::Schema&, SemanticGraph::Path const& path, - CLI::Options const&, + options_type const&, StringLiteralMap const*, Regex const* hxx_expr, Regex const* ixx_expr, @@ -50,7 +53,7 @@ namespace CXX Context (Context& c, std::wostream& o); public: - Boolean + bool restriction_p (SemanticGraph::Complex& c) const { if (c.inherits_p () && @@ -69,7 +72,7 @@ namespace CXX content (SemanticGraph::Complex&); public: - static Boolean + static bool anonymous (SemanticGraph::Type&); public: @@ -89,9 +92,6 @@ namespace CXX static String const& emember (SemanticGraph::Member&); - static String const& - emember_cache (SemanticGraph::Member&); - static String const& emember_map (SemanticGraph::Member&); @@ -100,7 +100,7 @@ namespace CXX eimpl (SemanticGraph::Type&); public: - CLI::Options const& options; + options_type const& options; String& xml_parser; String& simple_base; String& complex_base; @@ -109,8 +109,8 @@ namespace CXX String& cerr_inst; String& parser_map; String& std_string_type; - Boolean& validation; - Boolean& polymorphic; + bool& validation; + bool& polymorphic; Regex const* hxx_expr; Regex const* ixx_expr; @@ -125,20 +125,20 @@ namespace CXX String cerr_inst_; String parser_map_; String std_string_type_; - Boolean validation_; - Boolean polymorphic_; + bool validation_; + bool polymorphic_; }; // // struct RequiredAttributeTest: Traversal::Attribute { - RequiredAttributeTest (Boolean& result) + RequiredAttributeTest (bool& result) : result_ (result) { } - virtual Void + virtual void traverse (Type& a) { if (!result_ && !a.optional_p ()) @@ -146,7 +146,7 @@ namespace CXX } private: - Boolean& result_; + bool& result_; }; // @@ -156,14 +156,14 @@ namespace CXX Traversal::Member, Context { - ParserParamDecl (Context& c, Boolean name_arg) + ParserParamDecl (Context& c, bool name_arg) : Context (c), first_ (true), name_arg_ (name_arg) { inherits_ >> *this; names_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -172,7 +172,7 @@ namespace CXX names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (!first_) @@ -188,7 +188,7 @@ namespace CXX os << " /* " << comment (l.name ()) << " item */"; } - virtual Void + virtual void traverse (SemanticGraph::Member& m) { if (skip (m)) return; @@ -210,8 +210,8 @@ namespace CXX Traversal::Inherits inherits_; Traversal::Names names_; - Boolean first_; - Boolean name_arg_; + bool first_; + bool name_arg_; }; @@ -219,16 +219,16 @@ namespace CXX // struct TypeForward: Traversal::Type, Context { - TypeForward (Context& c, Char const* name_key) + TypeForward (Context& c, char const* name_key) : Context (c), name_key_ (name_key) { } - virtual Void + virtual void traverse (SemanticGraph::Type& t); private: - Char const* name_key_; + char const* name_key_; }; struct Includes: Traversal::Imports, @@ -250,20 +250,20 @@ namespace CXX schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; } - virtual Void + virtual void traverse (SemanticGraph::Imports& i) { traverse_ (i); } - virtual Void + virtual void traverse (SemanticGraph::Includes& i) { traverse_ (i); } private: - Void + void traverse_ (SemanticGraph::Uses&); private: @@ -281,21 +281,23 @@ namespace CXX // struct RootElement: Traversal::Element { - RootElement (CLI::Options const& options, + typedef Parser::options options_type; + + RootElement (options_type const& options, SemanticGraph::Element*& element) : options_ (options), element_ (element) { } - virtual Void + virtual void traverse (Type& e) { - if (options_.value ()) + if (options_.root_element_first ()) { if (element_ == 0) element_ = &e; } - else if (String name = options_.value ()) + else if (String name = options_.root_element ()) { if (e.name () == name) element_ = &e; @@ -305,7 +307,7 @@ namespace CXX } private: - CLI::Options const& options_; + options_type const& options_; SemanticGraph::Element*& element_; }; } diff --git a/xsd/xsd/cxx/parser/generator.cxx b/xsd/xsd/cxx/parser/generator.cxx index b3aee76..e17986b 100644 --- a/xsd/xsd/cxx/parser/generator.cxx +++ b/xsd/xsd/cxx/parser/generator.cxx @@ -1,8 +1,19 @@ // file : xsd/cxx/parser/generator.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 +#include +#include + +#include + +#include +#include +#include + +#include + #include #include #include @@ -28,49 +39,28 @@ #include #include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include +#include #include "../../../libxsd/xsd/cxx/version.hxx" using std::endl; using std::wcerr; +using std::wcout; using namespace XSDFrontend::SemanticGraph; // // -typedef -boost::filesystem::wifstream -WideInputFileStream; - -typedef -boost::filesystem::wofstream -WideOutputFileStream; - -typedef -boost::filesystem::ifstream -NarrowInputFileStream; +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; +typedef std::ifstream NarrowInputFileStream; namespace CXX { namespace { - Char const copyright_gpl[] = - "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n" + char const copyright_gpl[] = + "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n" "//\n" "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" "// C++ data binding compiler.\n" @@ -103,8 +93,8 @@ namespace CXX "// in the accompanying FLOSSE file.\n" "//\n\n"; - Char const copyright_proprietary[] = - "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n" + char const copyright_proprietary[] = + "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n" "//\n" "// This program was generated by CodeSynthesis XSD, an XML Schema\n" "// to C++ data binding compiler, in the Proprietary License mode.\n" @@ -113,7 +103,7 @@ namespace CXX "// conditions.\n" "//\n\n"; - Char const copyright_impl[] = + char const copyright_impl[] = "// Not copyrighted - public domain.\n" "//\n" "// This sample parser implementation was generated by CodeSynthesis XSD,\n" @@ -122,442 +112,24 @@ namespace CXX "//\n\n"; } - namespace Parser - { - namespace CLI - { - extern Key type_map = "type-map"; - extern Key char_type = "char-type"; - extern Key char_encoding = "char-encoding"; - extern Key output_dir = "output-dir"; - extern Key xml_parser = "xml-parser"; - extern Key generate_inline = "generate-inline"; - extern Key generate_validation = "generate-validation"; - extern Key suppress_validation = "suppress-validation"; - extern Key generate_polymorphic = "generate-polymorphic"; - extern Key generate_noop_impl = "generate-noop-impl"; - extern Key generate_print_impl = "generate-print-impl"; - extern Key generate_test_driver = "generate-test-driver"; - extern Key force_overwrite = "force-overwrite"; - extern Key root_element_first = "root-element-first"; - extern Key root_element_last = "root-element-last"; - extern Key root_element = "root-element"; - extern Key generate_xml_schema = "generate-xml-schema"; - extern Key extern_xml_schema = "extern-xml-schema"; - extern Key skel_type_suffix = "skel-type-suffix"; - extern Key skel_file_suffix = "skel-file-suffix"; - extern Key impl_type_suffix = "impl-type-suffix"; - extern Key impl_file_suffix = "impl-file-suffix"; - extern Key namespace_map = "namespace-map"; - extern Key namespace_regex = "namespace-regex"; - extern Key namespace_regex_trace = "namespace-regex-trace"; - extern Key reserved_name = "reserved-name"; - extern Key include_with_brackets = "include-with-brackets"; - extern Key include_prefix = "include-prefix"; - extern Key include_regex = "include-regex"; - extern Key include_regex_trace = "include-regex-trace"; - extern Key guard_prefix = "guard-prefix"; - extern Key hxx_suffix = "hxx-suffix"; - extern Key ixx_suffix = "ixx-suffix"; - extern Key cxx_suffix = "cxx-suffix"; - extern Key hxx_regex = "hxx-regex"; - extern Key ixx_regex = "ixx-regex"; - extern Key cxx_regex = "cxx-regex"; - extern Key hxx_prologue = "hxx-prologue"; - extern Key ixx_prologue = "ixx-prologue"; - extern Key cxx_prologue = "cxx-prologue"; - extern Key prologue = "prologue"; - extern Key hxx_epilogue = "hxx-epilogue"; - extern Key ixx_epilogue = "ixx-epilogue"; - extern Key cxx_epilogue = "cxx-epilogue"; - extern Key epilogue = "epilogue"; - extern Key hxx_prologue_file = "hxx-prologue-file"; - extern Key ixx_prologue_file = "ixx-prologue-file"; - extern Key cxx_prologue_file = "cxx-prologue-file"; - extern Key prologue_file = "prologue-file"; - extern Key hxx_epilogue_file = "hxx-epilogue-file"; - extern Key ixx_epilogue_file = "ixx-epilogue-file"; - extern Key cxx_epilogue_file = "cxx-epilogue-file"; - extern Key epilogue_file = "epilogue-file"; - extern Key export_symbol = "export-symbol"; - extern Key export_maps = "export-maps"; - extern Key import_maps = "import-maps"; - extern Key show_anonymous = "show-anonymous"; - extern Key show_sloc = "show-sloc"; - extern Key proprietary_license = "proprietary-license"; - } - } - - Void Parser::Generator:: + void Parser::Generator:: usage () { - std::wostream& e (wcerr); - ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e); - - e << "--type-map " << endl - << " Read XML Schema to C++ type mapping information\n" - << " from . Repeat this option to specify\n" - << " several type maps. Type maps are considered in\n" - << " order of appearance and the first match is used." - << endl; - - e << "--char-type " << endl - << " Use as the base character type. Valid\n" - << " values are 'char' (default) and 'wchar_t'." - << endl; - - e << "--char-encoding " << endl - << " Specify the character encoding that should be used\n" - << " in the object model. Valid values for the 'char'\n" - << " character type are 'utf8' (default), 'iso8859-1',\n" - << " 'lcp', and 'custom'. For the 'wchar_t' character\n" - << " type the only valid value is 'auto'." - << endl; - - e << "--output-dir " << endl - << " Write generated files to instead of current\n" - << " directory." - << endl; - - e << "--xml-parser " << endl - << " Use as the underlying XML parser. Valid\n" - << " values are 'xerces' (default) and 'expat'." - << endl; - - e << "--generate-inline" << endl - << " Generate certain functions inline." - << endl; - - e << "--generate-validation" << endl - << " Generate validation code." - << endl; - - e << "--suppress-validation" << endl - << " Suppress the generation of validation code." - << endl; - - e << "--generate-polymorphic" << endl - << " Generate polymorphism-aware code. Specify this\n" - << " option if you use substitution groups or xsi:type." - << endl; - - e << "--generate-noop-impl" << endl - << " Generate a sample parser implementation that\n" - << " does nothing (no operation)." - << endl; - - e << "--generate-print-impl" << endl - << " Generate a sample parser implementation that\n" - << " prints the XML data to STDOUT." - << endl; - - e << "--generate-test-driver" << endl - << " Generate a test driver for the sample parser\n" - << " implementation." - << endl; - - e << "--force-overwrite" << endl - << " Force overwriting of the existing implementation\n" - << " and test driver files." - << endl; - - e << "--root-element-first" << endl - << " Indicate that the first global element is the\n" - << " document root." - << endl; - - e << "--root-element-last" << endl - << " Indicate that the last global element is the\n" - << " document root." - << endl; - - e << "--root-element " << endl - << " Indicate that is the document root." - << endl; - - e << "--generate-xml-schema" << endl - << " Generate a C++ header file as if the schema being\n" - << " compiled defines the XML Schema namespace." - << endl; - - e << "--extern-xml-schema " << endl - << " Generate code as if the XML Schema namespace was\n" - << " defined in and xsd:included in the schema\n" - << " being compiled." - << endl; - - e << "--skel-type-suffix " << endl - << " Use instead of the default '_pskel' to\n" - << " construct the names of generated parser skeletons." - << endl; - - e << "--skel-file-suffix " << endl - << " Use instead of the default '-pskel' to\n" - << " construct the names of generated parser skeleton\n" - << " files." - << endl; - - e << "--impl-type-suffix " << endl - << " Use instead of the default '_pimpl' to\n" - << " construct the names of parser implementations for\n" - << " the built-in XML Schema types and sample parser\n" - << " implementations." - << endl; - - e << "--impl-file-suffix " << endl - << " Use instead of the default '-pimpl' to\n" - << " construct the names of generated sample parser\n" - << " implementation files." - << endl; - - e << "--namespace-map =" << endl - << " Map XML Schema namespace to C++ namespace\n" - << " . Repeat this option to specify mapping for\n" - << " more than one XML Schema namespace." - << endl; - - e << "--namespace-regex " << endl - << " Add to the list of regular expressions\n" - << " used to translate XML Schema namespace names to\n" - << " C++ namespace names." - << endl; - - e << "--namespace-regex-trace" << endl - << " Trace the process of applying regular expressions\n" - << " specified with the --namespace-regex option." - << endl; - - e << "--reserved-name " << endl - << " Add to the list of names that should not\n" - << " be used as identifiers. The name can optionally\n" - << " be followed by '=' and the replacement name that\n" - << " should be used instead." - << endl; - - e << "--include-with-brackets" << endl - << " Use angle brackets (<>) instead of quotes (\"\") in\n" - << " generated #include directives." - << endl; - - e << "--include-prefix " << endl - << " Add to generated #include directive\n" - << " paths." - << endl; - - e << "--include-regex " << endl - << " Add to the list of regular expressions\n" - << " used to transform #include directive paths." - << endl; - - e << "--include-regex-trace" << endl - << " Trace the process of applying regular expressions\n" - << " specified with the --include-regex option." - << endl; - - e << "--guard-prefix " << endl - << " Add to generated header inclusion guards." - << endl; - - e << "--hxx-suffix " << endl - << " Use instead of the default '.hxx' to\n" - << " construct the name of the header file." - << endl; - - e << "--ixx-suffix " << endl - << " Use instead of the default '.ixx' to\n" - << " construct the name of the inline file." - << endl; - - e << "--cxx-suffix " << endl - << " Use instead of the default '.cxx' to\n" - << " construct the name of the source file." - << endl; - - e << "--hxx-regex " << endl - << " Use to construct the name of the header\n" - << " file." - << endl; - - e << "--ixx-regex " << endl - << " Use to construct the name of the inline\n" - << " file." - << endl; - - e << "--cxx-regex " << endl - << " Use to construct the name of the source\n" - << " file." - << endl; - - - // Prologues. - // - e << "--hxx-prologue " << endl - << " Insert at the beginning of the header file." - << endl; - - e << "--ixx-prologue " << endl - << " Insert at the beginning of the inline file." - << endl; - - e << "--cxx-prologue " << endl - << " Insert at the beginning of the source file." - << endl; - - e << "--prologue " << endl - << " Insert at the beginning of each generated\n" - << " file for which there is no file-specific prologue." - << endl; - - - // Epilogues. - // - e << "--hxx-epilogue " << endl - << " Insert at the end of the header file." - << endl; - - e << "--ixx-epilogue " << endl - << " Insert at the end of the inline file." - << endl; - - e << "--cxx-epilogue " << endl - << " Insert at the end of the source file." - << endl; - - e << "--epilogue " << endl - << " Insert at the end of each generated file\n" - << " for which there is no file-specific epilogue." - << endl; - - - // Prologue files. - // - e << "--hxx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the header file." - << endl; - - e << "--ixx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the inline file." - << endl; - - e << "--cxx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the source file." - << endl; - - e << "--prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of each generated file for which there is no file-\n" - << " specific prologue file." - << endl; - - - // Epilogue files. - // - e << "--hxx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the header file." - << endl; - - e << "--ixx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the inline file." - << endl; - - e << "--cxx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the source file." - << endl; - - e << "--epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " each generated file for which there is no file-\n" - << " specific epilogue file." - << endl; - - - // Misc. - // - e << "--custom-literals " << endl - << " Load custom XML string to C++ literal mappings\n" - << " from ." - << endl; - - e << "--export-symbol " << endl - << " Export symbol for Win32 DLL export/import control." - << endl; - - e << "--export-maps" << endl - << " Export polymorphism support maps from Win32 DLL." - << endl; - - e << "--import-maps" << endl - << " Import polymorphism support maps from Win32 DLL." - << endl; - - e << "--show-anonymous" << endl - << " Show elements and attributes that are of anonymous\n" - << " types." - << endl; - - e << "--show-sloc" << endl - << " Show the number of generated physical source lines\n" - << " of code (SLOC)." - << endl; - - e << "--sloc-limit " << endl - << " Check that the number of generated physical source\n" - << " lines of code (SLOC) does not exceed ." - << endl; - - e << "--options-file " << endl - << " Read additional options from . Each option\n" - << " should appear on a separate line optionally\n" - << " followed by space and an argument." - << endl; - - e << "--proprietary-license" << endl - << " Indicate that the generated code is licensed under\n" - << " a proprietary license instead of the GPL." - << endl; + CXX::Parser::options::print_usage (wcout); + CXX::options::print_usage (wcout); } - Parser::CLI::OptionsSpec Parser::Generator:: - options_spec () - { - CLI::OptionsSpec spec; - - spec.option ().default_value ("char"); - spec.option ().default_value ("xerces"); - - spec.option ().default_value ("-pskel"); - spec.option ().default_value ("_pskel"); - spec.option ().default_value ("-pimpl"); - spec.option ().default_value ("_pimpl"); - - spec.option ().default_value (".hxx"); - spec.option ().default_value (".ixx"); - spec.option ().default_value (".cxx"); - - return spec; - } - - namespace { template - Void + void open (S& ifs, NarrowString const& path) { try { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - Path fs_path (path, boost::filesystem::native); -#else - Path fs_path (path.c_str()); -#endif - ifs.open (fs_path, std::ios_base::in | std::ios_base::binary); + Path fs_path (path); + ifs.open (fs_path.string ().c_str (), + std::ios_base::in | std::ios_base::binary); if (!ifs.is_open ()) { @@ -576,7 +148,7 @@ namespace CXX } } - Void + void append (WideOutputFileStream& os, NarrowString const& path, WideInputFileStream& default_is) @@ -596,16 +168,15 @@ namespace CXX } } - Void + void append (WideOutputFileStream& os, - Cult::Containers::Vector const& primary, - Cult::Containers::Vector const& def) + NarrowStrings const& primary, + NarrowStrings const& def) { - Cult::Containers::Vector const& v ( - primary.empty () ? def : primary); + NarrowStrings const& v (primary.empty () ? def : primary); - for (Containers::Vector::ConstIterator - i (v.begin ()), e (v.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); + i != e; ++i) { os << i->c_str () << endl; } @@ -613,25 +184,24 @@ namespace CXX } - UnsignedLong Parser::Generator:: - generate (Parser::CLI::Options const& ops, + size_t Parser::Generator:: + generate (Parser::options const& ops, Schema& schema, Path const& file_path, - Boolean fpt, + bool fpt, StringLiteralMap const& string_literal_map, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings, FileList& file_list, AutoUnlinks& unlinks) { using std::ios_base; - namespace Indentation = BackendElements::Indentation; - typedef BackendElements::Regex::Expression Regex; + typedef cutl::re::regexsub Regex; try { - Boolean generate_xml_schema (ops.value ()); + bool generate_xml_schema (ops.generate_xml_schema ()); // We could be compiling several schemas at once in which case // handling of the --generate-xml-schema option gets tricky: we @@ -640,23 +210,19 @@ namespace CXX // if (generate_xml_schema) { - if (NarrowString name = ops.value ()) + if (NarrowString name = ops.extern_xml_schema ()) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - if (file_path.native_file_string () != name) -#else if (file_path.string () != name) -#endif generate_xml_schema = false; } } - Boolean impl (!generate_xml_schema && - (ops.value () || - ops.value ())); + bool impl (!generate_xml_schema && + (ops.generate_noop_impl () || + ops.generate_print_impl ())); - Boolean driver (gen_driver && !generate_xml_schema && - ops.value ()); + bool driver (gen_driver && !generate_xml_schema && + ops.generate_test_driver ()); // Evaluate the graph for possibility of generating something useful. // @@ -674,9 +240,9 @@ namespace CXX proc.process (ops, schema, file_path, string_literal_map); } - Boolean validation ((ops.value () == "expat" || - ops.value ()) && - !ops.value ()); + bool validation ((ops.xml_parser () == "expat" || + ops.generate_validation ()) && + !ops.suppress_validation ()); // Compute state machine info. // @@ -691,11 +257,11 @@ namespace CXX TypeMap::Namespaces type_map; { using namespace TypeMap; - typedef Containers::Vector Files; - Files const& files (ops.value ()); + NarrowStrings const& files (ops.type_map ()); - for (Files::ConstIterator f (files.begin ()); f != files.end (); ++f ) + for (NarrowStrings::const_iterator f (files.begin ()); + f != files.end (); ++f ) { NarrowInputFileStream ifs; open (ifs, *f); @@ -712,7 +278,7 @@ namespace CXX // String-based types. // - String char_type (ops.value ()); + String char_type (ops.char_type ()); String string_type; if (char_type == L"char") @@ -723,12 +289,14 @@ namespace CXX string_type = L"::std::basic_string< " + char_type + L" >"; String xns; + String auto_ptr; { Context ctx (std::wcerr, schema, file_path, ops, 0, 0, 0, 0); xns = ctx.xs_ns_name (); + auto_ptr = ctx.auto_ptr; } - String buffer (L"::std::auto_ptr< " + xns + L"::buffer >"); + String buffer (auto_ptr + L"< " + xns + L"::buffer >"); TypeMap::Namespace xsd ("http://www\\.w3\\.org/2001/XMLSchema"); xsd.types_push_back ("string", string_type); @@ -800,7 +368,7 @@ namespace CXX type_map.push_back (xsd); - // Everyhting else maps to void. + // Everything else maps to void. // TypeMap::Namespace rest (".*"); rest.types_push_back (".*", "void", "void"); @@ -816,39 +384,33 @@ namespace CXX // // - Boolean inline_ (ops.value () && - !generate_xml_schema); - - Boolean source (!generate_xml_schema); + bool inline_ (ops.generate_inline () && !generate_xml_schema); + bool source (!generate_xml_schema); // Generate code. // -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - NarrowString name (file_path.leaf ()); -#else - NarrowString name (file_path.filename().string()); -#endif - NarrowString skel_suffix (ops.value ()); - NarrowString impl_suffix (ops.value ()); - - NarrowString hxx_suffix (ops.value ()); - NarrowString ixx_suffix (ops.value ()); - NarrowString cxx_suffix (ops.value ()); + NarrowString name (file_path.leaf ().string ()); + NarrowString skel_suffix (ops.skel_file_suffix ()); + NarrowString impl_suffix (ops.impl_file_suffix ()); + + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString ixx_suffix (ops.ixx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); Regex hxx_expr ( - ops.value ().empty () + ops.hxx_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + hxx_suffix + "#" - : ops.value ()); + : ops.hxx_regex ()); Regex ixx_expr ( - ops.value ().empty () + ops.ixx_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + ixx_suffix + "#" - : ops.value ()); + : ops.ixx_regex ()); Regex cxx_expr ( - ops.value ().empty () + ops.cxx_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + cxx_suffix + "#" - : ops.value ()); + : ops.cxx_regex ()); Regex hxx_impl_expr; @@ -870,7 +432,7 @@ namespace CXX if (!hxx_expr.match (name)) { wcerr << "error: header expression '" << - hxx_expr.pattern () << "' does not match '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -878,7 +440,7 @@ namespace CXX if (inline_ && !ixx_expr.match (name)) { wcerr << "error: inline expression '" << - ixx_expr.pattern () << "' does not match '" << + ixx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -886,7 +448,7 @@ namespace CXX if (source && !cxx_expr.match (name)) { wcerr << "error: source expression '" << - cxx_expr.pattern () << "' does not match '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -896,7 +458,7 @@ namespace CXX if (!hxx_impl_expr.match (name)) { wcerr << "error: implementation header expression '" << - hxx_impl_expr.pattern () << "' does not match '" << + hxx_impl_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -904,7 +466,7 @@ namespace CXX if (!cxx_impl_expr.match (name)) { wcerr << "error: implementation source expression '" << - cxx_impl_expr.pattern () << "' does not match '" << + cxx_impl_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -912,15 +474,15 @@ namespace CXX if (!cxx_driver_expr.match (name)) { wcerr << "error: driver source expression '" << - cxx_driver_expr.pattern () << "' does not match '" << + cxx_driver_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } } - NarrowString hxx_name (hxx_expr.merge (name)); - NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ()); - NarrowString cxx_name (source ? cxx_expr.merge (name) : NarrowString ()); + NarrowString hxx_name (hxx_expr.replace (name)); + NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); + NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ()); NarrowString hxx_impl_name; NarrowString cxx_impl_name; @@ -928,20 +490,14 @@ namespace CXX if (impl || driver) { - hxx_impl_name = hxx_impl_expr.merge (name); - cxx_impl_name = cxx_impl_expr.merge (name); - cxx_driver_name = cxx_driver_expr.merge (name); + hxx_impl_name = hxx_impl_expr.replace (name); + cxx_impl_name = cxx_impl_expr.replace (name); + cxx_driver_name = cxx_driver_expr.replace (name); } -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - Path hxx_path (hxx_name, boost::filesystem::native); - Path ixx_path (ixx_name, boost::filesystem::native); - Path cxx_path (cxx_name, boost::filesystem::native); -#else - Path hxx_path (hxx_name.c_str()); - Path ixx_path (ixx_name.c_str()); - Path cxx_path (cxx_name.c_str()); -#endif + Path hxx_path (hxx_name); + Path ixx_path (ixx_name); + Path cxx_path (cxx_name); Path hxx_impl_path; Path cxx_impl_path; @@ -949,28 +505,18 @@ namespace CXX if (impl || driver) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - hxx_impl_path = Path (hxx_impl_name, boost::filesystem::native); - cxx_impl_path = Path (cxx_impl_name, boost::filesystem::native); - cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native); -#else - hxx_impl_path = Path (hxx_impl_name.c_str()); - cxx_impl_path = Path (cxx_impl_name.c_str()); - cxx_driver_path = Path (cxx_driver_name.c_str()); -#endif + hxx_impl_path = Path (hxx_impl_name); + cxx_impl_path = Path (cxx_impl_name); + cxx_driver_path = Path (cxx_driver_name); } Path out_dir; - if (NarrowString dir = ops.value ()) + if (NarrowString dir = ops.output_dir ()) { try { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - out_dir = Path (dir, boost::filesystem::native); -#else - out_dir = Path (dir.c_str()); -#endif + out_dir = Path (dir); } catch (InvalidPath const&) { @@ -985,7 +531,7 @@ namespace CXX // unless the user added the directory so that we propagate this // to the output files. // - Path fpt_dir (file_path.branch_path ()); + Path fpt_dir (file_path.directory ()); if (!fpt_dir.empty ()) out_dir /= fpt_dir; @@ -1014,9 +560,10 @@ namespace CXX if (impl) { - if (!ops.value ()) + if (!ops.force_overwrite ()) { - WideInputFileStream tmp (hxx_impl_path, ios_base::in); + WideInputFileStream tmp ( + hxx_impl_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -1028,7 +575,7 @@ namespace CXX tmp.close (); } - hxx_impl.open (hxx_impl_path, ios_base::out); + hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); if (!hxx_impl.is_open ()) { @@ -1038,15 +585,12 @@ namespace CXX } unlinks.add (hxx_impl_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (hxx_impl_path.native_file_string ()); -#else file_list.push_back (hxx_impl_path.string ()); -#endif - if (!ops.value ()) + if (!ops.force_overwrite ()) { - WideInputFileStream tmp (cxx_impl_path, ios_base::in); + WideInputFileStream tmp ( + cxx_impl_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -1058,7 +602,7 @@ namespace CXX tmp.close (); } - cxx_impl.open (cxx_impl_path, ios_base::out); + cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); if (!cxx_impl.is_open ()) { @@ -1068,18 +612,15 @@ namespace CXX } unlinks.add (cxx_impl_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (cxx_impl_path.native_file_string ()); -#else file_list.push_back (cxx_impl_path.string ()); -#endif } if (driver) { - if (!ops.value ()) + if (!ops.force_overwrite ()) { - WideInputFileStream tmp (cxx_driver_path, ios_base::in); + WideInputFileStream tmp ( + cxx_driver_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -1091,7 +632,7 @@ namespace CXX tmp.close (); } - cxx_driver.open (cxx_driver_path, ios_base::out); + cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); if (!cxx_driver.is_open ()) { @@ -1101,16 +642,12 @@ namespace CXX } unlinks.add (cxx_driver_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (cxx_driver_path.native_file_string ()); -#else file_list.push_back (cxx_driver_path.string ()); -#endif } // Open the skel files. // - WideOutputFileStream hxx (hxx_path, ios_base::out); + WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out); WideOutputFileStream ixx; WideOutputFileStream cxx; @@ -1121,15 +658,11 @@ namespace CXX } unlinks.add (hxx_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (hxx_path.native_file_string ()); -#else file_list.push_back (hxx_path.string ()); -#endif if (inline_) { - ixx.open (ixx_path, ios_base::out); + ixx.open (ixx_path.string ().c_str (), ios_base::out); if (!ixx.is_open ()) { @@ -1138,17 +671,13 @@ namespace CXX } unlinks.add (ixx_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (ixx_path.native_file_string ()); -#else file_list.push_back (ixx_path.string ()); -#endif } if (source) { - cxx.open (cxx_path, ios_base::out); + cxx.open (cxx_path.string ().c_str (), ios_base::out); if (!cxx.is_open ()) { @@ -1157,19 +686,13 @@ namespace CXX } unlinks.add (cxx_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (cxx_path.native_file_string ()); -#else file_list.push_back (cxx_path.string ()); -#endif } // Print copyright and license. // - Char const* copyright ( - ops.value () - ? copyright_proprietary - : copyright_gpl); + char const* copyright ( + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); hxx << copyright; @@ -1192,7 +715,7 @@ namespace CXX // WideInputFileStream prologue; { - NarrowString name (ops.value ()); + NarrowString name (ops.prologue_file ()); if (name) open (prologue, name); @@ -1202,7 +725,7 @@ namespace CXX // WideInputFileStream epilogue; { - NarrowString name (ops.value ()); + NarrowString name (ops.epilogue_file ()); if (name) open (epilogue, name); @@ -1210,21 +733,25 @@ namespace CXX // SLOC counter. // - UnsignedLong sloc (0); - Boolean show_sloc (ops.value ()); + size_t sloc_total (0); + bool show_sloc (ops.show_sloc ()); + + typedef + compiler::ostream_filter + ind_filter; + + typedef + compiler::ostream_filter + sloc_filter; // // Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. - NarrowString guard_prefix (ops.value ()); + NarrowString guard_prefix (ops.guard_prefix ()); if (!guard_prefix) -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - guard_prefix = file_path.branch_path ().native_directory_string (); -#else - guard_prefix = file_path.branch_path ().string (); -#endif + guard_prefix = file_path.directory ().string (); if (guard_prefix) guard_prefix += '_'; @@ -1241,9 +768,9 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip hxx_sloc (hxx); + sloc_filter sloc (hxx); - String guard (guard_expr.merge (guard_prefix + hxx_name)); + String guard (guard_expr.replace (guard_prefix + hxx_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1251,14 +778,21 @@ namespace CXX << "#define " << guard << endl << endl; + if (ctx.std >= cxx_version::cxx11) + { + hxx << "#ifndef XSD_CXX11" << endl + << "#define XSD_CXX11" << endl + << "#endif" << endl + << endl; + } + // Copy prologue. // hxx << "// Begin prologue." << endl << "//" << endl; - append ( - hxx, ops.value (), ops.value ()); - append (hxx, ops.value (), prologue); + append (hxx, ops.hxx_prologue (), ops.prologue ()); + append (hxx, ops.hxx_prologue_file (), prologue); hxx << "//" << endl << "// End prologue." << endl @@ -1273,38 +807,33 @@ namespace CXX << "#endif" << endl << endl; - { - hxx << "#include " << endl - << endl; - - // Set auto-indentation. - // - Indentation::Clip hxx_clip (hxx); + hxx << "#include " << endl + << endl; + // Generate. + // + { + ind_filter ind (hxx); // We don't want to indent prologues/epilogues. - // Generate. - // if (!generate_xml_schema) generate_parser_forward (ctx); generate_parser_header (ctx, generate_xml_schema); + } + if (inline_) + hxx << "#include " << ctx.process_include_path (ixx_name) << endl; - if (inline_) - hxx << "#include " << ctx.process_include_path (ixx_name) << endl; - - hxx << "#include " << endl - << endl; - } + hxx << "#include " << endl + << endl; // Copy epilogue. // hxx << "// Begin epilogue." << endl << "//" << endl; - append (hxx, ops.value (), epilogue); - append ( - hxx, ops.value (), ops.value ()); + append (hxx, ops.hxx_epilogue_file (), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue ()); hxx << "//" << endl << "// End epilogue." << endl @@ -1313,12 +842,9 @@ namespace CXX hxx << "#endif // " << guard << endl; if (show_sloc) - { - wcerr << hxx_path << ": " - << hxx_sloc.buffer ().count () << endl; + wcerr << hxx_path << ": " << sloc.stream ().count () << endl; - sloc += hxx_sloc.buffer ().count (); - } + sloc_total += sloc.stream ().count (); } @@ -1335,30 +861,24 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip ixx_sloc (ixx); - + sloc_filter sloc (ixx); // Copy prologue. // ixx << "// Begin prologue." << endl << "//" << endl; - append ( - ixx, ops.value (), ops.value ()); - append (ixx, ops.value (), prologue); + append (ixx, ops.ixx_prologue (), ops.prologue ()); + append (ixx, ops.ixx_prologue_file (), prologue); ixx << "//" << endl << "// End prologue." << endl << endl; + // Generate. + // { - // Set auto-indentation. - // - Indentation::Clip ixx_clip (ixx); - - - // Generate. - // + ind_filter ind (ixx); // We don't want to indent prologues/epilogues. generate_parser_inline (ctx); } @@ -1367,21 +887,17 @@ namespace CXX ixx << "// Begin epilogue." << endl << "//" << endl; - append (ixx, ops.value (), epilogue); - append ( - ixx, ops.value (), ops.value ()); + append (ixx, ops.ixx_epilogue_file (), epilogue); + append (ixx, ops.ixx_epilogue (), ops.epilogue ()); ixx << "//" << endl << "// End epilogue." << endl << endl; if (show_sloc) - { - wcerr << ixx_path << ": " - << ixx_sloc.buffer ().count () << endl; + wcerr << ixx_path << ": " << sloc.stream ().count () << endl; - sloc += ixx_sloc.buffer ().count (); - } + sloc_total += sloc.stream ().count (); } @@ -1398,28 +914,30 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip cxx_sloc (cxx); + sloc_filter sloc (cxx); // Copy prologue. // cxx << "// Begin prologue." << endl << "//" << endl; - append ( - cxx, ops.value (), ops.value ()); - append (cxx, ops.value (), prologue); + append (cxx, ops.cxx_prologue (), ops.prologue ()); + append (cxx, ops.cxx_prologue_file (), prologue); cxx << "//" << endl << "// End prologue." << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip cxx_clip (cxx); + cxx << "#include " << endl + << endl; - cxx << "#include " << ctx.process_include_path (hxx_name) << endl - << endl; + cxx << "#include " << ctx.process_include_path (hxx_name) << endl + << endl; + + // Generate. + // + { + ind_filter ind (cxx); // We don't want to indent prologues/epilogues. if (!inline_) generate_parser_inline (ctx); @@ -1434,26 +952,25 @@ namespace CXX } } + cxx << "#include " << endl + << endl; + // Copy epilogue. // cxx << "// Begin epilogue." << endl << "//" << endl; - append (cxx, ops.value (), epilogue); - append ( - cxx, ops.value (), ops.value ()); + append (cxx, ops.cxx_epilogue_file (), epilogue); + append (cxx, ops.cxx_epilogue (), ops.epilogue ()); cxx << "//" << endl << "// End epilogue." << endl << endl; if (show_sloc) - { - wcerr << cxx_path << ": " - << cxx_sloc.buffer ().count () << endl; + wcerr << cxx_path << ": " << sloc.stream ().count () << endl; - sloc += cxx_sloc.buffer ().count (); - } + sloc_total += sloc.stream ().count (); } // HXX impl @@ -1469,7 +986,7 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - String guard (guard_expr.merge (guard_prefix + hxx_impl_name)); + String guard (guard_expr.replace (guard_prefix + hxx_impl_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1477,14 +994,11 @@ namespace CXX << "#define " << guard << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip clip (hxx_impl); - - hxx_impl << "#include " << ctx.process_include_path (hxx_name) - << endl << endl; + hxx_impl << "#include " << ctx.process_include_path (hxx_name) + << endl << endl; + { + ind_filter ind (hxx_impl); generate_impl_header (ctx); } @@ -1504,14 +1018,13 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - // Set auto-indentation. - // - Indentation::Clip clip (cxx_impl); - cxx_impl << "#include " << ctx.process_include_path (hxx_impl_name) << endl << endl; - generate_impl_source (ctx); + { + ind_filter ind (cxx_impl); + generate_impl_source (ctx); + } } // CXX driver @@ -1527,17 +1040,16 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - // Set auto-indentation. - // - Indentation::Clip clip (cxx_driver); - cxx_driver << "#include " << ctx.process_include_path (hxx_impl_name) << endl << endl; - generate_driver_source (ctx); + { + ind_filter ind (cxx_driver); + generate_driver_source (ctx); + } } - return sloc; + return sloc_total; } catch (UnrepresentableCharacter const& e) { @@ -1569,18 +1081,18 @@ namespace CXX throw Failed (); } - catch (BackendElements::Regex::Format const& e) + catch (cutl::re::format const& e) { wcerr << "error: invalid regex: '" << - e.expression ().c_str () << "': " << + e.regex ().c_str () << "': " << e.description ().c_str () << endl; throw Failed (); } - catch (BackendElements::Regex::Format const& e) + catch (cutl::re::wformat const& e) { wcerr << "error: invalid regex: '" << - e.expression () << "': " << e.description () << endl; + e.regex () << "': " << e.description ().c_str () << endl; throw Failed (); } diff --git a/xsd/xsd/cxx/parser/generator.hxx b/xsd/xsd/cxx/parser/generator.hxx index eaa1ecd..784ca9d 100644 --- a/xsd/xsd/cxx/parser/generator.hxx +++ b/xsd/xsd/cxx/parser/generator.hxx @@ -1,50 +1,38 @@ // file : xsd/cxx/parser/generator.hxx -// 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 #ifndef CXX_PARSER_GENERATOR_HXX #define CXX_PARSER_GENERATOR_HXX -#include - -#include - -#include -#include - #include // Path #include #include +#include #include -#include +#include namespace CXX { namespace Parser { - using namespace Cult::Types; - class Generator { public: - static Void + static void usage (); - static CLI::OptionsSpec - options_spec (); - struct Failed {}; - static UnsignedLong - generate (CLI::Options const& options, + static size_t + generate (options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, - Boolean file_per_type, + bool file_per_type, StringLiteralMap const&, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings, FileList& file_list, AutoUnlinks& unlinks); diff --git a/xsd/xsd/cxx/parser/impl-header.cxx b/xsd/xsd/cxx/parser/impl-header.cxx index ff635f1..a3d47a4 100644 --- a/xsd/xsd/cxx/parser/impl-header.cxx +++ b/xsd/xsd/cxx/parser/impl-header.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-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 @@ -21,7 +20,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (eimpl (e)); @@ -51,7 +50,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (eimpl (l)); @@ -98,7 +97,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (eimpl (u)); @@ -130,7 +129,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -161,7 +160,7 @@ namespace CXX names_parser_callback_ >> parser_callback_; } - virtual Void + virtual void traverse (Type& c) { String const& name (eimpl (c)); @@ -202,12 +201,12 @@ namespace CXX }; } - Void + void generate_impl_header (Context& ctx) { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Includes includes (ctx, Includes::impl_header); Traversal::Names schema_names; diff --git a/xsd/xsd/cxx/parser/impl-header.hxx b/xsd/xsd/cxx/parser/impl-header.hxx index dd63e52..273201b 100644 --- a/xsd/xsd/cxx/parser/impl-header.hxx +++ b/xsd/xsd/cxx/parser/impl-header.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-header.hxx -// 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 #ifndef CXX_PARSER_IMPL_HEADER_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_impl_header (Context&); } } diff --git a/xsd/xsd/cxx/parser/impl-source.cxx b/xsd/xsd/cxx/parser/impl-source.cxx index b951f6a..ad85f81 100644 --- a/xsd/xsd/cxx/parser/impl-source.cxx +++ b/xsd/xsd/cxx/parser/impl-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-source.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 @@ -22,7 +21,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (eimpl (e)); @@ -57,7 +56,7 @@ namespace CXX os << arg_type (base) << " v (" << post_name (base) << " ());" << endl; - if (options.value ()) + if (options.generate_print_impl ()) { PrintCall t (*this, e.name (), "v"); t.dispatch (base); @@ -91,7 +90,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (eimpl (l)); @@ -126,7 +125,7 @@ namespace CXX if (arg != L"void") { - if (options.value ()) + if (options.generate_print_impl ()) { PrintCall t (*this, type.name (), item); t.dispatch (type); @@ -164,7 +163,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (eimpl (u)); @@ -186,7 +185,7 @@ namespace CXX << "_characters (const " << string_type << "& s)" << "{"; - if (options.value ()) + if (options.generate_print_impl ()) os << cout_inst << " << " << strlit (u.name () + L": ") << " << s << std::endl;"; else @@ -221,7 +220,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -244,7 +243,7 @@ namespace CXX if (arg != L"void") { - if (options.value ()) + if (options.generate_print_impl ()) { PrintCall t (*this, m.name (), name); t.dispatch (m.type ()); @@ -268,12 +267,12 @@ namespace CXX names_parser_callback_ >> parser_callback_; } - virtual Void + virtual void traverse (Type& c) { String const& name (eimpl (c)); - Boolean restriction (restriction_p (c)); + bool restriction (restriction_p (c)); os << "// " << name << endl << "//" << endl @@ -314,7 +313,7 @@ namespace CXX os << arg_type (base) << " v (" << post_name (base) << " ());" << endl; - if (options.value ()) + if (options.generate_print_impl ()) { PrintCall t (*this, c.name (), "v"); t.dispatch (base); @@ -354,15 +353,15 @@ namespace CXX }; } - Void + void generate_impl_source (Context& ctx) { - if (ctx.options.value ()) + if (ctx.options.generate_print_impl ()) ctx.os << "#include " << endl << endl; Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); Traversal::Names names; diff --git a/xsd/xsd/cxx/parser/impl-source.hxx b/xsd/xsd/cxx/parser/impl-source.hxx index 0d60162..b6f9b3d 100644 --- a/xsd/xsd/cxx/parser/impl-source.hxx +++ b/xsd/xsd/cxx/parser/impl-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-source.hxx -// 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 #ifndef CXX_PARSER_IMPL_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_impl_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/name-processor.cxx b/xsd/xsd/cxx/parser/name-processor.cxx index d323187..219a3c9 100644 --- a/xsd/xsd/cxx/parser/name-processor.cxx +++ b/xsd/xsd/cxx/parser/name-processor.cxx @@ -1,66 +1,47 @@ // file : xsd/cxx/parser/name-processor.cxx -// author : Boris Kolpackov -// 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 +#include +#include +#include + #include #include #include -#include -#include -#include +using namespace std; namespace CXX { namespace Parser { - NameProcessor:: - NameProcessor () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - namespace { // // - typedef Cult::Containers::Set NameSet; + typedef set NameSet; class Context: public CXX::Context { public: - Context (CLI::Options const& ops, + Context (Parser::options const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path, StringLiteralMap const* map) - : CXX::Context (std::wcerr, - root, - path, - map, - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value ()), - skel_suffix_ (ops.value ()), - impl_suffix_ (ops.value ()), - impl (ops.value () || - ops.value () || - ops.value ()), + : CXX::Context (std::wcerr, root, path, ops, map), + skel_suffix_ (ops.skel_type_suffix ()), + impl_suffix_ (ops.impl_type_suffix ()), + impl (ops.generate_noop_impl () || + ops.generate_print_impl () || + ops.generate_test_driver ()), skel_suffix (skel_suffix_), impl_suffix (impl_suffix_), global_type_names (global_type_names_), - polymorphic (ops.value ()) + polymorphic (ops.generate_polymorphic ()) { } @@ -82,7 +63,7 @@ namespace CXX String base_name (escape (n)); 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; @@ -97,16 +78,16 @@ namespace CXX String const skel_suffix_; String const impl_suffix_; - Cult::Containers::Map global_type_names_; + map global_type_names_; public: - Boolean const impl; + bool const impl; String const& skel_suffix; String const& impl_suffix; - Cult::Containers::Map& global_type_names; + map& global_type_names; - Boolean polymorphic; + bool polymorphic; }; @@ -119,7 +100,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) @@ -139,7 +120,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) @@ -155,9 +136,6 @@ namespace CXX m.is_a () && !m.type ().context ().count ("anonymous")) { - m.context ().set ( - "member-cache", find_name (base + L"_parser_cache_", set_)); - m.context ().set ( "member-map", find_name (base + L"_parser_map_", set_)); @@ -245,7 +223,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) @@ -282,17 +260,17 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) return; - Boolean poly (polymorphic && + bool poly (polymorphic && m.is_a () && !m.type ().context ().count ("anonymous")); - String parser, member, member_cache, member_map, member_map_impl; + String parser, member, member_map, member_map_impl; try { @@ -306,7 +284,6 @@ namespace CXX if (poly) { - member_cache = bm.context ().get ("member-cache"); member_map = bm.context ().get ("member-map"); member_map_impl = bm.context ().get ("member-map-impl"); } @@ -322,7 +299,6 @@ namespace CXX if (poly) { - member_cache = find_name (base + L"_parser_cache_", set_); member_map = find_name (base + L"_parser_map_", set_); member_map_impl = find_name (base + L"_parser_map_impl_", set_); } @@ -333,7 +309,6 @@ namespace CXX if (poly) { - m.context ().set ("member-cache", member_cache); m.context ().set ("member-map", member_map); m.context ().set ("member-map-impl", member_map_impl); } @@ -349,7 +324,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { SemanticGraph::Context& cc (c.context ()); @@ -371,7 +346,7 @@ namespace CXX // inheriting by restriction in which case we need to have // the same names as our base. // - Boolean restriction (false); + bool restriction (false); if (c.inherits_p ()) { @@ -464,7 +439,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { SemanticGraph::Context& c (t.context ()); @@ -533,7 +508,7 @@ namespace CXX String base_name (escape (L"post_" + n)); String post (base_name); - for (UnsignedLong i (1); set.find (post) != set.end (); ++i) + for (size_t i (1); set.find (post) != set.end (); ++i) { std::wostringstream os; os << i; @@ -556,7 +531,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& ns) { NameSet& type_set (global_type_names[ns.name ()]); @@ -634,7 +609,7 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { t.context ().set ("name", make_skel_name ("any_type")); @@ -642,7 +617,7 @@ namespace CXX t.context ().set ("post", String ("post_any_type")); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { t.context ().set ("name", make_skel_name ("any_simple_type")); @@ -652,7 +627,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { t.context ().set ("name", make_skel_name ("boolean")); @@ -662,7 +637,7 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { t.context ().set ("name", make_skel_name ("byte")); @@ -670,7 +645,7 @@ namespace CXX t.context ().set ("post", String ("post_byte")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { t.context ().set ("name", make_skel_name ("unsigned_byte")); @@ -678,7 +653,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_byte")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { t.context ().set ("name", make_skel_name ("short")); @@ -686,7 +661,7 @@ namespace CXX t.context ().set ("post", String ("post_short")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { t.context ().set ("name", make_skel_name ("unsigned_short")); @@ -694,7 +669,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_short")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { t.context ().set ("name", make_skel_name ("int")); @@ -702,7 +677,7 @@ namespace CXX t.context ().set ("post", String ("post_int")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { t.context ().set ("name", make_skel_name ("unsigned_int")); @@ -710,7 +685,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_int")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { t.context ().set ("name", make_skel_name ("long")); @@ -718,7 +693,7 @@ namespace CXX t.context ().set ("post", String ("post_long")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { t.context ().set ("name", make_skel_name ("unsigned_long")); @@ -726,7 +701,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_long")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { t.context ().set ("name", make_skel_name ("integer")); @@ -734,7 +709,7 @@ namespace CXX t.context ().set ("post", String ("post_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { t.context ().set ("name", make_skel_name ("non_positive_integer")); @@ -742,7 +717,7 @@ namespace CXX t.context ().set ("post", String ("post_non_positive_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { t.context ().set ("name", make_skel_name ("non_negative_integer")); @@ -750,7 +725,7 @@ namespace CXX t.context ().set ("post", String ("post_non_negative_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { t.context ().set ("name", make_skel_name ("positive_integer")); @@ -758,7 +733,7 @@ namespace CXX t.context ().set ("post", String ("post_positive_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { t.context ().set ("name", make_skel_name ("negative_integer")); @@ -768,7 +743,7 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { t.context ().set ("name", make_skel_name ("float")); @@ -776,7 +751,7 @@ namespace CXX t.context ().set ("post", String ("post_float")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { t.context ().set ("name", make_skel_name ("double")); @@ -784,7 +759,7 @@ namespace CXX t.context ().set ("post", String ("post_double")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { t.context ().set ("name", make_skel_name ("decimal")); @@ -794,7 +769,7 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { t.context ().set ("name", make_skel_name ("string")); @@ -802,7 +777,7 @@ namespace CXX t.context ().set ("post", String ("post_string")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { t.context ().set ("name", make_skel_name ("normalized_string")); @@ -810,7 +785,7 @@ namespace CXX t.context ().set ("post", String ("post_normalized_string")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { t.context ().set ("name", make_skel_name ("token")); @@ -818,7 +793,7 @@ namespace CXX t.context ().set ("post", String ("post_token")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { t.context ().set ("name", make_skel_name ("nmtoken")); @@ -826,7 +801,7 @@ namespace CXX t.context ().set ("post", String ("post_nmtoken")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { t.context ().set ("name", make_skel_name ("nmtokens")); @@ -834,7 +809,7 @@ namespace CXX t.context ().set ("post", String ("post_nmtokens")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { t.context ().set ("name", make_skel_name ("name")); @@ -842,7 +817,7 @@ namespace CXX t.context ().set ("post", String ("post_name")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { t.context ().set ("name", make_skel_name ("ncname")); @@ -850,7 +825,7 @@ namespace CXX t.context ().set ("post", String ("post_ncname")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { t.context ().set ("name", make_skel_name ("language")); @@ -861,7 +836,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { t.context ().set ("name", make_skel_name ("qname")); @@ -872,7 +847,7 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { t.context ().set ("name", make_skel_name ("id")); @@ -880,7 +855,7 @@ namespace CXX t.context ().set ("post", String ("post_id")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { t.context ().set ("name", make_skel_name ("idref")); @@ -888,7 +863,7 @@ namespace CXX t.context ().set ("post", String ("post_idref")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { t.context ().set ("name", make_skel_name ("idrefs")); @@ -898,7 +873,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { t.context ().set ("name", make_skel_name ("uri")); @@ -908,7 +883,7 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { t.context ().set ("name", make_skel_name ("base64_binary")); @@ -916,7 +891,7 @@ namespace CXX t.context ().set ("post", String ("post_base64_binary")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { t.context ().set ("name", make_skel_name ("hex_binary")); @@ -927,7 +902,7 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { t.context ().set ("name", make_skel_name ("date")); @@ -935,7 +910,7 @@ namespace CXX t.context ().set ("post", String ("post_date")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { t.context ().set ("name", make_skel_name ("date_time")); @@ -943,7 +918,7 @@ namespace CXX t.context ().set ("post", String ("post_date_time")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { t.context ().set ("name", make_skel_name ("duration")); @@ -951,7 +926,7 @@ namespace CXX t.context ().set ("post", String ("post_duration")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { t.context ().set ("name", make_skel_name ("gday")); @@ -959,7 +934,7 @@ namespace CXX t.context ().set ("post", String ("post_gday")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { t.context ().set ("name", make_skel_name ("gmonth")); @@ -967,7 +942,7 @@ namespace CXX t.context ().set ("post", String ("post_gmonth")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { t.context ().set ("name", make_skel_name ("gmonth_day")); @@ -975,7 +950,7 @@ namespace CXX t.context ().set ("post", String ("post_gmonth_day")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { t.context ().set ("name", make_skel_name ("gyear")); @@ -983,7 +958,7 @@ namespace CXX t.context ().set ("post", String ("post_gyear")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { t.context ().set ("name", make_skel_name ("gyear_month")); @@ -991,7 +966,7 @@ namespace CXX t.context ().set ("post", String ("post_gyear_month")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { t.context ().set ("name", make_skel_name ("time")); @@ -1001,7 +976,7 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { t.context ().set ("name", make_skel_name ("entity")); @@ -1009,7 +984,7 @@ namespace CXX t.context ().set ("post", String ("post_entity")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { t.context ().set ("name", make_skel_name ("entities")); @@ -1038,7 +1013,7 @@ namespace CXX Traversal::Includes, Traversal::Imports { - virtual Void + virtual void traverse (SemanticGraph::Sources& sr) { SemanticGraph::Schema& s (sr.schema ()); @@ -1050,7 +1025,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Includes& i) { SemanticGraph::Schema& s (i.schema ()); @@ -1062,7 +1037,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Imports& i) { SemanticGraph::Schema& s (i.schema ()); @@ -1080,7 +1055,7 @@ namespace CXX // struct Implies: Traversal::Implies { - virtual Void + virtual void traverse (SemanticGraph::Implies& i) { SemanticGraph::Schema& s (i.schema ()); @@ -1093,8 +1068,8 @@ namespace CXX } }; - Void - process_impl (CLI::Options const& ops, + void + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, StringLiteralMap const& map) @@ -1169,7 +1144,7 @@ namespace CXX // { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; @@ -1189,8 +1164,8 @@ namespace CXX } } - Void NameProcessor:: - process (CLI::Options const& ops, + void NameProcessor:: + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, StringLiteralMap const& map) diff --git a/xsd/xsd/cxx/parser/name-processor.hxx b/xsd/xsd/cxx/parser/name-processor.hxx index 5c28371..0460ea4 100644 --- a/xsd/xsd/cxx/parser/name-processor.hxx +++ b/xsd/xsd/cxx/parser/name-processor.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/name-processor.hxx -// author : Boris Kolpackov -// 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 #ifndef CXX_PARSER_NAME_PROCESSOR_HXX @@ -8,22 +7,20 @@ #include +#include + #include -#include +#include namespace CXX { namespace Parser { - using namespace Cult::Types; - class NameProcessor { public: - NameProcessor (); // Dummy ctor, helps with long symbols on HP-UX. - - Void - process (CLI::Options const& ops, + void + process (options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, StringLiteralMap const& map); diff --git a/xsd/xsd/cxx/parser/options.cli b/xsd/xsd/cxx/parser/options.cli new file mode 100644 index 0000000..227bb51 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.cli @@ -0,0 +1,148 @@ +// file : xsd/cxx/parser/options.cli +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include ; // std::size_t + +include ; // NarrowString, NarrowStrings + +include ; + +namespace CXX +{ + namespace Parser + { + class options: CXX::options + { + NarrowStrings --type-map + { + "", + "Read XML Schema to C++ type mapping information from . + Repeat this option to specify several type maps. Type maps are + considered in order of appearance and the first match is used. By + default all user-defined types are mapped to \cb{void}. See the + TYPE MAP section below for more information." + }; + + NarrowString --xml-parser = "xerces" + { + "", + "Use as the underlying XML parser. Valid values are + \cb{xerces} for Xerces-C++ (default) and \cb{expat} for Expat." + }; + + // Features. + // + bool --generate-validation + { + "Generate validation code. The validation code (\"perfect parser\") + ensures that instance documents conform to the schema. Validation + code is generated by default when the selected underlying XML parser + is non-validating (\cb{expat})." + }; + + bool --suppress-validation + { + "Suppress the generation of validation code. Validation is suppressed + by default when the selected underlying XML parser is validating + (\cb{xerces})." + }; + + bool --generate-polymorphic + { + "Generate polymorphism-aware code. Specify this option if you use + substitution groups or \cb{xsi:type}." + }; + + bool --generate-noop-impl + { + "Generate a sample parser implementation that does nothing (no + operation). The sample implementation can then be filled with + the application-specific code. For an input file in the form + \cb{name.xsd} this option triggers the generation of two + additional C++ files in the form: \cb{name-pimpl.hxx} (parser + implementation header file) and \cb{name-pimpl.cxx} (parser + implementation source file)." + }; + + bool --generate-print-impl + { + "Generate a sample parser implementation that prints the XML data + to \c{STDOUT}. For an input file in the form \cb{name.xsd} this + option triggers the generation of two additional C++ files in the + form: \cb{name-pimpl.hxx} (parser implementation header file) and + \cb{name-pimpl.cxx} (parser implementation source file)." + }; + + bool --generate-test-driver + { + "Generate a test driver for the sample parser implementation. For an + input file in the form \cb{name.xsd} this option triggers the + generation of an additional C++ file in the form + \cb{name-driver.cxx}." + }; + + bool --force-overwrite + { + "Force overwriting of the existing implementation and test driver + files. Use this option only if you do not mind loosing the changes + you have made in the sample implementation or test driver files." + }; + + // Root element. + // + bool --root-element-first + { + "Indicate that the first global element is the document root. This + information is used to generate the test driver for the sample + implementation." + }; + + bool --root-element-last + { + "Indicate that the last global element is the document root. This + information is used to generate the test driver for the sample + implementation." + }; + + NarrowString --root-element + { + "", + "Indicate that is the document root. This information is + used to generate the test driver for the sample implementation." + }; + + // Suffixes. + // + NarrowString --skel-type-suffix = "_pskel" + { + "", + "Use the provided instead of the default \cb{_pskel} to + construct the names of the generated parser skeletons." + }; + + NarrowString --skel-file-suffix = "-pskel" + { + "", + "Use the provided instead of the default \cb{-pskel} to + construct the names of the generated parser skeleton files." + }; + + NarrowString --impl-type-suffix = "_pimpl" + { + "", + "Use the provided instead of the default \cb{_pimpl} to + construct the names of the parser implementations for the built-in + XML Schema types as well as sample parser implementations." + }; + + NarrowString --impl-file-suffix = "-pimpl" + { + "", + "Use the provided instead of the default \cb{-pimpl} to + construct the names of the generated sample parser implementation + files." + }; + }; + } +} diff --git a/xsd/xsd/cxx/parser/options.cxx b/xsd/xsd/cxx/parser/options.cxx new file mode 100644 index 0000000..6f18446 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.cxx @@ -0,0 +1,581 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +#include +// +// End prologue. + +#include + +#include +#include +#include +#include +#include +#include + +namespace cli +{ + template + struct parser + { + static void + parse (X& x, bool& xs, scanner& s) + { + std::string o (s.next ()); + + if (s.more ()) + { + std::string v (s.next ()); + std::istringstream is (v); + if (!(is >> x && is.eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + + xs = true; + } + }; + + template <> + struct parser + { + static void + parse (bool& x, scanner& s) + { + s.next (); + x = true; + } + }; + + template <> + struct parser + { + static void + parse (std::string& x, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + x = s.next (); + else + throw missing_value (o); + + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::vector& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.push_back (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::set& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.insert (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::map& m, bool& xs, scanner& s) + { + std::string o (s.next ()); + + if (s.more ()) + { + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + if (p == std::string::npos) + { + K k = K (); + + if (!ov.empty ()) + { + std::istringstream ks (ov); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + m[k] = V (); + } + else + { + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, p + 1); + + if (!kstr.empty ()) + { + std::istringstream ks (kstr); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + if (!vstr.empty ()) + { + std::istringstream vs (vstr); + + if (!(vs >> v && vs.eof ())) + throw invalid_value (o, ov); + } + + m[k] = v; + } + } + else + throw missing_value (o); + + xs = true; + } + }; + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, s); + } + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, x.*S, s); + } +} + +#include +#include + +namespace CXX +{ + namespace Parser + { + // options + // + + options:: + options () + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + } + + options:: + options (int& argc, + char** argv, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int start, + int& argc, + char** argv, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int& argc, + char** argv, + int& end, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (int start, + int& argc, + char** argv, + int& end, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (::cli::scanner& s, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + _parse (s, opt, arg); + } + + void options:: + print_usage (::std::wostream& os) + { + os << "--type-map Read XML Schema to C++ type mapping information" << ::std::endl + << " from ." << ::std::endl; + + os << "--xml-parser Use as the underlying XML parser." << ::std::endl; + + os << "--generate-validation Generate validation code." << ::std::endl; + + os << "--suppress-validation Suppress the generation of validation code." << ::std::endl; + + os << "--generate-polymorphic Generate polymorphism-aware code." << ::std::endl; + + os << "--generate-noop-impl Generate a sample parser implementation that does" << ::std::endl + << " nothing (no operation)." << ::std::endl; + + os << "--generate-print-impl Generate a sample parser implementation that" << ::std::endl + << " prints the XML data to 'STDOUT'." << ::std::endl; + + os << "--generate-test-driver Generate a test driver for the sample parser" << ::std::endl + << " implementation." << ::std::endl; + + os << "--force-overwrite Force overwriting of the existing implementation" << ::std::endl + << " and test driver files." << ::std::endl; + + os << "--root-element-first Indicate that the first global element is the" << ::std::endl + << " document root." << ::std::endl; + + os << "--root-element-last Indicate that the last global element is the" << ::std::endl + << " document root." << ::std::endl; + + os << "--root-element Indicate that is the document root." << ::std::endl; + + os << "--skel-type-suffix Use the provided instead of the default" << ::std::endl + << " '_pskel' to construct the names of the generated" << ::std::endl + << " parser skeletons." << ::std::endl; + + os << "--skel-file-suffix Use the provided instead of the default" << ::std::endl + << " '-pskel' to construct the names of the generated" << ::std::endl + << " parser skeleton files." << ::std::endl; + + os << "--impl-type-suffix Use the provided instead of the default" << ::std::endl + << " '_pimpl' to construct the names of the parser" << ::std::endl + << " implementations for the built-in XML Schema types" << ::std::endl + << " as well as sample parser implementations." << ::std::endl; + + os << "--impl-file-suffix Use the provided instead of the default" << ::std::endl + << " '-pimpl' to construct the names of the generated" << ::std::endl + << " sample parser implementation files." << ::std::endl; + } + + typedef + std::map + _cli_options_map; + + static _cli_options_map _cli_options_map_; + + struct _cli_options_map_init + { + _cli_options_map_init () + { + _cli_options_map_["--type-map"] = + &::cli::thunk< options, NarrowStrings, &options::type_map_, + &options::type_map_specified_ >; + _cli_options_map_["--xml-parser"] = + &::cli::thunk< options, NarrowString, &options::xml_parser_, + &options::xml_parser_specified_ >; + _cli_options_map_["--generate-validation"] = + &::cli::thunk< options, bool, &options::generate_validation_ >; + _cli_options_map_["--suppress-validation"] = + &::cli::thunk< options, bool, &options::suppress_validation_ >; + _cli_options_map_["--generate-polymorphic"] = + &::cli::thunk< options, bool, &options::generate_polymorphic_ >; + _cli_options_map_["--generate-noop-impl"] = + &::cli::thunk< options, bool, &options::generate_noop_impl_ >; + _cli_options_map_["--generate-print-impl"] = + &::cli::thunk< options, bool, &options::generate_print_impl_ >; + _cli_options_map_["--generate-test-driver"] = + &::cli::thunk< options, bool, &options::generate_test_driver_ >; + _cli_options_map_["--force-overwrite"] = + &::cli::thunk< options, bool, &options::force_overwrite_ >; + _cli_options_map_["--root-element-first"] = + &::cli::thunk< options, bool, &options::root_element_first_ >; + _cli_options_map_["--root-element-last"] = + &::cli::thunk< options, bool, &options::root_element_last_ >; + _cli_options_map_["--root-element"] = + &::cli::thunk< options, NarrowString, &options::root_element_, + &options::root_element_specified_ >; + _cli_options_map_["--skel-type-suffix"] = + &::cli::thunk< options, NarrowString, &options::skel_type_suffix_, + &options::skel_type_suffix_specified_ >; + _cli_options_map_["--skel-file-suffix"] = + &::cli::thunk< options, NarrowString, &options::skel_file_suffix_, + &options::skel_file_suffix_specified_ >; + _cli_options_map_["--impl-type-suffix"] = + &::cli::thunk< options, NarrowString, &options::impl_type_suffix_, + &options::impl_type_suffix_specified_ >; + _cli_options_map_["--impl-file-suffix"] = + &::cli::thunk< options, NarrowString, &options::impl_file_suffix_, + &options::impl_file_suffix_specified_ >; + } + }; + + static _cli_options_map_init _cli_options_map_init_; + + bool options:: + _parse (const char* o, ::cli::scanner& s) + { + _cli_options_map::const_iterator i (_cli_options_map_.find (o)); + + if (i != _cli_options_map_.end ()) + { + (*(i->second)) (*this, s); + return true; + } + + // options base + // + if (::CXX::options::_parse (o, s)) + return true; + + return false; + } + + void options:: + _parse (::cli::scanner& s, + ::cli::unknown_mode opt_mode, + ::cli::unknown_mode arg_mode) + { + bool opt = true; + + while (s.more ()) + { + const char* o = s.peek (); + + if (std::strcmp (o, "--") == 0) + { + s.skip (); + opt = false; + continue; + } + + if (opt && _parse (o, s)); + else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0') + { + switch (opt_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_option (o); + } + } + + break; + } + else + { + switch (arg_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_argument (o); + } + } + + break; + } + } + } + } +} + +// Begin epilogue. +// +// +// End epilogue. + diff --git a/xsd/xsd/cxx/parser/options.hxx b/xsd/xsd/cxx/parser/options.hxx new file mode 100644 index 0000000..976f93b --- /dev/null +++ b/xsd/xsd/cxx/parser/options.hxx @@ -0,0 +1,183 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef CXX_PARSER_OPTIONS_HXX +#define CXX_PARSER_OPTIONS_HXX + +// Begin prologue. +// +// +// End prologue. + +#include + +#include + +#include + +namespace CXX +{ + namespace Parser + { + class options: public ::CXX::options + { + public: + options (int& argc, + char** argv, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (int& argc, + char** argv, + int& end, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + int& end, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (::cli::scanner&, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (); + + // Option accessors. + // + const NarrowStrings& + type_map () const; + + bool + type_map_specified () const; + + const NarrowString& + xml_parser () const; + + bool + xml_parser_specified () const; + + const bool& + generate_validation () const; + + const bool& + suppress_validation () const; + + const bool& + generate_polymorphic () const; + + const bool& + generate_noop_impl () const; + + const bool& + generate_print_impl () const; + + const bool& + generate_test_driver () const; + + const bool& + force_overwrite () const; + + const bool& + root_element_first () const; + + const bool& + root_element_last () const; + + const NarrowString& + root_element () const; + + bool + root_element_specified () const; + + const NarrowString& + skel_type_suffix () const; + + bool + skel_type_suffix_specified () const; + + const NarrowString& + skel_file_suffix () const; + + bool + skel_file_suffix_specified () const; + + const NarrowString& + impl_type_suffix () const; + + bool + impl_type_suffix_specified () const; + + const NarrowString& + impl_file_suffix () const; + + bool + impl_file_suffix_specified () const; + + // Print usage information. + // + static void + print_usage (::std::wostream&); + + // Implementation details. + // + protected: + bool + _parse (const char*, ::cli::scanner&); + + private: + void + _parse (::cli::scanner&, + ::cli::unknown_mode option, + ::cli::unknown_mode argument); + + public: + NarrowStrings type_map_; + bool type_map_specified_; + NarrowString xml_parser_; + bool xml_parser_specified_; + bool generate_validation_; + bool suppress_validation_; + bool generate_polymorphic_; + bool generate_noop_impl_; + bool generate_print_impl_; + bool generate_test_driver_; + bool force_overwrite_; + bool root_element_first_; + bool root_element_last_; + NarrowString root_element_; + bool root_element_specified_; + NarrowString skel_type_suffix_; + bool skel_type_suffix_specified_; + NarrowString skel_file_suffix_; + bool skel_file_suffix_specified_; + NarrowString impl_type_suffix_; + bool impl_type_suffix_specified_; + NarrowString impl_file_suffix_; + bool impl_file_suffix_specified_; + }; + } +} + +#include + +// Begin epilogue. +// +// +// End epilogue. + +#endif // CXX_PARSER_OPTIONS_HXX diff --git a/xsd/xsd/cxx/parser/options.ixx b/xsd/xsd/cxx/parser/options.ixx new file mode 100644 index 0000000..22ab11d --- /dev/null +++ b/xsd/xsd/cxx/parser/options.ixx @@ -0,0 +1,160 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +namespace CXX +{ + namespace Parser + { + // options + // + + inline const NarrowStrings& options:: + type_map () const + { + return this->type_map_; + } + + inline bool options:: + type_map_specified () const + { + return this->type_map_specified_; + } + + inline const NarrowString& options:: + xml_parser () const + { + return this->xml_parser_; + } + + inline bool options:: + xml_parser_specified () const + { + return this->xml_parser_specified_; + } + + inline const bool& options:: + generate_validation () const + { + return this->generate_validation_; + } + + inline const bool& options:: + suppress_validation () const + { + return this->suppress_validation_; + } + + inline const bool& options:: + generate_polymorphic () const + { + return this->generate_polymorphic_; + } + + inline const bool& options:: + generate_noop_impl () const + { + return this->generate_noop_impl_; + } + + inline const bool& options:: + generate_print_impl () const + { + return this->generate_print_impl_; + } + + inline const bool& options:: + generate_test_driver () const + { + return this->generate_test_driver_; + } + + inline const bool& options:: + force_overwrite () const + { + return this->force_overwrite_; + } + + inline const bool& options:: + root_element_first () const + { + return this->root_element_first_; + } + + inline const bool& options:: + root_element_last () const + { + return this->root_element_last_; + } + + inline const NarrowString& options:: + root_element () const + { + return this->root_element_; + } + + inline bool options:: + root_element_specified () const + { + return this->root_element_specified_; + } + + inline const NarrowString& options:: + skel_type_suffix () const + { + return this->skel_type_suffix_; + } + + inline bool options:: + skel_type_suffix_specified () const + { + return this->skel_type_suffix_specified_; + } + + inline const NarrowString& options:: + skel_file_suffix () const + { + return this->skel_file_suffix_; + } + + inline bool options:: + skel_file_suffix_specified () const + { + return this->skel_file_suffix_specified_; + } + + inline const NarrowString& options:: + impl_type_suffix () const + { + return this->impl_type_suffix_; + } + + inline bool options:: + impl_type_suffix_specified () const + { + return this->impl_type_suffix_specified_; + } + + inline const NarrowString& options:: + impl_file_suffix () const + { + return this->impl_file_suffix_; + } + + inline bool options:: + impl_file_suffix_specified () const + { + return this->impl_file_suffix_specified_; + } + } +} + +// Begin epilogue. +// +// +// End epilogue. diff --git a/xsd/xsd/cxx/parser/parser-forward.cxx b/xsd/xsd/cxx/parser/parser-forward.cxx index a4e8ae7..faf427a 100644 --- a/xsd/xsd/cxx/parser/parser-forward.cxx +++ b/xsd/xsd/cxx/parser/parser-forward.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-forward.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 @@ -21,7 +20,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { os << "class " << ename (e) << ";"; @@ -37,7 +36,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { os << "class " << ename (l) << ";"; @@ -53,7 +52,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { os << "class " << ename (u) << ";"; @@ -69,7 +68,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { os << "class " << ename (c) << ";"; @@ -77,7 +76,7 @@ namespace CXX }; } - Void + void generate_parser_forward (Context& ctx) { ctx.os << "// Forward declarations" << endl @@ -85,7 +84,7 @@ namespace CXX Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/parser-forward.hxx b/xsd/xsd/cxx/parser/parser-forward.hxx index a8a17f1..53c7049 100644 --- a/xsd/xsd/cxx/parser/parser-forward.hxx +++ b/xsd/xsd/cxx/parser/parser-forward.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-forward.hxx -// 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 #ifndef CXX_PARSER_PARSER_FORWARD_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_parser_forward (Context&); } } diff --git a/xsd/xsd/cxx/parser/parser-header.cxx b/xsd/xsd/cxx/parser/parser-header.cxx index aade743..800a4b9 100644 --- a/xsd/xsd/cxx/parser/parser-header.cxx +++ b/xsd/xsd/cxx/parser/parser-header.cxx @@ -1,13 +1,16 @@ // file : xsd/cxx/parser/parser-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 + #include #include #include +using namespace std; + namespace CXX { namespace Parser @@ -21,7 +24,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (ename (e)); @@ -41,7 +44,7 @@ namespace CXX String const& ret (ret_type (e)); - Boolean same (ret == ret_type (base)); + bool same (ret == ret_type (base)); os << "virtual " << ret << endl << post_name (e) << " ()" << @@ -71,7 +74,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (ename (l)); @@ -173,7 +176,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (ename (u)); @@ -222,7 +225,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; @@ -251,7 +254,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -281,7 +284,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -295,8 +298,7 @@ namespace CXX m.is_a () && !anonymous (m.type ())) { - os << type << "* " << emember_cache (m) << ";" - << "const " << parser_map << "* " << emember_map (m) << ";" + os << "const " << parser_map << "* " << emember_map (m) << ";" << endl; } } @@ -316,14 +318,13 @@ namespace CXX } - virtual Void + virtual void traverse (SemanticGraph::All& a) { if (!a.context().count ("comp-number")) return; - UnsignedLong state_count ( - a.context().get ("state-count")); + size_t state_count (a.context().get ("state-count")); os << "void" << endl << "all_0 (unsigned long& state," << endl @@ -338,13 +339,13 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::Choice& c) { if (!c.context().count ("comp-number")) return; - UnsignedLong n (c.context ().get ("comp-number")); + size_t n (c.context ().get ("comp-number")); os << "void" << endl << "choice_" << n << " (unsigned long& state," << endl @@ -358,13 +359,13 @@ namespace CXX Traversal::Choice::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Sequence& s) { if (!s.context().count ("comp-number")) return; - UnsignedLong n (s.context ().get ("comp-number")); + size_t n (s.context ().get ("comp-number")); os << "void" << endl << "sequence_" << n << " (unsigned long& state," << endl @@ -392,7 +393,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (!a.optional_p ()) @@ -419,7 +420,7 @@ namespace CXX names_attribute_validation_state_ >> attribute_validation_state_; } - virtual Void + virtual void traverse (Type& c) { String const& name (ename (c)); @@ -428,15 +429,15 @@ namespace CXX // generate parser callbacks, etc. since they are the same as in // the base. We only need the parsing/validation code. // - Boolean restriction (restriction_p (c)); + bool restriction (restriction_p (c)); - Boolean he (has (c)); - Boolean ha (has (c)); + bool he (has (c)); + bool ha (has (c)); - Boolean hae (has_particle (c)); - Boolean haa (has (c)); + bool hae (has_particle (c)); + bool haa (has (c)); - Boolean hra (false); // Has required attribute. + bool hra (false); // Has required attribute. if (ha) { RequiredAttributeTest test (hra); @@ -472,7 +473,7 @@ namespace CXX String const& ret (ret_type (c)); - Boolean same (c.inherits_p () && + bool same (c.inherits_p () && ret == ret_type (c.inherits ().base ())); os << "virtual " << ret << endl @@ -606,7 +607,7 @@ namespace CXX if (validation && (he || hae)) { - UnsignedLong depth (c.context ().get ("depth")); + size_t depth (c.context ().get ("depth")); os << "protected:" << endl; @@ -770,13 +771,13 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { gen_typedef (t, "void", "any_type_pskel", "any_type_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { gen_typedef (t, "void", @@ -785,7 +786,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { gen_typedef (t, "bool", "boolean_pskel", "boolean_pimpl"); @@ -793,72 +794,72 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { gen_typedef (t, "signed char", "byte_pskel", "byte_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { gen_typedef (t, "unsigned char", "unsigned_byte_pskel", "unsigned_byte_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { gen_typedef (t, "short", "short_pskel", "short_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { gen_typedef (t, "unsigned short", "unsigned_short_pskel", "unsigned_short_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { gen_typedef (t, "int", "int_pskel", "int_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { gen_typedef (t, "unsigned int", "unsigned_int_pskel", "unsigned_int_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { gen_typedef (t, "long long", "long_pskel", "long_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { gen_typedef (t, "unsigned long long", "unsigned_long_pskel", "unsigned_long_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { gen_typedef (t, "long long", "integer_pskel", "integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { gen_typedef (t, "long long", "negative_integer_pskel", "negative_integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { gen_typedef (t, "long long", @@ -866,14 +867,14 @@ namespace CXX "non_positive_integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { gen_typedef (t, "unsigned long long", "positive_integer_pskel", "positive_integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { gen_typedef (t, "unsigned long long", @@ -883,19 +884,19 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { gen_typedef (t, "float", "float_pskel", "float_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { gen_typedef (t, "double", "double_pskel", "double_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { gen_typedef (t, "double", "decimal_pskel", "decimal_pimpl"); @@ -903,33 +904,33 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { gen_typedef (t, string_type_, "string_pskel", "string_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { gen_typedef (t, string_type_, "normalized_string_pskel", "normalized_string_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { gen_typedef (t, string_type_, "token_pskel", "token_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { nmtoken_ = gen_typedef (t, string_type_, "nmtoken_pskel", "nmtoken_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { // NMTOKENS uses NMTOKEN implementation to parse individual items. @@ -941,19 +942,19 @@ namespace CXX "nmtokens_pskel", "nmtokens_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { gen_typedef (t, string_type_, "name_pskel", "name_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { gen_typedef (t, string_type_, "ncname_pskel", "ncname_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { gen_typedef (t, string_type_, "language_pskel", "language_pimpl"); @@ -961,7 +962,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { gen_typedef (t, xs_ns_ + L"::qname", "qname_pskel", "qname_pimpl"); @@ -969,19 +970,19 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { gen_typedef (t, string_type_, "id_pskel", "id_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { idref_ = gen_typedef (t, string_type_, "idref_pskel", "idref_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { // IDREFS uses IDREF implementation to parse individual items. @@ -995,7 +996,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { gen_typedef (t, string_type_, "uri_pskel", "uri_pimpl"); @@ -1003,78 +1004,78 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { - String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >"); + String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); gen_typedef (t, buffer, "base64_binary_pskel", "base64_binary_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { - String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >"); + String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); gen_typedef (t, buffer, "hex_binary_pskel", "hex_binary_pimpl"); } // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { gen_typedef (t, xs_ns_ + L"::date", "date_pskel", "date_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { gen_typedef (t, xs_ns_ + L"::date_time", "date_time_pskel", "date_time_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { gen_typedef (t, xs_ns_ + L"::duration", "duration_pskel", "duration_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { gen_typedef (t, xs_ns_ + L"::gday", "gday_pskel", "gday_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { gen_typedef (t, xs_ns_ + L"::gmonth", "gmonth_pskel", "gmonth_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { gen_typedef (t, xs_ns_ + L"::gmonth_day", "gmonth_day_pskel", "gmonth_day_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { gen_typedef (t, xs_ns_ + L"::gyear", "gyear_pskel", "gyear_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { gen_typedef (t, xs_ns_ + L"::gyear_month", "gyear_month_pskel", "gyear_month_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { gen_typedef (t, xs_ns_ + L"::time", "time_pskel", "time_pimpl"); @@ -1082,18 +1083,18 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity&) { } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities&) { } private: - Boolean + bool gen_typedef (SemanticGraph::Type& t, String const& type, String const& pskel, @@ -1120,8 +1121,8 @@ namespace CXX String impl_ns_; String string_type_; - Boolean idref_; - Boolean nmtoken_; + bool idref_; + bool nmtoken_; }; struct FundNamespace: Namespace, Context @@ -1258,8 +1259,8 @@ namespace CXX }; } - Void - generate_parser_header (Context& ctx, Boolean generate_xml_schema) + void + generate_parser_header (Context& ctx, bool generate_xml_schema) { String c (ctx.char_type); @@ -1295,11 +1296,11 @@ namespace CXX NarrowString extern_xml_schema; if (!generate_xml_schema) - extern_xml_schema = ctx.options.value (); + extern_xml_schema = ctx.options.extern_xml_schema (); if (extern_xml_schema) { - String name (ctx.hxx_expr->merge (extern_xml_schema)); + String name (ctx.hxx_expr->replace (extern_xml_schema)); ctx.os << "#include " << ctx.process_include_path (name) << endl << endl; @@ -1308,12 +1309,12 @@ namespace CXX // if (ctx.schema_root.context ().count ("includes")) { - typedef Cult::Containers::Set Includes; + typedef set Includes; Includes const& is ( ctx.schema_root.context ().get ("includes")); - for (Includes::ConstReverseIterator i (is.rbegin ()); + for (Includes::const_reverse_iterator i (is.rbegin ()); i != is.rend (); ++i) { ctx.os << "#include " << *i << endl; @@ -1357,12 +1358,12 @@ namespace CXX // if (ctx.schema_root.context ().count ("includes")) { - typedef Cult::Containers::Set Includes; + typedef set Includes; Includes const& is ( ctx.schema_root.context ().get ("includes")); - for (Includes::ConstReverseIterator i (is.rbegin ()); + for (Includes::const_reverse_iterator i (is.rbegin ()); i != is.rend (); ++i) { ctx.os << "#include " << *i << endl; @@ -1412,7 +1413,7 @@ namespace CXX { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Includes includes (ctx, Includes::header); Traversal::Names schema_names; diff --git a/xsd/xsd/cxx/parser/parser-header.hxx b/xsd/xsd/cxx/parser/parser-header.hxx index c4e114d..467dcb5 100644 --- a/xsd/xsd/cxx/parser/parser-header.hxx +++ b/xsd/xsd/cxx/parser/parser-header.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-header.hxx -// 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 #ifndef CXX_PARSER_PARSER_HEADER_HXX @@ -12,8 +11,8 @@ namespace CXX { namespace Parser { - Void - generate_parser_header (Context&, Boolean generate_xml_schema); + void + generate_parser_header (Context&, bool generate_xml_schema); } } diff --git a/xsd/xsd/cxx/parser/parser-inline.cxx b/xsd/xsd/cxx/parser/parser-inline.cxx index b491b72..87ba92c 100644 --- a/xsd/xsd/cxx/parser/parser-inline.cxx +++ b/xsd/xsd/cxx/parser/parser-inline.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-inline.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 @@ -23,7 +22,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (ename (l)); @@ -75,7 +74,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -84,7 +83,7 @@ namespace CXX String const& scope (ename (m.scope ())); String const& parser (eparser (m)); - Boolean poly (polymorphic && + bool poly (polymorphic && m.is_a () && !anonymous (m.type ())); @@ -117,7 +116,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; @@ -138,7 +137,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; @@ -159,14 +158,14 @@ namespace CXX } } - Boolean + bool comma () const { return !first_; } private: - Boolean first_; + bool first_; }; struct ParserBaseSet: Traversal::Complex, @@ -180,7 +179,7 @@ namespace CXX names_ >> member_; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -189,7 +188,7 @@ namespace CXX names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { String const& name (ename (l)); @@ -212,14 +211,13 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { if (!a.context().count ("comp-number")) return; - UnsignedLong state_count ( - a.context().get ("state-count")); + size_t state_count (a.context().get ("state-count")); os << "," << endl << " v_all_count_ (" << state_count << "UL, v_all_first_)"; @@ -242,15 +240,15 @@ namespace CXX names_parser_member_set_ >> parser_member_set_; } - virtual Void + virtual void traverse (Type& c) { - Boolean he (has (c)); - Boolean ha (has (c)); + bool he (has (c)); + bool ha (has (c)); - Boolean hae (has_particle (c)); + bool hae (has_particle (c)); - Boolean hra (false); // Has required attribute. + bool hra (false); // Has required attribute. if (ha) { RequiredAttributeTest test (hra); @@ -258,7 +256,7 @@ namespace CXX names (c, names_test); } - Boolean restriction (restriction_p (c)); + bool restriction (restriction_p (c)); if (!((!restriction && (he || ha)) || (validation && (he || hae || hra)))) @@ -305,7 +303,7 @@ namespace CXX << name << " ()" << endl << ": "; - Boolean comma (false); + bool comma (false); if (!restriction && (he || ha)) { @@ -364,13 +362,13 @@ namespace CXX }; } - Void + void generate_parser_inline (Context& ctx) { // Emit "weak" header includes that are used in the file-per-type // compilation model. // - if (!ctx.options.value ()) + if (!ctx.options.generate_inline ()) { Traversal::Schema schema; Includes includes (ctx, Includes::source); @@ -381,7 +379,7 @@ namespace CXX Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/parser-inline.hxx b/xsd/xsd/cxx/parser/parser-inline.hxx index 51f5b93..aff2ad2 100644 --- a/xsd/xsd/cxx/parser/parser-inline.hxx +++ b/xsd/xsd/cxx/parser/parser-inline.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-inline.hxx -// 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 #ifndef CXX_PARSER_PARSER_INLINE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_parser_inline (Context&); } } diff --git a/xsd/xsd/cxx/parser/parser-source.cxx b/xsd/xsd/cxx/parser/parser-source.cxx index 99bc566..2ee5273 100644 --- a/xsd/xsd/cxx/parser/parser-source.cxx +++ b/xsd/xsd/cxx/parser/parser-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-source.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 @@ -21,7 +20,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (ename (e)); @@ -29,7 +28,7 @@ namespace CXX SemanticGraph::Type& base (e.inherits ().base ()); - Boolean same (ret == ret_type (base)); + bool same (ret == ret_type (base)); if (same || ret == L"void" || polymorphic) { @@ -79,7 +78,7 @@ namespace CXX if (validation) { - Boolean gen (!anonymous (e)); + bool gen (!anonymous (e)); // We normally don't need to enter anonymous types into // the inheritance map. The only exception is when an @@ -89,16 +88,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - e.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) + if (e.classifies_begin () != e.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + e.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } @@ -126,7 +130,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (ename (l)); @@ -222,7 +226,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (ename (u)); @@ -277,15 +281,13 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (skip (e)) return; - Boolean poly (polymorphic && !anonymous (e.type ())); - - String const& inst (poly ? emember_cache (e) : emember (e)); + bool poly (polymorphic && !anonymous (e.type ())); os << "if ("; @@ -316,9 +318,12 @@ namespace CXX os << ")" << "{"; + String inst; + if (poly) { SemanticGraph::Type& t (e.type ()); + inst = "p"; // For pre-computing length. // @@ -334,8 +339,10 @@ namespace CXX String const& member (emember (e)); String const& member_map (emember_map (e)); - os << "if (t == 0 && this->" << member << " != 0)" << endl - << "this->" << inst << " = this->" << member << ";" + os << fq_type << "* p = 0;" + << endl + << "if (t == 0 && this->" << member << " != 0)" << endl + << inst << " = this->" << member << ";" << "else" << "{" << string_type << " ts (" << fq_type << @@ -345,21 +352,21 @@ namespace CXX << "t = &ts;" << endl << "if (this->" << member << " != 0 && *t == ts)" << endl - << "this->" << inst << " = this->" << member << ";" + << inst << " = this->" << member << ";" << "else if (this->" << member_map << " != 0)" << endl - << "this->" << inst << " = dynamic_cast< " << fq_type << + << inst << " = dynamic_cast< " << fq_type << "* > (" << endl << "this->" << member_map << "->find (*t));" - << "else" << endl - << "this->" << inst << " = 0;" << "}"; } + else + inst = L"this->" + emember (e); os << "this->" << complex_base << "::context_.top ().parser_ = " << - "this->" << inst << ";" + inst << ";" << endl - << "if (this->" << inst << ")" << endl - << "this->" << inst << "->pre ();" // _start_element calls _pre + << "if (" << inst << ")" << endl + << inst << "->pre ();" // _start_element calls _pre << endl << "return true;" << "}"; @@ -376,16 +383,14 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (skip (e)) return; - Boolean poly (polymorphic && !anonymous (e.type ())); - + bool poly (polymorphic && !anonymous (e.type ())); String const& name (ename (e)); - String const& inst (poly ? emember_cache (e) : emember (e)); os << "if ("; @@ -421,18 +426,31 @@ namespace CXX SemanticGraph::Type& type (e.type ()); String const& post (post_name (type)); + String inst; + + if (poly) + { + String const& fq_type (fq_name (type)); + inst = "p"; - os << "if (this->" << inst << ")"; + os << fq_type << "* p =" << endl + << "dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << complex_base << "::context_.top ().parser_);" + << endl; + } + else + inst = L"this->" + emember (e); + + os << "if (" << inst << ")"; if (ret_type (type) == L"void") os << "{" - << "this->" << inst << "->" << post << " ();" + << inst << "->" << post << " ();" << "this->" << name << " ();" << "}"; else os << endl - << "this->" << name << " (this->" << inst << "->" << - post << " ());" + << "this->" << name << " (" << inst << "->" << post << " ());" << endl; os << "return true;" @@ -449,7 +467,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& name (ename (a)); @@ -500,7 +518,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -538,14 +556,14 @@ namespace CXX names_attribute_ >> attribute_; } - virtual Void + virtual void traverse (Type& c) { - Boolean he (has (c)); - Boolean ha (has (c)); + bool he (has (c)); + bool ha (has (c)); String const& ret (ret_type (c)); - Boolean same (c.inherits_p () && + bool same (c.inherits_p () && ret == ret_type (c.inherits ().base ())); String const& name (ename (c)); @@ -581,7 +599,7 @@ namespace CXX if (c.inherits_p () && validation) { - Boolean gen (!anonymous (c)); + bool gen (!anonymous (c)); // We normally don't need to enter anonymous types into // the inheritance map. The only exception is when an @@ -591,16 +609,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - c.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) + if (c.classifies_begin () != c.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + c.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } @@ -655,7 +678,7 @@ namespace CXX // Don't use restriction_p here since we don't want special // treatment of anyType. // - Boolean restriction ( + bool restriction ( c.inherits_p () && c.inherits ().is_a ()); @@ -782,7 +805,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (e.substitutes_p ()) @@ -809,7 +832,7 @@ namespace CXX }; } - Void + void generate_parser_source (Context& ctx) { if (ctx.polymorphic) @@ -822,8 +845,8 @@ namespace CXX else ctx.os << endl; - Boolean import_maps (ctx.options.value ()); - Boolean export_maps (ctx.options.value ()); + bool import_maps (ctx.options.import_maps ()); + bool export_maps (ctx.options.export_maps ()); if (import_maps || export_maps) { @@ -896,7 +919,7 @@ namespace CXX // Emit "weak" header includes that are used in the file-per-type // compilation model. // - if (ctx.options.value ()) + if (ctx.options.generate_inline ()) { Traversal::Schema schema; Includes includes (ctx, Includes::source); @@ -906,7 +929,7 @@ namespace CXX } Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/parser-source.hxx b/xsd/xsd/cxx/parser/parser-source.hxx index f6496ea..6e206b4 100644 --- a/xsd/xsd/cxx/parser/parser-source.hxx +++ b/xsd/xsd/cxx/parser/parser-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-source.hxx -// 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 #ifndef CXX_PARSER_PARSER_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_parser_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/print-impl-common.hxx b/xsd/xsd/cxx/parser/print-impl-common.hxx index 5a91931..516273a 100644 --- a/xsd/xsd/cxx/parser/print-impl-common.hxx +++ b/xsd/xsd/cxx/parser/print-impl-common.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/print-impl-common.hxx -// 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 #ifndef CXX_PARSER_PRINT_IMPL_COMMON_HXX @@ -74,7 +73,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type&) { gen_user_type (); @@ -82,7 +81,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { if (default_type (t, "bool")) @@ -96,7 +95,7 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { if (default_type (t, "signed char")) @@ -108,7 +107,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { if (default_type (t, "unsigned char")) @@ -120,7 +119,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { if (default_type (t, "short")) @@ -132,7 +131,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { if (default_type (t, "unsigned short")) @@ -144,7 +143,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { if (default_type (t, "int")) @@ -156,7 +155,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { if (default_type (t, "unsigned int")) @@ -168,7 +167,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { if (default_type (t, "long long")) @@ -180,7 +179,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { if (default_type (t, "unsigned long long")) @@ -192,7 +191,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { if (default_type (t, "long long")) @@ -204,7 +203,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { if (default_type (t, "long long")) @@ -216,7 +215,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { if (default_type (t, "long long")) @@ -228,7 +227,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { if (default_type (t, "unsigned long long")) @@ -240,7 +239,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { if (default_type (t, "unsigned long long")) @@ -254,7 +253,7 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { if (default_type (t, "float")) @@ -266,7 +265,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { if (default_type (t, "double")) @@ -278,7 +277,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { if (default_type (t, "double")) @@ -292,61 +291,61 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { gen_string (t); @@ -355,13 +354,13 @@ namespace CXX // String sequences. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { gen_sequence (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { gen_sequence (t); @@ -370,7 +369,7 @@ namespace CXX // QName // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { if (default_type (t, xs_ns_name () + L"::qname")) @@ -391,13 +390,13 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { gen_buffer (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { gen_buffer (t); @@ -405,7 +404,7 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { if (default_type (t, xs_ns_name () + L"::date")) @@ -421,7 +420,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { if (default_type (t, xs_ns_name () + L"::date_time")) @@ -440,7 +439,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { if (default_type (t, xs_ns_name () + L"::duration")) @@ -463,7 +462,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { if (default_type (t, xs_ns_name () + L"::gday")) @@ -477,7 +476,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { if (default_type (t, xs_ns_name () + L"::gmonth")) @@ -491,7 +490,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { if (default_type (t, xs_ns_name () + L"::gmonth_day")) @@ -506,7 +505,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { if (default_type (t, xs_ns_name () + L"::gyear")) @@ -520,7 +519,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { if (default_type (t, xs_ns_name () + L"::gyear_month")) @@ -535,7 +534,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { if (default_type (t, xs_ns_name () + L"::time")) @@ -605,7 +604,7 @@ namespace CXX void gen_buffer (SemanticGraph::Type& t) { - String type (L"::std::auto_ptr< " + xs_ns_name () + L"::buffer >"); + String type (auto_ptr + L"< " + xs_ns_name () + L"::buffer >"); if (default_type (t, type)) { diff --git a/xsd/xsd/cxx/parser/state-processor.cxx b/xsd/xsd/cxx/parser/state-processor.cxx index 7fe3ff6..86f97ce 100644 --- a/xsd/xsd/cxx/parser/state-processor.cxx +++ b/xsd/xsd/cxx/parser/state-processor.cxx @@ -1,8 +1,10 @@ // file : xsd/cxx/parser/state-processor.cxx -// author : Boris Kolpackov -// 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 +#include + #include #include @@ -10,9 +12,7 @@ #include #include -#include - -#include +using namespace std; namespace CXX { @@ -20,8 +20,9 @@ namespace CXX { namespace { - typedef Cult::Containers::Vector Particles; + typedef vector Particles; + /* void print (Particles const& p) { @@ -30,7 +31,7 @@ namespace CXX wcerr << "prefixes: " << endl; - for (Particles::ConstIterator i (p.begin ()); i != p.end (); ++i) + for (Particles::const_iterator i (p.begin ()); i != p.end (); ++i) { if (SemanticGraph::Element* e = dynamic_cast (*i)) @@ -45,6 +46,7 @@ namespace CXX wcerr << endl; } + */ // // @@ -52,10 +54,10 @@ namespace CXX Traversal::Choice, Traversal::Sequence { - Particle (UnsignedLong& all, - UnsignedLong& choice, - UnsignedLong& sequence, - UnsignedLong& depth) + Particle (size_t& all, + size_t& choice, + size_t& sequence, + size_t& depth) : all_ (all), choice_ (choice), sequence_ (sequence), @@ -63,7 +65,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { using SemanticGraph::Compositor; @@ -78,8 +80,8 @@ namespace CXX // compositor cannot contain any nested compositors. // - UnsignedLong state (0); - UnsignedLong min (0); + size_t state (0); + size_t min (0); for (Compositor::ContainsIterator ci (a.contains_begin ()); ci != a.contains_end (); ++ci) @@ -101,7 +103,7 @@ namespace CXX { a.context ().set ("comp-number", choice_++); a.context ().set ("prefixes", prefixes_); - a.context ().set ("state-count", UnsignedLong (prefixes_.size ())); + a.context ().set ("state-count", size_t (prefixes_.size ())); // effective-min = min * actual-min // @@ -114,7 +116,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Choice& c) { using SemanticGraph::Compositor; @@ -126,8 +128,8 @@ namespace CXX // the actual value specified in the schema. // - UnsignedLong state (0); - UnsignedLong min (1); + size_t state (0); + size_t min (1); for (Compositor::ContainsIterator ci (c.contains_begin ()); ci != c.contains_end (); ++ci) @@ -144,7 +146,7 @@ namespace CXX } else { - UnsignedLong depth (0); + size_t depth (0); Particle t (all_, choice_, sequence_, depth); t.dispatch (p); @@ -159,7 +161,7 @@ namespace CXX t.prefixes_.end ().base ()); if (min == 1 && - p.context ().get ("effective-min") == 0) + p.context ().get ("effective-min") == 0) min = 0; } @@ -183,7 +185,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Sequence& s) { using SemanticGraph::Compositor; @@ -195,9 +197,9 @@ namespace CXX // of the actual value specified in the schema. // - Boolean prefix (true); - UnsignedLong state (0); - UnsignedLong min (0); + bool prefix (true); + size_t state (0); + size_t min (0); for (Compositor::ContainsIterator ci (s.contains_begin ()); ci != s.contains_end (); ++ci) @@ -217,7 +219,7 @@ namespace CXX } else { - UnsignedLong depth (0); + size_t depth (0); Particle t (all_, choice_, sequence_, depth); t.dispatch (p); @@ -233,7 +235,7 @@ namespace CXX t.prefixes_.begin ().base (), t.prefixes_.end ().base ()); - if (p.context ().get ("effective-min") != 0) + if (p.context ().get ("effective-min") != 0) min = 1; } } @@ -266,11 +268,11 @@ namespace CXX private: Particles prefixes_; - UnsignedLong& all_; - UnsignedLong& choice_; - UnsignedLong& sequence_; + size_t& all_; + size_t& choice_; + size_t& sequence_; - UnsignedLong& depth_; + size_t& depth_; }; @@ -278,12 +280,12 @@ namespace CXX // struct Complex: Traversal::Complex { - virtual Void + virtual void traverse (Type& c) { if (c.contains_compositor_p ()) { - UnsignedLong all (0), choice (0), sequence (0), depth (0); + size_t all (0), choice (0), sequence (0), depth (0); Particle t (all, choice, sequence, depth); t.dispatch (c.contains_compositor ().compositor ()); @@ -296,11 +298,11 @@ namespace CXX }; } - Void StateProcessor:: + void StateProcessor:: process (SemanticGraph::Schema& tu, SemanticGraph::Path const&) { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Traversal::Namespace ns; Traversal::Names ns_names; diff --git a/xsd/xsd/cxx/parser/state-processor.hxx b/xsd/xsd/cxx/parser/state-processor.hxx index 630ac13..de5af69 100644 --- a/xsd/xsd/cxx/parser/state-processor.hxx +++ b/xsd/xsd/cxx/parser/state-processor.hxx @@ -1,24 +1,22 @@ // file : xsd/cxx/parser/state-processor.hxx -// author : Boris Kolpackov -// 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 #ifndef CXX_PARSER_STATE_PROCESSOR_HXX #define CXX_PARSER_STATE_PROCESSOR_HXX -#include #include +#include + namespace CXX { namespace Parser { - using namespace Cult::Types; - class StateProcessor { public: - Void + void process (XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file); }; diff --git a/xsd/xsd/cxx/parser/type-processor.cxx b/xsd/xsd/cxx/parser/type-processor.cxx index 4744c0a..2f1132c 100644 --- a/xsd/xsd/cxx/parser/type-processor.cxx +++ b/xsd/xsd/cxx/parser/type-processor.cxx @@ -1,9 +1,8 @@ // file : xsd/cxx/parser/type-processor.cxx -// author : Boris Kolpackov -// 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 +#include #include #include @@ -11,16 +10,12 @@ #include #include +using namespace std; + namespace CXX { namespace Parser { - TypeProcessor:: - TypeProcessor () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - namespace { // @@ -29,14 +24,14 @@ namespace CXX { Type (SemanticGraph::Schema& schema, TypeMap::Namespaces& type_map, - Boolean add_includes) + bool add_includes) : schema_ (schema), type_map_ (type_map), add_includes_ (add_includes) { } - virtual Void + virtual void traverse (SemanticGraph::Type& type) { using TypeMap::Namespace; @@ -54,7 +49,7 @@ namespace CXX // match the type in order to add include directives to the // new root schema. // - Boolean set (true); + bool set (true); if (tc.count ("ret-type")) { @@ -73,14 +68,14 @@ namespace CXX String ns_name (ns.name ()); String t_name (type.name ()); - // std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; + //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; - for (Namespaces::ConstIterator n (type_map_.begin ()); + for (Namespaces::const_iterator n (type_map_.begin ()); n != type_map_.end (); ++n) { // Check if the namespace matches. // - Boolean ns_match; + bool ns_match; if (!n->xsd_name ().empty ()) { @@ -89,7 +84,9 @@ namespace CXX else ns_match = ns_name.empty (); - // std::wcerr << "considering ns expr: " << n->xsd_name () << endl; + //std::wcerr << "considering ns expr: " << n->xsd_name () + // << " for " << ns_name + // << ": " << (ns_match ? "+" : "-") << endl; if (ns_match) { @@ -111,8 +108,8 @@ namespace CXX { if (!n->xsd_name ().empty ()) { - cxx_ns = n->xsd_name ().merge ( - n->cxx_name (), ns_name, true); + cxx_ns = n->xsd_name ().replace ( + ns_name, n->cxx_name (), true); } else cxx_ns = n->cxx_name (); @@ -124,16 +121,16 @@ namespace CXX // String ret_type (cxx_ns); - ret_type += t->xsd_name ().merge ( - t->cxx_ret_name (), t_name, true); + ret_type += t->xsd_name ().replace ( + t_name, t->cxx_ret_name (), true); String arg_type; if (t->cxx_arg_name ()) { arg_type = cxx_ns; - arg_type += t->xsd_name ().merge ( - t->cxx_arg_name (), t_name, true); + arg_type += t->xsd_name ().replace ( + t_name, t->cxx_arg_name (), true); } else { @@ -141,7 +138,7 @@ namespace CXX arg_type = ret_type; else { - WideChar last (ret_type[ret_type.size () - 1]); + wchar_t last (ret_type[ret_type.size () - 1]); // If it is already a pointer or reference then use // it as is. @@ -155,12 +152,12 @@ namespace CXX tc.set ("ret-type", ret_type); tc.set ("arg-type", arg_type); + + //std::wcerr << t_name << " -> " << ret_type << endl; } tc.set ("root-schema", &schema_); - //std::wcerr << t_name << " -> " << ret_type << endl; - // See of we need to add any includes to the translations // unit. // @@ -168,7 +165,7 @@ namespace CXX { if (n->includes_begin () != n->includes_end ()) { - typedef Cult::Containers::Set Includes; + typedef std::set Includes; if (!schema_.context ().count ("includes")) schema_.context ().set ("includes", Includes ()); @@ -194,7 +191,7 @@ namespace CXX private: SemanticGraph::Schema& schema_; TypeMap::Namespaces& type_map_; - Boolean add_includes_; + bool add_includes_; }; @@ -207,7 +204,7 @@ namespace CXX { GlobalType (SemanticGraph::Schema& schema, TypeMap::Namespaces& type_map, - Boolean add_includes) + bool add_includes) : type_ (schema, type_map, add_includes) { inherits_ >> type_; @@ -215,20 +212,20 @@ namespace CXX argumented_ >> type_; } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { type_.traverse (t); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { type_.traverse (l); Traversal::List::argumented (l, argumented_); } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { type_.traverse (c); @@ -236,7 +233,7 @@ namespace CXX Complex::names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::Enumeration& e) { type_.traverse (e); @@ -252,10 +249,10 @@ namespace CXX Traversal::Argumented argumented_; }; - Void - process_impl (CLI::Options const& options, + void + process_impl (options const& ops, XSDFrontend::SemanticGraph::Schema& tu, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces& type_map) { if (tu.names_begin ()->named ().name () == @@ -279,14 +276,13 @@ namespace CXX // If --extern-xml-schema is specified, then we don't want // includes from the XML Schema type map. // - Boolean extern_xml_schema ( - options.value ()); + bool extern_xml_schema (ops.extern_xml_schema ()); // // Traversal::Schema schema; Traversal::Schema xs_schema; - Traversal::Sources sources; + Sources sources; Traversal::Implies implies; schema >> sources >> schema; @@ -312,7 +308,7 @@ namespace CXX // If we are generating the test driver, make sure the root // element type is processed. // - if (gen_driver && options.value ()) + if (gen_driver && ops.generate_test_driver ()) { // Figure out the root element. Validator should have made sure // it is unique. @@ -320,14 +316,14 @@ namespace CXX SemanticGraph::Element* root (0); { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; Traversal::Names schema_names; Traversal::Namespace ns; Traversal::Names ns_names; - RootElement root_element (options, root); + RootElement root_element (ops, root); schema >> schema_names >> ns >> ns_names >> root_element; @@ -340,13 +336,13 @@ namespace CXX } } - Void TypeProcessor:: - process (CLI::Options const& options, + void TypeProcessor:: + process (options const& ops, XSDFrontend::SemanticGraph::Schema& s, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces& tm) { - process_impl (options, s, gen_driver, tm); + process_impl (ops, s, gen_driver, tm); } } } diff --git a/xsd/xsd/cxx/parser/type-processor.hxx b/xsd/xsd/cxx/parser/type-processor.hxx index 02a090f..634bc14 100644 --- a/xsd/xsd/cxx/parser/type-processor.hxx +++ b/xsd/xsd/cxx/parser/type-processor.hxx @@ -1,34 +1,29 @@ // file : xsd/cxx/parser/type-processor.hxx -// author : Boris Kolpackov -// 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 #ifndef CXX_PARSER_TYPE_PROCESSOR_HXX #define CXX_PARSER_TYPE_PROCESSOR_HXX -#include - #include +#include + #include -#include +#include namespace CXX { namespace Parser { - using namespace Cult::Types; - class TypeProcessor { public: - TypeProcessor (); // Dummy ctor, helps with long symbols on HP-UX. - - Void - process (CLI::Options const& options, + void + process (options const&, XSDFrontend::SemanticGraph::Schema&, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces&); }; } diff --git a/xsd/xsd/cxx/parser/validator.cxx b/xsd/xsd/cxx/parser/validator.cxx index 19b15c6..da9f8b0 100644 --- a/xsd/xsd/cxx/parser/validator.cxx +++ b/xsd/xsd/cxx/parser/validator.cxx @@ -1,8 +1,10 @@ // file : xsd/cxx/parser/validator.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 +#include + #include #include @@ -10,9 +12,7 @@ #include -#include - -using std::wcerr; +using namespace std; namespace CXX { @@ -25,10 +25,10 @@ namespace CXX public: ValidationContext (SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& options, + Parser::options const& ops, const WarningSet& disabled_warnings, - Boolean& valid_) - : Context (std::wcerr, root, path, options, 0, 0, 0, 0), + bool& valid_) + : Context (std::wcerr, root, path, ops, 0, 0, 0, 0), disabled_warnings_ (disabled_warnings), disabled_warnings_all_ (false), valid (valid_), @@ -38,8 +38,8 @@ namespace CXX } public: - Boolean - is_disabled (Char const* w) + bool + is_disabled (char const* w) { return disabled_warnings_all_ || disabled_warnings_.find (w) != disabled_warnings_.end (); @@ -74,10 +74,10 @@ namespace CXX protected: const WarningSet& disabled_warnings_; - Boolean disabled_warnings_all_; - Boolean& valid; - Boolean& subst_group_warning_issued; - Boolean subst_group_warning_issued_; + bool disabled_warnings_all_; + bool& valid; + bool& subst_group_warning_issued; + bool subst_group_warning_issued_; }; // @@ -98,20 +98,20 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) return; using SemanticGraph::Any; - Boolean q (e.qualified_p ()); + bool q (e.qualified_p ()); String ns (q ? e.namespace_ ().name () : ""); for (Any::NamespaceIterator i (any_.namespace_begin ()); i != any_.namespace_end (); ++i) { - Boolean failed (false); + bool failed (false); if (*i == L"##any") { @@ -184,14 +184,14 @@ namespace CXX { } - virtual Void + virtual void post (Type& c) { // Go down the inheritance hierarchy. // if (down_) { - Boolean up = up_; + bool up = up_; up_ = false; if (c.inherits_p ()) @@ -204,7 +204,7 @@ namespace CXX // if (up_) { - Boolean down = down_; + bool down = down_; down_ = false; for (Type::BegetsIterator i (c.begets_begin ()); @@ -218,10 +218,10 @@ namespace CXX } private: - Boolean up_, down_; + bool up_, down_; }; - virtual Void + virtual void traverse (SemanticGraph::Any& a) { using SemanticGraph::Compositor; @@ -273,7 +273,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { using SemanticGraph::Schema; @@ -319,7 +319,7 @@ namespace CXX Complex::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { if (t.named_p ()) @@ -328,14 +328,14 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (is_disabled ("P002")) return; if (e.substitutes_p () && - !options.value () && + !options.generate_polymorphic () && !subst_group_warning_issued) { subst_group_warning_issued = true; @@ -352,7 +352,7 @@ namespace CXX // Return true if root sources s. // - Boolean + bool sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s) { using SemanticGraph::Schema; @@ -372,9 +372,9 @@ namespace CXX } private: - Containers::Set types_; + set types_; - Traversal::Sources sources_; + Sources sources_; Traversal::Names schema_names_; Traversal::Namespace ns_; @@ -405,7 +405,7 @@ namespace CXX *this >> names_; } - Boolean + bool traverse_common (SemanticGraph::Member& m) { SemanticGraph::Type& t (m.type ()); @@ -434,7 +434,7 @@ namespace CXX << "automatically name them" << endl; - if (!options.value ()) + if (!options.show_anonymous ()) wcerr << t.file () << ": info: use --show-anonymous option to see these " << "types" << endl; @@ -446,14 +446,14 @@ namespace CXX return false; } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) return; if (traverse_common (e)) { - if (options.value ()) + if (options.show_anonymous ()) { wcerr << e.file () << ":" << e.line () << ":" << e.column () << ": error: element '" << xpath (e) << "' " @@ -464,12 +464,12 @@ namespace CXX Traversal::Element::traverse (e); } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { if (traverse_common (a)) { - if (options.value ()) + if (options.show_anonymous ()) { wcerr << a.file () << ":" << a.line () << ":" << a.column () << ": error: attribute '" << xpath (a) << "' " @@ -481,11 +481,11 @@ namespace CXX } private: - Boolean anonymous_error_issued_; + bool anonymous_error_issued_; - Containers::Set types_; + set types_; - Traversal::Sources sources_; + Sources sources_; Traversal::Names schema_names_; Traversal::Namespace ns_; @@ -500,22 +500,22 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (!valid) return; - if (options.value ()) + if (options.root_element_first ()) { if (element_ == 0) element_ = &e; } - else if (options.value ()) + else if (options.root_element_last ()) { element_ = &e; } - else if (String name = options.value ()) + else if (String name = options.root_element ()) { if (e.name () == name) element_ = &e; @@ -544,46 +544,40 @@ namespace CXX } - Validator:: - Validator () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - - Boolean Validator:: - validate (CLI::Options const& options, + bool Validator:: + validate (options const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings) { - Boolean valid (true); - ValidationContext ctx (root, path, options, disabled_warnings, valid); + bool valid (true); + ValidationContext ctx (root, path, ops, disabled_warnings, valid); // // - if (options.value () != "char" && - options.value () != "wchar_t" && + if (ops.char_type () != "char" && + ops.char_type () != "wchar_t" && !ctx.is_disabled ("P003")) { wcerr << "warning P003: unknown base character type '" << - options.value ().c_str () << "'" << endl; + ops.char_type ().c_str () << "'" << endl; } // // - if (options.value () != "xerces" && - options.value () != "expat" && + if (ops.xml_parser () != "xerces" && + ops.xml_parser () != "expat" && !ctx.is_disabled ("P004")) { wcerr << "warning P004: unknown underlying XML parser '" << - options.value ().c_str () << "'" << endl; + ops.xml_parser ().c_str () << "'" << endl; } // // - if (options.value () == "expat" && - options.value () == "wchar_t") + if (ops.xml_parser () == "expat" && + ops.char_type () == "wchar_t") { wcerr << "error: using expat with wchar_t is not supported" << endl; @@ -593,9 +587,9 @@ namespace CXX // // - if (options.value () == "expat" && - !options.value ().empty () && - options.value () != "utf8") + if (ops.xml_parser () == "expat" && + !ops.char_encoding ().empty () && + ops.char_encoding () != "utf8") { wcerr << "error: using expat with character encoding other than " << "utf8 is not supported" @@ -606,8 +600,7 @@ namespace CXX // // - if (options.value () && - options.value ()) + if (ops.generate_validation () && ops.suppress_validation ()) { wcerr << "error: mutually exclusive options specified: " << "--generate-validation and --suppress-validation" @@ -618,8 +611,7 @@ namespace CXX // // - if (options.value () && - options.value ()) + if (ops.generate_noop_impl () && ops.generate_print_impl ()) { wcerr << "error: mutually exclusive options specified: " << "--generate-noop-impl and --generate-print-impl" @@ -631,9 +623,9 @@ namespace CXX // // { - Boolean ref (options.value ()); - Boolean rel (options.value ()); - Boolean re (options.value ()); + bool ref (ops.root_element_first ()); + bool rel (ops.root_element_last ()); + bool re (ops.root_element ()); if ((ref && rel) || (ref && re) || (rel && re)) { @@ -648,8 +640,8 @@ namespace CXX // // - Boolean import_maps (options.value ()); - Boolean export_maps (options.value ()); + bool import_maps (ops.import_maps ()); + bool export_maps (ops.export_maps ()); if (import_maps && export_maps) { @@ -698,7 +690,7 @@ namespace CXX SemanticGraph::Element* element (0); Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; diff --git a/xsd/xsd/cxx/parser/validator.hxx b/xsd/xsd/cxx/parser/validator.hxx index f519b05..c67cced 100644 --- a/xsd/xsd/cxx/parser/validator.hxx +++ b/xsd/xsd/cxx/parser/validator.hxx @@ -1,32 +1,28 @@ // file : xsd/cxx/parser/validator.hxx -// 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 #ifndef CXX_PARSER_VALIDATOR_HXX #define CXX_PARSER_VALIDATOR_HXX -#include -#include - #include +#include + +#include +#include namespace CXX { namespace Parser { - using namespace Cult::Types; - class Validator { public: - Validator (); // Dummy ctor, helps with long symbols on HP-UX. - - Boolean - validate (CLI::Options const& options, + bool + validate (options const&, SemanticGraph::Schema&, SemanticGraph::Path const& tu, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings); }; } diff --git a/xsd/xsd/cxx/tree/cli.hxx b/xsd/xsd/cxx/tree/cli.hxx deleted file mode 100644 index 171711d..0000000 --- a/xsd/xsd/cxx/tree/cli.hxx +++ /dev/null @@ -1,228 +0,0 @@ -// file : xsd/cxx/tree/cli.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_TREE_CLI_HXX -#define CXX_TREE_CLI_HXX - -#include - -#include - -#include -#include - -namespace CXX -{ - namespace Tree - { - namespace CLI - { - using namespace Cult::Types; - - typedef Char const Key[]; - - extern Key char_type; - extern Key char_encoding; - extern Key output_dir; - extern Key generate_polymorphic; - extern Key polymorphic_type; - extern Key polymorphic_type_all; - extern Key generate_serialization; - extern Key generate_inline; - extern Key generate_ostream; - extern Key generate_doxygen; - extern Key generate_comparison; - extern Key generate_default_ctor; - extern Key generate_from_base_ctor; - extern Key generate_detach; - extern Key generate_wildcard; - extern Key generate_insertion; - extern Key generate_extraction; - extern Key generate_forward; - extern Key generate_xml_schema; - extern Key extern_xml_schema; - extern Key suppress_parsing; - extern Key generate_element_type; - extern Key generate_element_map; - extern Key generate_intellisense; - extern Key omit_default_attributes; - extern Key namespace_map; - extern Key namespace_regex; - extern Key namespace_regex_trace; - extern Key reserved_name; - extern Key type_naming; - extern Key function_naming; - extern Key type_regex; - extern Key accessor_regex; - extern Key one_accessor_regex; - extern Key opt_accessor_regex; - extern Key seq_accessor_regex; - extern Key modifier_regex; - extern Key one_modifier_regex; - extern Key opt_modifier_regex; - extern Key seq_modifier_regex; - extern Key parser_regex; - extern Key serializer_regex; - extern Key enumerator_regex; - extern Key element_type_regex; - extern Key name_regex_trace; - extern Key include_with_brackets; - extern Key include_prefix; - extern Key include_regex; - extern Key include_regex_trace; - extern Key guard_prefix; - extern Key root_element_first; - extern Key root_element_last; - extern Key root_element_all; - extern Key root_element_none; - extern Key root_element; - extern Key custom_type; - extern Key custom_type_regex; - extern Key hxx_suffix; - extern Key ixx_suffix; - extern Key cxx_suffix; - extern Key fwd_suffix; - extern Key hxx_regex; - extern Key ixx_regex; - extern Key cxx_regex; - extern Key fwd_regex; - extern Key hxx_prologue; - extern Key ixx_prologue; - extern Key cxx_prologue; - extern Key fwd_prologue; - extern Key prologue; - extern Key hxx_epilogue; - extern Key ixx_epilogue; - extern Key cxx_epilogue; - extern Key fwd_epilogue; - extern Key epilogue; - extern Key hxx_prologue_file; - extern Key ixx_prologue_file; - extern Key cxx_prologue_file; - extern Key fwd_prologue_file; - extern Key prologue_file; - extern Key hxx_epilogue_file; - extern Key ixx_epilogue_file; - extern Key cxx_epilogue_file; - extern Key fwd_epilogue_file; - extern Key epilogue_file; - extern Key parts; - extern Key parts_suffix; - extern Key export_symbol; - extern Key export_xml_schema; - extern Key export_maps; - extern Key import_maps; - extern Key show_anonymous; - extern Key show_sloc; - extern Key proprietary_license; - extern Key disable_multi_import; // Undocumented. - - - typedef Cult::CLI::Options< - - char_type, NarrowString, - char_encoding, NarrowString, - output_dir, NarrowString, - generate_polymorphic, Boolean, - polymorphic_type, Cult::Containers::Vector, - polymorphic_type_all, Boolean, - generate_serialization, Boolean, - generate_inline, Boolean, - generate_ostream, Boolean, - generate_doxygen, Boolean, - generate_comparison, Boolean, - generate_default_ctor, Boolean, - generate_from_base_ctor, Boolean, - generate_detach, Boolean, - generate_wildcard, Boolean, - generate_insertion, Cult::Containers::Vector, - generate_extraction, Cult::Containers::Vector, - generate_forward, Boolean, - generate_xml_schema, Boolean, - extern_xml_schema, NarrowString, - suppress_parsing, Boolean, - generate_element_type, Boolean, - generate_element_map, Boolean, - generate_intellisense, Boolean, - omit_default_attributes, Boolean, - namespace_map, Cult::Containers::Vector, - namespace_regex, Cult::Containers::Vector, - namespace_regex_trace, Boolean, - reserved_name, Cult::Containers::Vector, - type_naming, NarrowString, - function_naming, NarrowString, - type_regex, Cult::Containers::Vector, - accessor_regex, Cult::Containers::Vector, - one_accessor_regex, Cult::Containers::Vector, - opt_accessor_regex, Cult::Containers::Vector, - seq_accessor_regex, Cult::Containers::Vector, - modifier_regex, Cult::Containers::Vector, - one_modifier_regex, Cult::Containers::Vector, - opt_modifier_regex, Cult::Containers::Vector, - seq_modifier_regex, Cult::Containers::Vector, - parser_regex, Cult::Containers::Vector, - serializer_regex, Cult::Containers::Vector, - enumerator_regex, Cult::Containers::Vector, - element_type_regex, Cult::Containers::Vector, - name_regex_trace, Boolean, - include_with_brackets, Boolean, - include_prefix, NarrowString, - include_regex, Cult::Containers::Vector, - include_regex_trace, Boolean, - guard_prefix, NarrowString, - root_element_first, Boolean, - root_element_last, Boolean, - root_element_all, Boolean, - root_element_none, Boolean, - root_element, Cult::Containers::Vector, - custom_type, Cult::Containers::Vector, - custom_type_regex, Cult::Containers::Vector, - hxx_suffix, NarrowString, - ixx_suffix, NarrowString, - cxx_suffix, NarrowString, - fwd_suffix, NarrowString, - hxx_regex, NarrowString, - ixx_regex, NarrowString, - cxx_regex, NarrowString, - fwd_regex, NarrowString, - hxx_prologue, Cult::Containers::Vector, - ixx_prologue, Cult::Containers::Vector, - cxx_prologue, Cult::Containers::Vector, - fwd_prologue, Cult::Containers::Vector, - prologue, Cult::Containers::Vector, - hxx_epilogue, Cult::Containers::Vector, - ixx_epilogue, Cult::Containers::Vector, - cxx_epilogue, Cult::Containers::Vector, - fwd_epilogue, Cult::Containers::Vector, - epilogue, Cult::Containers::Vector, - hxx_prologue_file, NarrowString, - ixx_prologue_file, NarrowString, - cxx_prologue_file, NarrowString, - fwd_prologue_file, NarrowString, - prologue_file, NarrowString, - hxx_epilogue_file, NarrowString, - ixx_epilogue_file, NarrowString, - cxx_epilogue_file, NarrowString, - fwd_epilogue_file, NarrowString, - epilogue_file, NarrowString, - parts, UnsignedLong, - parts_suffix, NarrowString, - export_symbol, NarrowString, - export_xml_schema, Boolean, - export_maps, Boolean, - import_maps, Boolean, - show_anonymous, Boolean, - show_sloc, Boolean, - proprietary_license, Boolean, - disable_multi_import, Boolean - - > Options; - - struct OptionsSpec: Cult::CLI::OptionsSpec {}; - } - } -} - -#endif // CXX_TREE_CLI_HXX diff --git a/xsd/xsd/cxx/tree/counter.cxx b/xsd/xsd/cxx/tree/counter.cxx index 9254226..23fc221 100644 --- a/xsd/xsd/cxx/tree/counter.cxx +++ b/xsd/xsd/cxx/tree/counter.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/tree/counter.cxx -// author : Boris Kolpackov -// 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 @@ -15,40 +14,40 @@ namespace CXX { struct Member: Traversal::Member { - Member (UnsignedLong& complexity) + Member (size_t& complexity) : complexity_ (complexity) { } - virtual Void + virtual void traverse (Type&) { complexity_++; } - UnsignedLong& complexity_; + size_t& complexity_; }; struct Any: Traversal::Any, Traversal::AnyAttribute { - Any (UnsignedLong& complexity) + Any (size_t& complexity) : complexity_ (complexity) { } - virtual Void + virtual void traverse (SemanticGraph::Any&) { complexity_++; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute&) { complexity_++; } - UnsignedLong& complexity_; + size_t& complexity_; }; struct TypeBase: Traversal::List, @@ -57,27 +56,27 @@ namespace CXX Traversal::Complex, Context { - TypeBase (Context& c, UnsignedLong& complexity) + TypeBase (Context& c, size_t& complexity) : Context (c), complexity_ (complexity) { } - virtual Void + virtual void traverse (SemanticGraph::List&) { complexity_++; } - virtual Void + virtual void traverse (SemanticGraph::Union&) { complexity_++; } - virtual Void + virtual void traverse (SemanticGraph::Enumeration& e) { - Boolean string_based (false); + bool string_based (false); { IsStringBasedType t (string_based); t.dispatch (e); @@ -86,7 +85,7 @@ namespace CXX complexity_ += (string_based ? 1 : 2); } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { complexity_++; // One for the type itself. @@ -99,14 +98,14 @@ namespace CXX names >> member; - if (options.value ()) + if (options.generate_wildcard ()) names >> any; Complex::names (c, names); } private: - UnsignedLong& complexity_; + size_t& complexity_; }; @@ -120,12 +119,12 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { counts_.global_types++; - UnsignedLong complexity (0); + size_t complexity (0); TypeBase type (*this, complexity); type.dispatch (t); @@ -160,7 +159,7 @@ namespace CXX } } - virtual Void + virtual void traverse (Type& e) { // Check if the previous element we saw needs to be generated. @@ -177,33 +176,33 @@ namespace CXX } private: - Void + void count_last () { if (generate_p (*last_)) { counts_.generated_global_elements++; - UnsignedLong complexity (0); + size_t complexity (0); if (doc_root_p (*last_)) { - if (options.value ()) + if (options.generate_element_type ()) { complexity += 1; // For c-tors and d-tor. - if (!options.value ()) + if (!options.suppress_parsing ()) complexity += 1; - if (options.value ()) + if (options.generate_serialization ()) complexity += 1; } else { - if (!options.value ()) + if (!options.suppress_parsing ()) complexity += 6; // 13 parsing functions. - if (options.value ()) + if (options.generate_serialization ()) complexity += 4; // 8 serialization functions. } } @@ -230,21 +229,16 @@ namespace CXX }; } - Counter:: - Counter () - { - } - Counts Counter:: - count (CLI::Options const& options, + count (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& path) { Counts counts; - Context ctx (std::wcerr, tu, path, options, counts, false, 0, 0, 0, 0); + Context ctx (std::wcerr, tu, path, ops, counts, false, 0, 0, 0, 0); Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; diff --git a/xsd/xsd/cxx/tree/counter.hxx b/xsd/xsd/cxx/tree/counter.hxx index 726de47..ea1a3c3 100644 --- a/xsd/xsd/cxx/tree/counter.hxx +++ b/xsd/xsd/cxx/tree/counter.hxx @@ -1,13 +1,12 @@ // file : xsd/cxx/tree/counter.hxx -// author : Boris Kolpackov -// 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 #ifndef CXX_TREE_COUNTER_HXX #define CXX_TREE_COUNTER_HXX #include -#include +#include namespace CXX { @@ -16,10 +15,8 @@ namespace CXX class Counter { public: - Counter (); // Dummy ctor, helps with long symbols on HP-UX. - Counts - count (CLI::Options const&, + count (options const&, SemanticGraph::Schema&, SemanticGraph::Path const&); }; diff --git a/xsd/xsd/cxx/tree/default-value.cxx b/xsd/xsd/cxx/tree/default-value.cxx index ff964d3..4f27d7f 100644 --- a/xsd/xsd/cxx/tree/default-value.cxx +++ b/xsd/xsd/cxx/tree/default-value.cxx @@ -1,11 +1,11 @@ // file : xsd/cxx/tree/default-value.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 using std::hex; +using std::dec; namespace CXX { @@ -13,14 +13,14 @@ namespace CXX { namespace { - Void + void normalize (String& s) { - Size n (s.size ()); + size_t n (s.size ()); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - WideChar& c (s[i]); + wchar_t& c (s[i]); if (c == 0x0D || // carriage return c == 0x09 || // tab @@ -29,15 +29,15 @@ namespace CXX } } - Void + void collapse (String& s) { - Size n (s.size ()), j (0); - Boolean subs (false), trim (true); + size_t n (s.size ()), j (0); + bool subs (false), trim (true); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { - WideChar c (s[i]); + wchar_t c (s[i]); if (c == 0x20 || c == 0x09 || c == 0x0A) subs = true; @@ -61,21 +61,21 @@ namespace CXX s.resize (j); } - Void + void strip_zeros (String& s) { - Size n (s.size ()), i (0); + size_t n (s.size ()), i (0); if (n > 0 && (s[i] == '-' || s[i] == '+')) i++; - Size j (i); + size_t j (i); - Boolean strip (true); + bool strip (true); for (; i < n; ++i) { - WideChar c (s[i]); + wchar_t c (s[i]); if (c == '0') { @@ -97,7 +97,7 @@ namespace CXX s.resize (j); } - Void + void make_float (String& s) { if (s.find ('.') == String::npos && @@ -112,13 +112,13 @@ namespace CXX // IsLiteralValue:: - IsLiteralValue (Boolean& r) + IsLiteralValue (bool& r) : IsFundamentalType (r) { *this >> inherits_ >> *this; } - Void IsLiteralValue:: + void IsLiteralValue:: traverse (SemanticGraph::Complex& c) { inherits (c); @@ -144,7 +144,7 @@ namespace CXX return literal_; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Complex& c) { inherits (c); @@ -152,7 +152,7 @@ namespace CXX // Boolean. // - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Boolean&) { collapse (value_); @@ -161,7 +161,7 @@ namespace CXX // Integral types. // - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Byte&) { collapse (value_); @@ -169,15 +169,15 @@ namespace CXX literal_ = value_; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::UnsignedByte&) { collapse (value_); strip_zeros (value_); - literal_ = value_; + literal_ = value_ + L"U"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Short&) { collapse (value_); @@ -185,15 +185,15 @@ namespace CXX literal_ = value_; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::UnsignedShort&) { collapse (value_); strip_zeros (value_); - literal_ = value_; + literal_ = value_ + L"U"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Int&) { collapse (value_); @@ -201,15 +201,15 @@ namespace CXX literal_ = value_; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::UnsignedInt&) { collapse (value_); strip_zeros (value_); - literal_ = value_; + literal_ = value_ + L"U"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Long&) { collapse (value_); @@ -218,7 +218,7 @@ namespace CXX literal_ += L"LL"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::UnsignedLong&) { collapse (value_); @@ -227,7 +227,7 @@ namespace CXX literal_ += L"ULL"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Integer&) { collapse (value_); @@ -235,7 +235,7 @@ namespace CXX literal_ = value_ + L"LL"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::NonPositiveInteger&) { collapse (value_); @@ -243,7 +243,7 @@ namespace CXX literal_ = value_ + L"LL"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::NonNegativeInteger&) { collapse (value_); @@ -251,7 +251,7 @@ namespace CXX literal_ = value_ + L"ULL"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::PositiveInteger&) { collapse (value_); @@ -259,7 +259,7 @@ namespace CXX literal_ = value_ + L"ULL"; } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::NegativeInteger&) { collapse (value_); @@ -269,7 +269,7 @@ namespace CXX // Floats. // - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Float& t) { collapse (value_); @@ -297,7 +297,7 @@ namespace CXX } } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Double& t) { collapse (value_); @@ -325,7 +325,7 @@ namespace CXX } } - Void LiteralValue:: + void LiteralValue:: traverse (SemanticGraph::Fundamental::Decimal&) { collapse (value_); @@ -345,43 +345,43 @@ namespace CXX *this >> inherits_ >> *this; } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::List&) { r_ = function; } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::Complex& c) { inherits (c); } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::Fundamental::Base64Binary&) { r_ = data; } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::Fundamental::HexBinary&) { r_ = data; } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::Fundamental::NameTokens&) { r_ = function; } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::Fundamental::IdRefs&) { r_ = function; } - Void InitKind:: + void InitKind:: traverse (SemanticGraph::Fundamental::Entities&) { r_ = function; @@ -397,14 +397,14 @@ namespace CXX { } - Void InitValue:: + void InitValue:: dispatch (SemanticGraph::Node& type, String const& value) { value_ = value; Traversal::NodeBase::dispatch (type); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::List& l) { collapse (value_); @@ -415,9 +415,9 @@ namespace CXX SemanticGraph::Type& t (l.argumented ().type ()); String ov (value_); - Size b (0); + size_t b (0); - for (Size e (ov.find (' ')); ; e = ov.find (' ', b)) + for (size_t e (ov.find (' ')); ; e = ov.find (' ', b)) { String v (ov, b, e != String::npos ? e - b : e); @@ -448,21 +448,27 @@ namespace CXX value_ = ov; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Union&) { os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Complex& c) { Traversal::NodeBase::dispatch (ultimate_base (c)); } - // anySimpleType. + // anyType & anySimpleType. // - Void InitValue:: + void InitValue:: + traverse (SemanticGraph::AnyType& t) + { + os << fq_name (t) << " (" << strlit (value_) << ")"; + } + + void InitValue:: traverse (SemanticGraph::AnySimpleType& t) { os << fq_name (t) << " (" << strlit (value_) << ")"; @@ -470,34 +476,34 @@ namespace CXX // Strings. // - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::String&) { os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::NormalizedString&) { normalize (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Token&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::NameToken&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::NameTokens&) { string_sequence_type ( @@ -505,21 +511,21 @@ namespace CXX xs_ns ().find ("NMTOKEN").first->named ())); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Name&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::NCName&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Language&) { collapse (value_); @@ -528,10 +534,10 @@ namespace CXX // Qualified name. // - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::QName& t) { - Size p (value_.rfind ('#')); + size_t p (value_.rfind ('#')); if (p != String::npos) { @@ -563,21 +569,21 @@ namespace CXX // ID/IDREF. // - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Id&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::IdRef&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::IdRefs&) { string_sequence_type ( @@ -587,7 +593,7 @@ namespace CXX // URI. // - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::AnyURI&) { collapse (value_); @@ -615,7 +621,7 @@ namespace CXX return r; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Base64Binary& t) { collapse (value_); @@ -628,17 +634,17 @@ namespace CXX // Decode. // - Size size (value_.size ()); + size_t size (value_.size ()); // Remove all whitespaces. // { - Size j (0); - Boolean subs (false); + size_t j (0); + bool subs (false); - for (Size i (0); i < size; ++i) + for (size_t i (0); i < size; ++i) { - WideChar c (value_[i]); + wchar_t c (value_[i]); if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09) subs = true; @@ -657,20 +663,20 @@ namespace CXX // Our length should be a multiple of four. // - Size quad_count (size / 4); + size_t quad_count (size / 4); // Source and destination indexes. // - Size si (0), di (0); + size_t si (0), di (0); // Process all quads except the last one. // unsigned short v; unsigned char b1, b2, b3, b4; - WideChar prev_fill (os.fill ('0')); + wchar_t prev_fill (os.fill ('0')); - for (Size q (0); q < quad_count - 1; ++q) + for (size_t q (0); q < quad_count - 1; ++q) { b1 = base64_decode (value_[si++]); b2 = base64_decode (value_[si++]); @@ -683,17 +689,21 @@ namespace CXX if (di % 9 == 0) os << endl; + os << hex; + v = static_cast ((b1 << 2) | (b2 >> 4)); os.width (2); - os << "0x" << hex << v; + os << "0x" << v; v = static_cast ((b2 << 4) | (b3 >> 2)); os.width (2); - os << ", 0x" << hex << v; + os << ", 0x" << v; v = static_cast ((b3 << 6) | b4); os.width (2); - os << ", 0x" << hex << v; + os << ", 0x" << v; + + os << dec; di += 3; } @@ -703,7 +713,7 @@ namespace CXX b1 = base64_decode (value_[si++]); b2 = base64_decode (value_[si++]); - WideChar e3 (value_[si++]), e4 (value_[si++]); + wchar_t e3 (value_[si++]), e4 (value_[si++]); if (quad_count != 1) os << ", "; @@ -718,7 +728,7 @@ namespace CXX // Two pads. Last 4 bits in b2 should be zero. // v = static_cast ((b1 << 2) | (b2 >> 4)); - os << "0x" << hex << v; + os << "0x" << hex << v << dec; di++; } else @@ -727,13 +737,17 @@ namespace CXX // b3 = base64_decode (e3); + os << hex; + v = static_cast ((b1 << 2) | (b2 >> 4)); os.width (2); - os << "0x" << hex << v; + os << "0x" << v; v = static_cast ((b2 << 4) | (b3 >> 2)); os.width (2); - os << ", 0x" << hex << v; + os << ", 0x" << v; + + os << dec; di += 2; } @@ -745,17 +759,21 @@ namespace CXX b3 = base64_decode (e3); b4 = base64_decode (e4); + os << hex; + v = static_cast ((b1 << 2) | (b2 >> 4)); os.width (2); - os << "0x" << hex << v; + os << "0x" << v; v = static_cast ((b2 << 4) | (b3 >> 2)); os.width (2); - os << ", 0x" << hex << v; + os << ", 0x" << v; v = static_cast ((b3 << 6) | b4); os.width (2); - os << ", 0x" << hex << v; + os << ", 0x" << v; + + os << dec; di += 3; } @@ -797,7 +815,7 @@ namespace CXX return r; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::HexBinary& t) { collapse (value_); @@ -810,10 +828,10 @@ namespace CXX // Decode. // - Size n (value_.size () / 2); - WideChar prev_fill (os.fill ('0')); + size_t n (value_.size () / 2); + wchar_t prev_fill (os.fill ('0')); - for (Size i (0); i < n; ++i) + for (size_t i (0); i < n; ++i) { unsigned char h (hex_decode (value_[2 * i])); unsigned char l (hex_decode (value_[2 * i + 1])); @@ -829,7 +847,7 @@ namespace CXX unsigned short v = static_cast ((h << 4) | l); os.width (2); - os << "0x" << hex << v; + os << "0x" << hex << v << dec; } os.fill (prev_fill); @@ -856,15 +874,15 @@ namespace CXX // Date/time. // - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Date& t) { // date := [-]CCYY[N]*-MM-DD[Z|(+|-)HH:MM] // collapse (value_); - Size b (0); - Size e (value_.find ('-', value_[0] == '-' ? 5 : 4)); + size_t b (0); + size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4)); String year (value_, 0, e); b = e + 1; @@ -882,15 +900,15 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::DateTime& t) { // date_time := [-]CCYY[N]*-MM-DDTHH:MM:SS[.S+][Z|(+|-)HH:MM] // collapse (value_); - Size b (0); - Size e (value_.find ('-', value_[0] == '-' ? 5 : 4)); + size_t b (0); + size_t e (value_.find ('-', value_[0] == '-' ? 5 : 4)); String year (value_, 0, e); b = e + 1; @@ -909,7 +927,7 @@ namespace CXX e = b + 2; for (; e < value_.size (); ++e) { - WideChar c (value_[e]); + wchar_t c (value_[e]); if (c == 'Z' || c == '+' || c == '-') break; @@ -934,12 +952,12 @@ namespace CXX namespace { - Size - find_delim (String const& s, Size pos) + size_t + find_delim (String const& s, size_t pos) { for (; pos < s.size (); ++pos) { - WideChar c (s[pos]); + wchar_t c (s[pos]); if (c == 'Y' || c == 'D' || c == 'M' || c == 'H' || c == 'M' || c == 'S' || c == 'T') @@ -950,14 +968,14 @@ namespace CXX } } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Duration& t) { // duration := [-]P[nY][nM][nD][TnHnMn[.n+]S] // collapse (value_); - Size b (1), e, n (value_.size ()); + size_t b (1), e, n (value_.size ()); os << fq_name (t) << " ("; @@ -1053,7 +1071,7 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Day& t) { // gday := ---DD[Z|(+|-)HH:MM] @@ -1068,7 +1086,7 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Month& t) { // gmonth := --MM[Z|(+|-)HH:MM] @@ -1083,7 +1101,7 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::MonthDay& t) { // gmonth_day := --MM-DD[Z|(+|-)HH:MM] @@ -1101,17 +1119,17 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Year& t) { // gyear := [-]CCYY[N]*[Z|(+|-)HH:MM] // collapse (value_); - Size pos (value_[0] == '-' ? 5 : 4); + size_t pos (value_[0] == '-' ? 5 : 4); for (; pos < value_.size (); ++pos) { - WideChar c (value_[pos]); + wchar_t c (value_[pos]); if (c == 'Z' || c == '+' || c == '-') break; @@ -1125,14 +1143,14 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::YearMonth& t) { // gyear_month := [-]CCYY[N]*-MM[Z|(+|-)HH:MM] // collapse (value_); - Size pos (value_.find ('-', value_[0] == '-' ? 5 : 4)); + size_t pos (value_.find ('-', value_[0] == '-' ? 5 : 4)); String year (value_, 0, pos); String month (value_, pos + 1, 2); @@ -1145,7 +1163,7 @@ namespace CXX os << ")"; } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Time& t) { // time := HH:MM:SS[.S+][Z|(+|-)HH:MM] @@ -1155,10 +1173,10 @@ namespace CXX String hours (value_, 0, 2); String minutes (value_, 3, 2); - Size e (8); + size_t e (8); for (; e < value_.size (); ++e) { - WideChar c (value_[e]); + wchar_t c (value_[e]); if (c == 'Z' || c == '+' || c == '-') break; @@ -1176,8 +1194,8 @@ namespace CXX os << ")"; } - Void InitValue:: - time_zone (Size pos) + void InitValue:: + time_zone (size_t pos) { // time_zone := Z|(+|-)HH:MM // @@ -1211,14 +1229,14 @@ namespace CXX // Entity. // - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Entity&) { collapse (value_); os << strlit (value_); } - Void InitValue:: + void InitValue:: traverse (SemanticGraph::Fundamental::Entities&) { string_sequence_type ( @@ -1226,7 +1244,7 @@ namespace CXX xs_ns ().find ("ENTITY").first->named ())); } - Void InitValue:: + void InitValue:: string_sequence_type (SemanticGraph::Type& t) { collapse (value_); @@ -1234,9 +1252,9 @@ namespace CXX if (!value_) return; - Size b (0); + size_t b (0); - for (Size e (value_.find (' ')); ; e = value_.find (' ', b)) + for (size_t e (value_.find (' ')); ; e = value_.find (' ', b)) { String v (value_, b, e != String::npos ? e - b : e); diff --git a/xsd/xsd/cxx/tree/default-value.hxx b/xsd/xsd/cxx/tree/default-value.hxx index c80132e..eb91a8c 100644 --- a/xsd/xsd/cxx/tree/default-value.hxx +++ b/xsd/xsd/cxx/tree/default-value.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/tree/default-value.hxx -// 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 #ifndef CXX_TREE_DEFAULT_VALUE_HXX @@ -17,9 +16,9 @@ namespace CXX { struct IsLiteralValue: IsFundamentalType, Traversal::Complex { - IsLiteralValue (Boolean& r); + IsLiteralValue (bool& r); - virtual Void + virtual void traverse (SemanticGraph::Complex&); private: @@ -57,64 +56,64 @@ namespace CXX // Handle inheritance. // - virtual Void + virtual void traverse (SemanticGraph::Complex&); // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean&); // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger&); // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal&); private: @@ -148,25 +147,25 @@ namespace CXX // InitKind (Kind& r); - virtual Void + virtual void traverse (SemanticGraph::List&); - virtual Void + virtual void traverse (SemanticGraph::Complex&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities&); private: @@ -178,6 +177,7 @@ namespace CXX Traversal::Union, Traversal::Complex, + Traversal::AnyType, Traversal::AnySimpleType, Traversal::Fundamental::String, @@ -217,133 +217,136 @@ namespace CXX { InitValue (Context&); - Void + void data (String const& data) { data_ = data; dispatch_count_ = 0; } - Void + void dispatch (SemanticGraph::Node& type, String const& value); - virtual Void + virtual void traverse (SemanticGraph::List&); - virtual Void + virtual void traverse (SemanticGraph::Union&); - virtual Void + virtual void traverse (SemanticGraph::Complex&); - // anySimpleType. + // anyType & anySimpleType. // - virtual Void + virtual void + traverse (SemanticGraph::AnyType&); + + virtual void traverse (SemanticGraph::AnySimpleType&); // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language&); // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName&); // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs&); // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI&); // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary&); // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time&); // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity&); - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities&); private: - Void + void string_sequence_type (SemanticGraph::Type& element_type); - Void - time_zone (Size pos); + void + time_zone (size_t pos); private: String value_; String data_; - Size dispatch_count_; + size_t dispatch_count_; MemberTypeName type_name_; LiteralValue literal_value_; }; diff --git a/xsd/xsd/cxx/tree/elements.cxx b/xsd/xsd/cxx/tree/elements.cxx index cad5a33..202ab62 100644 --- a/xsd/xsd/cxx/tree/elements.cxx +++ b/xsd/xsd/cxx/tree/elements.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/tree/elements.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 @@ -11,55 +10,18 @@ namespace CXX { // Context // - Void Context:: - update_ns_scope () // Keeping this function first helps HP-UX - { // (long symbols). - ns_scope.clear (); - - Boolean first (true); - - for (NamespaceStack::Iterator i (ns_scope_stack.begin ()); - i != ns_scope_stack.end (); - ++i) - { - // We only qualify names until the namespace level. - // - if (first) - first = false; - else - ns_scope += L"::"; - - ns_scope += *i; - } - } - Context:: Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& ops, + options_type const& ops, Counts const& counts_, - Boolean generate_xml_schema__, + bool generate_xml_schema__, StringLiteralMap const* map, Regex const* fe, Regex const* he, Regex const* ie) - : CXX::Context (o, - root, - path, - map, - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value ()), + : CXX::Context (o, root, path, ops, map), options (ops), counts (counts_), any_type (any_type_), @@ -84,9 +46,10 @@ namespace CXX as_decimal_type (as_decimal_type_), generate_xml_schema (generate_xml_schema_), doxygen (doxygen_), - polymorphic (ops.value ()), - polymorphic_all (ops.value ()), - detach (ops.value ()), + polymorphic (ops.generate_polymorphic ()), + polymorphic_all (ops.polymorphic_type_all ()), + poly_plate (ops.polymorphic_plate ()), + detach (ops.generate_detach ()), fwd_expr (fe), hxx_expr (he), ixx_expr (ie), @@ -96,7 +59,7 @@ namespace CXX qname_type_ (L"::xsd::cxx::xml::qualified_name< " + char_type + L" >"), parser_type_ (L"::xsd::cxx::xml::dom::parser< " + char_type + L" >"), generate_xml_schema_ (generate_xml_schema__), - doxygen_ (ops.value ()), + doxygen_ (ops.generate_doxygen ()), ns_scope_stack (ns_scope_stack_), cxx_uq_id_expr_ (L"^[a-zA-Z_]\\w*$"), cxx_uq_id_expr (cxx_uq_id_expr_) @@ -118,23 +81,25 @@ namespace CXX container = xs_name + L"::" + xsc.get ("container"); flags_type = xs_name + L"::" + xsc.get ("flags"); - if (ops.value ()) + if (ops.generate_element_type ()) element_type = xs_name + L"::" + xsc.get ("element-type"); properties_type = xs_name + L"::" + xsc.get ("properties"); - if (!ops.value () || - ops.value ()) + if (!ops.suppress_parsing () || ops.generate_serialization ()) { error_handler_type = xs_name + L"::" + xsc.get ("error-handler"); } - dom_auto_ptr_ = xs_name + L"::dom::auto_ptr"; + dom_auto_ptr_ = xs_name + (std >= cxx_version::cxx11 + ? L"::dom::unique_ptr" + : L"::dom::auto_ptr"); + dom_node_key_ = xs_name + L"::dom::" + xsc.get ("tree-node-key"); - if (ops.value ()) + if (ops.generate_serialization ()) { as_double_type_ = xs_name + L"::" + xsc.get ("as-double"); @@ -152,17 +117,17 @@ namespace CXX // istream and ostream are templates and for now use the same // names regardless of the naming convention. // - if (!ops.value ().empty ()) + if (!ops.generate_extraction ().empty ()) istream_type = xs_name + L"::istream"; - if (!ops.value ().empty ()) + if (!ops.generate_insertion ().empty ()) ostream_type = xs_name + L"::ostream"; } // Xerces-C++ namespace. IntelliSense for some reason does not like // it fully-qualified (maybe because it's a namespace alias). // - if (ops.value ()) + if (ops.generate_intellisense ()) xerces_ns = "xercesc"; else xerces_ns = "::xercesc"; @@ -178,14 +143,14 @@ namespace CXX // Custom type mapping. // - typedef Containers::Vector Vector; // Direct custom type mapping. // { - Vector const& v (ops.value ()); + NarrowStrings const& v (ops.custom_type ()); - for (Vector::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (v.begin ()), + e (v.end ()); i != e; ++i) { String s (*i); @@ -194,7 +159,7 @@ namespace CXX // Split the string in two parts at the last '='. // - Size pos (s.rfind ('=')); + size_t pos (s.rfind ('=')); // If no delimiter found then both type and base are empty. // @@ -237,20 +202,21 @@ namespace CXX // Regex custom type mapping. // { - Vector const& v (ops.value ()); + NarrowStrings const& v (ops.custom_type_regex ()); - for (Vector::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (v.begin ()), + e (v.end ()); i != e; ++i) { String s (*i); if (s.empty ()) throw InvalidCustomTypeMapping (s, "mapping string is empty"); - WideChar delimiter (s[0]); + wchar_t delimiter (s[0]); // First get pattern. // - Size pos (s.find (delimiter, 1)); + size_t pos (s.find (delimiter, 1)); if (pos == String::npos) throw InvalidCustomTypeMapping ( @@ -291,7 +257,7 @@ namespace CXX } regex_custom_type_map.push_back ( - RegexCustomTypeMapInfo (pat, type, base)); + RegexCustomTypeMapInfo (WideRegexPat (pat), type, base)); } } } @@ -325,6 +291,7 @@ namespace CXX doxygen (c.doxygen), polymorphic (c.polymorphic), polymorphic_all (c.polymorphic_all), + poly_plate (c.poly_plate), detach (c.detach), fwd_expr (c.fwd_expr), hxx_expr (c.hxx_expr), @@ -366,6 +333,7 @@ namespace CXX doxygen (c.doxygen), polymorphic (c.polymorphic), polymorphic_all (c.polymorphic_all), + poly_plate (c.poly_plate), detach (c.detach), fwd_expr (c.fwd_expr), hxx_expr (c.hxx_expr), @@ -378,7 +346,29 @@ namespace CXX { } - Boolean Context:: + void Context:: + update_ns_scope () + { + ns_scope.clear (); + + bool first (true); + + for (NamespaceStack::iterator i (ns_scope_stack.begin ()); + i != ns_scope_stack.end (); + ++i) + { + // We only qualify names until the namespace level. + // + if (first) + first = false; + else + ns_scope += L"::"; + + ns_scope += *i; + } + } + + bool Context:: custom_type (SemanticGraph::Type const& t, String& r) const { String const& name (t.name ()); @@ -386,7 +376,7 @@ namespace CXX // First search the direct mapping. // { - DirectCustomTypeMap::ConstIterator i ( + DirectCustomTypeMap::const_iterator i ( direct_custom_type_map.find (name)); if (i != direct_custom_type_map.end ()) @@ -399,7 +389,7 @@ namespace CXX // Second search the regex mapping. // - for (RegexCustomTypeMap::ConstIterator + for (RegexCustomTypeMap::const_iterator i (regex_custom_type_map.begin ()), e (regex_custom_type_map.end ()); i != e; ++i) @@ -414,7 +404,7 @@ namespace CXX return true; } - r = i->pat.merge (i->type_sub, name); + r = i->pat.replace (name, i->type_sub); return true; } } @@ -437,7 +427,7 @@ namespace CXX return r; } - Boolean Context:: + bool Context:: renamed_type (SemanticGraph::Type const& t, String& r) const { String const& name (t.name ()); @@ -445,7 +435,7 @@ namespace CXX // First search the direct mapping. // { - DirectCustomTypeMap::ConstIterator i ( + DirectCustomTypeMap::const_iterator i ( direct_custom_type_map.find (name)); if (i != direct_custom_type_map.end ()) @@ -458,7 +448,7 @@ namespace CXX // Second search the regex mapping. // - for (RegexCustomTypeMap::ConstIterator + for (RegexCustomTypeMap::const_iterator i (regex_custom_type_map.begin ()), e (regex_custom_type_map.end ()); i != e; ++i) @@ -467,7 +457,7 @@ namespace CXX { if (!i->base_sub.empty ()) { - r = i->pat.merge (i->base_sub, name); + r = i->pat.replace (name, i->base_sub); } else r.clear (); @@ -479,17 +469,17 @@ namespace CXX return false; } - Void Context:: + void Context:: write_annotation (SemanticGraph::Annotation& a) { String const& doc (a.documentation ()); - WideChar const* s (doc.c_str ()); - Size size (doc.size ()); + wchar_t const* s (doc.c_str ()); + size_t size (doc.size ()); // Remove leading and trailing whitespaces. // - while (*s == WideChar (0x20) || *s == WideChar (0x0A) || - *s == WideChar (0x0D) || *s == WideChar (0x09)) + while (*s == wchar_t (0x20) || *s == wchar_t (0x0A) || + *s == wchar_t (0x0D) || *s == wchar_t (0x09)) { s++; size--; @@ -497,11 +487,11 @@ namespace CXX if (size != 0) { - WideChar const* e (s + size - 1); + wchar_t const* e (s + size - 1); while (e > s && - (*e == WideChar (0x20) || *e == WideChar (0x0A) || - *e == WideChar (0x0D) || *e == WideChar (0x09))) + (*e == wchar_t (0x20) || *e == wchar_t (0x0A) || + *e == wchar_t (0x0D) || *e == wchar_t (0x09))) --e; size = s <= e ? e - s + 1 : 0; @@ -514,15 +504,15 @@ namespace CXX // Go over the data, forcing newline after 80 chars and adding // ' * ' after each new line. // - WideChar const* last_space (0); - WideChar const* b (s); - WideChar const* e (s); - Boolean after_newline (false); - Boolean rogue (false); + wchar_t const* last_space (0); + wchar_t const* b (s); + wchar_t const* e (s); + bool after_newline (false); + bool rogue (false); for (; e < s + size; ++e) { - UnsignedLong u (unicode_char (e)); // May advance e. + unsigned int u (unicode_char (e)); // May advance e. // We are going to treat \v and \f as rogue here even though // they can be present in C++ source code. @@ -579,16 +569,16 @@ namespace CXX } } - Void Context:: - write_rogue_text (WideChar const* s, Size size, Boolean rogue) + void Context:: + write_rogue_text (wchar_t const* s, size_t size, bool rogue) { if (!rogue) os.write (s, size); else { - for (WideChar const* p (s); p < s + size; ++p) + for (wchar_t const* p (s); p < s + size; ++p) { - UnsignedLong u (unicode_char (p)); // May advance p. + unsigned int u (unicode_char (p)); // May advance p. // We are going to treat \v and \f as rogue here even though // they can be present in C++ source code. @@ -596,36 +586,69 @@ namespace CXX if (u > 127 || (u < 32 && u != '\t' && u != '\n')) os.put ('?'); else - os.put (static_cast (u)); + os.put (static_cast (u)); } } } - Boolean Context:: + bool Context:: polymorphic_p (SemanticGraph::Type& t) { + // IDREF templates cannot be polymorphic. + // + if (!t.named_p () && + (t.is_a () || + t.is_a ())) + return false; + if (polymorphic_all) { - Boolean fund (false); + bool fund (false); IsFundamentalType test (fund); test.dispatch (t); return !fund; } else - return t.context ().get ("polymorphic"); + return t.context ().get ("polymorphic"); + } + + bool Context:: + anonymous_substitutes_p (SemanticGraph::Type& t) + { + // IDREF templates cannot match. + // + if (!t.named_p () && + (t.is_a () || + t.is_a ())) + return false; + + // See which elements this type classifies. + // + for (SemanticGraph::Type::ClassifiesIterator i (t.classifies_begin ()), + e (t.classifies_end ()); i != e; ++i) + { + if (SemanticGraph::Element* e = + dynamic_cast (&i->instance ())) + { + if (e->substitutes_p ()) + return true; + } + } + + return false; } // GenerateDefautCtor // GenerateDefaultCtor:: - GenerateDefaultCtor (Context& c, Boolean& generate, Boolean no_base) + GenerateDefaultCtor (Context& c, bool& generate, bool no_base) : Context (c), generate_ (generate), no_base_ (no_base) { *this >> inherits_ >> *this; *this >> names_ >> *this; } - Void GenerateDefaultCtor:: + void GenerateDefaultCtor:: traverse (SemanticGraph::Complex& c) { // Make sure we figure out if we have any required members before @@ -637,38 +660,38 @@ namespace CXX Complex::inherits (c, inherits_); } - Void GenerateDefaultCtor:: + void GenerateDefaultCtor:: traverse (SemanticGraph::Type&) { if (!no_base_) generate_ = true; } - Void GenerateDefaultCtor:: + void GenerateDefaultCtor:: traverse (SemanticGraph::Enumeration&) { if (!no_base_) generate_ = true; } - Void GenerateDefaultCtor:: + void GenerateDefaultCtor:: traverse (SemanticGraph::Element& e) { if (!skip (e) && min (e) == 1 && max (e) == 1) generate_ = true; } - Void GenerateDefaultCtor:: + void GenerateDefaultCtor:: traverse (SemanticGraph::Attribute& a) { if (min (a) == 1 && !a.fixed_p ()) generate_ = true; } - Void GenerateDefaultCtor:: + void GenerateDefaultCtor:: traverse (SemanticGraph::Any& a) { - if (options.value () && + if (options.generate_wildcard () && min (a) == 1 && max (a) == 1) generate_ = true; } @@ -677,7 +700,7 @@ namespace CXX // GenerateFromBaseCtor // GenerateFromBaseCtor:: - GenerateFromBaseCtor (Context& c, Boolean& generate) + GenerateFromBaseCtor (Context& c, bool& generate) : generate_ (generate), custom_ (false), traverser_ (c, generate, custom_) @@ -685,7 +708,7 @@ namespace CXX inherits_ >> traverser_; } - Void GenerateFromBaseCtor:: + void GenerateFromBaseCtor:: traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -703,14 +726,14 @@ namespace CXX } GenerateFromBaseCtor::Traverser:: - Traverser (Context& c, Boolean& generate, Boolean& custom) + Traverser (Context& c, bool& generate, bool& custom) : Context (c), generate_ (generate), custom_ (custom) { *this >> inherits_ >> *this; *this >> names_ >> *this; } - Void GenerateFromBaseCtor::Traverser:: + void GenerateFromBaseCtor::Traverser:: traverse (SemanticGraph::Type& t) { if (!custom_) @@ -720,7 +743,7 @@ namespace CXX } } - Void GenerateFromBaseCtor::Traverser:: + void GenerateFromBaseCtor::Traverser:: traverse (SemanticGraph::Complex& c) { names (c, names_); @@ -732,24 +755,24 @@ namespace CXX traverse (static_cast (c)); } - Void GenerateFromBaseCtor::Traverser:: + void GenerateFromBaseCtor::Traverser:: traverse (SemanticGraph::Element& e) { if (!skip (e) && min (e) == 1 && max (e) == 1) generate_ = true; } - Void GenerateFromBaseCtor::Traverser:: + void GenerateFromBaseCtor::Traverser:: traverse (SemanticGraph::Attribute& a) { if (min (a) == 1 && !a.fixed_p ()) generate_ = true; } - Void GenerateFromBaseCtor::Traverser:: + void GenerateFromBaseCtor::Traverser:: traverse (SemanticGraph::Any& a) { - if (options.value () && + if (options.generate_wildcard () && min (a) == 1 && max (a) == 1) generate_ = true; } @@ -758,10 +781,10 @@ namespace CXX // HasComplexPolyNonOptArgs:: HasComplexPolyNonOptArgs (Context& c, - Boolean base, - Boolean& complex, - Boolean& poly, - Boolean& clash) + bool base, + bool& complex, + bool& poly, + bool& clash) : Context (c), complex_ (complex), poly_ (poly), @@ -773,7 +796,7 @@ namespace CXX *this >> names_ >> *this; } - Void HasComplexPolyNonOptArgs:: + void HasComplexPolyNonOptArgs:: traverse (SemanticGraph::Complex& c) { // No optimizations: need to check every arg for clashes. @@ -782,14 +805,14 @@ namespace CXX names (c, names_); } - Void HasComplexPolyNonOptArgs:: + void HasComplexPolyNonOptArgs:: traverse (SemanticGraph::Element& e) { if (!skip (e) && min (e) == 1 && max (e) == 1) { - Boolean poly (polymorphic && polymorphic_p (e.type ())); + bool poly (polymorphic && polymorphic_p (e.type ())); - Boolean simple (true); + bool simple (true); IsSimpleType t (simple); t.dispatch (e.type ()); @@ -807,15 +830,15 @@ namespace CXX // FromBaseCtorArg // FromBaseCtorArg:: - FromBaseCtorArg (Context& c, ArgType at, Boolean arg) + FromBaseCtorArg (Context& c, CtorArgType at, bool arg) : Context (c), arg_type_ (at), arg_ (arg) { } - Void FromBaseCtorArg:: + void FromBaseCtorArg:: traverse (SemanticGraph::Any& a) { - if (!options.value ()) + if (!options.generate_wildcard ()) return; if (min (a) == 1 && max (a) == 1) @@ -830,7 +853,7 @@ namespace CXX } } - Void FromBaseCtorArg:: + void FromBaseCtorArg:: traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -842,29 +865,29 @@ namespace CXX os << "," << endl; - Boolean auto_ptr (false); + bool ptr (false); switch (arg_type_) { - case arg_complex_auto_ptr: + case CtorArgType::complex_auto_ptr: { - Boolean simple (true); + bool simple (true); IsSimpleType t (simple); t.dispatch (e.type ()); - auto_ptr = !simple; + ptr = !simple; break; } - case arg_poly_auto_ptr: + case CtorArgType::poly_auto_ptr: { - auto_ptr = polymorphic && polymorphic_p (e.type ()); + ptr = polymorphic && polymorphic_p (e.type ()); break; } - case arg_type: + case CtorArgType::type: break; } - if (auto_ptr) - os << "::std::auto_ptr< " << etype (e) << " >&"; + if (ptr) + os << auto_ptr << "< " << etype (e) << " >"; else os << "const " << etype (e) << "&"; @@ -873,7 +896,7 @@ namespace CXX } } - Void FromBaseCtorArg:: + void FromBaseCtorArg:: traverse (SemanticGraph::Attribute& a) { // Note that we are not going to include attributes with @@ -895,7 +918,7 @@ namespace CXX // CtorArgs // CtorArgs:: - CtorArgs (Context& c, ArgType at) + CtorArgs (Context& c, CtorArgType at) : Context (c), arg_type_ (at), base_arg_ (0), @@ -907,7 +930,7 @@ namespace CXX } CtorArgs:: - CtorArgs (Context& c, ArgType at, String& base_arg) + CtorArgs (Context& c, CtorArgType at, String& base_arg) : Context (c), arg_type_ (at), base_arg_ (&base_arg), @@ -918,7 +941,7 @@ namespace CXX *this >> names_ >> *this; } - Void CtorArgs:: + void CtorArgs:: traverse (SemanticGraph::Type& t) { os << comma () << "const "; @@ -929,13 +952,17 @@ namespace CXX if (base_arg_ != 0) { - *base_arg_ = L"_xsd_" + ename (t) + L"_base"; + // IDREF templates don't have a name. + // + *base_arg_ = t.named_p () + ? (L"_xsd_" + ename (t) + L"_base") + : L"_xsd_base"; os << " " << *base_arg_; } } - Void CtorArgs:: + void CtorArgs:: traverse (SemanticGraph::Enumeration& e) { os << comma () << "const "; @@ -952,10 +979,10 @@ namespace CXX } } - Void CtorArgs:: + void CtorArgs:: traverse (SemanticGraph::Any& a) { - if (!options.value ()) + if (!options.generate_wildcard ()) return; if (min (a) == 1 && max (a) == 1) @@ -967,7 +994,7 @@ namespace CXX } } - Void CtorArgs:: + void CtorArgs:: traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -975,29 +1002,29 @@ namespace CXX if (min (e) == 1 && max (e) == 1) { - Boolean auto_ptr (false); + bool ptr (false); switch (arg_type_) { - case arg_complex_auto_ptr: + case CtorArgType::complex_auto_ptr: { - Boolean simple (true); + bool simple (true); IsSimpleType t (simple); t.dispatch (e.type ()); - auto_ptr = !simple; + ptr = !simple; break; } - case arg_poly_auto_ptr: + case CtorArgType::poly_auto_ptr: { - auto_ptr = polymorphic && polymorphic_p (e.type ()); + ptr = polymorphic && polymorphic_p (e.type ()); break; } - case arg_type: + case CtorArgType::type: break; } - if (auto_ptr) - os << comma () << "::std::auto_ptr< " << etype (e) << " >&"; + if (ptr) + os << comma () << auto_ptr << "< " << etype (e) << " >"; else os << comma () << "const " << etype (e) << "&"; @@ -1006,7 +1033,7 @@ namespace CXX } } - Void CtorArgs:: + void CtorArgs:: traverse (SemanticGraph::Attribute& a) { // Note that we are not going to include attributes with @@ -1025,7 +1052,7 @@ namespace CXX String CtorArgs:: comma () { - Boolean tmp (first_); + bool tmp (first_); first_ = false; return tmp ? "" : ",\n"; } @@ -1034,17 +1061,17 @@ namespace CXX // CtorArgsWithoutBase // CtorArgsWithoutBase:: - CtorArgsWithoutBase (Context& c, ArgType at, Boolean arg, Boolean first) + CtorArgsWithoutBase (Context& c, CtorArgType at, bool arg, bool first) : Context (c), arg_type_ (at), arg_ (arg), first_ (first) { *this >> inherits_ >> *this; *this >> names_ >> *this; } - Void CtorArgsWithoutBase:: + void CtorArgsWithoutBase:: traverse (SemanticGraph::Any& a) { - if (!options.value ()) + if (!options.generate_wildcard ()) return; if (min (a) == 1 && max (a) == 1) @@ -1056,7 +1083,7 @@ namespace CXX } } - Void CtorArgsWithoutBase:: + void CtorArgsWithoutBase:: traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -1064,29 +1091,29 @@ namespace CXX if (min (e) == 1 && max (e) == 1) { - Boolean auto_ptr (false); + bool ptr (false); switch (arg_type_) { - case arg_complex_auto_ptr: + case CtorArgType::complex_auto_ptr: { - Boolean simple (true); + bool simple (true); IsSimpleType t (simple); t.dispatch (e.type ()); - auto_ptr = !simple; + ptr = !simple; break; } - case arg_poly_auto_ptr: + case CtorArgType::poly_auto_ptr: { - auto_ptr = polymorphic && polymorphic_p (e.type ()); + ptr = polymorphic && polymorphic_p (e.type ()); break; } - case arg_type: + case CtorArgType::type: break; } - if (auto_ptr) - os << comma () << "::std::auto_ptr< " << etype (e) << " >&"; + if (ptr) + os << comma () << auto_ptr << "< " << etype (e) << " >"; else os << comma () << "const " << etype (e) << "&"; @@ -1095,7 +1122,7 @@ namespace CXX } } - Void CtorArgsWithoutBase:: + void CtorArgsWithoutBase:: traverse (SemanticGraph::Attribute& a) { // Note that we are not going to include attributes with @@ -1114,14 +1141,14 @@ namespace CXX String CtorArgsWithoutBase:: comma () { - Boolean tmp (first_); + bool tmp (first_); first_ = false; return tmp ? "" : ",\n"; } // GlobalElementBase // - Boolean GlobalElementBase:: + bool GlobalElementBase:: generate_p (SemanticGraph::Element& e) { if (e.substitutes_p () && ctx_.polymorphic) @@ -1133,44 +1160,44 @@ namespace CXX // If we are not generating element types nor parsing/serialization // code then we won't generate anything from it. // - if (!ctx_.options.value () && - ctx_.options.value () && - !ctx_.options.value ()) + if (!ctx_.options.generate_element_type () && + ctx_.options.suppress_parsing () && + !ctx_.options.generate_serialization ()) return false; return true; } - Boolean GlobalElementBase:: + bool GlobalElementBase:: doc_root_p (SemanticGraph::Element& e) { - if (!ctx_.options.value () && - !ctx_.options.value () && - !ctx_.options.value () && - !ctx_.options.value () && - ctx_.options.value ().empty ()) + if (!ctx_.options.root_element_first () && + !ctx_.options.root_element_last () && + !ctx_.options.root_element_all () && + !ctx_.options.root_element_none () && + ctx_.options.root_element ().empty ()) return true; // By default treat them all. - if (ctx_.options.value ()) + if (ctx_.options.root_element_none ()) return false; - if (ctx_.options.value ()) + if (ctx_.options.root_element_all ()) return true; - if (ctx_.options.value () && + if (ctx_.options.root_element_first () && e.context ().count ("first") != 0) return true; - if (ctx_.options.value () && + if (ctx_.options.root_element_last () && e.context ().count ("last") != 0) return true; - typedef Cult::Containers::Vector Names; - Names const& names (ctx_.options.value ()); + NarrowStrings const& names (ctx_.options.root_element ()); // Hopefully nobody will specify more than a handful of names ;-). // - for (Names::ConstIterator i (names.begin ()); i != names.end (); ++i) + for (NarrowStrings::const_iterator i (names.begin ()); + i != names.end (); ++i) { String name (*i); @@ -1185,8 +1212,8 @@ namespace CXX // Namespace:: Namespace (Context& c, - UnsignedLong first, - UnsignedLong last) + size_t first, + size_t last) : CXX::Namespace (c, *this), GlobalElementBase (c), ctx_ (c), @@ -1196,7 +1223,7 @@ namespace CXX { } - Void Namespace:: + void Namespace:: traverse (Type& ns) { using SemanticGraph::Element; @@ -1205,7 +1232,7 @@ namespace CXX CXX::Namespace::traverse (ns); else { - Boolean opened (false); + bool opened (false); for (Type::NamesIterator i (ns.names_begin ()); i != ns.names_end (); ++i) @@ -1235,13 +1262,13 @@ namespace CXX } } - Void Namespace:: - enter (Type&, String const& name, Boolean) + void Namespace:: + enter (Type&, String const& name, bool) { ctx_.enter_ns_scope (name); } - Void Namespace:: + void Namespace:: leave () { ctx_.leave_ns_scope (); @@ -1249,7 +1276,7 @@ namespace CXX // Includes // - Void TypeForward:: + void TypeForward:: traverse (SemanticGraph::Type& t) { String const& name (ename (t)); @@ -1271,14 +1298,14 @@ namespace CXX os << "class " << name << ";"; } - Void Includes:: + void Includes:: traverse_ (SemanticGraph::Uses& u) { // Support for weak (forward) inclusion used in the file-per-type // compilation model. // Type t (type_); - Boolean weak (u.context ().count ("weak")); + bool weak (u.context ().count ("weak")); SemanticGraph::Schema& s (u.schema ()); if (weak && t == header) @@ -1301,6 +1328,7 @@ namespace CXX s.context ().count ("renamed") ? s.context ().get ("renamed") : u.path ()); + path.normalize (); // Try to use the portable representation of the path. If that // fails, fall back to the native representation. @@ -1308,15 +1336,11 @@ namespace CXX NarrowString path_str; try { - path_str = path.string (); + path_str = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - path_str = path.native_file_string (); -#else path_str = path.string (); -#endif } String inc_path; @@ -1325,25 +1349,25 @@ namespace CXX { case forward: { - inc_path = ctx_.fwd_expr->merge (path_str); + inc_path = ctx_.fwd_expr->replace (path_str); break; } case header: case source: { - inc_path = ctx_.hxx_expr->merge (path_str); + inc_path = ctx_.hxx_expr->replace (path_str); break; } case inline_: { if (weak) { - inc_path = ctx_.hxx_expr->merge (path_str); + inc_path = ctx_.hxx_expr->replace (path_str); ctx_.os << "#include " << ctx_.process_include_path (inc_path) << endl; } - inc_path = ctx_.ixx_expr->merge (path_str); + inc_path = ctx_.ixx_expr->replace (path_str); break; } } diff --git a/xsd/xsd/cxx/tree/elements.hxx b/xsd/xsd/cxx/tree/elements.hxx index afe3951..6874e6a 100644 --- a/xsd/xsd/cxx/tree/elements.hxx +++ b/xsd/xsd/cxx/tree/elements.hxx @@ -1,23 +1,23 @@ // file : xsd/cxx/tree/elements.hxx -// 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 #ifndef CXX_TREE_ELEMENTS_HXX #define CXX_TREE_ELEMENTS_HXX +#include +#include +#include +#include #include -#include -#include -#include +#include -#include +#include #include -#include - +#include namespace CXX { @@ -33,15 +33,15 @@ namespace CXX { } - UnsignedLong global_types; - UnsignedLong global_elements; - UnsignedLong generated_global_elements; + size_t global_types; + size_t global_elements; + size_t generated_global_elements; // Complexity value for each global type and generated global // element, in order. // - Cult::Containers::Vector complexity; - UnsignedLong complexity_total; + std::vector complexity; + size_t complexity_total; }; struct InvalidCustomTypeMapping @@ -69,13 +69,63 @@ namespace CXX String reason_; }; + // A set of potentially qualified XML Schema type names. + // + struct TypeNameSet + { + template + TypeNameSet (I begin, I end) + { + for (; begin != end; ++begin) + insert (*begin); + } + + void + insert (String const& name) + { + size_t p (name.rfind ('#')); + + if (p == String::npos) + unames_.insert (name); + else + qnames_.insert (name); + } + + bool + find (SemanticGraph::Type& t) + { + if (!unames_.empty ()) + { + if (unames_.find (t.name ()) != unames_.end ()) + return true; + } + + if (!qnames_.empty ()) + { + if (qnames_.find (t.scope ().name () + L"#" + t.name ()) != + qnames_.end ()) + return true; + } + + return false; + } + + private: + typedef std::set StringSet; + + StringSet unames_; + StringSet qnames_; + }; + // // class Context: public CXX::Context { public: - typedef BackendElements::Regex::Expression Regex; - typedef BackendElements::Regex::Pattern WideRegexPat; + typedef cutl::re::regexsub Regex; + typedef cutl::re::wregex WideRegexPat; + + typedef Tree::options options_type; struct DirectCustomTypeMapInfo { @@ -103,21 +153,16 @@ namespace CXX String base_sub; }; - typedef - Cult::Containers::Vector - RegexCustomTypeMap; - - typedef - Cult::Containers::Map - DirectCustomTypeMap; + typedef std::vector RegexCustomTypeMap; + typedef std::map DirectCustomTypeMap; public: Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& ops, + options_type const& ops, Counts const& counts_, - Boolean generate_xml_schema, + bool generate_xml_schema, StringLiteralMap const*, Regex const* fwd_expr, Regex const* hxx_expr, @@ -139,7 +184,7 @@ namespace CXX // populated with the custom type name or empty if the // original name should be used. // - Boolean + bool custom_type (SemanticGraph::Type const&, String& name) const; // Returns true if this type has been renamed as part of the @@ -147,7 +192,7 @@ namespace CXX // name string is populated with the new name or empty if // the type should not be generated at all. // - Boolean + bool renamed_type (SemanticGraph::Type const&, String& name) const; public: @@ -155,21 +200,43 @@ namespace CXX // line after 80 characters as well as "commentizing" the text by // adding '* ' after each newline. // - Void + void write_annotation (SemanticGraph::Annotation&); // // public: - Boolean + static bool + ordered_p (SemanticGraph::Type const& t) + { + return t.context ().count ("ordered") && + t.context ().get ("ordered"); + } + + // Check if we are generating mixed support for this type. We only + // do it for ordered types. + // + static bool + mixed_p (SemanticGraph::Complex const& c) + { + return c.mixed_p () && ordered_p (c); + } + + bool polymorphic_p (SemanticGraph::Type&); - Boolean + bool anonymous_p (SemanticGraph::Type const& t) { return t.context ().count ("anonymous"); } + // Return true if this anonymous type is defined in an element + // that belongs to a substitution group. + // + bool + anonymous_substitutes_p (SemanticGraph::Type&); + // Escaped names. // public: @@ -329,7 +396,7 @@ namespace CXX // dom_document // - static Boolean + static bool edom_document_p (SemanticGraph::Complex const& c) { return c.context ().count ("dom-document"); @@ -341,7 +408,7 @@ namespace CXX return c.context ().get ("dom-document"); } - static Boolean + static bool edom_document_member_p (SemanticGraph::Complex const& c) { return c.context ().count ("dom-document-member"); @@ -368,14 +435,14 @@ namespace CXX } public: - Void + void enter_ns_scope (String const& name) { ns_scope_stack.push_back (name); update_ns_scope (); } - Void + void leave_ns_scope () { ns_scope_stack.pop_back (); @@ -383,18 +450,18 @@ namespace CXX } private: - Void + void update_ns_scope (); private: // Write text that may contain characters that we will have // to escape (indicated by the rogue flag). // - Void - write_rogue_text (WideChar const* s, Size size, Boolean rogue); + void + write_rogue_text (wchar_t const* s, size_t size, bool rogue); public: - CLI::Options const& options; + options_type const& options; Counts const& counts; String& any_type; String& any_simple_type; @@ -417,11 +484,12 @@ namespace CXX String& as_double_type; String& as_decimal_type; - Boolean& generate_xml_schema; - Boolean& doxygen; - Boolean polymorphic; - Boolean polymorphic_all; - Boolean detach; + bool& generate_xml_schema; + bool& doxygen; + bool polymorphic; + bool polymorphic_all; + unsigned long poly_plate; + bool detach; Regex const* fwd_expr; Regex const* hxx_expr; @@ -454,16 +522,11 @@ namespace CXX String as_double_type_; String as_decimal_type_; - Boolean generate_xml_schema_; - Boolean doxygen_; + bool generate_xml_schema_; + bool doxygen_; - typedef - Cult::Containers::Deque - NamespaceStack; - - typedef - Cult::Containers::Deque - ScopeStack; + typedef std::deque NamespaceStack; + typedef std::deque ScopeStack; String ns_scope_; @@ -501,86 +564,86 @@ namespace CXX Traversal::Fundamental::Decimal { - IsFundamentalType (Boolean& r) + IsFundamentalType (bool& r) : r_ (r) { } // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger&) { r_ = true; @@ -588,7 +651,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean&) { r_ = true; @@ -596,26 +659,26 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal&) { r_ = true; } private: - Boolean& r_; + bool& r_; }; // Check whether this is a string-based type. @@ -630,19 +693,19 @@ namespace CXX Traversal::Fundamental::NCName, Traversal::Fundamental::Language { - IsStringBasedType (Boolean& r) + IsStringBasedType (bool& r) : r_ (r) { *this >> inherits_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); } - virtual Void + virtual void traverse (SemanticGraph::Union&) { // Current mapping of union is string-based. @@ -652,50 +715,50 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName&) { r_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language&) { r_ = true; } private: - Boolean& r_; + bool& r_; Traversal::Inherits inherits_; }; @@ -713,7 +776,7 @@ namespace CXX inherits_ >> enum_; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -727,7 +790,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (e_ == 0) @@ -820,25 +883,25 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type&) { abort (); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { os << fq_name (l); } - virtual Void + virtual void traverse (SemanticGraph::Union& u) { os << fq_name (u); } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { os << fq_name (c); @@ -846,13 +909,13 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { os << fq_name (t); @@ -860,79 +923,79 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { os << fq_name (t); @@ -940,7 +1003,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { os << fq_name (t); @@ -948,19 +1011,19 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { os << fq_name (t); @@ -968,49 +1031,49 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { os << fq_name (t); @@ -1019,7 +1082,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { os << fq_name (t); @@ -1028,13 +1091,13 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { if (t.named_p ()) @@ -1054,7 +1117,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { if (t.named_p ()) @@ -1077,7 +1140,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { os << fq_name (t); @@ -1085,13 +1148,13 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { os << fq_name (t); @@ -1100,55 +1163,55 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { os << fq_name (t); @@ -1156,13 +1219,13 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { os << fq_name (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { os << fq_name (t); @@ -1200,7 +1263,7 @@ namespace CXX { } - virtual Void + virtual void fundamental_base (SemanticGraph::Type& t) { os << "::xsd::cxx::tree::fundamental_base< " << @@ -1210,79 +1273,79 @@ namespace CXX // Integrals. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { fundamental_base (t); @@ -1290,7 +1353,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { fundamental_base (t); @@ -1298,13 +1361,13 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { fundamental_base (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { os << "::xsd::cxx::tree::fundamental_base< " << @@ -1313,7 +1376,7 @@ namespace CXX "::xsd::cxx::tree::schema_type::double_ >"; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { os << "::xsd::cxx::tree::fundamental_base< " << @@ -1330,42 +1393,46 @@ namespace CXX Traversal::Any, Traversal::AnyAttribute { - IsSimpleType (Boolean& v) + IsSimpleType (bool& v) : v_ (v) { *this >> names_ >> *this; *this >> inherits_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { - names (c, names_); + if (c.mixed_p ()) + v_ = false; + + if (v_) + names (c, names_); if (v_) inherits (c, inherits_); } - virtual Void + virtual void traverse (SemanticGraph::Member&) { v_ = false; } - virtual Void + virtual void traverse (SemanticGraph::Any&) { v_ = false; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute&) { v_ = false; } private: - Boolean& v_; + bool& v_; Traversal::Names names_; Traversal::Inherits inherits_; }; @@ -1383,29 +1450,29 @@ namespace CXX { // generate should initially be false. // - GenerateDefaultCtor (Context&, Boolean& generate, Boolean no_base); + GenerateDefaultCtor (Context&, bool& generate, bool no_base); - virtual Void + virtual void traverse (SemanticGraph::Complex&); - virtual Void + virtual void traverse (SemanticGraph::Type&); - virtual Void + virtual void traverse (SemanticGraph::Enumeration&); - virtual Void + virtual void traverse (SemanticGraph::Element&); - virtual Void + virtual void traverse (SemanticGraph::Attribute&); - virtual Void + virtual void traverse (SemanticGraph::Any&); private: - Boolean& generate_; - Boolean no_base_; + bool& generate_; + bool no_base_; private: Traversal::Inherits inherits_; @@ -1418,14 +1485,14 @@ namespace CXX { // generate should initially be false. // - GenerateFromBaseCtor (Context& c, Boolean& generate); + GenerateFromBaseCtor (Context& c, bool& generate); - virtual Void + virtual void traverse (SemanticGraph::Complex& c); private: - Boolean& generate_; - Boolean custom_; + bool& generate_; + bool custom_; // Note that we are not interested in anyAttribute since it is always // mapped to a sequence. @@ -1437,26 +1504,26 @@ namespace CXX Traversal::Any, Context { - Traverser (Context& c, Boolean& generate, Boolean& custom); + Traverser (Context& c, bool& generate, bool& custom); - virtual Void + virtual void traverse (SemanticGraph::Type&); - virtual Void + virtual void traverse (SemanticGraph::Complex&); - virtual Void + virtual void traverse (SemanticGraph::Attribute&); - virtual Void + virtual void traverse (SemanticGraph::Element&); - virtual Void + virtual void traverse (SemanticGraph::Any&); private: - Boolean& generate_; - Boolean& custom_; + bool& generate_; + bool& custom_; private: Traversal::Inherits inherits_; @@ -1477,26 +1544,44 @@ namespace CXX // should initially be true. // HasComplexPolyNonOptArgs (Context& c, - Boolean including_base, - Boolean& complex, - Boolean& poly, - Boolean& clash); + bool including_base, + bool& complex, + bool& poly, + bool& clash); - virtual Void + virtual void traverse (SemanticGraph::Complex&); - virtual Void + virtual void traverse (SemanticGraph::Element&); private: - Boolean& complex_; - Boolean& poly_; - Boolean& clash_; + bool& complex_; + bool& poly_; + bool& clash_; Traversal::Inherits inherits_; Traversal::Names names_; }; + // Contructor argument types. + // + struct CtorArgType + { + enum Value + { + type, + complex_auto_ptr, + poly_auto_ptr + }; + + CtorArgType (Value v = Value (0)) : v_ (v) {} + operator Value () const {return v_;} + + private: + Value v_; + }; + // Immediate non-optional member. Note that AnyAttribute is always // mapped to a sequence. // @@ -1505,27 +1590,20 @@ namespace CXX Traversal::Attribute, Context { - enum ArgType - { - arg_type, - arg_complex_auto_ptr, - arg_poly_auto_ptr - }; + FromBaseCtorArg (Context& c, CtorArgType, bool arg); - FromBaseCtorArg (Context& c, ArgType, Boolean arg); - - virtual Void + virtual void traverse (SemanticGraph::Any&); - virtual Void + virtual void traverse (SemanticGraph::Attribute&); - virtual Void + virtual void traverse (SemanticGraph::Element&); private: - ArgType arg_type_; - Boolean arg_; + CtorArgType arg_type_; + bool arg_; }; // List of all non-optional members and a simple base. Note that @@ -1539,32 +1617,25 @@ namespace CXX Traversal::Attribute, Context { - enum ArgType - { - arg_type, - arg_complex_auto_ptr, - arg_poly_auto_ptr - }; - // The second version outputs the argument name and stores // in in the base_arg string. // - CtorArgs (Context&, ArgType); - CtorArgs (Context&, ArgType, String& base_arg); + CtorArgs (Context&, CtorArgType); + CtorArgs (Context&, CtorArgType, String& base_arg); - virtual Void + virtual void traverse (SemanticGraph::Type&); - virtual Void + virtual void traverse (SemanticGraph::Enumeration&); - virtual Void + virtual void traverse (SemanticGraph::Any&); - virtual Void + virtual void traverse (SemanticGraph::Attribute&); - virtual Void + virtual void traverse (SemanticGraph::Element&); private: @@ -1572,10 +1643,10 @@ namespace CXX comma (); private: - ArgType arg_type_; + CtorArgType arg_type_; String base_; String* base_arg_; - Boolean first_; + bool first_; private: Traversal::Inherits inherits_; @@ -1607,92 +1678,92 @@ namespace CXX { // generate should initially be false. // - GenerateWithoutBaseCtor (Boolean& generate) + GenerateWithoutBaseCtor (bool& generate) : generate_ (generate) { *this >> inherits_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::List&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Union&) { // No default initialization. } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { Complex::inherits (c); } - virtual Void + virtual void traverse (SemanticGraph::Enumeration&) { // No default initialization. } - virtual Void + virtual void traverse (SemanticGraph::AnyType&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary&) { generate_ = true; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary&) { generate_ = true; } private: - Boolean& generate_; + bool& generate_; Traversal::Inherits inherits_; }; @@ -1706,22 +1777,15 @@ namespace CXX Traversal::Attribute, Context { - enum ArgType - { - arg_type, - arg_complex_auto_ptr, - arg_poly_auto_ptr - }; - - CtorArgsWithoutBase (Context& c, ArgType, Boolean arg, Boolean first); + CtorArgsWithoutBase (Context& c, CtorArgType, bool arg, bool first); - virtual Void + virtual void traverse (SemanticGraph::Any&); - virtual Void + virtual void traverse (SemanticGraph::Element&); - virtual Void + virtual void traverse (SemanticGraph::Attribute&); private: @@ -1729,9 +1793,9 @@ namespace CXX comma (); private: - ArgType arg_type_; - Boolean arg_; - Boolean first_; + CtorArgType arg_type_; + bool arg_; + bool first_; private: Traversal::Inherits inherits_; @@ -1747,10 +1811,10 @@ namespace CXX { } - Boolean + bool generate_p (SemanticGraph::Element&); - Boolean + bool doc_root_p (SemanticGraph::Element&); private: @@ -1765,26 +1829,26 @@ namespace CXX CXX::Namespace::ScopeTracker { Namespace (Context&, - UnsignedLong first = 1, - UnsignedLong last = 0); + size_t first = 1, + size_t last = 0); - virtual Void + virtual void traverse (Type&); protected: - virtual Void - enter (Type&, String const& name, Boolean last); + virtual void + enter (Type&, String const& name, bool last); - virtual Void + virtual void leave (); protected: Context& ctx_; private: - UnsignedLong first_; - UnsignedLong last_; - UnsignedLong count_; + size_t first_; + size_t last_; + size_t count_; }; // @@ -1796,8 +1860,8 @@ namespace CXX { } - virtual Void - enter (Type& ns, String const& name, Boolean last) + virtual void + enter (Type& ns, String const& name, bool last) { Namespace::enter (ns, name, last); @@ -1823,7 +1887,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type& t); }; @@ -1841,33 +1905,33 @@ namespace CXX Includes (Context& c, Type type) : ctx_ (c), type_ (type), - forward_ (c.options.value ()), + forward_ (c.options.generate_forward ()), namespace_ (c), type_forward_ (c) { schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; } - virtual Void + virtual void traverse (SemanticGraph::Imports& i) { traverse_ (i); } - virtual Void + virtual void traverse (SemanticGraph::Includes& i) { traverse_ (i); } private: - Void + void traverse_ (SemanticGraph::Uses&); private: Context& ctx_; Type type_; - Boolean forward_; + bool forward_; Traversal::Schema schema_; Traversal::Names schema_names_; @@ -1907,85 +1971,85 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { gen_include (t, "byte.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { gen_include (t, "unsigned-byte.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { gen_include (t, "short.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { gen_include (t, "unsigned-short.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { gen_include (t, "int.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { gen_include (t, "unsigned-int.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { if (!long_) long_ = gen_include (t, "long.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { if (!unsigned_long_) unsigned_long_ = gen_include (t, "unsigned-long.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { if (!long_) long_ = gen_include (t, "long.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { if (!long_) long_ = gen_include (t, "long.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { if (!unsigned_long_) unsigned_long_ = gen_include (t, "unsigned-long.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { if (!unsigned_long_) unsigned_long_ = gen_include (t, "unsigned-long.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { if (!long_) @@ -1994,7 +2058,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { gen_include (t, "boolean.hxx"); @@ -2002,26 +2066,26 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { gen_include (t, "float.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { gen_include (t, "double.hxx"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { gen_include (t, "decimal.hxx"); } private: - Boolean + bool gen_include (SemanticGraph::Type& t, String const& file) { String custom; @@ -2046,8 +2110,8 @@ namespace CXX private: String prefix_; - Boolean long_; - Boolean unsigned_long_; + bool long_; + bool unsigned_long_; }; } } diff --git a/xsd/xsd/cxx/tree/fundamental-header.hxx b/xsd/xsd/cxx/tree/fundamental-header.hxx index 71cfbea..925d65e 100644 --- a/xsd/xsd/cxx/tree/fundamental-header.hxx +++ b/xsd/xsd/cxx/tree/fundamental-header.hxx @@ -1,13 +1,13 @@ // file : xsd/cxx/tree/fundamental-header.hxx -// 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 #ifndef CXX_TREE_FUNDAMENTAL_HEADER_HXX #define CXX_TREE_FUNDAMENTAL_HEADER_HXX -#include -#include +#include +#include +#include #include #include @@ -80,7 +80,7 @@ namespace CXX FundamentalNamespace (Context& c) : DocumentedNamespace (c), Context (c), - export_ (c.options.value () && type_exp) + export_ (c.options.export_xml_schema () && type_exp) { *this >> names_ >> *this; @@ -88,13 +88,13 @@ namespace CXX xs_ns_ = ns_name (xs_ns ()); } - Void + void gen_typedef (String const& name, String const& type, String const& arg1 = L"", String const& arg2 = L"", String const& arg3 = L"", - Boolean export_type = true) + bool export_type = true) { os << "typedef " << type; @@ -225,7 +225,7 @@ namespace CXX // anyType and anySimpleType // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { os << "// anyType and anySimpleType." << endl @@ -237,11 +237,11 @@ namespace CXX type_ = built_in_type (t, "::xsd::cxx::tree::type"); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { simple_type_ = built_in_type ( - t, L"::xsd::cxx::tree::simple_type< ", type_); + t, L"::xsd::cxx::tree::simple_type< " + char_type + L", ", type_); if (doxygen) os << "/**" << endl @@ -259,7 +259,7 @@ namespace CXX // Integrals. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { os << "// 8-bit" << endl @@ -271,14 +271,14 @@ namespace CXX built_in_type (t, "signed char"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { built_in_type (t, "unsigned char"); os << endl; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { os << "// 16-bit" << endl @@ -290,14 +290,14 @@ namespace CXX built_in_type (t, "short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { built_in_type (t, "unsigned short"); os << endl; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { os << "// 32-bit" << endl @@ -309,14 +309,14 @@ namespace CXX built_in_type (t, "int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { built_in_type (t, "unsigned int"); os << endl; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { os << "// 64-bit" << endl @@ -328,14 +328,14 @@ namespace CXX built_in_type (t, "long long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { built_in_type (t, "unsigned long long"); os << endl; } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { os << "// Supposed to be arbitrary-length integral types." << endl @@ -347,25 +347,25 @@ namespace CXX built_in_type (t, "long long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { built_in_type (t, "long long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { built_in_type (t, "unsigned long long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { built_in_type (t, "unsigned long long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { built_in_type (t, "long long"); @@ -374,7 +374,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { os << "// Boolean." << endl @@ -390,7 +390,7 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { os << "// Floating-point types." << endl @@ -402,13 +402,13 @@ namespace CXX built_in_type (t, "float"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { double_ = built_in_type (t, "double"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { decimal_ = built_in_type (t, "double"); @@ -418,7 +418,7 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { os << "// String types." << endl @@ -431,7 +431,7 @@ namespace CXX t, L"::xsd::cxx::tree::string< " + char_type + L", ", simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { norm_string_ = built_in_type ( @@ -440,21 +440,21 @@ namespace CXX string_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { token_ = built_in_type ( t, L"::xsd::cxx::tree::token< " + char_type + L", ", norm_string_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { nmtoken_ = built_in_type ( t, L"::xsd::cxx::tree::nmtoken< " + char_type + L", ", token_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { built_in_type ( @@ -464,21 +464,21 @@ namespace CXX nmtoken_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { name_ = built_in_type ( t, L"::xsd::cxx::tree::name< " + char_type + L", ", token_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { ncname_ = built_in_type ( t, L"::xsd::cxx::tree::ncname< " + char_type + L", ", name_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { built_in_type ( @@ -489,7 +489,7 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { os << "// ID/IDREF." << endl @@ -502,14 +502,14 @@ namespace CXX t, L"::xsd::cxx::tree::id< " + char_type + L", ", ncname_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { idref_ = built_in_type ( t, L"::xsd::cxx::tree::idref< " + char_type + L", ", ncname_, type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { built_in_type ( @@ -524,7 +524,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { os << "// URI." << endl @@ -541,7 +541,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { os << "// Qualified name." << endl @@ -562,7 +562,7 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { os << "// Binary." << endl @@ -586,7 +586,7 @@ namespace CXX simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { built_in_type ( @@ -600,7 +600,7 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { os << "// Date/time." << endl @@ -622,7 +622,7 @@ namespace CXX t, L"::xsd::cxx::tree::date< " + char_type + L", ", simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { built_in_type ( @@ -631,7 +631,7 @@ namespace CXX simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { built_in_type ( @@ -640,21 +640,21 @@ namespace CXX simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { built_in_type ( t, L"::xsd::cxx::tree::gday< " + char_type + L", ", simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { built_in_type ( t, L"::xsd::cxx::tree::gmonth< " + char_type + L", ", simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { built_in_type ( @@ -663,14 +663,14 @@ namespace CXX simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { built_in_type ( t, L"::xsd::cxx::tree::gyear< " + char_type + L", ", simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { built_in_type ( @@ -679,7 +679,7 @@ namespace CXX simple_type_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { built_in_type ( @@ -690,7 +690,7 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { os << "// Entity." << endl @@ -703,7 +703,7 @@ namespace CXX t, L"::xsd::cxx::tree::entity< " + char_type + L", ", ncname_); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { built_in_type ( @@ -715,16 +715,27 @@ namespace CXX os << endl; } - virtual Void + virtual void post (SemanticGraph::Namespace& n) { SemanticGraph::Context& c (xs_ns ().context()); - Boolean parsing (!options.value ()); - Boolean serialization (options.value ()); - Boolean element_map (options.value ()); + bool parsing (!options.suppress_parsing ()); + bool serialization (options.generate_serialization ()); + bool element_map (options.generate_element_map ()); - if (options.value ()) + { + if (doxygen) + os << endl + << "/**" << endl + << " * @brief Content order sequence entry." << endl + << " */" << endl; + + gen_typedef (c.get ("content-order"), + "::xsd::cxx::tree::content_order"); + } + + if (options.generate_element_type ()) { if (doxygen) os << "/**" << endl @@ -838,7 +849,7 @@ namespace CXX //@@ Can't change names of ostream/istream since they are // templates. // - if (!options.value ().empty ()) + if (!options.generate_insertion ().empty ()) { if (doxygen) os << "/**" << endl @@ -852,7 +863,7 @@ namespace CXX << endl; } - if (!options.value ().empty ()) + if (!options.generate_extraction ().empty ()) { if (doxygen) os << "/**" << endl @@ -1050,7 +1061,7 @@ namespace CXX L"::xsd::cxx::tree::no_prefix_mapping< " + char_type + L" >"); } - if (options.value ()) + if (options.generate_polymorphic ()) { if (parsing || serialization) { @@ -1145,7 +1156,8 @@ namespace CXX << "{"; // @@ Disregarding current naming convention by using the - // fixed name (no template typedef). + // fixed name (even in C++11, template alias is not yet + // widely supported). // if (doxygen) os << "/**" << endl @@ -1155,8 +1167,12 @@ namespace CXX os << "// Automatic pointer for DOMDocument." << endl << "//" << endl; - os << "using ::xsd::cxx::xml::dom::auto_ptr;" - << endl; + if (std >= cxx_version::cxx11) + os << "using ::xsd::cxx::xml::dom::unique_ptr;"; + else + os << "using ::xsd::cxx::xml::dom::auto_ptr;"; + + os << endl; if (parsing) { @@ -1228,7 +1244,7 @@ namespace CXX { StringSet ns_set; - for (StringList::ConstIterator i (exports_.begin ()); + for (StringList::const_iterator i (exports_.begin ()); i != exports_.end (); ++i) { String const& e (*i); @@ -1245,14 +1261,14 @@ namespace CXX << "namespace cxx" << "{"; - for (StringSet::ConstIterator i (ns_set.begin ()); + for (StringSet::const_iterator i (ns_set.begin ()); i != ns_set.end (); ++i) { String const& ns (*i); String prefix (L"::xsd::cxx::" + ns); - Size n (1); - for (Size b (0), e (ns.find (':')); ; n++) + size_t n (1); + for (size_t b (0), e (ns.find (':')); ; n++) { os << "namespace " << String (ns, b, e) << "{"; @@ -1264,7 +1280,7 @@ namespace CXX e = ns.find (':', b); } - for (StringList::ConstIterator i (exports_.begin ()); + for (StringList::const_iterator i (exports_.begin ()); i != exports_.end (); ++i) { String const& e (*i); @@ -1289,10 +1305,10 @@ namespace CXX } private: - typedef Cult::Containers::Set StringSet; - typedef Cult::Containers::Vector StringList; + typedef std::set StringSet; + typedef std::vector StringList; - Boolean export_; + bool export_; StringList exports_; StringSet exports_set_; String xs_ns_; diff --git a/xsd/xsd/cxx/tree/generator.cxx b/xsd/xsd/cxx/tree/generator.cxx index fe5286a..7a413bd 100644 --- a/xsd/xsd/cxx/tree/generator.cxx +++ b/xsd/xsd/cxx/tree/generator.cxx @@ -1,8 +1,22 @@ // file : xsd/cxx/tree/generator.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 +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + #include #include @@ -10,6 +24,7 @@ #include #include #include +#include #include #include @@ -30,45 +45,25 @@ #include #include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include +#include #include "../../../libxsd/xsd/cxx/version.hxx" -using std::endl; -using std::wcerr; - +using namespace std; +using namespace cutl; using namespace XSDFrontend::SemanticGraph; // // -typedef -boost::filesystem::wifstream -WideInputFileStream; - -typedef -boost::filesystem::wofstream -WideOutputFileStream; +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; namespace CXX { namespace { - Char const copyright_gpl[] = - "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n" + char const copyright_gpl[] = + "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n" "//\n" "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" "// C++ data binding compiler.\n" @@ -101,8 +96,8 @@ namespace CXX "// in the accompanying FLOSSE file.\n" "//\n\n"; - Char const copyright_proprietary[] = - "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n" + char const copyright_proprietary[] = + "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n" "//\n" "// This program was generated by CodeSynthesis XSD, an XML Schema\n" "// to C++ data binding compiler, in the Proprietary License mode.\n" @@ -112,673 +107,23 @@ namespace CXX "//\n\n"; } - namespace Tree - { - namespace CLI - { - extern Key char_type = "char-type"; - extern Key char_encoding = "char-encoding"; - extern Key output_dir = "output-dir"; - extern Key generate_polymorphic = "generate-polymorphic"; - extern Key polymorphic_type = "polymorphic-type"; - extern Key polymorphic_type_all = "polymorphic-type-all"; - extern Key generate_serialization = "generate-serialization"; - extern Key generate_inline = "generate-inline"; - extern Key generate_ostream = "generate-ostream"; - extern Key generate_doxygen = "generate-doxygen"; - extern Key generate_comparison = "generate-comparison"; - extern Key generate_default_ctor = "generate-default-ctor"; - extern Key generate_from_base_ctor = "generate-from-base-ctor"; - extern Key generate_detach = "generate-detach"; - extern Key generate_wildcard = "generate-wildcard"; - extern Key generate_insertion = "generate-insertion"; - extern Key generate_extraction = "generate-extraction"; - extern Key generate_forward = "generate-forward"; - extern Key generate_xml_schema = "generate-xml-schema"; - extern Key extern_xml_schema = "extern-xml-schema"; - extern Key suppress_parsing = "suppress-parsing"; - extern Key generate_element_type = "generate-element-type"; - extern Key generate_element_map = "generate-element-map"; - extern Key generate_intellisense = "generate-intellisense"; - extern Key omit_default_attributes = "omit-default-attributes"; - extern Key namespace_map = "namespace-map"; - extern Key namespace_regex = "namespace-regex"; - extern Key namespace_regex_trace = "namespace-regex-trace"; - extern Key reserved_name = "reserved-name"; - extern Key type_naming = "type-naming"; - extern Key function_naming = "function-naming"; - extern Key type_regex = "type-regex"; - extern Key accessor_regex = "accessor-regex"; - extern Key one_accessor_regex = "one-accessor-regex"; - extern Key opt_accessor_regex = "opt-accessor-regex"; - extern Key seq_accessor_regex = "seq-accessor-regex"; - extern Key modifier_regex = "modifier-regex"; - extern Key one_modifier_regex = "one-modifier-regex"; - extern Key opt_modifier_regex = "opt-modifier-regex"; - extern Key seq_modifier_regex = "seq-modifier-regex"; - extern Key parser_regex = "parser-regex"; - extern Key serializer_regex = "serializer-regex"; - extern Key enumerator_regex = "enumerator-regex"; - extern Key element_type_regex = "element-type-regex"; - extern Key name_regex_trace = "name-regex-trace"; - extern Key include_with_brackets = "include-with-brackets"; - extern Key include_prefix = "include-prefix"; - extern Key include_regex = "include-regex"; - extern Key include_regex_trace = "include-regex-trace"; - extern Key guard_prefix = "guard-prefix"; - extern Key root_element_first = "root-element-first"; - extern Key root_element_last = "root-element-last"; - extern Key root_element_all = "root-element-all"; - extern Key root_element_none = "root-element-none"; - extern Key root_element = "root-element"; - extern Key custom_type = "custom-type"; - extern Key custom_type_regex = "custom-type-regex"; - extern Key hxx_suffix = "hxx-suffix"; - extern Key ixx_suffix = "ixx-suffix"; - extern Key cxx_suffix = "cxx-suffix"; - extern Key fwd_suffix = "fwd-suffix"; - extern Key hxx_regex = "hxx-regex"; - extern Key ixx_regex = "ixx-regex"; - extern Key cxx_regex = "cxx-regex"; - extern Key fwd_regex = "fwd-regex"; - extern Key hxx_prologue = "hxx-prologue"; - extern Key ixx_prologue = "ixx-prologue"; - extern Key cxx_prologue = "cxx-prologue"; - extern Key fwd_prologue = "fwd-prologue"; - extern Key prologue = "prologue"; - extern Key hxx_epilogue = "hxx-epilogue"; - extern Key ixx_epilogue = "ixx-epilogue"; - extern Key cxx_epilogue = "cxx-epilogue"; - extern Key fwd_epilogue = "fwd-epilogue"; - extern Key epilogue = "epilogue"; - extern Key hxx_prologue_file = "hxx-prologue-file"; - extern Key ixx_prologue_file = "ixx-prologue-file"; - extern Key cxx_prologue_file = "cxx-prologue-file"; - extern Key fwd_prologue_file = "fwd-prologue-file"; - extern Key prologue_file = "prologue-file"; - extern Key hxx_epilogue_file = "hxx-epilogue-file"; - extern Key ixx_epilogue_file = "ixx-epilogue-file"; - extern Key cxx_epilogue_file = "cxx-epilogue-file"; - extern Key fwd_epilogue_file = "fwd-epilogue-file"; - extern Key epilogue_file = "epilogue-file"; - extern Key parts = "parts"; - extern Key parts_suffix = "parts-suffix"; - extern Key export_symbol = "export-symbol"; - extern Key export_xml_schema = "export-xml-schema"; - extern Key export_maps = "export-maps"; - extern Key import_maps = "import-maps"; - extern Key show_anonymous = "show-anonymous"; - extern Key show_sloc = "show-sloc"; - extern Key proprietary_license = "proprietary-license"; - extern Key disable_multi_import = "disable-multi-import"; - } - } - - Void Tree::Generator:: + void Tree::Generator:: usage () { - std::wostream& e (wcerr); - ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e); - - e << "--char-type " << endl - << " Use as the base character type. Valid\n" - << " values are 'char' (default) and 'wchar_t'." - << endl; - - e << "--char-encoding " << endl - << " Specify the character encoding that should be used\n" - << " in the object model. Valid values for the 'char'\n" - << " character type are 'utf8' (default), 'iso8859-1',\n" - << " 'lcp', and 'custom'. For the 'wchar_t' character\n" - << " type the only valid value is 'auto'." - << endl; - - e << "--output-dir " << endl - << " Write generated files to instead of current\n" - << " directory." - << endl; - - e << "--generate-polymorphic" << endl - << " Generate polymorphism-aware code. Specify this\n" - << " option if you use substitution groups or xsi:type." - << endl; - - e << "--polymorphic-type " << endl - << " Indicate that is a root of a polymorphic\n" - << " type hierarchy." - << endl; - - e << "--polymorphic-type-all" << endl - << " Indicate that all types should be treated as\n" - << " polymorphic." - << endl; - - e << "--generate-serialization" << endl - << " Generate serialization functions. They convert an\n" - << " in-memory representation back to XML." - << endl; - - e << "--generate-inline" << endl - << " Generate certain functions inline." - << endl; - - e << "--generate-ostream" << endl - << " Generate ostream insertion operators." - << endl; - - e << "--generate-doxygen" << endl - << " Generate documentation comments in the Doxygen\n" - << " format." - << endl; - - e << "--generate-comparison" << endl - << " Generate comparison operators." - << endl; - - e << "--generate-default-ctor" << endl - << " Generate default constructors even for types that\n" - << " have required members." - << endl; - - e << "--generate-from-base-ctor" << endl - << " Generate from-base constructors." - << endl; - - e << "--generate-detach" << endl - << " Generate detach functions for required members." - << endl; - - e << "--generate-wildcard" << endl - << " Generate accessors/modifiers as well as parsing\n" - << " and serialization code for XML Schema wildcards." - << endl; - - e << "--generate-insertion " << endl - << " Generate data representation stream insertion\n" - << " operators for the output stream type." - << endl; - - e << "--generate-extraction " << endl - << " Generate data representation stream extraction\n" - << " constructors for the input stream type." - << endl; - - e << "--generate-forward" << endl - << " Generate forward declaration file." - << endl; - - e << "--generate-xml-schema" << endl - << " Generate a C++ header file as if the schema being\n" - << " compiled defines the XML Schema namespace." - << endl; - - e << "--extern-xml-schema " << endl - << " Generate code as if the XML Schema namespace was\n" - << " defined in and xsd:included in the schema\n" - << " being compiled." - << endl; - - e << "--suppress-parsing" << endl - << " Suppress the generation of parsing functions." - << endl; - - e << "--generate-element-type" << endl - << " Generate types instead of parsing/serialization\n" - << " functions for root elements." - << endl; - - e << "--generate-element-map" << endl - << " Generate a root element map that allows uniform\n" - << " parsing/serialization of multiple root elements.\n" - << endl; - - e << "--generate-intellisense" << endl - << " Generate workarounds for IntelliSense bugs in\n" - << " Visual Studio 2005 (8.0)." - << endl; - - e << "--omit-default-attributes" << endl - << " Omit attributes with default and fixed values\n" - << " from serialized XML documents." - << endl; - - e << "--namespace-map =" << endl - << " Map XML Schema namespace to C++ namespace\n" - << " . Repeat this option to specify mapping for\n" - << " more than one XML Schema namespace." - << endl; - - e << "--namespace-regex " << endl - << " Add to the list of regular expressions\n" - << " used to translate XML Schema namespace names to\n" - << " C++ namespace names." - << endl; - - e << "--namespace-regex-trace" << endl - << " Trace the process of applying regular expressions\n" - << " specified with the --namespace-regex option." - << endl; - - e << "--reserved-name " << endl - << " Add to the list of names that should not\n" - << " be used as identifiers. The name can optionally\n" - << " be followed by '=' and the replacement name that\n" - << " should be used instead." - << endl; - - e << "--type-naming