aboutsummaryrefslogtreecommitdiff
path: root/xsd/cxx/parser
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-06-20 11:54:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-06-20 11:55:22 +0200
commitc04f7d6ed04d62efafa79a87bcde6c5f62e95327 (patch)
tree500cc93aed55b0809fe04e5a0b7020d9045c65c5 /xsd/cxx/parser
parente14a3f91e6e51430bf9c6978f44c7f46114793fb (diff)
Completion of the CLI port
Diffstat (limited to 'xsd/cxx/parser')
-rw-r--r--xsd/cxx/parser/cli.hxx154
-rw-r--r--xsd/cxx/parser/driver-source.cxx2
-rw-r--r--xsd/cxx/parser/elements.cxx29
-rw-r--r--xsd/cxx/parser/elements.hxx20
-rw-r--r--xsd/cxx/parser/generator.cxx202
-rw-r--r--xsd/cxx/parser/generator.hxx10
-rw-r--r--xsd/cxx/parser/impl-source.cxx12
-rw-r--r--xsd/cxx/parser/name-processor.cxx35
-rw-r--r--xsd/cxx/parser/name-processor.hxx4
-rw-r--r--xsd/cxx/parser/options.cli6
-rw-r--r--xsd/cxx/parser/parser-header.cxx2
-rw-r--r--xsd/cxx/parser/parser-inline.cxx2
-rw-r--r--xsd/cxx/parser/parser-source.cxx6
-rw-r--r--xsd/cxx/parser/type-processor.cxx13
-rw-r--r--xsd/cxx/parser/type-processor.hxx4
-rw-r--r--xsd/cxx/parser/validator.cxx60
-rw-r--r--xsd/cxx/parser/validator.hxx4
17 files changed, 137 insertions, 428 deletions
diff --git a/xsd/cxx/parser/cli.hxx b/xsd/cxx/parser/cli.hxx
deleted file mode 100644
index 4b3184e..0000000
--- a/xsd/cxx/parser/cli.hxx
+++ /dev/null
@@ -1,154 +0,0 @@
-// file : xsd/cxx/parser/cli.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#ifndef CXX_PARSER_CLI_HXX
-#define CXX_PARSER_CLI_HXX
-
-#include <cult/types.hxx>
-
-#include <cult/containers/vector.hxx>
-
-#include <cult/cli/options.hxx>
-#include <cult/cli/options-spec.hxx>
-
-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<NarrowString>,
- 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<NarrowString>,
- namespace_regex, Cult::Containers::Vector<NarrowString>,
- namespace_regex_trace, Boolean,
- reserved_name, Cult::Containers::Vector<NarrowString>,
- include_with_brackets, Boolean,
- include_prefix, NarrowString,
- include_regex, Cult::Containers::Vector<NarrowString>,
- 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<NarrowString>,
- ixx_prologue, Cult::Containers::Vector<NarrowString>,
- cxx_prologue, Cult::Containers::Vector<NarrowString>,
- prologue, Cult::Containers::Vector<NarrowString>,
- hxx_epilogue, Cult::Containers::Vector<NarrowString>,
- ixx_epilogue, Cult::Containers::Vector<NarrowString>,
- cxx_epilogue, Cult::Containers::Vector<NarrowString>,
- epilogue, Cult::Containers::Vector<NarrowString>,
- 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<Options> {};
- }
- }
-}
-
-#endif // CXX_PARSER_CLI_HXX
diff --git a/xsd/cxx/parser/driver-source.cxx b/xsd/cxx/parser/driver-source.cxx
index 483e728..4d0294e 100644
--- a/xsd/cxx/parser/driver-source.cxx
+++ b/xsd/cxx/parser/driver-source.cxx
@@ -751,7 +751,7 @@ namespace CXX
root_p << "." << post << " ());"
<< endl;
- if (ctx.options.value<CLI::generate_print_impl> ())
+ if (ctx.options.generate_print_impl ())
{
PrintCall t (ctx, root->name (), "v");
t.dispatch (root_type);
diff --git a/xsd/cxx/parser/elements.cxx b/xsd/cxx/parser/elements.cxx
index 94baa28..556398a 100644
--- a/xsd/cxx/parser/elements.cxx
+++ b/xsd/cxx/parser/elements.cxx
@@ -42,27 +42,12 @@ namespace CXX
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<CLI::char_type> (),
- ops.value<CLI::char_encoding> (),
- ops.value<CLI::include_with_brackets> (),
- ops.value<CLI::include_prefix> (),
- ops.value<CLI::export_symbol> (),
- ops.value<CLI::namespace_map> (),
- ops.value<CLI::namespace_regex> (),
- ops.value<CLI::namespace_regex_trace> (),
- ops.value<CLI::include_regex> (),
- ops.value<CLI::include_regex_trace> (),
- ops.value<CLI::generate_inline> (),
- ops.value<CLI::reserved_name> ()),
+ : CXX::Context (o, root, path, ops, map),
options (ops),
xml_parser (xml_parser_),
simple_base (simple_base_),
@@ -77,11 +62,11 @@ namespace CXX
hxx_expr (he),
ixx_expr (ie),
hxx_impl_expr (hie),
- xml_parser_ (ops.value<CLI::xml_parser> ()),
- validation_ ((ops.value<CLI::xml_parser> () == "expat" ||
- ops.value<CLI::generate_validation> ()) &&
- !ops.value<CLI::suppress_validation> ()),
- polymorphic_ (ops.value<CLI::generate_polymorphic> ())
+ 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";
diff --git a/xsd/cxx/parser/elements.hxx b/xsd/cxx/parser/elements.hxx
index d8cedd8..8b57b61 100644
--- a/xsd/cxx/parser/elements.hxx
+++ b/xsd/cxx/parser/elements.hxx
@@ -10,9 +10,11 @@
#include <cutl/re.hxx>
+#include <types.hxx>
+
#include <cxx/elements.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
@@ -35,11 +37,13 @@ namespace CXX
public:
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,
@@ -97,7 +101,7 @@ namespace CXX
eimpl (SemanticGraph::Type&);
public:
- CLI::Options const& options;
+ options_type const& options;
String& xml_parser;
String& simple_base;
String& complex_base;
@@ -278,7 +282,9 @@ 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)
{
@@ -287,12 +293,12 @@ namespace CXX
virtual Void
traverse (Type& e)
{
- if (options_.value<CLI::root_element_first> ())
+ if (options_.root_element_first ())
{
if (element_ == 0)
element_ = &e;
}
- else if (String name = options_.value<CLI::root_element> ())
+ else if (String name = options_.root_element ())
{
if (e.name () == name)
element_ = &e;
@@ -302,7 +308,7 @@ namespace CXX
}
private:
- CLI::Options const& options_;
+ options_type const& options_;
SemanticGraph::Element*& element_;
};
}
diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx
index 95a48c5..338705e 100644
--- a/xsd/cxx/parser/generator.cxx
+++ b/xsd/cxx/parser/generator.cxx
@@ -124,72 +124,6 @@ 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::
usage ()
{
@@ -197,27 +131,6 @@ namespace CXX
CXX::options::print_usage (wcout);
}
- Parser::CLI::OptionsSpec Parser::Generator::
- options_spec ()
- {
- CLI::OptionsSpec spec;
-
- spec.option<CLI::char_type> ().default_value ("char");
- spec.option<CLI::xml_parser> ().default_value ("xerces");
-
- spec.option<CLI::skel_file_suffix> ().default_value ("-pskel");
- spec.option<CLI::skel_type_suffix> ().default_value ("_pskel");
- spec.option<CLI::impl_file_suffix> ().default_value ("-pimpl");
- spec.option<CLI::impl_type_suffix> ().default_value ("_pimpl");
-
- spec.option<CLI::hxx_suffix> ().default_value (".hxx");
- spec.option<CLI::ixx_suffix> ().default_value (".ixx");
- spec.option<CLI::cxx_suffix> ().default_value (".cxx");
-
- return spec;
- }
-
-
namespace
{
template <typename S>
@@ -268,14 +181,13 @@ namespace CXX
Void
append (WideOutputFileStream& os,
- Cult::Containers::Vector<NarrowString> const& primary,
- Cult::Containers::Vector<NarrowString> const& def)
+ NarrowStrings const& primary,
+ NarrowStrings const& def)
{
- Cult::Containers::Vector<NarrowString> const& v (
- primary.empty () ? def : primary);
+ NarrowStrings const& v (primary.empty () ? def : primary);
- for (Containers::Vector<NarrowString>::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;
}
@@ -284,7 +196,7 @@ namespace CXX
UnsignedLong Parser::Generator::
- generate (Parser::CLI::Options const& ops,
+ generate (Parser::options const& ops,
Schema& schema,
Path const& file_path,
Boolean fpt,
@@ -300,7 +212,7 @@ namespace CXX
try
{
- Boolean generate_xml_schema (ops.value<CLI::generate_xml_schema> ());
+ 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
@@ -309,7 +221,7 @@ namespace CXX
//
if (generate_xml_schema)
{
- if (NarrowString name = ops.value<CLI::extern_xml_schema> ())
+ if (NarrowString name = ops.extern_xml_schema ())
{
if (file_path.native_file_string () != name)
generate_xml_schema = false;
@@ -317,11 +229,11 @@ namespace CXX
}
Boolean impl (!generate_xml_schema &&
- (ops.value<CLI::generate_noop_impl> () ||
- ops.value<CLI::generate_print_impl> ()));
+ (ops.generate_noop_impl () ||
+ ops.generate_print_impl ()));
Boolean driver (gen_driver && !generate_xml_schema &&
- ops.value<CLI::generate_test_driver> ());
+ ops.generate_test_driver ());
// Evaluate the graph for possibility of generating something useful.
//
@@ -339,9 +251,9 @@ namespace CXX
proc.process (ops, schema, file_path, string_literal_map);
}
- Boolean validation ((ops.value<CLI::xml_parser> () == "expat" ||
- ops.value<CLI::generate_validation> ()) &&
- !ops.value<CLI::suppress_validation> ());
+ Boolean validation ((ops.xml_parser () == "expat" ||
+ ops.generate_validation ()) &&
+ !ops.suppress_validation ());
// Compute state machine info.
//
@@ -356,11 +268,11 @@ namespace CXX
TypeMap::Namespaces type_map;
{
using namespace TypeMap;
- typedef Containers::Vector<NarrowString> Files;
- Files const& files (ops.value<CLI::type_map> ());
+ 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);
@@ -377,7 +289,7 @@ namespace CXX
// String-based types.
//
- String char_type (ops.value<CLI::char_type> ());
+ String char_type (ops.char_type ());
String string_type;
if (char_type == L"char")
@@ -481,35 +393,33 @@ namespace CXX
//
//
- Boolean inline_ (ops.value<CLI::generate_inline> () &&
- !generate_xml_schema);
-
+ Boolean inline_ (ops.generate_inline () && !generate_xml_schema);
Boolean source (!generate_xml_schema);
// Generate code.
//
NarrowString name (file_path.leaf ());
- NarrowString skel_suffix (ops.value <CLI::skel_file_suffix> ());
- NarrowString impl_suffix (ops.value <CLI::impl_file_suffix> ());
+ NarrowString skel_suffix (ops.skel_file_suffix ());
+ NarrowString impl_suffix (ops.impl_file_suffix ());
- NarrowString hxx_suffix (ops.value <CLI::hxx_suffix> ());
- NarrowString ixx_suffix (ops.value <CLI::ixx_suffix> ());
- NarrowString cxx_suffix (ops.value <CLI::cxx_suffix> ());
+ NarrowString hxx_suffix (ops.hxx_suffix ());
+ NarrowString ixx_suffix (ops.ixx_suffix ());
+ NarrowString cxx_suffix (ops.cxx_suffix ());
Regex hxx_expr (
- ops.value <CLI::hxx_regex> ().empty ()
+ ops.hxx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + hxx_suffix + "#"
- : ops.value <CLI::hxx_regex> ());
+ : ops.hxx_regex ());
Regex ixx_expr (
- ops.value <CLI::ixx_regex> ().empty ()
+ ops.ixx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + ixx_suffix + "#"
- : ops.value <CLI::ixx_regex> ());
+ : ops.ixx_regex ());
Regex cxx_expr (
- ops.value <CLI::cxx_regex> ().empty ()
+ ops.cxx_regex ().empty ()
? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + cxx_suffix + "#"
- : ops.value <CLI::cxx_regex> ());
+ : ops.cxx_regex ());
Regex hxx_impl_expr;
@@ -611,7 +521,7 @@ namespace CXX
Path out_dir;
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ if (NarrowString dir = ops.output_dir ())
{
try
{
@@ -659,7 +569,7 @@ namespace CXX
if (impl)
{
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
WideInputFileStream tmp (hxx_impl_path, ios_base::in);
@@ -685,7 +595,7 @@ namespace CXX
unlinks.add (hxx_impl_path);
file_list.push_back (hxx_impl_path.native_file_string ());
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
WideInputFileStream tmp (cxx_impl_path, ios_base::in);
@@ -714,7 +624,7 @@ namespace CXX
if (driver)
{
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
WideInputFileStream tmp (cxx_driver_path, ios_base::in);
@@ -788,9 +698,7 @@ namespace CXX
// Print copyright and license.
//
Char const* copyright (
- ops.value<CLI::proprietary_license> ()
- ? copyright_proprietary
- : copyright_gpl);
+ ops.proprietary_license () ? copyright_proprietary : copyright_gpl);
hxx << copyright;
@@ -813,7 +721,7 @@ namespace CXX
//
WideInputFileStream prologue;
{
- NarrowString name (ops.value<CLI::prologue_file> ());
+ NarrowString name (ops.prologue_file ());
if (name)
open (prologue, name);
@@ -823,7 +731,7 @@ namespace CXX
//
WideInputFileStream epilogue;
{
- NarrowString name (ops.value<CLI::epilogue_file> ());
+ NarrowString name (ops.epilogue_file ());
if (name)
open (epilogue, name);
@@ -831,8 +739,8 @@ namespace CXX
// SLOC counter.
//
- UnsignedLong sloc_total (0);
- Boolean show_sloc (ops.value<CLI::show_sloc> ());
+ size_t sloc_total (0);
+ Boolean show_sloc (ops.show_sloc ());
typedef
compiler::ostream_filter<compiler::cxx_indenter, wchar_t>
@@ -846,7 +754,7 @@ namespace CXX
//
Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words.
- NarrowString guard_prefix (ops.value<CLI::guard_prefix> ());
+ NarrowString guard_prefix (ops.guard_prefix ());
if (!guard_prefix)
guard_prefix = file_path.branch_path ().native_directory_string ();
@@ -893,9 +801,8 @@ namespace CXX
hxx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ());
- append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue);
+ append (hxx, ops.hxx_prologue (), ops.prologue ());
+ append (hxx, ops.hxx_prologue_file (), prologue);
hxx << "//" << endl
<< "// End prologue." << endl
@@ -920,9 +827,8 @@ namespace CXX
hxx << "// Begin epilogue." << endl
<< "//" << endl;
- append (hxx, ops.value<CLI::hxx_epilogue_file> (), epilogue);
- append (
- hxx, ops.value<CLI::hxx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (hxx, ops.hxx_epilogue_file (), epilogue);
+ append (hxx, ops.hxx_epilogue (), ops.epilogue ());
hxx << "//" << endl
<< "// End epilogue." << endl
@@ -960,9 +866,8 @@ namespace CXX
ixx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- ixx, ops.value<CLI::ixx_prologue> (), ops.value<CLI::prologue> ());
- append (ixx, ops.value<CLI::ixx_prologue_file> (), prologue);
+ append (ixx, ops.ixx_prologue (), ops.prologue ());
+ append (ixx, ops.ixx_prologue_file (), prologue);
ixx << "//" << endl
<< "// End prologue." << endl
@@ -980,9 +885,8 @@ namespace CXX
ixx << "// Begin epilogue." << endl
<< "//" << endl;
- append (ixx, ops.value<CLI::ixx_epilogue_file> (), epilogue);
- append (
- ixx, ops.value<CLI::ixx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (ixx, ops.ixx_epilogue_file (), epilogue);
+ append (ixx, ops.ixx_epilogue (), ops.epilogue ());
ixx << "//" << endl
<< "// End epilogue." << endl
@@ -1015,9 +919,8 @@ namespace CXX
cxx << "// Begin prologue." << endl
<< "//" << endl;
- append (
- cxx, ops.value<CLI::cxx_prologue> (), ops.value<CLI::prologue> ());
- append (cxx, ops.value<CLI::cxx_prologue_file> (), prologue);
+ append (cxx, ops.cxx_prologue (), ops.prologue ());
+ append (cxx, ops.cxx_prologue_file (), prologue);
cxx << "//" << endl
<< "// End prologue." << endl
@@ -1049,9 +952,8 @@ namespace CXX
cxx << "// Begin epilogue." << endl
<< "//" << endl;
- append (cxx, ops.value<CLI::cxx_epilogue_file> (), epilogue);
- append (
- cxx, ops.value<CLI::cxx_epilogue> (), ops.value<CLI::epilogue> ());
+ append (cxx, ops.cxx_epilogue_file (), epilogue);
+ append (cxx, ops.cxx_epilogue (), ops.epilogue ());
cxx << "//" << endl
<< "// End epilogue." << endl
diff --git a/xsd/cxx/parser/generator.hxx b/xsd/cxx/parser/generator.hxx
index 8ae683d..8391553 100644
--- a/xsd/cxx/parser/generator.hxx
+++ b/xsd/cxx/parser/generator.hxx
@@ -10,16 +10,13 @@
#include <cult/containers/vector.hxx>
-#include <cult/cli/options.hxx>
-#include <cult/cli/options-spec.hxx>
-
#include <xsd-frontend/semantic-graph/elements.hxx> // Path
#include <xsd-frontend/semantic-graph/schema.hxx>
#include <xsd.hxx>
#include <cxx/literal-map.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
@@ -33,13 +30,10 @@ namespace CXX
static Void
usage ();
- static CLI::OptionsSpec
- options_spec ();
-
struct Failed {};
static UnsignedLong
- generate (CLI::Options const& options,
+ generate (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
Boolean file_per_type,
diff --git a/xsd/cxx/parser/impl-source.cxx b/xsd/cxx/parser/impl-source.cxx
index be30b6b..3f5aec5 100644
--- a/xsd/cxx/parser/impl-source.cxx
+++ b/xsd/cxx/parser/impl-source.cxx
@@ -57,7 +57,7 @@ namespace CXX
os << arg_type (base) << " v (" << post_name (base) << " ());"
<< endl;
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, e.name (), "v");
t.dispatch (base);
@@ -126,7 +126,7 @@ namespace CXX
if (arg != L"void")
{
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, type.name (), item);
t.dispatch (type);
@@ -186,7 +186,7 @@ namespace CXX
<< "_characters (const " << string_type << "& s)"
<< "{";
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
os << cout_inst << " << " << strlit (u.name () + L": ") <<
" << s << std::endl;";
else
@@ -244,7 +244,7 @@ namespace CXX
if (arg != L"void")
{
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, m.name (), name);
t.dispatch (m.type ());
@@ -314,7 +314,7 @@ namespace CXX
os << arg_type (base) << " v (" << post_name (base) << " ());"
<< endl;
- if (options.value<CLI::generate_print_impl> ())
+ if (options.generate_print_impl ())
{
PrintCall t (*this, c.name (), "v");
t.dispatch (base);
@@ -357,7 +357,7 @@ namespace CXX
Void
generate_impl_source (Context& ctx)
{
- if (ctx.options.value<CLI::generate_print_impl> ())
+ if (ctx.options.generate_print_impl ())
ctx.os << "#include <iostream>" << endl
<< endl;
diff --git a/xsd/cxx/parser/name-processor.cxx b/xsd/cxx/parser/name-processor.cxx
index d1bbf09..2812ef4 100644
--- a/xsd/cxx/parser/name-processor.cxx
+++ b/xsd/cxx/parser/name-processor.cxx
@@ -32,35 +32,20 @@ namespace CXX
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<CLI::char_type> (),
- ops.value<CLI::char_encoding> (),
- ops.value<CLI::include_with_brackets> (),
- ops.value<CLI::include_prefix> (),
- ops.value<CLI::export_symbol> (),
- ops.value<CLI::namespace_map> (),
- ops.value<CLI::namespace_regex> (),
- ops.value<CLI::namespace_regex_trace> (),
- ops.value<CLI::include_regex> (),
- ops.value<CLI::include_regex_trace> (),
- ops.value<CLI::generate_inline> (),
- ops.value<CLI::reserved_name> ()),
- skel_suffix_ (ops.value<CLI::skel_type_suffix> ()),
- impl_suffix_ (ops.value<CLI::impl_type_suffix> ()),
- impl (ops.value<CLI::generate_noop_impl> () ||
- ops.value<CLI::generate_print_impl> () ||
- ops.value<CLI::generate_test_driver> ()),
+ : 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<CLI::generate_polymorphic> ())
+ polymorphic (ops.generate_polymorphic ())
{
}
@@ -1088,7 +1073,7 @@ namespace CXX
};
Void
- process_impl (CLI::Options const& ops,
+ process_impl (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
StringLiteralMap const& map)
@@ -1184,7 +1169,7 @@ namespace CXX
}
Void NameProcessor::
- process (CLI::Options const& ops,
+ process (options const& ops,
SemanticGraph::Schema& tu,
SemanticGraph::Path const& file,
StringLiteralMap const& map)
diff --git a/xsd/cxx/parser/name-processor.hxx b/xsd/cxx/parser/name-processor.hxx
index e397480..558ca2a 100644
--- a/xsd/cxx/parser/name-processor.hxx
+++ b/xsd/cxx/parser/name-processor.hxx
@@ -9,7 +9,7 @@
#include <xsd-frontend/semantic-graph.hxx>
#include <cxx/elements.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
@@ -23,7 +23,7 @@ namespace CXX
NameProcessor (); // Dummy ctor, helps with long symbols on HP-UX.
Void
- process (CLI::Options const& ops,
+ process (options const&,
XSDFrontend::SemanticGraph::Schema&,
XSDFrontend::SemanticGraph::Path const& file,
StringLiteralMap const& map);
diff --git a/xsd/cxx/parser/options.cli b/xsd/cxx/parser/options.cli
index e40230b..9bbaf0f 100644
--- a/xsd/cxx/parser/options.cli
+++ b/xsd/cxx/parser/options.cli
@@ -36,12 +36,6 @@ namespace CXX
// Features.
//
- bool --generate-inline
- {
- "Generate simple functions inline. This option triggers creation
- of the inline file."
- };
-
bool --generate-validation
{
"Generate validation code. The validation code (\"perfect parser\")
diff --git a/xsd/cxx/parser/parser-header.cxx b/xsd/cxx/parser/parser-header.cxx
index 2490a26..c717fc8 100644
--- a/xsd/cxx/parser/parser-header.cxx
+++ b/xsd/cxx/parser/parser-header.cxx
@@ -1294,7 +1294,7 @@ namespace CXX
NarrowString extern_xml_schema;
if (!generate_xml_schema)
- extern_xml_schema = ctx.options.value<CLI::extern_xml_schema> ();
+ extern_xml_schema = ctx.options.extern_xml_schema ();
if (extern_xml_schema)
{
diff --git a/xsd/cxx/parser/parser-inline.cxx b/xsd/cxx/parser/parser-inline.cxx
index b3805c6..e549e24 100644
--- a/xsd/cxx/parser/parser-inline.cxx
+++ b/xsd/cxx/parser/parser-inline.cxx
@@ -370,7 +370,7 @@ namespace CXX
// Emit "weak" header includes that are used in the file-per-type
// compilation model.
//
- if (!ctx.options.value<CLI::generate_inline> ())
+ if (!ctx.options.generate_inline ())
{
Traversal::Schema schema;
Includes includes (ctx, Includes::source);
diff --git a/xsd/cxx/parser/parser-source.cxx b/xsd/cxx/parser/parser-source.cxx
index 547a02f..b9928bc 100644
--- a/xsd/cxx/parser/parser-source.cxx
+++ b/xsd/cxx/parser/parser-source.cxx
@@ -846,8 +846,8 @@ namespace CXX
else
ctx.os << endl;
- Boolean import_maps (ctx.options.value<CLI::import_maps> ());
- Boolean export_maps (ctx.options.value<CLI::export_maps> ());
+ Boolean import_maps (ctx.options.import_maps ());
+ Boolean export_maps (ctx.options.export_maps ());
if (import_maps || export_maps)
{
@@ -920,7 +920,7 @@ namespace CXX
// Emit "weak" header includes that are used in the file-per-type
// compilation model.
//
- if (ctx.options.value<CLI::generate_inline> ())
+ if (ctx.options.generate_inline ())
{
Traversal::Schema schema;
Includes includes (ctx, Includes::source);
diff --git a/xsd/cxx/parser/type-processor.cxx b/xsd/cxx/parser/type-processor.cxx
index db3e45b..1fefeb3 100644
--- a/xsd/cxx/parser/type-processor.cxx
+++ b/xsd/cxx/parser/type-processor.cxx
@@ -255,7 +255,7 @@ namespace CXX
};
Void
- process_impl (CLI::Options const& options,
+ process_impl (options const& ops,
XSDFrontend::SemanticGraph::Schema& tu,
Boolean gen_driver,
TypeMap::Namespaces& type_map)
@@ -281,8 +281,7 @@ 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<CLI::extern_xml_schema> ());
+ Boolean extern_xml_schema (ops.extern_xml_schema ());
//
//
@@ -314,7 +313,7 @@ namespace CXX
// If we are generating the test driver, make sure the root
// element type is processed.
//
- if (gen_driver && options.value<CLI::generate_test_driver> ())
+ if (gen_driver && ops.generate_test_driver ())
{
// Figure out the root element. Validator should have made sure
// it is unique.
@@ -329,7 +328,7 @@ namespace CXX
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;
@@ -343,12 +342,12 @@ namespace CXX
}
Void TypeProcessor::
- process (CLI::Options const& options,
+ process (options const& ops,
XSDFrontend::SemanticGraph::Schema& s,
Boolean gen_driver,
TypeMap::Namespaces& tm)
{
- process_impl (options, s, gen_driver, tm);
+ process_impl (ops, s, gen_driver, tm);
}
}
}
diff --git a/xsd/cxx/parser/type-processor.hxx b/xsd/cxx/parser/type-processor.hxx
index 9159752..2165846 100644
--- a/xsd/cxx/parser/type-processor.hxx
+++ b/xsd/cxx/parser/type-processor.hxx
@@ -12,7 +12,7 @@
#include <type-map/type-map.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
namespace CXX
{
@@ -26,7 +26,7 @@ namespace CXX
TypeProcessor (); // Dummy ctor, helps with long symbols on HP-UX.
Void
- process (CLI::Options const& options,
+ process (options const&,
XSDFrontend::SemanticGraph::Schema&,
Boolean gen_driver,
TypeMap::Namespaces&);
diff --git a/xsd/cxx/parser/validator.cxx b/xsd/cxx/parser/validator.cxx
index 81f1579..96110f1 100644
--- a/xsd/cxx/parser/validator.cxx
+++ b/xsd/cxx/parser/validator.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),
+ : Context (std::wcerr, root, path, ops, 0, 0, 0, 0),
disabled_warnings_ (disabled_warnings),
disabled_warnings_all_ (false),
valid (valid_),
@@ -335,7 +335,7 @@ namespace CXX
return;
if (e.substitutes_p () &&
- !options.value<CLI::generate_polymorphic> () &&
+ !options.generate_polymorphic () &&
!subst_group_warning_issued)
{
subst_group_warning_issued = true;
@@ -434,7 +434,7 @@ namespace CXX
<< "automatically name them"
<< endl;
- if (!options.value<CLI::show_anonymous> ())
+ if (!options.show_anonymous ())
wcerr << t.file ()
<< ": info: use --show-anonymous option to see these "
<< "types" << endl;
@@ -453,7 +453,7 @@ namespace CXX
if (traverse_common (e))
{
- if (options.value<CLI::show_anonymous> ())
+ if (options.show_anonymous ())
{
wcerr << e.file () << ":" << e.line () << ":" << e.column ()
<< ": error: element '" << xpath (e) << "' "
@@ -469,7 +469,7 @@ namespace CXX
{
if (traverse_common (a))
{
- if (options.value<CLI::show_anonymous> ())
+ if (options.show_anonymous ())
{
wcerr << a.file () << ":" << a.line () << ":" << a.column ()
<< ": error: attribute '" << xpath (a) << "' "
@@ -506,16 +506,16 @@ namespace CXX
if (!valid)
return;
- if (options.value<CLI::root_element_first> ())
+ if (options.root_element_first ())
{
if (element_ == 0)
element_ = &e;
}
- else if (options.value<CLI::root_element_last> ())
+ else if (options.root_element_last ())
{
element_ = &e;
}
- else if (String name = options.value<CLI::root_element> ())
+ else if (String name = options.root_element ())
{
if (e.name () == name)
element_ = &e;
@@ -551,39 +551,39 @@ namespace CXX
}
Boolean Validator::
- validate (CLI::Options const& options,
+ validate (options const& ops,
SemanticGraph::Schema& root,
SemanticGraph::Path const& path,
Boolean gen_driver,
const WarningSet& disabled_warnings)
{
Boolean valid (true);
- ValidationContext ctx (root, path, options, disabled_warnings, valid);
+ ValidationContext ctx (root, path, ops, disabled_warnings, valid);
//
//
- if (options.value<CLI::char_type> () != "char" &&
- options.value<CLI::char_type> () != "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<CLI::char_type> ().c_str () << "'" << endl;
+ ops.char_type ().c_str () << "'" << endl;
}
//
//
- if (options.value<CLI::xml_parser> () != "xerces" &&
- options.value<CLI::xml_parser> () != "expat" &&
+ if (ops.xml_parser () != "xerces" &&
+ ops.xml_parser () != "expat" &&
!ctx.is_disabled ("P004"))
{
wcerr << "warning P004: unknown underlying XML parser '" <<
- options.value<CLI::xml_parser> ().c_str () << "'" << endl;
+ ops.xml_parser ().c_str () << "'" << endl;
}
//
//
- if (options.value<CLI::xml_parser> () == "expat" &&
- options.value<CLI::char_type> () == "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 +593,9 @@ namespace CXX
//
//
- if (options.value<CLI::xml_parser> () == "expat" &&
- !options.value<CLI::char_encoding> ().empty () &&
- options.value<CLI::char_encoding> () != "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 +606,7 @@ namespace CXX
//
//
- if (options.value<CLI::generate_validation> () &&
- options.value<CLI::suppress_validation> ())
+ if (ops.generate_validation () && ops.suppress_validation ())
{
wcerr << "error: mutually exclusive options specified: "
<< "--generate-validation and --suppress-validation"
@@ -618,8 +617,7 @@ namespace CXX
//
//
- if (options.value<CLI::generate_noop_impl> () &&
- options.value<CLI::generate_print_impl> ())
+ if (ops.generate_noop_impl () && ops.generate_print_impl ())
{
wcerr << "error: mutually exclusive options specified: "
<< "--generate-noop-impl and --generate-print-impl"
@@ -631,9 +629,9 @@ namespace CXX
//
//
{
- Boolean ref (options.value<CLI::root_element_first> ());
- Boolean rel (options.value<CLI::root_element_last> ());
- Boolean re (options.value<CLI::root_element> ());
+ Boolean ref (ops.root_element_first ());
+ Boolean rel (ops.root_element_last ());
+ Boolean re (ops.root_element ());
if ((ref && rel) || (ref && re) || (rel && re))
{
@@ -648,8 +646,8 @@ namespace CXX
//
//
- Boolean import_maps (options.value<CLI::import_maps> ());
- Boolean export_maps (options.value<CLI::export_maps> ());
+ Boolean import_maps (ops.import_maps ());
+ Boolean export_maps (ops.export_maps ());
if (import_maps && export_maps)
{
diff --git a/xsd/cxx/parser/validator.hxx b/xsd/cxx/parser/validator.hxx
index 0fb57f1..35c13fc 100644
--- a/xsd/cxx/parser/validator.hxx
+++ b/xsd/cxx/parser/validator.hxx
@@ -7,7 +7,7 @@
#define CXX_PARSER_VALIDATOR_HXX
#include <cxx/parser/elements.hxx>
-#include <cxx/parser/cli.hxx>
+#include <cxx/parser/options.hxx>
#include <xsd.hxx>
@@ -23,7 +23,7 @@ namespace CXX
Validator (); // Dummy ctor, helps with long symbols on HP-UX.
Boolean
- validate (CLI::Options const& options,
+ validate (options const&,
SemanticGraph::Schema&,
SemanticGraph::Path const& tu,
Boolean gen_driver,