diff options
Diffstat (limited to 'xsd/xsd/cxx/parser')
38 files changed, 2133 insertions, 1750 deletions
diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.cxx b/xsd/xsd/cxx/parser/attribute-validation-source.cxx index 536e2da..7ed54e4 100644 --- a/xsd/xsd/cxx/parser/attribute-validation-source.cxx +++ b/xsd/xsd/cxx/parser/attribute-validation-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/attribute-validation-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/attribute-validation-source.hxx> @@ -23,7 +22,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { String const& name (a.name ()); @@ -39,7 +38,7 @@ namespace CXX os << "n == " << strlit (name) << " && ns.empty ()"; } - virtual Void + virtual void traverse (SemanticGraph::AnyAttribute& a) { String const& ns (a.definition_namespace ().name ()); @@ -93,7 +92,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& name (ename (a)); @@ -120,10 +119,20 @@ namespace CXX os << "this->" << inst << "->" << post << " ();" << "this->" << name << " ();"; else - os << arg_type (type) << " tmp (this->" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);" - << endl; + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (std == cxx_version::cxx98) + os << arg_type (type) << " tmp (this->" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (this->" << inst << "->" << + post << " ());"; + } os << "}"; @@ -149,7 +158,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { os << "if ("; @@ -177,7 +186,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (!a.optional_p ()) @@ -195,7 +204,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (!a.optional_p ()) @@ -227,16 +236,16 @@ namespace CXX names_attribute_state_check_ >> attribute_state_check_; } - virtual Void + virtual void traverse (Type& c) { - Boolean has_att (has<Traversal::Attribute> (c)); - Boolean has_any (has<Traversal::AnyAttribute> (c)); + bool has_att (has<Traversal::Attribute> (c)); + bool has_any (has<Traversal::AnyAttribute> (c)); if (!has_att && !has_any) return; - Boolean has_req_att (false); + bool has_req_att (false); if (has_att) { RequiredAttributeTest test (has_req_att); @@ -380,12 +389,12 @@ namespace CXX }; } - Void + void generate_attribute_validation_source (Context& ctx) { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/attribute-validation-source.hxx b/xsd/xsd/cxx/parser/attribute-validation-source.hxx index a11f434..10438fd 100644 --- a/xsd/xsd/cxx/parser/attribute-validation-source.hxx +++ b/xsd/xsd/cxx/parser/attribute-validation-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/attribute-validation-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_ATTRIBUTE_VALIDATION_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_attribute_validation_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/characters-validation-source.cxx b/xsd/xsd/cxx/parser/characters-validation-source.cxx index 236f2f5..ddecc70 100644 --- a/xsd/xsd/cxx/parser/characters-validation-source.cxx +++ b/xsd/xsd/cxx/parser/characters-validation-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/characters-validation-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/characters-validation-source.hxx> @@ -23,7 +22,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { if (!c.mixed_p ()) @@ -46,7 +45,7 @@ namespace CXX }; } - Void + void generate_characters_validation_source (Context& ctx) { //@@ Most of the time there is no mixed content type so @@ -56,7 +55,7 @@ namespace CXX // Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/characters-validation-source.hxx b/xsd/xsd/cxx/parser/characters-validation-source.hxx index 2c1a1b1..219df3e 100644 --- a/xsd/xsd/cxx/parser/characters-validation-source.hxx +++ b/xsd/xsd/cxx/parser/characters-validation-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/characters-validation-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_CHARACTERS_VALIDATION_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_characters_validation_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/cli.hxx b/xsd/xsd/cxx/parser/cli.hxx deleted file mode 100644 index bc7ca1a..0000000 --- a/xsd/xsd/cxx/parser/cli.hxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : xsd/cxx/parser/cli.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#ifndef CXX_PARSER_CLI_HXX -#define CXX_PARSER_CLI_HXX - -#include <cult/types.hxx> - -#include <cult/containers/vector.hxx> - -#include <cult/cli/options.hxx> -#include <cult/cli/options-spec.hxx> - -namespace CXX -{ - namespace Parser - { - namespace CLI - { - using namespace Cult::Types; - - typedef Char const Key[]; - - extern Key type_map; - extern Key char_encoding; - extern Key char_type; - extern Key output_dir; - extern Key xml_parser; - extern Key generate_inline; - extern Key generate_validation; - extern Key suppress_validation; - extern Key generate_polymorphic; - extern Key generate_noop_impl; - extern Key generate_print_impl; - extern Key generate_test_driver; - extern Key force_overwrite; - extern Key root_element_first; - extern Key root_element_last; - extern Key root_element; - extern Key generate_xml_schema; - extern Key extern_xml_schema; - extern Key skel_type_suffix; - extern Key skel_file_suffix; - extern Key impl_type_suffix; - extern Key impl_file_suffix; - extern Key namespace_map; - extern Key namespace_regex; - extern Key namespace_regex_trace; - extern Key reserved_name; - extern Key include_with_brackets; - extern Key include_prefix; - extern Key include_regex; - extern Key include_regex_trace; - extern Key guard_prefix; - extern Key hxx_suffix; - extern Key ixx_suffix; - extern Key cxx_suffix; - extern Key hxx_regex; - extern Key ixx_regex; - extern Key cxx_regex; - extern Key hxx_prologue; - extern Key ixx_prologue; - extern Key cxx_prologue; - extern Key prologue; - extern Key hxx_epilogue; - extern Key ixx_epilogue; - extern Key cxx_epilogue; - extern Key epilogue; - extern Key hxx_prologue_file; - extern Key ixx_prologue_file; - extern Key cxx_prologue_file; - extern Key prologue_file; - extern Key hxx_epilogue_file; - extern Key ixx_epilogue_file; - extern Key cxx_epilogue_file; - extern Key epilogue_file; - extern Key export_symbol; - extern Key export_maps; - extern Key import_maps; - extern Key show_anonymous; - extern Key show_sloc; - extern Key proprietary_license; - - typedef Cult::CLI::Options< - type_map, Cult::Containers::Vector<NarrowString>, - char_type, NarrowString, - char_encoding, NarrowString, - output_dir, NarrowString, - xml_parser, NarrowString, - generate_inline, Boolean, - generate_validation, Boolean, - suppress_validation, Boolean, - generate_polymorphic, Boolean, - generate_noop_impl, Boolean, - generate_print_impl, Boolean, - generate_test_driver, Boolean, - force_overwrite, Boolean, - root_element_first, Boolean, - root_element_last, Boolean, - root_element, NarrowString, - generate_xml_schema, Boolean, - extern_xml_schema, NarrowString, - skel_type_suffix, NarrowString, - skel_file_suffix, NarrowString, - impl_type_suffix, NarrowString, - impl_file_suffix, NarrowString, - namespace_map, Cult::Containers::Vector<NarrowString>, - namespace_regex, Cult::Containers::Vector<NarrowString>, - namespace_regex_trace, Boolean, - reserved_name, Cult::Containers::Vector<NarrowString>, - include_with_brackets, Boolean, - include_prefix, NarrowString, - include_regex, Cult::Containers::Vector<NarrowString>, - include_regex_trace, Boolean, - guard_prefix, NarrowString, - hxx_suffix, NarrowString, - ixx_suffix, NarrowString, - cxx_suffix, NarrowString, - hxx_regex, NarrowString, - ixx_regex, NarrowString, - cxx_regex, NarrowString, - hxx_prologue, Cult::Containers::Vector<NarrowString>, - ixx_prologue, Cult::Containers::Vector<NarrowString>, - cxx_prologue, Cult::Containers::Vector<NarrowString>, - prologue, Cult::Containers::Vector<NarrowString>, - hxx_epilogue, Cult::Containers::Vector<NarrowString>, - ixx_epilogue, Cult::Containers::Vector<NarrowString>, - cxx_epilogue, Cult::Containers::Vector<NarrowString>, - epilogue, Cult::Containers::Vector<NarrowString>, - hxx_prologue_file, NarrowString, - ixx_prologue_file, NarrowString, - cxx_prologue_file, NarrowString, - prologue_file, NarrowString, - hxx_epilogue_file, NarrowString, - ixx_epilogue_file, NarrowString, - cxx_epilogue_file, NarrowString, - epilogue_file, NarrowString, - export_symbol, NarrowString, - export_maps, Boolean, - import_maps, Boolean, - show_anonymous, Boolean, - show_sloc, Boolean, - proprietary_license, Boolean - - > Options; - - struct OptionsSpec: Cult::CLI::OptionsSpec<Options> {}; - } - } -} - -#endif // CXX_PARSER_CLI_HXX diff --git a/xsd/xsd/cxx/parser/driver-source.cxx b/xsd/xsd/cxx/parser/driver-source.cxx index b48b0e0..510c965 100644 --- a/xsd/xsd/cxx/parser/driver-source.cxx +++ b/xsd/xsd/cxx/parser/driver-source.cxx @@ -1,18 +1,18 @@ // file : xsd/cxx/parser/driver-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <set> +#include <map> +#include <sstream> + #include <cxx/parser/driver-source.hxx> #include <cxx/parser/print-impl-common.hxx> #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> -#include <cult/containers/map.hxx> -#include <cult/containers/set.hxx> - -#include <sstream> +using namespace std; namespace CXX { @@ -20,23 +20,22 @@ namespace CXX { namespace { - typedef - Cult::Containers::Map<SemanticGraph::Type*, String> - TypeInstanceMap; - - typedef Cult::Containers::Set<String> InstanceSet; + typedef map<SemanticGraph::Type*, String> TypeInstanceMap; + typedef set<String> InstanceSet; // For base types we only want member's types, but not the // base itself. // - struct BaseType: Traversal::Complex, Context + struct BaseType: Traversal::Complex, + Traversal::List, + Context { - BaseType (Context& c) - : Context (c) + BaseType (Context& c, Traversal::NodeBase& def) + : Context (c), def_ (def) { } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c); @@ -44,6 +43,15 @@ namespace CXX if (!restriction_p (c)) names (c); } + + virtual void + traverse (SemanticGraph::List& l) + { + def_.dispatch (l.argumented ().type ()); + } + + private: + Traversal::NodeBase& def_; }; struct ParserDef: Traversal::Type, @@ -109,7 +117,7 @@ namespace CXX Context { ParserDef (Context& c, TypeInstanceMap& map, InstanceSet& set) - : Context (c), map_ (map), set_ (set), base_ (c) + : Context (c), map_ (map), set_ (set), base_ (c, *this) { *this >> inherits_ >> base_ >> inherits_; @@ -119,7 +127,7 @@ namespace CXX names_ >> member_ >> belongs_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { if (map_.find (&t) == map_.end ()) @@ -131,7 +139,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (map_.find (&l) == map_.end ()) @@ -145,7 +153,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { if (map_.find (&c) == map_.end ()) @@ -164,13 +172,13 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { fund_type (t, "any_type"); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { fund_type (t, "any_simple_type"); @@ -178,7 +186,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { fund_type (t, "boolean"); @@ -186,79 +194,79 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { fund_type (t, "byte"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { fund_type (t, "unsigned_byte"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { fund_type (t, "short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { fund_type (t, "unsigned_short"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { fund_type (t, "int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { fund_type (t, "unsigned_int"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { fund_type (t, "long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { fund_type (t, "unsigned_long"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { fund_type (t, "integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { fund_type (t, "non_positive_integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { fund_type (t, "non_negative_integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { fund_type (t, "positive_integer"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { fund_type (t, "negative_integer"); @@ -266,19 +274,19 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { fund_type (t, "float"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { fund_type (t, "double"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { fund_type (t, "decimal"); @@ -286,49 +294,49 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { fund_type (t, "string"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { fund_type (t, "normalized_string"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { fund_type (t, "token"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { fund_type (t, "nmtoken"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { fund_type (t, "nmtokens"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { fund_type (t, "name"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { fund_type (t, "ncname"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { fund_type (t, "language"); @@ -337,7 +345,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { fund_type (t, "qname"); @@ -346,19 +354,19 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { fund_type (t, "id"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { fund_type (t, "idref"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { fund_type (t, "idrefs"); @@ -366,7 +374,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { fund_type (t, "uri"); @@ -374,13 +382,13 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { fund_type (t, "base64_binary"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { fund_type (t, "hex_binary"); @@ -389,55 +397,55 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { fund_type (t, "date"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { fund_type (t, "date_time"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { fund_type (t, "duration"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { fund_type (t, "day"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { fund_type (t, "month"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { fund_type (t, "month_day"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { fund_type (t, "year"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { fund_type (t, "year_month"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { fund_type (t, "time"); @@ -445,20 +453,20 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { fund_type (t, "entity"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { fund_type (t, "entities"); } private: - virtual Void + virtual void fund_type (SemanticGraph::Type& t, String const& name) { if (map_.find (&t) == map_.end ()) @@ -476,7 +484,7 @@ namespace CXX String base_name (escape (raw_name + L"_p")); String name (base_name); - for (UnsignedLong i (1); set_.find (name) != set_.end (); ++i) + for (size_t i (1); set_.find (name) != set_.end (); ++i) { std::wostringstream os; os << i; @@ -516,7 +524,7 @@ namespace CXX names_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -525,7 +533,7 @@ namespace CXX names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (!first_) @@ -536,7 +544,7 @@ namespace CXX os << map_[&l.argumented ().type ()]; } - virtual Void + virtual void traverse (SemanticGraph::Member& m) { if (skip (m)) @@ -556,7 +564,7 @@ namespace CXX Traversal::Inherits inherits_; Traversal::Names names_; - Boolean first_; + bool first_; }; struct ParserConnect: Traversal::List, @@ -564,7 +572,7 @@ namespace CXX Context { ParserConnect (Context& c, TypeInstanceMap& map) - : Context (c), map_ (map), base_ (c) + : Context (c), map_ (map), base_ (c, *this) { *this >> inherits_ >> base_ >> inherits_; @@ -574,7 +582,7 @@ namespace CXX names_ >> member_ >> belongs_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (type_set_.find (&l) == type_set_.end ()) @@ -587,7 +595,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { if (type_set_.find (&c) == type_set_.end ()) @@ -613,7 +621,7 @@ namespace CXX } private: - Boolean + bool has_members (SemanticGraph::Complex& c) { using SemanticGraph::Complex; @@ -636,7 +644,7 @@ namespace CXX private: TypeInstanceMap& map_; - Cult::Containers::Set<SemanticGraph::Type*> type_set_; + set<SemanticGraph::Type*> type_set_; BaseType base_; Traversal::Inherits inherits_; @@ -647,7 +655,7 @@ namespace CXX }; } - Void + void generate_driver_source (Context& ctx) { // Figure out the root element. Validator should have made sure @@ -656,7 +664,7 @@ namespace CXX SemanticGraph::Element* root (0); { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; @@ -740,7 +748,7 @@ namespace CXX root_p << "." << post << " ());" << endl; - if (ctx.options.value<CLI::generate_print_impl> ()) + if (ctx.options.generate_print_impl ()) { PrintCall t (ctx, root->name (), "v"); t.dispatch (root_type); diff --git a/xsd/xsd/cxx/parser/driver-source.hxx b/xsd/xsd/cxx/parser/driver-source.hxx index 9b5a8b1..53e19d8 100644 --- a/xsd/xsd/cxx/parser/driver-source.hxx +++ b/xsd/xsd/cxx/parser/driver-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/driver-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_DRIVER_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_driver_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/element-validation-source.cxx b/xsd/xsd/cxx/parser/element-validation-source.cxx index 211a0d3..b2c244e 100644 --- a/xsd/xsd/cxx/parser/element-validation-source.cxx +++ b/xsd/xsd/cxx/parser/element-validation-source.cxx @@ -1,14 +1,15 @@ // file : xsd/cxx/parser/element-validation-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <vector> + #include <cxx/parser/element-validation-source.hxx> #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> -#include <cult/containers/vector.hxx> +using namespace std; namespace CXX { @@ -16,8 +17,7 @@ namespace CXX { namespace { - typedef Cult::Containers::Vector<SemanticGraph::Particle*> Particles; - + typedef vector<SemanticGraph::Particle*> Particles; // // @@ -31,7 +31,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { String const& name (e.name ()); @@ -62,7 +62,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& ns (a.definition_namespace ().name ()); @@ -109,7 +109,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { // This compositor should already have been tested for @@ -117,9 +117,9 @@ namespace CXX // Particles const& p (c.context ().get<Particles> ("prefixes")); - Boolean paren (p.size () != 1); + bool paren (p.size () != 1); - for (Particles::ConstIterator i (p.begin ()), e (p.end ()); + for (Particles::const_iterator i (p.begin ()), e (p.end ()); i != e;) { if (paren) @@ -150,21 +150,21 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); os << strlit (ns) << ", " << strlit (e.name ()); } - virtual Void + virtual void traverse (SemanticGraph::Any& a) { String const& ns (*a.namespace_begin ()); os << strlit (ns) << ", " << L << "\"*\""; } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { Particles const& p (c.context ().get<Particles> ("prefixes")); @@ -187,7 +187,7 @@ namespace CXX // Generate sub-parser setup code as well as the pre/post calls. // - Void + void pre_post_calls (SemanticGraph::Particle& p) { using SemanticGraph::Element; @@ -196,20 +196,23 @@ namespace CXX if (Element* e = dynamic_cast<Element*> (&p)) { SemanticGraph::Type& type (e->type ()); - Boolean poly (polymorphic && !anonymous (type)); + String const& fq_type (fq_name (type)); + bool poly (polymorphic && !anonymous (type)); String name, inst, def_parser, map; if (e->context ().count("name")) { name = ename (*e); - inst = poly ? emember_cache (*e) : emember (*e); if (poly) { def_parser = emember (*e); map = emember_map (*e); + inst = "p"; } + else + inst = L"this->" + emember (*e); } else { @@ -222,13 +225,15 @@ namespace CXX Element& fe (dynamic_cast<Element&>(ip.first->named ())); name = ename (fe); - inst = poly ? emember_cache (fe) : emember (fe); if (poly) { def_parser = emember (fe); map = emember_map (fe); + inst = "p"; } + else + inst = L"this->" + emember (fe); } if (poly) @@ -243,8 +248,10 @@ namespace CXX type_id += type_ns; } - os << "if (t == 0 && this->" << def_parser << " != 0)" << endl - << "this->" << inst << " = this->" << def_parser << ";" + os << fq_type << "* p = 0;" + << endl + << "if (t == 0 && this->" << def_parser << " != 0)" << endl + << inst << " = this->" << def_parser << ";" << "else" << "{" << string_type << " ts (" << fq_name (type) << @@ -254,7 +261,7 @@ namespace CXX << "t = &ts;" << endl << "if (this->" << def_parser << " != 0 && *t == ts)" << endl - << "this->" << inst << " = this->" << def_parser << ";" + << inst << " = this->" << def_parser << ";" << "else" << "{"; @@ -269,36 +276,51 @@ namespace CXX " > (*t);" << endl << "if (this->" << map << " != 0)" << endl - << "this->" << inst << " = dynamic_cast< " << - fq_name (type) << "* > (" << endl + << inst << " = dynamic_cast< " << fq_type << "* > (" << endl << "this->" << map << "->find (*t));" - << "else" << endl - << "this->" << inst << " = 0;" << "}" << "}"; } os << "this->" << complex_base << "::context_.top ()." << - "parser_ = this->" << inst << ";" + "parser_ = " << inst << ";" << endl - << "if (this->" << inst << ")" << endl - << "this->" << inst << "->pre ();" + << "if (" << inst << ")" << endl + << inst << "->pre ();" << "}" << "else" // start - << "{" - << "if (this->" << inst << ")" + << "{"; + + if (poly) + os << fq_type << "* p =" << endl + << "dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << complex_base << "::context_.top ().parser_);" + << endl; + + os << "if (" << inst << ")" << "{"; String const& ret (ret_type (type)); String const& post (post_name (type)); if (ret == L"void") - os << "this->" << inst << "->" << post << " ();" + os << inst << "->" << post << " ();" << "this->" << name << " ();"; else - os << arg_type (type) << " tmp (this->" << inst << "->" << - post << " ());" - << "this->" << name << " (tmp);"; + { + // Don't create an lvalue in C++11 (think std::unique_ptr). + // In C++98 we do it for compatibility with older/broken + // compilers (e.g., IBM xlC that needs an lvalue to pass + // std::auto_ptr). + // + if (std == cxx_version::cxx98) + os << arg_type (type) << " tmp (" << inst << "->" << + post << " ());" + << "this->" << name << " (tmp);"; + else + os << "this->" << name << " (" << inst << "->" << + post << " ());"; + } os << "}"; } @@ -331,10 +353,10 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { - UnsignedLong state (e.context ().get<UnsignedLong> ("state")); + size_t state (e.context ().get<size_t> ("state")); if (state != 0) os << "else "; @@ -382,14 +404,14 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Particle& p) { using SemanticGraph::Element; - UnsignedLong state (p.context ().get<UnsignedLong> ("state")); + size_t state (p.context ().get<size_t> ("state")); - UnsignedLong min (p.min ()), max (p.max ()); + size_t min (p.min ()), max (p.max ()); os << "case " << state << "UL:" << endl << "{"; @@ -465,15 +487,15 @@ namespace CXX << "}"; // case } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { using SemanticGraph::Compositor; - UnsignedLong max (c.max ()); - UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min")); - UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number")); - UnsignedLong state (c.context ().get<UnsignedLong> ("state")); + size_t max (c.max ()); + size_t min (c.context ().get<size_t> ("effective-min")); + size_t n (c.context ().get<size_t> ("comp-number")); + size_t state (c.context ().get<size_t> ("state")); String func (c.is_a<SemanticGraph::Choice> () ? "choice_" : "sequence_"); @@ -483,7 +505,7 @@ namespace CXX << "unsigned long s (~0UL);" << endl; - Boolean first (true); + bool first (true); for (Compositor::ContainsIterator ci (c.contains_begin ()); ci != c.contains_end (); ++ci) @@ -496,7 +518,7 @@ namespace CXX if (!p.context ().count ("prefix")) break; - UnsignedLong state (p.context ().get<UnsignedLong> ("state")); + size_t state (p.context ().get<size_t> ("state")); if (first) first = false; @@ -599,8 +621,8 @@ namespace CXX ParticleInCompositor { ParticleInSequence (Context& c, - UnsignedLong state, - UnsignedLong next_state, + size_t state, + size_t next_state, SemanticGraph::Complex& type) : ParticleInCompositor (c, type), state_ (state), particle_name_ (c) @@ -617,10 +639,10 @@ namespace CXX next_state_ = L"~0"; } - virtual Void + virtual void traverse (SemanticGraph::Particle& p) { - UnsignedLong min (p.min ()), max (p.max ()); + size_t min (p.min ()), max (p.max ()); os << "case " << state_ << "UL:" << endl << "{" @@ -694,14 +716,14 @@ namespace CXX << "}"; // case } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) { using SemanticGraph::Compositor; - UnsignedLong max (c.max ()); - UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min")); - UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number")); + size_t max (c.max ()); + size_t min (c.context ().get<size_t> ("effective-min")); + size_t n (c.context ().get<size_t> ("comp-number")); String func (c.is_a<SemanticGraph::Choice> () ? "choice_" : "sequence_"); @@ -711,7 +733,7 @@ namespace CXX << "unsigned long s (~0UL);" << endl; - Boolean first (true); + bool first (true); for (Compositor::ContainsIterator ci (c.contains_begin ()); ci != c.contains_end (); ++ci) @@ -724,7 +746,7 @@ namespace CXX if (!p.context ().count ("prefix")) break; - UnsignedLong state (p.context ().get<UnsignedLong> ("state")); + size_t state (p.context ().get<size_t> ("state")); if (first) first = false; @@ -816,7 +838,7 @@ namespace CXX } private: - UnsignedLong state_; + size_t state_; String next_state_; ParticleName particle_name_; @@ -837,7 +859,7 @@ namespace CXX } - virtual Void + virtual void traverse (SemanticGraph::All& a) { if (!a.context().count ("comp-number")) // Empty compositor. @@ -878,7 +900,7 @@ namespace CXX Element& e (dynamic_cast<Element&> (ci->particle ())); String ns (e.qualified_p () ? e.namespace_ ().name () : String ()); - UnsignedLong state (e.context ().get<UnsignedLong> ("state")); + size_t state (e.context ().get<size_t> ("state")); os << "if (count[" << state << "UL] == 0)" << endl << "this->_expected_element (" << endl @@ -894,7 +916,7 @@ namespace CXX << "}"; } - virtual Void + virtual void traverse (SemanticGraph::Choice& c) { if (!c.context().count ("comp-number")) // Empty compositor. @@ -902,7 +924,7 @@ namespace CXX using SemanticGraph::Compositor; - UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number")); + size_t n (c.context ().get<size_t> ("comp-number")); os << "void " << ename (type_) << "::" << endl << "choice_" << n << " (unsigned long& state," << endl @@ -940,7 +962,7 @@ namespace CXX Traversal::Choice::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Sequence& s) { if (!s.context().count ("comp-number")) // Empty compositor. @@ -948,7 +970,7 @@ namespace CXX using SemanticGraph::Compositor; - UnsignedLong n (s.context ().get<UnsignedLong> ("comp-number")); + size_t n (s.context ().get<size_t> ("comp-number")); os << "void " << ename (type_) << "::" << endl << "sequence_" << n << " (unsigned long& state," << endl @@ -963,7 +985,7 @@ namespace CXX << "switch (state)" << "{"; - UnsignedLong state (0); + size_t state (0); for (Compositor::ContainsIterator ci (s.contains_begin ()), ce (s.contains_end ()); ci != ce;) @@ -986,7 +1008,7 @@ namespace CXX ci->particle ().is_a<Compositor> () && !ci->particle ().context().count ("comp-number")); - UnsignedLong next (ci == ce ? 0 : state + 1); + size_t next (ci == ce ? 0 : state + 1); ParticleInSequence t (*this, state++, next, type_); t.dispatch (p); @@ -1014,12 +1036,12 @@ namespace CXX Traversal::Compositor, Context { - CompositorPre (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type) + CompositorPre (Context& c) + : Context (c) { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { // Clear the counts and push the initial state. @@ -1031,7 +1053,7 @@ namespace CXX traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Compositor&) // Choice and sequence. { os << "v_state_& vs = *static_cast< v_state_* > (" << @@ -1042,9 +1064,6 @@ namespace CXX << "vd.state = 0;" << "vd.count = 0;"; } - - private: - SemanticGraph::Complex& type_; }; @@ -1060,7 +1079,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::All&) { // The 'all' state machine reaches the final state only @@ -1078,14 +1097,14 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) // Choice and sequence. { using SemanticGraph::Compositor; - UnsignedLong max (c.max ()); - UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min")); - UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number")); + size_t max (c.max ()); + size_t min (c.context ().get<size_t> ("effective-min")); + size_t n (c.context ().get<size_t> ("comp-number")); String func (c.is_a<SemanticGraph::Choice> () ? "choice_" : "sequence_"); @@ -1117,7 +1136,7 @@ namespace CXX << "unsigned long s = ~0UL;" << endl; - Boolean first (true); + bool first (true); // Note that we don't need to worry about the compositor // being empty - this case is handled by our caller. @@ -1133,7 +1152,7 @@ namespace CXX if (!p.context ().count ("prefix")) break; - UnsignedLong state (p.context ().get<UnsignedLong> ("state")); + size_t state (p.context ().get<size_t> ("state")); if (first) first = false; @@ -1230,12 +1249,12 @@ namespace CXX Traversal::Compositor, Context { - CompositorEndElement (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type) + CompositorEndElement (Context& c) + : Context (c) { } - virtual Void + virtual void traverse (SemanticGraph::All&) { os << "all_0 (vd.state, v_all_count_.top (), " << @@ -1243,7 +1262,7 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::Compositor&) // Choice and sequence. { os << "assert (vd.func != 0);" @@ -1253,9 +1272,6 @@ namespace CXX << "vs.size--;" // pop << endl; } - - private: - SemanticGraph::Complex& type_; }; @@ -1265,12 +1281,12 @@ namespace CXX Traversal::Compositor, Context { - CompositorPost (Context& c, SemanticGraph::Complex& type) - : Context (c), type_ (type), particle_name_ (c) + CompositorPost (Context& c) + : Context (c), particle_name_ (c) { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { using SemanticGraph::Element; @@ -1289,7 +1305,7 @@ namespace CXX << "all_0 (vd.state, v_all_count_.top (), empty, empty, 0, true);" << "}"; - if (a.context ().get<UnsignedLong> ("effective-min") != 0) + if (a.context ().get<size_t> ("effective-min") != 0) { os << "else" << endl << "this->_expected_element (" << endl; @@ -1304,10 +1320,10 @@ namespace CXX << "v_all_count_.pop ();"; } - virtual Void + virtual void traverse (SemanticGraph::Compositor& c) // Choice and sequence. { - UnsignedLong min (c.context ().get<UnsignedLong> ("effective-min")); + size_t min (c.context ().get<size_t> ("effective-min")); os << "v_state_& vs = *static_cast< v_state_* > (" << "this->v_state_stack_.top ());" @@ -1343,7 +1359,6 @@ namespace CXX } private: - SemanticGraph::Complex& type_; ParticleName particle_name_; }; @@ -1357,7 +1372,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { // Nothing to generate if we don't have any elements and wildcards. @@ -1374,7 +1389,7 @@ namespace CXX // Don't use restriction_p here since we don't want special // treatment of anyType. // - Boolean restriction ( + bool restriction ( c.inherits_p () && c.inherits ().is_a<SemanticGraph::Restricts> ()); @@ -1476,7 +1491,7 @@ namespace CXX } { - CompositorEndElement t (*this, c); + CompositorEndElement t (*this); t.dispatch (comp); } @@ -1495,7 +1510,7 @@ namespace CXX << endl; { - CompositorPre t (*this, c); + CompositorPre t (*this); t.dispatch (comp); } @@ -1543,7 +1558,7 @@ namespace CXX } { - CompositorPost t (*this, c); + CompositorPost t (*this); t.dispatch (c.contains_compositor ().compositor ()); } @@ -1559,7 +1574,7 @@ namespace CXX }; } - Void + void generate_element_validation_source (Context& ctx) { ctx.os << "#include <cassert>" << endl @@ -1567,7 +1582,7 @@ namespace CXX Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/element-validation-source.hxx b/xsd/xsd/cxx/parser/element-validation-source.hxx index 544b8f1..b9bd70b 100644 --- a/xsd/xsd/cxx/parser/element-validation-source.hxx +++ b/xsd/xsd/cxx/parser/element-validation-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/element-validation-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_ELEMENT_VALIDATION_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_element_validation_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/elements.cxx b/xsd/xsd/cxx/parser/elements.cxx index b3458c7..889eea4 100644 --- a/xsd/xsd/cxx/parser/elements.cxx +++ b/xsd/xsd/cxx/parser/elements.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/elements.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/elements.hxx> @@ -9,60 +8,16 @@ namespace CXX { namespace Parser { - // Keep this symbol first to help HP-UX linker (long symbols?). - // - Content::Value Context:: - content (SemanticGraph::Complex& c) - { - using namespace SemanticGraph; - - if (c.mixed_p ()) - return Content::mixed; - - if (c.inherits_p ()) - { - Type& base (c.inherits ().base ()); - - if (Complex* cb = dynamic_cast<Complex*> (&base)) - return content (*cb); - - if (base.is_a<AnyType> ()) - return Content::complex; - - // Everyhting else (built-in type and AnySimpleType) is simple - // content. - // - return Content::simple; - } - else - return Content::complex; - } - Context:: Context (std::wostream& o, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& ops, + options_type const& ops, StringLiteralMap const* map, Regex const* he, Regex const* ie, Regex const* hie) - : CXX::Context (o, - root, - path, - map, - ops.value<CLI::char_type> (), - ops.value<CLI::char_encoding> (), - ops.value<CLI::include_with_brackets> (), - ops.value<CLI::include_prefix> (), - ops.value<CLI::export_symbol> (), - ops.value<CLI::namespace_map> (), - ops.value<CLI::namespace_regex> (), - ops.value<CLI::namespace_regex_trace> (), - ops.value<CLI::include_regex> (), - ops.value<CLI::include_regex_trace> (), - ops.value<CLI::generate_inline> (), - ops.value<CLI::reserved_name> ()), + : CXX::Context (o, root, path, ops, map), options (ops), xml_parser (xml_parser_), simple_base (simple_base_), @@ -77,11 +32,11 @@ namespace CXX hxx_expr (he), ixx_expr (ie), hxx_impl_expr (hie), - xml_parser_ (ops.value<CLI::xml_parser> ()), - validation_ ((ops.value<CLI::xml_parser> () == "expat" || - ops.value<CLI::generate_validation> ()) && - !ops.value<CLI::suppress_validation> ()), - polymorphic_ (ops.value<CLI::generate_polymorphic> ()) + xml_parser_ (ops.xml_parser ()), + validation_ ((ops.xml_parser () == "expat" || + ops.generate_validation ()) && + !ops.suppress_validation ()), + polymorphic_ (ops.generate_polymorphic ()) { if (char_type == L"char") std_string_type = L"::std::string"; @@ -144,7 +99,34 @@ namespace CXX { } - Boolean Context:: + Content::Value Context:: + content (SemanticGraph::Complex& c) + { + using namespace SemanticGraph; + + if (c.mixed_p ()) + return Content::mixed; + + if (c.inherits_p ()) + { + Type& base (c.inherits ().base ()); + + if (Complex* cb = dynamic_cast<Complex*> (&base)) + return content (*cb); + + if (base.is_a<AnyType> ()) + return Content::complex; + + // Everyhting else (built-in type and AnySimpleType) is simple + // content. + // + return Content::simple; + } + else + return Content::complex; + } + + bool Context:: anonymous (SemanticGraph::Type& t) { return t.context ().count ("anonymous"); @@ -181,12 +163,6 @@ namespace CXX } String const& Context:: - emember_cache (SemanticGraph::Member& m) - { - return m.context ().get<String> ("member-cache"); - } - - String const& Context:: emember_map (SemanticGraph::Member& m) { return m.context ().get<String> ("member-map"); @@ -200,20 +176,20 @@ namespace CXX // Includes // - Void TypeForward:: + void TypeForward:: traverse (SemanticGraph::Type& t) { os << "class " << t.context ().get<String> (name_key_) << ";"; } - Void Includes:: + void Includes:: traverse_ (SemanticGraph::Uses& u) { // Support for weak (forward) inclusion used in the file-per-type // compilation model. // SemanticGraph::Schema& s (u.schema ()); - Boolean weak (u.context ().count ("weak")); + bool weak (u.context ().count ("weak")); if (weak && (type_ == header || type_ == impl_header)) { @@ -233,6 +209,7 @@ namespace CXX s.context ().count ("renamed") ? s.context ().get<SemanticGraph::Path> ("renamed") : u.path ()); + path.normalize (); // Try to use the portable representation of the path. If that // fails, fall back to the native representation. @@ -240,15 +217,11 @@ namespace CXX NarrowString path_str; try { - path_str = path.string (); + path_str = path.posix_string (); } catch (SemanticGraph::InvalidPath const&) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - path_str = path.native_file_string (); -#else path_str = path.string (); -#endif } String inc_path; @@ -258,12 +231,12 @@ namespace CXX case header: case source: { - inc_path = ctx_.hxx_expr->merge (path_str); + inc_path = ctx_.hxx_expr->replace (path_str); break; } case impl_header: { - inc_path = ctx_.hxx_impl_expr->merge (path_str); + inc_path = ctx_.hxx_impl_expr->replace (path_str); break; } } diff --git a/xsd/xsd/cxx/parser/elements.hxx b/xsd/xsd/cxx/parser/elements.hxx index ee5ca86..31f5d87 100644 --- a/xsd/xsd/cxx/parser/elements.hxx +++ b/xsd/xsd/cxx/parser/elements.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/elements.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_ELEMENTS_HXX @@ -8,11 +7,13 @@ #include <sstream> -#include <backend-elements/regex.hxx> +#include <cutl/re.hxx> + +#include <types.hxx> #include <cxx/elements.hxx> -#include <cxx/parser/cli.hxx> +#include <cxx/parser/options.hxx> namespace CXX { @@ -33,13 +34,15 @@ namespace CXX class Context: public CXX::Context { public: - typedef BackendElements::Regex::Expression<Char> Regex; + typedef cutl::re::regexsub Regex; + + typedef Parser::options options_type; public: Context (std::wostream&, SemanticGraph::Schema&, SemanticGraph::Path const& path, - CLI::Options const&, + options_type const&, StringLiteralMap const*, Regex const* hxx_expr, Regex const* ixx_expr, @@ -50,7 +53,7 @@ namespace CXX Context (Context& c, std::wostream& o); public: - Boolean + bool restriction_p (SemanticGraph::Complex& c) const { if (c.inherits_p () && @@ -69,7 +72,7 @@ namespace CXX content (SemanticGraph::Complex&); public: - static Boolean + static bool anonymous (SemanticGraph::Type&); public: @@ -90,9 +93,6 @@ namespace CXX emember (SemanticGraph::Member&); static String const& - emember_cache (SemanticGraph::Member&); - - static String const& emember_map (SemanticGraph::Member&); public: @@ -100,7 +100,7 @@ namespace CXX eimpl (SemanticGraph::Type&); public: - CLI::Options const& options; + options_type const& options; String& xml_parser; String& simple_base; String& complex_base; @@ -109,8 +109,8 @@ namespace CXX String& cerr_inst; String& parser_map; String& std_string_type; - Boolean& validation; - Boolean& polymorphic; + bool& validation; + bool& polymorphic; Regex const* hxx_expr; Regex const* ixx_expr; @@ -125,20 +125,20 @@ namespace CXX String cerr_inst_; String parser_map_; String std_string_type_; - Boolean validation_; - Boolean polymorphic_; + bool validation_; + bool polymorphic_; }; // // struct RequiredAttributeTest: Traversal::Attribute { - RequiredAttributeTest (Boolean& result) + RequiredAttributeTest (bool& result) : result_ (result) { } - virtual Void + virtual void traverse (Type& a) { if (!result_ && !a.optional_p ()) @@ -146,7 +146,7 @@ namespace CXX } private: - Boolean& result_; + bool& result_; }; // @@ -156,14 +156,14 @@ namespace CXX Traversal::Member, Context { - ParserParamDecl (Context& c, Boolean name_arg) + ParserParamDecl (Context& c, bool name_arg) : Context (c), first_ (true), name_arg_ (name_arg) { inherits_ >> *this; names_ >> *this; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -172,7 +172,7 @@ namespace CXX names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { if (!first_) @@ -188,7 +188,7 @@ namespace CXX os << " /* " << comment (l.name ()) << " item */"; } - virtual Void + virtual void traverse (SemanticGraph::Member& m) { if (skip (m)) return; @@ -210,8 +210,8 @@ namespace CXX Traversal::Inherits inherits_; Traversal::Names names_; - Boolean first_; - Boolean name_arg_; + bool first_; + bool name_arg_; }; @@ -219,16 +219,16 @@ namespace CXX // struct TypeForward: Traversal::Type, Context { - TypeForward (Context& c, Char const* name_key) + TypeForward (Context& c, char const* name_key) : Context (c), name_key_ (name_key) { } - virtual Void + virtual void traverse (SemanticGraph::Type& t); private: - Char const* name_key_; + char const* name_key_; }; struct Includes: Traversal::Imports, @@ -250,20 +250,20 @@ namespace CXX schema_ >> schema_names_ >> namespace_ >> names_ >> type_forward_; } - virtual Void + virtual void traverse (SemanticGraph::Imports& i) { traverse_ (i); } - virtual Void + virtual void traverse (SemanticGraph::Includes& i) { traverse_ (i); } private: - Void + void traverse_ (SemanticGraph::Uses&); private: @@ -281,21 +281,23 @@ namespace CXX // struct RootElement: Traversal::Element { - RootElement (CLI::Options const& options, + typedef Parser::options options_type; + + RootElement (options_type const& options, SemanticGraph::Element*& element) : options_ (options), element_ (element) { } - virtual Void + virtual void traverse (Type& e) { - if (options_.value<CLI::root_element_first> ()) + if (options_.root_element_first ()) { if (element_ == 0) element_ = &e; } - else if (String name = options_.value<CLI::root_element> ()) + else if (String name = options_.root_element ()) { if (e.name () == name) element_ = &e; @@ -305,7 +307,7 @@ namespace CXX } private: - CLI::Options const& options_; + options_type const& options_; SemanticGraph::Element*& element_; }; } diff --git a/xsd/xsd/cxx/parser/generator.cxx b/xsd/xsd/cxx/parser/generator.cxx index b3aee76..e17986b 100644 --- a/xsd/xsd/cxx/parser/generator.cxx +++ b/xsd/xsd/cxx/parser/generator.cxx @@ -1,8 +1,19 @@ // file : xsd/cxx/parser/generator.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <algorithm> +#include <iostream> +#include <fstream> + +#include <cutl/re.hxx> + +#include <cutl/compiler/code-stream.hxx> +#include <cutl/compiler/cxx-indenter.hxx> +#include <cutl/compiler/sloc-counter.hxx> + +#include <xsd-frontend/semantic-graph.hxx> + #include <type-map/lexer.hxx> #include <type-map/parser.hxx> #include <type-map/type-map.hxx> @@ -28,49 +39,28 @@ #include <cxx/parser/attribute-validation-source.hxx> #include <cxx/parser/characters-validation-source.hxx> -#include <xsd-frontend/semantic-graph.hxx> - -#include <backend-elements/regex.hxx> -#include <backend-elements/indentation/cxx.hxx> -#include <backend-elements/indentation/sloc.hxx> -#include <backend-elements/indentation/clip.hxx> - -#include <cult/containers/set.hxx> -#include <cult/containers/vector.hxx> - -#include <boost/filesystem/fstream.hpp> - -#include <iostream> - -#include <usage.hxx> +#include <cxx/parser/options.hxx> #include "../../../libxsd/xsd/cxx/version.hxx" using std::endl; using std::wcerr; +using std::wcout; using namespace XSDFrontend::SemanticGraph; // // -typedef -boost::filesystem::wifstream -WideInputFileStream; - -typedef -boost::filesystem::wofstream -WideOutputFileStream; - -typedef -boost::filesystem::ifstream -NarrowInputFileStream; +typedef std::wifstream WideInputFileStream; +typedef std::wofstream WideOutputFileStream; +typedef std::ifstream NarrowInputFileStream; namespace CXX { namespace { - Char const copyright_gpl[] = - "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n" + char const copyright_gpl[] = + "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n" "//\n" "// This program was generated by CodeSynthesis XSD, an XML Schema to\n" "// C++ data binding compiler.\n" @@ -103,8 +93,8 @@ namespace CXX "// in the accompanying FLOSSE file.\n" "//\n\n"; - Char const copyright_proprietary[] = - "// Copyright (C) 2005-2010 Code Synthesis Tools CC\n" + char const copyright_proprietary[] = + "// Copyright (c) 2005-2014 Code Synthesis Tools CC\n" "//\n" "// This program was generated by CodeSynthesis XSD, an XML Schema\n" "// to C++ data binding compiler, in the Proprietary License mode.\n" @@ -113,7 +103,7 @@ namespace CXX "// conditions.\n" "//\n\n"; - Char const copyright_impl[] = + char const copyright_impl[] = "// Not copyrighted - public domain.\n" "//\n" "// This sample parser implementation was generated by CodeSynthesis XSD,\n" @@ -122,442 +112,24 @@ namespace CXX "//\n\n"; } - namespace Parser - { - namespace CLI - { - extern Key type_map = "type-map"; - extern Key char_type = "char-type"; - extern Key char_encoding = "char-encoding"; - extern Key output_dir = "output-dir"; - extern Key xml_parser = "xml-parser"; - extern Key generate_inline = "generate-inline"; - extern Key generate_validation = "generate-validation"; - extern Key suppress_validation = "suppress-validation"; - extern Key generate_polymorphic = "generate-polymorphic"; - extern Key generate_noop_impl = "generate-noop-impl"; - extern Key generate_print_impl = "generate-print-impl"; - extern Key generate_test_driver = "generate-test-driver"; - extern Key force_overwrite = "force-overwrite"; - extern Key root_element_first = "root-element-first"; - extern Key root_element_last = "root-element-last"; - extern Key root_element = "root-element"; - extern Key generate_xml_schema = "generate-xml-schema"; - extern Key extern_xml_schema = "extern-xml-schema"; - extern Key skel_type_suffix = "skel-type-suffix"; - extern Key skel_file_suffix = "skel-file-suffix"; - extern Key impl_type_suffix = "impl-type-suffix"; - extern Key impl_file_suffix = "impl-file-suffix"; - extern Key namespace_map = "namespace-map"; - extern Key namespace_regex = "namespace-regex"; - extern Key namespace_regex_trace = "namespace-regex-trace"; - extern Key reserved_name = "reserved-name"; - extern Key include_with_brackets = "include-with-brackets"; - extern Key include_prefix = "include-prefix"; - extern Key include_regex = "include-regex"; - extern Key include_regex_trace = "include-regex-trace"; - extern Key guard_prefix = "guard-prefix"; - extern Key hxx_suffix = "hxx-suffix"; - extern Key ixx_suffix = "ixx-suffix"; - extern Key cxx_suffix = "cxx-suffix"; - extern Key hxx_regex = "hxx-regex"; - extern Key ixx_regex = "ixx-regex"; - extern Key cxx_regex = "cxx-regex"; - extern Key hxx_prologue = "hxx-prologue"; - extern Key ixx_prologue = "ixx-prologue"; - extern Key cxx_prologue = "cxx-prologue"; - extern Key prologue = "prologue"; - extern Key hxx_epilogue = "hxx-epilogue"; - extern Key ixx_epilogue = "ixx-epilogue"; - extern Key cxx_epilogue = "cxx-epilogue"; - extern Key epilogue = "epilogue"; - extern Key hxx_prologue_file = "hxx-prologue-file"; - extern Key ixx_prologue_file = "ixx-prologue-file"; - extern Key cxx_prologue_file = "cxx-prologue-file"; - extern Key prologue_file = "prologue-file"; - extern Key hxx_epilogue_file = "hxx-epilogue-file"; - extern Key ixx_epilogue_file = "ixx-epilogue-file"; - extern Key cxx_epilogue_file = "cxx-epilogue-file"; - extern Key epilogue_file = "epilogue-file"; - extern Key export_symbol = "export-symbol"; - extern Key export_maps = "export-maps"; - extern Key import_maps = "import-maps"; - extern Key show_anonymous = "show-anonymous"; - extern Key show_sloc = "show-sloc"; - extern Key proprietary_license = "proprietary-license"; - } - } - - Void Parser::Generator:: + void Parser::Generator:: usage () { - std::wostream& e (wcerr); - ::CLI::Indent::Clip< ::CLI::OptionsUsage, WideChar> clip (e); - - e << "--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; - - e << "--char-type <type>" << endl - << " Use <type> as the base character type. Valid\n" - << " values are 'char' (default) and 'wchar_t'." - << endl; - - e << "--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; - - e << "--output-dir <dir>" << endl - << " Write generated files to <dir> instead of current\n" - << " directory." - << endl; - - e << "--xml-parser <parser>" << endl - << " Use <parser> as the underlying XML parser. Valid\n" - << " values are 'xerces' (default) and 'expat'." - << endl; - - e << "--generate-inline" << endl - << " Generate certain functions inline." - << endl; - - e << "--generate-validation" << endl - << " Generate validation code." - << endl; - - e << "--suppress-validation" << endl - << " Suppress the generation of validation code." - << endl; - - e << "--generate-polymorphic" << endl - << " Generate polymorphism-aware code. Specify this\n" - << " option if you use substitution groups or xsi:type." - << endl; - - e << "--generate-noop-impl" << endl - << " Generate a sample parser implementation that\n" - << " does nothing (no operation)." - << endl; - - e << "--generate-print-impl" << endl - << " Generate a sample parser implementation that\n" - << " prints the XML data to STDOUT." - << endl; - - e << "--generate-test-driver" << endl - << " Generate a test driver for the sample parser\n" - << " implementation." - << endl; - - e << "--force-overwrite" << endl - << " Force overwriting of the existing implementation\n" - << " and test driver files." - << endl; - - e << "--root-element-first" << endl - << " Indicate that the first global element is the\n" - << " document root." - << endl; - - e << "--root-element-last" << endl - << " Indicate that the last global element is the\n" - << " document root." - << endl; - - e << "--root-element <element>" << endl - << " Indicate that <element> is the document root." - << endl; - - e << "--generate-xml-schema" << endl - << " Generate a C++ header file as if the schema being\n" - << " compiled defines the XML Schema namespace." - << endl; - - e << "--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; - - e << "--skel-type-suffix <suffix>" << endl - << " Use <suffix> instead of the default '_pskel' to\n" - << " construct the names of generated parser skeletons." - << endl; - - e << "--skel-file-suffix <suffix>" << endl - << " Use <suffix> instead of the default '-pskel' to\n" - << " construct the names of generated parser skeleton\n" - << " files." - << endl; - - e << "--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; - - e << "--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; - - e << "--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; - - e << "--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; - - e << "--namespace-regex-trace" << endl - << " Trace the process of applying regular expressions\n" - << " specified with the --namespace-regex option." - << endl; - - e << "--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; - - e << "--include-with-brackets" << endl - << " Use angle brackets (<>) instead of quotes (\"\") in\n" - << " generated #include directives." - << endl; - - e << "--include-prefix <prefix>" << endl - << " Add <prefix> to generated #include directive\n" - << " paths." - << endl; - - e << "--include-regex <regex>" << endl - << " Add <regex> to the list of regular expressions\n" - << " used to transform #include directive paths." - << endl; - - e << "--include-regex-trace" << endl - << " Trace the process of applying regular expressions\n" - << " specified with the --include-regex option." - << endl; - - e << "--guard-prefix <prefix>" << endl - << " Add <prefix> to generated header inclusion guards." - << endl; - - e << "--hxx-suffix <suffix>" << endl - << " Use <suffix> instead of the default '.hxx' to\n" - << " construct the name of the header file." - << endl; - - e << "--ixx-suffix <suffix>" << endl - << " Use <suffix> instead of the default '.ixx' to\n" - << " construct the name of the inline file." - << endl; - - e << "--cxx-suffix <suffix>" << endl - << " Use <suffix> instead of the default '.cxx' to\n" - << " construct the name of the source file." - << endl; - - e << "--hxx-regex <regex>" << endl - << " Use <regex> to construct the name of the header\n" - << " file." - << endl; - - e << "--ixx-regex <regex>" << endl - << " Use <regex> to construct the name of the inline\n" - << " file." - << endl; - - e << "--cxx-regex <regex>" << endl - << " Use <regex> to construct the name of the source\n" - << " file." - << endl; - - - // Prologues. - // - e << "--hxx-prologue <text>" << endl - << " Insert <text> at the beginning of the header file." - << endl; - - e << "--ixx-prologue <text>" << endl - << " Insert <text> at the beginning of the inline file." - << endl; - - e << "--cxx-prologue <text>" << endl - << " Insert <text> at the beginning of the source file." - << endl; - - e << "--prologue <text>" << endl - << " Insert <text> at the beginning of each generated\n" - << " file for which there is no file-specific prologue." - << endl; - - - // Epilogues. - // - e << "--hxx-epilogue <text>" << endl - << " Insert <text> at the end of the header file." - << endl; - - e << "--ixx-epilogue <text>" << endl - << " Insert <text> at the end of the inline file." - << endl; - - e << "--cxx-epilogue <text>" << endl - << " Insert <text> at the end of the source file." - << endl; - - e << "--epilogue <text>" << endl - << " Insert <text> at the end of each generated file\n" - << " for which there is no file-specific epilogue." - << endl; - - - // Prologue files. - // - e << "--hxx-prologue-file <file>" << endl - << " Insert the content of the <file> at the beginning\n" - << " of the header file." - << endl; - - e << "--ixx-prologue-file <file>" << endl - << " Insert the content of the <file> at the beginning\n" - << " of the inline file." - << endl; - - e << "--cxx-prologue-file <file>" << endl - << " Insert the content of the <file> at the beginning\n" - << " of the source file." - << endl; - - e << "--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. - // - e << "--hxx-epilogue-file <file>" << endl - << " Insert the content of the <file> at the end of\n" - << " the header file." - << endl; - - e << "--ixx-epilogue-file <file>" << endl - << " Insert the content of the <file> at the end of\n" - << " the inline file." - << endl; - - e << "--cxx-epilogue-file <file>" << endl - << " Insert the content of the <file> at the end of\n" - << " the source file." - << endl; - - e << "--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. - // - e << "--custom-literals <file>" << endl - << " Load custom XML string to C++ literal mappings\n" - << " from <file>." - << endl; - - e << "--export-symbol <symbol>" << endl - << " Export symbol for Win32 DLL export/import control." - << endl; - - e << "--export-maps" << endl - << " Export polymorphism support maps from Win32 DLL." - << endl; - - e << "--import-maps" << endl - << " Import polymorphism support maps from Win32 DLL." - << endl; - - e << "--show-anonymous" << endl - << " Show elements and attributes that are of anonymous\n" - << " types." - << endl; - - e << "--show-sloc" << endl - << " Show the number of generated physical source lines\n" - << " of code (SLOC)." - << endl; - - e << "--sloc-limit <num>" << endl - << " Check that the number of generated physical source\n" - << " lines of code (SLOC) does not exceed <num>." - << endl; - - e << "--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; - - e << "--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:: - options_spec () - { - CLI::OptionsSpec spec; - - spec.option<CLI::char_type> ().default_value ("char"); - spec.option<CLI::xml_parser> ().default_value ("xerces"); - - spec.option<CLI::skel_file_suffix> ().default_value ("-pskel"); - spec.option<CLI::skel_type_suffix> ().default_value ("_pskel"); - spec.option<CLI::impl_file_suffix> ().default_value ("-pimpl"); - spec.option<CLI::impl_type_suffix> ().default_value ("_pimpl"); - - spec.option<CLI::hxx_suffix> ().default_value (".hxx"); - spec.option<CLI::ixx_suffix> ().default_value (".ixx"); - spec.option<CLI::cxx_suffix> ().default_value (".cxx"); - - return spec; - } - - namespace { template <typename S> - Void + void open (S& ifs, NarrowString const& path) { try { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - Path fs_path (path, boost::filesystem::native); -#else - Path fs_path (path.c_str()); -#endif - ifs.open (fs_path, std::ios_base::in | std::ios_base::binary); + Path fs_path (path); + ifs.open (fs_path.string ().c_str (), + std::ios_base::in | std::ios_base::binary); if (!ifs.is_open ()) { @@ -576,7 +148,7 @@ namespace CXX } } - Void + void append (WideOutputFileStream& os, NarrowString const& path, WideInputFileStream& default_is) @@ -596,16 +168,15 @@ namespace CXX } } - Void + void append (WideOutputFileStream& os, - Cult::Containers::Vector<NarrowString> const& primary, - Cult::Containers::Vector<NarrowString> const& def) + NarrowStrings const& primary, + NarrowStrings const& def) { - Cult::Containers::Vector<NarrowString> const& v ( - primary.empty () ? def : primary); + NarrowStrings const& v (primary.empty () ? def : primary); - for (Containers::Vector<NarrowString>::ConstIterator - i (v.begin ()), e (v.end ()); i != e; ++i) + for (NarrowStrings::const_iterator i (v.begin ()), e (v.end ()); + i != e; ++i) { os << i->c_str () << endl; } @@ -613,25 +184,24 @@ namespace CXX } - UnsignedLong Parser::Generator:: - generate (Parser::CLI::Options const& ops, + size_t Parser::Generator:: + generate (Parser::options const& ops, Schema& schema, Path const& file_path, - Boolean fpt, + bool fpt, StringLiteralMap const& string_literal_map, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings, FileList& file_list, AutoUnlinks& unlinks) { using std::ios_base; - namespace Indentation = BackendElements::Indentation; - typedef BackendElements::Regex::Expression<Char> Regex; + typedef cutl::re::regexsub Regex; try { - Boolean generate_xml_schema (ops.value<CLI::generate_xml_schema> ()); + bool generate_xml_schema (ops.generate_xml_schema ()); // We could be compiling several schemas at once in which case // handling of the --generate-xml-schema option gets tricky: we @@ -640,23 +210,19 @@ namespace CXX // if (generate_xml_schema) { - if (NarrowString name = ops.value<CLI::extern_xml_schema> ()) + if (NarrowString name = ops.extern_xml_schema ()) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - if (file_path.native_file_string () != name) -#else if (file_path.string () != name) -#endif generate_xml_schema = false; } } - Boolean impl (!generate_xml_schema && - (ops.value<CLI::generate_noop_impl> () || - ops.value<CLI::generate_print_impl> ())); + bool impl (!generate_xml_schema && + (ops.generate_noop_impl () || + ops.generate_print_impl ())); - Boolean driver (gen_driver && !generate_xml_schema && - ops.value<CLI::generate_test_driver> ()); + bool driver (gen_driver && !generate_xml_schema && + ops.generate_test_driver ()); // Evaluate the graph for possibility of generating something useful. // @@ -674,9 +240,9 @@ namespace CXX proc.process (ops, schema, file_path, string_literal_map); } - Boolean validation ((ops.value<CLI::xml_parser> () == "expat" || - ops.value<CLI::generate_validation> ()) && - !ops.value<CLI::suppress_validation> ()); + bool validation ((ops.xml_parser () == "expat" || + ops.generate_validation ()) && + !ops.suppress_validation ()); // Compute state machine info. // @@ -691,11 +257,11 @@ namespace CXX TypeMap::Namespaces type_map; { using namespace TypeMap; - typedef Containers::Vector<NarrowString> Files; - Files const& files (ops.value<CLI::type_map> ()); + NarrowStrings const& files (ops.type_map ()); - for (Files::ConstIterator f (files.begin ()); f != files.end (); ++f ) + for (NarrowStrings::const_iterator f (files.begin ()); + f != files.end (); ++f ) { NarrowInputFileStream ifs; open (ifs, *f); @@ -712,7 +278,7 @@ namespace CXX // String-based types. // - String char_type (ops.value<CLI::char_type> ()); + String char_type (ops.char_type ()); String string_type; if (char_type == L"char") @@ -723,12 +289,14 @@ namespace CXX string_type = L"::std::basic_string< " + char_type + L" >"; String xns; + String auto_ptr; { Context ctx (std::wcerr, schema, file_path, ops, 0, 0, 0, 0); xns = ctx.xs_ns_name (); + auto_ptr = ctx.auto_ptr; } - String buffer (L"::std::auto_ptr< " + xns + L"::buffer >"); + String buffer (auto_ptr + L"< " + xns + L"::buffer >"); TypeMap::Namespace xsd ("http://www\\.w3\\.org/2001/XMLSchema"); xsd.types_push_back ("string", string_type); @@ -800,7 +368,7 @@ namespace CXX type_map.push_back (xsd); - // Everyhting else maps to void. + // Everything else maps to void. // TypeMap::Namespace rest (".*"); rest.types_push_back (".*", "void", "void"); @@ -816,39 +384,33 @@ namespace CXX // // - Boolean inline_ (ops.value<CLI::generate_inline> () && - !generate_xml_schema); - - Boolean source (!generate_xml_schema); + bool inline_ (ops.generate_inline () && !generate_xml_schema); + bool source (!generate_xml_schema); // Generate code. // -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - NarrowString name (file_path.leaf ()); -#else - NarrowString name (file_path.filename().string()); -#endif - NarrowString skel_suffix (ops.value <CLI::skel_file_suffix> ()); - NarrowString impl_suffix (ops.value <CLI::impl_file_suffix> ()); - - NarrowString hxx_suffix (ops.value <CLI::hxx_suffix> ()); - NarrowString ixx_suffix (ops.value <CLI::ixx_suffix> ()); - NarrowString cxx_suffix (ops.value <CLI::cxx_suffix> ()); + NarrowString name (file_path.leaf ().string ()); + NarrowString skel_suffix (ops.skel_file_suffix ()); + NarrowString impl_suffix (ops.impl_file_suffix ()); + + NarrowString hxx_suffix (ops.hxx_suffix ()); + NarrowString ixx_suffix (ops.ixx_suffix ()); + NarrowString cxx_suffix (ops.cxx_suffix ()); Regex hxx_expr ( - ops.value <CLI::hxx_regex> ().empty () + ops.hxx_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + hxx_suffix + "#" - : ops.value <CLI::hxx_regex> ()); + : ops.hxx_regex ()); Regex ixx_expr ( - ops.value <CLI::ixx_regex> ().empty () + ops.ixx_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + ixx_suffix + "#" - : ops.value <CLI::ixx_regex> ()); + : ops.ixx_regex ()); Regex cxx_expr ( - ops.value <CLI::cxx_regex> ().empty () + ops.cxx_regex ().empty () ? "#^(.+?)(\\.[^./\\\\]+)?$#$1" + skel_suffix + cxx_suffix + "#" - : ops.value <CLI::cxx_regex> ()); + : ops.cxx_regex ()); Regex hxx_impl_expr; @@ -870,7 +432,7 @@ namespace CXX if (!hxx_expr.match (name)) { wcerr << "error: header expression '" << - hxx_expr.pattern () << "' does not match '" << + hxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -878,7 +440,7 @@ namespace CXX if (inline_ && !ixx_expr.match (name)) { wcerr << "error: inline expression '" << - ixx_expr.pattern () << "' does not match '" << + ixx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -886,7 +448,7 @@ namespace CXX if (source && !cxx_expr.match (name)) { wcerr << "error: source expression '" << - cxx_expr.pattern () << "' does not match '" << + cxx_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -896,7 +458,7 @@ namespace CXX if (!hxx_impl_expr.match (name)) { wcerr << "error: implementation header expression '" << - hxx_impl_expr.pattern () << "' does not match '" << + hxx_impl_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -904,7 +466,7 @@ namespace CXX if (!cxx_impl_expr.match (name)) { wcerr << "error: implementation source expression '" << - cxx_impl_expr.pattern () << "' does not match '" << + cxx_impl_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } @@ -912,15 +474,15 @@ namespace CXX if (!cxx_driver_expr.match (name)) { wcerr << "error: driver source expression '" << - cxx_driver_expr.pattern () << "' does not match '" << + cxx_driver_expr.regex ().str ().c_str () << "' does not match '" << name.c_str () << "'" << endl; throw Failed (); } } - NarrowString hxx_name (hxx_expr.merge (name)); - NarrowString ixx_name (inline_ ? ixx_expr.merge (name) : NarrowString ()); - NarrowString cxx_name (source ? cxx_expr.merge (name) : NarrowString ()); + NarrowString hxx_name (hxx_expr.replace (name)); + NarrowString ixx_name (inline_ ? ixx_expr.replace (name) : NarrowString ()); + NarrowString cxx_name (source ? cxx_expr.replace (name) : NarrowString ()); NarrowString hxx_impl_name; NarrowString cxx_impl_name; @@ -928,20 +490,14 @@ namespace CXX if (impl || driver) { - hxx_impl_name = hxx_impl_expr.merge (name); - cxx_impl_name = cxx_impl_expr.merge (name); - cxx_driver_name = cxx_driver_expr.merge (name); + hxx_impl_name = hxx_impl_expr.replace (name); + cxx_impl_name = cxx_impl_expr.replace (name); + cxx_driver_name = cxx_driver_expr.replace (name); } -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - Path hxx_path (hxx_name, boost::filesystem::native); - Path ixx_path (ixx_name, boost::filesystem::native); - Path cxx_path (cxx_name, boost::filesystem::native); -#else - Path hxx_path (hxx_name.c_str()); - Path ixx_path (ixx_name.c_str()); - Path cxx_path (cxx_name.c_str()); -#endif + Path hxx_path (hxx_name); + Path ixx_path (ixx_name); + Path cxx_path (cxx_name); Path hxx_impl_path; Path cxx_impl_path; @@ -949,28 +505,18 @@ namespace CXX if (impl || driver) { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - hxx_impl_path = Path (hxx_impl_name, boost::filesystem::native); - cxx_impl_path = Path (cxx_impl_name, boost::filesystem::native); - cxx_driver_path = Path (cxx_driver_name, boost::filesystem::native); -#else - hxx_impl_path = Path (hxx_impl_name.c_str()); - cxx_impl_path = Path (cxx_impl_name.c_str()); - cxx_driver_path = Path (cxx_driver_name.c_str()); -#endif + hxx_impl_path = Path (hxx_impl_name); + cxx_impl_path = Path (cxx_impl_name); + cxx_driver_path = Path (cxx_driver_name); } Path out_dir; - if (NarrowString dir = ops.value<CLI::output_dir> ()) + if (NarrowString dir = ops.output_dir ()) { try { -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - out_dir = Path (dir, boost::filesystem::native); -#else - out_dir = Path (dir.c_str()); -#endif + out_dir = Path (dir); } catch (InvalidPath const&) { @@ -985,7 +531,7 @@ namespace CXX // unless the user added the directory so that we propagate this // to the output files. // - Path fpt_dir (file_path.branch_path ()); + Path fpt_dir (file_path.directory ()); if (!fpt_dir.empty ()) out_dir /= fpt_dir; @@ -1014,9 +560,10 @@ namespace CXX if (impl) { - if (!ops.value<CLI::force_overwrite> ()) + if (!ops.force_overwrite ()) { - WideInputFileStream tmp (hxx_impl_path, ios_base::in); + WideInputFileStream tmp ( + hxx_impl_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -1028,7 +575,7 @@ namespace CXX tmp.close (); } - hxx_impl.open (hxx_impl_path, ios_base::out); + hxx_impl.open (hxx_impl_path.string ().c_str (), ios_base::out); if (!hxx_impl.is_open ()) { @@ -1038,15 +585,12 @@ namespace CXX } unlinks.add (hxx_impl_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (hxx_impl_path.native_file_string ()); -#else file_list.push_back (hxx_impl_path.string ()); -#endif - if (!ops.value<CLI::force_overwrite> ()) + if (!ops.force_overwrite ()) { - WideInputFileStream tmp (cxx_impl_path, ios_base::in); + WideInputFileStream tmp ( + cxx_impl_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -1058,7 +602,7 @@ namespace CXX tmp.close (); } - cxx_impl.open (cxx_impl_path, ios_base::out); + cxx_impl.open (cxx_impl_path.string ().c_str (), ios_base::out); if (!cxx_impl.is_open ()) { @@ -1068,18 +612,15 @@ namespace CXX } unlinks.add (cxx_impl_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (cxx_impl_path.native_file_string ()); -#else file_list.push_back (cxx_impl_path.string ()); -#endif } if (driver) { - if (!ops.value<CLI::force_overwrite> ()) + if (!ops.force_overwrite ()) { - WideInputFileStream tmp (cxx_driver_path, ios_base::in); + WideInputFileStream tmp ( + cxx_driver_path.string ().c_str (), ios_base::in); if (tmp.is_open ()) { @@ -1091,7 +632,7 @@ namespace CXX tmp.close (); } - cxx_driver.open (cxx_driver_path, ios_base::out); + cxx_driver.open (cxx_driver_path.string ().c_str (), ios_base::out); if (!cxx_driver.is_open ()) { @@ -1101,16 +642,12 @@ namespace CXX } unlinks.add (cxx_driver_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (cxx_driver_path.native_file_string ()); -#else file_list.push_back (cxx_driver_path.string ()); -#endif } // Open the skel files. // - WideOutputFileStream hxx (hxx_path, ios_base::out); + WideOutputFileStream hxx (hxx_path.string ().c_str (), ios_base::out); WideOutputFileStream ixx; WideOutputFileStream cxx; @@ -1121,15 +658,11 @@ namespace CXX } unlinks.add (hxx_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (hxx_path.native_file_string ()); -#else file_list.push_back (hxx_path.string ()); -#endif if (inline_) { - ixx.open (ixx_path, ios_base::out); + ixx.open (ixx_path.string ().c_str (), ios_base::out); if (!ixx.is_open ()) { @@ -1138,17 +671,13 @@ namespace CXX } unlinks.add (ixx_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (ixx_path.native_file_string ()); -#else file_list.push_back (ixx_path.string ()); -#endif } if (source) { - cxx.open (cxx_path, ios_base::out); + cxx.open (cxx_path.string ().c_str (), ios_base::out); if (!cxx.is_open ()) { @@ -1157,19 +686,13 @@ namespace CXX } unlinks.add (cxx_path); -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - file_list.push_back (cxx_path.native_file_string ()); -#else file_list.push_back (cxx_path.string ()); -#endif } // Print copyright and license. // - Char const* copyright ( - ops.value<CLI::proprietary_license> () - ? copyright_proprietary - : copyright_gpl); + char const* copyright ( + ops.proprietary_license () ? copyright_proprietary : copyright_gpl); hxx << copyright; @@ -1192,7 +715,7 @@ namespace CXX // WideInputFileStream prologue; { - NarrowString name (ops.value<CLI::prologue_file> ()); + NarrowString name (ops.prologue_file ()); if (name) open (prologue, name); @@ -1202,7 +725,7 @@ namespace CXX // WideInputFileStream epilogue; { - NarrowString name (ops.value<CLI::epilogue_file> ()); + NarrowString name (ops.epilogue_file ()); if (name) open (epilogue, name); @@ -1210,21 +733,25 @@ namespace CXX // SLOC counter. // - UnsignedLong sloc (0); - Boolean show_sloc (ops.value<CLI::show_sloc> ()); + size_t sloc_total (0); + bool show_sloc (ops.show_sloc ()); + + typedef + compiler::ostream_filter<compiler::cxx_indenter, wchar_t> + ind_filter; + + typedef + compiler::ostream_filter<compiler::sloc_counter, wchar_t> + sloc_filter; // // Regex guard_expr ("/([a-z])([A-Z])/$1_$2/"); // Split words. - NarrowString guard_prefix (ops.value<CLI::guard_prefix> ()); + NarrowString guard_prefix (ops.guard_prefix ()); if (!guard_prefix) -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 - guard_prefix = file_path.branch_path ().native_directory_string (); -#else - guard_prefix = file_path.branch_path ().string (); -#endif + guard_prefix = file_path.directory ().string (); if (guard_prefix) guard_prefix += '_'; @@ -1241,9 +768,9 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip<Indentation::SLOC, WideChar> hxx_sloc (hxx); + sloc_filter sloc (hxx); - String guard (guard_expr.merge (guard_prefix + hxx_name)); + String guard (guard_expr.replace (guard_prefix + hxx_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1251,14 +778,21 @@ namespace CXX << "#define " << guard << endl << endl; + if (ctx.std >= cxx_version::cxx11) + { + hxx << "#ifndef XSD_CXX11" << endl + << "#define XSD_CXX11" << endl + << "#endif" << endl + << endl; + } + // Copy prologue. // hxx << "// Begin prologue." << endl << "//" << endl; - append ( - hxx, ops.value<CLI::hxx_prologue> (), ops.value<CLI::prologue> ()); - append (hxx, ops.value<CLI::hxx_prologue_file> (), prologue); + append (hxx, ops.hxx_prologue (), ops.prologue ()); + append (hxx, ops.hxx_prologue_file (), prologue); hxx << "//" << endl << "// End prologue." << endl @@ -1273,38 +807,33 @@ namespace CXX << "#endif" << endl << endl; - { - hxx << "#include <xsd/cxx/pre.hxx>" << endl - << endl; - - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> hxx_clip (hxx); + hxx << "#include <xsd/cxx/pre.hxx>" << endl + << endl; + // Generate. + // + { + ind_filter ind (hxx); // We don't want to indent prologues/epilogues. - // Generate. - // if (!generate_xml_schema) generate_parser_forward (ctx); generate_parser_header (ctx, generate_xml_schema); + } + if (inline_) + hxx << "#include " << ctx.process_include_path (ixx_name) << endl; - if (inline_) - hxx << "#include " << ctx.process_include_path (ixx_name) << endl; - - hxx << "#include <xsd/cxx/post.hxx>" << endl - << endl; - } + hxx << "#include <xsd/cxx/post.hxx>" << endl + << endl; // Copy epilogue. // hxx << "// Begin epilogue." << endl << "//" << endl; - append (hxx, ops.value<CLI::hxx_epilogue_file> (), epilogue); - append ( - hxx, ops.value<CLI::hxx_epilogue> (), ops.value<CLI::epilogue> ()); + append (hxx, ops.hxx_epilogue_file (), epilogue); + append (hxx, ops.hxx_epilogue (), ops.epilogue ()); hxx << "//" << endl << "// End epilogue." << endl @@ -1313,12 +842,9 @@ namespace CXX hxx << "#endif // " << guard << endl; if (show_sloc) - { - wcerr << hxx_path << ": " - << hxx_sloc.buffer ().count () << endl; + wcerr << hxx_path << ": " << sloc.stream ().count () << endl; - sloc += hxx_sloc.buffer ().count (); - } + sloc_total += sloc.stream ().count (); } @@ -1335,30 +861,24 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip<Indentation::SLOC, WideChar> ixx_sloc (ixx); - + sloc_filter sloc (ixx); // Copy prologue. // ixx << "// Begin prologue." << endl << "//" << endl; - append ( - ixx, ops.value<CLI::ixx_prologue> (), ops.value<CLI::prologue> ()); - append (ixx, ops.value<CLI::ixx_prologue_file> (), prologue); + append (ixx, ops.ixx_prologue (), ops.prologue ()); + append (ixx, ops.ixx_prologue_file (), prologue); ixx << "//" << endl << "// End prologue." << endl << endl; + // Generate. + // { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> ixx_clip (ixx); - - - // Generate. - // + ind_filter ind (ixx); // We don't want to indent prologues/epilogues. generate_parser_inline (ctx); } @@ -1367,21 +887,17 @@ namespace CXX ixx << "// Begin epilogue." << endl << "//" << endl; - append (ixx, ops.value<CLI::ixx_epilogue_file> (), epilogue); - append ( - ixx, ops.value<CLI::ixx_epilogue> (), ops.value<CLI::epilogue> ()); + append (ixx, ops.ixx_epilogue_file (), epilogue); + append (ixx, ops.ixx_epilogue (), ops.epilogue ()); ixx << "//" << endl << "// End epilogue." << endl << endl; if (show_sloc) - { - wcerr << ixx_path << ": " - << ixx_sloc.buffer ().count () << endl; + wcerr << ixx_path << ": " << sloc.stream ().count () << endl; - sloc += ixx_sloc.buffer ().count (); - } + sloc_total += sloc.stream ().count (); } @@ -1398,28 +914,30 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - Indentation::Clip<Indentation::SLOC, WideChar> cxx_sloc (cxx); + sloc_filter sloc (cxx); // Copy prologue. // cxx << "// Begin prologue." << endl << "//" << endl; - append ( - cxx, ops.value<CLI::cxx_prologue> (), ops.value<CLI::prologue> ()); - append (cxx, ops.value<CLI::cxx_prologue_file> (), prologue); + append (cxx, ops.cxx_prologue (), ops.prologue ()); + append (cxx, ops.cxx_prologue_file (), prologue); cxx << "//" << endl << "// End prologue." << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> cxx_clip (cxx); + cxx << "#include <xsd/cxx/pre.hxx>" << endl + << endl; - cxx << "#include " << ctx.process_include_path (hxx_name) << endl - << endl; + cxx << "#include " << ctx.process_include_path (hxx_name) << endl + << endl; + + // Generate. + // + { + ind_filter ind (cxx); // We don't want to indent prologues/epilogues. if (!inline_) generate_parser_inline (ctx); @@ -1434,26 +952,25 @@ namespace CXX } } + cxx << "#include <xsd/cxx/post.hxx>" << endl + << endl; + // Copy epilogue. // cxx << "// Begin epilogue." << endl << "//" << endl; - append (cxx, ops.value<CLI::cxx_epilogue_file> (), epilogue); - append ( - cxx, ops.value<CLI::cxx_epilogue> (), ops.value<CLI::epilogue> ()); + append (cxx, ops.cxx_epilogue_file (), epilogue); + append (cxx, ops.cxx_epilogue (), ops.epilogue ()); cxx << "//" << endl << "// End epilogue." << endl << endl; if (show_sloc) - { - wcerr << cxx_path << ": " - << cxx_sloc.buffer ().count () << endl; + wcerr << cxx_path << ": " << sloc.stream ().count () << endl; - sloc += cxx_sloc.buffer ().count (); - } + sloc_total += sloc.stream ().count (); } // HXX impl @@ -1469,7 +986,7 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - String guard (guard_expr.merge (guard_prefix + hxx_impl_name)); + String guard (guard_expr.replace (guard_prefix + hxx_impl_name)); guard = ctx.escape (guard); // Make it a C++ id. std::transform (guard.begin (), guard.end(), guard.begin (), upcase); @@ -1477,14 +994,11 @@ namespace CXX << "#define " << guard << endl << endl; - { - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> clip (hxx_impl); - - hxx_impl << "#include " << ctx.process_include_path (hxx_name) - << endl << endl; + hxx_impl << "#include " << ctx.process_include_path (hxx_name) + << endl << endl; + { + ind_filter ind (hxx_impl); generate_impl_header (ctx); } @@ -1504,14 +1018,13 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> clip (cxx_impl); - cxx_impl << "#include " << ctx.process_include_path (hxx_impl_name) << endl << endl; - generate_impl_source (ctx); + { + ind_filter ind (cxx_impl); + generate_impl_source (ctx); + } } // CXX driver @@ -1527,17 +1040,16 @@ namespace CXX &ixx_expr, &hxx_impl_expr); - // Set auto-indentation. - // - Indentation::Clip<Indentation::CXX, WideChar> clip (cxx_driver); - cxx_driver << "#include " << ctx.process_include_path (hxx_impl_name) << endl << endl; - generate_driver_source (ctx); + { + ind_filter ind (cxx_driver); + generate_driver_source (ctx); + } } - return sloc; + return sloc_total; } catch (UnrepresentableCharacter const& e) { @@ -1569,18 +1081,18 @@ namespace CXX throw Failed (); } - catch (BackendElements::Regex::Format<Char> const& e) + catch (cutl::re::format const& e) { wcerr << "error: invalid regex: '" << - e.expression ().c_str () << "': " << + e.regex ().c_str () << "': " << e.description ().c_str () << endl; throw Failed (); } - catch (BackendElements::Regex::Format<WideChar> const& e) + catch (cutl::re::wformat const& e) { wcerr << "error: invalid regex: '" << - e.expression () << "': " << e.description () << endl; + e.regex () << "': " << e.description ().c_str () << endl; throw Failed (); } diff --git a/xsd/xsd/cxx/parser/generator.hxx b/xsd/xsd/cxx/parser/generator.hxx index eaa1ecd..784ca9d 100644 --- a/xsd/xsd/cxx/parser/generator.hxx +++ b/xsd/xsd/cxx/parser/generator.hxx @@ -1,50 +1,38 @@ // file : xsd/cxx/parser/generator.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_GENERATOR_HXX #define CXX_PARSER_GENERATOR_HXX -#include <cult/types.hxx> - -#include <cult/containers/vector.hxx> - -#include <cult/cli/options.hxx> -#include <cult/cli/options-spec.hxx> - #include <xsd-frontend/semantic-graph/elements.hxx> // Path #include <xsd-frontend/semantic-graph/schema.hxx> #include <xsd.hxx> +#include <types.hxx> #include <cxx/literal-map.hxx> -#include <cxx/parser/cli.hxx> +#include <cxx/parser/options.hxx> namespace CXX { namespace Parser { - using namespace Cult::Types; - class Generator { public: - static Void + static void usage (); - static CLI::OptionsSpec - options_spec (); - struct Failed {}; - static UnsignedLong - generate (CLI::Options const& options, + static size_t + generate (options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, - Boolean file_per_type, + bool file_per_type, StringLiteralMap const&, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings, FileList& file_list, AutoUnlinks& unlinks); diff --git a/xsd/xsd/cxx/parser/impl-header.cxx b/xsd/xsd/cxx/parser/impl-header.cxx index ff635f1..a3d47a4 100644 --- a/xsd/xsd/cxx/parser/impl-header.cxx +++ b/xsd/xsd/cxx/parser/impl-header.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-header.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/impl-header.hxx> @@ -21,7 +20,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (eimpl (e)); @@ -51,7 +50,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (eimpl (l)); @@ -98,7 +97,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (eimpl (u)); @@ -130,7 +129,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -161,7 +160,7 @@ namespace CXX names_parser_callback_ >> parser_callback_; } - virtual Void + virtual void traverse (Type& c) { String const& name (eimpl (c)); @@ -202,12 +201,12 @@ namespace CXX }; } - Void + void generate_impl_header (Context& ctx) { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Includes includes (ctx, Includes::impl_header); Traversal::Names schema_names; diff --git a/xsd/xsd/cxx/parser/impl-header.hxx b/xsd/xsd/cxx/parser/impl-header.hxx index dd63e52..273201b 100644 --- a/xsd/xsd/cxx/parser/impl-header.hxx +++ b/xsd/xsd/cxx/parser/impl-header.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-header.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_IMPL_HEADER_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_impl_header (Context&); } } diff --git a/xsd/xsd/cxx/parser/impl-source.cxx b/xsd/xsd/cxx/parser/impl-source.cxx index b951f6a..ad85f81 100644 --- a/xsd/xsd/cxx/parser/impl-source.cxx +++ b/xsd/xsd/cxx/parser/impl-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/impl-source.hxx> @@ -22,7 +21,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (eimpl (e)); @@ -57,7 +56,7 @@ namespace CXX os << arg_type (base) << " v (" << post_name (base) << " ());" << endl; - if (options.value<CLI::generate_print_impl> ()) + if (options.generate_print_impl ()) { PrintCall t (*this, e.name (), "v"); t.dispatch (base); @@ -91,7 +90,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (eimpl (l)); @@ -126,7 +125,7 @@ namespace CXX if (arg != L"void") { - if (options.value<CLI::generate_print_impl> ()) + if (options.generate_print_impl ()) { PrintCall t (*this, type.name (), item); t.dispatch (type); @@ -164,7 +163,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (eimpl (u)); @@ -186,7 +185,7 @@ namespace CXX << "_characters (const " << string_type << "& s)" << "{"; - if (options.value<CLI::generate_print_impl> ()) + if (options.generate_print_impl ()) os << cout_inst << " << " << strlit (u.name () + L": ") << " << s << std::endl;"; else @@ -221,7 +220,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -244,7 +243,7 @@ namespace CXX if (arg != L"void") { - if (options.value<CLI::generate_print_impl> ()) + if (options.generate_print_impl ()) { PrintCall t (*this, m.name (), name); t.dispatch (m.type ()); @@ -268,12 +267,12 @@ namespace CXX names_parser_callback_ >> parser_callback_; } - virtual Void + virtual void traverse (Type& c) { String const& name (eimpl (c)); - Boolean restriction (restriction_p (c)); + bool restriction (restriction_p (c)); os << "// " << name << endl << "//" << endl @@ -314,7 +313,7 @@ namespace CXX os << arg_type (base) << " v (" << post_name (base) << " ());" << endl; - if (options.value<CLI::generate_print_impl> ()) + if (options.generate_print_impl ()) { PrintCall t (*this, c.name (), "v"); t.dispatch (base); @@ -354,15 +353,15 @@ namespace CXX }; } - Void + void generate_impl_source (Context& ctx) { - if (ctx.options.value<CLI::generate_print_impl> ()) + if (ctx.options.generate_print_impl ()) ctx.os << "#include <iostream>" << endl << endl; Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); Traversal::Names names; diff --git a/xsd/xsd/cxx/parser/impl-source.hxx b/xsd/xsd/cxx/parser/impl-source.hxx index 0d60162..b6f9b3d 100644 --- a/xsd/xsd/cxx/parser/impl-source.hxx +++ b/xsd/xsd/cxx/parser/impl-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/impl-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_IMPL_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_impl_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/name-processor.cxx b/xsd/xsd/cxx/parser/name-processor.cxx index d323187..219a3c9 100644 --- a/xsd/xsd/cxx/parser/name-processor.cxx +++ b/xsd/xsd/cxx/parser/name-processor.cxx @@ -1,66 +1,47 @@ // file : xsd/cxx/parser/name-processor.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <set> +#include <map> +#include <sstream> +#include <iostream> + #include <cxx/parser/name-processor.hxx> #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> -#include <cult/containers/set.hxx> -#include <sstream> -#include <iostream> +using namespace std; namespace CXX { namespace Parser { - NameProcessor:: - NameProcessor () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - namespace { // // - typedef Cult::Containers::Set<String> NameSet; + typedef set<String> NameSet; class Context: public CXX::Context { public: - Context (CLI::Options const& ops, + Context (Parser::options const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path, StringLiteralMap const* map) - : CXX::Context (std::wcerr, - root, - path, - map, - ops.value<CLI::char_type> (), - ops.value<CLI::char_encoding> (), - ops.value<CLI::include_with_brackets> (), - ops.value<CLI::include_prefix> (), - ops.value<CLI::export_symbol> (), - ops.value<CLI::namespace_map> (), - ops.value<CLI::namespace_regex> (), - ops.value<CLI::namespace_regex_trace> (), - ops.value<CLI::include_regex> (), - ops.value<CLI::include_regex_trace> (), - ops.value<CLI::generate_inline> (), - ops.value<CLI::reserved_name> ()), - skel_suffix_ (ops.value<CLI::skel_type_suffix> ()), - impl_suffix_ (ops.value<CLI::impl_type_suffix> ()), - impl (ops.value<CLI::generate_noop_impl> () || - ops.value<CLI::generate_print_impl> () || - ops.value<CLI::generate_test_driver> ()), + : CXX::Context (std::wcerr, root, path, ops, map), + skel_suffix_ (ops.skel_type_suffix ()), + impl_suffix_ (ops.impl_type_suffix ()), + impl (ops.generate_noop_impl () || + ops.generate_print_impl () || + ops.generate_test_driver ()), skel_suffix (skel_suffix_), impl_suffix (impl_suffix_), global_type_names (global_type_names_), - polymorphic (ops.value<CLI::generate_polymorphic> ()) + polymorphic (ops.generate_polymorphic ()) { } @@ -82,7 +63,7 @@ namespace CXX String base_name (escape (n)); String name (base_name); - for (UnsignedLong i (1); set.find (name) != set.end (); ++i) + for (size_t i (1); set.find (name) != set.end (); ++i) { std::wostringstream os; os << i; @@ -97,16 +78,16 @@ namespace CXX String const skel_suffix_; String const impl_suffix_; - Cult::Containers::Map<String, NameSet> global_type_names_; + map<String, NameSet> global_type_names_; public: - Boolean const impl; + bool const impl; String const& skel_suffix; String const& impl_suffix; - Cult::Containers::Map<String, NameSet>& global_type_names; + map<String, NameSet>& global_type_names; - Boolean polymorphic; + bool polymorphic; }; @@ -119,7 +100,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) @@ -139,7 +120,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) @@ -156,9 +137,6 @@ namespace CXX !m.type ().context ().count ("anonymous")) { m.context ().set ( - "member-cache", find_name (base + L"_parser_cache_", set_)); - - m.context ().set ( "member-map", find_name (base + L"_parser_map_", set_)); m.context ().set ( @@ -245,7 +223,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) @@ -282,17 +260,17 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (Parser::Context::skip (m)) return; - Boolean poly (polymorphic && + bool poly (polymorphic && m.is_a<SemanticGraph::Element> () && !m.type ().context ().count ("anonymous")); - String parser, member, member_cache, member_map, member_map_impl; + String parser, member, member_map, member_map_impl; try { @@ -306,7 +284,6 @@ namespace CXX if (poly) { - member_cache = bm.context ().get<String> ("member-cache"); member_map = bm.context ().get<String> ("member-map"); member_map_impl = bm.context ().get<String> ("member-map-impl"); } @@ -322,7 +299,6 @@ namespace CXX if (poly) { - member_cache = find_name (base + L"_parser_cache_", set_); member_map = find_name (base + L"_parser_map_", set_); member_map_impl = find_name (base + L"_parser_map_impl_", set_); } @@ -333,7 +309,6 @@ namespace CXX if (poly) { - m.context ().set ("member-cache", member_cache); m.context ().set ("member-map", member_map); m.context ().set ("member-map-impl", member_map_impl); } @@ -349,7 +324,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { SemanticGraph::Context& cc (c.context ()); @@ -371,7 +346,7 @@ namespace CXX // inheriting by restriction in which case we need to have // the same names as our base. // - Boolean restriction (false); + bool restriction (false); if (c.inherits_p ()) { @@ -464,7 +439,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { SemanticGraph::Context& c (t.context ()); @@ -533,7 +508,7 @@ namespace CXX String base_name (escape (L"post_" + n)); String post (base_name); - for (UnsignedLong i (1); set.find (post) != set.end (); ++i) + for (size_t i (1); set.find (post) != set.end (); ++i) { std::wostringstream os; os << i; @@ -556,7 +531,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& ns) { NameSet& type_set (global_type_names[ns.name ()]); @@ -634,7 +609,7 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { t.context ().set ("name", make_skel_name ("any_type")); @@ -642,7 +617,7 @@ namespace CXX t.context ().set ("post", String ("post_any_type")); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { t.context ().set ("name", make_skel_name ("any_simple_type")); @@ -652,7 +627,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { t.context ().set ("name", make_skel_name ("boolean")); @@ -662,7 +637,7 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { t.context ().set ("name", make_skel_name ("byte")); @@ -670,7 +645,7 @@ namespace CXX t.context ().set ("post", String ("post_byte")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { t.context ().set ("name", make_skel_name ("unsigned_byte")); @@ -678,7 +653,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_byte")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { t.context ().set ("name", make_skel_name ("short")); @@ -686,7 +661,7 @@ namespace CXX t.context ().set ("post", String ("post_short")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { t.context ().set ("name", make_skel_name ("unsigned_short")); @@ -694,7 +669,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_short")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { t.context ().set ("name", make_skel_name ("int")); @@ -702,7 +677,7 @@ namespace CXX t.context ().set ("post", String ("post_int")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { t.context ().set ("name", make_skel_name ("unsigned_int")); @@ -710,7 +685,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_int")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { t.context ().set ("name", make_skel_name ("long")); @@ -718,7 +693,7 @@ namespace CXX t.context ().set ("post", String ("post_long")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { t.context ().set ("name", make_skel_name ("unsigned_long")); @@ -726,7 +701,7 @@ namespace CXX t.context ().set ("post", String ("post_unsigned_long")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { t.context ().set ("name", make_skel_name ("integer")); @@ -734,7 +709,7 @@ namespace CXX t.context ().set ("post", String ("post_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { t.context ().set ("name", make_skel_name ("non_positive_integer")); @@ -742,7 +717,7 @@ namespace CXX t.context ().set ("post", String ("post_non_positive_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { t.context ().set ("name", make_skel_name ("non_negative_integer")); @@ -750,7 +725,7 @@ namespace CXX t.context ().set ("post", String ("post_non_negative_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { t.context ().set ("name", make_skel_name ("positive_integer")); @@ -758,7 +733,7 @@ namespace CXX t.context ().set ("post", String ("post_positive_integer")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { t.context ().set ("name", make_skel_name ("negative_integer")); @@ -768,7 +743,7 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { t.context ().set ("name", make_skel_name ("float")); @@ -776,7 +751,7 @@ namespace CXX t.context ().set ("post", String ("post_float")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { t.context ().set ("name", make_skel_name ("double")); @@ -784,7 +759,7 @@ namespace CXX t.context ().set ("post", String ("post_double")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { t.context ().set ("name", make_skel_name ("decimal")); @@ -794,7 +769,7 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { t.context ().set ("name", make_skel_name ("string")); @@ -802,7 +777,7 @@ namespace CXX t.context ().set ("post", String ("post_string")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { t.context ().set ("name", make_skel_name ("normalized_string")); @@ -810,7 +785,7 @@ namespace CXX t.context ().set ("post", String ("post_normalized_string")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { t.context ().set ("name", make_skel_name ("token")); @@ -818,7 +793,7 @@ namespace CXX t.context ().set ("post", String ("post_token")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { t.context ().set ("name", make_skel_name ("nmtoken")); @@ -826,7 +801,7 @@ namespace CXX t.context ().set ("post", String ("post_nmtoken")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { t.context ().set ("name", make_skel_name ("nmtokens")); @@ -834,7 +809,7 @@ namespace CXX t.context ().set ("post", String ("post_nmtokens")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { t.context ().set ("name", make_skel_name ("name")); @@ -842,7 +817,7 @@ namespace CXX t.context ().set ("post", String ("post_name")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { t.context ().set ("name", make_skel_name ("ncname")); @@ -850,7 +825,7 @@ namespace CXX t.context ().set ("post", String ("post_ncname")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { t.context ().set ("name", make_skel_name ("language")); @@ -861,7 +836,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { t.context ().set ("name", make_skel_name ("qname")); @@ -872,7 +847,7 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { t.context ().set ("name", make_skel_name ("id")); @@ -880,7 +855,7 @@ namespace CXX t.context ().set ("post", String ("post_id")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { t.context ().set ("name", make_skel_name ("idref")); @@ -888,7 +863,7 @@ namespace CXX t.context ().set ("post", String ("post_idref")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { t.context ().set ("name", make_skel_name ("idrefs")); @@ -898,7 +873,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { t.context ().set ("name", make_skel_name ("uri")); @@ -908,7 +883,7 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { t.context ().set ("name", make_skel_name ("base64_binary")); @@ -916,7 +891,7 @@ namespace CXX t.context ().set ("post", String ("post_base64_binary")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { t.context ().set ("name", make_skel_name ("hex_binary")); @@ -927,7 +902,7 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { t.context ().set ("name", make_skel_name ("date")); @@ -935,7 +910,7 @@ namespace CXX t.context ().set ("post", String ("post_date")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { t.context ().set ("name", make_skel_name ("date_time")); @@ -943,7 +918,7 @@ namespace CXX t.context ().set ("post", String ("post_date_time")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { t.context ().set ("name", make_skel_name ("duration")); @@ -951,7 +926,7 @@ namespace CXX t.context ().set ("post", String ("post_duration")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { t.context ().set ("name", make_skel_name ("gday")); @@ -959,7 +934,7 @@ namespace CXX t.context ().set ("post", String ("post_gday")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { t.context ().set ("name", make_skel_name ("gmonth")); @@ -967,7 +942,7 @@ namespace CXX t.context ().set ("post", String ("post_gmonth")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { t.context ().set ("name", make_skel_name ("gmonth_day")); @@ -975,7 +950,7 @@ namespace CXX t.context ().set ("post", String ("post_gmonth_day")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { t.context ().set ("name", make_skel_name ("gyear")); @@ -983,7 +958,7 @@ namespace CXX t.context ().set ("post", String ("post_gyear")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { t.context ().set ("name", make_skel_name ("gyear_month")); @@ -991,7 +966,7 @@ namespace CXX t.context ().set ("post", String ("post_gyear_month")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { t.context ().set ("name", make_skel_name ("time")); @@ -1001,7 +976,7 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity& t) { t.context ().set ("name", make_skel_name ("entity")); @@ -1009,7 +984,7 @@ namespace CXX t.context ().set ("post", String ("post_entity")); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities& t) { t.context ().set ("name", make_skel_name ("entities")); @@ -1038,7 +1013,7 @@ namespace CXX Traversal::Includes, Traversal::Imports { - virtual Void + virtual void traverse (SemanticGraph::Sources& sr) { SemanticGraph::Schema& s (sr.schema ()); @@ -1050,7 +1025,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Includes& i) { SemanticGraph::Schema& s (i.schema ()); @@ -1062,7 +1037,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Imports& i) { SemanticGraph::Schema& s (i.schema ()); @@ -1080,7 +1055,7 @@ namespace CXX // struct Implies: Traversal::Implies { - virtual Void + virtual void traverse (SemanticGraph::Implies& i) { SemanticGraph::Schema& s (i.schema ()); @@ -1093,8 +1068,8 @@ namespace CXX } }; - Void - process_impl (CLI::Options const& ops, + void + process_impl (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, StringLiteralMap const& map) @@ -1169,7 +1144,7 @@ namespace CXX // { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; @@ -1189,8 +1164,8 @@ namespace CXX } } - Void NameProcessor:: - process (CLI::Options const& ops, + void NameProcessor:: + process (options const& ops, SemanticGraph::Schema& tu, SemanticGraph::Path const& file, StringLiteralMap const& map) diff --git a/xsd/xsd/cxx/parser/name-processor.hxx b/xsd/xsd/cxx/parser/name-processor.hxx index 5c28371..0460ea4 100644 --- a/xsd/xsd/cxx/parser/name-processor.hxx +++ b/xsd/xsd/cxx/parser/name-processor.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/name-processor.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_NAME_PROCESSOR_HXX @@ -8,22 +7,20 @@ #include <xsd-frontend/semantic-graph.hxx> +#include <types.hxx> + #include <cxx/elements.hxx> -#include <cxx/parser/cli.hxx> +#include <cxx/parser/options.hxx> namespace CXX { namespace Parser { - using namespace Cult::Types; - class NameProcessor { public: - NameProcessor (); // Dummy ctor, helps with long symbols on HP-UX. - - Void - process (CLI::Options const& ops, + void + process (options const&, XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file, StringLiteralMap const& map); diff --git a/xsd/xsd/cxx/parser/options.cli b/xsd/xsd/cxx/parser/options.cli new file mode 100644 index 0000000..227bb51 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.cli @@ -0,0 +1,148 @@ +// file : xsd/cxx/parser/options.cli +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include <cstddef>; // std::size_t + +include <types.hxx>; // NarrowString, NarrowStrings + +include <cxx/options.cli>; + +namespace CXX +{ + namespace Parser + { + class options: CXX::options + { + NarrowStrings --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." + }; + + 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-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." + }; + + 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. + // + 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." + }; + + 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." + }; + + 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." + }; + + 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/xsd/cxx/parser/options.cxx b/xsd/xsd/cxx/parser/options.cxx new file mode 100644 index 0000000..6f18446 --- /dev/null +++ b/xsd/xsd/cxx/parser/options.cxx @@ -0,0 +1,581 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +// Begin prologue. +// +#include <options-parser.hxx> +// +// End prologue. + +#include <cxx/parser/options.hxx> + +#include <map> +#include <set> +#include <string> +#include <vector> +#include <ostream> +#include <sstream> + +namespace cli +{ + template <typename X> + struct parser + { + static void + parse (X& x, bool& xs, scanner& s) + { + std::string o (s.next ()); + + if (s.more ()) + { + std::string v (s.next ()); + std::istringstream is (v); + if (!(is >> x && is.eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + + xs = true; + } + }; + + template <> + struct parser<bool> + { + static void + parse (bool& x, scanner& s) + { + s.next (); + x = true; + } + }; + + template <> + struct parser<std::string> + { + 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 <typename X> + struct parser<std::vector<X> > + { + static void + parse (std::vector<X>& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser<X>::parse (x, dummy, s); + c.push_back (x); + xs = true; + } + }; + + template <typename X> + struct parser<std::set<X> > + { + static void + parse (std::set<X>& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser<X>::parse (x, dummy, s); + c.insert (x); + xs = true; + } + }; + + template <typename K, typename V> + struct parser<std::map<K, V> > + { + static void + parse (std::map<K, V>& m, bool& xs, scanner& s) + { + std::string o (s.next ()); + + if (s.more ()) + { + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + if (p == std::string::npos) + { + K k = K (); + + if (!ov.empty ()) + { + std::istringstream ks (ov); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + m[k] = V (); + } + else + { + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, p + 1); + + if (!kstr.empty ()) + { + std::istringstream ks (kstr); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + if (!vstr.empty ()) + { + std::istringstream vs (vstr); + + if (!(vs >> v && vs.eof ())) + throw invalid_value (o, ov); + } + + m[k] = v; + } + } + else + throw missing_value (o); + + xs = true; + } + }; + + template <typename X, typename T, T X::*M> + void + thunk (X& x, scanner& s) + { + parser<T>::parse (x.*M, s); + } + + template <typename X, typename T, T X::*M, bool X::*S> + void + thunk (X& x, scanner& s) + { + parser<T>::parse (x.*M, x.*S, s); + } +} + +#include <map> +#include <cstring> + +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); + } + + void options:: + print_usage (::std::wostream& os) + { + os << "--type-map <mapfile> Read XML Schema to C++ type mapping information" << ::std::endl + << " from <mapfile>." << ::std::endl; + + os << "--xml-parser <parser> Use <parser> 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 <element> Indicate that <element> is the document root." << ::std::endl; + + os << "--skel-type-suffix <suffix> Use the provided <suffix> instead of the default" << ::std::endl + << " '_pskel' to construct the names of the generated" << ::std::endl + << " parser skeletons." << ::std::endl; + + os << "--skel-file-suffix <suffix> Use the provided <suffix> 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 <suffix> Use the provided <suffix> 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 <suffix> Use the provided <suffix> instead of the default" << ::std::endl + << " '-pimpl' to construct the names of the generated" << ::std::endl + << " sample parser implementation files." << ::std::endl; + } + + typedef + std::map<std::string, void (*) (options&, ::cli::scanner&)> + _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; + } + + void options:: + _parse (::cli::scanner& s, + ::cli::unknown_mode opt_mode, + ::cli::unknown_mode arg_mode) + { + bool opt = true; + + while (s.more ()) + { + const char* o = s.peek (); + + if (std::strcmp (o, "--") == 0) + { + s.skip (); + opt = false; + continue; + } + + if (opt && _parse (o, s)); + else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0') + { + switch (opt_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_option (o); + } + } + + break; + } + else + { + switch (arg_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_argument (o); + } + } + + break; + } + } + } + } +} + +// 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..976f93b --- /dev/null +++ b/xsd/xsd/cxx/parser/options.hxx @@ -0,0 +1,183 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef CXX_PARSER_OPTIONS_HXX +#define CXX_PARSER_OPTIONS_HXX + +// Begin prologue. +// +// +// End prologue. + +#include <cstddef> + +#include <types.hxx> + +#include <cxx/options.hxx> + +namespace CXX +{ + namespace Parser + { + class options: public ::CXX::options + { + public: + 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); + + options (); + + // 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 void + print_usage (::std::wostream&); + + // Implementation details. + // + protected: + bool + _parse (const char*, ::cli::scanner&); + + private: + void + _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 <cxx/parser/options.ixx> + +// Begin epilogue. +// +// +// End epilogue. + +#endif // 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..22ab11d --- /dev/null +++ b/xsd/xsd/cxx/parser/options.ixx @@ -0,0 +1,160 @@ +// This code 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. diff --git a/xsd/xsd/cxx/parser/parser-forward.cxx b/xsd/xsd/cxx/parser/parser-forward.cxx index a4e8ae7..faf427a 100644 --- a/xsd/xsd/cxx/parser/parser-forward.cxx +++ b/xsd/xsd/cxx/parser/parser-forward.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-forward.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/parser-forward.hxx> @@ -21,7 +20,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { os << "class " << ename (e) << ";"; @@ -37,7 +36,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { os << "class " << ename (l) << ";"; @@ -53,7 +52,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { os << "class " << ename (u) << ";"; @@ -69,7 +68,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& c) { os << "class " << ename (c) << ";"; @@ -77,7 +76,7 @@ namespace CXX }; } - Void + void generate_parser_forward (Context& ctx) { ctx.os << "// Forward declarations" << endl @@ -85,7 +84,7 @@ namespace CXX Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/parser-forward.hxx b/xsd/xsd/cxx/parser/parser-forward.hxx index a8a17f1..53c7049 100644 --- a/xsd/xsd/cxx/parser/parser-forward.hxx +++ b/xsd/xsd/cxx/parser/parser-forward.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-forward.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_PARSER_FORWARD_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_parser_forward (Context&); } } diff --git a/xsd/xsd/cxx/parser/parser-header.cxx b/xsd/xsd/cxx/parser/parser-header.cxx index aade743..800a4b9 100644 --- a/xsd/xsd/cxx/parser/parser-header.cxx +++ b/xsd/xsd/cxx/parser/parser-header.cxx @@ -1,13 +1,16 @@ // file : xsd/cxx/parser/parser-header.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <set> + #include <cxx/parser/parser-header.hxx> #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> +using namespace std; + namespace CXX { namespace Parser @@ -21,7 +24,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (ename (e)); @@ -41,7 +44,7 @@ namespace CXX String const& ret (ret_type (e)); - Boolean same (ret == ret_type (base)); + bool same (ret == ret_type (base)); os << "virtual " << ret << endl << post_name (e) << " ()" << @@ -71,7 +74,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (ename (l)); @@ -173,7 +176,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (ename (u)); @@ -222,7 +225,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; @@ -251,7 +254,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -281,7 +284,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -295,8 +298,7 @@ namespace CXX m.is_a<SemanticGraph::Element> () && !anonymous (m.type ())) { - os << type << "* " << emember_cache (m) << ";" - << "const " << parser_map << "* " << emember_map (m) << ";" + os << "const " << parser_map << "* " << emember_map (m) << ";" << endl; } } @@ -316,14 +318,13 @@ namespace CXX } - virtual Void + virtual void traverse (SemanticGraph::All& a) { if (!a.context().count ("comp-number")) return; - UnsignedLong state_count ( - a.context().get<UnsignedLong> ("state-count")); + size_t state_count (a.context().get<size_t> ("state-count")); os << "void" << endl << "all_0 (unsigned long& state," << endl @@ -338,13 +339,13 @@ namespace CXX << endl; } - virtual Void + virtual void traverse (SemanticGraph::Choice& c) { if (!c.context().count ("comp-number")) return; - UnsignedLong n (c.context ().get<UnsignedLong> ("comp-number")); + size_t n (c.context ().get<size_t> ("comp-number")); os << "void" << endl << "choice_" << n << " (unsigned long& state," << endl @@ -358,13 +359,13 @@ namespace CXX Traversal::Choice::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Sequence& s) { if (!s.context().count ("comp-number")) return; - UnsignedLong n (s.context ().get<UnsignedLong> ("comp-number")); + size_t n (s.context ().get<size_t> ("comp-number")); os << "void" << endl << "sequence_" << n << " (unsigned long& state," << endl @@ -392,7 +393,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { if (!a.optional_p ()) @@ -419,7 +420,7 @@ namespace CXX names_attribute_validation_state_ >> attribute_validation_state_; } - virtual Void + virtual void traverse (Type& c) { String const& name (ename (c)); @@ -428,15 +429,15 @@ namespace CXX // generate parser callbacks, etc. since they are the same as in // the base. We only need the parsing/validation code. // - Boolean restriction (restriction_p (c)); + bool restriction (restriction_p (c)); - Boolean he (has<Traversal::Element> (c)); - Boolean ha (has<Traversal::Attribute> (c)); + bool he (has<Traversal::Element> (c)); + bool ha (has<Traversal::Attribute> (c)); - Boolean hae (has_particle<Traversal::Any> (c)); - Boolean haa (has<Traversal::AnyAttribute> (c)); + bool hae (has_particle<Traversal::Any> (c)); + bool haa (has<Traversal::AnyAttribute> (c)); - Boolean hra (false); // Has required attribute. + bool hra (false); // Has required attribute. if (ha) { RequiredAttributeTest test (hra); @@ -472,7 +473,7 @@ namespace CXX String const& ret (ret_type (c)); - Boolean same (c.inherits_p () && + bool same (c.inherits_p () && ret == ret_type (c.inherits ().base ())); os << "virtual " << ret << endl @@ -606,7 +607,7 @@ namespace CXX if (validation && (he || hae)) { - UnsignedLong depth (c.context ().get<UnsignedLong> ("depth")); + size_t depth (c.context ().get<size_t> ("depth")); os << "protected:" << endl; @@ -770,13 +771,13 @@ namespace CXX // anyType & anySimpleType. // - virtual Void + virtual void traverse (SemanticGraph::AnyType& t) { gen_typedef (t, "void", "any_type_pskel", "any_type_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::AnySimpleType& t) { gen_typedef (t, "void", @@ -785,7 +786,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { gen_typedef (t, "bool", "boolean_pskel", "boolean_pimpl"); @@ -793,72 +794,72 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { gen_typedef (t, "signed char", "byte_pskel", "byte_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { gen_typedef (t, "unsigned char", "unsigned_byte_pskel", "unsigned_byte_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { gen_typedef (t, "short", "short_pskel", "short_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { gen_typedef (t, "unsigned short", "unsigned_short_pskel", "unsigned_short_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { gen_typedef (t, "int", "int_pskel", "int_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { gen_typedef (t, "unsigned int", "unsigned_int_pskel", "unsigned_int_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { gen_typedef (t, "long long", "long_pskel", "long_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { gen_typedef (t, "unsigned long long", "unsigned_long_pskel", "unsigned_long_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { gen_typedef (t, "long long", "integer_pskel", "integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { gen_typedef (t, "long long", "negative_integer_pskel", "negative_integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { gen_typedef (t, "long long", @@ -866,14 +867,14 @@ namespace CXX "non_positive_integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { gen_typedef (t, "unsigned long long", "positive_integer_pskel", "positive_integer_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { gen_typedef (t, "unsigned long long", @@ -883,19 +884,19 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { gen_typedef (t, "float", "float_pskel", "float_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { gen_typedef (t, "double", "double_pskel", "double_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { gen_typedef (t, "double", "decimal_pskel", "decimal_pimpl"); @@ -903,33 +904,33 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { gen_typedef (t, string_type_, "string_pskel", "string_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { gen_typedef (t, string_type_, "normalized_string_pskel", "normalized_string_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { gen_typedef (t, string_type_, "token_pskel", "token_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { nmtoken_ = gen_typedef (t, string_type_, "nmtoken_pskel", "nmtoken_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { // NMTOKENS uses NMTOKEN implementation to parse individual items. @@ -941,19 +942,19 @@ namespace CXX "nmtokens_pskel", "nmtokens_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { gen_typedef (t, string_type_, "name_pskel", "name_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { gen_typedef (t, string_type_, "ncname_pskel", "ncname_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { gen_typedef (t, string_type_, "language_pskel", "language_pimpl"); @@ -961,7 +962,7 @@ namespace CXX // Qualified name. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { gen_typedef (t, xs_ns_ + L"::qname", "qname_pskel", "qname_pimpl"); @@ -969,19 +970,19 @@ namespace CXX // ID/IDREF. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { gen_typedef (t, string_type_, "id_pskel", "id_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { idref_ = gen_typedef (t, string_type_, "idref_pskel", "idref_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { // IDREFS uses IDREF implementation to parse individual items. @@ -995,7 +996,7 @@ namespace CXX // URI. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { gen_typedef (t, string_type_, "uri_pskel", "uri_pimpl"); @@ -1003,78 +1004,78 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { - String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >"); + String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); gen_typedef (t, buffer, "base64_binary_pskel", "base64_binary_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { - String buffer (L"::std::auto_ptr< " + xs_ns_ + L"::buffer >"); + String buffer (auto_ptr + L"< " + xs_ns_ + L"::buffer >"); gen_typedef (t, buffer, "hex_binary_pskel", "hex_binary_pimpl"); } // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { gen_typedef (t, xs_ns_ + L"::date", "date_pskel", "date_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { gen_typedef (t, xs_ns_ + L"::date_time", "date_time_pskel", "date_time_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { gen_typedef (t, xs_ns_ + L"::duration", "duration_pskel", "duration_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { gen_typedef (t, xs_ns_ + L"::gday", "gday_pskel", "gday_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { gen_typedef (t, xs_ns_ + L"::gmonth", "gmonth_pskel", "gmonth_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { gen_typedef (t, xs_ns_ + L"::gmonth_day", "gmonth_day_pskel", "gmonth_day_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { gen_typedef (t, xs_ns_ + L"::gyear", "gyear_pskel", "gyear_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { gen_typedef (t, xs_ns_ + L"::gyear_month", "gyear_month_pskel", "gyear_month_pimpl"); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { gen_typedef (t, xs_ns_ + L"::time", "time_pskel", "time_pimpl"); @@ -1082,18 +1083,18 @@ namespace CXX // Entity. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entity&) { } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Entities&) { } private: - Boolean + bool gen_typedef (SemanticGraph::Type& t, String const& type, String const& pskel, @@ -1120,8 +1121,8 @@ namespace CXX String impl_ns_; String string_type_; - Boolean idref_; - Boolean nmtoken_; + bool idref_; + bool nmtoken_; }; struct FundNamespace: Namespace, Context @@ -1258,8 +1259,8 @@ namespace CXX }; } - Void - generate_parser_header (Context& ctx, Boolean generate_xml_schema) + void + generate_parser_header (Context& ctx, bool generate_xml_schema) { String c (ctx.char_type); @@ -1295,11 +1296,11 @@ namespace CXX NarrowString extern_xml_schema; if (!generate_xml_schema) - extern_xml_schema = ctx.options.value<CLI::extern_xml_schema> (); + extern_xml_schema = ctx.options.extern_xml_schema (); if (extern_xml_schema) { - String name (ctx.hxx_expr->merge (extern_xml_schema)); + String name (ctx.hxx_expr->replace (extern_xml_schema)); ctx.os << "#include " << ctx.process_include_path (name) << endl << endl; @@ -1308,12 +1309,12 @@ namespace CXX // if (ctx.schema_root.context ().count ("includes")) { - typedef Cult::Containers::Set<String> Includes; + typedef set<String> Includes; Includes const& is ( ctx.schema_root.context ().get<Includes> ("includes")); - for (Includes::ConstReverseIterator i (is.rbegin ()); + for (Includes::const_reverse_iterator i (is.rbegin ()); i != is.rend (); ++i) { ctx.os << "#include " << *i << endl; @@ -1357,12 +1358,12 @@ namespace CXX // if (ctx.schema_root.context ().count ("includes")) { - typedef Cult::Containers::Set<String> Includes; + typedef set<String> Includes; Includes const& is ( ctx.schema_root.context ().get<Includes> ("includes")); - for (Includes::ConstReverseIterator i (is.rbegin ()); + for (Includes::const_reverse_iterator i (is.rbegin ()); i != is.rend (); ++i) { ctx.os << "#include " << *i << endl; @@ -1412,7 +1413,7 @@ namespace CXX { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Includes includes (ctx, Includes::header); Traversal::Names schema_names; diff --git a/xsd/xsd/cxx/parser/parser-header.hxx b/xsd/xsd/cxx/parser/parser-header.hxx index c4e114d..467dcb5 100644 --- a/xsd/xsd/cxx/parser/parser-header.hxx +++ b/xsd/xsd/cxx/parser/parser-header.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-header.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_PARSER_HEADER_HXX @@ -12,8 +11,8 @@ namespace CXX { namespace Parser { - Void - generate_parser_header (Context&, Boolean generate_xml_schema); + void + generate_parser_header (Context&, bool generate_xml_schema); } } diff --git a/xsd/xsd/cxx/parser/parser-inline.cxx b/xsd/xsd/cxx/parser/parser-inline.cxx index b491b72..87ba92c 100644 --- a/xsd/xsd/cxx/parser/parser-inline.cxx +++ b/xsd/xsd/cxx/parser/parser-inline.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-inline.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/parser-inline.hxx> @@ -23,7 +22,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (ename (l)); @@ -75,7 +74,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -84,7 +83,7 @@ namespace CXX String const& scope (ename (m.scope ())); String const& parser (eparser (m)); - Boolean poly (polymorphic && + bool poly (polymorphic && m.is_a<SemanticGraph::Element> () && !anonymous (m.type ())); @@ -117,7 +116,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; @@ -138,7 +137,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) return; @@ -159,14 +158,14 @@ namespace CXX } } - Boolean + bool comma () const { return !first_; } private: - Boolean first_; + bool first_; }; struct ParserBaseSet: Traversal::Complex, @@ -180,7 +179,7 @@ namespace CXX names_ >> member_; } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { inherits (c, inherits_); @@ -189,7 +188,7 @@ namespace CXX names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { String const& name (ename (l)); @@ -212,14 +211,13 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { if (!a.context().count ("comp-number")) return; - UnsignedLong state_count ( - a.context().get<UnsignedLong> ("state-count")); + size_t state_count (a.context().get<size_t> ("state-count")); os << "," << endl << " v_all_count_ (" << state_count << "UL, v_all_first_)"; @@ -242,15 +240,15 @@ namespace CXX names_parser_member_set_ >> parser_member_set_; } - virtual Void + virtual void traverse (Type& c) { - Boolean he (has<Traversal::Element> (c)); - Boolean ha (has<Traversal::Attribute> (c)); + bool he (has<Traversal::Element> (c)); + bool ha (has<Traversal::Attribute> (c)); - Boolean hae (has_particle<Traversal::Any> (c)); + bool hae (has_particle<Traversal::Any> (c)); - Boolean hra (false); // Has required attribute. + bool hra (false); // Has required attribute. if (ha) { RequiredAttributeTest test (hra); @@ -258,7 +256,7 @@ namespace CXX names (c, names_test); } - Boolean restriction (restriction_p (c)); + bool restriction (restriction_p (c)); if (!((!restriction && (he || ha)) || (validation && (he || hae || hra)))) @@ -305,7 +303,7 @@ namespace CXX << name << " ()" << endl << ": "; - Boolean comma (false); + bool comma (false); if (!restriction && (he || ha)) { @@ -364,13 +362,13 @@ namespace CXX }; } - Void + void generate_parser_inline (Context& ctx) { // Emit "weak" header includes that are used in the file-per-type // compilation model. // - if (!ctx.options.value<CLI::generate_inline> ()) + if (!ctx.options.generate_inline ()) { Traversal::Schema schema; Includes includes (ctx, Includes::source); @@ -381,7 +379,7 @@ namespace CXX Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/parser-inline.hxx b/xsd/xsd/cxx/parser/parser-inline.hxx index 51f5b93..aff2ad2 100644 --- a/xsd/xsd/cxx/parser/parser-inline.hxx +++ b/xsd/xsd/cxx/parser/parser-inline.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-inline.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_PARSER_INLINE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_parser_inline (Context&); } } diff --git a/xsd/xsd/cxx/parser/parser-source.cxx b/xsd/xsd/cxx/parser/parser-source.cxx index 99bc566..2ee5273 100644 --- a/xsd/xsd/cxx/parser/parser-source.cxx +++ b/xsd/xsd/cxx/parser/parser-source.cxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-source.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cxx/parser/parser-source.hxx> @@ -21,7 +20,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { String const& name (ename (e)); @@ -29,7 +28,7 @@ namespace CXX SemanticGraph::Type& base (e.inherits ().base ()); - Boolean same (ret == ret_type (base)); + bool same (ret == ret_type (base)); if (same || ret == L"void" || polymorphic) { @@ -79,7 +78,7 @@ namespace CXX if (validation) { - Boolean gen (!anonymous (e)); + bool gen (!anonymous (e)); // We normally don't need to enter anonymous types into // the inheritance map. The only exception is when an @@ -89,16 +88,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - e.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast<SemanticGraph::Element*> (&i)) + if (e.classifies_begin () != e.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + e.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast<SemanticGraph::Element*> (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } @@ -126,7 +130,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& l) { String const& name (ename (l)); @@ -222,7 +226,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& u) { String const& name (ename (u)); @@ -277,15 +281,13 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (skip (e)) return; - Boolean poly (polymorphic && !anonymous (e.type ())); - - String const& inst (poly ? emember_cache (e) : emember (e)); + bool poly (polymorphic && !anonymous (e.type ())); os << "if ("; @@ -316,9 +318,12 @@ namespace CXX os << ")" << "{"; + String inst; + if (poly) { SemanticGraph::Type& t (e.type ()); + inst = "p"; // For pre-computing length. // @@ -334,8 +339,10 @@ namespace CXX String const& member (emember (e)); String const& member_map (emember_map (e)); - os << "if (t == 0 && this->" << member << " != 0)" << endl - << "this->" << inst << " = this->" << member << ";" + os << fq_type << "* p = 0;" + << endl + << "if (t == 0 && this->" << member << " != 0)" << endl + << inst << " = this->" << member << ";" << "else" << "{" << string_type << " ts (" << fq_type << @@ -345,21 +352,21 @@ namespace CXX << "t = &ts;" << endl << "if (this->" << member << " != 0 && *t == ts)" << endl - << "this->" << inst << " = this->" << member << ";" + << inst << " = this->" << member << ";" << "else if (this->" << member_map << " != 0)" << endl - << "this->" << inst << " = dynamic_cast< " << fq_type << + << inst << " = dynamic_cast< " << fq_type << "* > (" << endl << "this->" << member_map << "->find (*t));" - << "else" << endl - << "this->" << inst << " = 0;" << "}"; } + else + inst = L"this->" + emember (e); os << "this->" << complex_base << "::context_.top ().parser_ = " << - "this->" << inst << ";" + inst << ";" << endl - << "if (this->" << inst << ")" << endl - << "this->" << inst << "->pre ();" // _start_element calls _pre + << "if (" << inst << ")" << endl + << inst << "->pre ();" // _start_element calls _pre << endl << "return true;" << "}"; @@ -376,16 +383,14 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (skip (e)) return; - Boolean poly (polymorphic && !anonymous (e.type ())); - + bool poly (polymorphic && !anonymous (e.type ())); String const& name (ename (e)); - String const& inst (poly ? emember_cache (e) : emember (e)); os << "if ("; @@ -421,18 +426,31 @@ namespace CXX SemanticGraph::Type& type (e.type ()); String const& post (post_name (type)); + String inst; + + if (poly) + { + String const& fq_type (fq_name (type)); + inst = "p"; - os << "if (this->" << inst << ")"; + os << fq_type << "* p =" << endl + << "dynamic_cast< " << fq_type << "* > (" << endl + << "this->" << complex_base << "::context_.top ().parser_);" + << endl; + } + else + inst = L"this->" + emember (e); + + os << "if (" << inst << ")"; if (ret_type (type) == L"void") os << "{" - << "this->" << inst << "->" << post << " ();" + << inst << "->" << post << " ();" << "this->" << name << " ();" << "}"; else os << endl - << "this->" << name << " (this->" << inst << "->" << - post << " ());" + << "this->" << name << " (" << inst << "->" << post << " ());" << endl; os << "return true;" @@ -449,7 +467,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& a) { String const& name (ename (a)); @@ -500,7 +518,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& m) { if (skip (m)) @@ -538,14 +556,14 @@ namespace CXX names_attribute_ >> attribute_; } - virtual Void + virtual void traverse (Type& c) { - Boolean he (has<Traversal::Element> (c)); - Boolean ha (has<Traversal::Attribute> (c)); + bool he (has<Traversal::Element> (c)); + bool ha (has<Traversal::Attribute> (c)); String const& ret (ret_type (c)); - Boolean same (c.inherits_p () && + bool same (c.inherits_p () && ret == ret_type (c.inherits ().base ())); String const& name (ename (c)); @@ -581,7 +599,7 @@ namespace CXX if (c.inherits_p () && validation) { - Boolean gen (!anonymous (c)); + bool gen (!anonymous (c)); // We normally don't need to enter anonymous types into // the inheritance map. The only exception is when an @@ -591,16 +609,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - c.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast<SemanticGraph::Element*> (&i)) + if (c.classifies_begin () != c.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + c.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast<SemanticGraph::Element*> (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } @@ -655,7 +678,7 @@ namespace CXX // Don't use restriction_p here since we don't want special // treatment of anyType. // - Boolean restriction ( + bool restriction ( c.inherits_p () && c.inherits ().is_a<SemanticGraph::Restricts> ()); @@ -782,7 +805,7 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (e.substitutes_p ()) @@ -809,7 +832,7 @@ namespace CXX }; } - Void + void generate_parser_source (Context& ctx) { if (ctx.polymorphic) @@ -822,8 +845,8 @@ namespace CXX else ctx.os << endl; - Boolean import_maps (ctx.options.value<CLI::import_maps> ()); - Boolean export_maps (ctx.options.value<CLI::export_maps> ()); + bool import_maps (ctx.options.import_maps ()); + bool export_maps (ctx.options.export_maps ()); if (import_maps || export_maps) { @@ -896,7 +919,7 @@ namespace CXX // Emit "weak" header includes that are used in the file-per-type // compilation model. // - if (ctx.options.value<CLI::generate_inline> ()) + if (ctx.options.generate_inline ()) { Traversal::Schema schema; Includes includes (ctx, Includes::source); @@ -906,7 +929,7 @@ namespace CXX } Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Namespace ns (ctx); diff --git a/xsd/xsd/cxx/parser/parser-source.hxx b/xsd/xsd/cxx/parser/parser-source.hxx index f6496ea..6e206b4 100644 --- a/xsd/xsd/cxx/parser/parser-source.hxx +++ b/xsd/xsd/cxx/parser/parser-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/parser-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_PARSER_SOURCE_HXX @@ -12,7 +11,7 @@ namespace CXX { namespace Parser { - Void + void generate_parser_source (Context&); } } diff --git a/xsd/xsd/cxx/parser/print-impl-common.hxx b/xsd/xsd/cxx/parser/print-impl-common.hxx index 5a91931..516273a 100644 --- a/xsd/xsd/cxx/parser/print-impl-common.hxx +++ b/xsd/xsd/cxx/parser/print-impl-common.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/print-impl-common.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_PRINT_IMPL_COMMON_HXX @@ -74,7 +73,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Type&) { gen_user_type (); @@ -82,7 +81,7 @@ namespace CXX // Boolean. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Boolean& t) { if (default_type (t, "bool")) @@ -96,7 +95,7 @@ namespace CXX // Integral types. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Byte& t) { if (default_type (t, "signed char")) @@ -108,7 +107,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedByte& t) { if (default_type (t, "unsigned char")) @@ -120,7 +119,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Short& t) { if (default_type (t, "short")) @@ -132,7 +131,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedShort& t) { if (default_type (t, "unsigned short")) @@ -144,7 +143,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Int& t) { if (default_type (t, "int")) @@ -156,7 +155,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedInt& t) { if (default_type (t, "unsigned int")) @@ -168,7 +167,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Long& t) { if (default_type (t, "long long")) @@ -180,7 +179,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::UnsignedLong& t) { if (default_type (t, "unsigned long long")) @@ -192,7 +191,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Integer& t) { if (default_type (t, "long long")) @@ -204,7 +203,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NegativeInteger& t) { if (default_type (t, "long long")) @@ -216,7 +215,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonPositiveInteger& t) { if (default_type (t, "long long")) @@ -228,7 +227,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::PositiveInteger& t) { if (default_type (t, "unsigned long long")) @@ -240,7 +239,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NonNegativeInteger& t) { if (default_type (t, "unsigned long long")) @@ -254,7 +253,7 @@ namespace CXX // Floats. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Float& t) { if (default_type (t, "float")) @@ -266,7 +265,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Double& t) { if (default_type (t, "double")) @@ -278,7 +277,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Decimal& t) { if (default_type (t, "double")) @@ -292,61 +291,61 @@ namespace CXX // Strings. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Language& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { gen_string (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::AnyURI& t) { gen_string (t); @@ -355,13 +354,13 @@ namespace CXX // String sequences. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameTokens& t) { gen_sequence (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRefs& t) { gen_sequence (t); @@ -370,7 +369,7 @@ namespace CXX // QName // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::QName& t) { if (default_type (t, xs_ns_name () + L"::qname")) @@ -391,13 +390,13 @@ namespace CXX // Binary. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Base64Binary& t) { gen_buffer (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::HexBinary& t) { gen_buffer (t); @@ -405,7 +404,7 @@ namespace CXX // Date/time. // - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Date& t) { if (default_type (t, xs_ns_name () + L"::date")) @@ -421,7 +420,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::DateTime& t) { if (default_type (t, xs_ns_name () + L"::date_time")) @@ -440,7 +439,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Duration& t) { if (default_type (t, xs_ns_name () + L"::duration")) @@ -463,7 +462,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Day& t) { if (default_type (t, xs_ns_name () + L"::gday")) @@ -477,7 +476,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Month& t) { if (default_type (t, xs_ns_name () + L"::gmonth")) @@ -491,7 +490,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::MonthDay& t) { if (default_type (t, xs_ns_name () + L"::gmonth_day")) @@ -506,7 +505,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Year& t) { if (default_type (t, xs_ns_name () + L"::gyear")) @@ -520,7 +519,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::YearMonth& t) { if (default_type (t, xs_ns_name () + L"::gyear_month")) @@ -535,7 +534,7 @@ namespace CXX gen_user_type (); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Time& t) { if (default_type (t, xs_ns_name () + L"::time")) @@ -605,7 +604,7 @@ namespace CXX void gen_buffer (SemanticGraph::Type& t) { - String type (L"::std::auto_ptr< " + xs_ns_name () + L"::buffer >"); + String type (auto_ptr + L"< " + xs_ns_name () + L"::buffer >"); if (default_type (t, type)) { diff --git a/xsd/xsd/cxx/parser/state-processor.cxx b/xsd/xsd/cxx/parser/state-processor.cxx index 7fe3ff6..86f97ce 100644 --- a/xsd/xsd/cxx/parser/state-processor.cxx +++ b/xsd/xsd/cxx/parser/state-processor.cxx @@ -1,8 +1,10 @@ // file : xsd/cxx/parser/state-processor.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <vector> +#include <iostream> + #include <cxx/parser/state-processor.hxx> #include <cxx/parser/elements.hxx> @@ -10,9 +12,7 @@ #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> -#include <cult/containers/vector.hxx> - -#include <iostream> +using namespace std; namespace CXX { @@ -20,8 +20,9 @@ namespace CXX { namespace { - typedef Cult::Containers::Vector<SemanticGraph::Particle*> Particles; + typedef vector<SemanticGraph::Particle*> Particles; + /* void print (Particles const& p) { @@ -30,7 +31,7 @@ namespace CXX wcerr << "prefixes: " << endl; - for (Particles::ConstIterator i (p.begin ()); i != p.end (); ++i) + for (Particles::const_iterator i (p.begin ()); i != p.end (); ++i) { if (SemanticGraph::Element* e = dynamic_cast<SemanticGraph::Element*> (*i)) @@ -45,6 +46,7 @@ namespace CXX wcerr << endl; } + */ // // @@ -52,10 +54,10 @@ namespace CXX Traversal::Choice, Traversal::Sequence { - Particle (UnsignedLong& all, - UnsignedLong& choice, - UnsignedLong& sequence, - UnsignedLong& depth) + Particle (size_t& all, + size_t& choice, + size_t& sequence, + size_t& depth) : all_ (all), choice_ (choice), sequence_ (sequence), @@ -63,7 +65,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::All& a) { using SemanticGraph::Compositor; @@ -78,8 +80,8 @@ namespace CXX // compositor cannot contain any nested compositors. // - UnsignedLong state (0); - UnsignedLong min (0); + size_t state (0); + size_t min (0); for (Compositor::ContainsIterator ci (a.contains_begin ()); ci != a.contains_end (); ++ci) @@ -101,7 +103,7 @@ namespace CXX { a.context ().set ("comp-number", choice_++); a.context ().set ("prefixes", prefixes_); - a.context ().set ("state-count", UnsignedLong (prefixes_.size ())); + a.context ().set ("state-count", size_t (prefixes_.size ())); // effective-min = min * actual-min // @@ -114,7 +116,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Choice& c) { using SemanticGraph::Compositor; @@ -126,8 +128,8 @@ namespace CXX // the actual value specified in the schema. // - UnsignedLong state (0); - UnsignedLong min (1); + size_t state (0); + size_t min (1); for (Compositor::ContainsIterator ci (c.contains_begin ()); ci != c.contains_end (); ++ci) @@ -144,7 +146,7 @@ namespace CXX } else { - UnsignedLong depth (0); + size_t depth (0); Particle t (all_, choice_, sequence_, depth); t.dispatch (p); @@ -159,7 +161,7 @@ namespace CXX t.prefixes_.end ().base ()); if (min == 1 && - p.context ().get<UnsignedLong> ("effective-min") == 0) + p.context ().get<size_t> ("effective-min") == 0) min = 0; } @@ -183,7 +185,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Sequence& s) { using SemanticGraph::Compositor; @@ -195,9 +197,9 @@ namespace CXX // of the actual value specified in the schema. // - Boolean prefix (true); - UnsignedLong state (0); - UnsignedLong min (0); + bool prefix (true); + size_t state (0); + size_t min (0); for (Compositor::ContainsIterator ci (s.contains_begin ()); ci != s.contains_end (); ++ci) @@ -217,7 +219,7 @@ namespace CXX } else { - UnsignedLong depth (0); + size_t depth (0); Particle t (all_, choice_, sequence_, depth); t.dispatch (p); @@ -233,7 +235,7 @@ namespace CXX t.prefixes_.begin ().base (), t.prefixes_.end ().base ()); - if (p.context ().get<UnsignedLong> ("effective-min") != 0) + if (p.context ().get<size_t> ("effective-min") != 0) min = 1; } } @@ -266,11 +268,11 @@ namespace CXX private: Particles prefixes_; - UnsignedLong& all_; - UnsignedLong& choice_; - UnsignedLong& sequence_; + size_t& all_; + size_t& choice_; + size_t& sequence_; - UnsignedLong& depth_; + size_t& depth_; }; @@ -278,12 +280,12 @@ namespace CXX // struct Complex: Traversal::Complex { - virtual Void + virtual void traverse (Type& c) { if (c.contains_compositor_p ()) { - UnsignedLong all (0), choice (0), sequence (0), depth (0); + size_t all (0), choice (0), sequence (0), depth (0); Particle t (all, choice, sequence, depth); t.dispatch (c.contains_compositor ().compositor ()); @@ -296,11 +298,11 @@ namespace CXX }; } - Void StateProcessor:: + void StateProcessor:: process (SemanticGraph::Schema& tu, SemanticGraph::Path const&) { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; Traversal::Names schema_names; Traversal::Namespace ns; Traversal::Names ns_names; diff --git a/xsd/xsd/cxx/parser/state-processor.hxx b/xsd/xsd/cxx/parser/state-processor.hxx index 630ac13..de5af69 100644 --- a/xsd/xsd/cxx/parser/state-processor.hxx +++ b/xsd/xsd/cxx/parser/state-processor.hxx @@ -1,24 +1,22 @@ // file : xsd/cxx/parser/state-processor.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_STATE_PROCESSOR_HXX #define CXX_PARSER_STATE_PROCESSOR_HXX -#include <cult/types.hxx> #include <xsd-frontend/semantic-graph.hxx> +#include <types.hxx> + namespace CXX { namespace Parser { - using namespace Cult::Types; - class StateProcessor { public: - Void + void process (XSDFrontend::SemanticGraph::Schema&, XSDFrontend::SemanticGraph::Path const& file); }; diff --git a/xsd/xsd/cxx/parser/type-processor.cxx b/xsd/xsd/cxx/parser/type-processor.cxx index 4744c0a..2f1132c 100644 --- a/xsd/xsd/cxx/parser/type-processor.cxx +++ b/xsd/xsd/cxx/parser/type-processor.cxx @@ -1,9 +1,8 @@ // file : xsd/cxx/parser/type-processor.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include <cult/containers/set.hxx> +#include <set> #include <cxx/parser/elements.hxx> #include <cxx/parser/type-processor.hxx> @@ -11,16 +10,12 @@ #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> +using namespace std; + namespace CXX { namespace Parser { - TypeProcessor:: - TypeProcessor () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - namespace { // @@ -29,14 +24,14 @@ namespace CXX { Type (SemanticGraph::Schema& schema, TypeMap::Namespaces& type_map, - Boolean add_includes) + bool add_includes) : schema_ (schema), type_map_ (type_map), add_includes_ (add_includes) { } - virtual Void + virtual void traverse (SemanticGraph::Type& type) { using TypeMap::Namespace; @@ -54,7 +49,7 @@ namespace CXX // match the type in order to add include directives to the // new root schema. // - Boolean set (true); + bool set (true); if (tc.count ("ret-type")) { @@ -73,14 +68,14 @@ namespace CXX String ns_name (ns.name ()); String t_name (type.name ()); - // std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; + //std::wcerr << "traversing: " << ns_name << "#" << t_name << endl; - for (Namespaces::ConstIterator n (type_map_.begin ()); + for (Namespaces::const_iterator n (type_map_.begin ()); n != type_map_.end (); ++n) { // Check if the namespace matches. // - Boolean ns_match; + bool ns_match; if (!n->xsd_name ().empty ()) { @@ -89,7 +84,9 @@ namespace CXX else ns_match = ns_name.empty (); - // std::wcerr << "considering ns expr: " << n->xsd_name () << endl; + //std::wcerr << "considering ns expr: " << n->xsd_name () + // << " for " << ns_name + // << ": " << (ns_match ? "+" : "-") << endl; if (ns_match) { @@ -111,8 +108,8 @@ namespace CXX { if (!n->xsd_name ().empty ()) { - cxx_ns = n->xsd_name ().merge ( - n->cxx_name (), ns_name, true); + cxx_ns = n->xsd_name ().replace ( + ns_name, n->cxx_name (), true); } else cxx_ns = n->cxx_name (); @@ -124,16 +121,16 @@ namespace CXX // String ret_type (cxx_ns); - ret_type += t->xsd_name ().merge ( - t->cxx_ret_name (), t_name, true); + ret_type += t->xsd_name ().replace ( + t_name, t->cxx_ret_name (), true); String arg_type; if (t->cxx_arg_name ()) { arg_type = cxx_ns; - arg_type += t->xsd_name ().merge ( - t->cxx_arg_name (), t_name, true); + arg_type += t->xsd_name ().replace ( + t_name, t->cxx_arg_name (), true); } else { @@ -141,7 +138,7 @@ namespace CXX arg_type = ret_type; else { - WideChar last (ret_type[ret_type.size () - 1]); + wchar_t last (ret_type[ret_type.size () - 1]); // If it is already a pointer or reference then use // it as is. @@ -155,12 +152,12 @@ namespace CXX tc.set ("ret-type", ret_type); tc.set ("arg-type", arg_type); + + //std::wcerr << t_name << " -> " << ret_type << endl; } tc.set ("root-schema", &schema_); - //std::wcerr << t_name << " -> " << ret_type << endl; - // See of we need to add any includes to the translations // unit. // @@ -168,7 +165,7 @@ namespace CXX { if (n->includes_begin () != n->includes_end ()) { - typedef Cult::Containers::Set<String> Includes; + typedef std::set<String> Includes; if (!schema_.context ().count ("includes")) schema_.context ().set ("includes", Includes ()); @@ -194,7 +191,7 @@ namespace CXX private: SemanticGraph::Schema& schema_; TypeMap::Namespaces& type_map_; - Boolean add_includes_; + bool add_includes_; }; @@ -207,7 +204,7 @@ namespace CXX { GlobalType (SemanticGraph::Schema& schema, TypeMap::Namespaces& type_map, - Boolean add_includes) + bool add_includes) : type_ (schema, type_map, add_includes) { inherits_ >> type_; @@ -215,20 +212,20 @@ namespace CXX argumented_ >> type_; } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { type_.traverse (t); } - virtual Void + virtual void traverse (SemanticGraph::List& l) { type_.traverse (l); Traversal::List::argumented (l, argumented_); } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { type_.traverse (c); @@ -236,7 +233,7 @@ namespace CXX Complex::names (c, names_); } - virtual Void + virtual void traverse (SemanticGraph::Enumeration& e) { type_.traverse (e); @@ -252,10 +249,10 @@ namespace CXX Traversal::Argumented argumented_; }; - Void - process_impl (CLI::Options const& options, + void + process_impl (options const& ops, XSDFrontend::SemanticGraph::Schema& tu, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces& type_map) { if (tu.names_begin ()->named ().name () == @@ -279,14 +276,13 @@ namespace CXX // If --extern-xml-schema is specified, then we don't want // includes from the XML Schema type map. // - Boolean extern_xml_schema ( - options.value<CLI::extern_xml_schema> ()); + bool extern_xml_schema (ops.extern_xml_schema ()); // // Traversal::Schema schema; Traversal::Schema xs_schema; - Traversal::Sources sources; + Sources sources; Traversal::Implies implies; schema >> sources >> schema; @@ -312,7 +308,7 @@ namespace CXX // If we are generating the test driver, make sure the root // element type is processed. // - if (gen_driver && options.value<CLI::generate_test_driver> ()) + if (gen_driver && ops.generate_test_driver ()) { // Figure out the root element. Validator should have made sure // it is unique. @@ -320,14 +316,14 @@ namespace CXX SemanticGraph::Element* root (0); { Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; Traversal::Names schema_names; Traversal::Namespace ns; Traversal::Names ns_names; - RootElement root_element (options, root); + RootElement root_element (ops, root); schema >> schema_names >> ns >> ns_names >> root_element; @@ -340,13 +336,13 @@ namespace CXX } } - Void TypeProcessor:: - process (CLI::Options const& options, + void TypeProcessor:: + process (options const& ops, XSDFrontend::SemanticGraph::Schema& s, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces& tm) { - process_impl (options, s, gen_driver, tm); + process_impl (ops, s, gen_driver, tm); } } } diff --git a/xsd/xsd/cxx/parser/type-processor.hxx b/xsd/xsd/cxx/parser/type-processor.hxx index 02a090f..634bc14 100644 --- a/xsd/xsd/cxx/parser/type-processor.hxx +++ b/xsd/xsd/cxx/parser/type-processor.hxx @@ -1,34 +1,29 @@ // file : xsd/cxx/parser/type-processor.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_TYPE_PROCESSOR_HXX #define CXX_PARSER_TYPE_PROCESSOR_HXX -#include <cult/types.hxx> - #include <xsd-frontend/semantic-graph.hxx> +#include <types.hxx> + #include <type-map/type-map.hxx> -#include <cxx/parser/cli.hxx> +#include <cxx/parser/options.hxx> namespace CXX { namespace Parser { - using namespace Cult::Types; - class TypeProcessor { public: - TypeProcessor (); // Dummy ctor, helps with long symbols on HP-UX. - - Void - process (CLI::Options const& options, + void + process (options const&, XSDFrontend::SemanticGraph::Schema&, - Boolean gen_driver, + bool gen_driver, TypeMap::Namespaces&); }; } diff --git a/xsd/xsd/cxx/parser/validator.cxx b/xsd/xsd/cxx/parser/validator.cxx index 19b15c6..da9f8b0 100644 --- a/xsd/xsd/cxx/parser/validator.cxx +++ b/xsd/xsd/cxx/parser/validator.cxx @@ -1,8 +1,10 @@ // file : xsd/cxx/parser/validator.cxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#include <set> +#include <iostream> + #include <cxx/parser/validator.hxx> #include <xsd-frontend/semantic-graph.hxx> @@ -10,9 +12,7 @@ #include <cxx/parser/elements.hxx> -#include <iostream> - -using std::wcerr; +using namespace std; namespace CXX { @@ -25,10 +25,10 @@ namespace CXX public: ValidationContext (SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& options, + Parser::options const& ops, const WarningSet& disabled_warnings, - Boolean& valid_) - : Context (std::wcerr, root, path, options, 0, 0, 0, 0), + bool& valid_) + : Context (std::wcerr, root, path, ops, 0, 0, 0, 0), disabled_warnings_ (disabled_warnings), disabled_warnings_all_ (false), valid (valid_), @@ -38,8 +38,8 @@ namespace CXX } public: - Boolean - is_disabled (Char const* w) + bool + is_disabled (char const* w) { return disabled_warnings_all_ || disabled_warnings_.find (w) != disabled_warnings_.end (); @@ -74,10 +74,10 @@ namespace CXX protected: const WarningSet& disabled_warnings_; - Boolean disabled_warnings_all_; - Boolean& valid; - Boolean& subst_group_warning_issued; - Boolean subst_group_warning_issued_; + bool disabled_warnings_all_; + bool& valid; + bool& subst_group_warning_issued; + bool subst_group_warning_issued_; }; // @@ -98,20 +98,20 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) return; using SemanticGraph::Any; - Boolean q (e.qualified_p ()); + bool q (e.qualified_p ()); String ns (q ? e.namespace_ ().name () : ""); for (Any::NamespaceIterator i (any_.namespace_begin ()); i != any_.namespace_end (); ++i) { - Boolean failed (false); + bool failed (false); if (*i == L"##any") { @@ -184,14 +184,14 @@ namespace CXX { } - virtual Void + virtual void post (Type& c) { // Go down the inheritance hierarchy. // if (down_) { - Boolean up = up_; + bool up = up_; up_ = false; if (c.inherits_p ()) @@ -204,7 +204,7 @@ namespace CXX // if (up_) { - Boolean down = down_; + bool down = down_; down_ = false; for (Type::BegetsIterator i (c.begets_begin ()); @@ -218,10 +218,10 @@ namespace CXX } private: - Boolean up_, down_; + bool up_, down_; }; - virtual Void + virtual void traverse (SemanticGraph::Any& a) { using SemanticGraph::Compositor; @@ -273,7 +273,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { using SemanticGraph::Schema; @@ -319,7 +319,7 @@ namespace CXX Complex::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { if (t.named_p ()) @@ -328,14 +328,14 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (is_disabled ("P002")) return; if (e.substitutes_p () && - !options.value<CLI::generate_polymorphic> () && + !options.generate_polymorphic () && !subst_group_warning_issued) { subst_group_warning_issued = true; @@ -352,7 +352,7 @@ namespace CXX // Return true if root sources s. // - Boolean + bool sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s) { using SemanticGraph::Schema; @@ -372,9 +372,9 @@ namespace CXX } private: - Containers::Set<String> types_; + set<String> types_; - Traversal::Sources sources_; + Sources sources_; Traversal::Names schema_names_; Traversal::Namespace ns_; @@ -405,7 +405,7 @@ namespace CXX *this >> names_; } - Boolean + bool traverse_common (SemanticGraph::Member& m) { SemanticGraph::Type& t (m.type ()); @@ -434,7 +434,7 @@ namespace CXX << "automatically name them" << endl; - if (!options.value<CLI::show_anonymous> ()) + if (!options.show_anonymous ()) wcerr << t.file () << ": info: use --show-anonymous option to see these " << "types" << endl; @@ -446,14 +446,14 @@ namespace CXX return false; } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) return; if (traverse_common (e)) { - if (options.value<CLI::show_anonymous> ()) + if (options.show_anonymous ()) { wcerr << e.file () << ":" << e.line () << ":" << e.column () << ": error: element '" << xpath (e) << "' " @@ -464,12 +464,12 @@ namespace CXX Traversal::Element::traverse (e); } - virtual Void + virtual void traverse (SemanticGraph::Attribute& a) { if (traverse_common (a)) { - if (options.value<CLI::show_anonymous> ()) + if (options.show_anonymous ()) { wcerr << a.file () << ":" << a.line () << ":" << a.column () << ": error: attribute '" << xpath (a) << "' " @@ -481,11 +481,11 @@ namespace CXX } private: - Boolean anonymous_error_issued_; + bool anonymous_error_issued_; - Containers::Set<String> types_; + set<String> types_; - Traversal::Sources sources_; + Sources sources_; Traversal::Names schema_names_; Traversal::Namespace ns_; @@ -500,22 +500,22 @@ namespace CXX { } - virtual Void + virtual void traverse (Type& e) { if (!valid) return; - if (options.value<CLI::root_element_first> ()) + if (options.root_element_first ()) { if (element_ == 0) element_ = &e; } - else if (options.value<CLI::root_element_last> ()) + else if (options.root_element_last ()) { element_ = &e; } - else if (String name = options.value<CLI::root_element> ()) + else if (String name = options.root_element ()) { if (e.name () == name) element_ = &e; @@ -544,46 +544,40 @@ namespace CXX } - Validator:: - Validator () - { - // Dummy ctor, helps with long symbols on HP-UX. - } - - Boolean Validator:: - validate (CLI::Options const& options, + bool Validator:: + validate (options const& ops, SemanticGraph::Schema& root, SemanticGraph::Path const& path, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings) { - Boolean valid (true); - ValidationContext ctx (root, path, options, disabled_warnings, valid); + bool valid (true); + ValidationContext ctx (root, path, ops, disabled_warnings, valid); // // - if (options.value<CLI::char_type> () != "char" && - options.value<CLI::char_type> () != "wchar_t" && + if (ops.char_type () != "char" && + ops.char_type () != "wchar_t" && !ctx.is_disabled ("P003")) { wcerr << "warning P003: unknown base character type '" << - options.value<CLI::char_type> ().c_str () << "'" << endl; + ops.char_type ().c_str () << "'" << endl; } // // - if (options.value<CLI::xml_parser> () != "xerces" && - options.value<CLI::xml_parser> () != "expat" && + if (ops.xml_parser () != "xerces" && + ops.xml_parser () != "expat" && !ctx.is_disabled ("P004")) { wcerr << "warning P004: unknown underlying XML parser '" << - options.value<CLI::xml_parser> ().c_str () << "'" << endl; + ops.xml_parser ().c_str () << "'" << endl; } // // - if (options.value<CLI::xml_parser> () == "expat" && - options.value<CLI::char_type> () == "wchar_t") + if (ops.xml_parser () == "expat" && + ops.char_type () == "wchar_t") { wcerr << "error: using expat with wchar_t is not supported" << endl; @@ -593,9 +587,9 @@ namespace CXX // // - if (options.value<CLI::xml_parser> () == "expat" && - !options.value<CLI::char_encoding> ().empty () && - options.value<CLI::char_encoding> () != "utf8") + if (ops.xml_parser () == "expat" && + !ops.char_encoding ().empty () && + ops.char_encoding () != "utf8") { wcerr << "error: using expat with character encoding other than " << "utf8 is not supported" @@ -606,8 +600,7 @@ namespace CXX // // - if (options.value<CLI::generate_validation> () && - options.value<CLI::suppress_validation> ()) + if (ops.generate_validation () && ops.suppress_validation ()) { wcerr << "error: mutually exclusive options specified: " << "--generate-validation and --suppress-validation" @@ -618,8 +611,7 @@ namespace CXX // // - if (options.value<CLI::generate_noop_impl> () && - options.value<CLI::generate_print_impl> ()) + if (ops.generate_noop_impl () && ops.generate_print_impl ()) { wcerr << "error: mutually exclusive options specified: " << "--generate-noop-impl and --generate-print-impl" @@ -631,9 +623,9 @@ namespace CXX // // { - Boolean ref (options.value<CLI::root_element_first> ()); - Boolean rel (options.value<CLI::root_element_last> ()); - Boolean re (options.value<CLI::root_element> ()); + bool ref (ops.root_element_first ()); + bool rel (ops.root_element_last ()); + bool re (ops.root_element ()); if ((ref && rel) || (ref && re) || (rel && re)) { @@ -648,8 +640,8 @@ namespace CXX // // - Boolean import_maps (options.value<CLI::import_maps> ()); - Boolean export_maps (options.value<CLI::export_maps> ()); + bool import_maps (ops.import_maps ()); + bool export_maps (ops.export_maps ()); if (import_maps && export_maps) { @@ -698,7 +690,7 @@ namespace CXX SemanticGraph::Element* element (0); Traversal::Schema schema; - Traversal::Sources sources; + Sources sources; schema >> sources >> schema; diff --git a/xsd/xsd/cxx/parser/validator.hxx b/xsd/xsd/cxx/parser/validator.hxx index f519b05..c67cced 100644 --- a/xsd/xsd/cxx/parser/validator.hxx +++ b/xsd/xsd/cxx/parser/validator.hxx @@ -1,32 +1,28 @@ // file : xsd/cxx/parser/validator.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef CXX_PARSER_VALIDATOR_HXX #define CXX_PARSER_VALIDATOR_HXX -#include <cxx/parser/elements.hxx> -#include <cxx/parser/cli.hxx> - #include <xsd.hxx> +#include <types.hxx> + +#include <cxx/parser/elements.hxx> +#include <cxx/parser/options.hxx> namespace CXX { namespace Parser { - using namespace Cult::Types; - class Validator { public: - Validator (); // Dummy ctor, helps with long symbols on HP-UX. - - Boolean - validate (CLI::Options const& options, + bool + validate (options const&, SemanticGraph::Schema&, SemanticGraph::Path const& tu, - Boolean gen_driver, + bool gen_driver, const WarningSet& disabled_warnings); }; } |