From 592587e0073cb6722f1fc9c0833d441ad5636358 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Jun 2012 19:01:54 +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. --- xsd/cxx/parser/generator.cxx | 337 +------------------------------------------ xsd/cxx/parser/options.cli | 157 ++++++++++++++++++++ 2 files changed, 160 insertions(+), 334 deletions(-) create mode 100644 xsd/cxx/parser/options.cli (limited to 'xsd/cxx/parser') 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 #include -#include - #include #include @@ -45,7 +43,7 @@ #include #include -#include +#include #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 " << endl - << " Read XML Schema to C++ type mapping information\n" - << " from . 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 " << endl - << " Use as the base character type. Valid\n" - << " values are 'char' (default) and 'wchar_t'." - << endl; - - o << "--char-encoding " << 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 " << endl - << " Write generated files to instead of current\n" - << " directory." - << endl; - - o << "--xml-parser " << endl - << " Use 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 " << endl - << " Indicate that 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 " << endl - << " Generate code as if the XML Schema namespace was\n" - << " defined in and xsd:included in the schema\n" - << " being compiled." - << endl; - - o << "--skel-type-suffix " << endl - << " Use instead of the default '_pskel' to\n" - << " construct the names of generated parser skeletons." - << endl; - - o << "--skel-file-suffix " << endl - << " Use instead of the default '-pskel' to\n" - << " construct the names of generated parser skeleton\n" - << " files." - << endl; - - o << "--impl-type-suffix " << endl - << " Use 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 " << endl - << " Use instead of the default '-pimpl' to\n" - << " construct the names of generated sample parser\n" - << " implementation files." - << 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; - - o << "--hxx-suffix " << endl - << " Use instead of the default '.hxx' to\n" - << " construct the name of the header file." - << endl; - - o << "--ixx-suffix " << endl - << " Use instead of the default '.ixx' to\n" - << " construct the name of the inline file." - << endl; - - o << "--cxx-suffix " << endl - << " Use instead of the default '.cxx' to\n" - << " construct the name of the source file." - << endl; - - o << "--hxx-regex " << endl - << " Use to construct the name of the header\n" - << " file." - << endl; - - o << "--ixx-regex " << endl - << " Use to construct the name of the inline\n" - << " file." - << endl; - - o << "--cxx-regex " << endl - << " Use to construct the name of the source\n" - << " file." - << endl; - - - // Prologues. - // - o << "--hxx-prologue " << endl - << " Insert at the beginning of the header file." - << endl; - - o << "--ixx-prologue " << endl - << " Insert at the beginning of the inline file." - << endl; - - o << "--cxx-prologue " << endl - << " Insert at the beginning of the source 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 file." - << endl; - - o << "--ixx-epilogue " << endl - << " Insert at the end of the inline file." - << endl; - - o << "--cxx-epilogue " << endl - << " Insert at the end of the source 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 file." - << endl; - - o << "--ixx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the inline file." - << endl; - - o << "--cxx-prologue-file " << endl - << " Insert the content of the at the beginning\n" - << " of the source 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 file." - << endl; - - o << "--ixx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the inline file." - << endl; - - o << "--cxx-epilogue-file " << endl - << " Insert the content of the at the end of\n" - << " the source 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 << "--custom-literals " << endl - << " Load custom XML string to C++ literal mappings\n" - << " from ." - << endl; - - o << "--export-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 " << 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::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 +// 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 Parser + { + class options: CXX::options + { + std::vector --type-map + { + "", + "Read XML Schema to C++ type mapping information from . + 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" + { + "", + "Use 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 + { + "", + "Indicate that 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" + { + "", + "Use the provided instead of the default \cb{_pskel} to + construct the names of the generated parser skeletons." + }; + + Cult::Types::NarrowString --skel-file-suffix = "-pskel" + { + "", + "Use the provided instead of the default \cb{-pskel} to + construct the names of the generated parser skeleton files." + }; + + Cult::Types::NarrowString --impl-type-suffix = "_pimpl" + { + "", + "Use the provided 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" + { + "", + "Use the provided instead of the default \cb{-pimpl} to + construct the names of the generated sample parser implementation + files." + }; + }; + } +} -- cgit v1.1