The Battle for Wesnoth  1.19.5+dev
Classes | Public Member Functions | Public Attributes | List of all members
abstract_validator Class Referenceabstract

Used in parsing config file. More...

#include <validator.hpp>

Inheritance diagram for abstract_validator:

Classes

struct  error
 Used to manage with not initialized validators Supposed to be thrown from the constructor. More...
 

Public Member Functions

 abstract_validator (const std::string &name)
 Constructor of validator can throw validator::error. More...
 
virtual ~abstract_validator ()
 
virtual void open_tag (const std::string &name, const config &parent, int start_line, const std::string &file, bool addition=false)=0
 Is called when parser opens tag. More...
 
virtual void close_tag ()=0
 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)=0
 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)=0
 Checks if key is allowed and if its value is valid What exactly is validated depends on validator realization. More...
 

Public Attributes

const std::string name_
 

Detailed Description

Used in parsing config file.

parser.cpp Contains virtual methods, which are called by parser and take information about config to be validated

Definition at line 37 of file validator.hpp.

Constructor & Destructor Documentation

◆ abstract_validator()

abstract_validator::abstract_validator ( const std::string &  name)
inline

Constructor of validator can throw validator::error.

Exceptions
abstract_validator::error

Definition at line 44 of file validator.hpp.

◆ ~abstract_validator()

virtual abstract_validator::~abstract_validator ( )
inlinevirtual

Definition at line 46 of file validator.hpp.

Member Function Documentation

◆ close_tag()

virtual void abstract_validator::close_tag ( )
pure virtual

As far as parser is built on stack, some realizations can store stack too.

So they need to know if tag was closed.

Implemented in schema_validation::schema_self_validator, and schema_validation::schema_validator.

◆ open_tag()

virtual void abstract_validator::open_tag ( const std::string &  name,
const config parent,
int  start_line,
const std::string &  file,
bool  addition = false 
)
pure virtual

Is called when parser opens tag.

Parameters
nameName of tag
parentThe parent config
start_lineLine in file
fileName of file
addition

Implemented in schema_validation::schema_self_validator, and schema_validation::schema_validator.

◆ validate()

virtual void abstract_validator::validate ( const config cfg,
const std::string &  name,
int  start_line,
const std::string &  file 
)
pure virtual

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

Implemented in schema_validation::schema_self_validator, and schema_validation::schema_validator.

◆ validate_key()

virtual void abstract_validator::validate_key ( const config cfg,
const std::string &  name,
const config_attribute_value value,
int  start_line,
const std::string &  file 
)
pure virtual

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
valueThe key's value
start_lineLine in file
fileName of file

Implemented in schema_validation::schema_self_validator, and schema_validation::schema_validator.

Member Data Documentation

◆ name_

const std::string abstract_validator::name_

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