TS++ library: time series library
error.h
Go to the documentation of this file.
1 
34 // include guard
35 #ifndef TSXX_ERROR_H_VERSION
36 
37 #define TSXX_ERROR_H_VERSION \
38  "TSXX_ERROR_H V1.0"
39 
40  /*----------------------------------------------------------------------*/
41  // assertions
42 
43 namespace ts {
44 
45  namespace error {
46 
60  class Exception
61  {
62  public:
64  Exception();
66  Exception(const char* message);
68  Exception(const char* message,
69  const char* condition);
71  Exception(const char* message,
72  const char* file,
73  const int& line,
74  const char* condition);
76  Exception(const char* message,
77  const char* file,
78  const int& line);
80  virtual ~Exception() { }
82  virtual void report() const;
84  static void report_on_construct();
86  static void dont_report_on_construct();
87  private:
89  void base_report() const;
91  static bool Mreport_on_construct;
93  const char* Mmessage;
95  const char* Mfile;
97  const int& Mline;
99  const char* Mcondition;
100  }; // class exception
101 
102  } // namespace error
103 
104 } // namespace ts
105 
106 /*======================================================================*/
107 //
108 // preprocessor macros
109 // ===================
110 
118 #define TSXX_Xassert(C,M,E) \
119  if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
120 
127 #define TSXX_assert(C,M) TSXX_Xassert( C , M , ts::error::Exception )
128 
135 #define TSXX_abort(M) \
136  throw( ts::error::Exception ( M , __FILE__, __LINE__ ))
137 
138 #endif // TSXX_ERROR_H_VERSION (includeguard)
139 
140 /* ----- END OF error.h ----- */
const char * Mmessage
pointer to message string
Definition: error.h:93
const char * Mfile
pointer to file name string
Definition: error.h:95
Base class for exceptions.
Definition: error.h:60
Exception()
Creates exception with no explaning comments.
Definition: error.cc:50
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:81
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:91
void base_report() const
Screen report.
Definition: error.cc:99
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:87
virtual ~Exception()
provide virtual destructor
Definition: error.h:80
All stuff in this library will be placed within namespace ts.
Definition: anyfilter.cc:43
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:99
virtual void report() const
Screen report.
Definition: error.cc:93
const int & Mline
pointer to line number in source file
Definition: error.h:97