[colobot] 73/390: Replaced std::to_string with boost::lexical_cast<std::string>

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:21:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit f2c6b322dd3d909fe7928a35d4744992ab17adc1
Author: krzys-h <krzys_h at interia.pl>
Date:   Sun Sep 28 19:25:28 2014 +0200

    Replaced std::to_string with boost::lexical_cast<std::string>
    
    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 <boost/algorithm/string/trim.hpp>
 #include <boost/algorithm/string/replace.hpp>
+#include <boost/lexical_cast.hpp>
 
 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<std::string>(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<std::string>(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 <boost/lexical_cast.hpp>
+
 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<std::string>(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<std::string>(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<int>(value));
+    return boost::lexical_cast<std::string>(static_cast<int>(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<int>(value));
+    return boost::lexical_cast<std::string>(static_cast<int>(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<std::string>(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<std::string>(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<std::string>(i+1); // script1..script10
                         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/
                         }
@@ -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<std::string>(i+1); // autoValue1..autoValue5
                         automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f));
                     }
                     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(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)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list