* Forgot writeLineAt in TextStream

This commit is contained in:
Antidote 2013-01-27 12:25:01 -08:00
parent 2e53be3baa
commit 6c5e489f71
2 changed files with 22 additions and 2 deletions

View File

@ -85,6 +85,13 @@ public:
*/
std::string readLineAt(Uint32 line);
/*! \brief Writes a line at the given address.
*
* \param line The address to write to.
* \param str The string to write.
*/
void writeLineAt(Uint32 line, const std::string& str);
/*! \brief Sets the current line in the Stream.
*
* \param line The line to seek to.

View File

@ -52,6 +52,8 @@ TextStream::TextStream(const std::string& filename, TextMode fileMode, AccessMod
void TextStream::save(const std::string& filename)
{
if (m_accessmode != WriteOnly || m_accessmode != ReadWrite)
throw InvalidOperationException("Stream not open for writing");
if (filename != std::string())
m_filename = filename;
@ -95,7 +97,7 @@ std::string TextStream::readLine()
void TextStream::writeLine(const std::string& str)
{
if (m_accessmode != WriteOnly || m_accessmode != ReadWrite)
throw InvalidOperationException("Stream not open for reading");
throw InvalidOperationException("Stream not open for writing");
else if (m_currentLine > m_lines.size())
{
m_lines.push_back(str);
@ -109,7 +111,7 @@ void TextStream::writeLine(const std::string& str)
void TextStream::writeLines(std::vector<std::string> strings)
{
if (m_accessmode != WriteOnly || m_accessmode != ReadWrite)
throw InvalidOperationException("Stream not open for reading");
throw InvalidOperationException("Stream not open for writing");
for (std::string s: strings)
writeLine(s);
@ -144,6 +146,17 @@ std::string TextStream::readLineAt(Uint32 line)
return m_lines[line - 1];
}
void TextStream::writeLineAt(Uint32 line, const std::string& line)
{
if (m_accessmode != WriteOnly || m_accessmode != ReadWrite)
throw InvalidOperationException("Stream not open for reading");
if (line <= 0)
throw InvalidOperationException("A line cannot be zero indexed");
m_currentLine = line;
writeLine(line);
}
std::vector<std::string> TextStream::readAllLines()
{
if (m_accessmode != ReadOnly || m_accessmode != ReadWrite)