Added InputStream::GetLine(size);

Former-commit-id: 4c5afc038877bfa9865285d044663df3f7932d58
This commit is contained in:
Jérôme Leclercq
2012-09-21 12:39:40 +02:00
parent 2ea37a1877
commit cc6f2a6fc9
4 changed files with 57 additions and 54 deletions

View File

@@ -1,8 +1,49 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/Debug.hpp>
NzInputStream::~NzInputStream() = default;
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/Debug.hpp>
NzInputStream::~NzInputStream() = default;
NzString NzInputStream::GetLine(unsigned int lineSize)
{
NzString line;
if (lineSize == 0) // Taille maximale indéterminée
{
while (!EndOfStream())
{
char c;
if (Read(&c, sizeof(char)) == sizeof(char))
{
if (c == '\n')
break;
line += c;
}
else
break;
}
}
else
{
line.Reserve(lineSize);
for (unsigned int i = 0; i < lineSize; ++i)
{
char c;
if (Read(&c, sizeof(char)) == sizeof(char))
{
if (c == '\n')
break;
line += c;
}
else
break;
}
}
return line;
}