- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gexception.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
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 3 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, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // gexception.cpp
19 //
20
21 #include "gdef.h"
22 #include "gexception.h"
23
24 G::Exception::Exception()
25 {
26 }
27
28 G::Exception::Exception( const char * what ) :
29 m_what(what?what:"")
30 {
31 }
32
33 G::Exception::Exception( const std::string & what ) :
34 m_what(what)
35 {
36 }
37
38 G::Exception::Exception( const char * what , const std::string & more ) :
39 m_what(what)
40 {
41 append( more ) ;
42 }
43
44 G::Exception::Exception( const std::string & what , const std::string & more ) :
45 m_what(what)
46 {
47 append( more ) ;
48 }
49
50 G::Exception::Exception( const std::string & what , const std::string & more1 , const std::string & more2 ) :
51 m_what(what)
52 {
53 append( more1 ) ;
54 append( more2 ) ;
55 }
56
57
58 G::Exception::~Exception() throw()
59 {
60 }
61
62 const char * G::Exception::what() const throw()
63 {
64 return m_what.c_str() ;
65 }
66
67 void G::Exception::append( const char * more )
68 {
69 if( more != NULL && *more != '\0' )
70 {
71 m_what += std::string(": ") ;
72 m_what += std::string(more) ;
73 }
74 }
75
76 void G::Exception::append( const std::string & more )
77 {
78 if( !more.empty() )
79 {
80 m_what += std::string(": ") ;
81 m_what += std::string(more) ;
82 }
83 }
84
85 void G::Exception::prepend( const char * context )
86 {
87 if( context != NULL && *context != '\0' )
88 {
89 m_what = std::string(context) + ": " + m_what ;
90 }
91 }
92
G::Exception::prepend
void prepend(const char *context)
Prepends context to the what string.
Definition: gexception.cpp:85
G::Exception::~Exception
virtual ~Exception()
Destructor.
Definition: gexception.cpp:58
G::Exception::Exception
Exception()
Default constructor.
Definition: gexception.cpp:24
gexception.h
G::Exception::append
void append(const char *more)
Appends 'more' to the what string.
Definition: gexception.cpp:67
G::Exception::what
virtual const char * what() const
Override from std::exception.
Definition: gexception.cpp:62