1
0
Fork 0

Unboosting files

Use simgear::strutils replacements in places, C++11 features in others
This commit is contained in:
James Turner 2019-02-04 14:58:11 +00:00
parent f6046836c0
commit a9a49bc2e6
11 changed files with 38 additions and 77 deletions

View file

@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <Main/locale.hxx> #include <Main/locale.hxx>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <simgear/props/props_io.hxx> #include <simgear/props/props_io.hxx>
#include <boost/lexical_cast.hpp>
#include <map> #include <map>
#include <vector> #include <vector>
@ -38,7 +37,7 @@ static string EMPTY("");
std::string ATCSpeech::getSpokenDigit( int i ) std::string ATCSpeech::getSpokenDigit( int i )
{ {
string key = "n" + boost::lexical_cast<std::string>( i ); string key = "n" + std::to_string(i);
return globals->get_locale()->getLocalizedString(key.c_str(), "atc", "" ); return globals->get_locale()->getLocalizedString(key.c_str(), "atc", "" );
} }

View file

@ -23,20 +23,13 @@
// $Id$ // $Id$
#ifdef HAVE_CONFIG_H #include <config.h>
# include <config.h>
#endif
#include <cstdio> #include <cstdio>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include "route_mgr.hxx" #include "route_mgr.hxx"
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp>
#include <simgear/misc/strutils.hxx> #include <simgear/misc/strutils.hxx>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <simgear/structure/commands.hxx> #include <simgear/structure/commands.hxx>
@ -945,7 +938,7 @@ flightgear::SID* createDefaultSID(FGRunway* aRunway, double enrouteCourse)
wpts.push_back(w); wpts.push_back(w);
} }
BOOST_FOREACH(Waypt* w, wpts) { for (Waypt* w : wpts) {
w->setFlag(WPT_DEPARTURE); w->setFlag(WPT_DEPARTURE);
w->setFlag(WPT_GENERATED); w->setFlag(WPT_GENERATED);
} }
@ -1103,7 +1096,7 @@ flightgear::Approach* createDefaultApproach(FGRunway* aRunway, double aEnrouteCo
w->setAltitude(thresholdElevFt + approachHeightFt, RESTRICT_AT); w->setAltitude(thresholdElevFt + approachHeightFt, RESTRICT_AT);
wpts.push_back(w); wpts.push_back(w);
BOOST_FOREACH(Waypt* w, wpts) { for (Waypt* w : wpts) {
w->setFlag(WPT_APPROACH); w->setFlag(WPT_APPROACH);
w->setFlag(WPT_GENERATED); w->setFlag(WPT_GENERATED);
} }

View file

@ -34,8 +34,6 @@
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
#include <osgGA/GUIEventHandler> #include <osgGA/GUIEventHandler>
#include <boost/bind.hpp>
class DesktopGroup; class DesktopGroup;
typedef SGSharedPtr<DesktopGroup> DesktopPtr; typedef SGSharedPtr<DesktopGroup> DesktopPtr;
typedef SGWeakPtr<DesktopGroup> DesktopWeakPtr; typedef SGWeakPtr<DesktopGroup> DesktopWeakPtr;
@ -682,7 +680,7 @@ void GUIMgr::init()
sc::Canvas::addPlacementFactory sc::Canvas::addPlacementFactory
( (
"window", "window",
boost::bind(&GUIMgr::addWindowPlacement, this, _1, _2) std::bind(&GUIMgr::addWindowPlacement, this, std::placeholders::_1, std::placeholders::_2)
); );
_desktop->getProps()->fireCreatedRecursive(); _desktop->getProps()->fireCreatedRecursive();

View file

@ -19,15 +19,11 @@
// //
// //
#ifdef HAVE_CONFIG_H #include "config.h"
# include "config.h"
#endif
#include "NavDisplay.hxx" #include "NavDisplay.hxx"
#include <cassert> #include <cassert>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <algorithm> #include <algorithm>
#include <osg/Array> #include <osg/Array>
@ -196,8 +192,7 @@ public:
return false; return false;
} }
type = node->getStringValue("type"); type = simgear::strutils::lowercase(node->getStringValue("type"));
boost::to_lower(type);
SGPropertyNode* enableNode = node->getChild("enable"); SGPropertyNode* enableNode = node->getChild("enable");
if (enableNode) { if (enableNode) {
enable.reset(sgReadCondition(fgGetNode("/"), enableNode)); enable.reset(sgReadCondition(fgGetNode("/"), enableNode));
@ -227,13 +222,13 @@ public:
bool matches(const string_set& states) const bool matches(const string_set& states) const
{ {
BOOST_FOREACH(const string& s, required_states) { for (auto s : required_states) {
if (states.count(s) == 0) { if (states.count(s) == 0) {
return false; return false;
} }
} }
BOOST_FOREACH(const string& s, excluded_states) { for (auto s : excluded_states) {
if (states.count(s) != 0) { if (states.count(s) != 0) {
return false; return false;
} }
@ -479,7 +474,7 @@ NavDisplay::NavDisplay(SGPropertyNode *node) :
_definitions.push_back(def); _definitions.push_back(def);
} // of symbol definition parsing } // of symbol definition parsing
BOOST_FOREACH(SGPropertyNode* rule, symbolsNode->getChildren("rule")) { for (SGPropertyNode* rule : symbolsNode->getChildren("rule")) {
SymbolRule* r = new SymbolRule; SymbolRule* r = new SymbolRule;
if (!r->initFromNode(rule, this)) { if (!r->initFromNode(rule, this)) {
delete r; delete r;
@ -719,18 +714,18 @@ NavDisplay::update (double delta_time_sec)
_texCoords->clear(); _texCoords->clear();
_textGeode->removeDrawables(0, _textGeode->getNumDrawables()); _textGeode->removeDrawables(0, _textGeode->getNumDrawables());
BOOST_FOREACH(SymbolInstance* si, _symbols) { for (SymbolInstance* si : _symbols) {
delete si; delete si;
} }
_symbols.clear(); _symbols.clear();
BOOST_FOREACH(SymbolDef* d, _definitions) { for (SymbolDef* d : _definitions) {
d->instanceCount = 0; d->instanceCount = 0;
d->textEnabled = d->textEnable.get() ? d->textEnable->test() : true; d->textEnabled = d->textEnable.get() ? d->textEnable->test() : true;
} }
bool enableChanged = false; bool enableChanged = false;
BOOST_FOREACH(SymbolRule* r, _rules) { for (SymbolRule* r : _rules) {
enableChanged |= r->checkEnabled(); enableChanged |= r->checkEnabled();
} }
@ -928,7 +923,7 @@ public:
void NavDisplay::addSymbolsToScene() void NavDisplay::addSymbolsToScene()
{ {
std::sort(_symbols.begin(), _symbols.end(), OrderByZ()); std::sort(_symbols.begin(), _symbols.end(), OrderByZ());
BOOST_FOREACH(SymbolInstance* sym, _symbols) { for (SymbolInstance* sym : _symbols) {
addSymbolToScene(sym); addSymbolToScene(sym);
} }
} }
@ -1015,8 +1010,7 @@ void NavDisplay::findItems()
// sort by distance from pos, so symbol limits are accurate // sort by distance from pos, so symbol limits are accurate
FGPositioned::sortByRange(_itemsInRange, _pos); FGPositioned::sortByRange(_itemsInRange, _pos);
for (FGPositioned* pos : _itemsInRange) {
BOOST_FOREACH(FGPositioned* pos, _itemsInRange) {
foundPositionedItem(pos); foundPositionedItem(pos);
} }
} }
@ -1068,7 +1062,7 @@ void NavDisplay::processRoute()
computeWayptPropsAndHeading(wpt, g, vars, heading); computeWayptPropsAndHeading(wpt, g, vars, heading);
osg::Vec2 projected = projectGeod(g); osg::Vec2 projected = projectGeod(g);
BOOST_FOREACH(SymbolRule* r, rules) { for (SymbolRule* r : rules) {
addSymbolInstance(projected, heading, r->getDefinition(), vars); addSymbolInstance(projected, heading, r->getDefinition(), vars);
if (r->getDefinition()->drawRouteLeg) { if (r->getDefinition()->drawRouteLeg) {
@ -1120,7 +1114,7 @@ FGNavRecord* NavDisplay::processNavRadio(const SGPropertyNode_ptr& radio)
bool NavDisplay::anyRuleForType(const string& type) const bool NavDisplay::anyRuleForType(const string& type) const
{ {
BOOST_FOREACH(SymbolRule* r, _rules) { for (SymbolRule* r : _rules) {
if (!r->enabled) { if (!r->enabled) {
continue; continue;
} }
@ -1135,7 +1129,7 @@ bool NavDisplay::anyRuleForType(const string& type) const
void NavDisplay::findRules(const string& type, const string_set& states, SymbolRuleVector& rules) void NavDisplay::findRules(const string& type, const string_set& states, SymbolRuleVector& rules)
{ {
BOOST_FOREACH(SymbolRule* candidate, _rules) { for (SymbolRule* candidate : _rules) {
if (!candidate->enabled || (candidate->type != type)) { if (!candidate->enabled || (candidate->type != type)) {
continue; continue;
} }
@ -1155,8 +1149,7 @@ bool NavDisplay::isPositionedShown(FGPositioned* pos)
void NavDisplay::isPositionedShownInner(FGPositioned* pos, SymbolRuleVector& rules) void NavDisplay::isPositionedShownInner(FGPositioned* pos, SymbolRuleVector& rules)
{ {
string type = FGPositioned::nameForType(pos->type()); string type = simgear::strutils::lowercase(FGPositioned::nameForType(pos->type()));
boost::to_lower(type);
if (!anyRuleForType(type)) { if (!anyRuleForType(type)) {
return; // not diplayed at all, we're done return; // not diplayed at all, we're done
} }
@ -1189,7 +1182,7 @@ void NavDisplay::foundPositionedItem(FGPositioned* pos)
projected = projectGeod(rwy->threshold()); projected = projectGeod(rwy->threshold());
} }
BOOST_FOREACH(SymbolRule* r, rules) { for (SymbolRule* r : rules) {
SymbolInstance* ins = addSymbolInstance(projected, heading, r->getDefinition(), vars); SymbolInstance* ins = addSymbolInstance(projected, heading, r->getDefinition(), vars);
if ((ins)&&(pos->type() == FGPositioned::RUNWAY)) { if ((ins)&&(pos->type() == FGPositioned::RUNWAY)) {
FGRunway* rwy = (FGRunway*) pos; FGRunway* rwy = (FGRunway*) pos;
@ -1345,7 +1338,7 @@ void NavDisplay::processAI()
model->setIntValue("flight-level", fl * 10); model->setIntValue("flight-level", fl * 10);
osg::Vec2 projected = projectGeod(aiModelPos); osg::Vec2 projected = projectGeod(aiModelPos);
BOOST_FOREACH(SymbolRule* r, rules) { for (SymbolRule* r : rules) {
addSymbolInstance(projected, heading, r->getDefinition(), (SGPropertyNode*) model); addSymbolInstance(projected, heading, r->getDefinition(), (SGPropertyNode*) model);
} }
} // of ai models iteration } // of ai models iteration
@ -1399,7 +1392,7 @@ bool NavDisplay::isProjectedClipped(const osg::Vec2& projected) const
void NavDisplay::addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars) void NavDisplay::addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars)
{ {
string_set stateSet; string_set stateSet;
BOOST_FOREACH(std::string s, simgear::strutils::split(states, ",")) { for (auto s : simgear::strutils::split(states, ",")) {
stateSet.insert(s); stateSet.insert(s);
} }
@ -1410,7 +1403,7 @@ void NavDisplay::addTestSymbol(const std::string& type, const std::string& state
} }
osg::Vec2 projected = projectGeod(pos); osg::Vec2 projected = projectGeod(pos);
BOOST_FOREACH(SymbolRule* r, rules) { for (SymbolRule* r : rules) {
addSymbolInstance(projected, heading, r->getDefinition(), vars); addSymbolInstance(projected, heading, r->getDefinition(), vars);
} }
} }
@ -1454,7 +1447,7 @@ void NavDisplay::addRule(SymbolRule* r)
void NavDisplay::computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states) void NavDisplay::computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states)
{ {
BOOST_FOREACH(SGPropertyNode* st, sym->getChildren("state")) { for (SGPropertyNode* st : sym->getChildren("state")) {
states.insert(st->getStringValue()); states.insert(st->getStringValue());
} }
} }
@ -1481,7 +1474,7 @@ void NavDisplay::processCustomSymbols()
osg::Vec2 projected = projectGeod(pos); osg::Vec2 projected = projectGeod(pos);
BOOST_FOREACH(SymbolRule* r, rules) { for (SymbolRule* r : rules) {
addSymbolInstance(projected, heading, r->getDefinition(), symNode); addSymbolInstance(projected, heading, r->getDefinition(), symNode);
} }
} // of custom symbols iteration } // of custom symbols iteration

View file

@ -18,9 +18,6 @@
#include <simgear/props/props_io.hxx> #include <simgear/props/props_io.hxx>
#include <simgear/misc/sg_dir.hxx> #include <simgear/misc/sg_dir.hxx>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/foreach.hpp>
#include <Add-ons/AddonManager.hxx> #include <Add-ons/AddonManager.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
@ -155,7 +152,7 @@ NewGUI::reset (bool reload)
for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); ++iter) for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); ++iter)
openDialogs.push_back(iter->first); openDialogs.push_back(iter->first);
BOOST_FOREACH(string d, openDialogs) for (auto d : openDialogs)
closeDialog(d); closeDialog(d);
setStyle(); setStyle();
@ -174,7 +171,7 @@ NewGUI::reset (bool reload)
bind(); bind();
// open dialogs again // open dialogs again
BOOST_FOREACH(string d, openDialogs) for (auto d : openDialogs)
showDialog(d); showDialog(d);
} }

View file

@ -28,8 +28,6 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <boost/algorithm/string.hpp>
#include <simgear/environment/metar.hxx> #include <simgear/environment/metar.hxx>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
@ -542,8 +540,7 @@ int main(int argc, char *argv[])
"http://tgftp.nws.noaa.gov/data/observations/metar/stations/"; "http://tgftp.nws.noaa.gov/data/observations/metar/stations/";
HTTP::MemoryRequest* mr = new HTTP::MemoryRequest HTTP::MemoryRequest* mr = new HTTP::MemoryRequest
( (
NOAA_BASE_URL NOAA_BASE_URL + strutils::uppercase(argv[i]) + ".TXT"
+ boost::to_upper_copy<std::string>(argv[i]) + ".TXT"
); );
HTTP::Request_ptr own(mr); HTTP::Request_ptr own(mr);
http.makeRequest(mr); http.makeRequest(mr);

View file

@ -27,10 +27,6 @@
#include <fstream> #include <fstream>
#include <cassert> #include <cassert>
// Boost
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string.hpp>
// SimGear // SimGear
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
@ -1325,7 +1321,7 @@ WayptRef viaFromString(const SGGeod& basePosition, const std::string& target)
WayptRef FlightPlan::waypointFromString(const string& tgt ) WayptRef FlightPlan::waypointFromString(const string& tgt )
{ {
string target(boost::to_upper_copy(tgt)); string target = simgear::strutils::uppercase(tgt);
// extract altitude // extract altitude
double altFt = 0.0; double altFt = 0.0;
RouteRestriction altSetting = RESTRICT_NONE; RouteRestriction altSetting = RESTRICT_NONE;

View file

@ -4,10 +4,9 @@
#include "LevelDXML.hxx" #include "LevelDXML.hxx"
#include <boost/algorithm/string.hpp>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/misc/strutils.hxx>
#include <Navaids/waypoint.hxx> #include <Navaids/waypoint.hxx>
#include <Airports/airport.hxx> #include <Airports/airport.hxx>
@ -111,8 +110,7 @@ void NavdataVisitor::processRunways(ArrivalDeparture* aProc, const XMLAttributes
return; return;
} }
vector<string> rwys; auto rwys = simgear::strutils::split_on_any_of(v, " ,");
boost::split(rwys, v, boost::is_any_of(" ,"));
for (auto rwy : rwys) { for (auto rwy : rwys) {
if (!_airport->hasRunwayWithIdent(rwy)) { if (!_airport->hasRunwayWithIdent(rwy)) {
SG_LOG(SG_NAVAID, SG_DEV_WARN, "Procedure file " << _path << " references unknown airport runway:" << rwy); SG_LOG(SG_NAVAID, SG_DEV_WARN, "Procedure file " << _path << " references unknown airport runway:" << rwy);

View file

@ -18,9 +18,7 @@
// //
// $Id$ // $Id$
#ifdef HAVE_CONFIG_H #include "config.h"
# include "config.h"
#endif
#include "positioned.hxx" #include "positioned.hxx"
@ -30,9 +28,6 @@
#include <queue> #include <queue>
#include <memory> #include <memory>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <simgear/timing/timestamp.hxx> #include <simgear/timing/timestamp.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
@ -216,7 +211,7 @@ FGPositioned::Type FGPositioned::typeFromName(const std::string& aName)
{NULL, INVALID} {NULL, INVALID}
}; };
std::string lowerName(boost::to_lower_copy(aName)); std::string lowerName = simgear::strutils::lowercase(aName);
for (const NameTypeEntry* n = names; (n->_name != NULL); ++n) { for (const NameTypeEntry* n = names; (n->_name != NULL); ++n) {
if (::strcmp(n->_name, lowerName.c_str()) == 0) { if (::strcmp(n->_name, lowerName.c_str()) == 0) {
@ -464,7 +459,7 @@ FGPositioned::TypeFilter::fromString(const std::string& aFilterSpec)
string_list parts = simgear::strutils::split(aFilterSpec, ","); string_list parts = simgear::strutils::split(aFilterSpec, ",");
TypeFilter f; TypeFilter f;
BOOST_FOREACH(std::string token, parts) { for (std::string token : parts) {
f.addType(typeFromName(token)); f.addType(typeFromName(token));
} }

View file

@ -26,10 +26,6 @@
#include <map> #include <map>
#include <fstream> #include <fstream>
// Boost
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
// SimGear // SimGear
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
@ -166,7 +162,7 @@ std::string Waypt::icaoDescription() const
static RouteRestriction restrictionFromString(const char* aStr) static RouteRestriction restrictionFromString(const char* aStr)
{ {
std::string l = boost::to_lower_copy(std::string(aStr)); std::string l = simgear::strutils::lowercase(aStr);
if (l == "at") return RESTRICT_AT; if (l == "at") return RESTRICT_AT;
if (l == "above") return RESTRICT_ABOVE; if (l == "above") return RESTRICT_ABOVE;

View file

@ -25,7 +25,6 @@
#include <Aircraft/FlightHistory.hxx> #include <Aircraft/FlightHistory.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <sstream> #include <sstream>
#include <boost/lexical_cast.hpp>
using std::string; using std::string;
using std::stringstream; using std::stringstream;
@ -287,13 +286,13 @@ bool FlightHistoryUriHandler::handleRequest(const HTTPRequest & request,
} else if (requestPath == "track.json") { } else if (requestPath == "track.json") {
size_t count = -1; size_t count = -1;
try { try {
count = boost::lexical_cast<size_t>(request.RequestVariables.get("count")); count = std::stoul(request.RequestVariables.get("count"));
} }
catch( ... ) { catch( ... ) {
} }
size_t last = 0; size_t last = 0;
try { try {
last = boost::lexical_cast<size_t>(request.RequestVariables.get("last")); last = std::stoul(request.RequestVariables.get("last"));
} }
catch( ... ) { catch( ... ) {
} }