The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
variable_info_detail.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 by David White <[email protected]>
3  Copyright (C) 2005 - 2016 by Philippe Plantier <[email protected]>
4 
5  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 #ifndef VARIABLE_INFO_DETAIL_HPP_INCLUDED
17 #define VARIABLE_INFO_DETAIL_HPP_INCLUDED
18 
19 #include <string>
20 #include "config.hpp"
21 
23 {
26  state_start = 0, // for internal use
27  // only used at the 'starting_pos' of the variable_info::calculate_value algorithm
28  state_named, // the result of .someval this can eigher man an attribute value or an
29  // child range
30  state_indexed, // the result of .someval[index] this is never an attribute value,
31  // this is always a single config.
32  state_temporary, // the result of .length this value can never be written, it can only be read.
33 
34  };
35 
36  //Special case of boost::enable_if
37  template<const variable_info_type vit>
39  {
41  };
42 
43  template<>
45  {
46  };
47 
48  template<const variable_info_type vit, typename T>
49  struct maybe_const
50  {
51  typedef T type;
52  };
53 
54  template <class T>
56  {
57  typedef const T type;
58  };
59 
60  template <>
61  struct maybe_const<vit_const, config::child_itors>
62  {
64  };
65 
66 
67  template<const variable_info_type vit>
69  {
71 
72  variable_info_state(t_child& vars)
73  : child_(&vars)
74  , key_()
75  , index_(0)
76  , temp_val_()
78  {
79  child_ = &vars;
80  }
81 
82  // The meaning of the following 3 depends on 'type_', but usualy the case is:
83  // the current config is child_->child_at(key_, index_).
84  t_child* child_;
86  int index_;
87 
88  // If we have a temporary value like .length
89  // Then we store the result here.
91 
92  // See the definition of 'variable_info_state_type'
94  };
95 }
96 
97 #endif
Definitions for the interface to Wesnoth Markup Language (WML).
std::pair< const_child_iterator, const_child_iterator > const_child_itors
Definition: config.hpp:214
Variant for storing WML attributes.
Definition: config.hpp:223
maybe_const< vit, config >::type t_child
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