Mercurial > fife-parpg
comparison ext/guichan-0.8.1/include/guichan/exception.hpp @ 89:fa33cda75471
* Reverting back to 2543 as requested by sleek
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 19 Jul 2008 11:38:52 +0000 |
parents | 4a0efb7baf70 |
children |
comparison
equal
deleted
inserted
replaced
88:1c2842ebe393 | 89:fa33cda75471 |
---|---|
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 | |
52 #ifdef _MSC_VER | |
53 #if _MSC_VER <= 1200 | |
54 #define __FUNCTION__ "?" | |
55 #endif | |
56 #endif | |
57 | |
58 /* | |
59 * A macro used to create a standard exception object. | |
60 * What it basicly does is that it creates a new exception | |
61 * and automatically sets the filename and line number where | |
62 * the exception occured by using other compiler macros. | |
63 */ | |
64 #define GCN_EXCEPTION(mess) gcn::Exception(mess, \ | |
65 __FUNCTION__, \ | |
66 __FILE__, \ | |
67 __LINE__) | |
68 | |
69 namespace gcn | |
70 { | |
71 | |
72 /** | |
73 * An exception containing a message, a file and a line number | |
74 * where the exception occured. Guichan will only throw exceptions | |
75 * of this class. | |
76 * | |
77 * You can use this class for your own exceptions that has | |
78 * something to do with a GUI exception. A nifty feature of the | |
79 * excpetion class is that it can tell you from which line and | |
80 * file it was thrown. To make things easier when throwing | |
81 * exceptions there exists a macro for creating exceptions | |
82 * which automatically sets the filename and line number. | |
83 * | |
84 * EXAMPLE: @code | |
85 * throw GCN_EXCEPTION("my error message"); | |
86 * @endcode | |
87 */ | |
88 class GCN_CORE_DECLSPEC Exception | |
89 { | |
90 public: | |
91 | |
92 /** | |
93 * Constructor. | |
94 */ | |
95 Exception(); | |
96 | |
97 /** | |
98 * Constructor. | |
99 * | |
100 * @param message The error message of the exception. | |
101 */ | |
102 Exception(const std::string& message); | |
103 | |
104 /** | |
105 * Constructor. | |
106 * | |
107 * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead. | |
108 * This constructor merely exists for the GCN_EXCEPTION macro to | |
109 * use. | |
110 * | |
111 * @param message The error message of the exception. | |
112 * @param function The function name where the exception occured. | |
113 * @param filename The name of the file where the exception occured. | |
114 * @param line The line number in the source code where the exception | |
115 * occured. | |
116 */ | |
117 Exception(const std::string& message, | |
118 const std::string& function, | |
119 const std::string& filename, | |
120 unsigned int line); | |
121 | |
122 /** | |
123 * Gets the function name where the exception occured. | |
124 * | |
125 * @return The function name where the exception occured. | |
126 */ | |
127 const std::string& getFunction() const; | |
128 | |
129 /** | |
130 * Gets the error message of the exception. | |
131 * | |
132 * @return The error message of the exception. | |
133 */ | |
134 const std::string& getMessage() const; | |
135 | |
136 /** | |
137 * Gets the filename where the exception occured. | |
138 * | |
139 * @return The filename where the exception occured. | |
140 */ | |
141 const std::string& getFilename() const; | |
142 | |
143 /** | |
144 * Gets the line number where the exception occured. | |
145 * | |
146 * @return The line number where the exception occured. | |
147 */ | |
148 unsigned int getLine() const; | |
149 | |
150 protected: | |
151 /** | |
152 * Holds the name of the function name where the | |
153 * exception occured. | |
154 */ | |
155 std::string mFunction; | |
156 | |
157 /** | |
158 * Holds the error message of the exception. | |
159 */ | |
160 std::string mMessage; | |
161 | |
162 /** | |
163 * Holds the filename where the exception occured. | |
164 */ | |
165 std::string mFilename; | |
166 | |
167 /** | |
168 * Holds the line number where the exception occured. | |
169 */ | |
170 unsigned int mLine; | |
171 }; | |
172 } | |
173 | |
174 #endif // end GCN_EXCEPTION_HPP | |
175 | |
176 /* | |
177 * "Final Fantasy XI is the BEST!... It's even better then water!" | |
178 * - Astrolite | |
179 * I believe it's WoW now days. | |
180 */ |