[Orxonox-commit 591] r3123 - in branches/netp4/src: core util
rgrieder at orxonox.net
rgrieder at orxonox.net
Tue Jun 9 13:31:32 CEST 2009
Author: rgrieder
Date: 2009-06-09 13:31:32 +0200 (Tue, 09 Jun 2009)
New Revision: 3123
Modified:
branches/netp4/src/core/ConfigFileManager.cc
branches/netp4/src/core/ConsoleCommandCompilation.cc
branches/netp4/src/core/Language.cc
branches/netp4/src/core/LuaBind.cc
branches/netp4/src/util/OutputBuffer.cc
Log:
Replaced all the std::istream::getline(const char*) calls with std::getline(std::ostream, std::string).
This gets rid of these nasty MAX_BUFFER = 1024 (or however long you want to make it) limitations.
Modified: branches/netp4/src/core/ConfigFileManager.cc
===================================================================
--- branches/netp4/src/core/ConfigFileManager.cc 2009-06-08 23:11:55 UTC (rev 3122)
+++ branches/netp4/src/core/ConfigFileManager.cc 2009-06-09 11:31:32 UTC (rev 3123)
@@ -39,7 +39,6 @@
namespace orxonox
{
- const int CONFIG_FILE_MAX_LINELENGHT = 1024;
const char* const DEFAULT_CONFIG_FILE = "default.ini";
ConfigFileManager* ConfigFileManager::singletonRef_s = 0;
@@ -243,17 +242,13 @@
file.open(filepath.string().c_str(), std::fstream::in);
if (file.is_open())
{
-
- char linearray[CONFIG_FILE_MAX_LINELENGHT];
-
ConfigFileSection* newsection = 0;
while (file.good() && !file.eof())
{
- file.getline(linearray, CONFIG_FILE_MAX_LINELENGHT);
+ std::string line;
+ std::getline(file, line);
- std::string line = std::string(linearray);
-
std::string temp = getStripped(line);
if (!isEmpty(temp) && !isComment(temp))
{
Modified: branches/netp4/src/core/ConsoleCommandCompilation.cc
===================================================================
--- branches/netp4/src/core/ConsoleCommandCompilation.cc 2009-06-08 23:11:55 UTC (rev 3122)
+++ branches/netp4/src/core/ConsoleCommandCompilation.cc 2009-06-09 11:31:32 UTC (rev 3123)
@@ -67,10 +67,10 @@
executingFiles.insert(filename);
// Iterate through the file and put the lines into the CommandExecutor
- char line[1024];
while (file.good() && !file.eof())
{
- file.getline(line, 1024);
+ std::string line;
+ std::getline(file, line);
CommandExecutor::execute(line);
}
@@ -138,10 +138,10 @@
}
std::string output = "";
- char line[1024];
while (file.good() && !file.eof())
{
- file.getline(line, 1024);
+ std::string line;
+ std::getline(file, line);
output += line;
output += "\n";
}
Modified: branches/netp4/src/core/Language.cc
===================================================================
--- branches/netp4/src/core/Language.cc 2009-06-08 23:11:55 UTC (rev 3122)
+++ branches/netp4/src/core/Language.cc 2009-06-09 11:31:32 UTC (rev 3123)
@@ -223,13 +223,11 @@
return;
}
- char line[1024];
-
// Iterate through the file and create the LanguageEntries
while (file.good() && !file.eof())
{
- file.getline(line, 1024);
- std::string lineString = std::string(line);
+ std::string lineString;
+ std::getline(file, lineString);
// Check if the line is empty
if ((lineString != "") && (lineString.size() > 0))
@@ -271,13 +269,11 @@
return;
}
- char line[1024];
-
// Iterate through the file and create the LanguageEntries
while (file.good() && !file.eof())
{
- file.getline(line, 1024);
- std::string lineString = std::string(line);
+ std::string lineString;
+ std::getline(file, lineString);
// Check if the line is empty
if ((lineString != "") && (lineString.size() > 0))
Modified: branches/netp4/src/core/LuaBind.cc
===================================================================
--- branches/netp4/src/core/LuaBind.cc 2009-06-08 23:11:55 UTC (rev 3122)
+++ branches/netp4/src/core/LuaBind.cc 2009-06-09 11:31:32 UTC (rev 3123)
@@ -96,12 +96,12 @@
// some error msg
}
- char line[1024*32];
std::string levelString = "";
while (file.good() && !file.eof())
{
- file.getline(line, 1024*32);
+ std::string line;
+ std::getline(file, line);
levelString += line;
levelString += "\n";
}
Modified: branches/netp4/src/util/OutputBuffer.cc
===================================================================
--- branches/netp4/src/util/OutputBuffer.cc 2009-06-08 23:11:55 UTC (rev 3122)
+++ branches/netp4/src/util/OutputBuffer.cc 2009-06-09 11:31:32 UTC (rev 3123)
@@ -35,8 +35,6 @@
namespace orxonox
{
- const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384; //! The maximal number of lines that can be stored within the OutputBuffer.
-
/**
@brief Adds a new listener to the list.
@param listener The new listener
@@ -104,11 +102,8 @@
*/
bool OutputBuffer::getLine(std::string* output)
{
- char line[OUTPUTBUFFER_MAX_LINE_LENGTH];
+ std::getline(this->stream_, *output);
- this->stream_.getline(line, OUTPUTBUFFER_MAX_LINE_LENGTH);
- (*output) = std::string(line);
-
bool eof = this->stream_.eof();
bool fail = this->stream_.fail();
More information about the Orxonox-commit
mailing list