#include <variant.hpp>
Public Types | |
enum | TYPE { TYPE_NULL, TYPE_INT, TYPE_DECIMAL, TYPE_CALLABLE, TYPE_LIST, TYPE_STRING, TYPE_MAP } |
enum | DECIMAL_VARIANT_TYPE { DECIMAL_VARIANT } |
Private Member Functions | |
void | must_be (TYPE t) const |
void | increment_refcount () |
void | release () |
Private Attributes | |
TYPE | type_ |
union { | |
int int_value_ | |
int decimal_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 52 of file variant.hpp.
Enumerator | |
---|---|
DECIMAL_VARIANT |
Definition at line 57 of file variant.hpp.
enum variant::TYPE |
Enumerator | |
---|---|
TYPE_NULL | |
TYPE_INT | |
TYPE_DECIMAL | |
TYPE_CALLABLE | |
TYPE_LIST | |
TYPE_STRING | |
TYPE_MAP |
Definition at line 55 of file variant.hpp.
variant::variant | ( | ) |
Definition at line 343 of file variant.cpp.
Referenced by build_range(), concatenate(), get_keys(), get_member(), get_values(), list_elements_add(), list_elements_div(), list_elements_mul(), list_elements_sub(), operator%(), operator*(), operator+(), operator-(), operator/(), operator[](), operator^(), and serialize_from_string().
|
explicit |
Definition at line 346 of file variant.cpp.
variant::variant | ( | int | n, |
variant::DECIMAL_VARIANT_TYPE | |||
) |
Definition at line 349 of file variant.cpp.
variant::variant | ( | double | n, |
variant::DECIMAL_VARIANT_TYPE | |||
) |
Definition at line 352 of file variant.cpp.
References decimal_value_.
|
explicit |
Definition at line 364 of file variant.cpp.
References callable_, and increment_refcount().
|
explicit |
Definition at line 371 of file variant.cpp.
References variant_list::elements, increment_refcount(), and list_.
|
explicit |
Definition at line 380 of file variant.cpp.
References increment_refcount(), variant_string::str, and string_.
Definition at line 388 of file variant.cpp.
References variant_map::elements, increment_refcount(), and map_.
variant::~variant | ( | ) |
Definition at line 404 of file variant.cpp.
References release().
variant::variant | ( | const variant & | v | ) |
Definition at line 397 of file variant.cpp.
References increment_refcount().
bool variant::as_bool | ( | ) | const |
Definition at line 580 of file variant.cpp.
References callable_, decimal_value_, variant_list::elements, variant_map::elements, int_value_, list_, map_, variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by gui2::tformula< T >::execute(), basic_unit_filter_impl::internal_matches_filter(), side_filter::match_internal(), terrain_filter::match_internal(), matches_simple_filter(), and ai::variant_value_translator< bool >::variant_to_value().
|
inline |
Definition at line 101 of file variant.hpp.
References callable_, must_be(), and TYPE_CALLABLE.
Referenced by game_logic::formula_function_expression::execute(), and luaW_pushfaivariant().
int variant::as_decimal | ( | ) | const |
Definition at line 565 of file variant.cpp.
References decimal_value_, int_value_, to_debug_string(), type_, TYPE_DECIMAL, TYPE_INT, TYPE_NULL, and type_string().
Referenced by as_int(), luaW_pushfaivariant(), operator%(), operator*(), operator+(), operator-(), operator/(), operator<=(), operator==(), and operator^().
int variant::as_int | ( | ) | const |
Definition at line 558 of file variant.cpp.
References as_decimal(), int_value_, must_be(), type_, TYPE_DECIMAL, TYPE_INT, and TYPE_NULL.
Referenced by BOOST_AUTO_TEST_CASE(), build_range(), gui2::tformula< T >::execute(), luaW_pushfaivariant(), operator%(), operator*(), operator+(), operator-(), operator/(), operator[](), operator^(), and ai::variant_value_translator< int >::variant_to_value().
const std::vector< variant > & variant::as_list | ( | ) | const |
Definition at line 610 of file variant.cpp.
References variant_list::elements, list_, must_be(), and TYPE_LIST.
Referenced by luaW_pushfaivariant().
Definition at line 617 of file variant.cpp.
References variant_map::elements, map_, must_be(), and TYPE_MAP.
Referenced by luaW_pushfaivariant().
const std::string & variant::as_string | ( | ) | const |
Definition at line 603 of file variant.cpp.
References must_be(), variant_string::str, string_, and TYPE_STRING.
Referenced by concatenate(), gui2::tformula< T >::execute(), ai::formula_ai::execute_variant(), luaW_pushfaivariant(), and ai::variant_value_translator< std::string >::variant_to_value().
variant_iterator variant::begin | ( | ) | const |
Definition at line 490 of file variant.cpp.
References variant_list::elements, variant_map::elements, list_, map_, type_, TYPE_LIST, and TYPE_MAP.
Referenced by contains(), game_logic::move_candidate_action::evaluate(), and game_logic::attack_candidate_action::evaluate().
Definition at line 971 of file variant.cpp.
References as_string(), i, must_be(), num_elements(), to_debug_string(), type_, TYPE_LIST, TYPE_STRING, type_string(), and variant().
bool variant::contains | ( | const variant & | other | ) | const |
Definition at line 1018 of file variant.cpp.
References begin(), variant_map::elements, end(), gui2::event::find(), map_, to_debug_string(), type_, TYPE_LIST, and TYPE_MAP.
|
inline |
Definition at line 116 of file variant.hpp.
References mutable_callable().
variant_iterator variant::end | ( | ) | const |
Definition at line 500 of file variant.cpp.
References variant_list::elements, variant_map::elements, list_, map_, type_, TYPE_LIST, and TYPE_MAP.
Referenced by contains(), game_logic::move_candidate_action::evaluate(), and game_logic::attack_candidate_action::evaluate().
variant variant::get_keys | ( | ) | const |
Definition at line 468 of file variant.cpp.
References variant_map::elements, i, map_, must_be(), TYPE_MAP, and variant().
variant variant::get_member | ( | const std::string & | str | ) | const |
Definition at line 545 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().
variant variant::get_values | ( | ) | const |
Definition at line 479 of file variant.cpp.
References variant_map::elements, i, map_, must_be(), TYPE_MAP, and variant().
|
private |
Definition at line 285 of file variant.cpp.
References callable_, intrusive_ptr_add_ref(), list_, map_, variant_list::refcount, variant_string::refcount, variant_map::refcount, string_, type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by operator=(), and variant().
|
inline |
Definition at line 100 of file variant.hpp.
References type_, and TYPE_CALLABLE.
Referenced by get_member(), luaW_pushfaivariant(), try_convert(), and try_convert_variant().
|
inline |
Definition at line 82 of file variant.hpp.
References type_, and TYPE_DECIMAL.
Referenced by luaW_pushfaivariant().
bool variant::is_empty | ( | ) | const |
Definition at line 511 of file variant.cpp.
References variant_list::elements, variant_map::elements, list_, map_, type_, TYPE_LIST, TYPE_MAP, and TYPE_NULL.
Referenced by ai::stage_side_formulas::do_play_stage(), ai::stage_unit_formulas::do_play_stage(), ai::formula_ai::evaluate(), and ai::formula_ai::execute_candidate_action().
|
inline |
Definition at line 81 of file variant.hpp.
References type_, and TYPE_INT.
Referenced by luaW_pushfaivariant().
|
inline |
Definition at line 92 of file variant.hpp.
References type_, and TYPE_LIST.
Referenced by ai::formula_ai::execute_variant(), luaW_pushfaivariant(), and operator[]().
|
inline |
Definition at line 83 of file variant.hpp.
References type_, and TYPE_MAP.
Referenced by luaW_pushfaivariant().
|
inline |
Definition at line 80 of file variant.hpp.
References type_, and TYPE_NULL.
Referenced by ai::formula_ai::get_keeps(), game_logic::formula_callable_with_backup::get_value(), game_logic::formula_variant_callable_with_backup::get_value(), game_logic::formula_callable::has_key(), luaW_pushfaivariant(), and operator==().
|
inline |
Definition at line 79 of file variant.hpp.
References type_, and TYPE_STRING.
Referenced by ai::formula_ai::execute_variant(), and luaW_pushfaivariant().
Definition at line 899 of file variant.cpp.
References i, must_be(), num_elements(), TYPE_LIST, and variant().
Definition at line 953 of file variant.cpp.
References i, must_be(), num_elements(), TYPE_LIST, and variant().
Definition at line 935 of file variant.cpp.
References i, must_be(), num_elements(), TYPE_LIST, and variant().
Definition at line 917 of file variant.cpp.
References i, must_be(), num_elements(), TYPE_LIST, and variant().
|
private |
Definition at line 1036 of file variant.cpp.
References to_debug_string(), type_, and type_string().
Referenced by as_callable(), as_int(), as_list(), as_map(), as_string(), build_range(), concatenate(), get_keys(), get_values(), list_elements_add(), list_elements_div(), list_elements_mul(), list_elements_sub(), mutable_callable(), and operator[]().
|
inline |
Definition at line 103 of file variant.hpp.
References must_be(), mutable_callable_, and TYPE_CALLABLE.
Referenced by convert_to(), convert_variant(), try_convert(), and try_convert_variant().
size_t variant::num_elements | ( | ) | const |
Definition at line 526 of file variant.cpp.
References variant_list::elements, variant_map::elements, list_, map_, to_debug_string(), type_, TYPE_CALLABLE, TYPE_LIST, TYPE_MAP, and type_string().
Referenced by BOOST_AUTO_TEST_CASE(), concatenate(), game_logic::attack_candidate_action::evaluate(), ai::formula_ai::execute_variant(), list_elements_add(), list_elements_div(), list_elements_mul(), list_elements_sub(), operator<=(), operator==(), operator[](), and to_debug_string().
bool variant::operator!= | ( | const variant & | v | ) | const |
Definition at line 824 of file variant.cpp.
References operator==().
Definition at line 726 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, type_, TYPE_DECIMAL, and variant().
Definition at line 670 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, type_, TYPE_DECIMAL, and variant().
Definition at line 624 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, variant_list::elements, variant_map::elements, i, list_, map_, type_, TYPE_DECIMAL, TYPE_LIST, TYPE_MAP, and variant().
Definition at line 661 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, type_, TYPE_DECIMAL, and variant().
variant variant::operator- | ( | ) | const |
Definition at line 763 of file variant.cpp.
References as_int(), decimal_value_, DECIMAL_VARIANT, type_, TYPE_DECIMAL, and variant().
Definition at line 692 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, type_, TYPE_DECIMAL, and variant().
bool variant::operator< | ( | const variant & | v | ) | const |
Definition at line 889 of file variant.cpp.
bool variant::operator<= | ( | const variant & | v | ) | const |
Definition at line 829 of file variant.cpp.
References as_decimal(), callable_, decimal_value_, variant_map::elements, int_value_, game_logic::formula_callable::less(), map_, num_elements(), variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Definition at line 409 of file variant.cpp.
References increment_refcount(), and release().
bool variant::operator== | ( | const variant & | v | ) | const |
Definition at line 771 of file variant.cpp.
References as_decimal(), callable_, decimal_value_, variant_map::elements, game_logic::formula_callable::equals(), int_value_, is_null(), map_, num_elements(), variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by operator!=().
bool variant::operator> | ( | const variant & | v | ) | const |
Definition at line 894 of file variant.cpp.
bool variant::operator>= | ( | const variant & | v | ) | const |
Definition at line 884 of file variant.cpp.
variant variant::operator[] | ( | size_t | n | ) | const |
Definition at line 419 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 434 of file variant.cpp.
References as_int(), variant_map::elements, i, is_list(), map_, num_elements(), operator[](), to_debug_string(), type_, TYPE_CALLABLE, TYPE_LIST, TYPE_MAP, type_string(), and variant().
Definition at line 748 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, round_portable(), type_, TYPE_DECIMAL, and variant().
int variant::refcount | ( | ) | const |
Definition at line 1145 of file variant.cpp.
References callable_, list_, map_, reference_counted_object::refcount(), variant_list::refcount, variant_string::refcount, variant_map::refcount, string_, type_, TYPE_CALLABLE, TYPE_LIST, TYPE_MAP, and TYPE_STRING.
|
private |
Definition at line 309 of file variant.cpp.
References callable_, intrusive_ptr_release(), list_, map_, variant_list::refcount, variant_string::refcount, variant_map::refcount, string_, type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by operator=(), and ~variant().
void variant::serialize_from_string | ( | const std::string & | str | ) |
Definition at line 1136 of file variant.cpp.
References game_logic::formula::evaluate(), and variant().
Referenced by ai::formula_ai::on_create(), and unit_formula_manager::read().
void variant::serialize_to_string | ( | std::string & | str | ) | const |
Definition at line 1045 of file variant.cpp.
References callable_, decimal_value_, variant_list::elements, variant_map::elements, i, int_value_, list_, map_, game_logic::formula_callable::serialize(), serialize_to_string(), variant_string::str, string_, type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by serialize_to_string().
std::string variant::string_cast | ( | ) | const |
Definition at line 1165 of file variant.cpp.
References decimal_value_, variant_list::elements, variant_map::elements, i, int_value_, list_, map_, variant_string::str, string_, string_cast(), type_, TYPE_CALLABLE, TYPE_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by do_interpolation(), and string_cast().
std::string variant::to_debug_string | ( | std::vector< const game_logic::formula_callable * > * | seen = nullptr , |
bool | verbose = false |
||
) | const |
Definition at line 1229 of file variant.cpp.
References game_logic::formula_input::access, callable_, decimal_value_, variant_map::elements, gui2::event::find(), game_logic::FORMULA_READ_WRITE, game_logic::FORMULA_WRITE_ONLY, i, 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_DECIMAL, TYPE_INT, TYPE_LIST, TYPE_MAP, TYPE_NULL, and TYPE_STRING.
Referenced by as_decimal(), concatenate(), contains(), ai::formula_ai::evaluate(), ai::formula_ai::execute_variant(), must_be(), num_elements(), operator[](), and to_debug_string().
|
inline |
Definition at line 107 of file variant.hpp.
References is_callable(), and mutable_callable().
Referenced by luaW_pushfaivariant().
std::string variant::type_string | ( | ) | const |
Definition at line 339 of file variant.cpp.
References type_.
Referenced by as_decimal(), concatenate(), must_be(), num_elements(), and operator[]().
union { ... } |
const game_logic::formula_callable* variant::callable_ |
Definition at line 169 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().
int variant::decimal_value_ |
Definition at line 168 of file variant.hpp.
Referenced by as_bool(), as_decimal(), operator-(), operator<=(), operator==(), serialize_to_string(), string_cast(), to_debug_string(), and variant().
int variant::int_value_ |
Definition at line 167 of file variant.hpp.
Referenced by as_bool(), as_decimal(), as_int(), operator<=(), operator==(), serialize_to_string(), string_cast(), and to_debug_string().
variant_list* variant::list_ |
Definition at line 171 of file variant.hpp.
Referenced by as_bool(), as_list(), begin(), end(), increment_refcount(), is_empty(), num_elements(), operator+(), operator[](), refcount(), release(), serialize_to_string(), string_cast(), and variant().
variant_map* variant::map_ |
Definition at line 173 of file variant.hpp.
Referenced by as_bool(), as_map(), begin(), contains(), end(), get_keys(), get_values(), increment_refcount(), is_empty(), num_elements(), operator+(), operator<=(), operator==(), operator[](), refcount(), release(), serialize_to_string(), string_cast(), to_debug_string(), and variant().
game_logic::formula_callable* variant::mutable_callable_ |
Definition at line 170 of file variant.hpp.
Referenced by mutable_callable().
variant_string* variant::string_ |
Definition at line 172 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().
|
private |
Definition at line 165 of file variant.hpp.
Referenced by as_bool(), as_decimal(), as_int(), begin(), concatenate(), contains(), end(), increment_refcount(), is_callable(), is_decimal(), is_empty(), is_int(), is_list(), is_map(), is_null(), is_string(), must_be(), num_elements(), operator%(), operator*(), operator+(), operator-(), operator/(), operator<=(), operator==(), operator[](), operator^(), refcount(), release(), serialize_to_string(), string_cast(), to_debug_string(), and type_string().