The Battle for Wesnoth  1.17.21+dev
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
schema_validation::wml_tag Class Reference

Stores information about tag. More...

#include <tag.hpp>

Inheritance diagram for schema_validation::wml_tag:

Classes

class  iterator
 

Public Types

using tag_map = std::map< std::string, wml_tag >
 
using key_map = std::map< std::string, wml_key >
 
using link_map = std::map< std::string, std::string >
 
using condition_list = std::vector< wml_condition >
 
using super_list = std::vector< wml_tag * >
 

Public Member Functions

 wml_tag ()
 
 wml_tag (const std::string &name, int min, int max, const std::string &super="", bool any=false)
 
 wml_tag (const config &)
 
 ~wml_tag ()
 
void print (std::ostream &os)
 Prints information about tag to outputstream, recursively is used to print tag info the format is next [tag] subtags keys name="name" min="min" max="max" [/tag]. More...
 
const std::string & get_name () const
 
int get_min () const
 
int get_max () const
 
int get_min_children () const
 
int get_max_children () const
 
const std::string & get_super () const
 
bool is_extension () const
 
bool is_fuzzy () const
 
bool accepts_any_tag () const
 
void set_name (const std::string &name)
 
void set_min (int o)
 
void set_max (int o)
 
void set_min_children (int o)
 
void set_max_children (int o)
 
void set_min (const std::string &s)
 
void set_max (const std::string &s)
 
void set_min_children (const std::string &s)
 
void set_max_children (const std::string &s)
 
void set_super (const std::string &s)
 
void set_fuzzy (bool f)
 
void set_any_tag (bool any)
 
void add_key (const wml_key &new_key)
 
void add_tag (const wml_tag &new_tag)
 
void add_link (const std::string &link)
 
void add_switch (const config &switch_cfg)
 
void add_filter (const config &cond_cfg)
 
void add_tag (const std::string &path, const wml_tag &tag, wml_tag &root)
 Tags are usually organized in tree. More...
 
bool operator< (const wml_tag &t) const
 
bool operator== (const wml_tag &other) const
 
const wml_keyfind_key (const std::string &name, const config &match, bool ignore_super=false) const
 Returns pointer to child key. More...
 
const std::string * find_link (const std::string &name) const
 Returns pointer to child link. More...
 
const wml_tagfind_tag (const std::string &fullpath, const wml_tag &root, const config &match, bool ignore_super=false) const
 Returns pointer to tag using full path to it. More...
 
void expand_all (wml_tag &root)
 Calls the expansion on each child. More...
 
boost::iterator_range< tag_iteratortags (const config &cfg_match) const
 
boost::iterator_range< key_iteratorkeys (const config &cfg_match) const
 
const link_maplinks () const
 
const condition_listconditions () const
 
void remove_key_by_name (const std::string &name)
 
void remove_keys_by_type (const std::string &type)
 Removes all keys with this type. More...
 

Private Types

using tag_iterator = iterator< wml_tag >
 
using key_iterator = iterator< wml_key >
 

Private Member Functions

void printl (std::ostream &os, int level, int step=4)
 the same as wml_tag::print(std::ostream&) but indents different levels with step space. More...
 
wml_tagfind_tag (const std::string &fullpath, wml_tag &root, const config &match)
 
void add_tags (const tag_map &list)
 
void add_keys (const key_map &list)
 
void add_links (const link_map &list)
 
void add_conditions (const condition_list &list)
 
void expand (wml_tag &root)
 Expands all "super", storing direct references for easier access. More...
 

Static Private Member Functions

static void push_new_tag_conditions (std::queue< const wml_tag * > &q, const config &match, const wml_tag &tag)
 

Private Attributes

std::string name_
 name of tag. More...
 
int min_
 minimum number of occurrences. More...
 
int max_
 maximum number of occurrences. More...
 
int min_children_
 minimum number of children. More...
 
int max_children_
 maximum number of children. More...
 
std::string super_
 name of tag to extend "super-tag" Extension is smth like inheritance and is used in case when you need to use another tag with all his keys, children, etc. More...
 
tag_map tags_
 children tags More...
 
key_map keys_
 keys More...
 
link_map links_
 links to possible children. More...
 
condition_list conditions_
 conditional partial matches More...
 
super_list super_refs_
 super-tag references More...
 
bool fuzzy_
 whether this is a "fuzzy" tag. More...
 
bool any_tag_
 whether this tag allows arbitrary subtags. More...
 

Friends

template<typename T , typename Map >
class iterator
 

Detailed Description

Stores information about tag.

Each tags is an element of great tag tree. This tree is close to filesystem: you can use links and special include directory global/ Normally root is not mentioned in path. Each tag has name, minimum and maximum occasions number, and lists of subtags, keys and links.

Definition at line 47 of file tag.hpp.

Member Typedef Documentation

◆ condition_list

Definition at line 53 of file tag.hpp.

◆ key_iterator

Definition at line 109 of file tag.hpp.

◆ key_map

using schema_validation::wml_tag::key_map = std::map<std::string, wml_key>

Definition at line 51 of file tag.hpp.

◆ link_map

using schema_validation::wml_tag::link_map = std::map<std::string, std::string>

Definition at line 52 of file tag.hpp.

◆ super_list

Definition at line 54 of file tag.hpp.

◆ tag_iterator

Definition at line 108 of file tag.hpp.

◆ tag_map

using schema_validation::wml_tag::tag_map = std::map<std::string, wml_tag>

Definition at line 50 of file tag.hpp.

Constructor & Destructor Documentation

◆ wml_tag() [1/3]

schema_validation::wml_tag::wml_tag ( )
inline

Definition at line 112 of file tag.hpp.

◆ wml_tag() [2/3]

schema_validation::wml_tag::wml_tag ( const std::string &  name,
int  min,
int  max,
const std::string &  super = "",
bool  any = false 
)
inline

Definition at line 127 of file tag.hpp.

◆ wml_tag() [3/3]

schema_validation::wml_tag::wml_tag ( const config cfg)

◆ ~wml_tag()

schema_validation::wml_tag::~wml_tag ( )
inline

Definition at line 144 of file tag.hpp.

Member Function Documentation

◆ accepts_any_tag()

bool schema_validation::wml_tag::accepts_any_tag ( ) const
inline

Definition at line 200 of file tag.hpp.

References any_tag_.

◆ add_conditions()

void schema_validation::wml_tag::add_conditions ( const condition_list list)
private

Definition at line 350 of file tag.cpp.

◆ add_filter()

void schema_validation::wml_tag::add_filter ( const config cond_cfg)

◆ add_key()

void schema_validation::wml_tag::add_key ( const wml_key new_key)
inline

Definition at line 248 of file tag.hpp.

References schema_validation::wml_key::get_name(), and keys_.

Referenced by wml_tag().

◆ add_keys()

void schema_validation::wml_tag::add_keys ( const key_map list)
inlineprivate

Definition at line 393 of file tag.hpp.

References keys_.

◆ add_link()

void schema_validation::wml_tag::add_link ( const std::string &  link)

Definition at line 101 of file tag.cpp.

References links_.

Referenced by wml_tag().

◆ add_links()

void schema_validation::wml_tag::add_links ( const link_map list)
inlineprivate

Definition at line 398 of file tag.hpp.

References links_.

◆ add_switch()

void schema_validation::wml_tag::add_switch ( const config switch_cfg)

◆ add_tag() [1/2]

void schema_validation::wml_tag::add_tag ( const std::string &  path,
const wml_tag tag,
wml_tag root 
)

Tags are usually organized in tree.

This function helps to add a tag to his exact place in tree

Parameters
path- path in subtree to exact place of tag
tag- tag to add
root- root of schema tree - use to support of adding to link. Path is getting shotter and shoter with each call. Path should look like tag1/tag2/parent/ Slash at end is mandatory.

Definition at line 309 of file tag.cpp.

References add_tag(), get_name(), keys_, links_, max_, min_, name_, game_config::path, set_name(), and tags_.

◆ add_tag() [2/2]

void schema_validation::wml_tag::add_tag ( const wml_tag new_tag)
inline

Definition at line 253 of file tag.hpp.

References name_, and tags_.

Referenced by add_tag(), and wml_tag().

◆ add_tags()

void schema_validation::wml_tag::add_tags ( const tag_map list)
inlineprivate

Definition at line 388 of file tag.hpp.

References tags_.

◆ conditions()

const condition_list& schema_validation::wml_tag::conditions ( ) const
inline

Definition at line 315 of file tag.hpp.

References conditions_.

◆ expand()

void schema_validation::wml_tag::expand ( wml_tag root)
private

Expands all "super", storing direct references for easier access.

Definition at line 355 of file tag.cpp.

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

Referenced by expand_all().

◆ expand_all()

void schema_validation::wml_tag::expand_all ( wml_tag root)

Calls the expansion on each child.

Definition at line 243 of file tag.cpp.

References expand().

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

◆ find_key()

const wml_key * schema_validation::wml_tag::find_key ( const std::string &  name,
const config match,
bool  ignore_super = false 
) const

Returns pointer to child key.

Definition at line 109 of file tag.cpp.

References conditions_, keys_, and utils::wildcard_string_match().

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

◆ find_link()

const std::string * schema_validation::wml_tag::find_link ( const std::string &  name) const

Returns pointer to child link.

Definition at line 155 of file tag.cpp.

◆ find_tag() [1/2]

const wml_tag * schema_validation::wml_tag::find_tag ( const std::string &  fullpath,
const wml_tag root,
const config match,
bool  ignore_super = false 
) const

Returns pointer to tag using full path to it.

Also work with links

Definition at line 165 of file tag.cpp.

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

Referenced by schema_validation::schema_self_validator::reference::can_find(), expand(), find_tag(), and schema_validation::schema_validator::open_tag().

◆ find_tag() [2/2]

wml_tag* schema_validation::wml_tag::find_tag ( const std::string &  fullpath,
wml_tag root,
const config match 
)
inlineprivate

Definition at line 383 of file tag.hpp.

References find_tag().

◆ get_max()

int schema_validation::wml_tag::get_max ( ) const
inline

Definition at line 171 of file tag.hpp.

References max_.

◆ get_max_children()

int schema_validation::wml_tag::get_max_children ( ) const
inline

Definition at line 181 of file tag.hpp.

References max_children_.

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

◆ get_min()

int schema_validation::wml_tag::get_min ( ) const
inline

Definition at line 166 of file tag.hpp.

References min_.

◆ get_min_children()

int schema_validation::wml_tag::get_min_children ( ) const
inline

Definition at line 176 of file tag.hpp.

References min_children_.

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

◆ get_name()

const std::string& schema_validation::wml_tag::get_name ( ) const
inline

◆ get_super()

const std::string& schema_validation::wml_tag::get_super ( ) const
inline

Definition at line 186 of file tag.hpp.

References super_.

◆ is_extension()

bool schema_validation::wml_tag::is_extension ( ) const
inline

Definition at line 191 of file tag.hpp.

References super_.

◆ is_fuzzy()

bool schema_validation::wml_tag::is_fuzzy ( ) const
inline

Definition at line 196 of file tag.hpp.

References fuzzy_.

◆ keys()

boost::iterator_range<key_iterator> schema_validation::wml_tag::keys ( const config cfg_match) const
inline

Definition at line 305 of file tag.hpp.

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

◆ links()

const link_map& schema_validation::wml_tag::links ( ) const
inline

Definition at line 310 of file tag.hpp.

References links_.

◆ operator<()

bool schema_validation::wml_tag::operator< ( const wml_tag t) const
inline

Definition at line 275 of file tag.hpp.

References name_, and t.

◆ operator==()

bool schema_validation::wml_tag::operator== ( const wml_tag other) const
inline

Definition at line 280 of file tag.hpp.

References name_.

◆ print()

void schema_validation::wml_tag::print ( std::ostream &  os)

Prints information about tag to outputstream, recursively is used to print tag info the format is next [tag] subtags keys name="name" min="min" max="max" [/tag].

Definition at line 80 of file tag.cpp.

References printl().

◆ printl()

void schema_validation::wml_tag::printl ( std::ostream &  os,
int  level,
int  step = 4 
)
private

the same as wml_tag::print(std::ostream&) but indents different levels with step space.

Parameters
osstream to print
levelcurrent level of indentation
stepstep to next indent

Definition at line 271 of file tag.cpp.

References game_config::images::level, and s.

Referenced by print().

◆ push_new_tag_conditions()

void schema_validation::wml_tag::push_new_tag_conditions ( std::queue< const wml_tag * > &  q,
const config match,
const wml_tag tag 
)
staticprivate

◆ remove_key_by_name()

void schema_validation::wml_tag::remove_key_by_name ( const std::string &  name)
inline

Definition at line 320 of file tag.hpp.

References keys_.

◆ remove_keys_by_type()

void schema_validation::wml_tag::remove_keys_by_type ( const std::string &  type)

Removes all keys with this type.

Works recursively

Definition at line 255 of file tag.cpp.

References i.

◆ set_any_tag()

void schema_validation::wml_tag::set_any_tag ( bool  any)
inline

Definition at line 244 of file tag.hpp.

References any_tag_.

◆ set_fuzzy()

void schema_validation::wml_tag::set_fuzzy ( bool  f)
inline

Definition at line 240 of file tag.hpp.

References f, and fuzzy_.

◆ set_max() [1/2]

void schema_validation::wml_tag::set_max ( const std::string &  s)

Definition at line 93 of file tag.cpp.

References i, max_, and s.

◆ set_max() [2/2]

void schema_validation::wml_tag::set_max ( int  o)
inline

Definition at line 214 of file tag.hpp.

References max_.

◆ set_max_children() [1/2]

void schema_validation::wml_tag::set_max_children ( const std::string &  s)

◆ set_max_children() [2/2]

void schema_validation::wml_tag::set_max_children ( int  o)
inline

Definition at line 224 of file tag.hpp.

References max_children_.

◆ set_min() [1/2]

void schema_validation::wml_tag::set_min ( const std::string &  s)

Definition at line 85 of file tag.cpp.

References i, min_, and s.

◆ set_min() [2/2]

void schema_validation::wml_tag::set_min ( int  o)
inline

Definition at line 209 of file tag.hpp.

References min_.

◆ set_min_children() [1/2]

void schema_validation::wml_tag::set_min_children ( const std::string &  s)

◆ set_min_children() [2/2]

void schema_validation::wml_tag::set_min_children ( int  o)
inline

Definition at line 219 of file tag.hpp.

References min_children_.

◆ set_name()

void schema_validation::wml_tag::set_name ( const std::string &  name)
inline

Definition at line 204 of file tag.hpp.

References name_.

Referenced by add_tag().

◆ set_super()

void schema_validation::wml_tag::set_super ( const std::string &  s)
inline

Definition at line 235 of file tag.hpp.

References s, and super_.

◆ tags()

boost::iterator_range<tag_iterator> schema_validation::wml_tag::tags ( const config cfg_match) const
inline

Definition at line 300 of file tag.hpp.

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

Friends And Related Function Documentation

◆ iterator

template<typename T , typename Map >
friend class iterator
friend

Definition at line 107 of file tag.hpp.

Member Data Documentation

◆ any_tag_

bool schema_validation::wml_tag::any_tag_
private

whether this tag allows arbitrary subtags.

Definition at line 372 of file tag.hpp.

Referenced by accepts_any_tag(), and set_any_tag().

◆ conditions_

condition_list schema_validation::wml_tag::conditions_
private

conditional partial matches

Definition at line 363 of file tag.hpp.

Referenced by conditions(), find_key(), and push_new_tag_conditions().

◆ fuzzy_

bool schema_validation::wml_tag::fuzzy_
private

whether this is a "fuzzy" tag.

Definition at line 369 of file tag.hpp.

Referenced by is_fuzzy(), and set_fuzzy().

◆ keys_

key_map schema_validation::wml_tag::keys_
private

keys

Definition at line 357 of file tag.hpp.

Referenced by add_key(), add_keys(), add_tag(), find_key(), and remove_key_by_name().

◆ links_

link_map schema_validation::wml_tag::links_
private

links to possible children.

Definition at line 360 of file tag.hpp.

Referenced by add_link(), add_links(), add_tag(), and links().

◆ max_

int schema_validation::wml_tag::max_
private

maximum number of occurrences.

Definition at line 336 of file tag.hpp.

Referenced by add_tag(), get_max(), set_max(), and wml_tag().

◆ max_children_

int schema_validation::wml_tag::max_children_
private

maximum number of children.

Definition at line 342 of file tag.hpp.

Referenced by get_max_children(), set_max_children(), and wml_tag().

◆ min_

int schema_validation::wml_tag::min_
private

minimum number of occurrences.

Definition at line 333 of file tag.hpp.

Referenced by add_tag(), get_min(), and set_min().

◆ min_children_

int schema_validation::wml_tag::min_children_
private

minimum number of children.

Definition at line 339 of file tag.hpp.

Referenced by get_min_children(), and set_min_children().

◆ name_

std::string schema_validation::wml_tag::name_
private

name of tag.

Definition at line 330 of file tag.hpp.

Referenced by add_tag(), get_name(), operator<(), operator==(), and set_name().

◆ super_

std::string schema_validation::wml_tag::super_
private

name of tag to extend "super-tag" Extension is smth like inheritance and is used in case when you need to use another tag with all his keys, children, etc.

But you also want to allow extra subtags of that tags, so just linking that tag wouldn't help at all.

Definition at line 351 of file tag.hpp.

Referenced by get_super(), is_extension(), set_super(), and wml_tag().

◆ super_refs_

super_list schema_validation::wml_tag::super_refs_
private

super-tag references

Definition at line 366 of file tag.hpp.

◆ tags_

tag_map schema_validation::wml_tag::tags_
private

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