Skip to content

Commit

Permalink
Migrate a bunch of boost.format occurrences.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 11, 2017
1 parent 3690148 commit 4f45dc3
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 100 deletions.
9 changes: 4 additions & 5 deletions libs/math/Vector2.h
Expand Up @@ -16,7 +16,7 @@
#include "lrint.h"
#include <sstream>
#include <cmath>
#include <boost/format.hpp>
#include <fmt/format.h>

template <typename Element>
class BasicVector2 {
Expand Down Expand Up @@ -259,10 +259,9 @@ class BasicVector2 {

/** Cast to std::string
*/
operator std::string() const {
return (boost::format("%s %s")
% _v[0]
% _v[1]).str();
operator std::string() const
{
return fmt::format("{0:f} {1:f}", _v[0], _v[1]);
}

/** Return the length of this vector.
Expand Down
5 changes: 2 additions & 3 deletions libs/wxutil/preview/ModelPreview.cpp
Expand Up @@ -153,9 +153,8 @@ void ModelPreview::setupSceneGraph()
}
catch (std::runtime_error&)
{
wxutil::Messagebox::ShowError(
(boost::format(_("Unable to setup the preview,\n"
"could not find the entity class %s")) % FUNC_STATIC_CLASS).str());
wxutil::Messagebox::ShowError(fmt::format(_("Unable to setup the preview,\n"
"could not find the entity class {0}"), FUNC_STATIC_CLASS));
}
}

Expand Down
7 changes: 3 additions & 4 deletions libs/wxutil/preview/ParticlePreview.cpp
Expand Up @@ -18,7 +18,7 @@

#include <wx/artprov.h>

#include <boost/format.hpp>
#include <fmt/format.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/classification.hpp>
Expand Down Expand Up @@ -182,9 +182,8 @@ void ParticlePreview::setupSceneGraph()
}
catch (std::runtime_error&)
{
wxutil::Messagebox::ShowError(
(boost::format(_("Unable to setup the preview,\n"
"could not find the entity class %s")) % FUNC_EMITTER_CLASS).str());
wxutil::Messagebox::ShowError(fmt::format(_("Unable to setup the preview,\n"
"could not find the entity class {0}"), FUNC_EMITTER_CLASS));
}
}

Expand Down
3 changes: 2 additions & 1 deletion libs/wxutil/preview/RenderPreview.cpp
Expand Up @@ -17,6 +17,7 @@
#include <wx/menu.h>
#include <wx/dcclient.h>

#include <fmt/format.h>
#include <functional>

namespace wxutil
Expand Down Expand Up @@ -779,7 +780,7 @@ void RenderPreview::drawTime()

glRasterPos3f(1.0f, static_cast<float>(_previewHeight) - 1.0f, 0.0f);

GlobalOpenGL().drawString((boost::format("%.3f sec.") % (_renderSystem->getTime() * 0.001f)).str());
GlobalOpenGL().drawString(fmt::format("{0:.3f} sec.", (_renderSystem->getTime() * 0.001f)));
}

void RenderPreview::onGLKeyPress(wxKeyEvent& ev)
Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.conversation/CommandEditor.cpp
Expand Up @@ -4,7 +4,7 @@
#include "string/string.h"
#include "string/convert.h"

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

#include <wx/sizer.h>
Expand Down Expand Up @@ -37,7 +37,7 @@ CommandEditor::CommandEditor(wxWindow* parent, conversation::ConversationCommand
for (conversation::Conversation::ActorMap::const_iterator i = _conversation.actors.begin();
i != _conversation.actors.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
findNamedObject<wxChoice>(this, "ConvCmdEditorActorChoice")->Append(actorStr,
Expand Down
3 changes: 1 addition & 2 deletions plugins/dm.conversation/ConversationEntityFinder.h
Expand Up @@ -75,8 +75,7 @@ class ConversationEntityFinder :
{
// Construct the display string
std::string name = entity->getKeyValue("name");
std::string sDisplay =
(boost::format(_("%s at [ %s ]")) % name % entity->getKeyValue("origin")).str();
std::string sDisplay = fmt::format(_("{0} at [ {1} ]"), name, entity->getKeyValue("origin"));

// Add the entity to the list
wxutil::TreeModel::Row row = _store->AddItem();
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.editing/FixupMap.cpp
Expand Up @@ -57,7 +57,7 @@ FixupMap::Result FixupMap::perform()
{
double fraction = static_cast<double>(parsedSize) / _contents.size();
_progress.setTextAndFraction(
(boost::format(_("Processing line %d...")) % _curLineNumber).str(),
fmt::format(_("Processing line {0}..."), _curLineNumber),
fraction);
}
catch (wxutil::ModalProgressDialog::OperationAbortedException& ex)
Expand Down
10 changes: 5 additions & 5 deletions plugins/dm.editing/FixupMapDialog.cpp
Expand Up @@ -44,10 +44,10 @@ void FixupMapDialog::RunDialog(const cmd::ArgumentList& args)
// Show popup with results
std::string msg;

msg += (boost::format(_("%d shaders replaced.")) % result.replacedShaders).str() + "\n";
msg += (boost::format(_("%d entities replaced.")) % result.replacedEntities).str() + "\n";
msg += (boost::format(_("%d models replaced.")) % result.replacedModels).str() + "\n";
msg += (boost::format(_("%d spawnargs replaced.")) % result.replacedMisc).str() + "\n";
msg += fmt::format(_("{0} shaders replaced."), result.replacedShaders) + "\n";
msg += fmt::format(_("{0} entities replaced."), result.replacedEntities) + "\n";
msg += fmt::format(_("{0} models replaced."), result.replacedModels) + "\n";
msg += fmt::format(_("{0} spawnargs replaced."), result.replacedMisc) + "\n";

if (!result.errors.empty())
{
Expand All @@ -58,7 +58,7 @@ void FixupMapDialog::RunDialog(const cmd::ArgumentList& args)
for (FixupMap::Result::ErrorMap::const_iterator i = result.errors.begin();
i != result.errors.end(); ++i)
{
msg += (boost::format(_("(Line %d): %s")) % i->first % i->second).str();
msg += fmt::format(_("(Line {0}): {1}"), i->first, i->second);
msg += "\n";
}
}
Expand Down
32 changes: 16 additions & 16 deletions plugins/dm.gui/ReadableEditorDialog.cpp
Expand Up @@ -313,7 +313,7 @@ bool ReadableEditorDialog::initControlsFromEntity()
}
catch (XdFileChooserDialog::ImportFailedException&)
{
std::string msg = (boost::format(_("Failed to import %s.")) % _entity->getKeyValue("xdata_contents")).str();
std::string msg = fmt::format(_("Failed to import {0}."), _entity->getKeyValue("xdata_contents"));
msg += "\n";
msg += _("Creating a new XData definition...");
msg += "\n\n";
Expand Down Expand Up @@ -394,7 +394,7 @@ bool ReadableEditorDialog::save()
{
case XData::OpenFailed:
wxutil::Messagebox::ShowError(
(boost::format(_("Failed to open %s for saving.")) % _xdFilename).str(),
fmt::format(_("Failed to open {0} for saving."), _xdFilename),
this
);
_saveInProgress = false;
Expand All @@ -415,7 +415,7 @@ bool ReadableEditorDialog::save()
else if (fst == XData::OpenFailed)
{
wxutil::Messagebox::ShowError(
(boost::format(_("Failed to open %s for saving.")) % _xdFilename).str(),
fmt::format(_("Failed to open {0} for saving."), _xdFilename),
this
);
}
Expand Down Expand Up @@ -501,11 +501,11 @@ std::string ReadableEditorDialog::constructStoragePath()
if (compPath.empty())
{
wxutil::Messagebox::ShowError(
(boost::format(_("%s%s already exists in another path.\n\nXData will be stored in %s%s!")) %
XData::XDATA_DIR %
_mapBasedFilename %
XData::XDATA_DIR %
newFileName).str(),
fmt::format(_("{0}{1} already exists in another path.\n\nXData will be stored in {2}{3}!"),
XData::XDATA_DIR,
_mapBasedFilename,
XData::XDATA_DIR,
newFileName),
this
);
break;
Expand Down Expand Up @@ -640,7 +640,7 @@ void ReadableEditorDialog::updateGuiView(wxWindow* parent,
}
else
{
std::string msg = (boost::format(_("Failed to import %s.")) % xDataName).str();
std::string msg = fmt::format(_("Failed to import {0}."), xDataName);
msg += "\n\n";
msg += _("Do you want to open the import summary?");

Expand All @@ -659,7 +659,7 @@ void ReadableEditorDialog::updateGuiView(wxWindow* parent,

if (gui == NULL)
{
std::string msg = (boost::format(_("Failed to load gui definition %s.")) % xd->getGuiPage(0)).str();
std::string msg = fmt::format(_("Failed to load gui definition {0}."), xd->getGuiPage(0));
msg += "\n\n";
msg += _("Do you want to open the import summary?");

Expand Down Expand Up @@ -710,7 +710,7 @@ void ReadableEditorDialog::updateGuiView(wxWindow* parent,
{
std::string nameGui = guiPath.empty() ? _guiEntry->GetValue().ToStdString() : guiPath;

std::string msg = (boost::format(_("Failed to load gui definition %s.")) % nameGui).str();
std::string msg = fmt::format(_("Failed to load gui definition {0}."), nameGui);
msg += "\n\n";
msg += _("Do you want to open the import summary?");

Expand Down Expand Up @@ -833,7 +833,7 @@ void ReadableEditorDialog::checkXDataUniqueness()
// The definition already exists. Ask the user whether it should be imported. If not make a different name suggestion.
wxutil::Messagebox dialog(
_("Import definition?"),
(boost::format(_("The definition %s already exists. Should it be imported?")) % xdn).str(),
fmt::format(_("The definition {0} already exists. Should it be imported?"), xdn),
ui::IDialog::MESSAGE_ASK, this
);

Expand Down Expand Up @@ -883,8 +883,8 @@ void ReadableEditorDialog::checkXDataUniqueness()
_xDataNameEntry->SetValue(suggestion);
_xData->setName(suggestion);

message += (boost::format(_("To avoid duplicated XData definitions "
"the current definition has been renamed to %s.")) % suggestion).str();
message += fmt::format(_("To avoid duplicated XData definitions "
"the current definition has been renamed to {0}."), suggestion);

wxutil::Messagebox::Show(
_("XData has been renamed."),
Expand Down Expand Up @@ -1396,7 +1396,7 @@ void ReadableEditorDialog::onBrowseXd(wxCommandEvent& ev)
}
catch (XdFileChooserDialog::ImportFailedException&)
{
std::string msg = (boost::format(_("Failed to import %s.")) % res).str();
std::string msg = fmt::format(_("Failed to import {0}."), res);
msg += "\n\n";
msg += _("Do you want to open the import summary?");

Expand Down Expand Up @@ -1570,7 +1570,7 @@ void ReadableEditorDialog::showDuplicateDefinitions()

occ += it->second[it->second.size() - 1];

out += (boost::format(_("%s has been defined in:")) % it->first).str();
out += fmt::format(_("{0} has been defined in:"), it->first);
out +="\n\t";
out += occ;
out += ".\n\n";
Expand Down
2 changes: 1 addition & 1 deletion plugins/dm.gui/XdFileChooserDialog.cpp
Expand Up @@ -57,7 +57,7 @@ int XdFileChooserDialog::Import(const std::string& defName,

if (loader->getImportSummary().size() > 1)
{
std::string msg = (boost::format(_("%s successfully imported.")) % defName).str();
std::string msg = fmt::format(_("{0} successfully imported."), defName);
msg += "\n\nHowever, there were some problems.\n\n";
msg += _("Do you want to open the import summary?");

Expand Down
26 changes: 13 additions & 13 deletions plugins/dm.objectives/ObjectiveConditionsDialog.cpp
Expand Up @@ -208,10 +208,10 @@ void ObjectiveConditionsDialog::refreshPossibleValues()
switch (cond.type)
{
case ObjectiveCondition::CHANGE_STATE:
_value->Append((boost::format(_("Set state to %s")) % Objective::getStateText(Objective::INCOMPLETE)).str());
_value->Append((boost::format(_("Set state to %s")) % Objective::getStateText(Objective::COMPLETE)).str());
_value->Append((boost::format(_("Set state to %s")) % Objective::getStateText(Objective::INVALID)).str());
_value->Append((boost::format(_("Set state to %s")) % Objective::getStateText(Objective::FAILED)).str());
_value->Append(fmt::format(_("Set state to {0}"), Objective::getStateText(Objective::INCOMPLETE)));
_value->Append(fmt::format(_("Set state to {0}"), Objective::getStateText(Objective::COMPLETE)));
_value->Append(fmt::format(_("Set state to {0}"), Objective::getStateText(Objective::INVALID)));
_value->Append(fmt::format(_("Set state to {0}"), Objective::getStateText(Objective::FAILED)));

if (cond.value >= Objective::NUM_STATES)
{
Expand Down Expand Up @@ -460,7 +460,7 @@ void ObjectiveConditionsDialog::populateWidgets()

std::string ObjectiveConditionsDialog::getDescription(const ObjectiveCondition& cond)
{
return (boost::format(_("Condition affecting objective %d")) % (cond.targetObjective+1)).str();
return fmt::format(_("Condition affecting objective {0:d}"), (cond.targetObjective+1));
}

void ObjectiveConditionsDialog::_onCancel(wxCommandEvent& ev)
Expand Down Expand Up @@ -490,8 +490,8 @@ std::string ObjectiveConditionsDialog::getSentence(const ObjectiveCondition& con

if (cond.isValid())
{
str = (boost::format(_("If Objective %d in Mission %d is in state '%s' do the following: ")) %
(cond.sourceObjective+1) % (cond.sourceMission+1) % Objective::getStateText(cond.sourceState)).str();
str = fmt::format(_("If Objective {0} in Mission {1} is in state '{2}' do the following: "),
(cond.sourceObjective+1), (cond.sourceMission+1), Objective::getStateText(cond.sourceState));

str += "\n";

Expand All @@ -501,29 +501,29 @@ std::string ObjectiveConditionsDialog::getSentence(const ObjectiveCondition& con
switch (cond.type)
{
case ObjectiveCondition::CHANGE_STATE:
actionStr = (boost::format(_("Set State on Objective %d to %s")) %
objNum % Objective::getStateText(static_cast<Objective::State>(cond.value))).str();
actionStr = fmt::format(_("Set State on Objective {0} to {1}"),
objNum, Objective::getStateText(static_cast<Objective::State>(cond.value)));
break;

case ObjectiveCondition::CHANGE_VISIBILITY:
if (cond.value != 0)
{
actionStr = (boost::format(_("Make Objective %d visible")) % objNum).str();
actionStr = fmt::format(_("Make Objective {0} visible"), objNum);
}
else
{
actionStr = (boost::format(_("Make Objective %d invisible")) % objNum).str();
actionStr = fmt::format(_("Make Objective {0} invisible"), objNum);
}
break;

case ObjectiveCondition::CHANGE_MANDATORY:
if (cond.value != 0)
{
actionStr = (boost::format(_("Make Objective %d mandatory")) % objNum).str();
actionStr = fmt::format(_("Make Objective {0} mandatory"), objNum);
}
else
{
actionStr = (boost::format(_("Make Objective %d not mandatory")) % objNum).str();
actionStr = fmt::format(_("Make Objective {0} not mandatory"), objNum);
}
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions plugins/eclassmgr/Doom3EntityClass.cpp
Expand Up @@ -8,6 +8,8 @@
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/format.hpp>
#include <boost/optional.hpp>
#include <functional>

namespace eclass
Expand Down
3 changes: 2 additions & 1 deletion plugins/entity/ColourKey.h
Expand Up @@ -2,6 +2,7 @@

#include "ientity.h"
#include "irender.h"
#include <fmt/format.h>

namespace entity
{
Expand Down Expand Up @@ -68,7 +69,7 @@ class ColourKey :

if (renderSystem)
{
std::string wireCol = (boost::format("<%f %f %f>") % _colour[0] % _colour[1] % _colour[2]).str();
std::string wireCol = fmt::format("<{0:f} {1:f} {2:f}>", _colour[0], _colour[1], _colour[2]);
_wireShader = renderSystem->capture(wireCol);
}
else
Expand Down
8 changes: 4 additions & 4 deletions plugins/entity/EntityCreator.cpp
Expand Up @@ -129,13 +129,13 @@ void Doom3EntityCreator::connectEntities(const scene::INodePtr& source,
for (int i = 0; i < 1024; ++i) {

// Construct candidate key by appending number to "target"
std::string targetKey = (boost::format("target%i") % i).str();
std::string targetKey = fmt::format("target{0:d}", i);

// If the source entity does not have this key, add it and finish,
// otherwise continue looping
if (e1->getKeyValue(targetKey).empty()) {
e1->setKeyValue(targetKey,
e2->getKeyValue("name"));
if (e1->getKeyValue(targetKey).empty())
{
e1->setKeyValue(targetKey, e2->getKeyValue("name"));
break;
}
}
Expand Down

0 comments on commit 4f45dc3

Please sign in to comment.