diff options
Diffstat (limited to 'xsd/cxx')
-rw-r--r-- | xsd/cxx/options.cli | 463 | ||||
-rw-r--r-- | xsd/cxx/parser/generator.cxx | 337 | ||||
-rw-r--r-- | xsd/cxx/parser/options.cli | 157 | ||||
-rw-r--r-- | xsd/cxx/tree/generator.cxx | 537 | ||||
-rw-r--r-- | xsd/cxx/tree/options.cli | 415 |
5 files changed, 1041 insertions, 868 deletions
diff --git a/xsd/cxx/options.cli b/xsd/cxx/options.cli new file mode 100644 index 0000000..fa46f96 --- /dev/null +++ b/xsd/cxx/options.cli @@ -0,0 +1,463 @@ +// file : xsd/cxx/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 <options.cli>; + +namespace CXX +{ + class options: ::options = 0 + { + // Character type and encoding. + // + Cult::Types::NarrowString --char-type = "char" + { + "<type>", + "Generate code using the provided character <type> instead of the + default \cb{char}. Valid values are \cb{char} and \cb{wchar_t}." + }; + + Cult::Types::NarrowString --char-encoding + { + "<enc>", + "Specify the character encoding that should be used in the generated + code. Valid values for the \cb{char} character type are \cb{utf8} + (default), \cb{iso8859-1}, \cb{lcp} (Xerces-C++ local code page), + and \cb{custom}. If you pass \cb{custom} as the value then you will + need to include the transcoder implementation header for your + encoding at the beginning of the generated header files (see the + \cb{--hxx-prologue} option). + + For the \cb{wchar_t} character type the only valid value is \cb{auto} + and the encoding is automatically selected between UTF-16 and + UTF-32/UCS-4, depending on the \cb{wchar_t} type size." + }; + + // Output options. + // + Cult::Types::NarrowString --output-dir + { + "<dir>", + "Write generated files to <dir> instead of the current directory." + }; + + // Extern XML Schema. + // + bool --generate-xml-schema + { + "Generate a C++ header file as if the schema being compiled defines the + XML Schema namespace. For the C++/Tree mapping, the resulting file will + contain definitions for all XML Schema built-in types. For the + C++/Parser mapping, the resulting file will contain definitions for + all the parser skeletons and implementations corresponding to the + XML Schema built-in types. + + The schema file provided to the compiler need not exist and is only + used to derive the name of the resulting header file. Use the + \cb{--extern-xml-schema} option to include this file in the + generated files for other schemas." + }; + + Cult::Types::NarrowString --extern-xml-schema + { + "<file>", + "Include a header file derived from <file> instead of generating the + XML Schema namespace mapping inline. The provided file need not + exist and is only used to derive the name of the included header + file. Use the \cb{--generate-xml-schema} option to generate this + header file." + }; + + // Namespace mapping. + // + std::vector<Cult::Types::NarrowString> --namespace-map + { + "<xns>=<cns>", + "Map XML Schema namespace <xns> to C++ namespace <cns>. Repeat + this option to specify mapping for more than one XML Schema namespace. + For example, the following option: + + \cb{--namespace-map http://example.com/foo/bar=foo::bar} + + Will map the \cb{http://example.com/foo/bar} XML Schema namespace to + the \cb{foo::bar} C++ namespace." + }; + + std::vector<Cult::Types::NarrowString> --namespace-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate XML + Schema namespace names to C++ namespace names. <regex> is a Perl-like + regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. Any character can be + used as a delimiter instead of \cb{/}. Escaping of the delimiter + character in \ci{pattern} or \ci{replacement} is not supported. + + All the regular expressions are pushed into a stack with the last + specified expression considered first. The first match that + succeeds is used. Regular expressions are applied to a string in + the form + + \c{\i{filename} \i{namespace}} + + For example, if you have file \cb{hello.xsd} with namespace + \cb{http://example.com/hello} and you run \cb{xsd} on this file, + then the string in question will be: + + \cb{hello.xsd. http://example.com/hello} + + For the built-in XML Schema namespace the string is: + + \cb{XMLSchema.xsd http://www.w3.org/2001/XMLSchema} + + The following three steps are performed for each regular expression + until the match is found: + + 1. The expression is applied and if the result is empty the next + expression is considered. + + 2. All \cb{/} are replaced with \cb{::}. + + 3. The result is verified to be a valid C++ scope name (e.g., + \cb{foo::bar}). If this test succeeds, the result is used as a + C++ namespace name. + + As an example, the following expression maps XML Schema namespaces + in the form \cb{http://example.com/foo/bar} to C++ namespaces in the + form \cb{foo::bar}: + + \cb{%.* http://example.com/(.+)%$1%} + + See also the REGEX AND SHELL QUOTING section below." + }; + + bool --namespace-regex-trace + { + "Trace the process of applying regular expressions specified with the + \cb{--namespace-regex} option. Use this option to find out why your + regular expressions don't do what you expected them to do." + }; + + // Reserved names. + // + std::vector<Cult::Types::NarrowString> --reserved-name + { + "<n>[=<r>]", + "Add name <n> to the list of names that should not be used as + identifiers. The name can optionally be followed by \cb{=} and the + replacement name <r> that should be used instead. All the C++ keywords + are already in this list." + }; + + // Include options. + // + bool --include-with-brackets + { + "Use angle brackets (<>) instead of quotes (\"\") in generated + \cb{#include} directives." + }; + + Cult::Types::NarrowString --include-prefix + { + "<prefix>", + "Add <prefix> to generated \cb{#include} directive paths. + + For example, if you had the following import element in your schema + + \cb{<import namespace=\"...\" schemaLocation=\"base.xsd\"/>} + + and compiled this fragment with \cb{--include-prefix schemas/}, then + the include directive in the generated code would be: + + \cb{#include \"schemas/base.hxx\"}" + }; + + std::vector<Cult::Types::NarrowString> --include-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to transform + \cb{#include} directive paths. <regex> is a Perl-like regular + expression in the form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. + Any character can be used as a delimiter instead of \cb{/}. Escaping + of the delimiter character in \ci{pattern} or \ci{replacement} is not + supported. + + All the regular expressions are pushed into a stack with the last + specified expression considered first. The first match that succeeds + is used. + + As an example, the following expression transforms paths in the form + \cb{schemas/foo/bar} to paths in the form \cb{generated/foo/bar}: + + \cb{%schemas/(.+)%generated/$1%} + + See also the REGEX AND SHELL QUOTING section below." + }; + + bool --include-regex-trace + { + "Trace the process of applying regular expressions specified with the + \cb{--include-regex} option. Use this option to find out why your + regular expressions don't do what you expected them to do." + }; + + Cult::Types::NarrowString --guard-prefix + { + "<prefix>", + "Add <prefix> to generated header inclusion guards. The prefix is + transformed to upper case and characters that are illegal in a + preprocessor macro name are replaced with underscores. If this + option is not specified then the directory part of the input schema + file is used as a prefix." + }; + + // File suffixes. + // + Cult::Types::NarrowString --hxx-suffix = ".hxx" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{.hxx} to + construct the name of the header file. Note that this suffix is also + used to construct names of header files corresponding to + included/imported schemas." + }; + + Cult::Types::NarrowString --ixx-suffix = ".ixx" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{.ixx} to + construct the name of the inline file." + }; + + Cult::Types::NarrowString --cxx-suffix = ".cxx" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{.cxx} to + construct the name of the source file." + }; + + Cult::Types::NarrowString --fwd-suffix = "-fwd.hxx" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{-fwd.hxx} to + construct the name of the forward declaration file." + }; + + Cult::Types::NarrowString --hxx-regex + { + "<regex>", + "Use the provided expression to construct the name of the header file. + <regex> is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. + Note that this expression is also used to construct names of header + files corresponding to included/imported schemas. See also the REGEX + AND SHELL QUOTING section below." + }; + + Cult::Types::NarrowString --ixx-regex + { + "<regex>", + "Use the provided expression to construct the name of the inline file. + <regex> is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND + SHELL QUOTING section below." + }; + + Cult::Types::NarrowString --cxx-regex + { + "<regex>", + "Use the provided expression to construct the name of the source file. + <regex> is a Perl-like regular expression in the form + \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX AND + SHELL QUOTING section below." + }; + + Cult::Types::NarrowString --fwd-regex + { + "<regex>", + "Use the provided expression to construct the name of the forward + declaration file. <regex> is a Perl-like regular expression in the + form \c{\b{/}\i{pattern}\b{/}\i{replacement}\b{/}}. See also the REGEX + AND SHELL QUOTING section below." + }; + + // Prologues/epilogues. + // + std::vector<Cult::Types::NarrowString> --hxx-prologue + { + "<text>", + "Insert <text> at the beginning of the header file." + }; + + std::vector<Cult::Types::NarrowString> --ixx-prologue + { + "<text>", + "Insert <text> at the beginning of the inline file." + }; + + std::vector<Cult::Types::NarrowString> --cxx-prologue + { + "<text>", + "Insert <text> at the beginning of the source file." + }; + + std::vector<Cult::Types::NarrowString> --fwd-prologue + { + "<text>", + "Insert <text> at the beginning of the forward declaration file." + }; + + std::vector<Cult::Types::NarrowString> --prologue + { + "<text>", + "Insert <text> at the beginning of each generated file for which + there is no file-specific prologue." + }; + + std::vector<Cult::Types::NarrowString> --hxx-epilogue + { + "<text>", + "Insert <text> at the end of the header file." + }; + + std::vector<Cult::Types::NarrowString> --ixx-epilogue + { + "<text>", + "Insert <text> at the end of the inline file." + }; + + std::vector<Cult::Types::NarrowString> --cxx-epilogue + { + "<text>", + "Insert <text> at the end of the source file." + }; + + std::vector<Cult::Types::NarrowString> --fwd-epilogue + { + "<text>", + "Insert <text> at the end of the forward declaration file." + }; + + std::vector<Cult::Types::NarrowString> --epilogue + { + "<text>", + "Insert <text> at the end of each generated file for which there + is no file-specific epilogue." + }; + + Cult::Types::NarrowString --hxx-prologue-file + { + "<file>", + "Insert the content of the <file> at the beginning of the header file." + }; + + Cult::Types::NarrowString --ixx-prologue-file + { + "<file>", + "Insert the content of the <file> at the beginning of the inline file." + }; + + Cult::Types::NarrowString --cxx-prologue-file + { + "<file>", + "Insert the content of the <file> at the beginning of the source file." + }; + + Cult::Types::NarrowString --fwd-prologue-file + { + "<file>", + "Insert the content of the <file> at the beginning of the forward + declaration file." + }; + + Cult::Types::NarrowString --prologue-file + { + "<file>", + "Insert the content of the <file> at the beginning of each generated + file for which there is no file-specific prologue file." + }; + + Cult::Types::NarrowString --hxx-epilogue-file + { + "<file>", + "Insert the content of the <file> at the end of the header file." + }; + + Cult::Types::NarrowString --ixx-epilogue-file + { + "<file>", + "Insert the content of the <file> at the end of the inline file." + }; + + Cult::Types::NarrowString --cxx-epilogue-file + { + "<file>", + "Insert the content of the <file> at the end of the source file." + }; + + Cult::Types::NarrowString --fwd-epilogue-file + { + "<file>", + "Insert the content of the <file> at the end of the forward declaration + file." + }; + + Cult::Types::NarrowString --epilogue-file + { + "<file>", + "Insert the content of the <file> at the end of each generated file + for which there is no file-specific epilogue file." + }; + + // Export options. + // + Cult::Types::NarrowString --export-symbol + { + "<symbol>", + "Insert <symbol> in places where DLL export/import control statements + (\cb{__declspec(dllexport/dllimport)}) are necessary." + }; + + bool --export-xml-schema + { + "Export/import types in the XML Schema namespace using the export + symbol provided with the \cb{--export-symbol} option. The + \cb{XSD_NO_EXPORT} macro can be used to omit this code during C++ + compilation, which may be useful if you would like to use the same + generated code across multiple platforms." + }; + + bool --export-maps + { + "Export polymorphism support maps from a Win32 DLL into which this + generated code is placed. This is necessary when your type hierarchy + is split across several DLLs since otherwise each DLL will have its + own set of maps. In this situation the generated code for the DLL + which contains base types and/or substitution group heads should be + compiled with this option and the generated code for all other DLLs + should be compiled with \cb{--import-maps}. This option is only valid + together with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} + macro can be used to omit this code during C++ compilation, which may + be useful if you would like to use the same generated code across + multiple platforms." + }; + + bool --import-maps + { + "Import polymorphism support maps to a Win32 DLL or executable into + which this generated code is linked. See the \cb{--export-maps} + option documentation for details. This options is only valid together + with \cb{--generate-polymorphic}. The \cb{XSD_NO_EXPORT} macro can be + used to omit this code during C++ compilation, which may be useful if + you would like to use the same generated code across multiple + platforms." + }; + }; +} diff --git a/xsd/cxx/parser/generator.cxx b/xsd/cxx/parser/generator.cxx index 998c480..95a48c5 100644 --- a/xsd/cxx/parser/generator.cxx +++ b/xsd/cxx/parser/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> @@ -45,7 +43,7 @@ #include <cxx/parser/attribute-validation-source.hxx> #include <cxx/parser/characters-validation-source.hxx> -#include <usage.hxx> +#include <cxx/parser/options.hxx> #include "../../../libxsd/xsd/cxx/version.hxx" @@ -195,336 +193,8 @@ namespace CXX Void Parser::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-type <type>" << endl - << " Use <type> as the base character type. Valid\n" - << " values are 'char' (default) and 'wchar_t'." - << endl; - - o << "--char-encoding <enc>" << endl - << " Specify the character encoding that should be used\n" - << " in the object model. Valid values for the 'char'\n" - << " character type are 'utf8' (default), 'iso8859-1',\n" - << " 'lcp', and 'custom'. For the 'wchar_t' character\n" - << " type the only valid value is 'auto'." - << endl; - - o << "--output-dir <dir>" << endl - << " Write generated files to <dir> instead of current\n" - << " directory." - << endl; - - o << "--xml-parser <parser>" << endl - << " Use <parser> as the underlying XML parser. Valid\n" - << " values are 'xerces' (default) and 'expat'." - << endl; - - o << "--generate-inline" << endl - << " Generate certain functions inline." - << endl; - - o << "--generate-validation" << endl - << " Generate validation code." - << 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 << "--generate-noop-impl" << endl - << " Generate a sample parser implementation that\n" - << " does nothing (no operation)." - << endl; - - o << "--generate-print-impl" << endl - << " Generate a sample parser implementation that\n" - << " prints the XML data to STDOUT." - << endl; - - o << "--generate-test-driver" << endl - << " Generate a test driver for the sample parser\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 << "--skel-type-suffix <suffix>" << endl - << " Use <suffix> instead of the default '_pskel' to\n" - << " construct the names of generated parser skeletons." - << endl; - - o << "--skel-file-suffix <suffix>" << endl - << " Use <suffix> instead of the default '-pskel' to\n" - << " construct the names of generated parser skeleton\n" - << " files." - << endl; - - o << "--impl-type-suffix <suffix>" << endl - << " Use <suffix> instead of the default '_pimpl' to\n" - << " construct the names of parser implementations for\n" - << " the built-in XML Schema types and sample parser\n" - << " implementations." - << endl; - - o << "--impl-file-suffix <suffix>" << endl - << " Use <suffix> instead of the default '-pimpl' to\n" - << " construct the names of generated sample parser\n" - << " 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 << "--custom-literals <file>" << endl - << " Load custom XML string to C++ literal mappings\n" - << " from <file>." - << endl; - - o << "--export-symbol <symbol>" << endl - << " Export symbol for Win32 DLL export/import control." - << endl; - - o << "--export-maps" << endl - << " Export polymorphism support maps from Win32 DLL." - << endl; - - o << "--import-maps" << endl - << " Import polymorphism support maps from Win32 DLL." - << endl; - - 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::Parser::options::print_usage (wcout); + CXX::options::print_usage (wcout); } Parser::CLI::OptionsSpec Parser::Generator:: @@ -625,7 +295,6 @@ namespace CXX AutoUnlinks& unlinks) { using std::ios_base; - namespace Indentation = BackendElements::Indentation; typedef cutl::re::regexsub Regex; diff --git a/xsd/cxx/parser/options.cli b/xsd/cxx/parser/options.cli new file mode 100644 index 0000000..e40230b --- /dev/null +++ b/xsd/cxx/parser/options.cli @@ -0,0 +1,157 @@ +// file : xsd/cxx/parser/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 Parser + { + 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." + }; + + Cult::Types::NarrowString --xml-parser = "xerces" + { + "<parser>", + "Use <parser> as the underlying XML parser. Valid values are + \cb{xerces} for Xerces-C++ (default) and \cb{expat} for Expat." + }; + + // 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\") + ensures that instance documents conform to the schema. Validation + code is generated by default when the selected underlying XML parser + is non-validating (\cb{expat})." + }; + + bool --suppress-validation + { + "Suppress the generation of validation code. Validation is suppressed + by default when the selected underlying XML parser is validating + (\cb{xerces})." + }; + + bool --generate-polymorphic + { + "Generate polymorphism-aware code. Specify this option if you use + substitution groups or \cb{xsi:type}." + }; + + bool --generate-noop-impl + { + "Generate a sample parser implementation that does nothing (no + operation). The sample implementation 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 two + additional C++ files in the form: \cb{name-pimpl.hxx} (parser + implementation header file) and \cb{name-pimpl.cxx} (parser + implementation source file)." + }; + + bool --generate-print-impl + { + "Generate a sample parser implementation that prints the XML data + to \c{STDOUT}. For an input file in the form \cb{name.xsd} this + option triggers the generation of two additional C++ files in the + form: \cb{name-pimpl.hxx} (parser implementation header file) and + \cb{name-pimpl.cxx} (parser implementation source file)." + }; + + bool --generate-test-driver + { + "Generate a test driver for the sample parser 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-driver.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 = "_pskel" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{_pskel} to + construct the names of the generated parser skeletons." + }; + + Cult::Types::NarrowString --skel-file-suffix = "-pskel" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{-pskel} to + construct the names of the generated parser skeleton files." + }; + + Cult::Types::NarrowString --impl-type-suffix = "_pimpl" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{_pimpl} to + construct the names of the parser implementations for the built-in + XML Schema types as well as sample parser implementations." + }; + + Cult::Types::NarrowString --impl-file-suffix = "-pimpl" + { + "<suffix>", + "Use the provided <suffix> instead of the default \cb{-pimpl} to + construct the names of the generated sample parser implementation + files." + }; + }; + } +} diff --git a/xsd/cxx/tree/generator.cxx b/xsd/cxx/tree/generator.cxx index 5fe4af5..7a6759b 100644 --- a/xsd/cxx/tree/generator.cxx +++ b/xsd/cxx/tree/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 <cxx/tree/generator.hxx> @@ -47,7 +45,7 @@ #include <cxx/tree/stream-insertion-source.hxx> #include <cxx/tree/stream-extraction-source.hxx> -#include <usage.hxx> +#include <cxx/tree/options.hxx> #include "../../../libxsd/xsd/cxx/version.hxx" @@ -223,536 +221,8 @@ namespace CXX Void Tree::Generator:: usage () { - std::wostream& o (wcout); - ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (o); - - o << "--char-type <type>" << endl - << " Use <type> as the base character type. Valid\n" - << " values are 'char' (default) and 'wchar_t'." - << endl; - - o << "--char-encoding <enc>" << endl - << " Specify the character encoding that should be used\n" - << " in the object model. Valid values for the 'char'\n" - << " character type are 'utf8' (default), 'iso8859-1',\n" - << " 'lcp', and 'custom'. For the 'wchar_t' character\n" - << " type the only valid value is 'auto'." - << endl; - - o << "--output-dir <dir>" << endl - << " Write generated files to <dir> instead of current\n" - << " directory." - << endl; - - o << "--generate-polymorphic" << endl - << " Generate polymorphism-aware code. Specify this\n" - << " option if you use substitution groups or xsi:type." - << endl; - - o << "--polymorphic-type <type>" << endl - << " Indicate that <type> is a root of a polymorphic\n" - << " type hierarchy." - << endl; - - o << "--polymorphic-type-all" << endl - << " Indicate that all types should be treated as\n" - << " polymorphic." - << endl; - - o << "--generate-serialization" << endl - << " Generate serialization functions. They convert an\n" - << " in-memory representation back to XML." - << endl; - - o << "--generate-inline" << endl - << " Generate certain functions inline." - << endl; - - o << "--generate-ostream" << endl - << " Generate ostream insertion operators." - << endl; - - o << "--generate-doxygen" << endl - << " Generate documentation comments in the Doxygen\n" - << " format." - << endl; - - o << "--generate-comparison" << endl - << " Generate comparison operators." - << endl; - - o << "--generate-default-ctor" << endl - << " Generate default constructors even for types that\n" - << " have required members." - << endl; - - o << "--generate-from-base-ctor" << endl - << " Generate from-base constructors." - << endl; - - o << "--suppress-assignment" << endl - << " Suppress the generation of copy assignment\n" - << " operators for complex types." - << endl; - - o << "--generate-detach" << endl - << " Generate detach functions for required members." - << endl; - - o << "--generate-wildcard" << endl - << " Generate accessors/modifiers as well as parsing\n" - << " and serialization code for XML Schema wildcards." - << endl; - - o << "--generate-insertion <os>" << endl - << " Generate data representation stream insertion\n" - << " operators for the <os> output stream type." - << endl; - - o << "--generate-extraction <is>" << endl - << " Generate data representation stream extraction\n" - << " constructors for the <is> input stream type." - << endl; - - o << "--generate-forward" << endl - << " Generate forward declaration file." - << 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 << "--suppress-parsing" << endl - << " Suppress the generation of parsing functions." - << endl; - - o << "--generate-element-type" << endl - << " Generate types instead of parsing/serialization\n" - << " functions for root elements." - << endl; - - o << "--generate-element-map" << endl - << " Generate a root element map that allows uniform\n" - << " parsing/serialization of multiple root elements.\n" - << endl; - - o << "--generate-intellisense" << endl - << " Generate workarounds for IntelliSense bugs in\n" - << " Visual Studio 2005 (8.0)." - << endl; - - o << "--omit-default-attributes" << endl - << " Omit attributes with default and fixed values\n" - << " from serialized XML documents." - << 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 << "--type-naming <style>" << endl - << " Specify the type naming convention that should be\n" - << " used in the generated code. Valid styles are 'knr'\n" - << " (default), 'ucc', and 'java'." - << endl; - - o << "--function-naming <style>" << endl - << " Specify the function naming convention that should\n" - << " be used in the generated code. Valid styles are\n" - << " 'knr' (default), 'lcc', and 'java'." - << endl; - - o << "--type-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema type names to C++\n" - << " type names." - << endl; - - o << "--accessor-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements and\n" - << " attributes to C++ accessor function names." - << endl; - - o << "--one-accessor-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements\n" - << " and attributes with cardinality one to C++\n" - << " accessor function names." - << endl; - - o << "--opt-accessor-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements\n" - << " and attributes with cardinality optional to C++\n" - << " accessor function names." - << endl; - - o << "--seq-accessor-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements\n" - << " and attributes with cardinality sequence to C++\n" - << " accessor function names." - << endl; - - o << "--modifier-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements and\n" - << " attributes to C++ modifier function names." - << endl; - - o << "--one-modifier-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements\n" - << " and attributes with cardinality one to C++\n" - << " modifier function names." - << endl; - - o << "--opt-modifier-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements\n" - << " and attributes with cardinality optional to C++\n" - << " modifier function names." - << endl; - - o << "--seq-modifier-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema names of elements\n" - << " and attributes with cardinality sequence to C++\n" - << " modifier function names." - << endl; - - o << "--parser-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema element names to\n" - << " C++ parsing function names." - << endl; - - o << "--serializer-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema element names to\n" - << " C++ serialization function names." - << endl; - - o << "--enumerator-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema enumeration values\n" - << " to C++ enumerator names." - << endl; - - o << "--element-type-regex <expr>" << endl - << " Add <expr> to the list of regular expressions\n" - << " used to translate XML Schema element names to\n" - << " C++ element type names." - << endl; - - o << "--name-regex-trace" << endl - << " Trace the process of applying regular expressions\n" - << " specified with the name transformation options." - << 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 << "--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 <element>" << endl - << " Treat only <element> as a document root. Repeat\n" - << " this option to specify more than one root element." - << endl; - - o << "--custom-type <map>" << endl - << " Use a custom C++ type instead of the generated\n" - << " class. The <map> argument is in the form\n" - << " name[=type[/base]], where <name> is a type name as\n" - << " defined in XML Schema, <type> is a C++ type name\n" - << " that should be used instead, and optional <base>\n" - << " is a C++ name that should be given to the C++\n" - << " class generated from the XML Schema definition\n" - << " which is normally used as a base for the custom\n" - << " type." - << endl; - - o << "--custom-type-regex <regex>" << endl - << " Use custom C++ types instead of the generated\n" - << " classes. The <regex> argument is in the form\n" - << " /name/[type/[base/]], where <name> is a regex\n" - << " pattern that will be matched against type names\n" - << " as defined in XML Schema, <type> is a C++ type\n" - << " name that should be used instead, and optional\n" - << " <base> is a C++ name that should be given to\n" - << " the C++ class generated from the XML Schema\n" - << " definition." - << 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 << "--fwd-suffix <suffix>" << endl - << " Use <suffix> instead of the default '-fwd.hxx'\n" - << " to construct the name of the forward declaration\n" - << " 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; - - o << "--fwd-regex <regex>" << endl - << " Use <regex> to construct the name of the forward\n" - << " declaration 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 << "--fwd-prologue <text>" << endl - << " Insert <text> at the beginning of the forward\n" - << " declaration 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 << "--fwd-epilogue <text>" << endl - << " Insert <text> at the end of the forward\n" - << " declaration 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 << "--fwd-prologue-file <file>" << endl - << " Insert the content of the <file> at the beginning\n" - << " of the forward declaration 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 << "--fwd-epilogue-file <file>" << endl - << " Insert the content of the <file> at the end of\n" - << " the forward declaration 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 << "--parts <num>" << endl - << " Split generated source code into <num> parts." - << endl; - - o << "--parts-suffix <suffix>" << endl - << " Use <suffix> instead of the default '-' to\n" - << " separate the file name from the part number." - << endl; - - o << "--custom-literals <file>" << endl - << " Load custom XML string to C++ literal mappings\n" - << " from <file>." - << endl; - - o << "--export-symbol <symbol>" << endl - << " Export symbol for Win32 DLL export/import control." - << endl; - - o << "--export-xml-schema" << endl - << " Export/import types in the XML Schema namespace." - << endl; - - o << "--export-maps" << endl - << " Export polymorphism support maps from Win32 DLL." - << endl; - - o << "--import-maps" << endl - << " Import polymorphism support maps from Win32 DLL." - << endl; - - 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::Tree::options::print_usage (wcout); + CXX::options::print_usage (wcout); } Tree::CLI::OptionsSpec Tree::Generator:: @@ -852,7 +322,6 @@ namespace CXX AutoUnlinks& unlinks) { using std::ios_base; - namespace Indentation = BackendElements::Indentation; typedef cutl::re::regexsub Regex; diff --git a/xsd/cxx/tree/options.cli b/xsd/cxx/tree/options.cli new file mode 100644 index 0000000..58407fa --- /dev/null +++ b/xsd/cxx/tree/options.cli @@ -0,0 +1,415 @@ +// file : xsd/cxx/tree/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 Tree + { + class options: CXX::options + { + // 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} + or \cb{--polymorphic-type-all} option to specify which type + hierarchies are polymorphic." + }; + + std::vector<Cult::Types::NarrowString> --polymorphic-type + { + "<type>", + "Indicate that <type> is a root of a polymorphic type hierarchy. The + 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 <type>. The <type> argument is an XML Schema type name + that can be optionally qualified with a namespace in the + \c{\i{namespace}\b{#}\i{name}} form." + }; + + bool --polymorphic-type-all + { + "Indicate that all types should be treated as polymorphic." + }; + + + // Features. + // + bool --generate-serialization + { + "Generate serialization functions. Serialization functions convert + the object model back to XML." + }; + + bool --generate-inline + { + "Generate simple functions inline. This option triggers creation of + the inline file." + }; + + bool --generate-ostream + { + "Generate ostream insertion operators (\cb{operator<<}) for generated + types. This allows one to easily print a fragment or the whole object + model for debugging or logging." + }; + + bool --generate-doxygen + { + "Generate documentation comments suitable for extraction by the + Doxygen documentation system. Documentation from annotations is + added to the comments if present in the schema." + }; + + bool --generate-comparison + { + "Generate comparison operators (\cb{operator==} and \cb{operator!=}) + for complex types. Comparison is performed member-wise." + }; + + bool --generate-default-ctor + { + "Generate default constructors even for types that have required + members. Required members of an instance constructed using such a + constructor are not initialized and accessing them results in + undefined behavior." + }; + + bool --generate-from-base-ctor + { + "Generate constructors that expect an instance of a base type + followed by all required members." + }; + + bool --suppress-assignment + { + "Suppress the generation of copy assignment operators for complex + types. If this option is specified, the copy assignment operators + for such types are declared private and left unimplemented." + }; + + bool --generate-detach + { + "Generate detach functions for required elements and attributes. + Detach functions for optional and sequence cardinalities are + provided by the respective containers. These functions, for + example, allow you to move sub-trees in the object model either + within the same tree or between different trees." + }; + + bool --generate-wildcard + { + "Generate accessors and modifiers as well as parsing and serialization + code for XML Schema wildcards (\cb{any} and \cb{anyAttribute}). XML + content matched by wildcards is presented as DOM fragments. Note + that you need to initialize the Xerces-C++ runtime if you are using + this option." + }; + + std::vector<Cult::Types::NarrowString> --generate-insertion + { + "<os>", + "Generate data representation stream insertion operators for the <os> + output stream type. Repeat this option to specify more than one + stream type. The ACE CDR stream (\cb{ACE_OutputCDR}) and RPC XDR + are recognized by the compiler and the necessary \cb{#include} + directives are automatically generated. For custom stream types use + the \cb{--hxx-prologue*} options to provide the necessary + declarations." + }; + + std::vector<Cult::Types::NarrowString> --generate-extraction + { + "<is>", + "Generate data representation stream extraction constructors for the + <is> input stream type. Repeat this option to specify more than one + stream type. The ACE CDR stream (\cb{ACE_InputCDR}) and RPC XDR are + recognized by the compiler and the necessary \cb{#include} directives + are automatically generated. For custom stream types use the + \cb{--hxx-prologue*} options to provide the necessary declarations." + }; + + bool --generate-forward + { + "Generate a separate header file with forward declarations for the + types being generated." + }; + + bool --suppress-parsing + { + "Suppress the generation of the parsing functions and constructors. + Use this option to reduce the generated code size when parsing from + XML is not needed." + }; + + bool --generate-element-type + { + "Generate types instead of parsing and serialization functions for + root elements. This is primarily useful to distinguish object models + with the same root type but with different root elements." + }; + + bool --generate-element-map + { + "Generate a root element map that allows uniform parsing and + serialization of multiple root elements. This option is only valid + together with \cb{--generate-element-type}." + }; + + bool --generate-intellisense + { + "Generate workarounds for IntelliSense bugs in Visual Studio 2005 + (8.0). When this option is used, the resulting code is slightly + more verbose. IntelliSense in Visual Studio 2008 (9.0) and later + does not require these workarounds. Support for IntelliSense in + Visual Studio 2003 (7.1) is improved with this option but is + still incomplete." + }; + + bool --omit-default-attributes + { + "Omit attributes with default and fixed values from serialized XML + documents." + }; + + // Naming. + // + Cult::Types::NarrowString --type-naming = "knr" + { + "<style>", + "Specify the type naming convention that should be used in the + generated code. Valid styles are \cb{knr} (default), \cb{ucc}, + and \cb{java}. See the NAMING CONVENTION section below for more + information." + }; + + Cult::Types::NarrowString --function-naming = "knr" + { + "<style>", + "Specify the function naming convention that should be used in the + generated code. Valid styles are \cb{knr} (default), \cb{lcc}, and + \cb{java}. See the NAMING CONVENTION section below for more + information." + }; + + std::vector<Cult::Types::NarrowString> --type-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema type names to C++ type names. See the NAMING CONVENTION + section below for more information." + }; + + std::vector<Cult::Types::NarrowString> --accessor-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes to C++ accessor function + names. See the NAMING CONVENTION section below for more information." + }; + + std::vector<Cult::Types::NarrowString> --one-accessor-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes with cardinality one to + C++ accessor function names. See the NAMING CONVENTION section + below for more information." + }; + + std::vector<Cult::Types::NarrowString> --opt-accessor-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes with cardinality optional + to C++ accessor function names. See the NAMING CONVENTION section + below for more information." + }; + + std::vector<Cult::Types::NarrowString> --seq-accessor-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes with cardinality sequence + to C++ accessor function names. See the NAMING CONVENTION section + below for more information." + }; + + std::vector<Cult::Types::NarrowString> --modifier-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes to C++ modifier function + names. See the NAMING CONVENTION section below for more information." + }; + + std::vector<Cult::Types::NarrowString> --one-modifier-regex + + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes with cardinality one to C++ + modifier function names. See the NAMING CONVENTION section below + for more information." + }; + + std::vector<Cult::Types::NarrowString> --opt-modifier-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes with cardinality optional + to C++ modifier function names. See the NAMING CONVENTION section + below for more information." + }; + + std::vector<Cult::Types::NarrowString> --seq-modifier-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema names of elements/attributes with cardinality sequence + to C++ modifier function names. See the NAMING CONVENTION section + below for more information." + }; + + std::vector<Cult::Types::NarrowString> --parser-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema element names to C++ parsing function names. See the + NAMING CONVENTION section below for more information." + }; + + std::vector<Cult::Types::NarrowString> --serializer-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema element names to C++ serialization function names. See + the NAMING CONVENTION section below for more information." + }; + + std::vector<Cult::Types::NarrowString> --enumerator-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema enumeration values to C++ enumerator names. See the + NAMING CONVENTION section below for more information." + }; + + std::vector<Cult::Types::NarrowString> --element-type-regex + { + "<regex>", + "Add <regex> to the list of regular expressions used to translate + XML Schema element names to C++ element type names. See the NAMING + CONVENTION section below for more information." + }; + + bool --name-regex-trace + { + "Trace the process of applying regular expressions specified with + the name transformation options. Use this option to find out why + your regular expressions don't do what you expected them to do." + }; + + // Root element. + // + bool --root-element-first + { + "Treat only the first global element as a document root. By default + all global elements are considered document roots." + }; + + bool --root-element-last + { + "Treat only the last global element as a document root. By default + all global elements are considered document roots." + }; + + bool --root-element-all + { + "Treat all global elements as document roots. This is the default + behavior. By explicitly specifying this option you can suppress + the warning that is issued if more than one global element is + defined." + }; + + bool --root-element-none + { + "Do not treat any global elements as document roots. By default all + global elements are considered document roots." + }; + + std::vector<Cult::Types::NarrowString> --root-element + { + "<element>", + "Treat only <element> as a document root. Repeat this option to + specify more than one root element." + }; + + // Custom type. + // + std::vector<Cult::Types::NarrowString> --custom-type + { + "<map>", + "Use a custom C++ type instead of the generated class. The <map> + argument is in the form \c{\i{name}[\b{=}\i{type}[\b{/}\i{base}]]}, + where \i{name} is a type name as defined in XML Schema and \i{type} + is a C++ type name that should be used instead. If \i{type} is not + present or empty then the custom type is assumed to have the same + name and be defined in the same namespace as the generated class + would have. If \i{base} is specified then the generated class is + still generated but with that name." + }; + + std::vector<Cult::Types::NarrowString> --custom-type-regex + { + "<regex>", + "Use custom C++ types instead of the generated classes. The <regex> + argument is in the form + \c{\b{/}\i{name-pat}\b{/}[\i{type-sub}\b{/}[\i{base-sub}\b{/}]]}, + where \i{name-pat} is a regex pattern that will be matched against + type names as defined in XML Schema and \i{type-sub} is a C++ type + name substitution that should be used instead. If \i{type-sub} is + not present or its substitution results in an empty string then + the custom type is assumed to have the same name and be defined + in the same namespace as the generated class would have. If + \i{base-sub} is present and its substitution results in a + non-empty string then the generated class is still generated + but with the result of this substitution as its name. The pattern + and substitutions are in the Perl regular expression format. + See also the REGEX AND SHELL QUOTING section below." + }; + + // Parts. + // + std::size_t --parts = 1 + { + "<num>", + "Split generated source code into <num> parts. This is useful when + translating large, monolithic schemas and a C++ compiler is not + able to compile the resulting source code at once (usually due + to insufficient memory)." + }; + + Cult::Types::NarrowString --parts-suffix = "-" + { + "<suffix>", + "Use <suffix> instead of the default '\cb{-}' to separate the file + name from the part number." + }; + }; + } +} |