author | mickeyl <mickeyl> | 2004-04-04 17:02:15 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 17:02:15 (UTC) |
commit | 100def2936503dedc8138d738d68b69d5de66766 (patch) (unidiff) | |
tree | 5d35c8a0a5b10941cc17bb44df10dd851b81d06c | |
parent | fd9146de7698a796659b68606429da490f817138 (diff) | |
download | opie-100def2936503dedc8138d738d68b69d5de66766.zip opie-100def2936503dedc8138d738d68b69d5de66766.tar.gz opie-100def2936503dedc8138d738d68b69d5de66766.tar.bz2 |
fix #defines, so that you never have to say
Opie::Core::odebug << "bla", but just
odebug << "bla".
(I fear otherwise people wouldn't want to use it ;)
-rw-r--r-- | libopie2/opiecore/odebug.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h index a5c9ded..b040166 100644 --- a/libopie2/opiecore/odebug.h +++ b/libopie2/opiecore/odebug.h | |||
@@ -1,323 +1,323 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) | 3 | (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) |
4 | Inspired by the KDE debug classes, which are | 4 | Inspired by the KDE debug classes, which are |
5 | (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) | 5 | (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) |
6 | (C) 2002 Holger Freyther (freyther@kde.org) | 6 | (C) 2002 Holger Freyther (freyther@kde.org) |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #ifndef ODEBUG_H | 33 | #ifndef ODEBUG_H |
34 | #define ODEBUG_H | 34 | #define ODEBUG_H |
35 | 35 | ||
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | 37 | ||
38 | class QWidget; | 38 | class QWidget; |
39 | class QDateTime; | 39 | class QDateTime; |
40 | class QDate; | 40 | class QDate; |
41 | class QTime; | 41 | class QTime; |
42 | class QPoint; | 42 | class QPoint; |
43 | class QSize; | 43 | class QSize; |
44 | class QRect; | 44 | class QRect; |
45 | class QRegion; | 45 | class QRegion; |
46 | class QStringList; | 46 | class QStringList; |
47 | class QColor; | 47 | class QColor; |
48 | class QBrush; | 48 | class QBrush; |
49 | 49 | ||
50 | namespace Opie { | 50 | namespace Opie { |
51 | namespace Core { | 51 | namespace Core { |
52 | 52 | ||
53 | class odbgstream; | 53 | class odbgstream; |
54 | class ondbgstream; | 54 | class ondbgstream; |
55 | 55 | ||
56 | #ifdef __GNUC__ | 56 | #ifdef __GNUC__ |
57 | #define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] " | 57 | #define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] " |
58 | #else | 58 | #else |
59 | #define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] " | 59 | #define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] " |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] " | 62 | #define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] " |
63 | 63 | ||
64 | #define owarn odWarning() | 64 | #define owarn Opie::Core::odWarning() |
65 | #define oerr odError() | 65 | #define oerr Opie::Core::odError() |
66 | #define odebug odDebug() | 66 | #define odebug Opie::Core::odDebug() |
67 | #define ofatal odFatal() | 67 | #define ofatal Opie::Core::odFatal() |
68 | #define oendl "\n" | 68 | #define oendl "\n" |
69 | 69 | ||
70 | class odbgstreamprivate; | 70 | class odbgstreamprivate; |
71 | /** | 71 | /** |
72 | * odbgstream is a text stream that allows you to print debug messages. | 72 | * odbgstream is a text stream that allows you to print debug messages. |
73 | * Using the overloaded "<<" operator you can send messages. Usually | 73 | * Using the overloaded "<<" operator you can send messages. Usually |
74 | * you do not create the odbgstream yourself, but use @ref odDebug() (odebug) | 74 | * you do not create the odbgstream yourself, but use @ref odDebug() (odebug) |
75 | * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one. | 75 | * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one. |
76 | * | 76 | * |
77 | * Example: | 77 | * Example: |
78 | * <pre> | 78 | * <pre> |
79 | * int i = 5; | 79 | * int i = 5; |
80 | * odebug << "The value of i is " << i << oendl; | 80 | * odebug << "The value of i is " << i << oendl; |
81 | * </pre> | 81 | * </pre> |
82 | * @see odbgstream | 82 | * @see odbgstream |
83 | */ | 83 | */ |
84 | 84 | ||
85 | /*====================================================================================== | 85 | /*====================================================================================== |
86 | * odbgstream | 86 | * odbgstream |
87 | *======================================================================================*/ | 87 | *======================================================================================*/ |
88 | 88 | ||
89 | class odbgstream | 89 | class odbgstream |
90 | { | 90 | { |
91 | public: | 91 | public: |
92 | /** | 92 | /** |
93 | * @internal | 93 | * @internal |
94 | */ | 94 | */ |
95 | odbgstream(unsigned int _area, unsigned int _level, bool _print = true); | 95 | odbgstream(unsigned int _area, unsigned int _level, bool _print = true); |
96 | odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true); | 96 | odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true); |
97 | odbgstream(odbgstream &str); | 97 | odbgstream(odbgstream &str); |
98 | odbgstream(const odbgstream &str); | 98 | odbgstream(const odbgstream &str); |
99 | virtual ~odbgstream(); | 99 | virtual ~odbgstream(); |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Prints the given value. | 102 | * Prints the given value. |
103 | * @param i the boolean to print (as "true" or "false") | 103 | * @param i the boolean to print (as "true" or "false") |
104 | * @return this stream | 104 | * @return this stream |
105 | */ | 105 | */ |
106 | odbgstream &operator<<(bool i); | 106 | odbgstream &operator<<(bool i); |
107 | /** | 107 | /** |
108 | * Prints the given value. | 108 | * Prints the given value. |
109 | * @param i the short to print | 109 | * @param i the short to print |
110 | * @return this stream | 110 | * @return this stream |
111 | */ | 111 | */ |
112 | odbgstream &operator<<(short i); | 112 | odbgstream &operator<<(short i); |
113 | /** | 113 | /** |
114 | * Prints the given value. | 114 | * Prints the given value. |
115 | * @param i the unsigned short to print | 115 | * @param i the unsigned short to print |
116 | * @return this stream | 116 | * @return this stream |
117 | */ | 117 | */ |
118 | odbgstream &operator<<(unsigned short i); | 118 | odbgstream &operator<<(unsigned short i); |
119 | /** | 119 | /** |
120 | * Prints the given value. | 120 | * Prints the given value. |
121 | * @param i the char to print | 121 | * @param i the char to print |
122 | * @return this stream | 122 | * @return this stream |
123 | */ | 123 | */ |
124 | odbgstream &operator<<(char i); | 124 | odbgstream &operator<<(char i); |
125 | /** | 125 | /** |
126 | * Prints the given value. | 126 | * Prints the given value. |
127 | * @param i the unsigned char to print | 127 | * @param i the unsigned char to print |
128 | * @return this stream | 128 | * @return this stream |
129 | */ | 129 | */ |
130 | odbgstream &operator<<(unsigned char i); | 130 | odbgstream &operator<<(unsigned char i); |
131 | /** | 131 | /** |
132 | * Prints the given value. | 132 | * Prints the given value. |
133 | * @param i the int to print | 133 | * @param i the int to print |
134 | * @return this stream | 134 | * @return this stream |
135 | */ | 135 | */ |
136 | odbgstream &operator<<(int i); | 136 | odbgstream &operator<<(int i); |
137 | /** | 137 | /** |
138 | * Prints the given value. | 138 | * Prints the given value. |
139 | * @param i the unsigned int to print | 139 | * @param i the unsigned int to print |
140 | * @return this stream | 140 | * @return this stream |
141 | */ | 141 | */ |
142 | odbgstream &operator<<(unsigned int i); | 142 | odbgstream &operator<<(unsigned int i); |
143 | /** | 143 | /** |
144 | * Prints the given value. | 144 | * Prints the given value. |
145 | * @param i the long to print | 145 | * @param i the long to print |
146 | * @return this stream | 146 | * @return this stream |
147 | */ | 147 | */ |
148 | odbgstream &operator<<(long i); | 148 | odbgstream &operator<<(long i); |
149 | /** | 149 | /** |
150 | * Prints the given value. | 150 | * Prints the given value. |
151 | * @param i the unsigned long to print | 151 | * @param i the unsigned long to print |
152 | * @return this stream | 152 | * @return this stream |
153 | */ | 153 | */ |
154 | odbgstream &operator<<(unsigned long i); | 154 | odbgstream &operator<<(unsigned long i); |
155 | /** | 155 | /** |
156 | * Flushes the output. | 156 | * Flushes the output. |
157 | */ | 157 | */ |
158 | virtual void flush(); | 158 | virtual void flush(); |
159 | /** | 159 | /** |
160 | * Prints the given value. | 160 | * Prints the given value. |
161 | * @param string the string to print | 161 | * @param string the string to print |
162 | * @return this stream | 162 | * @return this stream |
163 | */ | 163 | */ |
164 | odbgstream &operator<<(const QString& string); | 164 | odbgstream &operator<<(const QString& string); |
165 | /** | 165 | /** |
166 | * Prints the given value. | 166 | * Prints the given value. |
167 | * @param string the string to print | 167 | * @param string the string to print |
168 | * @return this stream | 168 | * @return this stream |
169 | */ | 169 | */ |
170 | odbgstream &operator<<(const char *string); | 170 | odbgstream &operator<<(const char *string); |
171 | /** | 171 | /** |
172 | * Prints the given value. | 172 | * Prints the given value. |
173 | * @param string the string to print | 173 | * @param string the string to print |
174 | * @return this stream | 174 | * @return this stream |
175 | */ | 175 | */ |
176 | odbgstream &operator<<(const QCString& string); | 176 | odbgstream &operator<<(const QCString& string); |
177 | /** | 177 | /** |
178 | * Prints the given value. | 178 | * Prints the given value. |
179 | * @param p a pointer to print (in number form) | 179 | * @param p a pointer to print (in number form) |
180 | * @return this stream | 180 | * @return this stream |
181 | */ | 181 | */ |
182 | odbgstream& operator<<(const void * p); | 182 | odbgstream& operator<<(const void * p); |
183 | /** | 183 | /** |
184 | * Prints the given value. | 184 | * Prints the given value. |
185 | * @param d the double to print | 185 | * @param d the double to print |
186 | * @return this stream | 186 | * @return this stream |
187 | */ | 187 | */ |
188 | odbgstream& operator<<(double d); | 188 | odbgstream& operator<<(double d); |
189 | /** | 189 | /** |
190 | * Prints the string @p format which can contain | 190 | * Prints the string @p format which can contain |
191 | * printf-style formatted values. | 191 | * printf-style formatted values. |
192 | * @param format the printf-style format | 192 | * @param format the printf-style format |
193 | * @return this stream | 193 | * @return this stream |
194 | */ | 194 | */ |
195 | odbgstream &form(const char *format, ...); | 195 | odbgstream &form(const char *format, ...); |
196 | /** Operator to print out basic information about a QWidget. | 196 | /** Operator to print out basic information about a QWidget. |
197 | * Output of class names only works if the class is moc'ified. | 197 | * Output of class names only works if the class is moc'ified. |
198 | * @param widget the widget to print | 198 | * @param widget the widget to print |
199 | * @return this stream | 199 | * @return this stream |
200 | */ | 200 | */ |
201 | odbgstream& operator<< (QWidget* widget); | 201 | odbgstream& operator<< (QWidget* widget); |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * Prints the given value. | 204 | * Prints the given value. |
205 | * @param dateTime the datetime to print | 205 | * @param dateTime the datetime to print |
206 | * @return this stream | 206 | * @return this stream |
207 | */ | 207 | */ |
208 | odbgstream& operator<< ( const QDateTime& dateTime ); | 208 | odbgstream& operator<< ( const QDateTime& dateTime ); |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * Prints the given value. | 211 | * Prints the given value. |
212 | * @param date the date to print | 212 | * @param date the date to print |
213 | * @return this stream | 213 | * @return this stream |
214 | */ | 214 | */ |
215 | odbgstream& operator<< ( const QDate& date ); | 215 | odbgstream& operator<< ( const QDate& date ); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * Prints the given value. | 218 | * Prints the given value. |
219 | * @param time the time to print | 219 | * @param time the time to print |
220 | * @return this stream | 220 | * @return this stream |
221 | */ | 221 | */ |
222 | odbgstream& operator<< ( const QTime& time ); | 222 | odbgstream& operator<< ( const QTime& time ); |
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Prints the given value. | 225 | * Prints the given value. |
226 | * @param point the point to print | 226 | * @param point the point to print |
227 | * @return this stream | 227 | * @return this stream |
228 | */ | 228 | */ |
229 | odbgstream& operator<< ( const QPoint& point ); | 229 | odbgstream& operator<< ( const QPoint& point ); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Prints the given value. | 232 | * Prints the given value. |
233 | * @param size the QSize to print | 233 | * @param size the QSize to print |
234 | * @return this stream | 234 | * @return this stream |
235 | */ | 235 | */ |
236 | odbgstream& operator<< ( const QSize& size ); | 236 | odbgstream& operator<< ( const QSize& size ); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * Prints the given value. | 239 | * Prints the given value. |
240 | * @param rect the QRect to print | 240 | * @param rect the QRect to print |
241 | * @return this stream | 241 | * @return this stream |
242 | */ | 242 | */ |
243 | odbgstream& operator<< ( const QRect& rect); | 243 | odbgstream& operator<< ( const QRect& rect); |
244 | 244 | ||
245 | /** | 245 | /** |
246 | * Prints the given value. | 246 | * Prints the given value. |
247 | * @param region the QRegion to print | 247 | * @param region the QRegion to print |
248 | * @return this stream | 248 | * @return this stream |
249 | */ | 249 | */ |
250 | odbgstream& operator<< ( const QRegion& region); | 250 | odbgstream& operator<< ( const QRegion& region); |
251 | 251 | ||
252 | /** | 252 | /** |
253 | * Prints the given value. | 253 | * Prints the given value. |
254 | * @param list the stringlist to print | 254 | * @param list the stringlist to print |
255 | * @return this stream | 255 | * @return this stream |
256 | */ | 256 | */ |
257 | odbgstream& operator<< ( const QStringList& list); | 257 | odbgstream& operator<< ( const QStringList& list); |
258 | 258 | ||
259 | /** | 259 | /** |
260 | * Prints the given value. | 260 | * Prints the given value. |
261 | * @param color the color to print | 261 | * @param color the color to print |
262 | * @return this stream | 262 | * @return this stream |
263 | */ | 263 | */ |
264 | odbgstream& operator<< ( const QColor& color); | 264 | odbgstream& operator<< ( const QColor& color); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | * Prints the given value. | 267 | * Prints the given value. |
268 | * @param brush the brush to print | 268 | * @param brush the brush to print |
269 | * @return this stream | 269 | * @return this stream |
270 | */ | 270 | */ |
271 | odbgstream& operator<< ( const QBrush& brush ); | 271 | odbgstream& operator<< ( const QBrush& brush ); |
272 | 272 | ||
273 | private: | 273 | private: |
274 | QString output; | 274 | QString output; |
275 | unsigned int area, level; | 275 | unsigned int area, level; |
276 | bool print; | 276 | bool print; |
277 | odbgstreamprivate* d; | 277 | odbgstreamprivate* d; |
278 | }; | 278 | }; |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Prints an "\n". | 281 | * Prints an "\n". |
282 | * @param s the debug stream to write to | 282 | * @param s the debug stream to write to |
283 | * @return the debug stream (@p s) | 283 | * @return the debug stream (@p s) |
284 | */ | 284 | */ |
285 | inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; } | 285 | inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; } |
286 | /** | 286 | /** |
287 | * Flushes the stream. | 287 | * Flushes the stream. |
288 | * @param s the debug stream to write to | 288 | * @param s the debug stream to write to |
289 | * @return the debug stream (@p s) | 289 | * @return the debug stream (@p s) |
290 | */ | 290 | */ |
291 | inline odbgstream& flush( odbgstream &s) { s.flush(); return s; } | 291 | inline odbgstream& flush( odbgstream &s) { s.flush(); return s; } |
292 | 292 | ||
293 | odbgstream &perror( odbgstream &s); | 293 | odbgstream &perror( odbgstream &s); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | * ondbgstream is a dummy variant of @ref odbgstream. All functions do | 296 | * ondbgstream is a dummy variant of @ref odbgstream. All functions do |
297 | * nothing. | 297 | * nothing. |
298 | * @see ondDebug() | 298 | * @see ondDebug() |
299 | */ | 299 | */ |
300 | class ondbgstream { | 300 | class ondbgstream { |
301 | public: | 301 | public: |
302 | /// Empty constructor. | 302 | /// Empty constructor. |
303 | ondbgstream() {} | 303 | ondbgstream() {} |
304 | ~ondbgstream() {} | 304 | ~ondbgstream() {} |
305 | /** | 305 | /** |
306 | * Does nothing. | 306 | * Does nothing. |
307 | * @return this stream | 307 | * @return this stream |
308 | */ | 308 | */ |
309 | ondbgstream &operator<<(short int ) { return *this; } | 309 | ondbgstream &operator<<(short int ) { return *this; } |
310 | /** | 310 | /** |
311 | * Does nothing. | 311 | * Does nothing. |
312 | * @return this stream | 312 | * @return this stream |
313 | */ | 313 | */ |
314 | ondbgstream &operator<<(unsigned short int ) { return *this; } | 314 | ondbgstream &operator<<(unsigned short int ) { return *this; } |
315 | /** | 315 | /** |
316 | * Does nothing. | 316 | * Does nothing. |
317 | * @return this stream | 317 | * @return this stream |
318 | */ | 318 | */ |
319 | ondbgstream &operator<<(char ) { return *this; } | 319 | ondbgstream &operator<<(char ) { return *this; } |
320 | /** | 320 | /** |
321 | * Does nothing. | 321 | * Does nothing. |
322 | * @return this stream | 322 | * @return this stream |
323 | */ | 323 | */ |