Skip to content

Commit

Permalink
Migrate a lot more boost.format occurrences.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 15, 2017
1 parent f6f14a6 commit 115ebcc
Show file tree
Hide file tree
Showing 44 changed files with 148 additions and 158 deletions.
1 change: 0 additions & 1 deletion libs/wxutil/FileChooser.cpp
Expand Up @@ -12,7 +12,6 @@
#include "dialog/MessageBox.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/format.hpp>
#include <wx/app.h>

namespace wxutil
Expand Down
4 changes: 2 additions & 2 deletions libs/wxutil/ScopeTimer.h
Expand Up @@ -2,7 +2,7 @@

#include "itextstream.h"
#include <wx/stopwatch.h>
#include <boost/format.hpp>
#include <fmt/format.h>

namespace wxutil
{
Expand All @@ -24,7 +24,7 @@ class ScopeTimer
{
double elapsed_time = _timer.Time() / 1000.f;

rMessage() << _message << " timer: " << (boost::format("%5.2lf") % elapsed_time).str()
rMessage() << _message << " timer: " << fmt::format("{0:5.2f}", elapsed_time)
<< " second(s) elapsed" << std::endl;
}
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.conversation/CommandArgumentItem.cpp
Expand Up @@ -17,7 +17,7 @@

#include "wxutil/ChoiceHelper.h"

#include <boost/format.hpp>
#include <fmt/format.h>

#include "CommandEditor.h"
#include "ActorNodeFinder.h"
Expand Down Expand Up @@ -115,7 +115,7 @@ ActorArgument::ActorArgument(CommandEditor& owner,
for (conversation::Conversation::ActorMap::const_iterator i = dummy.begin();
i != dummy.end(); ++i)
{
std::string actorStr = (boost::format(_("Actor %d (%s)")) % i->first % i->second).str();
std::string actorStr = fmt::format(_("Actor {0:d} ({1})"), i->first, i->second);

// Store the actor ID into a client data object and pass it along
_comboBox->Append(actorStr, new wxStringClientData(string::to_string(i->first)));
Expand Down
6 changes: 3 additions & 3 deletions plugins/dm.conversation/ConversationDialog.cpp
Expand Up @@ -19,7 +19,7 @@
#include <wx/button.h>
#include <wx/sizer.h>

#include <boost/format.hpp>
#include <fmt/format.h>
#include <iostream>

namespace ui
Expand Down Expand Up @@ -277,8 +277,8 @@ void ConversationDialog::onAddEntity(wxCommandEvent& ev)
{
// conversation entityclass was not found
wxutil::Messagebox::ShowError(
(boost::format(_("Unable to create conversation Entity: class '%s' not found."))
% CONVERSATION_ENTITY_CLASS).str()
fmt::format(_("Unable to create conversation Entity: class '{0}' not found."),
CONVERSATION_ENTITY_CLASS)
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/dm.conversation/ConversationEditor.cpp
Expand Up @@ -3,7 +3,7 @@
#include "i18n.h"
#include "string/string.h"

#include <boost/format.hpp>
#include <fmt/format.h>
#include <boost/algorithm/string/join.hpp>
#include <regex>

Expand Down Expand Up @@ -229,7 +229,7 @@ void ConversationEditor::updateCommandList()
wxutil::TreeModel::Row row = _commandStore->AddItem();

row[_commandColumns.cmdNumber] = i->first;
row[_commandColumns.actorName] = (boost::format(_("Actor %d")) % cmd.actor).str();
row[_commandColumns.actorName] = fmt::format(_("Actor {0:d}"), cmd.actor);
row[_commandColumns.sentence] = removeMarkup(cmd.getSentence());
row[_commandColumns.wait] = cmd.waitUntilFinished ? _("yes") : _("no");

Expand Down Expand Up @@ -452,7 +452,7 @@ void ConversationEditor::onValidateActors(wxCommandEvent& ev)

if (!finder.getFoundNode())
{
errors.push_back((boost::format(_("The actor %s cannot be found in the current map.")) % i.second).str());
errors.push_back(fmt::format(_("The actor {0} cannot be found in the current map."), i.second));
}
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.editing/SpawnargLinkedSpinButton.h
Expand Up @@ -5,7 +5,7 @@
#include "ientity.h"
#include "string/convert.h"
#include "util/ScopedBoolLock.h"
#include <boost/format.hpp>
#include <fmt/format.h>
#include <wx/spinctrl.h>
#include <wx/panel.h>
#include <wx/sizer.h>
Expand Down Expand Up @@ -103,7 +103,7 @@ class SpawnargLinkedSpinButton :
UndoableCommand cmd("editAIProperties");

double floatVal = _spinCtrl->GetValue();
std::string newValue = (boost::format("%." + string::to_string(_spinCtrl->GetDigits()) + "f") % floatVal).str();
std::string newValue = fmt::format("{0:." + string::to_string(_spinCtrl->GetDigits()) + "f}", floatVal);

// Check if the new value conincides with an inherited one
const EntityClassAttribute& attr = _entity->getEntityClass()->getAttribute(_propertyName);
Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.objectives/MissionLogicDialog.cpp
Expand Up @@ -4,7 +4,7 @@
#include "i18n.h"
#include "string/string.h"

#include <boost/format.hpp>
#include <fmt/format.h>

#include <wx/sizer.h>
#include <wx/stattext.h>
Expand Down Expand Up @@ -63,7 +63,7 @@ MissionLogicDialog::MissionLogicDialog(wxWindow* parent, ObjectiveEntity& object
for (LogicEditorMap::iterator i = _logicEditors.lower_bound(0);
i != _logicEditors.end(); ++i)
{
std::string logicStr = (boost::format(_("Logic for Difficulty Level %d")) % i->first).str();
std::string logicStr = fmt::format(_("Logic for Difficulty Level {0:d}"), i->first);

wxStaticText* logicLabel = new wxStaticText(this, wxID_ANY, logicStr);
logicLabel->SetFont(logicLabel->GetFont().Bold());
Expand Down
6 changes: 3 additions & 3 deletions plugins/dm.objectives/ObjectiveEntity.cpp
Expand Up @@ -12,7 +12,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/format.hpp>
#include <fmt/format.h>
#include <regex>

#include <wx/choice.h>
Expand Down Expand Up @@ -149,7 +149,7 @@ void ObjectiveEntity::writeObjectiveConditions(Entity& ent)
continue; // skip invalid conditions without increasing the index
}

std::string prefix = (boost::format(OBJ_COND_PREFIX + "%d_") % index).str();
std::string prefix = fmt::format(OBJ_COND_PREFIX + "{0:d}_", index);

ent.setKeyValue(prefix + "src_mission", string::to_string(cond.sourceMission));
ent.setKeyValue(prefix + "src_obj", string::to_string(cond.sourceObjective));
Expand Down Expand Up @@ -277,7 +277,7 @@ void ObjectiveEntity::addObjective() {

// Insert a new Objective at this ID.
Objective o;
o.description = (boost::format(_("New objective %d")) % index).str();
o.description = fmt::format(_("New objective {0:d}"), index);
_objectives.insert(ObjectiveMap::value_type(index, o));
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.objectives/ObjectiveEntityFinder.cpp
Expand Up @@ -33,7 +33,7 @@ bool ObjectiveEntityFinder::pre(const scene::INodePtr& node)
// Add the entity to the list
wxutil::TreeModel::Row row = _store->AddItem();

row[_columns.displayName] = (boost::format(_("%s at [ %s ]")) % name % ePtr->getKeyValue("origin")).str();
row[_columns.displayName] = fmt::format(_("{0} at [ {1} ]"), name, ePtr->getKeyValue("origin"));
row[_columns.entityName] = name;
row[_columns.startActive] = false;

Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.objectives/ObjectiveEntityFinder.h
Expand Up @@ -5,7 +5,7 @@
#include "i18n.h"

#include <string>
#include <boost/format.hpp>
#include <fmt/format.h>
#include "wxutil/TreeModel.h"

namespace objectives
Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.objectives/ObjectivesEditor.cpp
Expand Up @@ -23,7 +23,7 @@
#include <wx/panel.h>

#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <fmt/format.h>

namespace objectives
{
Expand Down Expand Up @@ -464,7 +464,7 @@ void ObjectivesEditor::_onAddEntity(wxCommandEvent& ev)
{
// Objective entityclass was not found
wxutil::Messagebox::ShowError(
(boost::format(_("Unable to create Objective Entity: class '%s' not found.")) % objEClass).str()
fmt::format(_("Unable to create Objective Entity: class '{0}' not found."), objEClass)
);
}
}
Expand Down
22 changes: 11 additions & 11 deletions plugins/dm.objectives/Specifier.cpp
Expand Up @@ -4,7 +4,7 @@
#include "i18n.h"
#include "itextstream.h"
#include "string/convert.h"
#include <boost/format.hpp>
#include <fmt/format.h>

namespace objectives {

Expand Down Expand Up @@ -51,35 +51,35 @@ std::string Specifier::getSentence(Component& component) {
else if (id == SpecifierType::SPEC_GROUP().getId()) {

if (_value == "loot_gold") {
result += (boost::format(_("%d loot in gold")) % amount).str();
result += fmt::format(_("{0:d} loot in gold"), amount);
}
else if (_value == "loot_goods") {
result += (boost::format(_("%d loot in goods")) % amount).str();
result += fmt::format(_("{0:d} loot in goods"), amount);
}
else if (_value == "loot_jewels") {
result += (boost::format(_("%d loot in jewels")) % amount).str();
result += fmt::format(_("{0:d} loot in jewels"), amount);
}
else if (_value == "loot_total") {
result += (boost::format(_("%d loot")) % amount).str();
result += fmt::format(_("{0:d} loot"), amount);
}
else {
result += (boost::format(_("%d of \"%s\"")) % amount % _value).str();
result += fmt::format(_("{0:d} of \"{1}\""), amount, _value);
}
}
else if (id == SpecifierType::SPEC_CLASSNAME().getId()) {
result += (boost::format(_("%s of type %s")) % printEntityAmount(amountStr) % _value).str();
result += fmt::format(_("{0} of type {1}"), printEntityAmount(amountStr), _value);
}
else if (id == SpecifierType::SPEC_SPAWNCLASS().getId()) {
result += (boost::format(_("%s of spawnclass %s")) % printEntityAmount(amountStr) % _value).str();
result += fmt::format(_("{0} of spawnclass {1}"), printEntityAmount(amountStr), _value);
}
else if (id == SpecifierType::SPEC_AI_TYPE().getId()) {
result += (boost::format(_("%s AI of type %s")) % amountStr % _value).str();
result += fmt::format(_("{0} AI of type {1}"), amountStr, _value);
}
else if (id == SpecifierType::SPEC_AI_TEAM().getId()) {
result += (boost::format(_("%s AI of team %s")) % amountStr % _value).str();
result += fmt::format(_("{0} AI of team {1}"), amountStr, _value);
}
else if (id == SpecifierType::SPEC_AI_INNOCENCE().getId()) {
result += (boost::format(_("%s AI of %s")) % amountStr % _value).str();
result += fmt::format(_("{0} AI of {1}"), amountStr, _value);
}
else {
rError() << "Unknown specifier ID " << id << "found!" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.stimresponse/precompiled.h
Expand Up @@ -10,5 +10,5 @@
#include "wxutil/TreeModel.h"
#include "wxutil/dialog/MessageBox.h"

#include <boost/format.hpp>
#include <fmt/format.h>
#include "string/string.h"
8 changes: 4 additions & 4 deletions plugins/eclassmgr/Doom3EntityClass.cpp
Expand Up @@ -8,7 +8,7 @@
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/format.hpp>
#include <fmt/format.h>
#include <boost/optional.hpp>
#include <functional>

Expand Down Expand Up @@ -297,10 +297,10 @@ void Doom3EntityClass::setColour(const Vector3& colour)

// Define fill and wire versions of the entity colour
_fillShader = _colourTransparent ?
(boost::format("[%f %f %f]") % _colour[0] % _colour[1] % _colour[2]).str() :
(boost::format("(%f %f %f)") % _colour[0] % _colour[1] % _colour[2]).str();
fmt::format("[{0:f} {1:f} {2:f}]", _colour[0], _colour[1], _colour[2]) :
fmt::format("({0:f} {1:f} {2:f})", _colour[0], _colour[1], _colour[2]);

_wireShader = (boost::format("<%f %f %f>") % _colour[0] % _colour[1] % _colour[2]).str();
_wireShader = fmt::format("<{0:f} {1:f} {2:f}>", _colour[0], _colour[1], _colour[2]);
}

const Vector3& Doom3EntityClass::getColour() const {
Expand Down
2 changes: 1 addition & 1 deletion plugins/entity/precompiled.h
Expand Up @@ -8,7 +8,7 @@
#include "precompiled_main.h"

// Some entity specifics
#include <boost/format.hpp>
#include <fmt/format.h>
#include <functional>

#include "string/string.h"
Expand Down
12 changes: 6 additions & 6 deletions plugins/mapdoom3/Doom3MapReader.cpp
Expand Up @@ -9,7 +9,7 @@
#include "Doom3MapFormat.h"

#include "i18n.h"
#include <boost/format.hpp>
#include <fmt/format.h>
#include <boost/lexical_cast.hpp>

#include "primitiveparsers/BrushDef.h"
Expand Down Expand Up @@ -47,7 +47,7 @@ void Doom3MapReader::readFromStream(std::istream& stream)
}
catch (FailureException& e)
{
std::string text = (boost::format(_("Failed parsing entity %d:\n%s")) % _entityCount % e.what()).str();
std::string text = fmt::format(_("Failed parsing entity {0:d}:\n{1}"), _entityCount, e.what());

// Re-throw with more text
throw FailureException(text);
Expand Down Expand Up @@ -108,7 +108,7 @@ void Doom3MapReader::parseMapVersion(parser::DefTokeniser& tok)
// Check we have the correct version for this module
if (version != requiredVersion)
{
std::string errMsg = (boost::format(_("Incorrect map version: required %f, found %f")) % requiredVersion % version).str();
std::string errMsg = fmt::format(_("Incorrect map version: required {0:f}, found {1:f}"), requiredVersion, version);

rError() << errMsg << std::endl;

Expand Down Expand Up @@ -141,7 +141,7 @@ void Doom3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INod

if (!primitive)
{
std::string text = (boost::format(_("Primitive #%d: parse error")) % _primitiveCount).str();
std::string text = fmt::format(_("Primitive #{0:d}: parse error"), _primitiveCount);
throw FailureException(text);
}

Expand All @@ -151,7 +151,7 @@ void Doom3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INod
catch (parser::ParseException& e)
{
// Translate ParseExceptions to FailureExceptions
std::string text = (boost::format(_("Primitive #%d: parse exception %s")) % _primitiveCount % e.what()).str();
std::string text = fmt::format(_("Primitive #{0:d}: parse exception {1}"), _primitiveCount, e.what());
throw FailureException(text);
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ void Doom3MapReader::parseEntity(parser::DefTokeniser& tok)
// Sanity check (invalid number of tokens will get us out of sync)
if (value == "{" || value == "}")
{
std::string text = (boost::format(_("Parsed invalid value '%s' for key '%s'")) % value % token).str();
std::string text = fmt::format(_("Parsed invalid value '{0}' for key '{1}'"), value, token);
throw FailureException(text);
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/mapdoom3/Quake3MapReader.cpp
Expand Up @@ -7,7 +7,7 @@
#include "string/string.h"

#include "i18n.h"
#include <boost/format.hpp>
#include <fmt/format.h>
#include <boost/lexical_cast.hpp>

#include "primitiveparsers/BrushDef.h"
Expand Down Expand Up @@ -42,7 +42,7 @@ void Quake3MapReader::readFromStream(std::istream& stream)
}
catch (FailureException& e)
{
std::string text = (boost::format(_("Failed parsing entity %d:\n%s")) % _entityCount % e.what()).str();
std::string text = fmt::format(_("Failed parsing entity {0:d}:\n{1}"), _entityCount, e.what());

// Re-throw with more text
throw FailureException(text);
Expand Down Expand Up @@ -99,7 +99,7 @@ void Quake3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INo

if (!primitive)
{
std::string text = (boost::format(_("Primitive #%d: parse error")) % _primitiveCount).str();
std::string text = fmt::format(_("Primitive #{0:d}: parse error"), _primitiveCount);
throw FailureException(text);
}

Expand All @@ -109,7 +109,7 @@ void Quake3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INo
catch (parser::ParseException& e)
{
// Translate ParseExceptions to FailureExceptions
std::string text = (boost::format(_("Primitive #%d: parse exception %s")) % _primitiveCount % e.what()).str();
std::string text = fmt::format(_("Primitive #{0:d}: parse exception {1}"), _primitiveCount, e.what());
throw FailureException(text);
}
}
Expand Down Expand Up @@ -200,7 +200,7 @@ void Quake3MapReader::parseEntity(parser::DefTokeniser& tok)
// Sanity check (invalid number of tokens will get us out of sync)
if (value == "{" || value == "}")
{
std::string text = (boost::format(_("Parsed invalid value '%s' for key '%s'")) % value % token).str();
std::string text = fmt::format(_("Parsed invalid value '{0}' for key '{1}'"), value, token);
throw FailureException(text);
}

Expand Down

0 comments on commit 115ebcc

Please sign in to comment.