File: cdsExcept.hh

package info (click to toggle)
toshset 1.73-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 484 kB
  • ctags: 572
  • sloc: sh: 3,589; cpp: 2,938; ansic: 1,057; makefile: 190
file content (52 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

#ifndef __cdsExcept_hh__
#define __cdsExcept_hh__

// mirror of stl exception tree

namespace CDS {

class exception {
  enum {messLength=300};
public:
  char mess[messLength];

  inline exception(const char* m="");      //constructor
  inline exception(const exception& e);    //copy constructor
  // is assignment operator needed?

#ifdef TESTING
  static int test();
#endif  
};

struct out_of_range : public exception 
{ out_of_range(const char* m="") : exception(m) {} };
struct bad_alloc    : public exception
{ bad_alloc(const char* m="") : exception(m) {} };
//exception
struct SingularError : public exception
{ SingularError(const char* m="SingularError") : exception(m) {} };

inline
exception::exception(const char* m)
{
 int i=0;
 for (const char* p=m ; *p!='\0'&&i<messLength-1 ; p++,i++) 
   mess[i] = *p;
 mess[i] = '\0';
} /* constructor */
 
inline
exception::exception(const exception& e)
{
 int i=0;
 for (const char* p=e.mess ; *p!='\0'&&i<messLength-1 ; p++,i++) 
   mess[i] = *p;
 mess[i] = '\0';
} /* copy constructor */

} /* namespace CDS */


#endif /* __cdsExcept_hh__ */