The Battle for Wesnoth  1.15.0-dev
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

using tag_map = std::map< std::string, class_tag >
 
using key_map = std::map< std::string, class_key >
 
using link_map = std::map< std::string, std::string >
 

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::string & get_name () const
 
int get_min () const
 
int get_max () const
 
const std::string & get_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 (const std::string &s)
 
void set_max (const std::string &s)
 
void set_super (const std::string &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::string * find_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...
 
const tag_maptags () const
 
const key_mapkeys () const
 
const link_maplinks () 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, children, 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 140 of file tag.hpp.

Member Typedef Documentation

◆ key_map

using schema_validation::class_tag::key_map = std::map<std::string, class_key>

Definition at line 144 of file tag.hpp.

◆ link_map

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

Definition at line 145 of file tag.hpp.

◆ tag_map

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

Definition at line 143 of file tag.hpp.

Constructor & Destructor Documentation

◆ class_tag() [1/3]

schema_validation::class_tag::class_tag ( )
inline

Definition at line 147 of file tag.hpp.

◆ class_tag() [2/3]

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

Definition at line 158 of file tag.hpp.

◆ class_tag() [3/3]

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

◆ ~class_tag()

schema_validation::class_tag::~class_tag ( )
inline

Definition at line 171 of file tag.hpp.

References schema_validation::class_key::print().

Member Function Documentation

◆ add_key()

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

Definition at line 249 of file tag.hpp.

References schema_validation::class_key::get_name().

Referenced by class_tag().

◆ add_keys()

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

Definition at line 378 of file tag.hpp.

Referenced by append_super().

◆ add_link()

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

Definition at line 110 of file tag.cpp.

References links_.

Referenced by append_super(), and class_tag().

◆ add_links()

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

Definition at line 383 of file tag.hpp.

Referenced by append_super().

◆ add_tag() [1/2]

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

Definition at line 254 of file tag.hpp.

References name_, and game_config::path.

Referenced by add_tag(), and class_tag().

◆ add_tag() [2/2]

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 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 308 of file tag.cpp.

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

◆ add_tags()

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

Definition at line 373 of file tag.hpp.

◆ append_super()

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 348 of file tag.cpp.

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

Referenced by expand().

◆ expand()

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

Expands all "super" copying their data to this.

Definition at line 359 of file tag.cpp.

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

Referenced by expand().

◆ expand_all()

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

Calls the expansion on each child.

Definition at line 172 of file tag.cpp.

References tags_.

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

◆ find_key()

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

Returns pointer to child key.

Definition at line 118 of file tag.cpp.

References keys_.

◆ find_link()

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

Returns pointer to child link.

Definition at line 128 of file tag.cpp.

References links_.

◆ find_tag() [1/2]

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 138 of file tag.cpp.

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

Referenced by expand(), and find_tag().

◆ find_tag() [2/2]

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

Definition at line 257 of file tag.cpp.

References find_tag(), keys_, links_, max_, min_, name(), name_, super_, t, and tags_.

◆ get_max()

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

Definition at line 198 of file tag.hpp.

◆ get_min()

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

Definition at line 193 of file tag.hpp.

◆ get_name()

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

Definition at line 188 of file tag.hpp.

References schema_validation::class_key::name_.

Referenced by add_tag().

◆ get_super()

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

Definition at line 203 of file tag.hpp.

◆ is_extension()

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

Definition at line 208 of file tag.hpp.

◆ keys()

const key_map& schema_validation::class_tag::keys ( ) const
inline

Definition at line 302 of file tag.hpp.

◆ links()

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

Definition at line 307 of file tag.hpp.

◆ operator<()

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

Definition at line 272 of file tag.hpp.

References schema_validation::class_key::name_, and name_.

◆ operator==()

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

Definition at line 277 of file tag.hpp.

References name(), schema_validation::class_key::name_, and name_.

◆ print()

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 105 of file tag.cpp.

References printl().

◆ printl()

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 221 of file tag.cpp.

References keys_, game_config::images::level, links_, max_, min_, name_, s, super_, and tags_.

Referenced by print().

◆ remove_key_by_name()

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

Definition at line 312 of file tag.hpp.

◆ remove_keys_by_type()

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

Removes all keys with this type.

Works recursively

Definition at line 180 of file tag.cpp.

References i, keys_, and tags_.

◆ set_max() [1/2]

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

Definition at line 223 of file tag.hpp.

◆ set_max() [2/2]

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

Definition at line 236 of file tag.hpp.

References i.

◆ set_min() [1/2]

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

Definition at line 218 of file tag.hpp.

◆ set_min() [2/2]

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

Definition at line 228 of file tag.hpp.

References i.

◆ set_name()

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

Definition at line 213 of file tag.hpp.

References name(), and schema_validation::class_key::name_.

Referenced by add_tag().

◆ set_super()

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

Definition at line 244 of file tag.hpp.

References s.

◆ tags()

const tag_map& schema_validation::class_tag::tags ( ) const
inline

Definition at line 297 of file tag.hpp.

Member Data Documentation

◆ keys_

key_map schema_validation::class_tag::keys_
private

keys

Definition at line 354 of file tag.hpp.

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

◆ links_

link_map schema_validation::class_tag::links_
private

links to possible children.

Definition at line 357 of file tag.hpp.

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

◆ max_

int schema_validation::class_tag::max_
private

number of maximum occasions.

Definition at line 339 of file tag.hpp.

Referenced by add_tag(), class_tag(), find_tag(), and printl().

◆ min_

int schema_validation::class_tag::min_
private

number of minimum occasions.

Definition at line 336 of file tag.hpp.

Referenced by add_tag(), find_tag(), and printl().

◆ name_

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

name of tag.

Definition at line 333 of file tag.hpp.

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

◆ super_

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

Referenced by class_tag(), expand(), find_tag(), and printl().

◆ tags_

tag_map schema_validation::class_tag::tags_
private

children tags

Definition at line 351 of file tag.hpp.

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


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