The base template for associating string values with enum values. More...
#include <enum_base.hpp>
Public Types | |
using | enum_type = typename Definition::type |
template<typename T > | |
using | sized_array = std::array< T, size()> |
Provide a alias template for an array of matching size. More... | |
Static Public Member Functions | |
static std::string | get_string (enum_type key) |
Converts a enum to its string equivalent. More... | |
static constexpr utils::optional< enum_type > | get_enum (const std::string_view value) |
Converts a string into its enum equivalent. More... | |
static constexpr utils::optional< enum_type > | get_enum (unsigned long value) |
Converts an int into its enum equivalent. More... | |
static constexpr std::size_t | size () |
The base template for associating string values with enum values.
Implementing classes should not set custom int values for their enum. The number of enum values must match the number of elements in the values array. The values the values array must be unique.
Definition at line 32 of file enum_base.hpp.
using string_enums::enum_base< Definition >::enum_type = typename Definition::type |
Definition at line 34 of file enum_base.hpp.
using string_enums::enum_base< Definition >::sized_array = std::array<T, size()> |
Provide a alias template for an array of matching size.
Definition at line 92 of file enum_base.hpp.
|
inlinestaticconstexpr |
Converts a string into its enum equivalent.
value | The string value to convert. |
Definition at line 57 of file enum_base.hpp.
References i, and string_enums::enum_base< Definition >::size().
Referenced by prefs::addon_manager_saved_order_direction(), unit::apply_builtin_effect(), attack_type::apply_modification(), unit_type::build_help_index(), team::change_controller(), team::change_controller_by_wml(), events::console_handler::do_unit(), gui2::dialogs::game_load::evaluate_summary_string(), gui2::listbox::get_active_sorting_option(), wesnothd::game::handle_controller_choice(), impl_add_animation(), unit::init(), ng::create_engine::init_extras(), ng::depcheck::manager::manager(), gui2::listbox::order_by_column(), playsingle_controller::play_scenario(), gui2::dialogs::mp_create_game::post_show(), gui2::dialogs::mp_create_game::pre_show(), playmp_controller::process_network_side_drop_impl(), ng::configure_engine::random_faction_mode_default(), team::team_info::read(), utils::irdya_date::read_date(), attack_type::set_attack_alignment(), team::set_defeat_condition_string(), team::set_share_vision(), gui2::dialogs::mp_join_game::show_flg_select(), SIDE_SETTER(), ai::lua_object< T >::to_type(), wesnothd::game::transfer_side_control(), UNIT_SETTER(), and wesnothd::game::update_side_data().
|
inlinestaticconstexpr |
Converts an int into its enum equivalent.
value | The string value to convert. |
Definition at line 73 of file enum_base.hpp.
References string_enums::enum_base< Definition >::size().
|
inlinestatic |
Converts a enum to its string equivalent.
key | The enum value to get the equivalent string for. |
Definition at line 46 of file enum_base.hpp.
Referenced by attack_type::alignment_str(), attack_info(), BOOST_AUTO_TEST_CASE(), ai::cfun_ai_get_targets(), wesnothd::game::change_controller_type(), game_board::check_victory(), wesnothd::game::debug_sides_info(), events::console_handler::do_controller(), game_classification::get_tagname(), wfl::unit_callable::get_value(), wfl::unit_type_callable::get_value(), wfl::team_callable::get_value(), wesnothd::game::handle_controller_choice(), impl_mp_settings_get(), intf_describe_plugins(), game_launcher::load_game(), gui2::dialogs::editor_edit_unit::load_unit_type(), side_filter::match_internal(), game_launcher::play_render_image_mode(), playsingle_controller::play_side_impl(), gui2::dialogs::mp_create_game::post_show(), gui2::dialogs::mp_create_game::pre_show(), playmp_controller::process_network_side_drop_impl(), team::team_info::read(), wesnothd::game::remove_player(), prefs::set_addon_manager_saved_order_direction(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), game_board::side_drop_to(), SIDE_GETTER(), editor::map_context::to_config(), game_classification::to_config(), mp_game_settings::to_config(), wfl::variant::type_string(), unit_alignment(), UNIT_GETTER(), UNIT_TYPE_GETTER(), wfl::variant_type_to_string(), team::team_info::write(), and unit::write().
|
inlinestaticconstexpr |
Definition at line 85 of file enum_base.hpp.
Referenced by string_enums::enum_base< Definition >::get_enum().