30 #include <boost/iterator/iterator_facade.hpp>
50 using tag_map = std::map<std::string, wml_tag>;
51 using key_map = std::map<std::string, wml_key>;
52 using link_map = std::map<std::string, std::string>;
54 using super_list = std::map<std::string, const wml_tag*>;
57 template<
typename T,
typename Map = std::map<std::
string, T>>
58 class iterator :
public boost::iterator_facade<iterator<T, Map>, const typename Map::value_type, std::forward_iterator_tag>
62 std::reference_wrapper<const config>
match;
107 template<
typename T,
typename Map>
friend class iterator;
115 wml_tag(
const std::string& name,
int min,
int max,
const std::string&
super =
"",
bool any =
false);
130 void print(std::ostream& os);
229 void add_link(
const std::string& link);
257 const wml_key*
find_key(
const std::string& name,
const config& match,
bool ignore_super =
false)
const;
260 const std::string*
find_link(
const std::string& name)
const;
271 boost::iterator_range<tag_iterator>
tags(
const config& cfg_match)
const
276 boost::iterator_range<key_iterator>
keys(
const config& cfg_match)
const
281 boost::iterator_range<super_iterator>
super(
const config& cfg_match)
const {
356 void printl(std::ostream& os,
int level,
int step = 4);
365 tags_.insert(list.begin(), list.end());
370 keys_.insert(list.begin(), list.end());
375 links_.insert(list.begin(), list.end());
384 const wml_key*
find_key(
const std::string& name,
const config& match,
bool ignore_super, std::vector<const wml_tag*>& visited)
const;
387 const wml_tag*
find_tag(
const std::string& fullpath,
const wml_tag& root,
const config& match,
bool ignore_super, std::vector<const wml_tag*>& visited)
const;
A config object defines a single node in a WML file, with access to child nodes.
Stores information about a conditional portion of a tag.
wml_condition(const config &info, const config &filter)
bool matches(const config &cfg) const
wml_key is used to save the information about one key.
const std::string & get_name() const
std::reference_wrapper< const config > match
iterator< T, Map >::reference dereference() const
bool equal(const iterator< T, Map > &other) const
iterator(const wml_tag &base_tag, const config &match)
void ensure_valid_or_end()
void push_new_tag_conditions(const wml_tag &tag)
friend class boost::iterator_core_access
std::queue< const wml_tag * > condition_queue
Map::const_iterator current
void init(const wml_tag &base_tag)
Stores information about tag.
void add_link(const std::string &link)
boost::iterator_range< super_iterator > super(const config &cfg_match) const
int get_min_children() const
const link_map & links() const
void expand(wml_tag &root)
Expands all "super", storing direct references for easier access.
void set_super(const std::string &s)
const std::string & get_name() const
std::string super_
name of tag to extend "super-tag" Extension is smth like inheritance and is used in case when you nee...
bool operator<(const wml_tag &t) const
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.
const condition_list & conditions() const
iterator< const wml_tag * > super_iterator
std::map< std::string, const wml_tag * > super_list
std::map< std::string, std::string > link_map
void remove_key_by_name(const std::string &name)
void add_tags(const tag_map &list)
int get_max_children() const
bool operator==(const wml_tag &other) const
void set_name(const std::string &name)
void add_filter(const config &cond_cfg)
int min_children_
minimum number of children.
super_list super_refs_
super-tag references
void add_keys(const key_map &list)
void add_tag(const wml_tag &new_tag)
const std::string * find_link(const std::string &name) const
Returns pointer to child link.
void set_any_tag(bool any)
std::map< std::string, wml_key > key_map
void set_min_children(const std::string &s)
void print(std::ostream &os)
Prints information about tag to outputstream, recursively is used to print tag info the format is nex...
link_map links_
links to possible children.
iterator< wml_tag > tag_iterator
std::string name_
name of tag.
void add_conditions(const condition_list &list)
boost::iterator_range< key_iterator > keys(const config &cfg_match) const
boost::iterator_range< tag_iterator > tags(const config &cfg_match) const
bool fuzzy_
whether this is a "fuzzy" tag.
void remove_keys_by_type(const std::string &type)
Removes all keys with this type.
iterator< wml_key > key_iterator
void add_links(const link_map &list)
int min_
minimum number of occurrences.
std::map< std::string, wml_tag > tag_map
bool accepts_any_tag() const
bool any_tag_
whether this tag allows arbitrary subtags.
void add_switch(const config &switch_cfg)
void set_max_children(const std::string &s)
static void push_new_tag_conditions(std::queue< const wml_tag * > &q, const config &match, const wml_tag &tag)
bool is_extension() const
condition_list conditions_
conditional partial matches
std::vector< wml_condition > condition_list
const wml_key * find_key(const std::string &name, const config &match, bool ignore_super=false) const
Returns pointer to child key.
void set_min_children(int o)
void expand_all(wml_tag &root)
Calls the expansion on each child.
const std::string & get_super() const
tag_map tags_
children tags
wml_tag * find_tag(const std::string &fullpath, wml_tag &root, const config &match)
void add_key(const wml_key &new_key)
int max_
maximum number of occurrences.
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.
int max_children_
maximum number of children.
void set_max_children(int o)
Definitions for the interface to Wesnoth Markup Language (WML).
std::string tag(const std::string &tag_name, Args &&... contents)
This file contains object "key", which is used to store information about keys while annotation parsi...
static map_location::direction s