The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
schema_validation::class_tag Class Reference

Stores information about tag. More...

#include <tag.hpp>

Public Types

typedef std::map< std::string,
class_tag
tag_map
 
typedef std::pair< std::string,
class_tag
tag_map_value
 
typedef std::map< std::string,
class_key
key_map
 
typedef std::pair< std::string,
class_key
key_map_value
 
typedef std::map< std::string,
std::string
link_map
 
typedef std::pair< std::string,
std::string
link_map_value
 
typedef key_map::iterator key_iterator
 
typedef std::pair
< key_iterator, key_iterator
all_key_iterators
 
typedef key_map::const_iterator const_key_iterator
 
typedef std::pair
< const_key_iterator,
const_key_iterator
all_const_key_iterators
 
typedef tag_map::iterator tag_iterator
 
typedef std::pair
< tag_iterator, tag_iterator
all_tag_iterators
 
typedef tag_map::const_iterator const_tag_iterator
 
typedef std::pair
< const_tag_iterator,
const_tag_iterator
all_const_tag_iterators
 
typedef link_map::iterator link_iterator
 
typedef std::pair
< link_iterator, link_iterator
all_link_iterators
 
typedef link_map::const_iterator const_link_iterator
 
typedef std::pair
< const_link_iterator,
const_link_iterator
all_const_link_iterators
 

Public Member Functions

 class_tag ()
 
 class_tag (const std::string &name, int min, int max, const std::string &super="")
 
 class_tag (const config &)
 
 ~class_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::stringget_name () const
 
int get_min () const
 
int get_max () const
 
const std::stringget_super () const
 
bool is_extension () const
 
void set_name (const std::string &name)
 
void set_min (int o)
 
void set_max (int o)
 
void set_min (std::string const &s)
 
void set_max (std::string const &s)
 
void set_super (std::string const &s)
 
void add_key (const class_key &new_key)
 
void add_tag (const class_tag &new_tag)
 
void add_link (const std::string &link)
 
void add_tag (const std::string &path, const class_tag &tag, class_tag &root)
 Tags are usually organized in tree. More...
 
bool operator< (const class_tag &t) const
 
bool operator== (const class_tag &other) const
 
const class_keyfind_key (const std::string &name) const
 Returns pointer to child key. More...
 
const std::stringfind_link (const std::string &name) const
 Returns pointer to child link. More...
 
const class_tagfind_tag (const std::string &fullpath, const class_tag &root) const
 Returns pointer to tag using full path to it. More...
 
void expand_all (class_tag &root)
 Calls the expansion on each child. More...
 
all_const_tag_iterators tags () const
 
all_const_key_iterators keys () const
 
all_const_link_iterators links () 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 Member Functions

void printl (std::ostream &os, int level, int step=4)
 the same as class_tag::print(std::ostream&) but indents different levels with step space. More...
 
class_tagfind_tag (const std::string &fullpath, class_tag &root)
 
void add_tags (const tag_map &list)
 
void add_keys (const key_map &list)
 
void add_links (const link_map &list)
 
void append_super (const class_tag &tag, const std::string &super)
 Copies tags, keys and links of tag to this. More...
 
void expand (class_tag &root)
 Expands all "super" copying their data to this. More...
 

Private Attributes

std::string name_
 name of tag More...
 
int min_
 number of minimum occasions More...
 
int max_
 number of maximum occasions 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, childs, etc. More...
 
tag_map tags_
 children tags More...
 
key_map keys_
 keys More...
 
link_map links_
 links to possible children. More...
 

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 116 of file tag.hpp.

Member Typedef Documentation

Definition at line 132 of file tag.hpp.

Definition at line 146 of file tag.hpp.

Definition at line 139 of file tag.hpp.

Definition at line 128 of file tag.hpp.

Definition at line 142 of file tag.hpp.

Definition at line 135 of file tag.hpp.

typedef key_map::const_iterator schema_validation::class_tag::const_key_iterator

Definition at line 130 of file tag.hpp.

typedef link_map::const_iterator schema_validation::class_tag::const_link_iterator

Definition at line 144 of file tag.hpp.

typedef tag_map::const_iterator schema_validation::class_tag::const_tag_iterator

Definition at line 137 of file tag.hpp.

typedef key_map::iterator schema_validation::class_tag::key_iterator

Definition at line 127 of file tag.hpp.

Definition at line 121 of file tag.hpp.

Definition at line 122 of file tag.hpp.

typedef link_map::iterator schema_validation::class_tag::link_iterator

Definition at line 141 of file tag.hpp.

Definition at line 124 of file tag.hpp.

Definition at line 125 of file tag.hpp.

typedef tag_map::iterator schema_validation::class_tag::tag_iterator

Definition at line 134 of file tag.hpp.

Definition at line 118 of file tag.hpp.

Definition at line 119 of file tag.hpp.

Constructor & Destructor Documentation

schema_validation::class_tag::class_tag ( )
inline

Definition at line 148 of file tag.hpp.

schema_validation::class_tag::class_tag ( const std::string name,
int  min,
int  max,
const std::string super = "" 
)
inline

Definition at line 159 of file tag.hpp.

schema_validation::class_tag::class_tag ( const config cfg)
schema_validation::class_tag::~class_tag ( )
inline

Definition at line 174 of file tag.hpp.

Member Function Documentation

void schema_validation::class_tag::add_key ( const class_key new_key)
inline

Definition at line 229 of file tag.hpp.

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

Referenced by class_tag().

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

Definition at line 342 of file tag.hpp.

Referenced by append_super().

void schema_validation::class_tag::add_link ( const std::string link)

Definition at line 101 of file tag.cpp.

References links_.

Referenced by append_super(), and class_tag().

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

Definition at line 345 of file tag.hpp.

Referenced by append_super().

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

Definition at line 232 of file tag.hpp.

References name_, and tags_.

Referenced by add_tag(), class_tag(), and schema_validation::class_source_parser::close_opened_tags().

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

Tags are usually organized in tree.

This fuction helps to add 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 schould look like tag1/tag2/parent/ Slash at end is mandatory.

Definition at line 268 of file tag.cpp.

References add_tag(), get_name(), keys_, links_, max_, min_, name_, pos, set_name(), and tags_.

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

Definition at line 339 of file tag.hpp.

void schema_validation::class_tag::append_super ( const class_tag tag,
const std::string super 
)
private

Copies tags, keys and links of tag to this.

Definition at line 303 of file tag.cpp.

References add_keys(), add_link(), add_links(), i, keys_, links_, and tags_.

Referenced by expand().

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

Expands all "super" copying their data to this.

Definition at line 313 of file tag.cpp.

References append_super(), expand(), find_tag(), name_, and super_.

Referenced by expand().

void schema_validation::class_tag::expand_all ( class_tag root)

Calls the expansion on each child.

Definition at line 152 of file tag.cpp.

References i, and tags_.

Referenced by schema_validation::class_source_parser::expand(), and schema_validation::schema_validator::schema_validator().

const class_key * schema_validation::class_tag::find_key ( const std::string name) const

Returns pointer to child key.

Definition at line 108 of file tag.cpp.

References keys_.

const std::string * schema_validation::class_tag::find_link ( const std::string name) const

Returns pointer to child link.

Definition at line 116 of file tag.cpp.

References links_.

const class_tag * schema_validation::class_tag::find_tag ( const std::string fullpath,
const class_tag root 
) const

Returns pointer to tag using full path to it.

Also work with links

Definition at line 124 of file tag.cpp.

References find_tag(), links_, pos, and tags_.

Referenced by expand(), and find_tag().

class_tag * schema_validation::class_tag::find_tag ( const std::string fullpath,
class_tag root 
)
private

Definition at line 227 of file tag.cpp.

References find_tag(), links_, pos, and tags_.

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

Definition at line 195 of file tag.hpp.

References max_.

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

Definition at line 192 of file tag.hpp.

References min_.

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

Definition at line 189 of file tag.hpp.

References name_.

Referenced by add_tag().

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

Definition at line 198 of file tag.hpp.

References super_.

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

Definition at line 201 of file tag.hpp.

References super_.

all_const_key_iterators schema_validation::class_tag::keys ( ) const
inline

Definition at line 278 of file tag.hpp.

References keys_.

all_const_link_iterators schema_validation::class_tag::links ( ) const
inline

Definition at line 281 of file tag.hpp.

References links_.

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

Definition at line 249 of file tag.hpp.

References name_.

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

Definition at line 252 of file tag.hpp.

References name_.

void schema_validation::class_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 97 of file tag.cpp.

References printl().

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

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

the same as class_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 197 of file tag.cpp.

References i, keys_, links_, max_, min_, name_, super_, and tags_.

Referenced by print().

void schema_validation::class_tag::remove_key_by_name ( const std::string name)
inline

Definition at line 285 of file tag.hpp.

References keys_.

void schema_validation::class_tag::remove_keys_by_type ( const std::string type)

Removes all keys with this type.

Works recursively

Definition at line 158 of file tag.cpp.

References i, keys_, and tags_.

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

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

Definition at line 211 of file tag.hpp.

References max_.

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

void schema_validation::class_tag::set_max ( std::string const &  s)
inline

Definition at line 220 of file tag.hpp.

References i, and max_.

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

Definition at line 208 of file tag.hpp.

References min_.

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

void schema_validation::class_tag::set_min ( std::string const &  s)
inline

Definition at line 214 of file tag.hpp.

References i, and min_.

void schema_validation::class_tag::set_name ( const std::string name)
inline

Definition at line 205 of file tag.hpp.

References name_.

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

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

Definition at line 226 of file tag.hpp.

References super_.

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

all_const_tag_iterators schema_validation::class_tag::tags ( ) const
inline

Definition at line 275 of file tag.hpp.

References tags_.

Member Data Documentation

key_map schema_validation::class_tag::keys_
private
link_map schema_validation::class_tag::links_
private

links to possible children.

Definition at line 323 of file tag.hpp.

Referenced by add_link(), add_tag(), append_super(), find_link(), find_tag(), links(), and printl().

int schema_validation::class_tag::max_
private

number of maximum occasions

Definition at line 309 of file tag.hpp.

Referenced by add_tag(), class_tag(), get_max(), printl(), and set_max().

int schema_validation::class_tag::min_
private

number of minimum occasions

Definition at line 307 of file tag.hpp.

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

std::string schema_validation::class_tag::name_
private

name of tag

Definition at line 305 of file tag.hpp.

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

std::string schema_validation::class_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, childs, 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 317 of file tag.hpp.

Referenced by class_tag(), expand(), get_super(), is_extension(), printl(), and set_super().

tag_map schema_validation::class_tag::tags_
private

children tags

Definition at line 319 of file tag.hpp.

Referenced by add_tag(), append_super(), expand_all(), find_tag(), printl(), remove_keys_by_type(), and tags().


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