blob: e701fc8e27d0fc98859887eea2032173447f2a0a [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001// Copyright (C) 1999-2005 Open Source Telecom Corporation.
2// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17//
18// As a special exception, you may use this file as part of a free software
19// library without restriction. Specifically, if other files instantiate
20// templates or use macros or inline functions from this file, or you compile
21// this file and link it with other files to produce an executable, this
22// file does not by itself cause the resulting executable to be covered by
23// the GNU General Public License. This exception does not however
24// invalidate any other reasons why the executable file might be covered by
25// the GNU General Public License.
26//
27// This exception applies only to the code released under the name GNU
28// Common C++. If you copy code from other releases into a copy of GNU
29// Common C++, as the General Public License permits, the exception does
30// not apply to the code that you add in this way. To avoid misleading
31// anyone as to the status of such modified files, you must delete
32// this exception notice from them.
33//
34// If you write modifications of your own for GNU Common C++, it is your choice
35// whether to permit this exception to apply to your modifications.
36// If you do not wish that, delete this exception notice.
37//
38
39/**
40 * @file exception.h
41 * @short GNU Common C++ exception model base classes.
42 **/
43
44#ifndef CCXX_EXCEPTION_H_
45#define CCXX_EXCEPTION_H_
46
47#ifndef CCXX_CONFIG_H_
48#include <cc++/config.h>
49#endif
50
51#ifndef CCXX_STRING_H_
52#include <cc++/string.h>
53#endif
54
55// see if we support useful and std exception handling, else we ignore
56// it for the rest of the system.
57
58#if defined(HAVE_EXCEPTION)
59#define COMMON_STD_EXCEPTION
60
61#include <exception>
62
63#ifdef CCXX_NAMESPACES
64namespace ost {
65#endif
66
67/**
68 * Mainline exception handler, this is the root for all Common C++
69 * exceptions and assures the ansi C++ exception class hierarchy is both
70 * followed and imported into the gnu Common C++ class hierarchy.
71 *
72 * @author David Sugar <dyfet@ostel.com>
73 * @short Base exception class for all Common C++ exceptions.
74 */
75class __EXPORT Exception : public std::exception
76{
77private:
78 String _what;
79
80public:
81 Exception(const String& what_arg) throw();
82 virtual ~Exception() throw();
83 virtual const char *getString() const;
84 virtual const char *what() const throw();
85};
86
87/**
88 * A sub-hierarchy for all Common C++ I/O related classes.
89 *
90 * @author David Sugar <dyfet@ostel.com>
91 * @short I/O operation exception hierarchy.
92 */
93class __EXPORT IOException : public Exception
94{
95private:
96 long _systemError;
97 mutable char* _systemErrorString;
98
99public:
100 IOException(const String &what_arg, long systemError = 0) throw();
101 virtual ~IOException() throw();
102
103 virtual long getSystemError() const throw();
104 virtual const char* getSystemErrorString() const throw();
105};
106
107/**
108 * A sub-hierarchy for thread exceptions.
109 *
110 * @author David Sugar <dyfet@ostel.com>
111 * @short thread exception hierarchy.
112 */
113class __EXPORT ThrException : public Exception
114{
115public:
116 ThrException(const String &what_arg) : Exception(what_arg) {};
117};
118
119/**
120 * A sub-hierarchy for all task synchronizion related exceptions.
121 *
122 * @author David Sugar <dyfet@ostel.com>
123 * @short Synchronization object exception hierarchy.
124 */
125class __EXPORT SyncException : public ThrException
126{
127public:
128 SyncException(const String &what_arg) : ThrException(what_arg) {};
129};
130
131class __EXPORT InterruptException : public ThrException
132{
133public:
134 InterruptException() : ThrException("interrupted") {};
135};
136
137
138#ifdef CCXX_NAMESPACES
139}
140#endif
141
142#endif
143
144#endif