The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
wml_exception.cpp File Reference

Implementation for wml_exception.hpp. More...

#include "global.hpp"
#include "wml_exception.hpp"
#include "gettext.hpp"
#include "gui/dialogs/message.hpp"
#include "formula/string_utils.hpp"
#include "log.hpp"
Include dependency graph for wml_exception.cpp:

Go to the source code of this file.

Macros

#define GETTEXT_DOMAIN   "wesnoth-lib"
 
#define WRN_NG   LOG_STREAM(warn, log_engine)
 

Functions

void wml_exception (const char *cond, const char *file, const 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 &section, 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_valueget_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...
 

Variables

static lg::log_domain log_engine ("engine")
 

Detailed Description

Implementation for wml_exception.hpp.

Definition in file wml_exception.cpp.

Macro Definition Documentation

#define GETTEXT_DOMAIN   "wesnoth-lib"

Definition at line 20 of file wml_exception.cpp.

#define WRN_NG   LOG_STREAM(warn, log_engine)

Definition at line 31 of file wml_exception.cpp.

Referenced by missing_mandatory_wml_key().

Function Documentation

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.

Parameters
keyThe deprecated key.
removal_versionThe version in which the key will be removed key.
Returns
The warning message.

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.

Parameters
deprecated_keyThe deprecated key.
keyThe new key to be used.
removal_versionThe version in which the key will be removed key.
Returns
The warning message.

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.

Note
This function is not a member of config, since that would add additional dependencies to the core library.
Parameters
cfgThe config to get the attribute from.
deprecated_keyThe deprecated key.
keyThe new key to be used.
removal_versionThe version in which the key will be removed key.
Returns
The attribute found as described above.

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.

Parameters
sectionThe 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].
keyThe omitted key.
primary_keyThe primary key of the section.
primary_valueThe value of the primary key (mandatory if primary key isn't empty).
Returns
The error message.

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.

Parameters
condThe textual presentation of the test that failed.
fileThe file in which the test failed.
lineThe line at which the test failed.
functionThe function in which the test failed.
messageThe translated message to show the user.

Definition at line 33 of file wml_exception.cpp.

Variable Documentation

lg::log_domain log_engine("engine")
static