Stores information about tag. More...
#include <tag.hpp>
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_key * | find_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_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. More... | |
void | expand_all (wml_tag &root) |
Calls the expansion on each child. More... | |
boost::iterator_range< tag_iterator > | tags (const config &cfg_match) const |
boost::iterator_range< key_iterator > | keys (const config &cfg_match) const |
const link_map & | links () const |
const condition_list & | conditions () 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_tag * | find_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 |
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.
using schema_validation::wml_tag::condition_list = std::vector<wml_condition> |
|
private |
using schema_validation::wml_tag::key_map = std::map<std::string, wml_key> |
using schema_validation::wml_tag::link_map = std::map<std::string, std::string> |
using schema_validation::wml_tag::super_list = std::vector<wml_tag*> |
|
private |
using schema_validation::wml_tag::tag_map = std::map<std::string, wml_tag> |
|
inline |
|
inline |
schema_validation::wml_tag::wml_tag | ( | const config & | cfg | ) |
Definition at line 30 of file tag.cpp.
References add_filter(), add_key(), add_link(), add_switch(), add_tag(), config::child_range(), config::has_attribute(), max_, max_children_, super_, and sw.
|
inline |
|
inline |
|
private |
void schema_validation::wml_tag::add_filter | ( | const config & | cond_cfg | ) |
Definition at line 416 of file tag.cpp.
References config::append_children(), config::child(), config::child_range(), config::clear_children(), conditions_, get_name(), config::has_child(), and i.
|
inline |
Definition at line 249 of file tag.hpp.
References schema_validation::wml_key::get_name(), and keys_.
Referenced by wml_tag().
|
inlineprivate |
void schema_validation::wml_tag::add_link | ( | const std::string & | link | ) |
|
inlineprivate |
Definition at line 399 of file tag.hpp.
References add_conditions(), and expand().
void schema_validation::wml_tag::add_switch | ( | const config & | switch_cfg | ) |
Definition at line 371 of file tag.cpp.
References config::add_child(), config::child(), config::child_range(), conditions_, config::empty(), get_name(), config::has_child(), utils::split(), and utils::STRIP_SPACES.
|
inline |
Definition at line 254 of file tag.hpp.
References add_filter(), add_link(), add_switch(), name_, game_config::path, and tags_.
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
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_, set_name(), and tags_.
|
inlineprivate |
|
inline |
Definition at line 316 of file tag.hpp.
References conditions_.
|
private |
Expands all "super", storing direct references for easier access.
Definition at line 355 of file tag.cpp.
References find_tag(), utils::split(), super_, and super_refs_.
Referenced by add_links().
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 conditions_, and tags_.
Referenced by operator==(), and schema_validation::schema_validator::schema_validator().
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_, super_refs_, and utils::wildcard_string_match().
Referenced by operator==(), and schema_validation::schema_validator::validate_key().
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.
References links_.
Referenced by operator==().
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 schema_validation::any_tag, any_tag_, conditions_, find_tag(), links_, super_refs_, tags_, and utils::wildcard_string_match().
Referenced by schema_validation::schema_self_validator::reference::can_find(), expand(), find_tag(), schema_validation::schema_validator::open_tag(), and operator==().
|
inlineprivate |
Definition at line 384 of file tag.hpp.
References find_tag().
|
inline |
|
inline |
Definition at line 182 of file tag.hpp.
References max_children_.
Referenced by schema_validation::schema_validator::validate().
|
inline |
|
inline |
Definition at line 177 of file tag.hpp.
References min_children_.
Referenced by schema_validation::schema_validator::validate().
|
inline |
Definition at line 162 of file tag.hpp.
References name_.
Referenced by add_filter(), add_switch(), add_tag(), schema_validation::schema_self_validator::close_tag(), schema_validation::schema_validator::validate(), and schema_validation::schema_self_validator::validate_key().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 306 of file tag.hpp.
Referenced by schema_validation::schema_validator::validate().
|
inline |
|
inline |
|
inline |
Definition at line 281 of file tag.hpp.
References expand_all(), find_key(), find_link(), find_tag(), schema_validation::wml_tag::iterator< T, Map >::match, and name_.
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().
Referenced by ~wml_tag().
|
private |
the same as wml_tag::print(std::ostream&) but indents different levels with step space.
os | stream to print |
level | current level of indentation |
step | step to next indent |
Definition at line 271 of file tag.cpp.
References keys_, game_config::images::level, links_, max_, min_, name_, s, super_, and tags_.
Referenced by print().
|
staticprivate |
Definition at line 498 of file tag.cpp.
References conditions_.
Referenced by schema_validation::wml_tag::iterator< T, Map >::ensure_valid_or_end(), and schema_validation::wml_tag::iterator< T, Map >::push_new_tag_conditions().
|
inline |
Definition at line 321 of file tag.hpp.
References keys_, and remove_keys_by_type().
void schema_validation::wml_tag::remove_keys_by_type | ( | const std::string & | type | ) |
|
inline |
|
inline |
|
inline |
void schema_validation::wml_tag::set_max | ( | const std::string & | s | ) |
|
inline |
Definition at line 225 of file tag.hpp.
References max_children_, s, set_max(), set_min(), and set_min_children().
void schema_validation::wml_tag::set_max_children | ( | const std::string & | s | ) |
|
inline |
void schema_validation::wml_tag::set_min | ( | const std::string & | s | ) |
|
inline |
void schema_validation::wml_tag::set_min_children | ( | const std::string & | s | ) |
|
inline |
|
inline |
|
inline |
Definition at line 301 of file tag.hpp.
Referenced by schema_validation::schema_validator::validate().
|
friend |
|
private |
whether this tag allows arbitrary subtags.
Definition at line 373 of file tag.hpp.
Referenced by accepts_any_tag(), find_tag(), and set_any_tag().
|
private |
conditional partial matches
Definition at line 364 of file tag.hpp.
Referenced by add_conditions(), add_filter(), add_switch(), conditions(), expand_all(), find_key(), find_tag(), and push_new_tag_conditions().
|
private |
whether this is a "fuzzy" tag.
Definition at line 370 of file tag.hpp.
Referenced by is_fuzzy(), and set_fuzzy().
|
private |
keys
Definition at line 358 of file tag.hpp.
Referenced by add_key(), add_tag(), schema_validation::wml_tag::iterator< T, Map >::ensure_valid_or_end(), find_key(), printl(), remove_key_by_name(), and remove_keys_by_type().
|
private |
links to possible children.
Definition at line 361 of file tag.hpp.
Referenced by add_link(), add_tag(), find_link(), find_tag(), links(), and printl().
|
private |
|
private |
maximum number of children.
Definition at line 343 of file tag.hpp.
Referenced by get_max_children(), set_max_children(), and wml_tag().
|
private |
|
private |
minimum number of children.
Definition at line 340 of file tag.hpp.
Referenced by get_min_children(), and set_min_children().
|
private |
name of tag.
Definition at line 331 of file tag.hpp.
Referenced by add_tag(), get_name(), operator<(), operator==(), printl(), and set_name().
|
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 352 of file tag.hpp.
Referenced by expand(), get_super(), is_extension(), printl(), set_super(), and wml_tag().
|
private |
super-tag references
Definition at line 367 of file tag.hpp.
Referenced by expand(), find_key(), and find_tag().
|
private |
children tags
Definition at line 355 of file tag.hpp.
Referenced by add_tag(), schema_validation::wml_tag::iterator< T, Map >::ensure_valid_or_end(), expand_all(), find_tag(), schema_validation::wml_tag::iterator< T, Map >::init(), printl(), and remove_keys_by_type().