From 1494877a56f9034d5a0218cc02128ef015e1fc23 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 19 Nov 2021 21:57:02 +0300 Subject: Make changes required for CI --- xsd/xsd/cxx/parser/options.cxx | 697 +++++++++++++++++++++++++++++++++++++++++ xsd/xsd/cxx/parser/options.hxx | 186 +++++++++++ xsd/xsd/cxx/parser/options.ixx | 162 ++++++++++ 3 files changed, 1045 insertions(+) create mode 100644 xsd/xsd/cxx/parser/options.cxx create mode 100644 xsd/xsd/cxx/parser/options.hxx create mode 100644 xsd/xsd/cxx/parser/options.ixx (limited to 'xsd/xsd/cxx/parser') diff --git a/xsd/xsd/cxx/parser/options.cxx b/xsd/xsd/cxx/parser/options.cxx new file mode 100644 index 0000000..d7c03d9 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.cxx @@ -0,0 +1,697 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +#include +// +// End prologue. + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace cli +{ + template + struct parser + { + static void + parse (X& x, bool& xs, scanner& s) + { + using namespace std; + + const char* o (s.next ()); + if (s.more ()) + { + string v (s.next ()); + istringstream is (v); + if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + + xs = true; + } + }; + + template <> + struct parser + { + static void + parse (bool& x, scanner& s) + { + s.next (); + x = true; + } + }; + + template <> + struct parser + { + static void + parse (std::string& x, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + x = s.next (); + else + throw missing_value (o); + + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::pair& x, bool& xs, scanner& s) + { + x.second = s.position (); + parser::parse (x.first, xs, s); + } + }; + + template + struct parser > + { + static void + parse (std::vector& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.push_back (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::set& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.insert (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::map& m, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + std::size_t pos (s.position ()); + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); + + int ac (2); + char* av[] = + { + const_cast (o), + 0 + }; + + bool dummy; + if (!kstr.empty ()) + { + av[1] = const_cast (kstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (k, dummy, s); + } + + if (!vstr.empty ()) + { + av[1] = const_cast (vstr.c_str ()); + argv_scanner s (0, ac, av, false, pos); + parser::parse (v, dummy, s); + } + + m[k] = v; + } + else + throw missing_value (o); + + xs = true; + } + }; + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, s); + } + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, x.*S, s); + } +} + +#include +#include + +namespace CXX +{ + namespace Parser + { + // options + // + + options:: + options () + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + } + + options:: + options (int& argc, + char** argv, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int start, + int& argc, + char** argv, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + } + + options:: + options (int& argc, + char** argv, + int& end, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (int start, + int& argc, + char** argv, + int& end, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + ::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + options:: + options (::cli::scanner& s, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : type_map_ (), + type_map_specified_ (false), + xml_parser_ ("xerces"), + xml_parser_specified_ (false), + generate_validation_ (), + suppress_validation_ (), + generate_polymorphic_ (), + generate_noop_impl_ (), + generate_print_impl_ (), + generate_test_driver_ (), + force_overwrite_ (), + root_element_first_ (), + root_element_last_ (), + root_element_ (), + root_element_specified_ (false), + skel_type_suffix_ ("_pskel"), + skel_type_suffix_specified_ (false), + skel_file_suffix_ ("-pskel"), + skel_file_suffix_specified_ (false), + impl_type_suffix_ ("_pimpl"), + impl_type_suffix_specified_ (false), + impl_file_suffix_ ("-pimpl"), + impl_file_suffix_specified_ (false) + { + _parse (s, opt, arg); + } + + ::cli::usage_para options:: + print_usage (::std::wostream& os, ::cli::usage_para p) + { + CLI_POTENTIALLY_UNUSED (os); + + if (p == ::cli::usage_para::text) + os << ::std::endl; + + os << "--type-map Read XML Schema to C++ type mapping information" << ::std::endl + << " from ." << ::std::endl; + + os << "--xml-parser Use as the underlying XML parser." << ::std::endl; + + os << "--generate-validation Generate validation code." << ::std::endl; + + os << "--suppress-validation Suppress the generation of validation code." << ::std::endl; + + os << "--generate-polymorphic Generate polymorphism-aware code." << ::std::endl; + + os << "--generate-noop-impl Generate a sample parser implementation that does" << ::std::endl + << " nothing (no operation)." << ::std::endl; + + os << "--generate-print-impl Generate a sample parser implementation that" << ::std::endl + << " prints the XML data to STDOUT." << ::std::endl; + + os << "--generate-test-driver Generate a test driver for the sample parser" << ::std::endl + << " implementation." << ::std::endl; + + os << "--force-overwrite Force overwriting of the existing implementation" << ::std::endl + << " and test driver files." << ::std::endl; + + os << "--root-element-first Indicate that the first global element is the" << ::std::endl + << " document root." << ::std::endl; + + os << "--root-element-last Indicate that the last global element is the" << ::std::endl + << " document root." << ::std::endl; + + os << "--root-element Indicate that is the document root." << ::std::endl; + + os << "--skel-type-suffix Use the provided instead of the default" << ::std::endl + << " _pskel to construct the names of the generated" << ::std::endl + << " parser skeletons." << ::std::endl; + + os << "--skel-file-suffix Use the provided instead of the default" << ::std::endl + << " -pskel to construct the names of the generated" << ::std::endl + << " parser skeleton files." << ::std::endl; + + os << "--impl-type-suffix Use the provided instead of the default" << ::std::endl + << " _pimpl to construct the names of the parser" << ::std::endl + << " implementations for the built-in XML Schema types" << ::std::endl + << " as well as sample parser implementations." << ::std::endl; + + os << "--impl-file-suffix Use the provided instead of the default" << ::std::endl + << " -pimpl to construct the names of the generated" << ::std::endl + << " sample parser implementation files." << ::std::endl; + + p = ::cli::usage_para::option; + + return p; + } + + typedef + std::map + _cli_options_map; + + static _cli_options_map _cli_options_map_; + + struct _cli_options_map_init + { + _cli_options_map_init () + { + _cli_options_map_["--type-map"] = + &::cli::thunk< options, NarrowStrings, &options::type_map_, + &options::type_map_specified_ >; + _cli_options_map_["--xml-parser"] = + &::cli::thunk< options, NarrowString, &options::xml_parser_, + &options::xml_parser_specified_ >; + _cli_options_map_["--generate-validation"] = + &::cli::thunk< options, bool, &options::generate_validation_ >; + _cli_options_map_["--suppress-validation"] = + &::cli::thunk< options, bool, &options::suppress_validation_ >; + _cli_options_map_["--generate-polymorphic"] = + &::cli::thunk< options, bool, &options::generate_polymorphic_ >; + _cli_options_map_["--generate-noop-impl"] = + &::cli::thunk< options, bool, &options::generate_noop_impl_ >; + _cli_options_map_["--generate-print-impl"] = + &::cli::thunk< options, bool, &options::generate_print_impl_ >; + _cli_options_map_["--generate-test-driver"] = + &::cli::thunk< options, bool, &options::generate_test_driver_ >; + _cli_options_map_["--force-overwrite"] = + &::cli::thunk< options, bool, &options::force_overwrite_ >; + _cli_options_map_["--root-element-first"] = + &::cli::thunk< options, bool, &options::root_element_first_ >; + _cli_options_map_["--root-element-last"] = + &::cli::thunk< options, bool, &options::root_element_last_ >; + _cli_options_map_["--root-element"] = + &::cli::thunk< options, NarrowString, &options::root_element_, + &options::root_element_specified_ >; + _cli_options_map_["--skel-type-suffix"] = + &::cli::thunk< options, NarrowString, &options::skel_type_suffix_, + &options::skel_type_suffix_specified_ >; + _cli_options_map_["--skel-file-suffix"] = + &::cli::thunk< options, NarrowString, &options::skel_file_suffix_, + &options::skel_file_suffix_specified_ >; + _cli_options_map_["--impl-type-suffix"] = + &::cli::thunk< options, NarrowString, &options::impl_type_suffix_, + &options::impl_type_suffix_specified_ >; + _cli_options_map_["--impl-file-suffix"] = + &::cli::thunk< options, NarrowString, &options::impl_file_suffix_, + &options::impl_file_suffix_specified_ >; + } + }; + + static _cli_options_map_init _cli_options_map_init_; + + bool options:: + _parse (const char* o, ::cli::scanner& s) + { + _cli_options_map::const_iterator i (_cli_options_map_.find (o)); + + if (i != _cli_options_map_.end ()) + { + (*(i->second)) (*this, s); + return true; + } + + // options base + // + if (::CXX::options::_parse (o, s)) + return true; + + return false; + } + + bool options:: + _parse (::cli::scanner& s, + ::cli::unknown_mode opt_mode, + ::cli::unknown_mode arg_mode) + { + // Can't skip combined flags (--no-combined-flags). + // + assert (opt_mode != ::cli::unknown_mode::skip); + + bool r = false; + bool opt = true; + + while (s.more ()) + { + const char* o = s.peek (); + + if (std::strcmp (o, "--") == 0) + { + opt = false; + s.skip (); + r = true; + continue; + } + + if (opt) + { + if (_parse (o, s)) + { + r = true; + continue; + } + + if (std::strncmp (o, "-", 1) == 0 && o[1] != '\0') + { + // Handle combined option values. + // + std::string co; + if (const char* v = std::strchr (o, '=')) + { + co.assign (o, 0, v - o); + ++v; + + int ac (2); + char* av[] = + { + const_cast (co.c_str ()), + const_cast (v) + }; + + ::cli::argv_scanner ns (0, ac, av); + + if (_parse (co.c_str (), ns)) + { + // Parsed the option but not its value? + // + if (ns.end () != 2) + throw ::cli::invalid_value (co, v); + + s.next (); + r = true; + continue; + } + else + { + // Set the unknown option and fall through. + // + o = co.c_str (); + } + } + + // Handle combined flags. + // + char cf[3]; + { + const char* p = o + 1; + for (; *p != '\0'; ++p) + { + if (!((*p >= 'a' && *p <= 'z') || + (*p >= 'A' && *p <= 'Z') || + (*p >= '0' && *p <= '9'))) + break; + } + + if (*p == '\0') + { + for (p = o + 1; *p != '\0'; ++p) + { + std::strcpy (cf, "-"); + cf[1] = *p; + cf[2] = '\0'; + + int ac (1); + char* av[] = + { + cf + }; + + ::cli::argv_scanner ns (0, ac, av); + + if (!_parse (cf, ns)) + break; + } + + if (*p == '\0') + { + // All handled. + // + s.next (); + r = true; + continue; + } + else + { + // Set the unknown option and fall through. + // + o = cf; + } + } + } + + switch (opt_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + r = true; + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_option (o); + } + } + + break; + } + } + + switch (arg_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + r = true; + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_argument (o); + } + } + + break; + } + + return r; + } + } +} + +// Begin epilogue. +// +// +// End epilogue. + diff --git a/xsd/xsd/cxx/parser/options.hxx b/xsd/xsd/cxx/parser/options.hxx new file mode 100644 index 0000000..03b67fd --- /dev/null +++ b/xsd/xsd/cxx/parser/options.hxx @@ -0,0 +1,186 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef XSD_CXX_PARSER_OPTIONS_HXX +#define XSD_CXX_PARSER_OPTIONS_HXX + +// Begin prologue. +// +// +// End prologue. + +#include + +#include + +#include + +namespace CXX +{ + namespace Parser + { + class options: public ::CXX::options + { + public: + options (); + + options (int& argc, + char** argv, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (int& argc, + char** argv, + int& end, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (int start, + int& argc, + char** argv, + int& end, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + options (::cli::scanner&, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + // Option accessors. + // + const NarrowStrings& + type_map () const; + + bool + type_map_specified () const; + + const NarrowString& + xml_parser () const; + + bool + xml_parser_specified () const; + + const bool& + generate_validation () const; + + const bool& + suppress_validation () const; + + const bool& + generate_polymorphic () const; + + const bool& + generate_noop_impl () const; + + const bool& + generate_print_impl () const; + + const bool& + generate_test_driver () const; + + const bool& + force_overwrite () const; + + const bool& + root_element_first () const; + + const bool& + root_element_last () const; + + const NarrowString& + root_element () const; + + bool + root_element_specified () const; + + const NarrowString& + skel_type_suffix () const; + + bool + skel_type_suffix_specified () const; + + const NarrowString& + skel_file_suffix () const; + + bool + skel_file_suffix_specified () const; + + const NarrowString& + impl_type_suffix () const; + + bool + impl_type_suffix_specified () const; + + const NarrowString& + impl_file_suffix () const; + + bool + impl_file_suffix_specified () const; + + // Print usage information. + // + static ::cli::usage_para + print_usage (::std::wostream&, + ::cli::usage_para = ::cli::usage_para::none); + + // Implementation details. + // + protected: + bool + _parse (const char*, ::cli::scanner&); + + private: + bool + _parse (::cli::scanner&, + ::cli::unknown_mode option, + ::cli::unknown_mode argument); + + public: + NarrowStrings type_map_; + bool type_map_specified_; + NarrowString xml_parser_; + bool xml_parser_specified_; + bool generate_validation_; + bool suppress_validation_; + bool generate_polymorphic_; + bool generate_noop_impl_; + bool generate_print_impl_; + bool generate_test_driver_; + bool force_overwrite_; + bool root_element_first_; + bool root_element_last_; + NarrowString root_element_; + bool root_element_specified_; + NarrowString skel_type_suffix_; + bool skel_type_suffix_specified_; + NarrowString skel_file_suffix_; + bool skel_file_suffix_specified_; + NarrowString impl_type_suffix_; + bool impl_type_suffix_specified_; + NarrowString impl_file_suffix_; + bool impl_file_suffix_specified_; + }; + } +} + +#include + +// Begin epilogue. +// +// +// End epilogue. + +#endif // XSD_CXX_PARSER_OPTIONS_HXX diff --git a/xsd/xsd/cxx/parser/options.ixx b/xsd/xsd/cxx/parser/options.ixx new file mode 100644 index 0000000..64c00c5 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.ixx @@ -0,0 +1,162 @@ +// -*- C++ -*- +// +// This file was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +// +// End prologue. + +namespace CXX +{ + namespace Parser + { + // options + // + + inline const NarrowStrings& options:: + type_map () const + { + return this->type_map_; + } + + inline bool options:: + type_map_specified () const + { + return this->type_map_specified_; + } + + inline const NarrowString& options:: + xml_parser () const + { + return this->xml_parser_; + } + + inline bool options:: + xml_parser_specified () const + { + return this->xml_parser_specified_; + } + + inline const bool& options:: + generate_validation () const + { + return this->generate_validation_; + } + + inline const bool& options:: + suppress_validation () const + { + return this->suppress_validation_; + } + + inline const bool& options:: + generate_polymorphic () const + { + return this->generate_polymorphic_; + } + + inline const bool& options:: + generate_noop_impl () const + { + return this->generate_noop_impl_; + } + + inline const bool& options:: + generate_print_impl () const + { + return this->generate_print_impl_; + } + + inline const bool& options:: + generate_test_driver () const + { + return this->generate_test_driver_; + } + + inline const bool& options:: + force_overwrite () const + { + return this->force_overwrite_; + } + + inline const bool& options:: + root_element_first () const + { + return this->root_element_first_; + } + + inline const bool& options:: + root_element_last () const + { + return this->root_element_last_; + } + + inline const NarrowString& options:: + root_element () const + { + return this->root_element_; + } + + inline bool options:: + root_element_specified () const + { + return this->root_element_specified_; + } + + inline const NarrowString& options:: + skel_type_suffix () const + { + return this->skel_type_suffix_; + } + + inline bool options:: + skel_type_suffix_specified () const + { + return this->skel_type_suffix_specified_; + } + + inline const NarrowString& options:: + skel_file_suffix () const + { + return this->skel_file_suffix_; + } + + inline bool options:: + skel_file_suffix_specified () const + { + return this->skel_file_suffix_specified_; + } + + inline const NarrowString& options:: + impl_type_suffix () const + { + return this->impl_type_suffix_; + } + + inline bool options:: + impl_type_suffix_specified () const + { + return this->impl_type_suffix_specified_; + } + + inline const NarrowString& options:: + impl_file_suffix () const + { + return this->impl_file_suffix_; + } + + inline bool options:: + impl_file_suffix_specified () const + { + return this->impl_file_suffix_specified_; + } + } +} + +// Begin epilogue. +// +// +// End epilogue. -- cgit v1.1