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 | wml_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 | throw_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 59 of file wml_exception.hpp.
Referenced by gui2::build(), gui2::builder_grid::builder_grid(), gui2::create_widget_builder(), make_enum_detail::debug_conversion_error(), gui2::get_control(), gui2::policy::select_action::selection::init(), gui2::parse_linked_group_definitions(), and gui2::implementation::parse_visibility().
#define FAIL_WITH_DEV_MESSAGE | ( | message, | |
dev_message | |||
) |
Definition at line 64 of file wml_exception.hpp.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::get_selected_item(), and gui2::tree_view_node::tree_view_node().
#define VALIDATE | ( | cond, | |
message | |||
) |
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 40 of file wml_exception.hpp.
Referenced by gui2::dialogs::mp_options_helper::add_node_and_get_widget(), gui2::multi_page::add_page(), theme::border_t::border_t(), gui2::implementation::builder_slider::build(), gui2::build_single_widget_instance_helper(), gui2::implementation::builder_grid_listbox::builder_grid_listbox(), gui2::implementation::builder_horizontal_listbox::builder_horizontal_listbox(), gui2::implementation::builder_listbox::builder_listbox(), gui2::implementation::builder_multi_page::builder_multi_page(), gui2::implementation::builder_pane::builder_pane(), gui2::implementation::builder_panel::builder_panel(), gui2::implementation::builder_scrollbar_panel::builder_scrollbar_panel(), gui2::implementation::builder_size_lock::builder_size_lock(), gui2::implementation::builder_stacked_widget::builder_stacked_widget(), gui2::implementation::builder_toggle_panel::builder_toggle_panel(), gui2::implementation::builder_tree_view::builder_tree_view(), gui2::size_lock::calculate_best_size(), battle_context::choose_defender_weapon(), pathfind::shortest_path_calculator::cost(), gui2::create_widget_builder(), default_map_generator_job::default_generate_map(), gui2::line_shape::draw(), gui2::rectangle_shape::draw(), gui2::round_rectangle_shape::draw(), gui2::text_shape::draw(), expand_partialresolution(), gui2::find_widget(), gui2::get_control(), gui2::get_window_builder(), gui2::gui_definition::gui_definition(), gui2::init(), gui2::window::layout(), gui2::parse_linked_group_definitions(), gui2::implementation::parse_list_data(), gui2::dialogs::server_info::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::preferences_dialog::pre_show(), gamemap::read(), gui2::builder_window::read(), gui2::scrollbar_panel_definition::resolution::resolution(), gui2::vertical_scrollbar_definition::resolution::resolution(), gui2::horizontal_scrollbar_definition::resolution::resolution(), gui2::size_lock_definition::resolution::resolution(), gui2::unit_preview_pane_definition::resolution::resolution(), gui2::scroll_label_definition::resolution::resolution(), gui2::stacked_widget_definition::resolution::resolution(), gui2::addon_list_definition::resolution::resolution(), gui2::tree_view_definition::resolution::resolution(), gui2::multi_page_definition::resolution::resolution(), gui2::slider_definition::resolution::resolution(), gui2::chatbox_definition::resolution::resolution(), gui2::listbox_definition::resolution::resolution(), gui2::policy::select_action::selection::select(), gui2::slider::set_value_range(), gui2::state_definition::state_definition(), t_translation::string_to_layer_(), gui2::styled_widget_definition::styled_widget_definition(), terrain_type::terrain_type(), gui2::text_shape::text_shape(), gui2::builder_window::window_resolution::tooltip_info::tooltip_info(), gui2::implementation::tree_node::tree_node(), and gui2::builder_window::window_resolution::window_resolution().
#define VALIDATE_WITH_DEV_MESSAGE | ( | cond, | |
message, | |||
dev_message | |||
) |
Definition at line 47 of file wml_exception.hpp.
Referenced by gui2::implementation::builder_styled_widget::builder_styled_widget(), gui2::image_shape::dimension_validation(), and gui2::circle_shape::draw().
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. |
Definition at line 102 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. |
Definition at line 117 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 138 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 70 of file wml_exception.cpp.
References VGETTEXT, and WRN_NG.
Referenced by expand_partialresolution(), gui2::gui_definition::gui_definition(), gui2::parse_linked_group_definitions(), gui2::implementation::parse_list_data(), gui2::builder_window::read(), gui2::vertical_scrollbar_definition::resolution::resolution(), gui2::horizontal_scrollbar_definition::resolution::resolution(), gui2::slider_definition::resolution::resolution(), gui2::styled_widget_definition::styled_widget_definition(), terrain_type::terrain_type(), gui2::builder_window::window_resolution::tooltip_info::tooltip_info(), gui2::implementation::tree_node::tree_node(), and gui2::builder_window::window_resolution::window_resolution().
void throw_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. |
dev_message | Any additional information that might be useful to a developer. |
Definition at line 32 of file wml_exception.cpp.