The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
config_assign.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 #ifndef CONFIG_ASSIGN_H_INCLUDED
15 #define CONFIG_ASSIGN_H_INCLUDED
16 
17 #include <string>
18 #include "config.hpp"
19 
20 class config_of
21 {
22 public:
23  template <typename AT>
24  config_of(const std::string& attrname, AT value)
25  {
26  this->operator()(attrname, value);
27  }
28 
29  config_of(const std::string& tagname, const config& child)
30  {
31  this->operator()(tagname, child);
32  }
33 
34  template <typename AT>
35  config_of& operator()(const std::string& attrname, AT value)
36  {
37  data_[attrname] = value;
38  return *this;
39  }
40 
41  config_of& operator()(const std::string& tagname, const config& child)
42  {
43  data_.add_child(tagname, child);
44  return *this;
45  }
46 
47  config_of& operator()(const std::string& tagname, const config_of& child)
48  {
49  data_.add_child(tagname, child);
50  return *this;
51  }
52 
53  operator config() const
54  {
55  return data_;
56  }
57 private:
59 };
60 #endif
Definitions for the interface to Wesnoth Markup Language (WML).
config_of & operator()(const std::string &tagname, const config_of &child)
GLsizei const GLfloat * value
Definition: glew.h:1817
config data_
config & add_child(const std::string &key)
Definition: config.cpp:743
config_of & operator()(const std::string &tagname, const config &child)
config_of(const std::string &tagname, const config &child)
config_of & operator()(const std::string &attrname, AT value)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
config_of(const std::string &attrname, AT value)