Replace boost::lexical_cast by std::ostringstream and std:stof/stoi/stod

This commit is contained in:
gallaert
2020-04-20 19:45:00 +01:00
committed by James Turner
parent d21137739d
commit b13d7f9392
7 changed files with 17 additions and 22 deletions

View File

@@ -18,7 +18,6 @@
#include "CSSBorder.hxx"
#include <boost/lexical_cast.hpp>
#include <boost/range.hpp>
#include <boost/tokenizer.hpp>
@@ -114,9 +113,9 @@ namespace simgear
std::max
(
0.f,
boost::lexical_cast<float>
std::stof
(
rel ? boost::make_iterator_range(tok->begin(), tok->end() - 1)
rel ? std::string(tok->begin(), tok->end() - 1)
: *tok
)
/

View File

@@ -39,7 +39,6 @@
#include <OpenThreads/Mutex>
#include <OpenThreads/ScopedLock>
#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
@@ -124,10 +123,11 @@ void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
const SGPropertyNode* pName = prop->getChild("name");
if (pName)
try {
unit = boost::lexical_cast<int>(pName->getStringValue());
} catch (boost::bad_lexical_cast& lex) {
unit = std::stoi(pName->getStringValue());
}
catch (const std::invalid_argument& ia) {
SG_LOG(SG_INPUT, SG_ALERT, "can't decode name as texture unit "
<< lex.what());
<< ia.what());
}
}
const SGPropertyNode* pType = getEffectPropertyChild(effect, prop, "type");

View File

@@ -11,9 +11,7 @@
#include <algorithm>
#include <cstring>
#include <map>
#include <sstream>
#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
@@ -167,22 +165,25 @@ Effect* makeEffect(SGPropertyNode* prop,
vector<SGPropertyNode_ptr> techniques = prop->getChildren("technique");
for (int i = 0; i < (int)techniques.size(); ++i) {
SGPropertyNode* tniqProp = techniques[i].ptr();
if (!tniqProp->hasChild("name"))
if (!tniqProp->hasChild("name")) {
setValue(tniqProp->getChild("name", 0, true),
boost::lexical_cast<string>(i));
std::to_string(i));
}
vector<SGPropertyNode_ptr> passes = tniqProp->getChildren("pass");
for (int j = 0; j < (int)passes.size(); ++j) {
SGPropertyNode* passProp = passes[j].ptr();
if (!passProp->hasChild("name"))
if (!passProp->hasChild("name")) {
setValue(passProp->getChild("name", 0, true),
boost::lexical_cast<string>(j));
std::to_string(j));
}
vector<SGPropertyNode_ptr> texUnits
= passProp->getChildren("texture-unit");
for (int k = 0; k < (int)texUnits.size(); ++k) {
SGPropertyNode* texUnitProp = texUnits[k].ptr();
if (!texUnitProp->hasChild("name"))
if (!texUnitProp->hasChild("name")) {
setValue(texUnitProp->getChild("name", 0, true),
boost::lexical_cast<string>(k));
std::to_string(k));
}
}
}
}

View File

@@ -27,7 +27,6 @@
#include <osg/Image>
#include <osg/Vec4>
#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple_comparison.hpp>
namespace simgear { namespace effect {

View File

@@ -66,7 +66,6 @@
#include "BoundingVolumeBuildVisitor.hxx"
#include "model.hxx"
#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>

View File

@@ -19,8 +19,6 @@
# include <simgear_config.h>
#endif
#include <boost/lexical_cast.hpp>
#include "animation.hxx"
#include "ConditionNode.hxx"
@@ -109,7 +107,7 @@ SGLightAnimation::SGLightAnimation(simgear::SGTransientModelData &modelData) :
_cutoff = getConfig()->getDoubleValue("cutoff");
_near = getConfig()->getDoubleValue("near-m");
_far = getConfig()->getDoubleValue("far-m");
_key = modelData.getPath() + ";" + boost::lexical_cast<std::string>(modelData.getIndex() );
_key = modelData.getPath() + ";" + std::to_string(modelData.getIndex());
SGConstPropertyNode_ptr dim_factor = modelData.getConfigNode()->getChild("dim-factor");
if (dim_factor.valid()) {

View File

@@ -20,7 +20,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <map>
@@ -77,7 +76,7 @@ namespace simgear
tok != tokens.end() && comp < 4;
++tok, ++comp )
{
color[comp] = boost::lexical_cast<float>(*tok)
color[comp] = std::stof(*tok)
// rgb = [0,255], a = [0,1]
/ (comp < 3 ? 255 : 1);
}