Build system improvements
[ustl.git] / ustdxept.h
blob4f50953701cb76afb6731be8b4c3f1c60c49ca50
1 // This file is part of the ustl library, an STL implementation.
2 //
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
5 //
6 // ustdxept.h
7 //
9 #ifndef USTDXEPT_H_46F7AE967738B588038F95E41158D7FF
10 #define USTDXEPT_H_46F7AE967738B588038F95E41158D7FF
12 #include "uexception.h"
13 #include "ustring.h"
15 namespace ustl {
17 enum {
18 xfmt_ErrorMessage = 2,
19 xfmt_LogicError = xfmt_ErrorMessage,
20 xfmt_RuntimeError = xfmt_ErrorMessage
23 /// \class logic_error ustdxept.h ustl.h
24 /// \ingroup Exceptions
25 ///
26 /// \brief Logic errors represent problems in the internal logic of the program.
27 ///
28 class error_message : public exception {
29 public:
30 explicit error_message (const char* arg) throw();
31 virtual ~error_message (void) throw();
32 inline virtual const char* what (void) const throw() { return ("error"); }
33 virtual void info (string& msgbuf, const char* fmt = NULL) const throw();
34 virtual void read (istream& is);
35 virtual void write (ostream& os) const;
36 virtual size_t stream_size (void) const;
37 protected:
38 string m_Arg;
41 /// \class logic_error ustdxept.h ustl.h
42 /// \ingroup Exceptions
43 ///
44 /// \brief Logic errors represent problems in the internal logic of the program.
45 ///
46 class logic_error : public error_message {
47 public:
48 inline explicit logic_error (const char* arg) throw() : error_message (arg) {}
49 inline virtual const char* what (void) const throw() { return ("logic error"); }
52 /// \class domain_error ustdxept.h ustl.h
53 /// \ingroup Exceptions
54 ///
55 /// \brief Reports domain errors ("domain" is in the mathematical sense)
56 ///
57 class domain_error : public logic_error {
58 public:
59 inline explicit domain_error (const char* arg) throw() : logic_error (arg) {}
60 inline virtual const char* what (void) const throw() { return ("domain error"); }
63 /// \class invalid_argument ustdxept.h ustl.h
64 /// \ingroup Exceptions
65 ///
66 /// \brief Reports an invalid argument to a function.
67 ///
68 class invalid_argument : public logic_error {
69 public:
70 inline explicit invalid_argument (const char* arg) throw() : logic_error (arg) {}
71 inline virtual const char* what (void) const throw() { return ("invalid argument"); }
74 /// \class length_error ustdxept.h ustl.h
75 /// \ingroup Exceptions
76 ///
77 /// \brief Reports when an object exceeds its allowed size.
78 ///
79 class length_error : public logic_error {
80 public:
81 inline explicit length_error (const char* arg) throw() : logic_error (arg) {}
82 inline virtual const char* what (void) const throw() { return ("length error"); }
85 /// \class out_of_range ustdxept.h ustl.h
86 /// \ingroup Exceptions
87 ///
88 /// \brief Reports arguments with values out of allowed range.
89 ///
90 class out_of_range : public logic_error {
91 public:
92 inline explicit out_of_range (const char* arg) throw() : logic_error (arg) {}
93 inline virtual const char* what (void) const throw() { return ("out of range"); }
96 /// \class runtime_error ustdxept.h ustl.h
97 /// \ingroup Exceptions
98 ///
99 /// \brief Reports errors that are dependent on the data being processed.
101 class runtime_error : public error_message {
102 public:
103 inline explicit runtime_error (const char* arg) throw() : error_message (arg) {}
104 inline virtual const char* what (void) const throw() { return ("runtime error"); }
107 /// \class range_error ustdxept.h ustl.h
108 /// \ingroup Exceptions
110 /// \brief Reports data that does not fall within the permitted range.
112 class range_error : public runtime_error {
113 public:
114 inline explicit range_error (const char* arg) throw() : runtime_error (arg) {}
115 inline virtual const char* what (void) const throw() { return ("range error"); }
118 /// \class overflow_error ustdxept.h ustl.h
119 /// \ingroup Exceptions
121 /// \brief Reports arithmetic overflow.
123 class overflow_error : public runtime_error {
124 public:
125 inline explicit overflow_error (const char* arg) throw() : runtime_error (arg) {}
126 inline virtual const char* what (void) const throw() { return ("overflow error"); }
129 /// \class underflow_error ustdxept.h ustl.h
130 /// \ingroup Exceptions
132 /// \brief Reports arithmetic underflow.
134 class underflow_error : public runtime_error {
135 public:
136 inline explicit underflow_error (const char* arg) throw() : runtime_error (arg) {}
137 inline virtual const char* what (void) const throw() { return ("underflow error"); }
140 } // namespace ustl
142 #endif