From a0e341f5cf9ebd44bf8ffbd9a1ab3463f1ba86e7 Mon Sep 17 00:00:00 2001 From: Antidote Date: Sun, 27 Jan 2013 12:28:59 -0800 Subject: [PATCH] * Forgot to implement isOpenForRead/Writing in TextStream * Changed isOpenForReading/Writing to const int Stream --- include/Stream.hpp | 4 ++-- src/Stream.cpp | 4 ++-- src/TextStream.cpp | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/Stream.hpp b/include/Stream.hpp index 2312d32..b82b044 100644 --- a/include/Stream.hpp +++ b/include/Stream.hpp @@ -193,13 +193,13 @@ public: * * \return True if open for reading; False otherwise. */ - virtual bool isOpenForReading(); + virtual bool isOpenForReading() const; /*! \brief Retuns whether or not the Stream is open for writing * * \return True if open for writing; False otherwise. */ - virtual bool isOpenForWriting(); + virtual bool isOpenForWriting() const; /*! \brief Sets the Endianss of the stream * diff --git a/src/Stream.cpp b/src/Stream.cpp index 564c655..c946b7b 100644 --- a/src/Stream.cpp +++ b/src/Stream.cpp @@ -287,12 +287,12 @@ bool Stream::autoResizing() const return m_autoResize; } -bool Stream::isOpenForReading() +bool Stream::isOpenForReading() const { return true; } -bool Stream::isOpenForWriting() +bool Stream::isOpenForWriting() const { return true; } diff --git a/src/TextStream.cpp b/src/TextStream.cpp index ac25de2..23eba37 100644 --- a/src/TextStream.cpp +++ b/src/TextStream.cpp @@ -146,7 +146,7 @@ std::string TextStream::readLineAt(Uint32 line) return m_lines[line - 1]; } -void TextStream::writeLineAt(Uint32 line, const std::string& line) +void TextStream::writeLineAt(Uint32 line, const std::string& str) { if (m_accessmode != WriteOnly || m_accessmode != ReadWrite) throw InvalidOperationException("Stream not open for reading"); @@ -154,7 +154,7 @@ void TextStream::writeLineAt(Uint32 line, const std::string& line) throw InvalidOperationException("A line cannot be zero indexed"); m_currentLine = line; - writeLine(line); + writeLine(str); } std::vector TextStream::readAllLines() @@ -197,6 +197,16 @@ TextStream::TextMode TextStream::textMode() const return m_textmode; } +bool TextStream::isOpenForReading() const +{ + return ((m_accessmode == ReadOnly || m_accessmode == ReadWrite) && m_accessmode != WriteOnly); +} + +bool TextStream::isOpenForReading() const +{ + return ((m_accessmode == WriteOnly || m_accessmode == ReadWrite) && m_accessmode != ReadOnly); +} + // PRIVATE FUNCTIONS void TextStream::loadLines() {