aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/serializer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-06-18 15:28:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-06-18 15:28:15 +0200
commitef4efbab2664232aa35b0111a6d430d2c67ababd (patch)
tree8b9666a028f081846341d61d90c4364448388226 /xsde/cxx/serializer
parentc2d38a4c6abd15c898492f09b4646eb93a01da69 (diff)
Initial work on CLI port
Add options files with all the documentation. Move documentation and usage to use the new approach. Finally get rid of dependency on libbackend-elements.
Diffstat (limited to 'xsde/cxx/serializer')
-rw-r--r--xsde/cxx/serializer/generator.cxx343
-rw-r--r--xsde/cxx/serializer/options.cli148
2 files changed, 151 insertions, 340 deletions
diff --git a/xsde/cxx/serializer/generator.cxx b/xsde/cxx/serializer/generator.cxx
index 167dae5..98e1cae 100644
--- a/xsde/cxx/serializer/generator.cxx
+++ b/xsde/cxx/serializer/generator.cxx
@@ -16,8 +16,6 @@
#include <cutl/compiler/cxx-indenter.hxx>
#include <cutl/compiler/sloc-counter.hxx>
-#include <backend-elements/indentation/clip.hxx>
-
#include <xsd-frontend/semantic-graph.hxx>
#include <type-map/lexer.hxx>
@@ -42,7 +40,7 @@
#include <cxx/serializer/element-validation-source.hxx>
#include <cxx/serializer/attribute-validation-source.hxx>
-#include <usage.hxx>
+#include <cxx/serializer/options.hxx>
#include "../../../libxsde/xsde/cxx/version.hxx"
@@ -181,342 +179,8 @@ namespace CXX
Void Serializer::Generator::
usage ()
{
- std::wostream& o (wcout);
- ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (o);
-
- o << "--type-map <mapfile>" << endl
- << " Read XML Schema to C++ type mapping information\n"
- << " from <mapfile>. Repeat this option to specify\n"
- << " several type maps. Type maps are considered in\n"
- << " order of appearance and the first match is used."
- << endl;
-
- o << "--char-encoding <enc>" << endl
- << " Specify the character encoding that is used in\n"
- << " the text data being serialized. Valid values are\n"
- << " 'utf8' (default) and 'iso8859-1'."
- << endl;
-
- o << "--no-stl" << endl
- << " Generate code that does not use STL."
- << endl;
-
- o << "--no-iostream" << endl
- << " Generate code that does not use the iostream\n"
- << " library."
- << endl;
-
- o << "--no-exceptions" << endl
- << " Generate code that does not use C++ exceptions."
- << endl;
-
- o << "--no-long-long" << endl
- << " Generate code that does not use the long long\n"
- << " and unsigned long long types."
- << endl;
-
- o << "--reuse-style-mixin" << endl
- << " Generate code that supports the mixin base\n"
- << " serializer implementation reuse style."
- << endl;
-
- o << "--reuse-style-none" << endl
- << " Do not generate any support for base serializer\n"
- << " implementation reuse."
- << endl;
-
- o << "--generate-inline" << endl
- << " Generate certain functions inline."
- << endl;
-
- o << "--suppress-validation" << endl
- << " Suppress the generation of validation code."
- << endl;
-
- o << "--generate-polymorphic" << endl
- << " Generate polymorphism-aware code. Specify this\n"
- << " option if you use substitution groups or xsi:type."
- << endl;
-
- o << "--runtime-polymorphic" << endl
- << " Generate non-polymorphic code that uses the\n"
- << " runtime library configured with polymorphism\n"
- << " support."
- << endl;
-
- o << "--suppress-reset" << endl
- << " Suppress the generation of serializer reset code."
- << endl;
-
- o << "--custom-allocator" << endl
- << " Generate code that uses custom allocator functions\n"
- << " instead of operator new/delete."
- << endl;
-
- o << "--generate-empty-impl" << endl
- << " Generate a sample serializer implementation with\n"
- << " empty function bodies."
- << endl;
-
- o << "--generate-test-driver" << endl
- << " Generate a test driver for the sample serializer\n"
- << " implementation."
- << endl;
-
- o << "--force-overwrite" << endl
- << " Force overwriting of the existing implementation\n"
- << " and test driver files."
- << endl;
-
- o << "--root-element-first" << endl
- << " Indicate that the first global element is the\n"
- << " document root."
- << endl;
-
- o << "--root-element-last" << endl
- << " Indicate that the last global element is the\n"
- << " document root."
- << endl;
-
- o << "--root-element <element>" << endl
- << " Indicate that <element> is the document root."
- << endl;
-
- o << "--generate-xml-schema" << endl
- << " Generate a C++ header file as if the schema being\n"
- << " compiled defines the XML Schema namespace."
- << endl;
-
- o << "--extern-xml-schema <file>" << endl
- << " Generate code as if the XML Schema namespace was\n"
- << " defined in <file> and xsd:included in the schema\n"
- << " being compiled."
- << endl;
-
- o << "--output-dir <dir>" << endl
- << " Write generated files to <dir> instead of the\n"
- << " current directory."
- << endl;
-
- o << "--skel-type-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '_sskel' to\n"
- << " construct the names of generated serializer\n"
- << " skeletons."
- << endl;
-
- o << "--skel-file-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '-sskel' to\n"
- << " construct the names of generated serializer\n"
- << " skeleton files."
- << endl;
-
- o << "--impl-type-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '_simpl' to\n"
- << " construct the names of serializer implementations\n"
- << " for the built-in XML Schema types and sample\n"
- << " serializer implementations."
- << endl;
-
- o << "--impl-file-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '-simpl' to\n"
- << " construct the names of generated sample\n"
- << " serializer implementation files."
- << endl;
-
- o << "--namespace-map <xns>=<cns>" << endl
- << " Map XML Schema namespace <xns> to C++ namespace\n"
- << " <cns>. Repeat this option to specify mapping for\n"
- << " more than one XML Schema namespace."
- << endl;
-
- o << "--namespace-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to translate XML Schema namespace names to\n"
- << " C++ namespace names."
- << endl;
-
- o << "--namespace-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --namespace-regex option."
- << endl;
-
- o << "--reserved-name <name>" << endl
- << " Add <name> to the list of names that should not\n"
- << " be used as identifiers. The name can optionally\n"
- << " be followed by '=' and the replacement name that\n"
- << " should be used instead."
- << endl;
-
- o << "--include-with-brackets" << endl
- << " Use angle brackets (<>) instead of quotes (\"\") in\n"
- << " generated #include directives."
- << endl;
-
- o << "--include-prefix <prefix>" << endl
- << " Add <prefix> to generated #include directive\n"
- << " paths."
- << endl;
-
- o << "--include-regex <regex>" << endl
- << " Add <regex> to the list of regular expressions\n"
- << " used to transform #include directive paths."
- << endl;
-
- o << "--include-regex-trace" << endl
- << " Trace the process of applying regular expressions\n"
- << " specified with the --include-regex option."
- << endl;
-
- o << "--guard-prefix <prefix>" << endl
- << " Add <prefix> to generated header inclusion guards."
- << endl;
-
- o << "--hxx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.hxx' to\n"
- << " construct the name of the header file."
- << endl;
-
- o << "--ixx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.ixx' to\n"
- << " construct the name of the inline file."
- << endl;
-
- o << "--cxx-suffix <suffix>" << endl
- << " Use <suffix> instead of the default '.cxx' to\n"
- << " construct the name of the source file."
- << endl;
-
- o << "--hxx-regex <regex>" << endl
- << " Use <regex> to construct the name of the header\n"
- << " file."
- << endl;
-
- o << "--ixx-regex <regex>" << endl
- << " Use <regex> to construct the name of the inline\n"
- << " file."
- << endl;
-
- o << "--cxx-regex <regex>" << endl
- << " Use <regex> to construct the name of the source\n"
- << " file."
- << endl;
-
-
- // Prologues.
- //
- o << "--hxx-prologue <text>" << endl
- << " Insert <text> at the beginning of the header file."
- << endl;
-
- o << "--ixx-prologue <text>" << endl
- << " Insert <text> at the beginning of the inline file."
- << endl;
-
- o << "--cxx-prologue <text>" << endl
- << " Insert <text> at the beginning of the source file."
- << endl;
-
- o << "--prologue <text>" << endl
- << " Insert <text> at the beginning of each generated\n"
- << " file for which there is no file-specific prologue."
- << endl;
-
-
- // Epilogues.
- //
- o << "--hxx-epilogue <text>" << endl
- << " Insert <text> at the end of the header file."
- << endl;
-
- o << "--ixx-epilogue <text>" << endl
- << " Insert <text> at the end of the inline file."
- << endl;
-
- o << "--cxx-epilogue <text>" << endl
- << " Insert <text> at the end of the source file."
- << endl;
-
- o << "--epilogue <text>" << endl
- << " Insert <text> at the end of each generated file\n"
- << " for which there is no file-specific epilogue."
- << endl;
-
-
- // Prologue files.
- //
- o << "--hxx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the header file."
- << endl;
-
- o << "--ixx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the inline file."
- << endl;
-
- o << "--cxx-prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of the source file."
- << endl;
-
- o << "--prologue-file <file>" << endl
- << " Insert the content of the <file> at the beginning\n"
- << " of each generated file for which there is no file-\n"
- << " specific prologue file."
- << endl;
-
-
- // Epilogue files.
- //
- o << "--hxx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the header file."
- << endl;
-
- o << "--ixx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the inline file."
- << endl;
-
- o << "--cxx-epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " the source file."
- << endl;
-
- o << "--epilogue-file <file>" << endl
- << " Insert the content of the <file> at the end of\n"
- << " each generated file for which there is no file-\n"
- << " specific epilogue file."
- << endl;
-
-
- // Misc.
- //
- o << "--show-anonymous" << endl
- << " Show elements and attributes that are of anonymous\n"
- << " types."
- << endl;
-
- o << "--show-sloc" << endl
- << " Show the number of generated physical source lines\n"
- << " of code (SLOC)."
- << endl;
-
- o << "--sloc-limit <num>" << endl
- << " Check that the number of generated physical source\n"
- << " lines of code (SLOC) does not exceed <num>."
- << endl;
-
- o << "--options-file <file>" << endl
- << " Read additional options from <file>. Each option\n"
- << " should appear on a separate line optionally\n"
- << " followed by space and an argument."
- << endl;
-
- o << "--proprietary-license" << endl
- << " Indicate that the generated code is licensed under\n"
- << " a proprietary license instead of the GPL."
- << endl;
+ CXX::Serializer::options::print_usage (wcout);
+ CXX::options::print_usage (wcout);
}
Serializer::CLI::OptionsSpec Serializer::Generator::
@@ -624,7 +288,6 @@ namespace CXX
AutoUnlinks& unlinks)
{
using std::ios_base;
- namespace Indentation = BackendElements::Indentation;
typedef cutl::re::regexsub Regex;
diff --git a/xsde/cxx/serializer/options.cli b/xsde/cxx/serializer/options.cli
new file mode 100644
index 0000000..ddb6c60
--- /dev/null
+++ b/xsde/cxx/serializer/options.cli
@@ -0,0 +1,148 @@
+// file : xsde/cxx/serializer/options.cli
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include <vector>;
+include <string>;
+include <cstddef>; // std::size_t
+
+include <cult/types.hxx>; // NarrowString
+
+include <cxx/options.cli>;
+
+namespace CXX
+{
+ namespace Serializer
+ {
+ class options: CXX::options
+ {
+ std::vector<Cult::Types::NarrowString> --type-map
+ {
+ "<mapfile>",
+ "Read XML Schema to C++ type mapping information from <mapfile>.
+ Repeat this option to specify several type maps. Type maps are
+ considered in order of appearance and the first match is used.
+ By default all user-defined types are mapped to \cb{void}. See
+ the TYPE MAP section below for more information."
+ };
+
+ bool --suppress-validation
+ {
+ "Suppress the generation of validation code."
+ };
+
+ // Reuse style.
+ //
+ bool --reuse-style-mixin
+ {
+ "Generate code that supports the mixin base serializer implementation
+ reuse style. Note that this reuse style relies on virtual inheritance
+ and may result in a substantial object code size increase for large
+ vocabularies. By default support for the tiein style is generated."
+ };
+
+ bool --reuse-style-none
+ {
+ "Do not generate any support for base serializer implementation
+ reuse. By default support for the tiein style is generated."
+ };
+
+ // Polymorphism.
+ //
+ bool --generate-polymorphic
+ {
+ "Generate polymorphism-aware code. Specify this option if you use
+ substitution groups or \cb{xsi:type}."
+ };
+
+ bool --runtime-polymorphic
+ {
+ "Generate non-polymorphic code that uses the runtime library
+ configured with polymorphism support."
+ };
+
+ // Implementation/driver.
+ //
+ bool --generate-empty-impl
+ {
+ "Generate a sample serializer implementation with empty function
+ bodies which can then be filled with the application-specific code.
+ For an input file in the form \cb{name.xsd} this option triggers
+ the generation of the two additional C++ files in the form:
+ \cb{name-simpl.hxx} (serializer implementation header file) and
+ \cb{name-simpl.cxx} (serializer implementation source file)."
+ };
+
+ bool --generate-test-driver
+ {
+ "Generate a test driver for the sample serializer implementation.
+ For an input file in the form \cb{name.xsd} this option triggers
+ the generation of an additional C++ file in the form
+ \cb{name-sdriver.cxx}."
+ };
+
+ bool --force-overwrite
+ {
+ "Force overwriting of the existing implementation and test driver
+ files. Use this option only if you do not mind loosing the changes
+ you have made in the sample implementation or test driver files."
+ };
+
+ // Root element.
+ //
+ bool --root-element-first
+ {
+ "Indicate that the first global element is the document root. This
+ information is used to generate the test driver for the sample
+ implementation."
+ };
+
+ bool --root-element-last
+ {
+ "Indicate that the last global element is the document root. This
+ information is used to generate the test driver for the sample
+ implementation."
+ };
+
+ Cult::Types::NarrowString --root-element
+ {
+ "<element>",
+ "Indicate that <element> is the document root. This information is
+ used to generate the test driver for the sample implementation."
+ };
+
+ // Suffixes.
+ //
+ Cult::Types::NarrowString --skel-type-suffix = "_sskel"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{_sskel} to
+ construct the names of generated serializer skeletons."
+ };
+
+ Cult::Types::NarrowString --skel-file-suffix = "-sskel"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{-sskel} to
+ construct the names of generated serializer skeleton files."
+ };
+
+ Cult::Types::NarrowString --impl-type-suffix = "_simpl"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{_simpl} to
+ construct the names of serializer implementations for the built-in
+ XML Schema types and sample serializer implementations."
+ };
+
+ Cult::Types::NarrowString --impl-file-suffix = "-simpl"
+ {
+ "<suffix>",
+ "Use the provided <suffix> instead of the default \cb{-simpl} to
+ construct the names of generated sample serializer implementation
+ files."
+ };
+ };
+ }
+}