Removed the heavyweight tstring argument,

...since in most cases, if not all, the string had already been
translated at that point.
This commit is contained in:
Guillaume Melquiond 2010-07-30 06:41:01 +00:00
parent 8dfe3b6d8b
commit d628621cfd
2 changed files with 14 additions and 35 deletions

View file

@ -29,24 +29,18 @@
void wml_exception(const char* cond, const char* file,
const int line, const char* function, const t_string& message)
int line, const char *function, const std::string &message)
{
std::stringstream sstr;
std::ostringstream sstr;
sstr << "Condition '" << cond << "' failed at "
<< file << ":" << line << " in function '" << function << "'.";
throw twml_exception(message, sstr.str());
}
twml_exception::twml_exception(const t_string& user_msg, const std::string& dev_msg) :
user_message(user_msg),
dev_message(dev_msg)
{
}
void twml_exception::show(display &disp)
{
std::stringstream sstr;
std::ostringstream sstr;
// The extra spaces between the \n are needed, otherwise the dialog doesn't show
// an empty line.
@ -58,7 +52,7 @@ void twml_exception::show(display &disp)
gui2::show_error_message(disp.video(), sstr.str());
}
t_string missing_mandatory_wml_key(const std::string& section, const std::string& key,
std::string missing_mandatory_wml_key(const std::string &section, const std::string &key,
const std::string& primary_key, const std::string& primary_value)
{
utils::string_map symbols;
@ -70,10 +64,10 @@ t_string missing_mandatory_wml_key(const std::string& section, const std::string
symbols["primary_key"] = primary_key;
symbols["primary_value"] = primary_value;
return t_string(vgettext("In section '[$section|]' where '$primary_key| = "
"$primary_value' the mandatory key '$key|' isn't set.", symbols));
return vgettext("In section '[$section|]' where '$primary_key| = "
"$primary_value' the mandatory key '$key|' isn't set.", symbols);
} else {
return t_string(vgettext("In section '[$section|]' the "
"mandatory key '$key|' isn't set.", symbols));
return vgettext("In section '[$section|]' the "
"mandatory key '$key|' isn't set.", symbols);
}
}

View file

@ -21,8 +21,6 @@
#ifndef WML_EXCEPTION_HPP_INCLUDED
#define WML_EXCEPTION_HPP_INCLUDED
#include "tstring.hpp"
#include <exception>
#include <string>
@ -55,36 +53,23 @@ class display;
* @param file The file in which the test failed.
* @param line The line at which the test failed.
* @param function The funtion in which the test failed.
* @param message The translatable message to show the user.
* @param message The translated message to show the user.
*/
void wml_exception(const char* cond, const char* file,
const int line, const char* function, const t_string& message);
/** Helper function, don't call this directly. */
inline void wml_exception(const char* cond, const char* file,
const int line, const char* function, const char* message)
{
wml_exception(cond, file, line, function, t_string(message));
}
/** Helper function, don't call this directly. */
inline void wml_exception(const char* cond, const char* file,
const int line, const char* function, const std::string& message)
{
wml_exception(cond, file, line, function, t_string(message));
}
int line, const char *function, const std::string &message);
/** Helper class, don't construct this directly. */
struct twml_exception: std::exception
{
twml_exception(const t_string& user_msg, const std::string& dev_msg);
twml_exception(const std::string &user_msg, const std::string &dev_msg)
: user_message(user_msg), dev_message(dev_msg) {}
~twml_exception() throw() {}
/**
* The message for the user explaining what went wrong. This message can
* be translated so the user gets a explanation in his/her native tongue.
*/
t_string user_message;
std::string user_message;
/**
* The message for developers telling which problem was triggered, this
@ -115,7 +100,7 @@ struct twml_exception: std::exception
*
* @return The error message.
*/
t_string missing_mandatory_wml_key(const std::string& section, const std::string& key,
std::string missing_mandatory_wml_key(const std::string& section, const std::string& key,
const std::string& primary_key = "", const std::string& primary_value = "");
#endif