Class dynamic::var
Constructors
- var() - create a null var
- var(bool) - create a var representing a
boolean value
- var(int) - create a var representing an
integer
- var(double) - create a var representing a
double-precision floating point number
- var(char) - create a var representing a
narrow character
- var(wchar_t) - create a var representing a
wide character
- var(const char*) - create a var representing
a narrow string
- var(const wchar_t*) - create a var representing
a wide string
- var(const std::string &) - create a var representing
a narrow string
- var(const std::wstring &) - creates a var representing
a wide string
- var(fn) - create a var representing a
function (limited to functions of var)
- template<std::size_t N> var(var(&)[N]) -
create a var representing a list
Operators
Note that the precise meaning of the operator depends on the
value stored in the var. Some of these operators will throw the "not_supported"
exception for certain types of var.
- operator bool() const - returns as_bool()
- operator int() const - returns as_int()
- var & operator=(const var &) - copies the
value. For simple types (such as ints and doubles) the value is
copied, whereas for complex types such as strings and containers, the
value is shared between all instances of the var.
- template<typename T> var & operator=(T const
& t) - assigns the var from a C++ type, as provided by the var
constructor.
- implementation-defined operator[](const var &)
const - access a member of a var.
- var operator+(const var &) const -
addition operator. The second operand is often converted to the type
of the first operand.
- var operator-(const var &) const -
subtraction operators. The second operand is often converted to the
type of the first operand.
- var operator*(const var&) const -
multiplication operator
- var operator/(const var&) const - divsion
operator
- var operator%(const var&) const - integer
modulus operator
- var operator<<(const var&) const -
bitwise left shift operator
- var operator>>(const var&) const -
bitwise right shift operator
- implementation-defined operator->() const -
access an iterator/enumerator
- var operator&(const var&) const - bitwise
and operator
- var operator|(const var&) const - bitwise or
operator
- var operator^(const var&) const - bitwise xor
operator
- var operator+() const - unary + (usually performs a
clone())
- var operator-() const - unary minus
- var operator*() const - dereference
iterator/enumerator
- var operator~() const - integer bitwise inverse
- bool operator==() const - equals operator
- bool operator!=() const - not equals
- bool operator<() const - less-than operator
- bool operator>() const - greater-than operator
- bool operator <=() const - less-than or equal
operator
- bool operator >=() const - greater-than or equal
operator
- template<typename T> T & as() - attempts
to access the native C type wrapped by this var.
- var & operator++() - preincrement operator
- var operator++(int) - postincrement operator
- var & operator--() - predecrement operator
- var operator--(int) - postdecrement operator
- var operator(...) - call the var as a functor,
with up to ten arguments
- var & operator+=(const var&) - add to the var
- var & operator-=(const var&) - subtract
from the var
- var & operator*=(const var&) - multiply the
var
- var & operator/=(const var&) - divide the var
- var & operator%=(const var&) - modulo the var
- var & operator<<=(const var&) - shift
the var left
- var & operator>>=(const var&) - shift
the var right
- var & operator&=(const var&) -
bitwise-and the var
- var & operator|=(const var&) - bitwise-or
the var
- var & operator^=(const var&) - bitwise-xor
the var
Typedefs
- typedef var iterator
- typedef var const_iterator
- typedef std::size_t size_type
- typedef std::ptrdiff_t difference_type
- typedef var reverse_iterator
- typedef var const_reverse_iterator
Conversion methods
These methods always succeed, but can return 0 by default.
- bool as_bool() const - convert the var to a
boolean value
- double as_double() const - convert the var
to a double
- int as_int() const - convert the var to an
integer
- void * as_ptr() const - convert the var to a
pointer
- std::string as_string() const - convert the var
to a narrow string
- std::wstring as_wstring() const - convert the var
to a wide string
Container methods
Note that the precise meaning of the method depends on the
value stored in the var. Some of these method will throw the "not_supported"
exception for certain types of var.
- var back() - returns the last element
- var begin() - returns an iterator to the first
element in the container, or null if the var isn't a
container
- void clear() - erases all elements.
- bool contains(const var&) - returns true if the
container contains the given key, false otherwise
- var end() - returns an end iterator, or null
if the var isn't a container
- var enumerator() - returns an enumerator, or null.
Usually the same as begin().
- void erase(const var&) - erases the given
element
- var front() - returns the first element
- var insert(const var&) - inserts an element
into a set
- var insert(const var & key, const var & value)
- inserts an element into a map
- void mixin(const var&) - inserts the elements
of one container into another
- var pop_back() - removes an item from the end, and
returns it
- var pop_front() - removes an item from the front,
and returns it
- void push_back(const var&) - adds an item to
the end
- void push_front(const var&) - adds an item to
the beginning
- var rbegin() - returns an iterator to the last
element in the container, iterating backwards, or null.
- var rend() - returns a reverse end iterator, or null
- void resize(std::size_t) - resizes the container
- var reverse_enumerator() - returns the reverse
enumerator, or null.
- std::size_t size() const - returns the number of
elements in the container, or 0.
Other Methods
Note that the precise meaning of the method depends on the
value stored in the var. Some of these method will throw the "not_supported"
exception for certain types of var.
- std::string class_name() const - returns the class
name of the var
- template<typename T> implementation-defined
extend(const char*, const T&) - inserts elements into an object or
a map
- var keys() - returns a container containing the
keys in the container, or null.
- int max_args() - returns the maximum number of
arguments for the functor, or -1 if the var is not a functor
- var proxy() - creates a threadsafe proxy for the var
- var values() - returns a container with the values
of the container