From c34158508eafb020fbb7bbb7c0b2479982c426cd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 21 Jun 2012 10:20:42 +0200 Subject: Completion of the CLI port --- xsde/cxx/hybrid/cli.hxx | 216 -------- xsde/cxx/hybrid/elements.cxx | 48 +- xsde/cxx/hybrid/elements.hxx | 19 +- xsde/cxx/hybrid/extraction-header.cxx | 14 +- xsde/cxx/hybrid/extraction-source.cxx | 14 +- xsde/cxx/hybrid/generator.cxx | 728 ++++++++------------------ xsde/cxx/hybrid/generator.hxx | 36 +- xsde/cxx/hybrid/insertion-header.cxx | 14 +- xsde/cxx/hybrid/insertion-source.cxx | 14 +- xsde/cxx/hybrid/options.cli | 22 +- xsde/cxx/hybrid/parser-header.cxx | 4 +- xsde/cxx/hybrid/parser-name-processor.cxx | 69 +-- xsde/cxx/hybrid/parser-name-processor.hxx | 4 +- xsde/cxx/hybrid/parser-source.cxx | 12 +- xsde/cxx/hybrid/serializer-name-processor.cxx | 72 +-- xsde/cxx/hybrid/serializer-name-processor.hxx | 4 +- xsde/cxx/hybrid/serializer-source.cxx | 14 +- xsde/cxx/hybrid/tree-forward.cxx | 12 +- xsde/cxx/hybrid/tree-header.cxx | 6 +- xsde/cxx/hybrid/tree-inline.cxx | 2 +- xsde/cxx/hybrid/tree-name-processor.cxx | 44 +- xsde/cxx/hybrid/tree-name-processor.hxx | 4 +- xsde/cxx/hybrid/tree-size-processor.cxx | 27 +- xsde/cxx/hybrid/tree-size-processor.hxx | 4 +- xsde/cxx/hybrid/tree-type-map.cxx | 31 +- xsde/cxx/hybrid/tree-type-map.hxx | 4 +- xsde/cxx/hybrid/validator.cxx | 37 +- xsde/cxx/hybrid/validator.hxx | 4 +- 28 files changed, 436 insertions(+), 1043 deletions(-) delete mode 100644 xsde/cxx/hybrid/cli.hxx (limited to 'xsde/cxx/hybrid') diff --git a/xsde/cxx/hybrid/cli.hxx b/xsde/cxx/hybrid/cli.hxx deleted file mode 100644 index f697247..0000000 --- a/xsde/cxx/hybrid/cli.hxx +++ /dev/null @@ -1,216 +0,0 @@ -// file : xsde/cxx/hybrid/cli.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_HYBRID_CLI_HXX -#define CXX_HYBRID_CLI_HXX - -#include - -#include - -#include -#include - -namespace CXX -{ - namespace Hybrid - { - namespace CLI - { - using namespace Cult::Types; - - typedef Char const Key[]; - - extern Key char_encoding; - extern Key no_stl; - extern Key no_iostream; - extern Key no_exceptions; - extern Key no_long_long; - extern Key generate_parser; - extern Key generate_serializer; - extern Key generate_aggregate; - extern Key suppress_validation; - extern Key suppress_parser_val; - extern Key suppress_serializer_val; - extern Key omit_default_attributes; - extern Key suppress_enum; - extern Key generate_clone; - extern Key generate_detach; - extern Key generate_insertion; - extern Key generate_extraction; - extern Key generate_inline; - extern Key generate_forward; - extern Key generate_xml_schema; - extern Key extern_xml_schema; - extern Key suppress_reset; - extern Key custom_allocator; - extern Key generate_polymorphic; - extern Key runtime_polymorphic; - extern Key polymorphic_type; - extern Key generate_typeinfo; - extern Key polymorphic_schema; - extern Key reuse_style_mixin; - extern Key custom_data; - extern Key custom_type; - extern Key custom_parser; - extern Key custom_serializer; - 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 root_type; - extern Key output_dir; - extern Key pskel_type_suffix; - extern Key sskel_type_suffix; - extern Key pskel_file_suffix; - extern Key sskel_file_suffix; - extern Key pimpl_type_suffix; - extern Key simpl_type_suffix; - extern Key pimpl_file_suffix; - extern Key simpl_file_suffix; - extern Key paggr_type_suffix; - extern Key saggr_type_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 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 show_anonymous; - extern Key show_sloc; - extern Key proprietary_license; - - typedef Cult::CLI::Options< - char_encoding, NarrowString, - no_stl, Boolean, - no_iostream, Boolean, - no_exceptions, Boolean, - no_long_long, Boolean, - generate_parser, Boolean, - generate_serializer, Boolean, - generate_aggregate, Boolean, - suppress_validation, Boolean, - suppress_parser_val, Boolean, - suppress_serializer_val, Boolean, - omit_default_attributes, Boolean, - suppress_enum, Boolean, - generate_clone, Boolean, - generate_detach, Boolean, - generate_insertion, Cult::Containers::Vector, - generate_extraction, Cult::Containers::Vector, - generate_inline, Boolean, - generate_forward, Boolean, - generate_xml_schema, Boolean, - extern_xml_schema, NarrowString, - suppress_reset, Boolean, - custom_allocator, Boolean, - generate_polymorphic, Boolean, - runtime_polymorphic, Boolean, - polymorphic_type, Cult::Containers::Vector, - generate_typeinfo, Boolean, - polymorphic_schema, Cult::Containers::Vector, - reuse_style_mixin, Boolean, - custom_data, Cult::Containers::Vector, - custom_type, Cult::Containers::Vector, - custom_parser, Cult::Containers::Vector, - custom_serializer, Cult::Containers::Vector, - root_element_first, Boolean, - root_element_last, Boolean, - root_element_all, Boolean, - root_element_none, Boolean, - root_element, Cult::Containers::Vector, - root_type, Cult::Containers::Vector, - output_dir, NarrowString, - pskel_type_suffix, NarrowString, - sskel_type_suffix, NarrowString, - pskel_file_suffix, NarrowString, - sskel_file_suffix, NarrowString, - pimpl_type_suffix, NarrowString, - simpl_type_suffix, NarrowString, - pimpl_file_suffix, NarrowString, - simpl_file_suffix, NarrowString, - paggr_type_suffix, NarrowString, - saggr_type_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, - fwd_suffix, NarrowString, - hxx_regex, Cult::Containers::Vector, - ixx_regex, Cult::Containers::Vector, - cxx_regex, Cult::Containers::Vector, - 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, Cult::Containers::Vector, - ixx_prologue_file, Cult::Containers::Vector, - cxx_prologue_file, Cult::Containers::Vector, - fwd_prologue_file, NarrowString, - prologue_file, Cult::Containers::Vector, - hxx_epilogue_file, Cult::Containers::Vector, - ixx_epilogue_file, Cult::Containers::Vector, - cxx_epilogue_file, Cult::Containers::Vector, - fwd_epilogue_file, NarrowString, - epilogue_file, Cult::Containers::Vector, - show_anonymous, Boolean, - show_sloc, Boolean, - proprietary_license, Boolean - - > Options; - - struct OptionsSpec: Cult::CLI::OptionsSpec {}; - } - } -} - -#endif // CXX_HYBRID_CLI_HXX diff --git a/xsde/cxx/hybrid/elements.cxx b/xsde/cxx/hybrid/elements.cxx index 337e15f..9356b66 100644 --- a/xsde/cxx/hybrid/elements.cxx +++ b/xsde/cxx/hybrid/elements.cxx @@ -13,39 +13,22 @@ namespace CXX Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& ops, + options_type const& ops, Regex const* fe, Regex const* he, Regex const* ie) - : CXX::Context (o, - root, - path, - "name", - "char", - ops.value (), - ops.value (), - ops.value (), - "", // export symbol - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - !ops.value (), - ops.value ()), + : CXX::Context (o, root, path, ops, "name", "char"), options (ops), - exceptions (!ops.value ()), - stl (!ops.value ()), - poly_code (ops.value ()), - poly_runtime (poly_code || ops.value ()), - reset (!ops.value ()), - clone (ops.value ()), - detach (ops.value ()), - mixin (ops.value ()), + exceptions (!ops.no_exceptions ()), + stl (!ops.no_stl ()), + poly_code (ops.generate_polymorphic ()), + poly_runtime (poly_code || ops.runtime_polymorphic ()), + reset (!ops.suppress_reset ()), + clone (ops.generate_clone ()), + detach (ops.generate_detach ()), + mixin (ops.reuse_style_mixin ()), tiein (!mixin), - enum_ (!ops.value ()), + enum_ (!ops.suppress_enum ()), fwd_expr (fe), hxx_expr (he), ixx_expr (ie), @@ -55,16 +38,15 @@ namespace CXX var_seq (var_seq_), str_seq (str_seq_), data_seq (data_seq_), - istreams (ops.value ()), - ostreams (ops.value ()), + istreams (ops.generate_extraction ()), + ostreams (ops.generate_insertion ()), icdrstream (icdrstream_), ocdrstream (ocdrstream_), ixdrstream (ixdrstream_), oxdrstream (oxdrstream_) { - typeinfo = poly_code && - (ops.value () || - ops.value ()); + typeinfo = + poly_code && (ops.generate_typeinfo () || ops.generate_serializer ()); String xs_ns (xs_ns_name ()); diff --git a/xsde/cxx/hybrid/elements.hxx b/xsde/cxx/hybrid/elements.hxx index 45fe671..f4b00e8 100644 --- a/xsde/cxx/hybrid/elements.hxx +++ b/xsde/cxx/hybrid/elements.hxx @@ -14,7 +14,7 @@ #include -#include +#include namespace CXX { @@ -29,11 +29,13 @@ namespace CXX public: typedef Hybrid::Regex Regex; + typedef Hybrid::options options_type; + public: Context (std::wostream&, SemanticGraph::Schema&, SemanticGraph::Path const&, - CLI::Options const&, + options_type const&, Regex const* fwd_expr, Regex const* hxx_expr, Regex const* ixx_expr); @@ -591,7 +593,7 @@ namespace CXX NamespaceStack; public: - CLI::Options const& options; + options_type const& options; Boolean exceptions; Boolean stl; @@ -617,9 +619,8 @@ namespace CXX String const& str_seq; String const& data_seq; - typedef Containers::Vector Streams; - Streams const& istreams; - Streams const& ostreams; + NarrowStrings const& istreams; + NarrowStrings const& ostreams; String const& icdrstream; String const& ocdrstream; @@ -1191,7 +1192,7 @@ namespace CXX { if (use_ != base) { - if (options.value ()) + if (options.no_long_long ()) fund_type ("long"); else fund_type ("long long"); @@ -1205,7 +1206,7 @@ namespace CXX { if (use_ != base) { - if (options.value ()) + if (options.no_long_long ()) fund_type ("unsigned long"); else fund_type ("unsigned long long"); @@ -2172,7 +2173,7 @@ namespace CXX Includes (Context& c, Type type, Regex const* r = 0) : ctx_ (c), type_ (type), - forward_ (c.options.value ()), + forward_ (c.options.generate_forward ()), regex_ (r), namespace_ (c), type_forward_ (c) diff --git a/xsde/cxx/hybrid/extraction-header.cxx b/xsde/cxx/hybrid/extraction-header.cxx index 3240f54..25b4b43 100644 --- a/xsde/cxx/hybrid/extraction-header.cxx +++ b/xsde/cxx/hybrid/extraction-header.cxx @@ -41,7 +41,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -73,7 +73,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -102,7 +102,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -135,7 +135,7 @@ namespace CXX String const& type (etype (a)); String const& scope (Context::scope (a)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -165,7 +165,7 @@ namespace CXX String const& type (etype (c)); String const& scope (Context::scope (c)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -201,7 +201,7 @@ namespace CXX String const& type (etype (s)); String const& scope (Context::scope (s)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -256,7 +256,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl diff --git a/xsde/cxx/hybrid/extraction-source.cxx b/xsde/cxx/hybrid/extraction-source.cxx index 8b314f5..413ffdc 100644 --- a/xsde/cxx/hybrid/extraction-source.cxx +++ b/xsde/cxx/hybrid/extraction-source.cxx @@ -41,7 +41,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -86,7 +86,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -126,7 +126,7 @@ namespace CXX String const& value (u.context ().get ("value")); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -980,7 +980,7 @@ namespace CXX String const& type (etype (a)); String const& scope (Context::scope (a)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -1023,7 +1023,7 @@ namespace CXX String const& type (etype (c)); String const& scope (Context::scope (c)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -1089,7 +1089,7 @@ namespace CXX String const& type (etype (s)); String const& scope (Context::scope (s)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -1188,7 +1188,7 @@ namespace CXX Boolean restriction (restriction_p (c)); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx index 3a61c95..c2289ae 100644 --- a/xsde/cxx/hybrid/generator.cxx +++ b/xsde/cxx/hybrid/generator.cxx @@ -54,10 +54,7 @@ #include "../../../libxsde/xsde/cxx/version.hxx" -using std::endl; -using std::wcerr; -using std::wcout; - +using namespace std; using namespace XSDFrontend::SemanticGraph; // @@ -110,103 +107,6 @@ namespace CXX "//\n\n"; } - namespace Hybrid - { - namespace CLI - { - extern Key char_encoding = "char-encoding"; - extern Key no_stl = "no-stl"; - extern Key no_iostream = "no-iostream"; - extern Key no_exceptions = "no-exceptions"; - extern Key no_long_long = "no-long-long"; - extern Key generate_parser = "generate-parser"; - extern Key generate_serializer = "generate-serializer"; - extern Key generate_aggregate = "generate-aggregate"; - extern Key suppress_validation = "suppress-validation"; - extern Key suppress_parser_val = "suppress-parser-val"; - extern Key suppress_serializer_val = "suppress-serializer-val"; - extern Key omit_default_attributes = "omit-default-attributes"; - extern Key suppress_enum = "suppress-enum"; - extern Key generate_clone = "generate-clone"; - extern Key generate_detach = "generate-detach"; - extern Key generate_insertion = "generate-insertion"; - extern Key generate_extraction = "generate-extraction"; - extern Key generate_inline = "generate-inline"; - 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_reset = "suppress-reset"; - extern Key custom_allocator = "custom-allocator"; - extern Key generate_polymorphic = "generate-polymorphic"; - extern Key runtime_polymorphic = "runtime-polymorphic"; - extern Key polymorphic_type = "polymorphic-type"; - extern Key generate_typeinfo = "generate-typeinfo"; - extern Key polymorphic_schema = "polymorphic-schema"; - extern Key reuse_style_mixin = "reuse-style-mixin"; - extern Key custom_data = "custom-data"; - extern Key custom_type = "custom-type"; - extern Key custom_parser = "custom-parser"; - extern Key custom_serializer = "custom-serializer"; - 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 root_type = "root-type"; - extern Key output_dir = "output-dir"; - extern Key pskel_type_suffix = "pskel-type-suffix"; - extern Key sskel_type_suffix = "sskel-type-suffix"; - extern Key pskel_file_suffix = "pskel-file-suffix"; - extern Key sskel_file_suffix = "sskel-file-suffix"; - extern Key pimpl_type_suffix = "pimpl-type-suffix"; - extern Key simpl_type_suffix = "simpl-type-suffix"; - extern Key pimpl_file_suffix = "pimpl-file-suffix"; - extern Key simpl_file_suffix = "simpl-file-suffix"; - extern Key paggr_type_suffix = "paggr-type-suffix"; - extern Key saggr_type_suffix = "saggr-type-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 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 show_anonymous = "show-anonymous"; - extern Key show_sloc = "show-sloc"; - extern Key proprietary_license = "proprietary-license"; - } - } - Void Hybrid::Generator:: usage () { @@ -214,34 +114,6 @@ namespace CXX CXX::options::print_usage (wcout); } - Hybrid::CLI::OptionsSpec Hybrid::Generator:: - options_spec () - { - CLI::OptionsSpec spec; - - spec.option ().default_value ("utf8"); - - spec.option ().default_value ("-pskel"); - spec.option ().default_value ("-sskel"); - spec.option ().default_value ("_pskel"); - spec.option ().default_value ("_sskel"); - - spec.option ().default_value ("-pimpl"); - spec.option ().default_value ("-simpl"); - spec.option ().default_value ("_pimpl"); - spec.option ().default_value ("_simpl"); - - spec.option ().default_value ("_paggr"); - spec.option ().default_value ("_saggr"); - - spec.option ().default_value (".hxx"); - spec.option ().default_value (".ixx"); - spec.option ().default_value (".cxx"); - spec.option ().default_value ("-fwd.hxx"); - - return spec; - } - namespace { typedef @@ -253,12 +125,10 @@ namespace CXX sloc_filter; NarrowString - find_value (Cult::Containers::Vector const& v, - Char const* key) + find_value (NarrowStrings const& v, Char const* key) { - typedef Cult::Containers::Vector Values; - - for (Values::ConstIterator i (v.begin ()), e (v.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); + i != e; ++i) { Size p (i->find ('=')); @@ -292,13 +162,12 @@ namespace CXX } Void - copy_values (Cult::Containers::Vector& dst, - Cult::Containers::Vector const& src, - Char const* key) + copy_values (NarrowStrings& dst, NarrowStrings const& src, Char const* key) { - typedef Cult::Containers::Vector Values; + dst.clear (); - for (Values::ConstIterator i (src.begin ()), e (src.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (src.begin ()), e (src.end ()); + i != e; ++i) { Size p (i->find ('=')); @@ -340,8 +209,6 @@ namespace CXX void traverse (Type& ns) { - namespace CLI = Hybrid::CLI; - pre (ns); os << "using ::xsde::cxx::hybrid::any_type;" @@ -352,16 +219,16 @@ namespace CXX if (type_ == 'p') { - skel = options.value (); - impl = options.value (); + skel = options.pskel_type_suffix (); + impl = options.pimpl_type_suffix (); us = skel == L"_pskel"; ui = impl == L"_pimpl"; } else { - skel = options.value (); - impl = options.value (); + skel = options.sskel_type_suffix (); + impl = options.simpl_type_suffix (); us = skel == L"_sskel"; ui = impl == L"_simpl"; @@ -387,85 +254,46 @@ namespace CXX }; } - Parser::CLI::Options* Hybrid::Generator:: - parser_options (CLI::Options const& h, Schema& schema, Path const& path) + auto_ptr Hybrid::Generator:: + parser_options (options const& h, Schema& schema, Path const& path) { - namespace H = CLI; - namespace P = Parser::CLI; - - Evptr r (new P::Options); - - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = false; - r->value () = h.value (); - r->value () = h.value () - || h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); + auto_ptr r (new Parser::options); + + static_cast (*r) = h; // Assign common options. + + r->reuse_style_mixin (h.reuse_style_mixin ()); + r->suppress_validation (h.suppress_validation () || + h.suppress_parser_val ()); + r->generate_polymorphic (h.generate_polymorphic ()); + r->runtime_polymorphic (h.runtime_polymorphic ()); + + r->skel_file_suffix (h.pskel_file_suffix ()); + r->skel_type_suffix (h.pskel_type_suffix ()); + r->impl_type_suffix (h.pimpl_type_suffix ()); Char const* k = "pskel"; - r->value () = - find_value (h.value (), k); - r->value () = - find_value (h.value (), k); - r->value () = - find_value (h.value (), k); - - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - - r->value () = h.value (); - r->value () = h.value (); + r->hxx_regex (find_value (h.hxx_regex (), k)); + r->ixx_regex (find_value (h.ixx_regex (), k)); + r->cxx_regex (find_value (h.cxx_regex (), k)); + + r->prologue_file (find_value (h.prologue_file (), k)); + r->epilogue_file (find_value (h.epilogue_file (), k)); + r->hxx_prologue_file (find_value (h.hxx_prologue_file (), k)); + r->ixx_prologue_file (find_value (h.ixx_prologue_file (), k)); + r->cxx_prologue_file (find_value (h.cxx_prologue_file (), k)); + r->hxx_epilogue_file (find_value (h.hxx_epilogue_file (), k)); + r->ixx_epilogue_file (find_value (h.ixx_epilogue_file (), k)); + r->cxx_epilogue_file (find_value (h.cxx_epilogue_file (), k)); + + copy_values (r->prologue (), h.prologue (), k); + copy_values (r->epilogue (), h.epilogue (), k); + copy_values (r->hxx_prologue (), h.hxx_prologue (), k); + copy_values (r->ixx_prologue (), h.ixx_prologue (), k); + copy_values (r->cxx_prologue (), h.cxx_prologue (), k); + copy_values (r->hxx_epilogue (), h.hxx_epilogue (), k); + copy_values (r->ixx_epilogue (), h.ixx_epilogue (), k); + copy_values (r->cxx_epilogue (), h.cxx_epilogue (), k); // Add the anyType parser. // @@ -486,91 +314,52 @@ namespace CXX ns.dispatch (ctx.xs_ns ()); } - r->value ().push_back (String (os.str ()).to_narrow ()); + r->hxx_prologue ().push_back (String (os.str ()).to_narrow ()); } - return r.release (); + return r; } - Serializer::CLI::Options* Hybrid::Generator:: - serializer_options (CLI::Options const& h, Schema& schema, Path const& path) + auto_ptr Hybrid::Generator:: + serializer_options (options const& h, Schema& schema, Path const& path) { - namespace H = CLI; - namespace S = Serializer::CLI; - - Evptr r (new S::Options); - - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = false; - r->value () = h.value (); - r->value () = h.value () - || h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - - r->value () = h.value (); - r->value () = h.value (); - r->value () = h.value (); - - Char const* k = "sskel"; - - r->value () = - find_value (h.value (), k); - r->value () = - find_value (h.value (), k); - r->value () = - find_value (h.value (), k); - - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - r->value () = find_value ( - h.value (), k); - - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - copy_values (r->value (), h.value (), k); - - r->value () = h.value (); - r->value () = h.value (); + auto_ptr r (new Serializer::options); + + static_cast (*r) = h; // Assign common options. + + r->reuse_style_mixin (h.reuse_style_mixin ()); + r->suppress_validation (h.suppress_validation () || + h.suppress_serializer_val ()); + r->generate_polymorphic (h.generate_polymorphic ()); + r->runtime_polymorphic (h.runtime_polymorphic ()); + + r->skel_file_suffix (h.sskel_file_suffix ()); + r->skel_type_suffix (h.sskel_type_suffix ()); + r->impl_type_suffix (h.simpl_type_suffix ()); + + Char const* k = "pskel"; + + r->hxx_regex (find_value (h.hxx_regex (), k)); + r->ixx_regex (find_value (h.ixx_regex (), k)); + r->cxx_regex (find_value (h.cxx_regex (), k)); + + r->prologue_file (find_value (h.prologue_file (), k)); + r->epilogue_file (find_value (h.epilogue_file (), k)); + r->hxx_prologue_file (find_value (h.hxx_prologue_file (), k)); + r->ixx_prologue_file (find_value (h.ixx_prologue_file (), k)); + r->cxx_prologue_file (find_value (h.cxx_prologue_file (), k)); + r->hxx_epilogue_file (find_value (h.hxx_epilogue_file (), k)); + r->ixx_epilogue_file (find_value (h.ixx_epilogue_file (), k)); + r->cxx_epilogue_file (find_value (h.cxx_epilogue_file (), k)); + + copy_values (r->prologue (), h.prologue (), k); + copy_values (r->epilogue (), h.epilogue (), k); + copy_values (r->hxx_prologue (), h.hxx_prologue (), k); + copy_values (r->ixx_prologue (), h.ixx_prologue (), k); + copy_values (r->cxx_prologue (), h.cxx_prologue (), k); + copy_values (r->hxx_epilogue (), h.hxx_epilogue (), k); + copy_values (r->ixx_epilogue (), h.ixx_epilogue (), k); + copy_values (r->cxx_epilogue (), h.cxx_epilogue (), k); // Add the anyType parser. // @@ -591,14 +380,14 @@ namespace CXX ns.dispatch (ctx.xs_ns ()); } - r->value ().push_back (String (os.str ()).to_narrow ()); + r->hxx_prologue ().push_back (String (os.str ()).to_narrow ()); } - return r.release (); + return r; } Void Hybrid::Generator:: - calculate_size (CLI::Options const& ops, + calculate_size (options const& ops, XSDFrontend::SemanticGraph::Schema& schema, XSDFrontend::SemanticGraph::Path const& file, const WarningSet& disabled_warnings) @@ -612,7 +401,7 @@ namespace CXX } Void Hybrid::Generator:: - process_tree_names (CLI::Options const& ops, + process_tree_names (options const& ops, XSDFrontend::SemanticGraph::Schema& schema, XSDFrontend::SemanticGraph::Path const& file) { @@ -621,7 +410,7 @@ namespace CXX } Void Hybrid::Generator:: - process_parser_names (CLI::Options const& ops, + process_parser_names (options const& ops, XSDFrontend::SemanticGraph::Schema& schema, XSDFrontend::SemanticGraph::Path const& file) { @@ -631,7 +420,7 @@ namespace CXX } Void Hybrid::Generator:: - process_serializer_names (CLI::Options const& ops, + process_serializer_names (options const& ops, XSDFrontend::SemanticGraph::Schema& schema, XSDFrontend::SemanticGraph::Path const& file) { @@ -690,19 +479,20 @@ namespace CXX Void append (WideOutputFileStream& os, - Cult::Containers::Vector const& primary, - Cult::Containers::Vector const& def, + NarrowStrings const& primary, + NarrowStrings const& def, Char const* primary_key, Char const* def_key) { - typedef Cult::Containers::Vector Values; - - for (Values const* v = &primary; v != 0; v = (v == &def ? 0 : &def)) + for (NarrowStrings const* v = &primary; + v != 0; + v = (v == &def ? 0 : &def)) { Boolean found (false); Char const* key (v == &primary ? primary_key : def_key); - for (Values::ConstIterator i (v->begin ()), e (v->end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (v->begin ()), e (v->end ()); + i != e; ++i) { if (key == 0) os << i->c_str () << endl; @@ -747,8 +537,8 @@ namespace CXX Void append (WideOutputFileStream& os, - Cult::Containers::Vector const& primary, - Cult::Containers::Vector const& def, + NarrowStrings const& primary, + NarrowStrings const& def, Char const* key) { append (os, primary, def, key, key); @@ -757,7 +547,7 @@ namespace CXX UnsignedLong Hybrid::Generator:: - generate_tree (Hybrid::CLI::Options const& ops, + generate_tree (Hybrid::options const& ops, Schema& schema, Path const& file_path, Boolean fpt, @@ -772,7 +562,7 @@ namespace CXX try { - Boolean generate_xml_schema (ops.value ()); + Boolean 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 @@ -781,7 +571,7 @@ namespace CXX // if (generate_xml_schema) { - if (NarrowString name = ops.value ()) + if (NarrowString name = ops.extern_xml_schema ()) { if (file_path.native_file_string () != name) generate_xml_schema = false; @@ -805,24 +595,20 @@ namespace CXX // Generate code. // - Boolean inline_ (ops.value () && - !generate_xml_schema); - - Boolean forward (ops.value () && - !generate_xml_schema); - + Boolean inline_ (ops.generate_inline () && !generate_xml_schema); + Boolean forward (ops.generate_forward () && !generate_xml_schema); Boolean source (!generate_xml_schema); NarrowString name (file_path.leaf ()); - NarrowString hxx_suffix (ops.value ()); - NarrowString ixx_suffix (ops.value ()); - NarrowString cxx_suffix (ops.value ()); - NarrowString fwd_suffix (ops.value ()); + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString ixx_suffix (ops.ixx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); + NarrowString fwd_suffix (ops.fwd_suffix ()); - NarrowString hxx_regex (find_value (ops.value (), "")); - NarrowString ixx_regex (find_value (ops.value (), "")); - NarrowString cxx_regex (find_value (ops.value (), "")); + NarrowString hxx_regex (find_value (ops.hxx_regex (), "")); + NarrowString ixx_regex (find_value (ops.ixx_regex (), "")); + NarrowString cxx_regex (find_value (ops.cxx_regex (), "")); Regex hxx_expr ( hxx_regex.empty () @@ -840,9 +626,9 @@ namespace CXX : cxx_regex); Regex fwd_expr ( - ops.value ().empty () + ops.fwd_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + fwd_suffix + "#" - : ops.value ()); + : ops.fwd_regex ()); if (!hxx_expr.match (name)) { @@ -888,7 +674,7 @@ namespace CXX Path out_dir; - if (NarrowString dir = ops.value ()) + if (NarrowString dir = ops.output_dir ()) { try { @@ -984,9 +770,7 @@ namespace CXX // Print copyright and license. // Char const* copyright ( - ops.value () - ? copyright_proprietary - : copyright_gpl); + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); if (forward) fwd << copyright; @@ -1003,8 +787,7 @@ namespace CXX // WideInputFileStream prologue; { - NarrowString name ( - find_value (ops.value (), "")); + NarrowString name (find_value (ops.prologue_file (), "")); if (name) open (prologue, name); @@ -1014,8 +797,7 @@ namespace CXX // WideInputFileStream epilogue; { - NarrowString name ( - find_value (ops.value (), "")); + NarrowString name (find_value (ops.epilogue_file (), "")); if (name) open (epilogue, name); @@ -1023,14 +805,14 @@ namespace CXX // SLOC counter. // - UnsignedLong sloc_total (0); - Boolean show_sloc (ops.value ()); + size_t sloc_total (0); + Boolean show_sloc (ops.show_sloc ()); // // 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) guard_prefix = file_path.branch_path ().native_directory_string (); @@ -1073,12 +855,8 @@ namespace CXX fwd << "// Begin prologue." << endl << "//" << endl; - append (fwd, - ops.value (), - ops.value (), - 0, - ""); - append (fwd, ops.value (), prologue); + append (fwd, ops.fwd_prologue (), ops.prologue (), 0, ""); + append (fwd, ops.fwd_prologue_file (), prologue); fwd << "//" << endl << "// End prologue." << endl @@ -1096,12 +874,8 @@ namespace CXX fwd << "// Begin epilogue." << endl << "//" << endl; - append (fwd, ops.value (), epilogue); - append (fwd, - ops.value (), - ops.value (), - 0, - ""); + append (fwd, ops.fwd_epilogue_file (), epilogue); + append (fwd, ops.fwd_epilogue (), ops.epilogue (), 0, ""); fwd << "//" << endl << "// End epilogue." << endl @@ -1155,7 +929,7 @@ namespace CXX hxx << "#include " << endl << endl; - if (ops.value () == "iso8859-1") + if (ops.char_encoding () == "iso8859-1") { hxx << "#ifndef XSDE_ENCODING_ISO8859_1" << endl << "#error the generated code uses the ISO-8859-1 encoding" << @@ -1174,7 +948,7 @@ namespace CXX << endl; } - if (ops.value ()) + if (ops.no_stl ()) { hxx << "#ifdef XSDE_STL" << endl << "#error the XSD/e runtime uses STL while the " << @@ -1193,7 +967,7 @@ namespace CXX << endl; } - if (ops.value ()) + if (ops.no_exceptions ()) { hxx << "#ifdef XSDE_EXCEPTIONS" << endl << "#error the XSD/e runtime uses exceptions while the " << @@ -1212,7 +986,7 @@ namespace CXX << endl; } - if (ops.value ()) + if (ops.no_long_long ()) { hxx << "#ifdef XSDE_LONGLONG" << endl << "#error the XSD/e runtime uses long long while the " << @@ -1231,7 +1005,7 @@ namespace CXX << endl; } - if (ops.value ()) + if (ops.custom_allocator ()) { hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl << "#error the generated code uses custom allocator while " << @@ -1261,13 +1035,8 @@ namespace CXX hxx << "// Begin prologue." << endl << "//" << endl; - append (hxx, - ops.value (), - ops.value (), - ""); - append (hxx, - find_value (ops.value (), ""), - prologue); + append (hxx, ops.hxx_prologue (), ops.prologue (), ""); + append (hxx, find_value (ops.hxx_prologue_file (), ""), prologue); hxx << "//" << endl << "// End prologue." << endl @@ -1288,10 +1057,10 @@ namespace CXX generate_tree_header (ctx); - if (!ops.value ().empty ()) + if (!ops.generate_insertion ().empty ()) generate_insertion_header (ctx); - if (!ops.value ().empty ()) + if (!ops.generate_extraction ().empty ()) generate_extraction_header (ctx); } else @@ -1311,13 +1080,8 @@ namespace CXX hxx << "// Begin epilogue." << endl << "//" << endl; - append (hxx, - find_value (ops.value (), ""), - epilogue); - append (hxx, - ops.value (), - ops.value (), - ""); + append (hxx, find_value (ops.hxx_epilogue_file (), ""), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue (), ""); hxx << "//" << endl << "// End epilogue." << endl @@ -1358,13 +1122,8 @@ namespace CXX ixx << "// Begin prologue." << endl << "//" << endl; - append (ixx, - ops.value (), - ops.value (), - ""); - append (ixx, - find_value (ops.value (), ""), - prologue); + append (ixx, ops.ixx_prologue (), ops.prologue (), ""); + append (ixx, find_value (ops.ixx_prologue_file (), ""), prologue); ixx << "//" << endl << "// End prologue." << endl @@ -1382,13 +1141,8 @@ namespace CXX ixx << "// Begin epilogue." << endl << "//" << endl; - append (ixx, - find_value (ops.value (), ""), - epilogue); - append (ixx, - ops.value (), - ops.value (), - ""); + append (ixx, find_value (ops.ixx_epilogue_file (), ""), epilogue); + append (ixx, ops.ixx_epilogue (), ops.epilogue (), ""); ixx << "//" << endl << "// End epilogue." << endl @@ -1419,13 +1173,8 @@ namespace CXX cxx << "// Begin prologue." << endl << "//" << endl; - append (cxx, - ops.value (), - ops.value (), - ""); - append (cxx, - find_value (ops.value (), ""), - prologue); + append (cxx, ops.cxx_prologue (), ops.prologue (), ""); + append (cxx, find_value (ops.cxx_prologue_file (), ""), prologue); cxx << "//" << endl << "// End prologue." << endl @@ -1444,10 +1193,10 @@ namespace CXX generate_tree_source (ctx); - if (!ops.value ().empty ()) + if (!ops.generate_insertion ().empty ()) generate_insertion_source (ctx); - if (!ops.value ().empty ()) + if (!ops.generate_extraction ().empty ()) generate_extraction_source (ctx); } @@ -1456,13 +1205,8 @@ namespace CXX cxx << "// Begin epilogue." << endl << "//" << endl; - append (cxx, - find_value (ops.value (), ""), - epilogue); - append (cxx, - ops.value (), - ops.value (), - ""); + append (cxx, find_value (ops.cxx_epilogue_file (), ""), epilogue); + append (cxx, ops.cxx_epilogue (), ops.epilogue (), ""); cxx << "//" << endl << "// End epilogue." << endl @@ -1480,15 +1224,14 @@ namespace CXX // Populate the type maps if we are generating parsing or // serialization code. // - if (ops.value () || - ops.value ()) + if (ops.generate_parser () || ops.generate_serializer ()) { generate_tree_type_map (ops, schema, file_path, hxx_name, parser_type_map, serializer_type_map); // Re-map anyType. // - if (ops.value ()) + if (ops.generate_parser ()) { parser_type_map.push_back ( TypeMap::Namespace ("http://www.w3.org/2001/XMLSchema")); @@ -1497,7 +1240,7 @@ namespace CXX xs.types_push_back ("anyType", xs_ns + L"::any_type*"); } - if (ops.value ()) + if (ops.generate_serializer ()) { serializer_type_map.push_back ( TypeMap::Namespace ("http://www.w3.org/2001/XMLSchema")); @@ -1546,7 +1289,7 @@ namespace CXX } UnsignedLong Hybrid::Generator:: - generate_parser (Hybrid::CLI::Options const& ops, + generate_parser (Hybrid::options const& ops, Schema& schema, Path const& file_path, Boolean fpt, @@ -1560,7 +1303,7 @@ namespace CXX try { { - Boolean gen_xml_schema (ops.value ()); + Boolean gen_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 @@ -1569,7 +1312,7 @@ namespace CXX // if (gen_xml_schema) { - if (NarrowString name = ops.value ()) + if (NarrowString name = ops.extern_xml_schema ()) { if (file_path.native_file_string () != name) gen_xml_schema = false; @@ -1590,22 +1333,17 @@ namespace CXX } NarrowString name (file_path.leaf ()); - NarrowString skel_suffix (ops.value ()); - NarrowString impl_suffix (ops.value ()); - - NarrowString hxx_suffix (ops.value ()); - NarrowString cxx_suffix (ops.value ()); + NarrowString skel_suffix (ops.pskel_file_suffix ()); + NarrowString impl_suffix (ops.pimpl_file_suffix ()); - NarrowString hxx_obj_regex ( - find_value (ops.value (), "")); + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); - NarrowString hxx_skel_regex ( - find_value (ops.value (), "pskel")); + NarrowString hxx_obj_regex (find_value (ops.hxx_regex (), "")); + NarrowString hxx_skel_regex (find_value (ops.hxx_regex (), "pskel")); - NarrowString hxx_regex ( - find_value (ops.value (), "pimpl")); - NarrowString cxx_regex ( - find_value (ops.value (), "pimpl")); + NarrowString hxx_regex (find_value (ops.hxx_regex (), "pimpl")); + NarrowString cxx_regex (find_value (ops.cxx_regex (), "pimpl")); // Here we need to make sure that hxx_obj_expr is the same // as in generate(). @@ -1658,7 +1396,7 @@ namespace CXX Path out_dir; - if (NarrowString dir = ops.value ()) + if (NarrowString dir = ops.output_dir ()) { try { @@ -1713,9 +1451,7 @@ namespace CXX // Print copyright and license. // Char const* copyright ( - ops.value () - ? copyright_proprietary - : copyright_gpl); + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); hxx << copyright; cxx << copyright; @@ -1724,8 +1460,7 @@ namespace CXX // WideInputFileStream prologue; { - NarrowString name ( - find_value (ops.value (), "pimpl")); + NarrowString name (find_value (ops.prologue_file (), "pimpl")); if (name) open (prologue, name); @@ -1735,8 +1470,7 @@ namespace CXX // WideInputFileStream epilogue; { - NarrowString name ( - find_value (ops.value (), "pimpl")); + NarrowString name (find_value (ops.epilogue_file (), "pimpl")); if (name) open (epilogue, name); @@ -1744,14 +1478,14 @@ namespace CXX // SLOC counter. // - UnsignedLong sloc_total (0); - Boolean show_sloc (ops.value ()); + size_t sloc_total (0); + Boolean show_sloc (ops.show_sloc ()); // // 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) guard_prefix = file_path.branch_path ().native_directory_string (); @@ -1759,7 +1493,7 @@ namespace CXX if (guard_prefix) guard_prefix += '_'; - Boolean aggr (ops.value ()); + Boolean aggr (ops.generate_aggregate ()); // HXX // @@ -1784,13 +1518,8 @@ namespace CXX hxx << "// Begin prologue." << endl << "//" << endl; - append (hxx, - ops.value (), - ops.value (), - "pimpl"); - append (hxx, - find_value (ops.value (), "pimpl"), - prologue); + append (hxx, ops.hxx_prologue (), ops.prologue (), "pimpl"); + append (hxx, find_value (ops.hxx_prologue_file (), "pimpl"), prologue); hxx << "//" << endl << "// End prologue." << endl @@ -1838,13 +1567,8 @@ namespace CXX hxx << "// Begin epilogue." << endl << "//" << endl; - append (hxx, - find_value (ops.value (), "pimpl"), - epilogue); - append (hxx, - ops.value (), - ops.value (), - "pimpl"); + append (hxx, find_value (ops.hxx_epilogue_file (), "pimpl"), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue (), "pimpl"); hxx << "//" << endl << "// End epilogue." << endl @@ -1873,13 +1597,8 @@ namespace CXX cxx << "// Begin prologue." << endl << "//" << endl; - append (cxx, - ops.value (), - ops.value (), - "pimpl"); - append (cxx, - find_value (ops.value (), "pimpl"), - prologue); + append (cxx, ops.cxx_prologue (), ops.prologue (), "pimpl"); + append (cxx, find_value (ops.cxx_prologue_file (), "pimpl"), prologue); cxx << "//" << endl << "// End prologue." << endl @@ -1904,13 +1623,8 @@ namespace CXX cxx << "// Begin epilogue." << endl << "//" << endl; - append (cxx, - find_value (ops.value (), "pimpl"), - epilogue); - append (cxx, - ops.value (), - ops.value (), - "pimpl"); + append (cxx, find_value (ops.cxx_epilogue_file (), "pimpl"), epilogue); + append (cxx, ops.cxx_epilogue (), ops.epilogue (), "pimpl"); cxx << "//" << endl << "// End epilogue." << endl @@ -1961,7 +1675,7 @@ namespace CXX } UnsignedLong Hybrid::Generator:: - generate_serializer (Hybrid::CLI::Options const& ops, + generate_serializer (Hybrid::options const& ops, Schema& schema, Path const& file_path, Boolean fpt, @@ -1975,7 +1689,7 @@ namespace CXX try { { - Boolean gen_xml_schema (ops.value ()); + Boolean gen_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 @@ -1984,7 +1698,7 @@ namespace CXX // if (gen_xml_schema) { - if (NarrowString name = ops.value ()) + if (NarrowString name = ops.extern_xml_schema ()) { if (file_path.native_file_string () != name) gen_xml_schema = false; @@ -2005,21 +1719,17 @@ namespace CXX } NarrowString name (file_path.leaf ()); - NarrowString skel_suffix (ops.value ()); - NarrowString impl_suffix (ops.value ()); + NarrowString skel_suffix (ops.sskel_file_suffix ()); + NarrowString impl_suffix (ops.simpl_file_suffix ()); - NarrowString hxx_suffix (ops.value ()); - NarrowString cxx_suffix (ops.value ()); + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); - NarrowString hxx_obj_regex ( - find_value (ops.value (), "")); + NarrowString hxx_obj_regex (find_value (ops.hxx_regex (), "")); - NarrowString hxx_skel_regex ( - find_value (ops.value (), "sskel")); - NarrowString hxx_regex ( - find_value (ops.value (), "simpl")); - NarrowString cxx_regex ( - find_value (ops.value (), "simpl")); + NarrowString hxx_skel_regex (find_value (ops.hxx_regex (), "sskel")); + NarrowString hxx_regex (find_value (ops.hxx_regex (), "simpl")); + NarrowString cxx_regex (find_value (ops.cxx_regex (), "simpl")); // Here we need to make sure that hxx_obj_expr is the same // as in generate(). @@ -2072,7 +1782,7 @@ namespace CXX Path out_dir; - if (NarrowString dir = ops.value ()) + if (NarrowString dir = ops.output_dir ()) { try { @@ -2127,9 +1837,7 @@ namespace CXX // Print copyright and license. // Char const* copyright ( - ops.value () - ? copyright_proprietary - : copyright_gpl); + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); hxx << copyright; cxx << copyright; @@ -2138,8 +1846,7 @@ namespace CXX // WideInputFileStream prologue; { - NarrowString name ( - find_value (ops.value (), "simpl")); + NarrowString name (find_value (ops.prologue_file (), "simpl")); if (name) open (prologue, name); @@ -2149,8 +1856,7 @@ namespace CXX // WideInputFileStream epilogue; { - NarrowString name ( - find_value (ops.value (), "simpl")); + NarrowString name (find_value (ops.epilogue_file (), "simpl")); if (name) open (epilogue, name); @@ -2158,14 +1864,14 @@ namespace CXX // SLOC counter. // - UnsignedLong sloc_total (0); - Boolean show_sloc (ops.value ()); + size_t sloc_total (0); + Boolean show_sloc (ops.show_sloc ()); // // 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) guard_prefix = file_path.branch_path ().native_directory_string (); @@ -2173,7 +1879,7 @@ namespace CXX if (guard_prefix) guard_prefix += '_'; - Boolean aggr (ops.value ()); + Boolean aggr (ops.generate_aggregate ()); // HXX // @@ -2198,13 +1904,8 @@ namespace CXX hxx << "// Begin prologue." << endl << "//" << endl; - append (hxx, - ops.value (), - ops.value (), - "simpl"); - append (hxx, - find_value (ops.value (), "simpl"), - prologue); + append (hxx, ops.hxx_prologue (), ops.prologue (), "simpl"); + append (hxx, find_value (ops.hxx_prologue_file (), "simpl"), prologue); hxx << "//" << endl << "// End prologue." << endl @@ -2252,13 +1953,8 @@ namespace CXX hxx << "// Begin epilogue." << endl << "//" << endl; - append (hxx, - find_value (ops.value (), "simpl"), - epilogue); - append (hxx, - ops.value (), - ops.value (), - "simpl"); + append (hxx, find_value (ops.hxx_epilogue_file (), "simpl"), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue (), "simpl"); hxx << "//" << endl << "// End epilogue." << endl @@ -2287,13 +1983,8 @@ namespace CXX cxx << "// Begin prologue." << endl << "//" << endl; - append (cxx, - ops.value (), - ops.value (), - "simpl"); - append (cxx, - find_value (ops.value (), "simpl"), - prologue); + append (cxx, ops.cxx_prologue (), ops.prologue (), "simpl"); + append (cxx, find_value (ops.cxx_prologue_file (), "simpl"), prologue); cxx << "//" << endl << "// End prologue." << endl @@ -2318,13 +2009,8 @@ namespace CXX cxx << "// Begin epilogue." << endl << "//" << endl; - append (cxx, - find_value (ops.value (), "simpl"), - epilogue); - append (cxx, - ops.value (), - ops.value (), - "simpl"); + append (cxx, find_value (ops.cxx_epilogue_file (), "simpl"), epilogue); + append (cxx, ops.cxx_epilogue (), ops.epilogue (), "simpl"); cxx << "//" << endl << "// End epilogue." << endl diff --git a/xsde/cxx/hybrid/generator.hxx b/xsde/cxx/hybrid/generator.hxx index 0b87007..cbef109 100644 --- a/xsde/cxx/hybrid/generator.hxx +++ b/xsde/cxx/hybrid/generator.hxx @@ -6,22 +6,21 @@ #ifndef CXX_HYBRID_GENERATOR_HXX #define CXX_HYBRID_GENERATOR_HXX +#include // std::auto_ptr + #include #include -#include -#include - #include // Path #include #include #include -#include -#include -#include +#include +#include +#include namespace CXX { @@ -37,16 +36,13 @@ namespace CXX static Void usage (); - static CLI::OptionsSpec - options_spec (); - - static Parser::CLI::Options* - parser_options (CLI::Options const&, + static std::auto_ptr + parser_options (options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&); - static Serializer::CLI::Options* - serializer_options (CLI::Options const&, + static std::auto_ptr + serializer_options (options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&); @@ -54,7 +50,7 @@ namespace CXX // static Void calculate_size ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, WarningSet const& disabled_warnings); @@ -63,19 +59,19 @@ namespace CXX // static Void process_tree_names ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&); static Void process_parser_names ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&); static Void process_serializer_names ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&); @@ -83,7 +79,7 @@ namespace CXX // static UnsignedLong generate_tree ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, Boolean file_per_type, @@ -95,7 +91,7 @@ namespace CXX static UnsignedLong generate_parser ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, Boolean file_per_type, @@ -105,7 +101,7 @@ namespace CXX static UnsignedLong generate_serializer ( - CLI::Options const&, + options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, Boolean file_per_type, diff --git a/xsde/cxx/hybrid/insertion-header.cxx b/xsde/cxx/hybrid/insertion-header.cxx index 887b948..a054d9e 100644 --- a/xsde/cxx/hybrid/insertion-header.cxx +++ b/xsde/cxx/hybrid/insertion-header.cxx @@ -41,7 +41,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -73,7 +73,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -102,7 +102,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -135,7 +135,7 @@ namespace CXX String const& type (etype (a)); String const& scope (Context::scope (a)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -165,7 +165,7 @@ namespace CXX String const& type (etype (c)); String const& scope (Context::scope (c)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -201,7 +201,7 @@ namespace CXX String const& type (etype (s)); String const& scope (Context::scope (s)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -256,7 +256,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl diff --git a/xsde/cxx/hybrid/insertion-source.cxx b/xsde/cxx/hybrid/insertion-source.cxx index 0c034dc..d579964 100644 --- a/xsde/cxx/hybrid/insertion-source.cxx +++ b/xsde/cxx/hybrid/insertion-source.cxx @@ -41,7 +41,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -77,7 +77,7 @@ namespace CXX if (!name) return; - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -118,7 +118,7 @@ namespace CXX String const& value (u.context ().get ("value")); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -475,7 +475,7 @@ namespace CXX String const& type (etype (a)); String const& scope (Context::scope (a)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -518,7 +518,7 @@ namespace CXX String const& type (etype (c)); String const& scope (Context::scope (c)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -581,7 +581,7 @@ namespace CXX String const& type (etype (s)); String const& scope (Context::scope (s)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl @@ -680,7 +680,7 @@ namespace CXX Boolean restriction (restriction_p (c)); - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { os << (exceptions ? "void" : "bool") << endl diff --git a/xsde/cxx/hybrid/options.cli b/xsde/cxx/hybrid/options.cli index 40df945..33b05b0 100644 --- a/xsde/cxx/hybrid/options.cli +++ b/xsde/cxx/hybrid/options.cli @@ -335,10 +335,10 @@ namespace CXX names of generated serializer implementation files." }; - Cult::Types::NarrowString --paggr-type-suffix = "_paggs" + Cult::Types::NarrowString --paggr-type-suffix = "_paggr" { "", - "Use instead of the default \cb{_paggs} to construct the + "Use instead of the default \cb{_paggr} to construct the names of generated parser aggregates." }; @@ -348,6 +348,24 @@ namespace CXX "Use instead of the default \cb{_saggr} to construct the names of generated serializer aggregates." }; + + // In C++/Hybrid these common options can be specified multiple + // times with keys that identify which files they apply to. So + // "override" them here. Note that the documentation is still + // specified in the common version. + // + std::vector --hxx-regex; + std::vector --ixx-regex; + std::vector --cxx-regex; + + std::vector --hxx-prologue-file; + std::vector --ixx-prologue-file; + std::vector --cxx-prologue-file; + std::vector --prologue-file; + std::vector --hxx-epilogue-file; + std::vector --ixx-epilogue-file; + std::vector --cxx-epilogue-file; + std::vector --epilogue-file; }; } } diff --git a/xsde/cxx/hybrid/parser-header.cxx b/xsde/cxx/hybrid/parser-header.cxx index 1e96dac..64a7f55 100644 --- a/xsde/cxx/hybrid/parser-header.cxx +++ b/xsde/cxx/hybrid/parser-header.cxx @@ -74,8 +74,8 @@ namespace CXX if (name) { Boolean fl (fixed_length (e)); - Boolean val (!options.value () && - !options.value ()); + Boolean val (!options.suppress_validation () && + !options.suppress_parser_val ()); SemanticGraph::Type& b (e.inherits ().base ()); diff --git a/xsde/cxx/hybrid/parser-name-processor.cxx b/xsde/cxx/hybrid/parser-name-processor.cxx index 99d11fa..d5f7edd 100644 --- a/xsde/cxx/hybrid/parser-name-processor.cxx +++ b/xsde/cxx/hybrid/parser-name-processor.cxx @@ -31,31 +31,17 @@ namespace CXX class Context: public CXX::Context { public: - Context (CLI::Options const& ops, + typedef Hybrid::options options_type; + + public: + Context (options_type const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path) - : CXX::Context (std::wcerr, - root, - path, - "name", - "char", - ops.value (), - ops.value (), - ops.value (), - "", // export symbol - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - !ops.value (), - ops.value ()), - impl_suffix_ (ops.value ()), - aggr_suffix_ (ops.value ()), + : CXX::Context (std::wcerr, root, path, ops, "name", "char"), + impl_suffix_ (ops.pimpl_type_suffix ()), + aggr_suffix_ (ops.paggr_type_suffix ()), options (ops), - aggregate (ops.value ()), + aggregate (ops.generate_aggregate ()), impl_suffix (impl_suffix_), aggr_suffix (aggr_suffix_), custom_parser_map (custom_parser_map_), @@ -63,10 +49,9 @@ namespace CXX { // Custom parser mapping. // - typedef Containers::Vector Vector; - Vector const& v (ops.value ()); + NarrowStrings const& v (ops.custom_parser ()); - for (Vector::ConstIterator i (v.begin ()), e (v.end ()); + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); i != e; ++i) { String s (*i); @@ -239,7 +224,7 @@ namespace CXX Cult::Containers::Map global_type_names_; public: - CLI::Options const& options; + options_type const& options; Boolean aggregate; String const& impl_suffix; String const& aggr_suffix; @@ -265,7 +250,7 @@ namespace CXX // Type* base_enum (0); - if (options.value () || + if (options.suppress_enum () || !Hybrid::Context::enum_mapping (e, &base_enum)) { complex_.traverse (e); @@ -530,12 +515,11 @@ namespace CXX if (aggregate) { - typedef Cult::Containers::Vector Names; - Names const& names (options.value ()); + NarrowStrings const& names (options.root_type ()); // Hopefully nobody will specify more than a handful of names. // - for (Names::ConstIterator i (names.begin ()); + for (NarrowStrings::const_iterator i (names.begin ()); i != names.end (); ++i) { if (name == String (*i)) @@ -562,7 +546,7 @@ namespace CXX ~GlobalElement () { - if (last_ != 0 && options.value ()) + if (last_ != 0 && options.root_element_last ()) process (*last_); } @@ -571,34 +555,33 @@ namespace CXX { Boolean p (false); - if (last_ == 0 && options.value ()) + if (last_ == 0 && options.root_element_first ()) p = true; last_ = &e; if (!p && - !options.value () && - !options.value () && - !options.value () && - !options.value () && - options.value ().empty ()) + !options.root_element_first () && + !options.root_element_last () && + !options.root_element_all () && + !options.root_element_none () && + options.root_element ().empty ()) { // By default process them all. // p = true; } - if (!p && options.value ()) + if (!p && options.root_element_all ()) p = true; if (!p) { - typedef Cult::Containers::Vector Names; - Names const& names (options.value ()); + NarrowStrings const& names (options.root_element ()); // Hopefully nobody will specify more than a handful of names. // - for (Names::ConstIterator i (names.begin ()); + for (NarrowStrings::const_iterator i (names.begin ()); !p && i != names.end (); ++i) { @@ -728,7 +711,7 @@ namespace CXX Char const* Uses::seen_key = "cxx-hybrid-parser-name-processor-seen"; Void - process_impl (CLI::Options const& ops, + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, Boolean deep) @@ -794,7 +777,7 @@ namespace CXX } Boolean ParserNameProcessor:: - process (CLI::Options const& ops, + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, Boolean deep) diff --git a/xsde/cxx/hybrid/parser-name-processor.hxx b/xsde/cxx/hybrid/parser-name-processor.hxx index 1a1ab58..20721ee 100644 --- a/xsde/cxx/hybrid/parser-name-processor.hxx +++ b/xsde/cxx/hybrid/parser-name-processor.hxx @@ -10,7 +10,7 @@ #include -#include +#include namespace CXX { @@ -22,7 +22,7 @@ namespace CXX { public: Boolean - process (CLI::Options const& options, + process (options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, Boolean deep); diff --git a/xsde/cxx/hybrid/parser-source.cxx b/xsde/cxx/hybrid/parser-source.cxx index 63afd43..3b6ed31 100644 --- a/xsde/cxx/hybrid/parser-source.cxx +++ b/xsde/cxx/hybrid/parser-source.cxx @@ -121,8 +121,8 @@ namespace CXX Boolean fl (fixed_length (e)); - Boolean val (!options.value () && - !options.value ()); + Boolean val (!options.suppress_validation () && + !options.suppress_parser_val ()); SemanticGraph::Context& ec (e.context ()); SemanticGraph::Type& b (e.inherits ().base ()); @@ -1611,8 +1611,8 @@ namespace CXX Boolean fixed (fixed_length (c)); Boolean rec (recursive (c)); - Boolean validation (!options.value () && - !options.value ()); + Boolean validation (!options.suppress_validation () && + !options.suppress_parser_val ()); Boolean c_string_base (false); if (!stl && hb) @@ -2093,8 +2093,8 @@ namespace CXX { // We need this functionality for enum mapping. // - if (!ctx.options.value () && - !ctx.options.value ()) + if (!ctx.options.suppress_validation () && + !ctx.options.suppress_parser_val ()) ctx.os << "#include " << endl << endl; else diff --git a/xsde/cxx/hybrid/serializer-name-processor.cxx b/xsde/cxx/hybrid/serializer-name-processor.cxx index b8cec72..4071ecb 100644 --- a/xsde/cxx/hybrid/serializer-name-processor.cxx +++ b/xsde/cxx/hybrid/serializer-name-processor.cxx @@ -30,31 +30,17 @@ namespace CXX class Context: public CXX::Context { public: - Context (CLI::Options const& ops, + typedef Hybrid::options options_type; + + public: + Context (options_type const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path) - : CXX::Context (std::wcerr, - root, - path, - "name", - "char", - ops.value (), - ops.value (), - ops.value (), - "", // export symbol - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - !ops.value (), - ops.value ()), - impl_suffix_ (ops.value ()), - aggr_suffix_ (ops.value ()), + : CXX::Context (std::wcerr, root, path, ops, "name", "char"), + impl_suffix_ (ops.simpl_type_suffix ()), + aggr_suffix_ (ops.saggr_type_suffix ()), options (ops), - aggregate (ops.value ()), + aggregate (ops.generate_aggregate ()), impl_suffix (impl_suffix_), aggr_suffix (aggr_suffix_), custom_serializer_map (custom_serializer_map_), @@ -62,10 +48,9 @@ namespace CXX { // Custom serializer mapping. // - typedef Containers::Vector Vector; - Vector const& v (ops.value ()); + NarrowStrings const& v (ops.custom_serializer ()); - for (Vector::ConstIterator i (v.begin ()), e (v.end ()); + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); i != e; ++i) { String s (*i); @@ -232,7 +217,7 @@ namespace CXX Cult::Containers::Map global_type_names_; public: - CLI::Options const& options; + options_type const& options; Boolean aggregate; String const& impl_suffix; String const& aggr_suffix; @@ -258,7 +243,7 @@ namespace CXX // Type* base_enum (0); - if (options.value () || + if (options.suppress_enum () || !Hybrid::Context::enum_mapping (e, &base_enum)) { complex_.traverse (e); @@ -538,12 +523,11 @@ namespace CXX if (aggregate) { - typedef Cult::Containers::Vector Names; - Names const& names (options.value ()); + NarrowStrings const& names (options.root_type ()); // Hopefully nobody will specify more than a handful of names. // - for (Names::ConstIterator i (names.begin ()); + for (NarrowStrings::const_iterator i (names.begin ()); i != names.end (); ++i) { if (name == String (*i)) @@ -570,7 +554,7 @@ namespace CXX ~GlobalElement () { - if (last_ != 0 && options.value ()) + if (last_ != 0 && options.root_element_last ()) process (*last_); } @@ -579,36 +563,34 @@ namespace CXX { Boolean p (false); - if (last_ == 0 && options.value ()) + if (last_ == 0 && options.root_element_first ()) p = true; last_ = &e; if (!p && - !options.value () && - !options.value () && - !options.value () && - !options.value () && - options.value ().empty ()) + !options.root_element_first () && + !options.root_element_last () && + !options.root_element_all () && + !options.root_element_none () && + options.root_element ().empty ()) { // By default process them all. // p = true; } - if (!p && options.value ()) + if (!p && options.root_element_all ()) p = true; if (!p) { - typedef Cult::Containers::Vector Names; - Names const& names (options.value ()); + NarrowStrings const& names (options.root_element ()); // Hopefully nobody will specify more than a handful of names. // - for (Names::ConstIterator i (names.begin ()); - !p && i != names.end (); - ++i) + for (NarrowStrings::const_iterator i (names.begin ()); + !p && i != names.end (); ++i) { if (e.name () == String (*i)) p = true; @@ -736,7 +718,7 @@ namespace CXX Char const* Uses::seen_key = "cxx-hybrid-serializer-name-processor-seen"; Void - process_impl (CLI::Options const& ops, + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, Boolean deep) @@ -802,7 +784,7 @@ namespace CXX } Boolean SerializerNameProcessor:: - process (CLI::Options const& ops, + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, Boolean deep) diff --git a/xsde/cxx/hybrid/serializer-name-processor.hxx b/xsde/cxx/hybrid/serializer-name-processor.hxx index 83f1ea9..0840f52 100644 --- a/xsde/cxx/hybrid/serializer-name-processor.hxx +++ b/xsde/cxx/hybrid/serializer-name-processor.hxx @@ -10,7 +10,7 @@ #include -#include +#include namespace CXX { @@ -22,7 +22,7 @@ namespace CXX { public: Boolean - process (CLI::Options const& options, + process (options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, Boolean deep); diff --git a/xsde/cxx/hybrid/serializer-source.cxx b/xsde/cxx/hybrid/serializer-source.cxx index e267407..d99d167 100644 --- a/xsde/cxx/hybrid/serializer-source.cxx +++ b/xsde/cxx/hybrid/serializer-source.cxx @@ -206,8 +206,8 @@ namespace CXX << "_serialize_content ()" << "{"; - if (!options.value () && - !options.value ()) + if (!options.suppress_validation () && + !options.suppress_serializer_val ()) { // Do facet validation. // @@ -1056,7 +1056,7 @@ namespace CXX if (a.default_p ()) { - Boolean omit (options.value ()); + Boolean omit (options.omit_default_attributes ()); if (a.fixed_p ()) os << "return " << (omit ? "false" : "true") << ";"; @@ -1144,8 +1144,8 @@ namespace CXX Boolean rec (recursive (c)); Boolean restriction (restriction_p (c)); - Boolean validation (!options.value () && - !options.value ()); + Boolean validation (!options.suppress_validation () && + !options.suppress_serializer_val ()); String state; String member; @@ -1400,8 +1400,8 @@ namespace CXX << endl; if (ctx.enum_ && - !ctx.options.value () && - !ctx.options.value ()) + !ctx.options.suppress_validation () && + !ctx.options.suppress_serializer_val ()) { // We need this functionality for enum mapping. // diff --git a/xsde/cxx/hybrid/tree-forward.cxx b/xsde/cxx/hybrid/tree-forward.cxx index b220847..6fbd424 100644 --- a/xsde/cxx/hybrid/tree-forward.cxx +++ b/xsde/cxx/hybrid/tree-forward.cxx @@ -220,7 +220,7 @@ namespace CXX else string_type_ = L"char*"; - if (options.value ()) + if (options.no_long_long ()) { long_type_ = L"long"; unsigned_long_type_ = L"unsigned long"; @@ -670,7 +670,7 @@ namespace CXX Boolean icdr (false), ocdr (false); Boolean ixdr (false), oxdr (false); - for (Streams::ConstIterator i (istreams.begin ()); + for (NarrowStrings::const_iterator i (istreams.begin ()); i != istreams.end (); ++i) { if (*i == "CDR") @@ -679,7 +679,7 @@ namespace CXX ixdr = true; } - for (Streams::ConstIterator i (ostreams.begin ()); + for (NarrowStrings::const_iterator i (ostreams.begin ()); i != ostreams.end (); ++i) { if (*i == "CDR") @@ -724,7 +724,7 @@ namespace CXX Void generate_tree_forward (Context& ctx, Boolean generate_xml_schema) { - NarrowString xml_schema (ctx.options.value ()); + NarrowString xml_schema (ctx.options.extern_xml_schema ()); // Inlcude or Emit fundamental types. // @@ -752,7 +752,7 @@ namespace CXX // Data representation stream includes. // - for (Context::Streams::ConstIterator i (ctx.istreams.begin ()); + for (NarrowStrings::const_iterator i (ctx.istreams.begin ()); i != ctx.istreams.end (); ++i) { if (*i == "CDR") @@ -763,7 +763,7 @@ namespace CXX << endl; } - for (Context::Streams::ConstIterator i (ctx.ostreams.begin ()); + for (NarrowStrings::const_iterator i (ctx.ostreams.begin ()); i != ctx.ostreams.end (); ++i) { if (*i == "CDR") diff --git a/xsde/cxx/hybrid/tree-header.cxx b/xsde/cxx/hybrid/tree-header.cxx index 123b235..ae24feb 100644 --- a/xsde/cxx/hybrid/tree-header.cxx +++ b/xsde/cxx/hybrid/tree-header.cxx @@ -787,7 +787,7 @@ namespace CXX virtual Void traverse (SemanticGraph::Fundamental::Long&) { - if (options.value ()) + if (options.no_long_long ()) align_type ("long", 5); else align_type ("long long", 8); @@ -796,7 +796,7 @@ namespace CXX virtual Void traverse (SemanticGraph::Fundamental::UnsignedLong&) { - if (options.value ()) + if (options.no_long_long ()) align_type ("unsigned long", 5); else align_type ("unsigned long long", 8); @@ -2946,7 +2946,7 @@ namespace CXX Void generate_tree_header (Context& ctx) { - Boolean inline_ (ctx.options.value ()); + Boolean inline_ (ctx.options.generate_inline ()); // Emit header includes. // diff --git a/xsde/cxx/hybrid/tree-inline.cxx b/xsde/cxx/hybrid/tree-inline.cxx index 748184c..2f6815e 100644 --- a/xsde/cxx/hybrid/tree-inline.cxx +++ b/xsde/cxx/hybrid/tree-inline.cxx @@ -2067,7 +2067,7 @@ namespace CXX { // Generate includes. // - if (ctx.options.value ()) + if (ctx.options.generate_inline ()) { Traversal::Schema schema; Includes includes (ctx, Includes::inline_); diff --git a/xsde/cxx/hybrid/tree-name-processor.cxx b/xsde/cxx/hybrid/tree-name-processor.cxx index a2d630d..0558907 100644 --- a/xsde/cxx/hybrid/tree-name-processor.cxx +++ b/xsde/cxx/hybrid/tree-name-processor.cxx @@ -31,30 +31,16 @@ namespace CXX class Context: public CXX::Context { public: - Context (CLI::Options const& ops, + typedef Hybrid::options options_type; + + public: + Context (options_type const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path) - : CXX::Context (std::wcerr, - root, - path, - "name", - "char", - ops.value (), - ops.value (), - ops.value (), - "", // export symbol - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - !ops.value (), - ops.value ()), - stl (!ops.value ()), - detach (ops.value ()), - enum_ (!ops.value ()), + : CXX::Context (std::wcerr, root, path, ops, "name", "char"), + stl (!ops.no_stl ()), + detach (ops.generate_detach ()), + enum_ (!ops.suppress_enum ()), custom_data_map (custom_data_map_), custom_type_map (custom_type_map_), global_type_names (global_type_names_) @@ -62,10 +48,9 @@ namespace CXX // Translate the type names with custom data. // { - typedef Cult::Containers::Vector CustomData; - CustomData const& cd (ops.value ()); + NarrowStrings const& cd (ops.custom_data ()); - for (CustomData::ConstIterator i (cd.begin ()); + for (NarrowStrings::const_iterator i (cd.begin ()); i != cd.end (); ++i) { String name (*i); @@ -102,10 +87,9 @@ namespace CXX // Custom type mapping. // { - typedef Containers::Vector Vector; - Vector const& v (ops.value ()); + NarrowStrings const& v (ops.custom_type ()); - for (Vector::ConstIterator i (v.begin ()), e (v.end ()); + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); i != e; ++i) { String s (*i); @@ -2197,7 +2181,7 @@ namespace CXX }; Void - process_impl (CLI::Options const& ops, + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, Boolean deep) @@ -2311,7 +2295,7 @@ namespace CXX } Void TreeNameProcessor:: - process (CLI::Options const& ops, + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, Boolean deep) diff --git a/xsde/cxx/hybrid/tree-name-processor.hxx b/xsde/cxx/hybrid/tree-name-processor.hxx index d1c6dba..fff1fb8 100644 --- a/xsde/cxx/hybrid/tree-name-processor.hxx +++ b/xsde/cxx/hybrid/tree-name-processor.hxx @@ -10,7 +10,7 @@ #include -#include +#include namespace CXX { @@ -22,7 +22,7 @@ namespace CXX { public: Void - process (CLI::Options const& options, + process (options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, Boolean deep); diff --git a/xsde/cxx/hybrid/tree-size-processor.cxx b/xsde/cxx/hybrid/tree-size-processor.cxx index 6b3b978..0d734ca 100644 --- a/xsde/cxx/hybrid/tree-size-processor.cxx +++ b/xsde/cxx/hybrid/tree-size-processor.cxx @@ -1026,25 +1026,22 @@ namespace CXX Char const* pass_two_key = "cxx-hybrid-size-processor-seen-two"; Boolean - process_impl (CLI::Options const& ops, + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const&, const WarningSet& disabled_warnings) { Boolean valid (true); - Boolean stl (!ops.value ()); - Boolean poly (ops.value ()); + Boolean stl (!ops.no_stl ()); + Boolean poly (ops.generate_polymorphic ()); // Prepare a set of polymorphic types. // TypeSet poly_types; if (poly) - { - poly_types.insert ( - ops.value ().begin (), - ops.value ().end ()); - } + poly_types.insert (ops.polymorphic_type ().begin (), + ops.polymorphic_type ().end ()); // Root schema in the file-per-type mode is just a bunch // of includes without a namespace. @@ -1103,10 +1100,9 @@ namespace CXX TypeSet custom_data_types; { - typedef Cult::Containers::Vector CustomData; - CustomData const& cd (ops.value ()); + NarrowStrings const& cd (ops.custom_data ()); - for (CustomData::ConstIterator i (cd.begin ()); + for (NarrowStrings::const_iterator i (cd.begin ()); i != cd.end (); ++i) { String n (*i); @@ -1119,10 +1115,9 @@ namespace CXX CustomTypeMap custom_type_map; { - typedef Containers::Vector Vector; - Vector const& v (ops.value ()); + NarrowStrings const& v (ops.custom_type ()); - for (Vector::ConstIterator i (v.begin ()), e (v.end ()); + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); i != e; ++i) { String s (*i); @@ -1226,7 +1221,7 @@ namespace CXX poly_types, stl, poly, - !ops.value ()); + !ops.suppress_enum ()); schema >> schema_names >> ns >> ns_names >> type; @@ -1244,7 +1239,7 @@ namespace CXX } Boolean TreeSizeProcessor:: - process (CLI::Options const& ops, + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, const WarningSet& disabled_warnings) diff --git a/xsde/cxx/hybrid/tree-size-processor.hxx b/xsde/cxx/hybrid/tree-size-processor.hxx index 05bdb65..6f13401 100644 --- a/xsde/cxx/hybrid/tree-size-processor.hxx +++ b/xsde/cxx/hybrid/tree-size-processor.hxx @@ -10,7 +10,7 @@ #include -#include +#include #include @@ -24,7 +24,7 @@ namespace CXX { public: Boolean - process (CLI::Options const& options, + process (options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, const WarningSet& disabled_warnings); diff --git a/xsde/cxx/hybrid/tree-type-map.cxx b/xsde/cxx/hybrid/tree-type-map.cxx index f2806c3..7825725 100644 --- a/xsde/cxx/hybrid/tree-type-map.cxx +++ b/xsde/cxx/hybrid/tree-type-map.cxx @@ -22,27 +22,10 @@ namespace CXX class Context: public CXX::Context { public: - Context (CLI::Options const& ops, + Context (Hybrid::options const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path) - : CXX::Context (std::wcerr, - root, - path, - "name", - "char", - ops.value (), - ops.value (), - ops.value (), - "", // export symbol - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - ops.value (), - !ops.value (), - ops.value ()) + : CXX::Context (std::wcerr, root, path, ops, "name", "char") { } @@ -205,7 +188,7 @@ namespace CXX } Void - generate_tree_type_map (CLI::Options const& ops, + generate_tree_type_map (options const& ops, XSDFrontend::SemanticGraph::Schema& tu, XSDFrontend::SemanticGraph::Path const& path, String const& hxx_name, @@ -229,16 +212,16 @@ namespace CXX Traversal::Names schema_names; Namespace ns ( ctx, &hxx_name, - (ops.value () ? &parser_map : 0), - (ops.value () ? &serializer_map : 0)); + (ops.generate_parser () ? &parser_map : 0), + (ops.generate_serializer () ? &serializer_map : 0)); schema >> schema_names >> ns; Traversal::Names used_schema_names; Namespace used_ns ( ctx, 0, - (ops.value () ? &parser_map : 0), - (ops.value () ? &serializer_map : 0)); + (ops.generate_parser () ? &parser_map : 0), + (ops.generate_serializer () ? &serializer_map : 0)); used_schema >> used_schema_names >> used_ns; diff --git a/xsde/cxx/hybrid/tree-type-map.hxx b/xsde/cxx/hybrid/tree-type-map.hxx index 2b75564..0f677cd 100644 --- a/xsde/cxx/hybrid/tree-type-map.hxx +++ b/xsde/cxx/hybrid/tree-type-map.hxx @@ -12,7 +12,7 @@ #include -#include +#include namespace CXX { @@ -21,7 +21,7 @@ namespace CXX using namespace Cult::Types; Void - generate_tree_type_map (CLI::Options const& options, + generate_tree_type_map (options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const&, String const& hxx_name, diff --git a/xsde/cxx/hybrid/validator.cxx b/xsde/cxx/hybrid/validator.cxx index 70d8b1c..2b13097 100644 --- a/xsde/cxx/hybrid/validator.cxx +++ b/xsde/cxx/hybrid/validator.cxx @@ -28,10 +28,10 @@ namespace CXX public: ValidationContext (SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& options, + Hybrid::options const& ops, const WarningSet& disabled_warnings, Boolean& valid_) - : Context (std::wcerr, root, path, options, 0, 0, 0), + : Context (std::wcerr, root, path, ops, 0, 0, 0), disabled_warnings_ (disabled_warnings), disabled_warnings_all_ (false), valid (valid_), @@ -160,7 +160,7 @@ namespace CXX return; if (e.substitutes_p () && - !options.value () && + !options.generate_polymorphic () && !subst_group_warning_issued) { subst_group_warning_issued = true; @@ -245,7 +245,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; @@ -274,7 +274,7 @@ namespace CXX { if (traverse_common (e)) { - if (options.value ()) + if (options.show_anonymous ()) { wcerr << e.file () << ":" << e.line () << ":" << e.column () << ": error: element '" << xpath (e) << "' " @@ -299,7 +299,7 @@ namespace CXX { if (traverse_common (a)) { - if (options.value ()) + if (options.show_anonymous ()) { wcerr << a.file () << ":" << a.line () << ":" << a.column () << ": error: attribute '" << xpath (a) << "' " @@ -482,17 +482,17 @@ namespace CXX } Boolean Validator:: - validate (CLI::Options const& options, + validate (options const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path, const WarningSet& disabled_warnings) { Boolean valid (true); - ValidationContext ctx (root, path, options, disabled_warnings, valid); + ValidationContext ctx (root, path, ops, disabled_warnings, valid); // // - NarrowString enc (options.value ()); + NarrowString enc (ops.char_encoding ()); if (enc != "utf8" && enc != "iso8859-1") { @@ -502,9 +502,9 @@ namespace CXX // // - Boolean par (options.value ()); - Boolean ser (options.value ()); - Boolean agg (options.value ()); + Boolean par (ops.generate_parser ()); + Boolean ser (ops.generate_serializer ()); + Boolean agg (ops.generate_aggregate ()); if (agg && !par && !ser && !ctx.is_disabled ("H002")) { @@ -517,11 +517,11 @@ namespace CXX // are generating aggregate types. // if (agg && - !options.value () && - !options.value () && - !options.value () && - !options.value () && - options.value ().empty () && + !ops.root_element_first () && + !ops.root_element_last () && + !ops.root_element_all () && + !ops.root_element_none () && + ops.root_element ().empty () && !ctx.is_disabled ("H003")) { UnsignedLong count (0); @@ -565,8 +565,7 @@ namespace CXX // Test for constructs that require validation in parser. // if (valid && par && - (options.value () || - options.value ())) + (ops.suppress_validation () || ops.suppress_parser_val ())) { Traversal::Schema schema; Sources sources; diff --git a/xsde/cxx/hybrid/validator.hxx b/xsde/cxx/hybrid/validator.hxx index cbc80ac..ba4cc80 100644 --- a/xsde/cxx/hybrid/validator.hxx +++ b/xsde/cxx/hybrid/validator.hxx @@ -10,7 +10,7 @@ #include -#include +#include #include @@ -24,7 +24,7 @@ namespace CXX { public: Boolean - validate (CLI::Options const& options, + validate (options const& options, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& tu, const WarningSet& disabled_warnings); -- cgit v1.1