aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/serializer/generator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xsde/cxx/serializer/generator.cxx')
-rw-r--r--xsde/cxx/serializer/generator.cxx223
1 files changed, 61 insertions, 162 deletions
diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index 98e1cae..479293c 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -108,74 +108,6 @@ namespace CXX
"//\n\n";
}
- namespace Serializer
- {
- namespace CLI
- {
- extern Key type_map = "type-map";
- 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 reuse_style_mixin = "reuse-style-mixin";
- extern Key reuse_style_none = "reuse-style-none";
- extern Key generate_inline = "generate-inline";
- extern Key suppress_validation = "suppress-validation";
- extern Key generate_polymorphic = "generate-polymorphic";
- extern Key runtime_polymorphic = "runtime-polymorphic";
- extern Key suppress_reset = "suppress-reset";
- extern Key custom_allocator = "custom-allocator";
- extern Key generate_empty_impl = "generate-empty-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 output_dir = "output-dir";
- 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 show_anonymous = "show-anonymous";
- extern Key show_sloc = "show-sloc";
- extern Key proprietary_license = "proprietary-license";
- }
- }
-
Void Serializer::Generator::
usage ()
{
@@ -183,27 +115,8 @@ namespace CXX
CXX::options::print_usage (wcout);
}
- Serializer::CLI::OptionsSpec Serializer::Generator::
- options_spec ()
- {
- CLI::OptionsSpec spec;
-
- spec.option<CLI::char_encoding> ().default_value ("utf8");
-
- spec.option<CLI::skel_file_suffix> ().default_value ("-sskel");
- spec.option<CLI::skel_type_suffix> ().default_value ("_sskel");
- spec.option<CLI::impl_file_suffix> ().default_value ("-simpl");
- spec.option<CLI::impl_type_suffix> ().default_value ("_simpl");
-
- 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;
- }
-
Void Serializer::Generator::
- process_names (CLI::Options const& ops,
+ process_names (options const& ops,
XSDFrontend::SemanticGraph::Schema& schema,
XSDFrontend::SemanticGraph::Path const& file)
{
@@ -261,14 +174,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;
}
@@ -277,7 +189,7 @@ namespace CXX
UnsignedLong Serializer::Generator::
- generate (Serializer::CLI::Options const& ops,
+ generate (Serializer::options const& ops,
Schema& schema,
Path const& file_path,
Boolean fpt,
@@ -293,7 +205,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
@@ -302,18 +214,16 @@ 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;
}
}
- Boolean impl (!generate_xml_schema &&
- ops.value<CLI::generate_empty_impl> ());
-
+ Boolean impl (!generate_xml_schema && ops.generate_empty_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.
//
@@ -333,17 +243,17 @@ namespace CXX
//
//
- Boolean validation (!ops.value<CLI::suppress_validation> ());
+ Boolean validation (!ops.suppress_validation ());
// Read-in type maps.
//
{
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);
@@ -363,7 +273,7 @@ namespace CXX
xns = ctx.xs_ns_name ();
}
- if (ops.value<CLI::no_stl> ())
+ if (ops.no_stl ())
{
TypeMap::Namespace xsd_std ("http://www\\.w3\\.org/2001/XMLSchema");
@@ -433,7 +343,7 @@ namespace CXX
xsd.types_push_back ("int", "int", "int");
xsd.types_push_back ("unsignedInt", "unsigned int", "unsigned int");
- if (ops.value<CLI::no_long_long> ())
+ if (ops.no_long_long ())
{
xsd.types_push_back ("long", "long", "long");
xsd.types_push_back ("unsignedLong", "unsigned long", "unsigned long");
@@ -487,34 +397,32 @@ namespace CXX
// Generate code.
//
- Boolean inline_ (ops.value<CLI::generate_inline> () &&
- !generate_xml_schema);
-
+ Boolean inline_ (ops.generate_inline () && !generate_xml_schema);
Boolean source (!generate_xml_schema);
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;
Regex cxx_impl_expr;
@@ -615,7 +523,7 @@ namespace CXX
Path out_dir;
- if (NarrowString dir = ops.value<CLI::output_dir> ())
+ if (NarrowString dir = ops.output_dir ())
{
try
{
@@ -663,7 +571,7 @@ namespace CXX
if (impl)
{
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
WideInputFileStream tmp (hxx_impl_path, ios_base::in);
@@ -689,7 +597,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);
@@ -718,7 +626,7 @@ namespace CXX
if (driver)
{
- if (!ops.value<CLI::force_overwrite> ())
+ if (!ops.force_overwrite ())
{
WideInputFileStream tmp (cxx_driver_path, ios_base::in);
@@ -791,9 +699,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;
@@ -816,7 +722,7 @@ namespace CXX
//
WideInputFileStream prologue;
{
- NarrowString name (ops.value<CLI::prologue_file> ());
+ NarrowString name (ops.prologue_file ());
if (name)
open (prologue, name);
@@ -826,7 +732,7 @@ namespace CXX
//
WideInputFileStream epilogue;
{
- NarrowString name (ops.value<CLI::epilogue_file> ());
+ NarrowString name (ops.epilogue_file ());
if (name)
open (epilogue, name);
@@ -834,8 +740,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>
@@ -849,7 +755,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 ();
@@ -889,7 +795,7 @@ namespace CXX
hxx << "#include <xsde/cxx/config.hxx>" << endl
<< endl;
- if (ops.value<CLI::char_encoding> () == "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" <<
@@ -908,7 +814,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::no_stl> ())
+ if (ops.no_stl ())
{
hxx << "#ifdef XSDE_STL" << endl
<< "#error the XSD/e runtime uses STL while the " <<
@@ -927,7 +833,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::no_iostream> ())
+ if (ops.no_iostream ())
{
hxx << "#ifdef XSDE_IOSTREAM" << endl
<< "#error the XSD/e runtime uses iostream while the " <<
@@ -946,7 +852,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::no_exceptions> ())
+ if (ops.no_exceptions ())
{
hxx << "#ifdef XSDE_EXCEPTIONS" << endl
<< "#error the XSD/e runtime uses exceptions while the " <<
@@ -965,7 +871,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::no_long_long> ())
+ if (ops.no_long_long ())
{
hxx << "#ifdef XSDE_LONGLONG" << endl
<< "#error the XSD/e runtime uses long long while the " <<
@@ -984,7 +890,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::suppress_validation> ())
+ if (ops.suppress_validation ())
{
hxx << "#ifdef XSDE_SERIALIZER_VALIDATION" << endl
<< "#error the XSD/e runtime uses validation while the " <<
@@ -1003,8 +909,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::generate_polymorphic> () ||
- ops.value<CLI::runtime_polymorphic> ())
+ if (ops.generate_polymorphic () || ops.runtime_polymorphic ())
{
hxx << "#ifndef XSDE_POLYMORPHIC" << endl
<< "#error the generated code expects XSD/e runtime with " <<
@@ -1023,7 +928,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::reuse_style_mixin> ())
+ if (ops.reuse_style_mixin ())
{
hxx << "#ifndef XSDE_REUSE_STYLE_MIXIN" << endl
<< "#error the generated code uses the mixin reuse style " <<
@@ -1032,7 +937,7 @@ namespace CXX
<< "#endif" << endl
<< endl;
}
- else if (ops.value<CLI::reuse_style_none> ())
+ else if (ops.reuse_style_none ())
{
hxx << "#ifndef XSDE_REUSE_STYLE_NONE" << endl
<< "#error the generated code does not provide support " <<
@@ -1051,7 +956,7 @@ namespace CXX
<< endl;
}
- if (ops.value<CLI::custom_allocator> ())
+ if (ops.custom_allocator ())
{
hxx << "#ifndef XSDE_CUSTOM_ALLOCATOR" << endl
<< "#error the generated code uses custom allocator while " <<
@@ -1081,9 +986,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
@@ -1109,9 +1013,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
@@ -1143,9 +1046,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
@@ -1163,9 +1065,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
@@ -1192,9 +1093,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
@@ -1225,9 +1125,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