ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
exception.h
Go to the documentation of this file.
1// Copyright (C) 1999-2005 Open Source Telecom Corporation.
2// Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3// Copyright (C) 2015 Cherokees of Idaho.
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
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 commoncpp/exception.h
41 * @short GNU Common C++ exception model base classes.
42 **/
43
44#ifndef COMMONCPP_EXCEPTION_H_
45#define COMMONCPP_EXCEPTION_H_
46
47#ifndef COMMONCPP_CONFIG_H_
48#include <commoncpp/config.h>
49#endif
50
51#ifndef COMMONCPP_STRING_H_
52#include <commoncpp/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(CCXX_EXCEPTIONS)
59#define COMMONCPP_EXCEPTIONS
60
61#include <exception>
62#include <stdexcept>
63
64namespace ost {
65
66/**
67 * Mainline exception handler, this is the root for all Common C++
68 * exceptions and assures the ansi C++ exception class hierarchy is both
69 * followed and imported into the gnu Common C++ class hierarchy.
70 *
71 * @author David Sugar <dyfet@ostel.com>
72 * @short Base exception class for all Common C++ exceptions.
73 */
74class __EXPORT Exception : public std::exception
75{
76private:
77 String _what;
78
79public:
80 Exception(const String& what_arg) throw();
81 virtual ~Exception() throw();
82 virtual const char *getString() const;
83 virtual const char *what() const throw();
84};
85
86/**
87 * A sub-hierarchy for all Common C++ I/O related classes.
88 *
89 * @author David Sugar <dyfet@ostel.com>
90 * @short I/O operation exception hierarchy.
91 */
92class __EXPORT IOException : public Exception
93{
94private:
95 long _systemError;
96 mutable char* _systemErrorString;
97
98public:
99 IOException(const String &what_arg, long systemError = 0) throw();
100 virtual ~IOException() throw();
101
102 virtual long getSystemError() const throw();
103 virtual const char* getSystemErrorString() const throw();
104};
105
106/**
107 * A sub-hierarchy for thread exceptions.
108 *
109 * @author David Sugar <dyfet@ostel.com>
110 * @short thread exception hierarchy.
111 */
112class __EXPORT ThrException : public Exception
113{
114public:
115 inline ThrException(const String &what_arg) : Exception(what_arg) {}
116};
117
118/**
119 * A sub-hierarchy for all task synchronizion related exceptions.
120 *
121 * @author David Sugar <dyfet@ostel.com>
122 * @short Synchronization object exception hierarchy.
123 */
124class __EXPORT SyncException : public ThrException
125{
126public:
127 inline SyncException(const String &what_arg) : ThrException(what_arg) {}
128};
129
130class __EXPORT InterruptException : public ThrException
131{
132public:
133 inline InterruptException() : ThrException("interrupted") {}
134};
135
136} // namespace ost
137
138#endif
139
140#endif
Common C++ generic string class.
#define __EXPORT
Definition: config.h:49
Definition: address.cpp:63
ucommon::String String
Definition: string.h:54