From ef4efbab2664232aa35b0111a6d430d2c67ababd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Jun 2012 15:28:15 +0200 Subject: 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. --- xsde/cxx/hybrid/generator.cxx | 516 +----------------------------------------- xsde/cxx/hybrid/options.cli | 353 +++++++++++++++++++++++++++++ 2 files changed, 356 insertions(+), 513 deletions(-) create mode 100644 xsde/cxx/hybrid/options.cli (limited to 'xsde/cxx/hybrid') diff --git a/xsde/cxx/hybrid/generator.cxx b/xsde/cxx/hybrid/generator.cxx index 4db77ea..3a61c95 100644 --- a/xsde/cxx/hybrid/generator.cxx +++ b/xsde/cxx/hybrid/generator.cxx @@ -17,8 +17,6 @@ #include #include -#include - #include #include @@ -52,7 +50,7 @@ #include #include -#include +#include #include "../../../libxsde/xsde/cxx/version.hxx" @@ -61,7 +59,6 @@ using std::wcerr; using std::wcout; using namespace XSDFrontend::SemanticGraph; -namespace Indentation = BackendElements::Indentation; // // @@ -213,515 +210,8 @@ namespace CXX Void Hybrid::Generator:: usage () { - std::wostream& o (wcout); - ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (o); - - o << "--char-encoding " << endl - << " Specify the character encoding that should be\n" - << " used in the object model. Valid values are 'utf8'\n" - << " (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 << "--generate-parser" << endl - << " Generate XML parsing code." - << endl; - - o << "--generate-serializer" << endl - << " Generate XML serialization code." - << endl; - - o << "--generate-aggregate" << endl - << " Generate parser/serializer aggregates for root\n" - << " elements and/or types." - << endl; - - o << "--suppress-validation" << endl - << " Suppress the generation of validation code in\n" - << " parser and serializer." - << endl; - - o << "--suppress-parser-val" << endl - << " Suppress the generation of validation code in\n" - << " parser." - << endl; - - o << "--suppress-serializer-val" << endl - << " Suppress the generation of validation code in\n" - << " serializer." - << endl; - - o << "--omit-default-attributes" << endl - << " Omit attributes with default and fixed values\n" - << " from serialized XML documents." - << endl; - - o << "--suppress-enum" << endl - << " Suppress the generation of the XML Schema\n" - << " enumeration to C++ enum mapping." - << endl; - - o << "--generate-clone" << endl - << " Generate clone functions for variable-length\n" - << " types." - << endl; - - o << "--generate-detach" << endl - << " Generate detach functions for elements and\n" - << " attributes of variable-length types." - << endl; - - o << "--generate-insertion " << endl - << " Generate data representation stream insertion\n" - << " operators for the output stream type." - << endl; - - o << "--generate-extraction " << endl - << " Generate data representation stream extraction\n" - << " operators for the input stream type." - << endl; - - o << "--generate-inline" << endl - << " Generate certain functions inline." - << endl; - - o << "--generate-forward" << endl - << " Generate forward declaration file." - << endl; - - o << "--generate-xml-schema" << endl - << " Generate C++ header files as if the schema being\n" - << " compiled defines the XML Schema namespace." - << endl; - - o << "--extern-xml-schema " << endl - << " Generate code as if the XML Schema namespace was\n" - << " defined in and xsd:included in the schema\n" - << " being compiled." - << endl; - - o << "--suppress-reset" << endl - << " Suppress the generation of parser and serializer\n" - << " reset code." - << endl; - - o << "--custom-allocator" << endl - << " Generate code that uses custom allocator functions\n" - << " instead of operator new/delete." - << 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 << "--polymorphic-type " << endl - << " Indicate that is a root of a polymorphic\n" - << " type hierarchy." - << endl; - - o << "--generate-typeinfo" << endl - << " Generate type information functions for\n" - << " polymorphic object model types." - << endl; - - o << "--polymorphic-schema " << endl - << " Indicate that contains derivations of\n" - << " polymorphic types." - << endl; - - o << "--reuse-style-mixin" << endl - << " Generate code that supports the mixin base\n" - << " parser/serializer implementation reuse style." - << endl; - - o << "--custom-data " << endl - << " Add custom data to the C++ class generated for\n" - << " XML Schema type ." - << endl; - - o << "--custom-type " << endl - << " Use a custom type implementation instead of the\n" - << " generated version. The argument is in the\n" - << " form name[=[flags][/[type][/[base][/include]]]],\n" - << " where is an XML Schema type name,\n" - << " optional specify whether the custom type\n" - << " is fixed or variable-length, optional is\n" - << " a C++ type name that should be used instead,\n" - << " optional is a C++ name that should be\n" - << " given to the generated version, and optional\n" - << " is the header file that defines the\n" - << " custom implementation." - << endl; - - o << "--custom-parser " << endl - << " Use a custom parser implementation instead of the\n" - << " generated version. The argument is in the\n" - << " form name[=[base][/include]], where is an\n" - << " XML Schema type name, optional is a C++\n" - << " name that should be given to the generated\n" - << " version, and optional is the header\n" - << " file that defines the custom implementation." - << endl; - - o << "--custom-serializer " << endl - << " Use a custom serializer implementation instead of\n" - << " the generated version. The argument is in\n" - << " the form name[=[base][/include]], where is\n" - << " an XML Schema type name, optional is a C++\n" - << " name that should be given to the generated\n" - << " version, and optional is the header\n" - << " file that defines the custom implementation." - << endl; - - o << "--root-element-first" << endl - << " Treat only the first global element as a document\n" - << " root." - << endl; - - o << "--root-element-last" << endl - << " Treat only the last global element as a document\n" - << " root." - << endl; - - o << "--root-element-all" << endl - << " Treat all global elements as document roots." - << endl; - - o << "--root-element-none" << endl - << " Don't treat any global elements as document roots." - << endl; - - o << "--root-element " << endl - << " Treat only as a document root. Repeat\n" - << " this option to specify more than one root element." - << endl; - - o << "--root-type " << endl - << " Generate parser/serializer aggregate for .\n" - << " Repeat this option to specify more than one type." - << endl; - - o << "--output-dir " << endl - << " Write generated files to instead of the\n" - << " current directory." - << endl; - - o << "--pskel-type-suffix " << endl - << " Use instead of the default '_pskel' suffix\n" - << " to construct the names of generated parser\n" - << " skeletons." - << endl; - - o << "--sskel-type-suffix " << endl - << " Use instead of the default '_sskel' suffix\n" - << " to construct the names of generated serializer\n" - << " skeletons." - << endl; - - o << "--pskel-file-suffix " << endl - << " Use instead of the default '-pskel' suffix\n" - << " to construct the names of generated parser\n" - << " skeleton files." - << endl; - - o << "--sskel-file-suffix " << endl - << " Use instead of the default '-sskel' suffix\n" - << " to construct the names of generated serializer\n" - << " skeleton files." - << endl; - - o << "--pimpl-type-suffix " << endl - << " Use instead of the default '_pimpl' suffix\n" - << " to construct the names of generated parser\n" - << " implementations." - << endl; - - o << "--simpl-type-suffix " << endl - << " Use instead of the default '_simpl' suffix\n" - << " to construct the names of generated serializer\n" - << " implementations." - << endl; - - o << "--pimpl-file-suffix " << endl - << " Use instead of the default '-pimpl' suffix\n" - << " to construct the names of generated parser\n" - << " implementation files." - << endl; - - o << "--simpl-file-suffix " << endl - << " Use instead of the default '-simpl' suffix\n" - << " to construct the names of generated serializer\n" - << " implementation files." - << endl; - - o << "--paggr-type-suffix " << endl - << " Use instead of the default '_paggs' suffix\n" - << " to construct the names of generated parser\n" - << " aggregates." - << endl; - - o << "--saggr-type-suffix " << endl - << " Use instead of the default '_saggr' suffix\n" - << " to construct the names of generated serializer\n" - << " aggregates." - << endl; - - o << "--namespace-map =" << endl - << " Map XML Schema namespace to C++ namespace\n" - << " . Repeat this option to specify mapping for\n" - << " more than one XML Schema namespace." - << endl; - - o << "--namespace-regex " << endl - << " Add 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 " << endl - << " Add to the list of names that should not\n" - << " be used as identifiers. The name can optionally\n" - << " be followed by '=' and the replacement name that\n" - << " should be used instead." - << endl; - - o << "--include-with-brackets" << endl - << " Use angle brackets (<>) instead of quotes (\"\") in\n" - << " generated #include directives." - << endl; - - o << "--include-prefix " << endl - << " Add to generated #include directive\n" - << " paths." - << endl; - - o << "--include-regex " << endl - << " Add 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 " << endl - << " Add to generated header inclusion guards." - << endl; - - // File suffix. - // - o << "--hxx-suffix " << endl - << " Use instead of the default '.hxx' to\n" - << " construct the name of the header files." - << endl; - - o << "--ixx-suffix " << endl - << " Use instead of the default '.ixx' to\n" - << " construct the name of the inline files." - << endl; - - o << "--cxx-suffix " << endl - << " Use instead of the default '.cxx' to\n" - << " construct the name of the source files." - << endl; - - o << "--fwd-suffix " << endl - << " Use instead of the default '-fwd.hxx'\n" - << " to construct the name of the forward declaration\n" - << " file." - << endl; - - // File regex. - // - o << "--hxx-regex " << endl - << " Use to construct the names of the header\n" - << " files." - << endl; - - o << "--ixx-regex " << endl - << " Use to construct the names of the inline\n" - << " files." - << endl; - - o << "--cxx-regex " << endl - << " Use to construct the names of the source\n" - << " files." - << endl; - - o << "--fwd-regex " << endl - << " Use to construct the name of the forward\n" - << " declaration file." - << endl; - - - // Prologues. - // - o << "--hxx-prologue " << endl - << " Insert at the beginning of the header\n" - << " files." - << endl; - - o << "--ixx-prologue " << endl - << " Insert at the beginning of the inline\n" - << " files." - << endl; - - o << "--cxx-prologue " << endl - << " Insert at the beginning of the source\n" - << " files." - << endl; - - o << "--fwd-prologue " << endl - << " Insert at the beginning of the forward\n" - << " declaration file." - << endl; - - o << "--prologue " << endl - << " Insert at the beginning of each generated\n" - << " file for which there is no file-specific prologue." - << endl; - - - // Epilogues. - // - o << "--hxx-epilogue " << endl - << " Insert at the end of the header files." - << endl; - - o << "--ixx-epilogue " << endl - << " Insert at the end of the inline files." - << endl; - - o << "--cxx-epilogue " << endl - << " Insert at the end of the source files." - << endl; - - o << "--fwd-epilogue " << endl - << " Insert at the end of the forward\n" - << " declaration file." - << endl; - - o << "--epilogue " << endl - << " Insert at the end of each generated file\n" - << " for which there is no file-specific epilogue." - << endl; - - - // Prologue files. - // - o << "--hxx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the header files." - << endl; - - o << "--ixx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the inline files." - << endl; - - o << "--cxx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the source files." - << endl; - - o << "--fwd-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the forward declaration file." - << endl; - - o << "--prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of each generated file for which there is no file-\n" - << " specific prologue file." - << endl; - - - // Epilogue files. - // - o << "--hxx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the header files." - << endl; - - o << "--ixx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the inline files." - << endl; - - o << "--cxx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the source files." - << endl; - - o << "--fwd-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the forward declaration file." - << endl; - - o << "--epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " each generated file for which there is no file-\n" - << " specific epilogue file." - << endl; - - - // Misc. - // - 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 " << endl - << " Check that the number of generated physical source\n" - << " lines of code (SLOC) does not exceed ." - << endl; - - o << "--options-file " << endl - << " Read additional options from . Each option\n" - << " should appear on a separate line optionally\n" - << " followed by space and an argument." - << endl; - - o << "--proprietary-license" << endl - << " Indicate that the generated code is licensed under\n" - << " a proprietary license instead of the GPL." - << endl; + CXX::Hybrid::options::print_usage (wcout); + CXX::options::print_usage (wcout); } Hybrid::CLI::OptionsSpec Hybrid::Generator:: diff --git a/xsde/cxx/hybrid/options.cli b/xsde/cxx/hybrid/options.cli new file mode 100644 index 0000000..40df945 --- /dev/null +++ b/xsde/cxx/hybrid/options.cli @@ -0,0 +1,353 @@ +// file : xsde/cxx/hybrid/options.cli +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include ; +include ; +include ; // std::size_t + +include ; // NarrowString + +include ; + +namespace CXX +{ + namespace Hybrid + { + class options: CXX::options + { + // Features. + // + bool --generate-parser + { + "Generate XML parsing code." + }; + + bool --generate-serializer + { + "Generate XML serialization code." + }; + + bool --generate-aggregate + { + "Generate parser/serializer aggregates for root elements and/or types. + See also the \cb{--root-element-*} and \cb{--root-type} options." + }; + + bool --suppress-validation + { + "Suppress the generation of validation code in parser and serializer." + }; + + bool --suppress-parser-val + { + "Suppress the generation of validation code in parser." + }; + + bool --suppress-serializer-val + { + "Suppress the generation of validation code in serializer." + }; + + bool --omit-default-attributes + { + "Omit attributes with default and fixed values from serialized + XML documents." + }; + + bool --suppress-enum + { + "Suppress the generation of the XML Schema enumeration to C++ + \cb{enum} mapping." + }; + + bool --generate-clone + { + "Generate clone functions for variable-length types. These + functions allow you to make dynamically-allocated copies of + variable-length objects." + }; + + bool --generate-detach + { + "Generate detach functions for elements and attributes of + variable-length types. These functions, for example, allow + you to move sub-trees in the object model either within the + same tree or between different trees." + }; + + std::vector --generate-insertion + { + "", + "Generate data representation stream insertion operators for the + output stream type. Repeat this option to specify more than + one stream type. The special \cb{CDR} and \cb{XDR} arguments are + recognized as ACE CDR and Sun RPC XDR stream types and the + corresponding stream wrappers provided by the XSD/e runtime are + automatically used. For custom stream types use the + \cb{--hxx-prologue*} options to include the necessary declarations." + }; + + std::vector --generate-extraction + { + "", + "Generate data representation stream extraction operators for the + input stream type. Repeat this option to specify more than + one stream type. The special \cb{CDR} and \cb{XDR} arguments are + recognized as ACE CDR and Sun RPC XDR stream types and the + corresponding stream wrappers provided by the XSD/e runtime are + automatically used. For custom stream types use the + \cb{--hxx-prologue*} options to include the necessary declarations." + }; + + bool --generate-forward + { + "Generate forward declaration file." + }; + + // Polymorphism. + // + bool --generate-polymorphic + { + "Generate polymorphism-aware code. Specify this option if you use + substitution groups or \cb{xsi:type}. Use the \cb{--polymorphic-type} + option to specify which type hierarchies are polymorphic." + }; + + bool --runtime-polymorphic + { + "Generate non-polymorphic code that uses the runtime library + configured with polymorphism support." + }; + + std::vector --polymorphic-type + { + "", + "Indicate that is a root of a polymorphic type hierarchy. The + XSD/e compiler can often automatically determine which types are + polymorphic based on the substitution group declarations. However, + you may need to use this option if you are not using substitution + groups or if substitution groups are defined in another schema. + You need to specify this option when compiling every schema file + that references ." + }; + + bool --generate-typeinfo + { + "Generate custom type information querying functions for polymorphic + object model types. These functions can be used instead of the + standard C++ RTTI mechanism to determine object's type at runtime." + }; + + std::vector --polymorphic-schema + { + "", + "Indicate that contains derivations of polymorphic types that + are not otherwise visible from the schema being compiled. This + option is used to make sure that during the generation of parser + and serializer aggregates the compiler is aware of all possible + derivations of polymorphic types. Repeat this option to specify + more than one schema file." + }; + + // Reuse style. + // + bool --reuse-style-mixin + { + "Generate code that supports the mixin base parser/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 the tiein reuse + style is used." + }; + + // Custom data/type. + // + std::vector --custom-data + { + "", + "Add the ability to store custom data to the C++ class generated for + XML Schema type . To add custom data to a nested compositor + class use the qualified name starting from the XML Schema type + containing the compositor, for example, \cb{foo::sequence::choise1}." + }; + + std::vector --custom-type + { + "", + "Use a custom type implementation instead of the generated version. + The argument is in the form + \c{\i{name}[\b{=}[\i{flags}][\b{/}[\i{type}][\b{/}[\i{base}][\b{/}\i{include}]]]]}, + where the \ci{name} component is the XML Schema type name being + customized. Optional \ci{flags} allow you to specify whether the + custom type is fixed or variable-length. The \cb{f} flag indicates + the type is fixed-length and the \cb{v} flag indicates the type is + variable-length. If omitted, the default rules are used to determine + the type length. Optional \ci{type} is a C++ type name that should + be used instead. If specified, the object model type is defined as + a \cb{typedef} alias for this C++ type. Optional \ci{base} is a C++ + name that should be given to the generated version. It is normally + used as a base for the custom implementation. Optional \ci{include} + is the header file that defines the custom implementation. It is + \cb{#include}'ed into the generated code immediately after (if + \ci{base} is specified) or instead of the generated version." + }; + + std::vector --custom-parser + { + "", + "Use a custom parser implementation instead of the generated version. + The argument is in the form + \c{\i{name}[\b{=}[\i{base}][\b{/}\i{include}]]}, where the \ci{name} + component is the XML Schema type name being customized. Optional + \ci{base} is a C++ name that should be given to the generated + version. It is normally used as a base for the custom implementation. + Optional \ci{include} is the header file that defines the custom + implementation. It is \cb{#include}'ed into the generated code + immediately after (if \ci{base} is specified) or instead of the + generated version." + }; + + std::vector --custom-serializer + { + "", + "Use a custom serializer implementation instead of the generated + version. The argument is in the form + \c{\i{name}[\b{=}[\i{base}][\b{/}\i{include}]]}, where The \ci{name} + component is the XML Schema type name being customized. Optional + \ci{base} is a C++ name that should be given to the generated + version. It is normally used as a base for the custom implementation. + Optional \ci{include} is the header file that defines the custom + implementation. It is \cb{#include}'ed into the generated code + immediately after (if \ci{base} is specified) or instead of the + generated version." + }; + + // Root element/type. + // + + bool --root-element-first + { + "Treat only the first global element as a document root. This + determines for which elements parser and serializer aggregates + are generated. By default all global elements are considered + document roots. See also the \cb{--generate-aggregate} option." + }; + + bool --root-element-last + { + "Treat only the last global element as a document root. This + determines for which elements parser and serializer aggregates + are generated. By default all global elements are considered + document roots. See also the \cb{--generate-aggregate} option." + }; + + bool --root-element-all + { + "Treat all global elements as document roots (the default behavior). + This determines for which elements parser and serializer aggregates + are generated. By explicitly specifying this option you can suppress + the warning that is issued if more than one global element is + defined. See also the \cb{--generate-aggregate} option." + }; + + bool --root-element-none + { + "Do not treat any global elements as document roots. This determines + for which elements parser and serializer aggregates are generated. + By default all global elements are considered document roots. See + also the \cb{--generate-aggregate} option." + }; + + std::vector --root-element + { + "", + "Treat only as a document root. This determines for which + elements parser and serializer aggregates are generated. Repeat + this option to specify more than one root element. See also the + \cb{--generate-aggregate} option." + }; + + std::vector --root-type + { + "", + "Generate parser/serializer aggregate for . Repeat this option + to specify more than one type. See also the \cb{--generate-aggregate} + option." + }; + + // Suffixes. + // + Cult::Types::NarrowString --pskel-type-suffix = "_pskel" + { + "", + "Use instead of the default \cb{_pskel} to construct the + names of generated parser skeletons." + }; + + Cult::Types::NarrowString --sskel-type-suffix = "_sskel" + { + "", + "Use instead of the default \cb{_sskel} to construct the + names of generated serializer skeletons." + }; + + Cult::Types::NarrowString --pskel-file-suffix = "-pskel" + { + "", + "Use instead of the default \cb{-pskel} to construct the + names of generated parser skeleton files." + }; + + Cult::Types::NarrowString --sskel-file-suffix = "-sskel" + { + "", + "Use instead of the default \cb{-sskel} to construct the + names of generated serializer skeleton files." + }; + + Cult::Types::NarrowString --pimpl-type-suffix = "_pimpl" + { + "", + "Use instead of the default \cb{_pimpl} to construct the + names of generated parser implementations." + }; + + Cult::Types::NarrowString --simpl-type-suffix = "_simpl" + { + "", + "Use instead of the default \cb{_simpl} to construct the + names of generated serializer implementations." + }; + + Cult::Types::NarrowString --pimpl-file-suffix = "-pimpl" + { + "", + "Use instead of the default \cb{-pimpl} to construct the + names of generated parser implementation files." + }; + + Cult::Types::NarrowString --simpl-file-suffix = "-simpl" + { + "", + "Use instead of the default \cb{-simpl} to construct the + names of generated serializer implementation files." + }; + + Cult::Types::NarrowString --paggr-type-suffix = "_paggs" + { + "", + "Use instead of the default \cb{_paggs} to construct the + names of generated parser aggregates." + }; + + Cult::Types::NarrowString --saggr-type-suffix = "_saggr" + { + "", + "Use instead of the default \cb{_saggr} to construct the + names of generated serializer aggregates." + }; + }; + } +} -- cgit v1.1