79 Var(
const Var& var,
bool with_attrs);
117 const
char*
value() const throw ();
120 bool isset() const throw ();
129 const
char*
enqc() const;
143 T
enq(T default_value)
const
145 if (!
isset())
return default_value;
153 void setd(
double val);
156 void setc(
const char* val);
185 void set(
const std::string& val) {
setc(val.c_str()); }
230 void seta(std::auto_ptr<Var> attr);
284 std::string
format(
const char* ifundef =
"(undef)")
const;
292 void print(FILE* out)
const;
300 void print(std::ostream& out)
const;
329 unsigned diff(
const Var& var)
const;
345 template<>
inline int Var::enq()
const {
return enqi(); }
346 template<>
inline float Var::enq()
const {
return (
float)
enqd(); }
347 template<>
inline double Var::enq()
const {
return enqd(); }
348 template<>
inline const char*
Var::enq()
const {
return enqc(); }
349 template<>
inline std::string
Var::enq()
const {
return enqc(); }
double enqd() const
Get the value as a double.
void copy_val_only(const Var &src)
Set the value from another variable, performing conversions if needed.
void set_from_formatted(const char *val)
Set from a value formatted with the format() method.
void set(const char *val)
Shortcuts (use with care, as the semanthics are slightly different depending on the type) ...
Definition: var.h:184
void copy_attrs_if_defined(const Var &src)
Copy all the attributes from another variable, unless they are set to an undefined value...
void set(const std::string &val)
Shortcuts (use with care, as the semanthics are slightly different depending on the type) ...
Definition: var.h:185
void set_binary(const unsigned char *val)
Set the raw, binary value from a string value.
std::string format(const char *ifundef="(undef)") const
Create a formatted string representation of the variable value.
void set(int val)
Shortcuts (use with care, as the semanthics are slightly different depending on the type) ...
Definition: var.h:182
void lua_push(struct lua_State *L)
Push the variable as an object in the lua stack.
void copy_attrs(const Var &src)
Copy all the attributes from another variable.
Holds a wreport variable.
Definition: var.h:50
void setc_truncate(const char *val)
Set the value from a string value, truncating val if it is too long.
int enqi() const
Get the value as an integer.
void unset()
Unset the value.
void set(const Var &var)
Shortcuts (use with care, as the semanthics are slightly different depending on the type) ...
Definition: var.h:186
T enq(T default_value) const
Return the variable value, or the given default value if the variable is not set. ...
Definition: var.h:143
Reports that a feature is still not implemented.
Definition: error.h:293
void set(double val)
Shortcuts (use with care, as the semanthics are slightly different depending on the type) ...
Definition: var.h:183
bool value_equals(const Var &var) const
Test if the values are the same, regardless of variable codes or attributes.
Varinfo info() const
Get informations about the variable.
void seta(const Var &attr)
Set an attribute of the variable.
bool operator!=(const Var &var) const
Equality.
Definition: var.h:102
const char * enqc() const
Get the value as a string.
void print(FILE *out) const
Print the variable to an output stream.
void print_without_attrs(FILE *out) const
Print the variable to an output stream, without its attributes.
void setc(const char *val)
Set the value from a string value.
void seti(int val)
Set the value from an integer value.
const Var * enqa_by_associated_field_significance(unsigned significance) const
Query variable attribute according to significance given in CODE TABLE 031021.
short unsigned int Varcode
Holds the WMO variable code of a variable.
Definition: varinfo.h:78
static Var * lua_check(struct lua_State *L, int idx)
Check that the element at idx is a Var.
unsigned diff(const Var &var) const
Compare two Var and return the number of differences.
T enq() const
Templated version of enq.
Definition: var.h:133
Varcode code() const
Retrieve the Varcode for a variable.
Implement fast access to information about WMO variables.
void clear_attrs()
Remove all attributes.
Smart pointer to handle/use varinfos.
Definition: varinfo.h:336
const char * value() const
Retrieve the internal string representation of the value for a variable.
void setd(double val)
Set the value from a double value.
void unseta(Varcode code)
Remove the attribute with the given code.
Var * m_attrs
Attribute list (ordered by Varcode)
Definition: var.h:60
Var & operator=(const Var &var)
Assignment.
const Var * next_attr() const
Get the next attribute in the attribute list.
bool operator==(const Var &var) const
Equality.
Varinfo m_info
Metadata about the variable.
Definition: var.h:54
char * m_value
Value of the variable.
Definition: var.h:57
Var(Varinfo info)
Create a new Var, with undefined value.
const Var * enqa(Varcode code) const
Query variable attributes.
void copy_val(const Var &src)
Set the value from another variable, performing conversions if needed.