From f2c6b322dd3d909fe7928a35d4744992ab17adc1 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 28 Sep 2014 19:25:28 +0200 Subject: Replaced std::to_string with boost::lexical_cast MXE has problems with std::to_string --- src/object/level/parser.cpp | 7 ++++--- src/object/level/parserexceptions.cpp | 8 +++++--- src/object/level/parserparam.cpp | 6 +++--- src/object/robotmain.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/object/level/parser.cpp b/src/object/level/parser.cpp index e73142e..383931c 100644 --- a/src/object/level/parser.cpp +++ b/src/object/level/parser.cpp @@ -32,6 +32,7 @@ #include #include +#include CLevelParser::CLevelParser() { @@ -177,11 +178,11 @@ void CLevelParser::Load() if(line[0] == '\"') { pos = line.find_first_of("\"", 1); if(pos == std::string::npos) - throw CLevelParserException("Unclosed \" in "+m_filename+":"+std::to_string(lineNumber)); + throw CLevelParserException("Unclosed \" in "+m_filename+":"+boost::lexical_cast(lineNumber)); } else if(line[0] == '\'') { pos = line.find_first_of("'", 1); if(pos == std::string::npos) - throw CLevelParserException("Unclosed ' in "+m_filename+":"+std::to_string(lineNumber)); + throw CLevelParserException("Unclosed ' in "+m_filename+":"+boost::lexical_cast(lineNumber)); } else { pos = line.find_first_of("="); if(pos != std::string::npos) { @@ -237,4 +238,4 @@ CLevelParserLine* CLevelParser::Get(std::string command) return line; } throw CLevelParserException("Command not found: "+command); -} \ No newline at end of file +} diff --git a/src/object/level/parserexceptions.cpp b/src/object/level/parserexceptions.cpp index d5c4620..b495de7 100644 --- a/src/object/level/parserexceptions.cpp +++ b/src/object/level/parserexceptions.cpp @@ -19,6 +19,8 @@ #include "object/level/parser.h" +#include + CLevelParserException::CLevelParserException(std::string message) noexcept { m_message = message; @@ -30,11 +32,11 @@ const char* CLevelParserException::what() const 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(thisParam->GetLine()->GetLineNumber())+")") { } 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(thisParam->GetLine()->GetLineNumber())+")") { -} \ No newline at end of file +} diff --git a/src/object/level/parserparam.cpp b/src/object/level/parserparam.cpp index 39a953b..50152c5 100644 --- a/src/object/level/parserparam.cpp +++ b/src/object/level/parserparam.cpp @@ -650,7 +650,7 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value) if(value == OBJECT_HUMAN ) return "Me"; if(value == OBJECT_TECH ) return "Tech"; if(value == OBJECT_CONTROLLER ) return "MissionController"; - return std::to_string(static_cast(value)); + return boost::lexical_cast(static_cast(value)); } 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_FIX ) return "FIX"; - return std::to_string(static_cast(value)); + return boost::lexical_cast(static_cast(value)); } Gfx::CameraType CLevelParserParam::AsCameraType() @@ -917,7 +917,7 @@ void CLevelParserParam::ParseArray() for(auto& value : values) { boost::algorithm::trim(value); if(value.empty()) continue; - CLevelParserParam* param = new CLevelParserParam(m_name+"["+std::to_string(i)+"]", value); + CLevelParserParam* param = new CLevelParserParam(m_name+"["+boost::lexical_cast(i)+"]", value); param->SetLine(m_line); m_array.push_back(param); i++; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 51af57c..a409aa0 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4495,7 +4495,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) // Puts information in terminal (OBJECT_INFO). for (int i = 0; i < OBJECTMAXINFO; i++) { - std::string op = "info"+std::to_string(i+1); + std::string op = "info"+boost::lexical_cast(i+1); if(!line->GetParam(op)->IsDefined()) break; std::string text = line->GetParam(op)->AsString(); 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++) { - std::string op = "script"+std::to_string(i+1); // script1..script10 + std::string op = "script"+boost::lexical_cast(i+1); // script1..script10 if(line->GetParam(op)->IsDefined()) { brain->SetScriptName(i, const_cast(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); 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(i+1); // autoValue1..autoValue5 automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f)); } automat->SetString(const_cast(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(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(line->GetLineNumber())); } if (read[0] == 0) -- cgit v1.2.3-1-g7c22