|
libwreport 2.1
|
Holds a wreport variable. More...
#include <var.h>
Public Member Functions | |
| Var (Varinfo info) | |
| Create a new Var, with undefined value. | |
| Var (Varinfo info, int val) | |
| Create a new Var, with integer value. | |
| Var (Varinfo info, double val) | |
| Create a new Var, with double value. | |
| Var (Varinfo info, const char *val) | |
| Create a new Var, with character value. | |
| Var (const Var &var) | |
| Copy constructor. | |
| Var (const Var &var, bool with_attrs) | |
| Copy constructor. | |
| Var (Varinfo info, const Var &var) | |
| Create a new Var with the value from another one. | |
| Var & | operator= (const Var &var) |
| Assignment. | |
| bool | operator== (const Var &var) const |
| Equality. | |
| bool | operator!= (const Var &var) const |
| Equality. | |
| Varcode | code () const throw () |
| Retrieve the Varcode for a variable. | |
| Varinfo | info () const throw () |
| Get informations about the variable. | |
| const char * | value () const throw () |
| Retrieve the internal string representation of the value for a variable. | |
| bool | isset () const throw () |
| int | enqi () const |
| Get the value as an integer. | |
| double | enqd () const |
| Get the value as a double. | |
| const char * | enqc () const |
| Get the value as a string. | |
| template<typename T > | |
| T | enq () const |
| Templated version of enq. | |
| template<typename T > | |
| T | enq (T default_value) const |
| Return the variable value, or the given default value if the variable is not set. | |
| void | seti (int val) |
| Set the value from an integer value. | |
| void | setd (double val) |
| Set the value from a double value. | |
| void | setc (const char *val) |
| Set the value from a string value. | |
| void | set_binary (const unsigned char *val) |
| Set the raw, binary value from a string value. | |
| void | setc_truncate (const char *val) |
| Set the value from a string value, truncating val if it is too long. | |
| void | set_from_formatted (const char *val) |
| Set from a value formatted with the format() method. | |
| void | unset () |
| Unset the value. | |
| void | clear_attrs () |
| Remove all attributes. | |
| const Var * | enqa (Varcode code) const |
| Query variable attributes. | |
| const Var * | enqa_by_associated_field_significance (unsigned significance) const |
| Query variable attribute according to significance given in CODE TABLE 031021. | |
| void | seta (const Var &attr) |
| Set an attribute of the variable. | |
| void | seta (std::auto_ptr< Var > attr) |
| Set an attribute of the variable. | |
| void | unseta (Varcode code) |
| Remove the attribute with the given code. | |
| const Var * | next_attr () const |
| Get the next attribute in the attribute list. | |
| void | copy_val (const Var &src) |
| Set the value from another variable, performing conversions if needed. | |
| void | copy_val_only (const Var &src) |
| Set the value from another variable, performing conversions if needed. | |
| void | copy_attrs (const Var &src) |
| Copy all the attributes from another variable. | |
| void | copy_attrs_if_defined (const Var &src) |
| Copy all the attributes from another variable, unless they are set to an undefined value. | |
| std::string | format (const char *ifundef="(undef)") const |
| Create a formatted string representation of the variable value. | |
| void | print (FILE *out) const |
| Print the variable to an output stream. | |
| void | print (std::ostream &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 | print_without_attrs (std::ostream &out) const |
| Print the variable to an output stream, without its attributes. | |
| unsigned | diff (const Var &var) const |
| Compare two Var and return the number of differences. | |
| void | lua_push (struct lua_State *L) |
| Push the variable as an object in the lua stack. | |
| void | set (int val) |
| Shortcuts (use with care, as the semanthics are slightly different depending on the type) | |
| void | set (double val) |
| Shortcuts (use with care, as the semanthics are slightly different depending on the type) | |
| void | set (const char *val) |
| Shortcuts (use with care, as the semanthics are slightly different depending on the type) | |
| void | set (const std::string &val) |
| Shortcuts (use with care, as the semanthics are slightly different depending on the type) | |
| void | set (const Var &var) |
| Shortcuts (use with care, as the semanthics are slightly different depending on the type) | |
Static Public Member Functions | |
| static Var * | lua_check (struct lua_State *L, int idx) |
| Check that the element at idx is a Var. | |
Protected Attributes | |
| Varinfo | m_info |
| Metadata about the variable. | |
| char * | m_value |
| Value of the variable. | |
| Var * | m_attrs |
| Attribute list (ordered by Varcode) | |
Holds a wreport variable.
A wreport::Var contains:
Create a new Var with the value from another one.
Conversions are applied if necessary
| info | The wreport::Varinfo describing the variable to create |
| var | The variable with the value to use |
| void wreport::Var::copy_attrs | ( | const Var & | src | ) |
Copy all the attributes from another variable.
| src | The variable with the attributes to copy. |
| void wreport::Var::copy_attrs_if_defined | ( | const Var & | src | ) |
Copy all the attributes from another variable, unless they are set to an undefined value.
| src | The variable with the attributes to copy. |
| void wreport::Var::copy_val | ( | const Var & | src | ) |
Set the value from another variable, performing conversions if needed.
The attributes of src will also be copied
Referenced by set().
| void wreport::Var::copy_val_only | ( | const Var & | src | ) |
Set the value from another variable, performing conversions if needed.
The attributes of src will NOT be copied
| unsigned wreport::Var::diff | ( | const Var & | var | ) | const |
Query variable attributes.
| code | The wreport::Varcode of the attribute requested. See vartable.h |
| std::string wreport::Var::format | ( | const char * | ifundef = "(undef)" | ) | const |
Create a formatted string representation of the variable value.
| ifundef | String to use if the variable is undefiend |
| bool wreport::Var::isset | ( | ) | const throw () |
Referenced by enq().
| static Var* wreport::Var::lua_check | ( | struct lua_State * | L, |
| int | idx | ||
| ) | [static] |
| const Var* wreport::Var::next_attr | ( | ) | const |
Get the next attribute in the attribute list.
Example attribute iteration:
for (const Var* a = var.next_attr(); a != NULL; a = a->next_attr()) // Do something with a
| void wreport::Var::print | ( | std::ostream & | out | ) | const |
Print the variable to an output stream.
| out | The output stream to use for printing |
| void wreport::Var::print | ( | FILE * | out | ) | const |
Print the variable to an output stream.
| out | The output stream to use for printing |
| void wreport::Var::print_without_attrs | ( | std::ostream & | out | ) | const |
Print the variable to an output stream, without its attributes.
| out | The output stream to use for printing |
| void wreport::Var::print_without_attrs | ( | FILE * | out | ) | const |
Print the variable to an output stream, without its attributes.
| out | The output stream to use for printing |
| void wreport::Var::set_binary | ( | const unsigned char * | val | ) |
Set the raw, binary value from a string value.
This is similar to setc(), but it always copies as many bytes as the variable is long, including null bytes.
| void wreport::Var::seta | ( | std::auto_ptr< Var > | attr | ) |
Set an attribute of the variable.
An existing attribute with the same wreport::Varcode will be replaced.
| attr | The attribute to add. It will be used directly, and var will take care of its memory management. |
| void wreport::Var::seta | ( | const Var & | attr | ) |
Set an attribute of the variable.
An existing attribute with the same wreport::Varcode will be replaced.
| attr | The attribute to add. It will be copied inside var, and memory management will still be in charge of the caller. |
| void wreport::Var::setc_truncate | ( | const char * | val | ) |
Set the value from a string value, truncating val if it is too long.
If a value is truncated, the last character is set to '>' to mark the truncation.
1.7.4