#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... | |
![]() | |
virtual | ~schema_validator () |
schema_validator (const std::string &filename, bool validate_schema=false) | |
Initializes validator from file. More... | |
void | set_create_exceptions (bool value) |
![]() | |
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 } |
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 |
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_ |
Additional Inherited Members | |
![]() | |
const std::string | name_ |
![]() | |
enum | { WRONG_TAG , EXTRA_TAG , MISSING_TAG , EXTRA_KEY , MISSING_KEY , WRONG_VALUE , NEXT_ERROR } |
using | message_type = int |
![]() | |
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 |
![]() | |
bool | create_exceptions_ |
Controls the way to print errors. More... | |
Definition at line 164 of file schema_validator.hpp.
|
private |
Enumerator | |
---|---|
WRONG_TYPE | |
WRONG_PATH | |
DUPLICATE_TAG | |
DUPLICATE_KEY | |
SUPER_LOOP | |
NEXT_ERROR |
Definition at line 198 of file schema_validator.hpp.
schema_validation::schema_self_validator::schema_self_validator | ( | ) |
Definition at line 431 of file schema_validator.cpp.
References defined_types_.
|
private |
Definition at line 521 of file schema_validator.cpp.
References draw::line(), name_matches(), schema_validation::schema_validator::queue_message(), and utils::split().
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 457 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 632 of file schema_validator.cpp.
References utils::join(), game_config::path, and tag_stack_.
Referenced by validate_key().
|
staticprivate |
Definition at line 513 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 440 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 662 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 473 of file schema_validator.cpp.
References 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 534 of file schema_validator.cpp.
References config::all_children_range(), check_for_duplicates(), defined_tag_paths_, defined_types_, DUPLICATE_KEY, DUPLICATE_TAG, schema_validation::schema_self_validator::reference::match(), schema_validation::schema_validator::queue_message(), referenced_tag_paths_, referenced_types_, tag_path_exists(), type_nesting_, schema_validation::schema_validator::validate(), 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 598 of file schema_validator.cpp.
References schema_validation::schema_validator::active_tag(), condition_nesting_, current_path(), defined_tag_paths_, derivations_, 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_, utils::split(), config_attribute_value::str(), SUPER_LOOP, tag_stack_, and schema_validation::schema_validator::validate_key().
|
private |
Definition at line 192 of file schema_validator.hpp.
Referenced by close_tag(), open_tag(), and validate_key().
|
private |
Definition at line 187 of file schema_validator.hpp.
Referenced by tag_path_exists(), validate(), and validate_key().
|
private |
Definition at line 187 of file schema_validator.hpp.
Referenced by schema_self_validator(), and validate().
|
private |
Definition at line 191 of file schema_validator.hpp.
Referenced by tag_path_exists(), and validate_key().
|
private |
Definition at line 190 of file schema_validator.hpp.
Referenced by tag_path_exists(), and validate_key().
|
private |
Definition at line 188 of file schema_validator.hpp.
Referenced by validate(), and validate_key().
|
private |
Definition at line 188 of file schema_validator.hpp.
Referenced by validate(), and validate_key().
|
private |
Definition at line 189 of file schema_validator.hpp.
Referenced by close_tag(), current_path(), open_tag(), and validate_key().
|
private |
Definition at line 192 of file schema_validator.hpp.
Referenced by close_tag(), open_tag(), and validate().