AFF --- A container for numbers (array) by Friederich and Forbriger.
error.h
Go to the documentation of this file.
1 
46 // include guard
47 #ifndef AFF_ERROR_H_VERSION
48 
49 #define AFF_ERROR_H_VERSION \
50  "AFF_ERROR_H V1.2"
51 
52 #include<aff/lib/types.h>
53 
54 namespace aff {
55 
74  class Exception
75  {
76  public:
78  Exception();
80  Exception(const char* message);
82  Exception(const char* message,
83  const char* condition);
85  Exception(const char* message,
86  const char* file,
87  const int& line,
88  const char* condition);
90  Exception(const char* message,
91  const char* file,
92  const int& line);
94  virtual ~Exception() { }
96  virtual void report() const;
98  static void report_on_construct();
100  static void dont_report_on_construct();
101  protected:
103  void base_report() const;
104  private:
106  static bool Mreport_on_construct;
108  const char* Mmessage;
110  const char* Mfile;
112  const int& Mline;
114  const char* Mcondition;
115  }; // class Exception
116 
117  /*----------------------------------------------------------------------*/
118 
125  public Exception
126  {
127  public:
129  AllocException(const Tsize& n, const Tsize& size);
131  virtual ~AllocException() { }
133  virtual void report() const;
134  private:
137  }; // class AllocException
138 
139 } // namespace aff
140 
141 /*======================================================================*/
142 //
143 // preprocessor macros
144 // ===================
145 
153 #define AFF_Xassert(C,M,E) \
154  if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
155 
162 #define AFF_assert(C,M) AFF_Xassert( C , M , aff::Exception )
163 
170 #define AFF_abort(M) \
171  throw( aff::Exception ( M , __FILE__, __LINE__ ))
172 
173 #endif // AFF_ERROR_H_VERSION (includeguard)
174 
175 /* ----- END OF error.h ----- */
virtual ~AllocException()
provide virtual destructor
Definition: error.h:131
Root namespace of library.
Definition: array.h:148
some typedefs we refer to
AllocException(const Tsize &n, const Tsize &size)
take number of requested elements and their size
Definition: error.cc:130
virtual ~Exception()
provide virtual destructor
Definition: error.h:94
const char * Mmessage
pointer to message string
Definition: error.h:108
Exception()
Creates exception with no explaning comments.
Definition: error.cc:55
virtual void report() const
Screen report.
Definition: error.cc:98
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:106
virtual void report() const
Screen report.
Definition: error.cc:134
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:86
Base class for exceptions.
Definition: error.h:74
const int & Mline
pointer to line number in source file
Definition: error.h:112
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:114
const char * Mfile
pointer to file name string
Definition: error.h:110
Tsize Mn
members to remember
Definition: error.h:136
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:92
void base_report() const
Screen report.
Definition: error.cc:104
Exception thrown in case of allocation error.
Definition: error.h:124
size_t Tsize
Type to hold the size of an array dimension.
Definition: types.h:51