From 67b6a78b347ab7ba269a52d772e79d12444f6e96 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 10 Oct 2011 23:09:53 -0700 Subject: Adding a few more features to Input, and actually creating a slightly better ClassName system, when using gcc and libstdc++. --- includes/Exceptions.h | 16 ++++++++++++++++ includes/Handle.h | 1 + includes/Input.h | 1 + 3 files changed, 18 insertions(+) (limited to 'includes') diff --git a/includes/Exceptions.h b/includes/Exceptions.h index 39f3239..b6730c1 100644 --- a/includes/Exceptions.h +++ b/includes/Exceptions.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace Balau { @@ -21,6 +22,21 @@ class GeneralException { static inline void AssertHelper(const String & msg) throw(GeneralException) { throw GeneralException(msg); } +class ClassName { + public: + template ClassName(T * ptr); + ~ClassName() { free(m_demangled); } + const char * c_str() const { return m_demangled; } + private: + char * m_demangled; +}; + +template +ClassName::ClassName(T * ptr) { + int status; + m_demangled = abi::__cxa_demangle(typeid(*ptr).name(), 0, 0, &status); +} + }; #define Assert(c) if (!(c)) { \ diff --git a/includes/Handle.h b/includes/Handle.h index f2b78ad..489ab75 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -53,6 +53,7 @@ class IO { class SeekableHandle : public Handle { public: + SeekableHandle() : m_wOffset(0), m_rOffset(0) { } virtual bool canSeek(); virtual void rseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); virtual void wseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); diff --git a/includes/Input.h b/includes/Input.h index 7f801f6..71e6845 100644 --- a/includes/Input.h +++ b/includes/Input.h @@ -9,6 +9,7 @@ class Input : public SeekableHandle { Input(const char * fname) throw (GeneralException); virtual void close() throw (GeneralException); virtual bool isClosed(); + virtual bool canRead(); virtual const char * getName(); virtual off_t getSize(); virtual time_t getMTime(); -- cgit v1.2.3