40 : name_(cfg[
"name"].str())
41 , type_(cfg[
"type"].str())
55 for (
int j=0;j<
level;j++){
59 << s <<
" name=\""<<
name_ <<
"\"\n"
60 << s <<
" type=\""<<
type_ <<
"\"\n";
62 os << s <<
" mandatory=\"true\"\n";
64 os << s <<
" default="<<
default_ <<
"\n";
66 os << s <<
"[/key]\n";
69 : name_(cfg[
"name"].str())
70 , min_(cfg[
"min"].to_int())
71 , max_(cfg[
"max"].to_int())
81 super_ = cfg[
"super"].str();
102 std::string::size_type pos_last = link.rfind(
'/');
104 std::string name_link = link.substr(pos_last+1,link.length());
105 links_.insert(std::pair<std::string,std::string>(name_link,link));
109 key_map::const_iterator it_keys =
keys_.find(name);
110 if ( it_keys!=
keys_.end() ){
111 return &(it_keys->second);
117 link_map::const_iterator it_links =
links_.find(name);
118 if ( it_links!=
links_.end() ){
119 return &(it_links->second);
126 if (fullpath.empty())
return nullptr;
127 std::string::size_type
pos = fullpath.find(
'/');
130 if (pos != std::string::npos) {
131 name = fullpath.substr(0,pos);
132 next_path = fullpath.substr(pos+1,fullpath.length());
136 tag_map::const_iterator it_tags =
tags_.find(name);
137 if (it_tags !=
tags_.end()){
138 if (next_path.empty()){
139 return &(it_tags->second);
141 return it_tags->second.find_tag(next_path,root);
144 link_map::const_iterator it_links =
links_.find(name);
145 if (it_links !=
links_.end()){
146 return root.
find_tag(it_links->second +
"/" +next_path,root);
154 i->second.expand(root);
155 i->second.expand_all(root);
160 while(i !=
keys_.end()) {
161 if(i->second.get_type() ==
type) {
168 t->second.remove_keys_by_type(type);
200 for (
int j=0;j<
level;j++){
204 << s <<
" name=\""<<
name_ <<
"\"\n"
205 << s <<
" min=\""<<
min_ <<
"\"\n"
206 << s <<
" max=\""<<
max_ <<
"\"\n";
208 os<< s <<
" super=\""<<
super_ <<
"\"\n";
212 i->second.printl(os,level+step,step);
216 os << s <<
"" <<
"[link]\n"
217 << s <<
"" <<
" name=\"" <<
i->second <<
"\"\n"
218 << s <<
"" <<
"[/link]\n";
222 i->second.print(os,level+step);
224 os<< s <<
"[/tag]\n";
229 if (fullpath.empty())
return nullptr;
230 std::string::size_type
pos = fullpath.find(
'/');
233 if (pos != std::string::npos) {
234 name = fullpath.substr(0,pos);
235 next_path = fullpath.substr(pos+1,fullpath.length());
241 if (it_tags !=
tags_.end()){
242 if (next_path.empty()){
243 return &(it_tags->second);
245 return it_tags->second.find_tag(next_path,root);
249 if (it_links !=
links_.end()){
250 return root.
find_tag(it_links->second +
"/" +next_path,root);
270 if ( path.empty() || path ==
"/" ){
272 if (it ==
tags_.end()){
275 it->second.set_min(tag.
min_);
276 it->second.set_max(tag.
max_);
277 it->second.add_tags(tag.
tags_);
278 it->second.add_keys(tag.
keys_);
279 it->second.add_links(tag.
links_);
284 std::string::size_type
pos = path.find(
'/');
286 std::string next_path = path.substr(pos+1,path.length());
288 link_map::const_iterator it_links=
links_.find(name);
289 if (it_links !=
links_.end()){
290 root.
add_tag(it_links->second +
"/" + next_path,tag,root);
293 if (it_tags ==
tags_.end()){
296 subtag.
add_tag(next_path,tag,root);
300 it_tags->second.add_tag(next_path,tag,root);
306 for (tag_map::const_iterator
i = tag.
tags_.begin();
i!=tag.
tags_.end();++
i){
317 if (super_tag !=
this){
322 std::cerr <<
"the same" << super_tag->
name_ <<
"\n";
void remove_keys_by_type(const std::string &type)
Removes all keys with this type.
child_itors child_range(const std::string &key)
bool is_mandatory() const
std::string name_
Name of key.
void expand(class_tag &root)
Expands all "super" copying their data to this.
const class_tag * find_tag(const std::string &fullpath, const class_tag &root) const
Returns pointer to tag using full path to it.
const class_key * find_key(const std::string &name) const
Returns pointer to child key.
std::pair< std::string, class_tag > tag_map_value
GLuint GLuint GLsizei GLenum type
const std::string * find_link(const std::string &name) const
Returns pointer to child link.
int max_
number of maximum occasions
tag_map::iterator tag_iterator
void add_key(const class_key &new_key)
const std::string & get_name() const
void append_super(const class_tag &tag, const std::string &super)
Copies tags, keys and links of tag to this.
int min_
number of minimum occasions
std::string default_
Default value.
void set_name(const std::string &name)
std::string type_
Type of key.
Definitions for the interface to Wesnoth Markup Language (WML).
class_key is used to save the information about one key.
void print(std::ostream &os, int level) const
is used to print key info the format is next [key] name="name" type="type" default="default" mandator...
This file contains objects "tag" and "key", which are used to store information about tags and keys w...
void expand_all(class_tag &root)
Calls the expansion on each child.
std::string super_
name of tag to extend "super-tag" Extension is smth like inheritance and is used in case when you nee...
GLsizei const char ** path
void add_keys(const key_map &list)
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...
void add_links(const link_map &list)
void add_link(const std::string &link)
link_map links_
links to possible children.
tag_map tags_
children tags
GLuint const GLchar * name
void add_tag(const class_tag &new_tag)
bool has_attribute(const std::string &key) const
std::string name_
name of tag
bool mandatory_
Shows, if key is a mandatory key.
A config object defines a single node in a WML file, with access to child nodes.
key_map::iterator key_iterator
GLsizei const GLcharARB ** string
Stores information about tag.
void print(std::ostream &os)
Prints information about tag to outputstream, recursively is used to print tag info the format is nex...