From 8386fa54a0d422f9779b96a74a52ea45e8dba088 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 30 Apr 2015 21:16:18 -0700 Subject: [PATCH] * Add formattedMessage to Exception * Add missing IStreamWriter::fill implementations in FileWriter --- include/Athena/Exception.hpp | 5 +++++ include/Athena/FileWriter.hpp | 2 ++ src/Athena/FileWriter.cpp | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/Athena/Exception.hpp b/include/Athena/Exception.hpp index 8fc7e1c..f3e82d8 100644 --- a/include/Athena/Exception.hpp +++ b/include/Athena/Exception.hpp @@ -71,6 +71,11 @@ public: { return m_line; } + + inline std::string formattedMessage() const + { + return Athena::utility::sprintf("%s : %s (%i) %s", m_file.c_str(), m_function.c_str(), m_line, m_message.c_str()); + } protected: std::string m_message; //!< The error message string std::string m_file; diff --git a/include/Athena/FileWriter.hpp b/include/Athena/FileWriter.hpp index 49f3445..4576e9c 100644 --- a/include/Athena/FileWriter.hpp +++ b/include/Athena/FileWriter.hpp @@ -59,6 +59,8 @@ public: void writeBool (bool val); void writeString(const std::string& val); void writeUnicode(const std::string& str); + void fill(atInt8 byte, atUint64 len); + void fill(atUint8 byte, atUint64 len); private: std::string m_filename; FILE* m_fileHandle; diff --git a/src/Athena/FileWriter.cpp b/src/Athena/FileWriter.cpp index e4a5572..438db10 100644 --- a/src/Athena/FileWriter.cpp +++ b/src/Athena/FileWriter.cpp @@ -306,5 +306,18 @@ void FileWriter::writeUnicode(const std::string& str) writeInt16(chr); } } + +void FileWriter::fill(atInt8 byte, atUint64 len) +{ + if (!isOpen()) + THROW_INVALID_OPERATION_EXCEPTION("File not open for writing"); + fwrite(&byte, 1, len, m_fileHandle); +} + +void FileWriter::fill(atUint8 byte, atUint64 len) +{ + fill((atInt8)byte, len); +} + } } // Athena