Replaced std::to_string with boost::lexical_cast<std::string>

MXE has problems with std::to_string
dev-mp
krzys-h 2014-09-28 19:25:28 +02:00
parent ab5c1271c0
commit f2c6b322dd
4 changed files with 16 additions and 13 deletions

View File

@ -32,6 +32,7 @@
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/lexical_cast.hpp>
CLevelParser::CLevelParser() CLevelParser::CLevelParser()
{ {
@ -177,11 +178,11 @@ void CLevelParser::Load()
if(line[0] == '\"') { if(line[0] == '\"') {
pos = line.find_first_of("\"", 1); pos = line.find_first_of("\"", 1);
if(pos == std::string::npos) if(pos == std::string::npos)
throw CLevelParserException("Unclosed \" in "+m_filename+":"+std::to_string(lineNumber)); throw CLevelParserException("Unclosed \" in "+m_filename+":"+boost::lexical_cast<std::string>(lineNumber));
} else if(line[0] == '\'') { } else if(line[0] == '\'') {
pos = line.find_first_of("'", 1); pos = line.find_first_of("'", 1);
if(pos == std::string::npos) if(pos == std::string::npos)
throw CLevelParserException("Unclosed ' in "+m_filename+":"+std::to_string(lineNumber)); throw CLevelParserException("Unclosed ' in "+m_filename+":"+boost::lexical_cast<std::string>(lineNumber));
} else { } else {
pos = line.find_first_of("="); pos = line.find_first_of("=");
if(pos != std::string::npos) { if(pos != std::string::npos) {

View File

@ -19,6 +19,8 @@
#include "object/level/parser.h" #include "object/level/parser.h"
#include <boost/lexical_cast.hpp>
CLevelParserException::CLevelParserException(std::string message) noexcept CLevelParserException::CLevelParserException(std::string message) noexcept
{ {
m_message = message; m_message = message;
@ -30,11 +32,11 @@ const char* CLevelParserException::what() const noexcept
} }
CLevelParserExceptionMissingParam::CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) noexcept CLevelParserExceptionMissingParam::CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) noexcept
: CLevelParserException("Missing required param "+thisParam->GetName()+" (in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+std::to_string(thisParam->GetLine()->GetLineNumber())+")") : CLevelParserException("Missing required param "+thisParam->GetName()+" (in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber())+")")
{ {
} }
CLevelParserExceptionBadParam::CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) noexcept CLevelParserExceptionBadParam::CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) noexcept
: CLevelParserException("Unable to parse '"+thisParam->GetValue()+"' as "+requestedType+" (param '"+thisParam->GetName()+"' in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+std::to_string(thisParam->GetLine()->GetLineNumber())+")") : CLevelParserException("Unable to parse '"+thisParam->GetValue()+"' as "+requestedType+" (param '"+thisParam->GetName()+"' in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber())+")")
{ {
} }

View File

@ -650,7 +650,7 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value)
if(value == OBJECT_HUMAN ) return "Me"; if(value == OBJECT_HUMAN ) return "Me";
if(value == OBJECT_TECH ) return "Tech"; if(value == OBJECT_TECH ) return "Tech";
if(value == OBJECT_CONTROLLER ) return "MissionController"; if(value == OBJECT_CONTROLLER ) return "MissionController";
return std::to_string(static_cast<int>(value)); return boost::lexical_cast<std::string>(static_cast<int>(value));
} }
ObjectType CLevelParserParam::AsObjectType() ObjectType CLevelParserParam::AsObjectType()
@ -888,7 +888,7 @@ const std::string CLevelParserParam::FromCameraType(Gfx::CameraType value)
{ {
if(value == Gfx::CAM_TYPE_ONBOARD) return "ONBOARD"; if(value == Gfx::CAM_TYPE_ONBOARD) return "ONBOARD";
if(value == Gfx::CAM_TYPE_FIX ) return "FIX"; if(value == Gfx::CAM_TYPE_FIX ) return "FIX";
return std::to_string(static_cast<int>(value)); return boost::lexical_cast<std::string>(static_cast<int>(value));
} }
Gfx::CameraType CLevelParserParam::AsCameraType() Gfx::CameraType CLevelParserParam::AsCameraType()
@ -917,7 +917,7 @@ void CLevelParserParam::ParseArray()
for(auto& value : values) { for(auto& value : values) {
boost::algorithm::trim(value); boost::algorithm::trim(value);
if(value.empty()) continue; if(value.empty()) continue;
CLevelParserParam* param = new CLevelParserParam(m_name+"["+std::to_string(i)+"]", value); CLevelParserParam* param = new CLevelParserParam(m_name+"["+boost::lexical_cast<std::string>(i)+"]", value);
param->SetLine(m_line); param->SetLine(m_line);
m_array.push_back(param); m_array.push_back(param);
i++; i++;

View File

@ -4495,7 +4495,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
// Puts information in terminal (OBJECT_INFO). // Puts information in terminal (OBJECT_INFO).
for (int i = 0; i < OBJECTMAXINFO; i++) for (int i = 0; i < OBJECTMAXINFO; i++)
{ {
std::string op = "info"+std::to_string(i+1); std::string op = "info"+boost::lexical_cast<std::string>(i+1);
if(!line->GetParam(op)->IsDefined()) break; if(!line->GetParam(op)->IsDefined()) break;
std::string text = line->GetParam(op)->AsString(); std::string text = line->GetParam(op)->AsString();
std::size_t p = text.find_first_of("="); std::size_t p = text.find_first_of("=");
@ -4568,7 +4568,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
{ {
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
std::string op = "script"+std::to_string(i+1); // script1..script10 std::string op = "script"+boost::lexical_cast<std::string>(i+1); // script1..script10
if(line->GetParam(op)->IsDefined()) { if(line->GetParam(op)->IsDefined()) {
brain->SetScriptName(i, const_cast<char*>(line->GetParam(op)->AsPath("").c_str())); //TODO: don't make this relative to ai/ brain->SetScriptName(i, const_cast<char*>(line->GetParam(op)->AsPath("").c_str())); //TODO: don't make this relative to ai/
} }
@ -4589,7 +4589,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
automat->SetType(type); automat->SetType(type);
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
std::string op = "autoValue"+std::to_string(i+1); // autoValue1..autoValue5 std::string op = "autoValue"+boost::lexical_cast<std::string>(i+1); // autoValue1..autoValue5
automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f)); automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f));
} }
automat->SetString(const_cast<char*>(line->GetParam("autoString")->AsString("").c_str())); automat->SetString(const_cast<char*>(line->GetParam("autoString")->AsString("").c_str()));
@ -4860,7 +4860,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if(read[0] != 0) continue; // ignore errors when loading saevd game (TODO: don't report ones that are just not loaded when loading saved game) if(read[0] != 0) continue; // ignore errors when loading saevd game (TODO: don't report ones that are just not loaded when loading saved game)
if(resetObject) continue; // ignore when reseting just objects (TODO: see above) if(resetObject) continue; // ignore when reseting just objects (TODO: see above)
throw CLevelParserException("Unknown command: '"+line->GetCommand()+"' in "+line->GetLevel()->GetFilename()+":"+std::to_string(line->GetLineNumber())); throw CLevelParserException("Unknown command: '"+line->GetCommand()+"' in "+line->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(line->GetLineNumber()));
} }
if (read[0] == 0) if (read[0] == 0)