The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
configr_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 #pragma once
15 
16 #include <string>
17 #include "config.hpp"
18 #include <boost/variant.hpp>
19 
20 //Similar to config_of but it stores references to configs (instead of cyoping them).
21 struct configr_of
22 {
23  template <typename AT>
24  configr_of(const std::string& attrname, AT value)
25  {
26  this->operator()(attrname, value);
27  }
28 
29  configr_of(const config& cfg)
30  {
31  this->operator()(cfg);
32  }
33 
35  {
36  data_ = &cfg;
37  return *this;
38  }
39 
40  configr_of& operator()(const std::string& tagname, const configr_of& child)
41  {
42  subtags_.push_back(std::make_pair(&tagname, &child));
43  return *this;
44  }
45  std::vector<std::pair<const std::string*, const configr_of*>> subtags_;
46  const config* data_;
47 };
configr_of(const std::string &attrname, AT value)
configr_of & operator()(const std::string &tagname, const configr_of &child)
configr_of & operator()(const config &cfg)
configr_of(const config &cfg)
Definitions for the interface to Wesnoth Markup Language (WML).
GLsizei const GLfloat * value
Definition: glew.h:1817
const config * data_
std::vector< std::pair< const std::string *, const configr_of * > > subtags_
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