Use cleaner format for formatter() when possible
This commit is contained in:
parent
7154a587b8
commit
6130c668c4
11 changed files with 47 additions and 47 deletions
|
@ -204,9 +204,9 @@ addon_op_result do_resolve_addon_dependencies(CVideo& v, addons_client& client,
|
|||
//
|
||||
|
||||
const std::string sep(1, COLUMN_SEPARATOR);
|
||||
const std::string& header = (formatter() << HEADING_PREFIX << sep <<
|
||||
const std::string& header = formatter() << HEADING_PREFIX << sep <<
|
||||
_("Name") << sep << _("Version") << sep << _("Author") << sep <<
|
||||
_("Size") << sep << _("Type")).str();
|
||||
_("Size") << sep << _("Type");
|
||||
|
||||
std::vector<std::string> options(1, header);
|
||||
std::vector<int> sort_sizes;
|
||||
|
|
|
@ -52,7 +52,7 @@ const version_table_manager versions;
|
|||
#if 0
|
||||
std::string format_version(unsigned a, unsigned b, unsigned c)
|
||||
{
|
||||
return (formatter() << a << '.' << b << '.' << c).str();
|
||||
return formatter() << a << '.' << b << '.' << c;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -259,10 +259,10 @@ std::string os_version()
|
|||
|
||||
version += " (";
|
||||
// Add internal version numbers.
|
||||
version += (formatter()
|
||||
version += formatter()
|
||||
<< v.dwMajorVersion << '.'
|
||||
<< v.dwMinorVersion << '.'
|
||||
<< v.dwBuildNumber).str();
|
||||
<< v.dwBuildNumber;
|
||||
version += ")";
|
||||
|
||||
return base + " " + version;
|
||||
|
|
|
@ -404,9 +404,9 @@ variant variant::operator[](const variant& v) const
|
|||
}
|
||||
return operator[](v.as_int());
|
||||
} else {
|
||||
throw type_error((formatter() << "type error: "
|
||||
throw type_error(formatter() << "type error: "
|
||||
<< " expected a list or a map but found " << type_string()
|
||||
<< " (" << to_debug_string() << ")").str());
|
||||
<< " (" << to_debug_string() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,9 +481,9 @@ size_t variant::num_elements() const
|
|||
assert(map_);
|
||||
return map_->size();
|
||||
} else {
|
||||
throw type_error((formatter() << "type error: "
|
||||
throw type_error(formatter() << "type error: "
|
||||
<< " expected a list or a map but found " << type_string()
|
||||
<< " (" << to_debug_string() << ")").str());
|
||||
<< " (" << to_debug_string() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,9 +516,9 @@ int variant::as_decimal() const
|
|||
} else if( type_ == TYPE_NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
throw type_error((formatter() << "type error: "
|
||||
throw type_error(formatter() << "type error: "
|
||||
<< " expected integer or decimal but found " << type_string()
|
||||
<< " (" << to_debug_string() << ")").str());
|
||||
<< " (" << to_debug_string() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ variant variant::operator/(const variant& v) const
|
|||
int denominator = v.as_decimal();
|
||||
|
||||
if(denominator == 0) {
|
||||
throw type_error((formatter() << "divide by zero error").str());
|
||||
throw type_error(formatter() << "divide by zero error");
|
||||
}
|
||||
|
||||
long long long_int = as_decimal();
|
||||
|
@ -662,7 +662,7 @@ variant variant::operator/(const variant& v) const
|
|||
const int numerator = as_int();
|
||||
const int denominator = v.as_int();
|
||||
if(denominator == 0) {
|
||||
throw type_error((formatter() << "divide by zero error").str());;
|
||||
throw type_error(formatter() << "divide by zero error");
|
||||
}
|
||||
|
||||
return variant(numerator/denominator);
|
||||
|
@ -674,7 +674,7 @@ variant variant::operator%(const variant& v) const
|
|||
const int numerator = as_decimal();
|
||||
const int denominator = v.as_decimal();
|
||||
if(denominator == 0) {
|
||||
throw type_error((formatter() << "divide by zero error").str());
|
||||
throw type_error(formatter() << "divide by zero error");
|
||||
}
|
||||
|
||||
return variant(numerator%denominator, DECIMAL_VARIANT);
|
||||
|
@ -682,7 +682,7 @@ variant variant::operator%(const variant& v) const
|
|||
const int numerator = as_int();
|
||||
const int denominator = v.as_int();
|
||||
if(denominator == 0) {
|
||||
throw type_error((formatter() << "divide by zero error").str());
|
||||
throw type_error(formatter() << "divide by zero error");
|
||||
}
|
||||
|
||||
return variant(numerator%denominator);
|
||||
|
@ -935,11 +935,11 @@ variant variant::concatenate(const variant& v) const
|
|||
std::string res = as_string() + v.as_string();
|
||||
return variant( res );
|
||||
} else {
|
||||
throw type_error((formatter() << "type error: expected two "
|
||||
throw type_error(formatter() << "type error: expected two "
|
||||
<< " lists or two maps but found " << type_string()
|
||||
<< " (" << to_debug_string() << ")"
|
||||
<< " and " << v.type_string()
|
||||
<< " (" << v.to_debug_string() << ")").str());
|
||||
<< " (" << v.to_debug_string() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -962,11 +962,11 @@ variant variant::build_range(const variant& v) const {
|
|||
|
||||
bool variant::contains(const variant& v) const {
|
||||
if(type_ != TYPE_LIST && type_ != TYPE_MAP) {
|
||||
throw type_error((formatter() << "type error: expected "
|
||||
throw type_error(formatter() << "type error: expected "
|
||||
<< variant_type_to_string(TYPE_LIST) << " or "
|
||||
<< variant_type_to_string(TYPE_MAP) << " but found "
|
||||
<< variant_type_to_string(type_)
|
||||
<< " (" << to_debug_string() << ")").str());
|
||||
<< " (" << to_debug_string() << ")");
|
||||
}
|
||||
|
||||
if(type_ == TYPE_LIST) {
|
||||
|
@ -981,9 +981,9 @@ bool variant::contains(const variant& v) const {
|
|||
void variant::must_be(variant::TYPE t) const
|
||||
{
|
||||
if(type_ != t) {
|
||||
throw type_error((formatter() << "type error: " << " expected "
|
||||
throw type_error(formatter() << "type error: " << " expected "
|
||||
<< variant_type_to_string(t) << " but found " << type_string()
|
||||
<< " (" << to_debug_string() << ")").str());
|
||||
<< " (" << to_debug_string() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -905,24 +905,24 @@ void tcircle::draw(surface& canvas,
|
|||
VALIDATE_WITH_DEV_MESSAGE(
|
||||
static_cast<int>(x - radius) >= 0,
|
||||
_("Circle doesn't fit on canvas."),
|
||||
(formatter() << "x = " << x << ", radius = " << radius).str());
|
||||
formatter() << "x = " << x << ", radius = " << radius);
|
||||
|
||||
VALIDATE_WITH_DEV_MESSAGE(
|
||||
static_cast<int>(y - radius) >= 0,
|
||||
_("Circle doesn't fit on canvas."),
|
||||
(formatter() << "y = " << y << ", radius = " << radius).str());
|
||||
formatter() << "y = " << y << ", radius = " << radius);
|
||||
|
||||
VALIDATE_WITH_DEV_MESSAGE(
|
||||
static_cast<int>(x + radius) < canvas->w,
|
||||
_("Circle doesn't fit on canvas."),
|
||||
(formatter() << "x = " << x << ", radius = " << radius
|
||||
<< "', canvas width = " << canvas->w << ".").str());
|
||||
formatter() << "x = " << x << ", radius = " << radius
|
||||
<< "', canvas width = " << canvas->w << ".");
|
||||
|
||||
VALIDATE_WITH_DEV_MESSAGE(
|
||||
static_cast<int>(y + radius) < canvas->h,
|
||||
_("Circle doesn't fit on canvas."),
|
||||
(formatter() << "y = " << y << ", radius = " << radius
|
||||
<< "', canvas height = " << canvas->h << ".").str());
|
||||
formatter() << "y = " << y << ", radius = " << radius
|
||||
<< "', canvas height = " << canvas->h << ".");
|
||||
|
||||
// lock the surface
|
||||
surface_lock locker(canvas);
|
||||
|
@ -1106,16 +1106,16 @@ void timage::draw(surface& canvas,
|
|||
unsigned w = w_(local_variables);
|
||||
VALIDATE_WITH_DEV_MESSAGE(static_cast<int>(w) >= 0,
|
||||
_("Image doesn't fit on canvas."),
|
||||
(formatter() << "Image '" << name
|
||||
formatter() << "Image '" << name
|
||||
<< "', w = " << static_cast<int>(w)
|
||||
<< ".").str());
|
||||
<< ".");
|
||||
|
||||
unsigned h = h_(local_variables);
|
||||
VALIDATE_WITH_DEV_MESSAGE(static_cast<int>(h) >= 0,
|
||||
_("Image doesn't fit on canvas."),
|
||||
(formatter() << "Image '" << name
|
||||
formatter() << "Image '" << name
|
||||
<< "', h = " << static_cast<int>(h)
|
||||
<< ".").str());
|
||||
<< ".");
|
||||
|
||||
local_variables.add("image_width", variant(w ? w : image_->w));
|
||||
local_variables.add("image_height", variant(h ? h : image_->h));
|
||||
|
@ -1123,16 +1123,16 @@ void timage::draw(surface& canvas,
|
|||
const unsigned x = x_(local_variables);
|
||||
VALIDATE_WITH_DEV_MESSAGE(static_cast<int>(x) >= 0,
|
||||
_("Image doesn't fit on canvas."),
|
||||
(formatter() << "Image '" << name
|
||||
formatter() << "Image '" << name
|
||||
<< "', x = " << static_cast<int>(x)
|
||||
<< ".").str());
|
||||
<< ".");
|
||||
|
||||
const unsigned y = y_(local_variables);
|
||||
VALIDATE_WITH_DEV_MESSAGE(static_cast<int>(y) >= 0,
|
||||
_("Image doesn't fit on canvas."),
|
||||
(formatter() << "Image '" << name
|
||||
formatter() << "Image '" << name
|
||||
<< "', y = " << static_cast<int>(y)
|
||||
<< ".").str());
|
||||
<< ".");
|
||||
|
||||
// Copy the data to local variables to avoid overwriting the originals.
|
||||
SDL_Rect src_clip = src_clip_;
|
||||
|
|
|
@ -664,8 +664,8 @@ tbuilder_control::tbuilder_control(const config& cfg)
|
|||
VALIDATE_WITH_DEV_MESSAGE(
|
||||
help.empty() || !tooltip.empty(),
|
||||
_("Found a widget with a helptip and without a tooltip."),
|
||||
(formatter() << "id '" << id << "' label '" << label
|
||||
<< "' helptip '" << help << "'.").str());
|
||||
formatter() << "id '" << id << "' label '" << label
|
||||
<< "' helptip '" << help << "'.");
|
||||
|
||||
|
||||
DBG_GUI_P << "Window builder: found control with id '" << id
|
||||
|
|
|
@ -56,7 +56,7 @@ std::string get_child_id(const std::string& parent_id,
|
|||
// strings. No idea why so switched to using the good old lexical_cast
|
||||
// instead.
|
||||
|
||||
// return (formatter() << parent_id << "_C_" << row << '_' << col).c_str();
|
||||
// return formatter() << parent_id << "_C_" << row << '_' << col;
|
||||
std::string result = parent_id + "_C_" + std::to_string(row)
|
||||
+ '_' + std::to_string(col);
|
||||
|
||||
|
@ -91,7 +91,7 @@ std::string get_base_filename()
|
|||
static unsigned counter = 0;
|
||||
++counter;
|
||||
|
||||
return (formatter() << buf << '_' << counter << '_').str();
|
||||
return formatter() << buf << '_' << counter << '_';
|
||||
}
|
||||
/***** ***** ***** ***** FLAGS ***** ***** ***** *****/
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ t_string tslider::get_value_label() const
|
|||
return maximum_value_label_;
|
||||
}
|
||||
|
||||
return t_string((formatter() << get_value()).str());
|
||||
return t_string(formatter() << get_value());
|
||||
}
|
||||
|
||||
void tslider::child_callback_positioner_moved()
|
||||
|
|
|
@ -64,9 +64,9 @@ uint32_t mt_rng::get_next_random()
|
|||
{
|
||||
uint32_t result = mt_();
|
||||
++random_calls_;
|
||||
DBG_RND << (formatter() << "pulled user random " << result
|
||||
DBG_RND << "pulled user random " << result
|
||||
<< " for call " << random_calls_
|
||||
<< " with seed " << std::hex << random_seed_).str() << std::endl;
|
||||
<< " with seed " << std::hex << random_seed_ << std::endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -81,8 +81,8 @@ void mt_rng::seed_random(const uint32_t seed, const unsigned int call_count)
|
|||
random_seed_ = seed;
|
||||
mt_.seed(random_seed_);
|
||||
discard(call_count); //mt_.discard(call_count);
|
||||
DBG_RND << (formatter() << "Seeded random with " << std::hex << random_seed_ << " with "
|
||||
<< random_calls_ << " calls.").str() << std::endl;
|
||||
DBG_RND << "Seeded random with " << std::hex << random_seed_ << " with "
|
||||
<< random_calls_ << " calls." << std::endl;
|
||||
}
|
||||
|
||||
void mt_rng::seed_random(const std::string & seed_str, const unsigned int call_count)
|
||||
|
|
|
@ -639,8 +639,8 @@ ingame_savegame::ingame_savegame(saved_game &gamestate,
|
|||
|
||||
void ingame_savegame::create_filename()
|
||||
{
|
||||
set_filename((formatter() << gamestate().classification().label
|
||||
<< " " << _("Turn") << " " << gamestate().get_starting_pos()["turn_at"]).str());
|
||||
set_filename(formatter() << gamestate().classification().label
|
||||
<< " " << _("Turn") << " " << gamestate().get_starting_pos()["turn_at"]);
|
||||
}
|
||||
|
||||
void ingame_savegame::write_game(config_writer &out) {
|
||||
|
|
|
@ -3545,7 +3545,7 @@ int game_lua_kernel::intf_modify_side(lua_State *L)
|
|||
*/
|
||||
int game_lua_kernel::intf_get_sides(lua_State* L)
|
||||
{
|
||||
LOG_LUA << "intf_get_sides called: this = " << (formatter() << std::hex << this).str() << " myname = " << my_name() << std::endl;
|
||||
LOG_LUA << "intf_get_sides called: this = " << std::hex << this << " myname = " << my_name() << std::endl;
|
||||
std::vector<int> sides;
|
||||
const vconfig ssf = luaW_checkvconfig(L, 1, true);
|
||||
if(ssf.null()){
|
||||
|
|
Loading…
Add table
Reference in a new issue