The Battle for Wesnoth  1.15.3+dev
game_config_view.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 2018 by Andrius Silinskas <silinskas.andrius@gmail.com>
3  Part of the Battle for Wesnoth Project https://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 
15 #pragma once
16 
17 #include "config.hpp"
18 
19 #include <functional>
20 #include <vector>
21 
22 using config_array_view = std::vector<std::reference_wrapper<const config>>;
23 
25 {
26 
27 public:
29  {
30 
31  }
32 
33  static game_config_view wrap(const config& cfg) {
34  return game_config_view(cfg);
35  }
36 
38 
39  const config& find_child(config_key_type key, const std::string &name, const std::string &value) const;
40 
41  const config& child(config_key_type key) const;
42 
43  const config& child_or_empty(config_key_type key) const;
44 
46 
47 
49  {
50  return cfgs_;
51  }
52 
53 private:
54 
55  explicit game_config_view(const config& cfg)
56  : cfgs_()
57  {
58  cfgs_.push_back(cfg);
59  }
61 };
static game_config_view wrap(const config &cfg)
config_array_view child_range(config_key_type key) const
Definitions for the interface to Wesnoth Markup Language (WML).
game_config_view(const config &cfg)
game_config_view merged_children_view(config_key_type key) const
const config & child_or_empty(config_key_type key) const
config_array_view cfgs_
const config & find_child(config_key_type key, const std::string &name, const std::string &value) const
std::vector< std::reference_wrapper< const config > > config_array_view
boost::string_ref config_key_type
Definition: config.hpp:57
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
config_array_view & data()
const config & child(config_key_type key) const