Add a special kind of assert to validate whether the input from WML doesn't contain any problems that might crash the game. More...
#include "config.hpp"#include "lua_jailbreak_exception.hpp"#include <string>
Go to the source code of this file.
Classes | |
| struct | twml_exception |
| Helper class, don't construct this directly. More... | |
Defines | |
| #define | VALIDATE(cond, message) |
| The macro to use for the validation of WML. | |
| #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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
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 | ) |
do { \ wml_exception(NULL, __FILE__, __LINE__, __func__, message); \ /* wml_exception never returns. */ \ /* Help the compiler to figure that out */ \ throw 42; \ } while(0)
Definition at line 69 of file wml_exception.hpp.
| #define FAIL_WITH_DEV_MESSAGE | ( | message, | ||
| dev_message | ||||
| ) |
do { \ wml_exception(NULL \ , __FILE__ \ , __LINE__ \ , __func__ \ , message \ , dev_message); \ /* wml_exception never returns. */ \ /* Help the compiler to figure that out */ \ throw 42; \ } while(0)
Definition at line 77 of file wml_exception.hpp.
| #define VALIDATE | ( | cond, | ||
| message | ||||
| ) |
do { \ if(!(cond)) { \ wml_exception(#cond, __FILE__, __LINE__, __func__, message); \ } \ } while(0)
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 50 of file wml_exception.hpp.
Referenced by ai::testing_ai_default::recruitment_phase::analyze_potential_recruit_combat(), battle_context::battle_context(), gui2::implementation::tbuilder_panel::build(), battle_context::choose_defender_weapon(), pathfind::shortest_path_calculator::cost(), default_generate_map(), gui2::find_widget(), ai::ai_default_recruitment_stage::get_combat_score_vs(), gui2::twindow::layout(), attack::perform(), gui2::twindow_builder::read(), gamemap::set_usage(), 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_scrollbar_panel::tbuilder_scrollbar_panel(), gui2::implementation::tbuilder_stacked_widget::tbuilder_stacked_widget(), gui2::implementation::tbuilder_toggle_panel::tbuilder_toggle_panel(), gui2::tcontrol_definition::tcontrol_definition(), terrain_type::terrain_type(), tportrait::tportrait(), gui2::twindow_builder::tresolution::tresolution(), gui2::twindow_builder::tresolution::ttip::ttip(), and gui2::ttree_view_node::ttree_view_node().
| #define VALIDATE_WITH_DEV_MESSAGE | ( | cond, | ||
| message, | ||||
| dev_message | ||||
| ) |
do { \ if(!(cond)) { \ wml_exception(#cond \ , __FILE__ \ , __LINE__ \ , __func__ \ , message \ , dev_message); \ } \ } while(0)
Definition at line 57 of file wml_exception.hpp.
Referenced by gui2::implementation::tbuilder_control::tbuilder_control(), and WML_HANDLER_FUNCTION().
| 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 105 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 120 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 141 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 ommitted 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 73 of file wml_exception.cpp.
References vgettext(), and WRN_NG.
Referenced by gui2::twindow_builder::read(), gui2::tcontrol_definition::tcontrol_definition(), terrain_type::terrain_type(), tportrait::tportrait(), gui2::twindow_builder::tresolution::tresolution(), and gui2::twindow_builder::tresolution::ttip::ttip().


| 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 35 of file wml_exception.cpp.
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:11:16 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |