The Battle for Wesnoth  1.19.5+dev
Classes | Public Member Functions | Private Types | Private Member Functions | Static 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:

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< 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_
 
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_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
 
- Protected Attributes inherited from schema_validation::schema_validator
bool create_exceptions_
 Controls the way to print errors. More...
 

Detailed Description

Definition at line 216 of file schema_validator.hpp.

Member Typedef Documentation

◆ schema_derivation_graph_t

using schema_validation::schema_self_validator::schema_derivation_graph_t = boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, std::string, std::pair<config, reference> >
private

Definition at line 252 of file schema_validator.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
WRONG_TYPE 
WRONG_PATH 
DUPLICATE_TAG 
DUPLICATE_KEY 
SUPER_LOOP 
NEXT_ERROR 

Definition at line 250 of file schema_validator.hpp.

Constructor & Destructor Documentation

◆ schema_self_validator()

schema_validation::schema_self_validator::schema_self_validator ( )

Definition at line 702 of file schema_validator.cpp.

References defined_types_.

Member Function Documentation

◆ check_for_duplicates()

void schema_validation::schema_self_validator::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 
)
private

◆ 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 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_.

◆ current_path()

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

Definition at line 931 of file schema_validator.cpp.

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

Referenced by validate_key().

◆ detect_schema_derivation_cycles()

void schema_validation::schema_self_validator::detect_schema_derivation_cycles ( )
private

◆ name_matches()

bool schema_validation::schema_self_validator::name_matches ( const std::string &  pattern,
const std::string &  name 
)
staticprivate

Definition at line 784 of file schema_validator.cpp.

References utils::split(), and utils::wildcard_string_match().

Referenced by check_for_duplicates().

◆ 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  addition = false 
)
overridevirtual

Is called when parser opens tag.

Parameters
nameName of tag
parentThe parent config
start_lineLine in file
fileName 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_.

◆ print()

void schema_validation::schema_self_validator::print ( message_info message)
overrideprivatevirtual

◆ 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

◆ validate_key()

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

Member Data Documentation

◆ condition_nesting_

int schema_validation::schema_self_validator::condition_nesting_
private

Definition at line 244 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 239 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 239 of file schema_validator.hpp.

Referenced by schema_self_validator(), and validate().

◆ derivations_

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

Definition at line 243 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 242 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 240 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 240 of file schema_validator.hpp.

Referenced by validate(), and validate_key().

◆ schema_derivation_graph_

schema_derivation_graph_t schema_validation::schema_self_validator::schema_derivation_graph_
private

Definition at line 255 of file schema_validator.hpp.

Referenced by detect_schema_derivation_cycles(), and validate_key().

◆ schema_derivation_map_

std::map<std::string, schema_derivation_graph_t::vertex_descriptor> schema_validation::schema_self_validator::schema_derivation_map_
private

Definition at line 256 of file schema_validator.hpp.

Referenced by validate_key().

◆ tag_stack_

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

Definition at line 241 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 244 of file schema_validator.hpp.

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


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