#include <variant.hpp>
Public Types | |
| enum | DECIMAL_VARIANT_TYPE { DECIMAL_VARIANT } |
Public Member Functions | |
| variant () | |
| variant (int n) | |
| variant (int n, DECIMAL_VARIANT_TYPE) | |
| variant (double n, DECIMAL_VARIANT_TYPE) | |
| variant (const std::vector< variant > &array) | |
| variant (std::vector< variant > &&array) | |
| variant (const std::string &str) | |
| variant (std::string &&str) | |
| variant (const std::map< variant, variant > &map) | |
| variant (std::map< variant, variant > &&map) | |
| variant (const_formula_callable_ptr callable) | |
| variant (const variant &v)=default | |
| variant (variant &&v)=default | |
| variant & | operator= (const variant &v)=default |
| variant & | operator= (variant &&v)=default |
| variant | operator[] (std::size_t n) const |
| variant | operator[] (const variant &v) const |
| std::size_t | num_elements () const |
| bool | is_empty () const |
| variant | get_member (const std::string &name) const |
| bool | is_null () const |
| Functions to test the type of the internal value. More... | |
| bool | is_int () const |
| bool | is_decimal () const |
| bool | is_callable () const |
| bool | is_list () const |
| bool | is_string () const |
| bool | is_map () const |
| int | as_int (int fallback=0) const |
| Returns the variant's value as an integer. More... | |
| int | as_decimal (int fallback=0) const |
| Returns the variant's internal representation of decimal number: ie, 1.234 is represented as 1234. More... | |
| bool | as_bool () const |
| Returns a boolean state of the variant value. More... | |
| const std::vector< variant > & | as_list () const |
| const std::map< variant, variant > & | as_map () const |
| const std::string & | as_string () const |
| const_formula_callable_ptr | as_callable () 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 |
| variant | list_elements_add (const variant &v) const |
| variant | list_elements_sub (const variant &v) const |
| variant | list_elements_mul (const variant &v) const |
| variant | list_elements_div (const variant &v) const |
| variant | concatenate (const variant &v) const |
| variant | build_range (const variant &v) const |
| bool | contains (const variant &other) const |
| variant | get_keys () const |
| variant | get_values () const |
| variant_iterator | begin () const |
| variant_iterator | end () const |
| std::string | serialize_to_string () const |
| void | serialize_from_string (const std::string &str) |
| std::string | string_cast () const |
| std::string | to_debug_string (bool verbose=false, formula_seen_stack *seen=nullptr) const |
| formula_variant::type | type () const |
Private Attributes | |
| std::shared_ptr< variant_value_base > | value_ |
Friends | |
| template<typename T > | |
| std::shared_ptr< T > | value_cast (const variant &v) |
Definition at line 38 of file variant.hpp.
| Enumerator | |
|---|---|
| DECIMAL_VARIANT | |
Definition at line 41 of file variant.hpp.
| wfl::variant::variant | ( | ) |
Definition at line 172 of file variant.cpp.
Referenced by concatenate(), get_keys(), get_member(), get_values(), operator%(), operator*(), operator+(), operator-(), operator/(), operator[](), operator^(), and serialize_from_string().
|
explicit |
Definition at line 176 of file variant.cpp.
| wfl::variant::variant | ( | int | n, |
| variant::DECIMAL_VARIANT_TYPE | |||
| ) |
Definition at line 181 of file variant.cpp.
| wfl::variant::variant | ( | double | n, |
| variant::DECIMAL_VARIANT_TYPE | |||
| ) |
Definition at line 186 of file variant.cpp.
|
explicit |
Definition at line 191 of file variant.cpp.
|
explicit |
Definition at line 196 of file variant.cpp.
|
explicit |
Definition at line 201 of file variant.cpp.
|
explicit |
Definition at line 206 of file variant.cpp.
Definition at line 211 of file variant.cpp.
Definition at line 216 of file variant.cpp.
|
explicit |
Definition at line 221 of file variant.cpp.
|
default |
|
default |
| bool wfl::variant::as_bool | ( | ) | const |
Returns a boolean state of the variant value.
The implementation is type-dependent.
Definition at line 357 of file variant.cpp.
References value_.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), gui2::image_shape::draw(), gui2::text_shape::draw(), wfl::unary_operator_expression::execute(), wfl::operator_expression::execute(), gui2::typed_formula< T >::execute(), terrain_filter::match_internal(), side_filter::match_internal(), matches_simple_filter(), and game_events::filter_formula::operator()().
| const_formula_callable_ptr wfl::variant::as_callable | ( | ) | const |
Definition at line 377 of file variant.cpp.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::dot_expression::execute(), wfl::formula_function_expression::execute(), wfl::safe_call_callable::execute_self(), get_member(), and luaW_pushfaivariant().
| int wfl::variant::as_decimal | ( | int | fallback = 0 | ) | const |
Returns the variant's internal representation of decimal number: ie, 1.234 is represented as 1234.
If is_null() is true, returns fallback.
Definition at line 344 of file variant.cpp.
References is_decimal(), is_int(), and is_null().
Referenced by as_int(), wfl::builtins::DEFINE_WFL_FUNCTION(), luaW_pushfaivariant(), operator%(), operator*(), operator+(), operator-(), operator/(), operator<(), operator==(), and operator^().
| int wfl::variant::as_int | ( | int | fallback = 0 | ) | const |
Returns the variant's value as an integer.
If is_null() is true, returns fallback.
Definition at line 336 of file variant.cpp.
References as_decimal(), is_decimal(), and is_null().
Referenced by BOOST_AUTO_TEST_CASE(), build_range(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::gamestate::DEFINE_WFL_FUNCTION(), gui2::text_shape::draw(), wfl::operator_expression::execute(), gui2::typed_formula< T >::execute(), active_ability_list::get_extremum(), gui2::rich_label::get_text_size(), unit_abilities::individual_value_int(), luaW_pushfaivariant(), operator%(), image::adjust_alpha_modification::operator()(), image::adjust_channels_modification::operator()(), operator*(), operator+(), operator-(), operator/(), operator[](), and operator^().
| const std::vector< variant > & wfl::variant::as_list | ( | ) | const |
Definition at line 367 of file variant.cpp.
Referenced by wfl::implementation::concat_lists(), contains(), gui2::typed_formula< T >::execute(), wfl::execute_actions(), luaW_pushfaivariant(), operator[](), and wfl::implementation::zip_transform().
Definition at line 372 of file variant.cpp.
Referenced by contains(), get_keys(), wfl::map_callable::get_value(), get_values(), luaW_pushfaivariant(), operator+(), and operator[]().
| const std::string & wfl::variant::as_string | ( | ) | const |
Definition at line 362 of file variant.cpp.
Referenced by concatenate(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::gamestate::DEFINE_WFL_FUNCTION(), wfl::string_expression::execute(), gui2::typed_formula< T >::execute(), wfl::map_callable::get_inputs(), wfl::string_callable::get_value(), luaW_pushfaivariant(), and wfl::string_expression::str().
| variant_iterator wfl::variant::begin | ( | ) | const |
Definition at line 297 of file variant.cpp.
References value_.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION().
Definition at line 648 of file variant.cpp.
References as_int().
Referenced by wfl::operator_expression::execute().
Definition at line 635 of file variant.cpp.
References as_string(), wfl::implementation::concat_lists(), is_list(), is_string(), and variant().
Referenced by wfl::operator_expression::execute(), and operator+().
| bool wfl::variant::contains | ( | const variant & | other | ) | const |
Definition at line 654 of file variant.cpp.
References as_list(), as_map(), utils::contains(), and type().
| variant_iterator wfl::variant::end | ( | ) | const |
Definition at line 302 of file variant.cpp.
References value_.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION().
| variant wfl::variant::get_keys | ( | ) | const |
Definition at line 277 of file variant.cpp.
References as_map(), and variant().
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION().
| variant wfl::variant::get_member | ( | const std::string & | name | ) | const |
Definition at line 321 of file variant.cpp.
References as_callable(), is_callable(), and variant().
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::map_callable::get_inputs(), and wfl::formula_variant_callable_with_backup::get_value().
| variant wfl::variant::get_values | ( | ) | const |
Definition at line 287 of file variant.cpp.
References as_map(), and variant().
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION().
|
inline |
Definition at line 72 of file variant.hpp.
References type().
Referenced by wfl::dot_expression::execute(), get_member(), luaW_pushfaivariant(), and operator[]().
|
inline |
Definition at line 71 of file variant.hpp.
References type().
Referenced by as_decimal(), as_int(), wfl::builtins::DEFINE_WFL_FUNCTION(), luaW_pushfaivariant(), operator%(), operator*(), operator+(), operator-(), operator/(), operator<(), operator==(), and operator^().
| bool wfl::variant::is_empty | ( | ) | const |
Definition at line 307 of file variant.cpp.
References value_.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION().
|
inline |
Definition at line 70 of file variant.hpp.
References type().
Referenced by as_decimal(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::gamestate::DEFINE_WFL_FUNCTION(), luaW_pushfaivariant(), and operator<().
|
inline |
Definition at line 73 of file variant.hpp.
References type().
Referenced by concatenate(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::dot_expression::execute(), wfl::square_bracket_expression::execute(), wfl::execute_actions(), luaW_pushfaivariant(), num_elements(), operator+(), and operator[]().
|
inline |
Definition at line 75 of file variant.hpp.
References type().
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::dot_expression::execute(), wfl::square_bracket_expression::execute(), luaW_pushfaivariant(), num_elements(), operator+(), and operator[]().
|
inline |
Functions to test the type of the internal value.
Definition at line 69 of file variant.hpp.
References type().
Referenced by as_decimal(), as_int(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::gamestate::DEFINE_WFL_FUNCTION(), wfl::formula_callable_with_backup::get_value(), wfl::formula_variant_callable_with_backup::get_value(), wfl::formula_callable::has_key(), and luaW_pushfaivariant().
|
inline |
Definition at line 74 of file variant.hpp.
References type().
Referenced by concatenate(), wfl::gamestate::DEFINE_WFL_FUNCTION(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::dot_expression::execute(), wfl::map_callable::get_inputs(), and luaW_pushfaivariant().
Definition at line 615 of file variant.cpp.
References wfl::implementation::zip_transform().
Referenced by wfl::operator_expression::execute().
Definition at line 630 of file variant.cpp.
References wfl::implementation::zip_transform().
Referenced by wfl::operator_expression::execute().
Definition at line 625 of file variant.cpp.
References wfl::implementation::zip_transform().
Referenced by wfl::operator_expression::execute().
Definition at line 620 of file variant.cpp.
References wfl::implementation::zip_transform().
Referenced by wfl::operator_expression::execute().
| std::size_t wfl::variant::num_elements | ( | ) | const |
Definition at line 312 of file variant.cpp.
References is_list(), is_map(), and value_.
Referenced by BOOST_AUTO_TEST_CASE(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::list_callable::get_value(), wfl::map_callable::get_value(), and operator[]().
| bool wfl::variant::operator!= | ( | const variant & | v | ) | const |
Definition at line 531 of file variant.cpp.
References operator==().
Definition at line 472 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, is_decimal(), and variant().
Definition at line 414 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, is_decimal(), and variant().
Definition at line 382 of file variant.cpp.
References as_decimal(), as_int(), as_map(), concatenate(), DECIMAL_VARIANT, is_decimal(), is_list(), is_map(), and variant().
| variant wfl::variant::operator- | ( | ) | const |
Definition at line 509 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, is_decimal(), and variant().
Definition at line 405 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, is_decimal(), and variant().
Definition at line 437 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, is_decimal(), and variant().
| bool wfl::variant::operator< | ( | const variant & | v | ) | const |
Definition at line 536 of file variant.cpp.
References as_decimal(), is_decimal(), is_int(), type(), and value_.
| bool wfl::variant::operator<= | ( | const variant & | v | ) | const |
Definition at line 558 of file variant.cpp.
| bool wfl::variant::operator== | ( | const variant & | v | ) | const |
Definition at line 518 of file variant.cpp.
References as_decimal(), is_decimal(), type(), and value_.
Referenced by operator!=().
| bool wfl::variant::operator> | ( | const variant & | v | ) | const |
Definition at line 563 of file variant.cpp.
| bool wfl::variant::operator>= | ( | const variant & | v | ) | const |
Definition at line 553 of file variant.cpp.
Definition at line 244 of file variant.cpp.
References as_int(), as_map(), i, is_callable(), is_list(), is_map(), num_elements(), operator[](), and variant().
| variant wfl::variant::operator[] | ( | std::size_t | n | ) | const |
Definition at line 231 of file variant.cpp.
References as_list(), is_callable(), and n.
Referenced by operator[]().
Definition at line 493 of file variant.cpp.
References as_decimal(), as_int(), DECIMAL_VARIANT, is_decimal(), and variant().
| void wfl::variant::serialize_from_string | ( | const std::string & | str | ) |
Definition at line 671 of file variant.cpp.
References DBG_SF, wfl::formula::evaluate(), utils::get_unknown_exception_type(), and variant().
| std::string wfl::variant::serialize_to_string | ( | ) | const |
Definition at line 666 of file variant.cpp.
References value_.
Referenced by wfl::variant_container< Container >::get_serialized_string().
| std::string wfl::variant::string_cast | ( | ) | const |
Definition at line 681 of file variant.cpp.
References value_.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), utils::detail::evaluate_formula_impl(), and wfl::variant_container< Container >::string_cast().
| std::string wfl::variant::to_debug_string | ( | bool | verbose = false, |
| formula_seen_stack * | seen = nullptr |
||
| ) | const |
Definition at line 686 of file variant.cpp.
References value_.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::gamestate::DEFINE_WFL_FUNCTION(), events::menu_handler::do_ai_formula(), wfl::formula_debugger::evaluate_arg_callback(), wfl::formula_debugger::evaluate_formula_callback(), wfl::set_var_callable::execute_self(), and wfl::variant_container< Container >::get_debug_string().
| formula_variant::type wfl::variant::type | ( | ) | const |
Definition at line 226 of file variant.cpp.
References value_.
Referenced by contains(), wfl::builtins::DEFINE_WFL_FUNCTION(), is_callable(), is_decimal(), is_int(), is_list(), is_map(), is_null(), is_string(), operator<(), and operator==().
|
friend |
Definition at line 77 of file variant.cpp.
|
private |
Definition at line 143 of file variant.hpp.
Referenced by as_bool(), begin(), end(), is_empty(), num_elements(), operator<(), operator==(), serialize_to_string(), string_cast(), to_debug_string(), and type().