#include <variant.hpp>
Public Types | |
enum | TYPE { TYPE_NULL, TYPE_INT, TYPE_CALLABLE, TYPE_LIST, TYPE_STRING, TYPE_MAP } |
Public Member Functions | |
variant () | |
variant (int n) | |
variant (const game_logic::formula_callable *callable) | |
variant (std::vector< variant > *array) | |
variant (const std::string &str) | |
variant (std::map< variant, variant > *map) | |
~variant () | |
variant (const variant &v) | |
const variant & | operator= (const variant &v) |
const variant & | operator[] (size_t n) const |
const variant & | operator[] (const variant v) const |
size_t | num_elements () const |
variant | get_member (const std::string &str) const |
bool | is_string () const |
bool | is_null () const |
bool | is_int () const |
bool | is_map () const |
int | as_int () const |
bool | as_bool () const |
bool | is_list () const |
const std::string & | as_string () const |
bool | is_callable () const |
const game_logic::formula_callable * | as_callable () const |
game_logic::formula_callable * | mutable_callable () const |
template<typename T> | |
T * | try_convert () const |
template<typename T> | |
T * | convert_to () const |
variant | operator+ (const variant &) const |
variant | operator- (const variant &) const |
variant | operator* (const variant &) const |
variant | operator/ (const variant &) const |
variant | operator^ (const variant &) const |
variant | operator% (const variant &) const |
variant | operator- () const |
bool | operator== (const variant &) const |
bool | operator!= (const variant &) const |
bool | operator< (const variant &) const |
bool | operator> (const variant &) const |
bool | operator<= (const variant &) const |
bool | operator>= (const variant &) const |
std::map< variant, variant > | get_map () const |
variant | get_keys () const |
variant | get_values () const |
void | serialize_to_string (std::string &str) const |
void | serialize_from_string (const std::string &str) |
int | refcount () const |
std::string | string_cast () const |
std::string | to_debug_string (std::vector< const game_logic::formula_callable * > *seen=NULL) const |
Private Member Functions | |
void | must_be (TYPE t) const |
void | increment_refcount () |
void | release () |
Private Attributes | |
TYPE | type_ |
union { | |
int int_value_ | |
const game_logic::formula_callable * callable_ | |
game_logic::formula_callable * mutable_callable_ | |
variant_list * list_ | |
variant_string * string_ | |
variant_map * map_ | |
}; |
Definition at line 36 of file variant.hpp.
enum variant::TYPE |
Definition at line 118 of file variant.hpp.
variant::variant | ( | ) |
Definition at line 143 of file variant.cpp.
Referenced by get_keys(), get_member(), get_values(), operator%(), operator*(), operator+(), operator-(), operator/(), operator^(), and serialize_from_string().
variant::variant | ( | int | n | ) | [explicit] |
Definition at line 146 of file variant.cpp.
variant::variant | ( | const game_logic::formula_callable * | callable | ) | [explicit] |
variant::variant | ( | std::vector< variant > * | array | ) | [explicit] |
Definition at line 156 of file variant.cpp.
References variant_list::elements, increment_refcount(), and list_.
variant::variant | ( | const std::string & | str | ) | [explicit] |
Definition at line 165 of file variant.cpp.
References increment_refcount(), variant_string::str, and string_.
Definition at line 173 of file variant.cpp.
References variant_map::elements, increment_refcount(), and map_.
variant::~variant | ( | ) |
variant::variant | ( | const variant & | v | ) |
const variant & variant::operator[] | ( | size_t | n | ) | const |
Definition at line 203 of file variant.cpp.
References variant_list::elements, list_, must_be(), type_, TYPE_CALLABLE, and TYPE_LIST.
Referenced by operator[](), and to_debug_string().
Definition at line 219 of file variant.cpp.
References as_int(), variant_map::elements, map_, operator[](), to_debug_string(), type_, TYPE_CALLABLE, TYPE_LIST, TYPE_MAP, and variant_type_to_string().
size_t variant::num_elements | ( | ) | const |
Definition at line 270 of file variant.cpp.
References variant_map::elements, variant_list::elements, list_, map_, to_debug_string(), type_, TYPE_CALLABLE, TYPE_LIST, TYPE_MAP, and variant_type_to_string().
Referenced by formula_ai::do_recruitment(), formula_ai::execute_variant(), operator<=(), operator==(), and to_debug_string().
variant variant::get_member | ( | const std::string & | str | ) | const |
Definition at line 287 of file variant.cpp.
References callable_, is_callable(), game_logic::formula_callable::query_value(), and variant().
Referenced by game_logic::formula_variant_callable_with_backup::get_value().
bool variant::is_string | ( | ) | const [inline] |
bool variant::is_null | ( | ) | const [inline] |
Definition at line 56 of file variant.hpp.
References type_, and TYPE_NULL.
Referenced by formula_ai::get_keeps(), game_logic::formula_variant_callable_with_backup::get_value(), game_logic::formula_callable_with_backup::get_value(), formula_ai::get_value(), game_logic::formula_callable::has_key(), and operator==().
bool variant::is_int | ( | ) | const [inline] |
bool variant::is_map | ( | ) | const [inline] |
int variant::as_int | ( | ) | const [inline] |
Definition at line 59 of file variant.hpp.
References int_value_, must_be(), type_, TYPE_INT, and TYPE_NULL.
Referenced by operator%(), operator*(), operator+(), operator-(), operator/(), operator[](), and operator^().
bool variant::as_bool | ( | ) | const |
Definition at line 300 of file variant.cpp.
References callable_, variant_map::elements, variant_list::elements, int_value_, list_, map_, variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by unit::internal_matches_filter().
bool variant::is_list | ( | ) | const [inline] |
Definition at line 62 of file variant.hpp.
References type_, and TYPE_LIST.
Referenced by formula_ai::do_recruitment(), and formula_ai::execute_variant().
const std::string & variant::as_string | ( | ) | const |
Definition at line 321 of file variant.cpp.
References must_be(), variant_string::str, string_, and TYPE_STRING.
bool variant::is_callable | ( | ) | const [inline] |
Definition at line 66 of file variant.hpp.
References type_, and TYPE_CALLABLE.
Referenced by get_member(), try_convert(), and try_convert_variant().
const game_logic::formula_callable* variant::as_callable | ( | ) | const [inline] |
Definition at line 67 of file variant.hpp.
References callable_, must_be(), and TYPE_CALLABLE.
Referenced by game_logic::formula_function_expression::execute().
game_logic::formula_callable* variant::mutable_callable | ( | ) | const [inline] |
Definition at line 69 of file variant.hpp.
References must_be(), mutable_callable_, and TYPE_CALLABLE.
Referenced by convert_to(), convert_variant(), try_convert(), and try_convert_variant().
T* variant::try_convert | ( | ) | const [inline] |
T* variant::convert_to | ( | ) | const [inline] |
Definition at line 328 of file variant.cpp.
References as_int(), variant_map::elements, variant_list::elements, list_, map_, type_, TYPE_LIST, TYPE_MAP, and variant().
variant variant::operator- | ( | ) | const |
bool variant::operator== | ( | const variant & | v | ) | const |
Definition at line 404 of file variant.cpp.
References callable_, variant_map::elements, game_logic::formula_callable::equals(), int_value_, is_null(), map_, num_elements(), variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by operator!=().
bool variant::operator!= | ( | const variant & | v | ) | const |
bool variant::operator< | ( | const variant & | v | ) | const |
Definition at line 504 of file variant.cpp.
bool variant::operator> | ( | const variant & | v | ) | const |
Definition at line 509 of file variant.cpp.
bool variant::operator<= | ( | const variant & | v | ) | const |
Definition at line 455 of file variant.cpp.
References callable_, variant_map::elements, int_value_, game_logic::formula_callable::less(), map_, num_elements(), variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
bool variant::operator>= | ( | const variant & | v | ) | const |
Definition at line 499 of file variant.cpp.
Definition at line 242 of file variant.cpp.
References variant_map::elements, map_, must_be(), and TYPE_MAP.
variant variant::get_keys | ( | ) | const |
Definition at line 248 of file variant.cpp.
References variant_map::elements, map_, must_be(), TYPE_MAP, and variant().
variant variant::get_values | ( | ) | const |
Definition at line 259 of file variant.cpp.
References variant_map::elements, map_, must_be(), TYPE_MAP, and variant().
void variant::serialize_to_string | ( | std::string & | str | ) | const |
Definition at line 521 of file variant.cpp.
References callable_, variant_map::elements, variant_list::elements, int_value_, lexical_cast(), list_, map_, game_logic::formula_callable::serialize(), serialize_to_string(), variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by serialize_to_string().
void variant::serialize_from_string | ( | const std::string & | str | ) |
int variant::refcount | ( | ) | const |
Definition at line 580 of file variant.cpp.
References callable_, list_, map_, reference_counted_object::refcount(), variant_map::refcount, variant_string::refcount, variant_list::refcount, string_, type_, TYPE_CALLABLE, TYPE_LIST, TYPE_MAP, and TYPE_STRING.
std::string variant::string_cast | ( | ) | const |
Definition at line 600 of file variant.cpp.
References variant_map::elements, variant_list::elements, int_value_, lexical_cast(), list_, map_, variant_string::str, string_, string_cast(), type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by string_cast().
std::string variant::to_debug_string | ( | std::vector< const game_logic::formula_callable * > * | seen = NULL |
) | const |
Definition at line 643 of file variant.cpp.
References game_logic::formula_input::access, callable_, variant_map::elements, game_logic::FORMULA_READ_WRITE, game_logic::FORMULA_WRITE_ONLY, game_logic::formula_callable::inputs(), int_value_, map_, game_logic::formula_input::name, num_elements(), operator[](), game_logic::formula_callable::query_value(), variant_string::str, string_, to_debug_string(), type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by formula_ai::evaluate(), must_be(), num_elements(), operator[](), and to_debug_string().
void variant::must_be | ( | variant::TYPE | t | ) | const [private] |
Definition at line 514 of file variant.cpp.
References to_debug_string(), type_, and variant_type_to_string().
Referenced by as_callable(), as_int(), as_string(), get_keys(), get_map(), get_values(), mutable_callable(), and operator[]().
void variant::increment_refcount | ( | ) | [private] |
Definition at line 91 of file variant.cpp.
References callable_, intrusive_ptr_add_ref(), list_, map_, variant_map::refcount, variant_string::refcount, variant_list::refcount, string_, type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by operator=(), and variant().
void variant::release | ( | ) | [private] |
Definition at line 114 of file variant.cpp.
References callable_, intrusive_ptr_release(), list_, map_, variant_map::refcount, variant_string::refcount, variant_list::refcount, string_, type_, TYPE_CALLABLE, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by operator=(), and ~variant().
TYPE variant::type_ [private] |
Definition at line 121 of file variant.hpp.
Referenced by as_bool(), as_int(), increment_refcount(), is_callable(), is_int(), is_list(), is_map(), is_null(), is_string(), must_be(), num_elements(), operator+(), operator<=(), operator==(), operator[](), refcount(), release(), serialize_to_string(), string_cast(), and to_debug_string().
Definition at line 123 of file variant.hpp.
Referenced by as_bool(), as_int(), operator<=(), operator==(), serialize_to_string(), string_cast(), and to_debug_string().
Definition at line 124 of file variant.hpp.
Referenced by as_bool(), as_callable(), get_member(), increment_refcount(), operator<=(), operator==(), refcount(), release(), serialize_to_string(), to_debug_string(), and variant().
Definition at line 126 of file variant.hpp.
Referenced by as_bool(), increment_refcount(), num_elements(), operator+(), operator[](), refcount(), release(), serialize_to_string(), string_cast(), and variant().
Definition at line 127 of file variant.hpp.
Referenced by as_bool(), as_string(), increment_refcount(), operator<=(), operator==(), refcount(), release(), serialize_to_string(), string_cast(), to_debug_string(), and variant().
Definition at line 128 of file variant.hpp.
Referenced by as_bool(), get_keys(), get_map(), get_values(), increment_refcount(), num_elements(), operator+(), operator<=(), operator==(), operator[](), refcount(), release(), serialize_to_string(), string_cast(), to_debug_string(), and variant().
union { ... } [private] |
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |