#ifndef _EXCEPT_H_ #define _EXCEPT_H_ #include #include "mystring.h" class DSException { public: DSException( const String & msg = "" ) : message( msg ) { } virtual ~DSException( ) { } virtual String toString( ) const { return "Exception " + String( typeid( *this ).name( ) ) + ": " + what( ); } virtual String what( ) const { return message; } private: String message; }; class GraphException : public DSException { public: GraphException( const String & msg = "" ) : DSException( msg ) { } }; class NullPointerException : public DSException { public: NullPointerException( const String & msg = "" ) : DSException( msg ) { } }; class IndexOutOfBoundsException : public DSException { public: IndexOutOfBoundsException( const String & msg = "" ) : DSException( msg ) { } IndexOutOfBoundsException( int idx, int sz, const String & msg = "" ) : DSException( msg ), index( idx ), size( sz ) { } int getIndex( ) const { return index; } int getSize( ) const { return size; } private: int index; int size; }; class ArrayIndexOutOfBoundsException : public IndexOutOfBoundsException { public: ArrayIndexOutOfBoundsException( const String & msg = "" ) : IndexOutOfBoundsException ( msg ) { } ArrayIndexOutOfBoundsException( int idx, int sz, const String & msg = "" ) : IndexOutOfBoundsException( idx, sz, msg ) { } }; class StringIndexOutOfBoundsException : public IndexOutOfBoundsException { public: StringIndexOutOfBoundsException( const String & msg = "" ) : IndexOutOfBoundsException ( msg ) { } StringIndexOutOfBoundsException( int idx, int sz, const String & msg = "" ) : IndexOutOfBoundsException( idx, sz, msg ) { } }; class UnderflowException : public DSException { public: UnderflowException( const String & msg = "" ) : DSException( msg ) { } }; class OverflowException : public DSException { public: OverflowException( const String & msg = "" ) : DSException( msg ) { } }; class ItemNotFoundException : public DSException { public: ItemNotFoundException( const String & msg = "" ) : DSException( msg ) { } }; class DuplicateItemException : public DSException { public: DuplicateItemException( const String & msg = "" ) : DSException( msg ) { } }; class IteratorException : public DSException { public: IteratorException( const String & msg = "" ) : DSException( msg ) { } }; class IteratorOutOfBoundsException : public IteratorException { public: IteratorOutOfBoundsException( const String & msg = "" ) : IteratorException( msg ) { } }; class IteratorUninitializedException : public IteratorException { public: IteratorUninitializedException( const String & msg = "" ) : IteratorException( msg ) { } }; class IteratorMismatchException : public IteratorException { public: IteratorMismatchException( const String & msg = "" ) : IteratorException( msg ) { } }; class BadArgumentException : public DSException { public: BadArgumentException( const String & msg = "" ) : DSException( msg ) { } }; #endif