diff options
Diffstat (limited to 'xsd/xsd/cxx/tree/validator.cxx')
-rw-r--r-- | xsd/xsd/cxx/tree/validator.cxx | 124 |
1 files changed, 58 insertions, 66 deletions
diff --git a/xsd/xsd/cxx/tree/validator.cxx b/xsd/xsd/cxx/tree/validator.cxx index 88451ba..ce3dcd8 100644 --- a/xsd/xsd/cxx/tree/validator.cxx +++ b/xsd/xsd/cxx/tree/validator.cxx @@ -1,20 +1,18 @@ // file : xsd/cxx/tree/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 <cxx/tree/validator.hxx> +#include <set> +#include <iostream> -#include <cult/containers/set.hxx> +#include <cxx/tree/validator.hxx> #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> #include <cxx/tree/elements.hxx> -#include <iostream> - -using std::wcerr; +using namespace std; namespace CXX { @@ -27,15 +25,15 @@ namespace CXX public: ValidationContext (SemanticGraph::Schema& root, SemanticGraph::Path const& path, - CLI::Options const& options, + Tree::options const& ops, const WarningSet& disabled_warnings, Counts const& counts, - Boolean generate_xml_schema, - Boolean& valid_) + bool generate_xml_schema, + bool& valid_) : Context (std::wcerr, root, path, - options, + ops, counts, generate_xml_schema, 0, @@ -53,8 +51,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 (); @@ -95,12 +93,12 @@ namespace CXX protected: const WarningSet& disabled_warnings_; - Boolean disabled_warnings_all_; + bool disabled_warnings_all_; - Boolean& valid; + bool& valid; - Boolean& subst_group_warning_issued; - Boolean subst_group_warning_issued_; + bool& subst_group_warning_issued; + bool subst_group_warning_issued_; }; @@ -122,7 +120,7 @@ namespace CXX { } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (skip (e)) @@ -130,13 +128,13 @@ namespace CXX 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") { @@ -205,14 +203,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 ()) @@ -225,7 +223,7 @@ namespace CXX // if (up_) { - Boolean down = down_; + bool down = down_; down_ = false; for (Type::BegetsIterator i (c.begets_begin ()); @@ -239,10 +237,10 @@ namespace CXX } private: - Boolean up_, down_; + bool up_, down_; }; - virtual Void + virtual void traverse (SemanticGraph::Any& a) { using SemanticGraph::Compositor; @@ -295,7 +293,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Complex& c) { using SemanticGraph::Schema; @@ -341,7 +339,7 @@ namespace CXX Complex::traverse (c); } - virtual Void + virtual void traverse (SemanticGraph::Type& t) { // This is also used to traverse Complex. @@ -352,7 +350,7 @@ namespace CXX } } - virtual Void + virtual void traverse (SemanticGraph::Element& e) { if (is_disabled ("T002")) @@ -379,7 +377,7 @@ namespace CXX // Return true if root sources s. // - Boolean + bool sources_p (SemanticGraph::Schema& root, SemanticGraph::Schema& s) { using SemanticGraph::Schema; @@ -399,9 +397,9 @@ namespace CXX } private: - Containers::Set<String> types_; + set<String> types_; - Traversal::Sources sources_; + Sources sources_; Traversal::Names schema_names_; Traversal::Namespace ns_; @@ -432,7 +430,7 @@ namespace CXX *this >> names_; } - Boolean + bool traverse_common (SemanticGraph::Member& m) { SemanticGraph::Type& t (m.type ()); @@ -461,7 +459,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; @@ -473,14 +471,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) << "' " @@ -491,12 +489,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) << "' " @@ -508,11 +506,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_; @@ -521,27 +519,21 @@ 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& schema, SemanticGraph::Path const& path, const WarningSet& disabled_warnings, Counts const& counts) { - Boolean valid (true); + bool valid (true); ValidationContext ctx ( - schema, path, options, disabled_warnings, counts, false, valid); + schema, path, ops, disabled_warnings, counts, false, valid); // // - 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) { @@ -569,17 +561,17 @@ namespace CXX // // - 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 ("T003")) { wcerr << "warning T003: unknown base character type '" << - options.value<CLI::char_type> ().c_str () << "'" << endl; + ops.char_type ().c_str () << "'" << endl; } // // - NarrowString tn (options.value<CLI::type_naming> ()); + NarrowString tn (ops.type_naming ()); if (tn != "knr" && tn != "ucc" && tn != "java") { @@ -589,7 +581,7 @@ namespace CXX return false; } - NarrowString fn (options.value<CLI::function_naming> ()); + NarrowString fn (ops.function_naming ()); if (fn != "knr" && fn != "lcc" && fn != "java") { @@ -601,11 +593,11 @@ namespace CXX // // - Boolean element_type (options.value<CLI::generate_element_type> ()); - Boolean par (!options.value<CLI::suppress_parsing> ()); - Boolean ser (options.value<CLI::generate_serialization> ()); + bool element_type (ops.generate_element_type ()); + bool par (!ops.suppress_parsing ()); + bool ser (ops.generate_serialization ()); - if (options.value<CLI::generate_element_map> ()) + if (ops.generate_element_map ()) { if (!element_type) { @@ -631,11 +623,11 @@ namespace CXX if (counts.global_elements > 1 && (element_type || par || ser) && - !options.value<CLI::root_element_first> () && - !options.value<CLI::root_element_last> () && - !options.value<CLI::root_element_all> () && - !options.value<CLI::root_element_none> () && - options.value<CLI::root_element> ().empty () && + !ops.root_element_first () && + !ops.root_element_last () && + !ops.root_element_all () && + !ops.root_element_none () && + ops.root_element ().empty () && !ctx.is_disabled ("T004")) { wcerr << schema.file () << ": warning T004: generating "; |