diff --git a/Common/Exception.cpp b/Common/Exception.cpp new file mode 100644 index 0000000..5295312 --- /dev/null +++ b/Common/Exception.cpp @@ -0,0 +1,44 @@ + +#include "Exception.h" +#include +#include + + +Exception::Exception(const char *cp): + _error(0), + _string(cp) +{ +} + +Exception::Exception(const std::string& string): + _error(0), + _string(string) +{ +} + +Exception::Exception(const char *cp, int error): + _error(error), + _string(cp) +{ +} + +Exception::Exception(const std::string& string, int error): + _error(error), + _string(string) +{ +} + + +Exception::~Exception() throw() +{ +} + +const char *Exception::what() +{ + return _string.c_str(); +} + +const char *Exception::errorString() +{ + return ""; +} diff --git a/Common/Exception.h b/Common/Exception.h new file mode 100644 index 0000000..3377cac --- /dev/null +++ b/Common/Exception.h @@ -0,0 +1,36 @@ +#ifndef __COMMON_EXCEPTION_H__ +#define __COMMON_EXCEPTION_H__ + +#include +#include + + +class Exception : public std::exception +{ +public: + Exception(const char *cp); + Exception(const std::string &str); + + + virtual ~Exception() throw (); + + virtual const char *what(); + virtual const char *errorString(); + + int error() const { return _error; } + +protected: + Exception(const char *cp, int error); + Exception(const std::string& string, int error); + +private: + int _error; + std::string _string; + +}; + + + + + +#endif \ No newline at end of file diff --git a/ProFUSE/Lock.cpp b/Common/Lock.cpp similarity index 85% rename from ProFUSE/Lock.cpp rename to Common/Lock.cpp index 7f6130c..7ef6acf 100644 --- a/ProFUSE/Lock.cpp +++ b/Common/Lock.cpp @@ -1,6 +1,5 @@ -#include +#include "Lock.h" -using namespace ProFUSE; Lock::Lock() { diff --git a/ProFUSE/Lock.h b/Common/Lock.h similarity index 94% rename from ProFUSE/Lock.h rename to Common/Lock.h index 8e32a80..246cf08 100644 --- a/ProFUSE/Lock.h +++ b/Common/Lock.h @@ -3,7 +3,6 @@ #include -namespace ProFUSE { class Lock { public: @@ -28,6 +27,4 @@ private: }; -} - #endif diff --git a/ProFUSE/Makefile b/Common/Makefile similarity index 100% rename from ProFUSE/Makefile rename to Common/Makefile diff --git a/ProFUSE/auto.h b/Common/auto.h similarity index 98% rename from ProFUSE/auto.h rename to Common/auto.h index e7c6876..8610d84 100644 --- a/ProFUSE/auto.h +++ b/Common/auto.h @@ -3,7 +3,6 @@ #include -namespace ProFUSE { template class auto_array @@ -98,7 +97,6 @@ private: }; #endif -} #endif diff --git a/ProFUSE/smart_pointers.h b/Common/smart_pointers.h similarity index 91% rename from ProFUSE/smart_pointers.h rename to Common/smart_pointers.h index 6ab4ecd..eee7fab 100644 --- a/ProFUSE/smart_pointers.h +++ b/Common/smart_pointers.h @@ -1,6 +1,6 @@ -#ifndef __PROFUSE_SMART_POINTERS_H__ -#define __PROFUSE_SMART_POINTERS_H__ +#ifndef __COMMON_SMART_POINTERS_H__ +#define __COMMON_SMART_POINTERS_H__ #ifdef CPP0X //C++0x diff --git a/NuFX/Exception.cpp b/NuFX/Exception.cpp new file mode 100644 index 0000000..60d9878 --- /dev/null +++ b/NuFX/Exception.cpp @@ -0,0 +1,10 @@ +#include "Exception.h" + +namespace NuFX { + +const char *NuFX::Exception::errorString() +{ + return ::NuStrError((NuError)error()); +} + +} \ No newline at end of file diff --git a/NuFX/Exception.h b/NuFX/Exception.h new file mode 100644 index 0000000..04ca32b --- /dev/null +++ b/NuFX/Exception.h @@ -0,0 +1,35 @@ +#ifndef __NUFX_EXCEPTION_H__ +#define __NUFX_EXCEPTION_H__ + +#include +#include + +namespace NuFX { + + +class Exception : public ::Exception +{ +public: + Exception(const char *cp, NuError error); + Exception(const std::string& string, NuError error); + + virtual const char *errorString(); + +private: + typedef ::Exception super; +}; + + +inline Exception::Exception(const char *cp, NuError error) : + super(cp, error) +{ +} + +inline Exception::Exception(const std::string& string, NuError error) : + super(string, error) +{ +} + +} + +#endif \ No newline at end of file diff --git a/POSIX/Exception.cpp b/POSIX/Exception.cpp new file mode 100644 index 0000000..5670956 --- /dev/null +++ b/POSIX/Exception.cpp @@ -0,0 +1,13 @@ + +#include "Exception.h" +#include +#include + +namespace POSIX { + +const char *Exception::errorString() +{ + return strerror(error()); +} + +} \ No newline at end of file diff --git a/POSIX/Exception.h b/POSIX/Exception.h new file mode 100644 index 0000000..016e8e4 --- /dev/null +++ b/POSIX/Exception.h @@ -0,0 +1,34 @@ +#ifndef __POSIX_EXCEPTION_H__ +#define __POSIX_EXCEPTION_H__ + +#include + +namespace POSIX { + + +class Exception : public ::Exception { +public: + Exception(const char *cp, int error); + Exception(const std::string& string, int error); + + virtual const char *errorString(); + +private: + typedef ::Exception super; +}; + + +inline Exception::Exception(const char *cp, int error) : + super(cp, error) +{ +} + +inline Exception::Exception(const std::string& string, int error) : + super(string, error) +{ +} + + +} + +#endif \ No newline at end of file diff --git a/ProFUSE/Exception.cpp b/ProDOS/Exception.cpp similarity index 92% rename from ProFUSE/Exception.cpp rename to ProDOS/Exception.cpp index 512a4d2..fe71da5 100644 --- a/ProFUSE/Exception.cpp +++ b/ProDOS/Exception.cpp @@ -1,33 +1,14 @@ -#include +#include "Exception.h" #include #include -using namespace ProFUSE; +namespace ProDOS { -Exception::~Exception() throw() -{ -} -const char *Exception::what() -{ - return _string.c_str(); -} const char *Exception::errorString() { - return ""; -} - - -const char *POSIXException::errorString() -{ - return strerror(error()); -} - -const char *ProDOSException::errorString() -{ - switch (error()) { @@ -147,3 +128,5 @@ const char *ProDOSException::errorString() } return ""; } + +} diff --git a/ProFUSE/Exception.h b/ProDOS/Exception.h similarity index 51% rename from ProFUSE/Exception.h rename to ProDOS/Exception.h index caa9964..b89bf39 100644 --- a/ProFUSE/Exception.h +++ b/ProDOS/Exception.h @@ -1,10 +1,9 @@ -#ifndef __EXCEPTION_H__ -#define __EXCEPTION_H__ +#ifndef __PRODOS_EXCEPTION_H__ +#define __PRODOS_EXCEPTION_H__ -#include -#include +#include -namespace ProFUSE { +namespace ProDOS { // ProDOS Errors @@ -67,87 +66,27 @@ enum resAddErr = 0x71 }; -class Exception : public std::exception -{ + +class Exception : public ::Exception { public: - Exception(const char *cp); - Exception(const std::string &str); - - - virtual ~Exception() throw (); - - virtual const char *what(); - virtual const char *errorString(); - - int error() const { return _error; } - -protected: Exception(const char *cp, int error); Exception(const std::string& string, int error); - -private: - int _error; - std::string _string; - -}; - -class POSIXException : public Exception { -public: - POSIXException(const char *cp, int error); - POSIXException(const std::string& string, int error); - - virtual const char *errorString(); -}; - -class ProDOSException : public Exception { -public: - ProDOSException(const char *cp, int error); - ProDOSException(const std::string& string, int error); virtual const char *errorString(); + +private: + typedef ::Exception super; }; -inline Exception::Exception(const char *cp): - _error(0), - _string(cp) + + +inline Exception::Exception(const char *cp, int error) : + super(cp, error) { } -inline Exception::Exception(const std::string& string): - _error(0), - _string(string) -{ -} - -inline Exception::Exception(const char *cp, int error): - _error(error), - _string(cp) -{ -} - -inline Exception::Exception(const std::string& string, int error): - _error(error), - _string(string) -{ -} - -inline POSIXException::POSIXException(const char *cp, int error) : - Exception(cp, error) -{ -} - -inline POSIXException::POSIXException(const std::string& string, int error) : - Exception(string, error) -{ -} - -inline ProDOSException::ProDOSException(const char *cp, int error) : - Exception(cp, error) -{ -} - -inline ProDOSException::ProDOSException(const std::string& string, int error) : - Exception(string, error) +inline Exception::Exception(const std::string& string, int error) : + super(string, error) { } @@ -155,4 +94,4 @@ inline ProDOSException::ProDOSException(const std::string& string, int error) : } -#endif \ No newline at end of file +#endif diff --git a/libNuFX.a b/libNuFX.a new file mode 100644 index 0000000..c715ef5 Binary files /dev/null and b/libNuFX.a differ