31 #define DBG_PERSIST LOG_STREAM(debug, log_persist)
32 #define ERR_PERSIST LOG_STREAM(err, log_persist)
57 return "a global variable";
78 for (
size_t i = 0;
i < arrsize;
i++)
87 ERR_PERSIST <<
"cannot store global variable into invalid variablename " << local << std::endl;
94 ctx.
clear_var(global, pcfg[
"immediate"].to_bool());
99 if (pcfg[
"from_local"].empty()) {
117 for (
size_t i = 0;
i < arraylen;
i++)
120 ctx.
set_var(global, val, pcfg[
"immediate"].to_bool());
127 ERR_PERSIST <<
"[get_global_variable] missing required attribute \"from_global\"";
131 ERR_PERSIST <<
"[get_global_variable] missing required attribute \"to_local\"";
136 ERR_PERSIST <<
"[get_global_variable] missing attribute \"namespace\"";
140 DBG_PERSIST <<
"verify_and_get_global_variable with from_global=" << pcfg[
"from_global"] <<
" from side " << pcfg[
"side"] <<
"\n";
144 ERR_PERSIST <<
"[get_global_variable] attribute \"side\" specifies invalid side number." <<
"\n";
147 DBG_PERSIST <<
"end verify_and_get_global_variable with from_global=" << pcfg[
"from_global"] <<
" from side " << pcfg[
"side"] <<
"\n";
155 LOG_PERSIST <<
"Error: [get_global_variable] attribute \"namespace\" is not valid.";
163 ERR_PERSIST <<
"[set_global_variable] missing required attribute \"to_global\"";
167 LOG_PERSIST <<
"Warning: [set_global_variable] missing attribute \"from_local\", global variable will be cleared";
171 ERR_PERSIST <<
"[set_global_variable] missing attribute \"namespace\" and no global namespace provided.";
176 int side = pcfg_side;
178 if (pcfg_side.
str() !=
"global" && !pcfg_side.
empty()) {
181 ERR_PERSIST <<
"[set_global_variable] attribute \"side\" specifies invalid side number.";
184 LOG_PERSIST <<
"[set_global_variable] attribute \"side\" specifies a null-controlled side number.";
188 valid = (*resources::teams)[side - 1].is_local();
198 LOG_PERSIST <<
"Error: [set_global_variable] attribute \"namespace\" is not valid.";
206 ERR_PERSIST <<
"[clear_global_variable] missing required attribute \"from_global\"";
210 ERR_PERSIST <<
"[clear_global_variable] missing attribute \"namespace\" and no global namespace provided.";
215 const int side = pcfg_side.
to_int();
217 if (pcfg_side.
str() !=
"global" && !pcfg_side.
empty()) {
220 ERR_PERSIST <<
"[clear_global_variable] attribute \"side\" specifies invalid side number.";
223 LOG_PERSIST <<
"[clear_global_variable] attribute \"side\" specifies a null-controlled side number.";
227 valid = (*resources::teams)[side - 1].is_local();
237 LOG_PERSIST <<
"Error: [clear_global_variable] attribute \"namespace\" is not valid.";
void verify_and_get_global_variable(const vconfig &pcfg)
play_controller * controller
config get_user_choice(const std::string &name, const user_choice &uch, int side=0)
static void get_global_variable(persist_context &ctx, const vconfig &pcfg)
virtual std::string description() const
static void set_global_variable(persist_context &ctx, const vconfig &pcfg)
virtual config random_choice(int) const
GLuint const GLfloat * val
persist_manager * persist
void verify_and_set_global_variable(const vconfig &pcfg)
config pack_scalar(const std::string &name, const t_string &val)
virtual bool set_var(const std::string &, const config &, bool immediate=false)=0
virtual bool is_visible() const
whether the choice is visible for the user like an advacement choice a non-visible choice is for exam...
bool empty() const
Tests for an attribute that either was never set or was set to "".
virtual config query_user(int) const
Variant for storing WML attributes.
const config & get_variables() const
std::vector< team > * teams
virtual config get_var(const std::string &) const =0
persist_choice(const persist_context &context, const std::string &name, int side_num)
Interface for querying local choices.
void set_variable(const std::string &varname, const t_string &value)
does nothing if varname is no valid variable name.
config & add_child(const std::string &key)
Templates and utility-routines for strings and numbers.
virtual bool clear_var(const std::string &, bool immediate=false)=0
const persist_context & ctx
persist_context & get_context(const std::string &ns)
Information on a WML variable.
unsigned child_count(const std::string &key) const
GLuint const GLchar * name
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
A variable-expanding proxy for the config class.
Standard logging facilities (interface).
int to_int(int def=0) const
static void clear_global_variable(persist_context &ctx, const vconfig &pcfg)
void clear_variable(const std::string &varname)
Clears attributes config children does nothing if varname is no valid variable name.
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
bool has_attribute(const std::string &key) const
< Synonym for operator[]
void verify_and_clear_global_variable(const vconfig &pcfg)
const std::string valid
Little parts of regex templates used to parse Wml annoations.