Stores information about tag. More...
#include <tag.hpp>
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 (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_key * | find_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_tag * | find_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_tag * | find_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... | |
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.
typedef std::pair<key_iterator,key_iterator> schema_validation::class_tag::all_key_iterators |
typedef std::pair<link_iterator,link_iterator> schema_validation::class_tag::all_link_iterators |
typedef std::pair<tag_iterator,tag_iterator> schema_validation::class_tag::all_tag_iterators |
typedef key_map::const_iterator schema_validation::class_tag::const_key_iterator |
typedef link_map::const_iterator schema_validation::class_tag::const_link_iterator |
typedef tag_map::const_iterator schema_validation::class_tag::const_tag_iterator |
typedef key_map::iterator schema_validation::class_tag::key_iterator |
typedef std::map<std::string,class_key> schema_validation::class_tag::key_map |
typedef std::pair<std::string,class_key> schema_validation::class_tag::key_map_value |
typedef link_map::iterator schema_validation::class_tag::link_iterator |
typedef std::map<std::string,std::string> schema_validation::class_tag::link_map |
typedef std::pair<std::string,std::string> schema_validation::class_tag::link_map_value |
typedef tag_map::iterator schema_validation::class_tag::tag_iterator |
typedef std::map<std::string,class_tag> schema_validation::class_tag::tag_map |
typedef std::pair<std::string,class_tag> schema_validation::class_tag::tag_map_value |
|
inline |
schema_validation::class_tag::class_tag | ( | const config & | cfg | ) |
Definition at line 68 of file tag.cpp.
References add_key(), add_link(), add_tag(), config::child_range(), config::has_attribute(), max_, and super_.
Definition at line 229 of file tag.hpp.
References schema_validation::class_key::get_name(), and keys_.
Referenced by class_tag().
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().
Definition at line 345 of file tag.hpp.
Referenced by append_super().
Definition at line 232 of file tag.hpp.
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
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_.
|
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().
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().
Calls the expansion on each child.
Definition at line 152 of file tag.cpp.
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 |
const std::string * schema_validation::class_tag::find_link | ( | const std::string & | name | ) | const |
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().
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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().
the same as class_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 197 of file tag.cpp.
References i, keys_, links_, max_, min_, name_, super_, and tags_.
Referenced by print().
|
inline |
void schema_validation::class_tag::remove_keys_by_type | ( | const std::string & | type | ) |
Definition at line 211 of file tag.hpp.
References max_.
Referenced by schema_validation::class_source_parser::check_tag_begin().
|
inline |
Definition at line 208 of file tag.hpp.
References min_.
Referenced by schema_validation::class_source_parser::check_tag_begin().
|
inline |
|
inline |
Definition at line 205 of file tag.hpp.
References name_.
Referenced by add_tag(), and schema_validation::class_source_parser::check_tag_begin().
|
inline |
Definition at line 226 of file tag.hpp.
References super_.
Referenced by schema_validation::class_source_parser::check_tag_begin().
|
inline |
|
private |
keys
Definition at line 321 of file tag.hpp.
Referenced by add_key(), add_tag(), append_super(), find_key(), keys(), printl(), remove_key_by_name(), and remove_keys_by_type().
|
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().
|
private |
|
private |
|
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().
|
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().
|
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().