The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Functions | Variables
schema_validation Namespace Reference

Classes

class  class_error_container
 Container of errors, which are generated while schema generator tool is parsing source files. More...
 
class  class_key
 class_key is used to save the information about one key. More...
 
class  class_source_parser
 
class  class_tag
 Stores information about tag. More...
 
class  schema_validator
 Realization of serialization/validator.hpp abstract validator. More...
 

Functions

static std::string at (const std::string &file, int line)
 
static void print_output (const std::string &message, bool flag_exception=false)
 
static void extra_tag_error (const std::string &file, int line, const std::string &name, int n, const std::string &parent, bool flag_exception)
 
static void wrong_tag_error (const std::string &file, int line, const std::string &name, const std::string &parent, bool flag_exception)
 
static void missing_tag_error (const std::string &file, int line, const std::string &name, int n, const std::string &parent, bool flag_exception)
 
static void extra_key_error (const std::string &file, int line, const std::string &tag, const std::string &key, bool flag_exception)
 
static void missing_key_error (const std::string &file, int line, const std::string &tag, const std::string &key, bool flag_exception)
 
static void wrong_value_error (const std::string &file, int line, const std::string &tag, const std::string &key, const std::string &value, bool flag_exception)
 
static std::string sub (const std::string &s)
 Private function to surround an argument with brackets. More...
 
static std::string quote (const std::string &s)
 Private function to surround argument with not mandatory quotes. More...
 
static std::string property (const std::string &name, const std::string &value="")
 Creates a property template. More...
 
const std::stringget_valid ()
 A few regex templates. More...
 
const std::stringget_wiki ()
 Template to check line is beginnnig of Wiki block. More...
 
const std::stringget_parent_begin ()
 Template to check begining of parent block. More...
 
const std::stringget_parent_end ()
 Template to check closing of parent block. More...
 
const std::stringget_tag_begin ()
 Template to check if line contains opening of tag block. More...
 
const std::stringget_tag_end ()
 Template to check end of tag block. More...
 
const std::stringget_allow_link ()
 Template to check allow{link} block. More...
 
const std::stringget_allow_global ()
 Template to check allow{global} block. More...
 
static const std::stringget_allow_type ()
 
static const std::stringget_remove_type ()
 
static const std::stringget_remove_key ()
 
const std::stringget_table_key_begin ()
 Template to check begining of table{config} storing key values. More...
 
const std::stringget_table_end ()
 Template to check if table is closed. More...
 
const std::stringget_key_value ()
 Template to get key value. More...
 
void test_regex (std::ostream &f)
 Writes to the file regex templates list. More...
 

Variables

static lg::log_domain log_validation ("validation")
 
const std::string valid = "^\\s*\\*\\s*"
 Little parts of regex templates used to parse Wml annoations. More...
 
const std::string wiki_begin ="^\\s*/\\*(?:WIKI|SCHEMA)"
 begining of wiki block More...
 
const std::string space ="\\s*"
 whitespace is possible More...
 
const std::string equals ="="
 sigh "=" More...
 
const std::string quote_symbol ="\"?"
 non-mandatory sign " More...
 
const std::string block_begin ="@begin"
 begining of the block. More...
 
const std::string block_end ="@end"
 end of block More...
 
const std::string allow ="@allow"
 allow directive More...
 
const std::string remove ="@remove"
 remove directive More...
 
const std::string property_open ="\\{"
 sign "{" - curly bracket More...
 
const std::string property_close = "\\}"
 sign "}" - another curly bracket More...
 
const std::string name_type = "[a-z][a-zA-Z0-9_-]*"
 type of possible name identificator More...
 
const std::string parent_type = "/|(?:[a-z][a-zA-Z0-9_-]*/)+"
 type of possible parent indentificator More...
 
const std::string link_type ="(?:[a-z][a-zA-Z0-9_-]*/)*(?:[a-z][a-zA-Z0-9_-]*)"
 type of possible link indentificator More...
 
const std::string number ="\\d*"
 template to number regex More...
 
const std::string sign ="-?"
 sign "-" - hyphen-minus used to set sign of signed integer More...
 
const std::string eol =".*$"
 end of line + possible various character before. More...
 

Function Documentation

static std::string schema_validation::at ( const std::string file,
int  line 
)
static
static void schema_validation::extra_key_error ( const std::string file,
int  line,
const std::string tag,
const std::string key,
bool  flag_exception 
)
static

Definition at line 82 of file schema_validator.cpp.

References at(), and print_output().

Referenced by schema_validation::schema_validator::print().

static void schema_validation::extra_tag_error ( const std::string file,
int  line,
const std::string name,
int  n,
const std::string parent,
bool  flag_exception 
)
static

Definition at line 52 of file schema_validator.cpp.

References at(), and print_output().

Referenced by schema_validation::schema_validator::print().

const std::string & schema_validation::get_allow_global ( )

Template to check allow{global} block.

Definition at line 150 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_allow_global(), and test_regex().

const std::string & schema_validation::get_allow_link ( )

Template to check allow{link} block.

Definition at line 144 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_allow_link(), and test_regex().

static const std::string& schema_validation::get_allow_type ( )
static

Definition at line 156 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_allow_type(), and test_regex().

const std::string & schema_validation::get_key_value ( )

Template to get key value.

Definition at line 189 of file sourceparser.cpp.

References eol, quote(), and sub().

Referenced by schema_validation::class_source_parser::parse_keys(), and test_regex().

const std::string & schema_validation::get_parent_begin ( )

Template to check begining of parent block.

Definition at line 109 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_parent_begin(), and test_regex().

const std::string & schema_validation::get_parent_end ( )

Template to check closing of parent block.

Definition at line 117 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_parent_end(), and test_regex().

static const std::string& schema_validation::get_remove_key ( )
static

Definition at line 169 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_remove_key().

static const std::string& schema_validation::get_remove_type ( )
static

Definition at line 163 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_remove_type().

const std::string & schema_validation::get_table_end ( )

Template to check if table is closed.

Definition at line 182 of file sourceparser.cpp.

References eol, and property().

Referenced by schema_validation::class_source_parser::check_keys_end(), and test_regex().

const std::string & schema_validation::get_table_key_begin ( )

Template to check begining of table{config} storing key values.

Definition at line 176 of file sourceparser.cpp.

References eol, and property().

Referenced by schema_validation::class_source_parser::check_keys_begin(), and test_regex().

const std::string & schema_validation::get_tag_begin ( )

Template to check if line contains opening of tag block.

Definition at line 123 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_tag_begin(), and test_regex().

const std::string & schema_validation::get_tag_end ( )

Template to check end of tag block.

Definition at line 137 of file sourceparser.cpp.

References eol, property(), and sub().

Referenced by schema_validation::class_source_parser::check_tag_end(), and test_regex().

const std::string & schema_validation::get_valid ( )

A few regex templates.

Please notice, that adding any regex template, schould be called in test_regexes()Template to check line of beeing valid

Definition at line 100 of file sourceparser.cpp.

References valid.

Referenced by schema_validation::class_source_parser::check_valid(), and test_regex().

const std::string & schema_validation::get_wiki ( )

Template to check line is beginnnig of Wiki block.

Definition at line 104 of file sourceparser.cpp.

References eol.

Referenced by schema_validation::class_source_parser::check_wiki(), and test_regex().

static void schema_validation::missing_key_error ( const std::string file,
int  line,
const std::string tag,
const std::string key,
bool  flag_exception 
)
static

Definition at line 92 of file schema_validator.cpp.

References at(), and print_output().

Referenced by schema_validation::schema_validator::print().

static void schema_validation::missing_tag_error ( const std::string file,
int  line,
const std::string name,
int  n,
const std::string parent,
bool  flag_exception 
)
static

Definition at line 72 of file schema_validator.cpp.

References at(), and print_output().

Referenced by schema_validation::schema_validator::print().

static void schema_validation::print_output ( const std::string message,
bool  flag_exception = false 
)
static
static std::string schema_validation::property ( const std::string name,
const std::string value = "" 
)
static

Creates a property template.

Parameters
nameName of property
valueType of property value If value is empty creates simple property like {table} Else creates a named property like {name="[name_type_template]"}

Definition at line 91 of file sourceparser.cpp.

References property_close, and quote().

Referenced by get_allow_global(), get_allow_link(), get_allow_type(), get_parent_begin(), get_parent_end(), get_remove_key(), get_remove_type(), get_table_end(), get_table_key_begin(), get_tag_begin(), and get_tag_end().

static std::string schema_validation::quote ( const std::string s)
static

Private function to surround argument with not mandatory quotes.

Is used when creating properties

Definition at line 80 of file sourceparser.cpp.

References quote_symbol.

Referenced by get_key_value(), and property().

static std::string schema_validation::sub ( const std::string s)
static
void schema_validation::test_regex ( std::ostream &  f)
static void schema_validation::wrong_tag_error ( const std::string file,
int  line,
const std::string name,
const std::string parent,
bool  flag_exception 
)
static
static void schema_validation::wrong_value_error ( const std::string file,
int  line,
const std::string tag,
const std::string key,
const std::string value,
bool  flag_exception 
)
static

Definition at line 102 of file schema_validator.cpp.

References at(), and print_output().

Referenced by schema_validation::schema_validator::print().

Variable Documentation

const std::string schema_validation::allow ="@allow"

allow directive

Definition at line 44 of file sourceparser.cpp.

const std::string schema_validation::block_begin ="@begin"

begining of the block.

Definition at line 40 of file sourceparser.cpp.

const std::string schema_validation::block_end ="@end"

end of block

Definition at line 42 of file sourceparser.cpp.

const std::string schema_validation::eol =".*$"

end of line + possible various character before.

Used to close template. ".*" is used cause I dont want to get error every misprint whitespace after annotation element

Definition at line 68 of file sourceparser.cpp.

Referenced by get_allow_global(), get_allow_link(), get_allow_type(), get_key_value(), get_parent_begin(), get_parent_end(), get_remove_key(), get_remove_type(), get_table_end(), get_table_key_begin(), get_tag_begin(), get_tag_end(), get_wiki(), print_option(), and display::refresh_report().

const std::string schema_validation::equals ="="

sigh "="

Definition at line 36 of file sourceparser.cpp.

const std::string schema_validation::link_type ="(?:[a-z][a-zA-Z0-9_-]*/)*(?:[a-z][a-zA-Z0-9_-]*)"

type of possible link indentificator

Definition at line 56 of file sourceparser.cpp.

lg::log_domain schema_validation::log_validation("validation")
static
const std::string schema_validation::name_type = "[a-z][a-zA-Z0-9_-]*"

type of possible name identificator

Definition at line 52 of file sourceparser.cpp.

Referenced by default_map_generator_job::default_generate_map().

const std::string schema_validation::number ="\\d*"
const std::string schema_validation::parent_type = "/|(?:[a-z][a-zA-Z0-9_-]*/)+"

type of possible parent indentificator

Definition at line 54 of file sourceparser.cpp.

const std::string schema_validation::property_close = "\\}"

sign "}" - another curly bracket

Definition at line 50 of file sourceparser.cpp.

Referenced by property().

const std::string schema_validation::property_open ="\\{"

sign "{" - curly bracket

Definition at line 48 of file sourceparser.cpp.

const std::string schema_validation::quote_symbol ="\"?"

non-mandatory sign "

Definition at line 38 of file sourceparser.cpp.

Referenced by quote().

const std::string schema_validation::remove ="@remove"
const std::string schema_validation::sign ="-?"

sign "-" - hyphen-minus used to set sign of signed integer

Definition at line 60 of file sourceparser.cpp.

Referenced by gui::slider::set_value().

const std::string schema_validation::space ="\\s*"

whitespace is possible

Definition at line 34 of file sourceparser.cpp.

Referenced by events::console_handler::get_command_flags_description(), and mp::lobby::layout_children().

const std::string schema_validation::valid = "^\\s*\\*\\s*"
const std::string schema_validation::wiki_begin ="^\\s*/\\*(?:WIKI|SCHEMA)"

begining of wiki block

Definition at line 32 of file sourceparser.cpp.