Mercurial > fife-parpg
comparison ext/guichan-0.8.2/include/guichan/exception.hpp @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 /* _______ __ __ __ ______ __ __ _______ __ __ | |
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ | |
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / | |
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / | |
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / | |
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / | |
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ | |
8 * | |
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson | |
10 * | |
11 * | |
12 * Per Larsson a.k.a finalman | |
13 * Olof Naessén a.k.a jansem/yakslem | |
14 * | |
15 * Visit: http://guichan.sourceforge.net | |
16 * | |
17 * License: (BSD) | |
18 * Redistribution and use in source and binary forms, with or without | |
19 * modification, are permitted provided that the following conditions | |
20 * are met: | |
21 * 1. Redistributions of source code must retain the above copyright | |
22 * notice, this list of conditions and the following disclaimer. | |
23 * 2. Redistributions in binary form must reproduce the above copyright | |
24 * notice, this list of conditions and the following disclaimer in | |
25 * the documentation and/or other materials provided with the | |
26 * distribution. | |
27 * 3. Neither the name of Guichan nor the names of its contributors may | |
28 * be used to endorse or promote products derived from this software | |
29 * without specific prior written permission. | |
30 * | |
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
42 */ | |
43 | |
44 #ifndef GCN_EXCEPTION_HPP | |
45 #define GCN_EXCEPTION_HPP | |
46 | |
47 #include <string> | |
48 | |
49 #include "guichan/platform.hpp" | |
50 | |
51 #ifndef __FUNCTION__ | |
52 #define __FUNCTION__ "?" | |
53 #endif | |
54 | |
55 /* | |
56 * A macro used to create a standard exception object. | |
57 * What it basicly does is that it creates a new exception | |
58 * and automatically sets the filename and line number where | |
59 * the exception occured by using other compiler macros. | |
60 */ | |
61 #define GCN_EXCEPTION(mess) gcn::Exception(mess, \ | |
62 __FUNCTION__, \ | |
63 __FILE__, \ | |
64 __LINE__) | |
65 | |
66 namespace gcn | |
67 { | |
68 | |
69 /** | |
70 * An exception containing a message, a file and a line number | |
71 * where the exception occured. Guichan will only throw exceptions | |
72 * of this class. | |
73 * | |
74 * You can use this class for your own exceptions that has | |
75 * something to do with a GUI exception. A nifty feature of the | |
76 * excpetion class is that it can tell you from which line and | |
77 * file it was thrown. To make things easier when throwing | |
78 * exceptions there exists a macro for creating exceptions | |
79 * which automatically sets the filename and line number. | |
80 * | |
81 * EXAMPLE: @code | |
82 * throw GCN_EXCEPTION("my error message"); | |
83 * @endcode | |
84 */ | |
85 class GCN_CORE_DECLSPEC Exception | |
86 { | |
87 public: | |
88 | |
89 /** | |
90 * Constructor. | |
91 */ | |
92 Exception(); | |
93 | |
94 /** | |
95 * Constructor. | |
96 * | |
97 * @param message The error message of the exception. | |
98 */ | |
99 Exception(const std::string& message); | |
100 | |
101 /** | |
102 * Constructor. | |
103 * | |
104 * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead. | |
105 * This constructor merely exists for the GCN_EXCEPTION macro to | |
106 * use. | |
107 * | |
108 * @param message The error message of the exception. | |
109 * @param function The function name where the exception occured. | |
110 * @param filename The name of the file where the exception occured. | |
111 * @param line The line number in the source code where the exception | |
112 * occured. | |
113 */ | |
114 Exception(const std::string& message, | |
115 const std::string& function, | |
116 const std::string& filename, | |
117 unsigned int line); | |
118 | |
119 /** | |
120 * Gets the function name where the exception occured. | |
121 * | |
122 * @return The function name where the exception occured. | |
123 */ | |
124 const std::string& getFunction() const; | |
125 | |
126 /** | |
127 * Gets the error message of the exception. | |
128 * | |
129 * @return The error message of the exception. | |
130 */ | |
131 const std::string& getMessage() const; | |
132 | |
133 /** | |
134 * Gets the filename where the exception occured. | |
135 * | |
136 * @return The filename where the exception occured. | |
137 */ | |
138 const std::string& getFilename() const; | |
139 | |
140 /** | |
141 * Gets the line number where the exception occured. | |
142 * | |
143 * @return The line number where the exception occured. | |
144 */ | |
145 unsigned int getLine() const; | |
146 | |
147 protected: | |
148 /** | |
149 * Holds the name of the function name where the | |
150 * exception occured. | |
151 */ | |
152 std::string mFunction; | |
153 | |
154 /** | |
155 * Holds the error message of the exception. | |
156 */ | |
157 std::string mMessage; | |
158 | |
159 /** | |
160 * Holds the filename where the exception occured. | |
161 */ | |
162 std::string mFilename; | |
163 | |
164 /** | |
165 * Holds the line number where the exception occured. | |
166 */ | |
167 unsigned int mLine; | |
168 }; | |
169 } | |
170 | |
171 #endif // end GCN_EXCEPTION_HPP | |
172 | |
173 /* | |
174 * "Final Fantasy XI is the BEST!... It's even better then water!" | |
175 * - Astrolite | |
176 * I believe it's WoW now days. | |
177 */ |