Add a special kind of assert to validate whether the input from WML doesn't contain any problems that might crash the game. More...
Go to the source code of this file.
Classes | |
struct | twml_exception |
Helper class, don't construct this directly. More... | |
Macros | |
#define | VALIDATE(cond, message) |
The macro to use for the validation of WML. More... | |
#define | VALIDATE_WITH_DEV_MESSAGE(cond, message, dev_message) |
#define | FAIL(message) |
#define | FAIL_WITH_DEV_MESSAGE(message, dev_message) |
Functions | |
void | wml_exception (const char *cond, const char *file, int line, const char *function, const std::string &message, const std::string &dev_message="") |
Helper function, don't call this directly. More... | |
std::string | missing_mandatory_wml_key (const std::string §ion, const std::string &key, const std::string &primary_key="", const std::string &primary_value="") |
Returns a standard message for a missing wml key. More... | |
std::string | deprecate_wml_key_warning (const std::string &key, const std::string &removal_version) |
Returns a standard warning message for using a deprecated wml key. More... | |
std::string | deprecated_renamed_wml_key_warning (const std::string &deprecated_key, const std::string &key, const std::string &removal_version) |
Returns a standard warning message for using a deprecated renamed wml key. More... | |
const config::attribute_value & | get_renamed_config_attribute (const config &cfg, const std::string &deprecated_key, const std::string &key, const std::string &removal_version) |
Returns a config attribute, using either the old name or the new one. More... | |
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that might crash the game.
Definition in file wml_exception.hpp.
#define FAIL | ( | message | ) |
Definition at line 68 of file wml_exception.hpp.
Referenced by make_enum_detail::debug_conversion_error(), and basic_unit_filter_impl::internal_matches_filter().
#define FAIL_WITH_DEV_MESSAGE | ( | message, | |
dev_message | |||
) |
Definition at line 76 of file wml_exception.hpp.
The macro to use for the validation of WML.
cond | The condition to test, if false and exception is generated. |
message | The translatable message to show at the user. |
Definition at line 49 of file wml_exception.hpp.
Referenced by battle_context::battle_context(), gui2::build(), gui2::implementation::tbuilder_slider::build(), battle_context::choose_defender_weapon(), pathfind::shortest_path_calculator::cost(), gui2::create_builder_widget(), default_map_generator_job::default_generate_map(), expand_partialresolution(), gui2::find_widget(), gui2::policy::select_action::tselect::init(), gui2::twindow::layout(), gui2::load_settings(), gui2::tgui_definition::load_widget_definitions(), gui2::tcampaign_selection::pre_show(), gui2::tgame_version::pre_show(), gui2::tgui_definition::read(), gui2::twindow_builder::read(), preferences::server_list(), t_translation::string_to_layer_(), theme::tborder::tborder(), gui2::tbuilder_grid::tbuilder_grid(), gui2::implementation::tbuilder_horizontal_listbox::tbuilder_horizontal_listbox(), gui2::implementation::tbuilder_listbox::tbuilder_listbox(), gui2::implementation::tbuilder_multi_page::tbuilder_multi_page(), gui2::implementation::tbuilder_pane::tbuilder_pane(), gui2::implementation::tbuilder_panel::tbuilder_panel(), gui2::implementation::tbuilder_scrollbar_panel::tbuilder_scrollbar_panel(), gui2::implementation::tbuilder_stacked_widget::tbuilder_stacked_widget(), gui2::implementation::tbuilder_toggle_panel::tbuilder_toggle_panel(), gui2::implementation::tbuilder_tree_view::tbuilder_tree_view(), gui2::tcontrol_definition::tcontrol_definition(), terrain_type::terrain_type(), gui2::tscrollbar_panel_definition::tresolution::tresolution(), gui2::tvertical_scrollbar_definition::tresolution::tresolution(), gui2::thorizontal_scrollbar_definition::tresolution::tresolution(), gui2::tunit_preview_pane_definition::tresolution::tresolution(), gui2::tscroll_label_definition::tresolution::tresolution(), gui2::tstacked_widget_definition::tresolution::tresolution(), gui2::twindow_builder::tresolution::tresolution(), gui2::ttree_view_definition::tresolution::tresolution(), gui2::tmulti_page_definition::tresolution::tresolution(), gui2::tslider_definition::tresolution::tresolution(), gui2::tlistbox_definition::tresolution::tresolution(), gui2::tstate_definition::tstate_definition(), gui2::twindow_builder::tresolution::ttip::ttip(), gui2::implementation::ttree_node::ttree_node(), gui2::ttree_view_node::ttree_view_node(), and font::word_wrap_text().
Definition at line 56 of file wml_exception.hpp.
Referenced by gui2::implementation::tbuilder_control::tbuilder_control().
std::string deprecate_wml_key_warning | ( | const std::string & | key, |
const std::string & | removal_version | ||
) |
Returns a standard warning message for using a deprecated wml key.
key | The deprecated key. |
removal_version | The version in which the key will be removed key. |
Definition at line 103 of file wml_exception.cpp.
References vgettext().
std::string deprecated_renamed_wml_key_warning | ( | const std::string & | deprecated_key, |
const std::string & | key, | ||
const std::string & | removal_version | ||
) |
Returns a standard warning message for using a deprecated renamed wml key.
deprecated_key | The deprecated key. |
key | The new key to be used. |
removal_version | The version in which the key will be removed key. |
Definition at line 118 of file wml_exception.cpp.
References vgettext().
Referenced by get_renamed_config_attribute().
const config::attribute_value& get_renamed_config_attribute | ( | const config & | cfg, |
const std::string & | deprecated_key, | ||
const std::string & | key, | ||
const std::string & | removal_version | ||
) |
Returns a config attribute, using either the old name or the new one.
The function first tries the find the attribute using key
and if that doesn't find the attribute it tries deprecated_key
. If that test finds an attribute it will issue a warning and return the result. Else returns an empty attribute.
cfg | The config to get the attribute from. |
deprecated_key | The deprecated key. |
key | The new key to be used. |
removal_version | The version in which the key will be removed key. |
Definition at line 139 of file wml_exception.cpp.
References deprecated_renamed_wml_key_warning(), config::get(), and lg::wml_error().
std::string missing_mandatory_wml_key | ( | const std::string & | section, |
const std::string & | key, | ||
const std::string & | primary_key = "" , |
||
const std::string & | primary_value = "" |
||
) |
Returns a standard message for a missing wml key.
section | The section is which the key should appear (this should include the section brackets). It may contain parent sections to make it easier to find the wanted sections. They are listed like [parent][child][section]. |
key | The omitted key. |
primary_key | The primary key of the section. |
primary_value | The value of the primary key (mandatory if primary key isn't empty). |
Definition at line 71 of file wml_exception.cpp.
References vgettext(), and WRN_NG.
Referenced by expand_partialresolution(), gui2::tgui_definition::read(), gui2::twindow_builder::read(), gui2::tcontrol_definition::tcontrol_definition(), terrain_type::terrain_type(), gui2::tvertical_scrollbar_definition::tresolution::tresolution(), gui2::thorizontal_scrollbar_definition::tresolution::tresolution(), gui2::twindow_builder::tresolution::tresolution(), gui2::tslider_definition::tresolution::tresolution(), gui2::twindow_builder::tresolution::ttip::ttip(), and gui2::implementation::ttree_node::ttree_node().
void wml_exception | ( | const char * | cond, |
const char * | file, | ||
int | line, | ||
const char * | function, | ||
const std::string & | message, | ||
const std::string & | dev_message = "" |
||
) |
Helper function, don't call this directly.
cond | The textual presentation of the test that failed. |
file | The file in which the test failed. |
line | The line at which the test failed. |
function | The function in which the test failed. |
message | The translated message to show the user. |
Definition at line 33 of file wml_exception.cpp.