The Battle for Wesnoth  1.15.2+dev
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
schema_validation::schema_self_validator Class Reference

#include <schema_validator.hpp>

Inheritance diagram for schema_validation::schema_self_validator:
Inheritance graph

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 std::string &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)
 
- 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 Member Functions

std::string current_path () const
 
bool tag_path_exists (const config &cfg, const reference &ref)
 

Private Attributes

std::set< std::string > defined_types_
 
std::set< std::string > defined_tag_paths_
 
std::vector< referencereferenced_types_
 
std::vector< referencereferenced_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

- Public Attributes inherited from abstract_validator
const std::string name_
 
- Protected Types inherited from schema_validation::schema_validator
enum  message_type {
  WRONG_TAG, EXTRA_TAG, MISSING_TAG, EXTRA_KEY,
  MISSING_KEY, WRONG_VALUE, WRONG_TYPE, WRONG_PATH
}
 
- Protected Member Functions inherited from schema_validation::schema_validator
void queue_message (const config &cfg, message_type t, const std::string &file, int line=0, int n=0, const std::string &tag="", const std::string &key="", const std::string &value="")
 
const wml_tagactive_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
 

Detailed Description

Definition at line 155 of file schema_validator.hpp.

Constructor & Destructor Documentation

◆ schema_self_validator()

schema_validation::schema_self_validator::schema_self_validator ( )

Definition at line 379 of file schema_validator.cpp.

Member Function Documentation

◆ close_tag()

void schema_validation::schema_self_validator::close_tag ( )
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 402 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_.

◆ current_path()

std::string schema_validation::schema_self_validator::current_path ( ) const
private

Definition at line 521 of file schema_validator.cpp.

References utils::join(), game_config::path, and tag_stack_.

Referenced by validate_key().

◆ open_tag()

void schema_validation::schema_self_validator::open_tag ( const std::string &  name,
const config parent,
int  start_line = 0,
const std::string &  file = "",
bool  addittion = false 
)
overridevirtual

Is called when parser opens tag.

Parameters
nameName of tag
start_lineLine in file
fileName of file

Reimplemented from schema_validation::schema_validator.

Definition at line 385 of file schema_validator.cpp.

References condition_nesting_, schema_validation::schema_validator::open_tag(), tag_stack_, and type_nesting_.

◆ tag_path_exists()

bool schema_validation::schema_self_validator::tag_path_exists ( const config cfg,
const reference ref 
)
private

◆ validate()

void schema_validation::schema_self_validator::validate ( const config cfg,
const std::string &  name,
int  start_line,
const std::string &  file 
)
overridevirtual

Validates config.

Checks if all mandatory elements are present. What exactly is validated depends on validator realization

Parameters
cfgConfig to be validated.
nameName of tag
start_lineLine in file
fileName of file

Reimplemented from schema_validation::schema_validator.

Definition at line 455 of file schema_validator.cpp.

References defined_tag_paths_, defined_types_, dummy, schema_validation::schema_self_validator::reference::match(), schema_validation::schema_validator::queue_message(), referenced_tag_paths_, referenced_types_, sort(), tag_path_exists(), type_nesting_, schema_validation::schema_validator::validate(), schema_validation::schema_validator::WRONG_PATH, and schema_validation::schema_validator::WRONG_TYPE.

◆ validate_key()

void schema_validation::schema_self_validator::validate_key ( const config cfg,
const std::string &  name,
const std::string &  value,
int  start_line,
const std::string &  file 
)
overridevirtual

Checks if key is allowed and if its value is valid What exactly is validated depends on validator realization.

Parameters
cfgConfig to be validated.
nameName of tag
start_lineLine in file
fileName of file

Reimplemented from schema_validation::schema_validator.

Definition at line 494 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_, referenced_tag_paths_, referenced_types_, utils::split(), tag_stack_, and schema_validation::schema_validator::validate_key().

Member Data Documentation

◆ condition_nesting_

int schema_validation::schema_self_validator::condition_nesting_
private

Definition at line 183 of file schema_validator.hpp.

Referenced by close_tag(), open_tag(), and validate_key().

◆ defined_tag_paths_

std::set<std::string> schema_validation::schema_self_validator::defined_tag_paths_
private

Definition at line 178 of file schema_validator.hpp.

Referenced by tag_path_exists(), validate(), and validate_key().

◆ defined_types_

std::set<std::string> schema_validation::schema_self_validator::defined_types_
private

Definition at line 178 of file schema_validator.hpp.

Referenced by validate().

◆ derivations_

std::multimap<std::string, std::string> schema_validation::schema_self_validator::derivations_
private

Definition at line 182 of file schema_validator.hpp.

Referenced by tag_path_exists(), and validate_key().

◆ links_

std::map<std::string, std::string> schema_validation::schema_self_validator::links_
private

Definition at line 181 of file schema_validator.hpp.

Referenced by tag_path_exists(), and validate_key().

◆ referenced_tag_paths_

std::vector<reference> schema_validation::schema_self_validator::referenced_tag_paths_
private

Definition at line 179 of file schema_validator.hpp.

Referenced by validate(), and validate_key().

◆ referenced_types_

std::vector<reference> schema_validation::schema_self_validator::referenced_types_
private

Definition at line 179 of file schema_validator.hpp.

Referenced by validate(), and validate_key().

◆ tag_stack_

std::stack<std::string> schema_validation::schema_self_validator::tag_stack_
private

Definition at line 180 of file schema_validator.hpp.

Referenced by close_tag(), current_path(), open_tag(), and validate_key().

◆ type_nesting_

int schema_validation::schema_self_validator::type_nesting_
private

Definition at line 183 of file schema_validator.hpp.

Referenced by close_tag(), open_tag(), and validate().


The documentation for this class was generated from the following files: