#include <schema_validator.hpp>
Classes | |
| struct | reference |
Public Member Functions | |
| schema_self_validator () | |
| virtual void | open_tag (const std::string &name, const config &parent, int start_line=0, const std::string &file="", bool addition=false) override |
| Is called when parser opens tag. More... | |
| virtual void | close_tag () override |
| As far as parser is built on stack, some realizations can store stack too. More... | |
| virtual void | validate (const config &cfg, const std::string &name, int start_line, const std::string &file) override |
| Validates config. More... | |
| virtual void | validate_key (const config &cfg, const std::string &name, const config_attribute_value &value, int start_line, const std::string &file) override |
| Checks if key is allowed and if its value is valid What exactly is validated depends on validator realization. More... | |
Public Member Functions inherited from schema_validation::schema_validator | |
| virtual | ~schema_validator () |
| schema_validator (const std::string &filename, bool validate_schema=false) | |
| Initializes validator from file. More... | |
| void | set_create_exceptions (bool value) |
| const std::vector< std::string > & | get_errors () const |
Public Member Functions inherited from abstract_validator | |
| abstract_validator (const std::string &name) | |
| Constructor of validator can throw validator::error. More... | |
| virtual | ~abstract_validator () |
Private Types | |
| enum | { WRONG_TYPE = NEXT_ERROR , WRONG_PATH , DUPLICATE_TAG , DUPLICATE_KEY , SUPER_LOOP , NEXT_ERROR } |
| using | schema_derivation_graph_t = boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, std::string, std::pair< config, reference > > |
Private Member Functions | |
| std::string | current_path () const |
| bool | tag_path_exists (const config &cfg, const reference &ref) |
| void | check_for_duplicates (const std::string &name, std::vector< std::string > &seen, const config &cfg, message_type type, const std::string &file, int line, const std::string &tag) |
| void | print (message_info &message) override |
| void | detect_schema_derivation_cycles () |
Static Private Member Functions | |
| static bool | name_matches (const std::string &pattern, const std::string &name) |
Private Attributes | |
| std::set< std::string > | defined_types_ |
| std::set< std::string > | defined_tag_paths_ |
| std::vector< reference > | referenced_types_ |
| std::vector< reference > | referenced_tag_paths_ |
| std::stack< std::string > | tag_stack_ |
| std::map< std::string, std::string > | links_ |
| std::multimap< std::string, std::string > | derivations_ |
| int | type_nesting_ |
| int | condition_nesting_ |
| schema_derivation_graph_t | schema_derivation_graph_ |
| std::map< std::string, schema_derivation_graph_t::vertex_descriptor > | schema_derivation_map_ |
Additional Inherited Members | |
Public Attributes inherited from abstract_validator | |
| const std::string | name_ |
Protected Types inherited from schema_validation::schema_validator | |
| enum | { WRONG_TAG , EXTRA_TAG , MISSING_TAG , EXTRA_KEY , MISSING_KEY , WRONG_VALUE , MISSING_SUPER , SUPER_CYCLE , NEXT_ERROR } |
| using | message_type = int |
Protected Member Functions inherited from schema_validation::schema_validator | |
| template<typename... T> | |
| void | queue_message (const config &cfg, T &&... args) |
| const wml_tag & | active_tag () const |
| std::string | active_tag_path () const |
| bool | have_active_tag () const |
| bool | is_valid () const |
| wml_type::ptr | find_type (const std::string &type) const |
Protected Attributes inherited from schema_validation::schema_validator | |
| bool | create_exceptions_ |
| Controls the way to print errors. More... | |
Definition at line 216 of file schema_validator.hpp.
|
private |
Definition at line 252 of file schema_validator.hpp.
|
private |
| Enumerator | |
|---|---|
| WRONG_TYPE | |
| WRONG_PATH | |
| DUPLICATE_TAG | |
| DUPLICATE_KEY | |
| SUPER_LOOP | |
| NEXT_ERROR | |
Definition at line 250 of file schema_validator.hpp.
| schema_validation::schema_self_validator::schema_self_validator | ( | ) |
Definition at line 702 of file schema_validator.cpp.
References defined_types_.
|
private |
Definition at line 792 of file schema_validator.cpp.
References cfg, draw::line(), name_matches(), schema_validation::schema_validator::queue_message(), utils::split(), and markup::tag().
Referenced by validate().
|
overridevirtual |
As far as parser is built on stack, some realizations can store stack too.
So they need to know if tag was closed.
Reimplemented from schema_validation::schema_validator.
Definition at line 728 of file schema_validator.cpp.
References schema_validation::schema_validator::active_tag(), schema_validation::schema_validator::close_tag(), condition_nesting_, schema_validation::wml_tag::get_name(), schema_validation::schema_validator::have_active_tag(), tag_stack_, and type_nesting_.
|
private |
Definition at line 931 of file schema_validator.cpp.
References utils::join(), game_config::path, and tag_stack_.
Referenced by validate_key().
|
private |
Definition at line 919 of file schema_validator.cpp.
References cfg, config::get(), config::has_attribute(), schema_validation::schema_validator::queue_message(), schema_derivation_graph_, config_attribute_value::str(), and SUPER_LOOP.
Referenced by validate().
|
staticprivate |
Definition at line 784 of file schema_validator.cpp.
References utils::split(), and utils::wildcard_string_match().
Referenced by check_for_duplicates().
|
overridevirtual |
Is called when parser opens tag.
| name | Name of tag |
| parent | The parent config |
| start_line | Line in file |
| file | Name of file |
| addition |
Reimplemented from schema_validation::schema_validator.
Definition at line 711 of file schema_validator.cpp.
References condition_nesting_, schema_validation::schema_validator::open_tag(), tag_stack_, and type_nesting_.
|
overrideprivatevirtual |
Reimplemented from schema_validation::schema_validator.
Definition at line 961 of file schema_validator.cpp.
References schema_validation::schema_validator::create_exceptions_, DUPLICATE_KEY, schema_validation::duplicate_key_error(), DUPLICATE_TAG, schema_validation::duplicate_tag_error(), schema_validation::schema_validator::message_info::file, schema_validation::inheritance_loop_error(), schema_validation::schema_validator::message_info::key, schema_validation::schema_validator::message_info::line, schema_validation::schema_validator::message_info::n, schema_validation::schema_validator::print(), SUPER_LOOP, schema_validation::schema_validator::message_info::tag, schema_validation::schema_validator::message_info::type, schema_validation::schema_validator::message_info::value, WRONG_PATH, schema_validation::wrong_path_error(), WRONG_TYPE, and schema_validation::wrong_type_error().
|
private |
Definition at line 744 of file schema_validator.cpp.
References cfg, defined_tag_paths_, derivations_, utils::join(), links_, game_config::path, utils::split(), and schema_validation::schema_self_validator::reference::value_.
Referenced by validate().
|
overridevirtual |
Validates config.
Checks if all mandatory elements are present. What exactly is validated depends on validator realization
| cfg | Config to be validated. |
| name | Name of tag |
| start_line | Line in file |
| file | Name of file |
Reimplemented from schema_validation::schema_validator.
Definition at line 805 of file schema_validator.cpp.
References config::all_children_view(), cfg, check_for_duplicates(), defined_tag_paths_, defined_types_, detect_schema_derivation_cycles(), dummy, DUPLICATE_KEY, DUPLICATE_TAG, utils::erase_if(), schema_validation::schema_self_validator::reference::file_, schema_validation::schema_self_validator::reference::line_, schema_validation::schema_self_validator::reference::match(), schema_validation::schema_validator::queue_message(), referenced_tag_paths_, referenced_types_, schema_validation::schema_self_validator::reference::tag_, tag_path_exists(), type_nesting_, schema_validation::schema_validator::validate(), schema_validation::schema_self_validator::reference::value_, WRONG_PATH, and WRONG_TYPE.
|
overridevirtual |
Checks if key is allowed and if its value is valid What exactly is validated depends on validator realization.
| cfg | Config to be validated. |
| name | Name of tag |
| value | The key's value |
| start_line | Line in file |
| file | Name of file |
Reimplemented from schema_validation::schema_validator.
Definition at line 871 of file schema_validator.cpp.
References schema_validation::schema_validator::active_tag(), cfg, condition_nesting_, current_path(), defined_tag_paths_, derivations_, utils::find(), schema_validation::wml_tag::get_name(), schema_validation::schema_validator::have_active_tag(), schema_validation::schema_validator::is_valid(), links_, schema_validation::schema_validator::queue_message(), referenced_tag_paths_, referenced_types_, schema_derivation_graph_, schema_derivation_map_, utils::split(), config_attribute_value::str(), SUPER_LOOP, tag_stack_, and schema_validation::schema_validator::validate_key().
|
private |
Definition at line 244 of file schema_validator.hpp.
Referenced by close_tag(), open_tag(), and validate_key().
|
private |
Definition at line 239 of file schema_validator.hpp.
Referenced by tag_path_exists(), validate(), and validate_key().
|
private |
Definition at line 239 of file schema_validator.hpp.
Referenced by schema_self_validator(), and validate().
|
private |
Definition at line 243 of file schema_validator.hpp.
Referenced by tag_path_exists(), and validate_key().
|
private |
Definition at line 242 of file schema_validator.hpp.
Referenced by tag_path_exists(), and validate_key().
|
private |
Definition at line 240 of file schema_validator.hpp.
Referenced by validate(), and validate_key().
|
private |
Definition at line 240 of file schema_validator.hpp.
Referenced by validate(), and validate_key().
|
private |
Definition at line 255 of file schema_validator.hpp.
Referenced by detect_schema_derivation_cycles(), and validate_key().
|
private |
Definition at line 256 of file schema_validator.hpp.
Referenced by validate_key().
|
private |
Definition at line 241 of file schema_validator.hpp.
Referenced by close_tag(), current_path(), open_tag(), and validate_key().
|
private |
Definition at line 244 of file schema_validator.hpp.
Referenced by close_tag(), open_tag(), and validate().