• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
kdebug.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
3  2000-2002 Stephan Kulow (coolo@kde.org)
4  2002 Holger Freyther (freyther@kde.org)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef _KDEBUG_H_
23 #define _KDEBUG_H_
24 
25 #include <tqstring.h>
26 #include "tdelibs_export.h"
27 
28 class TQWidget;
29 class TQDateTime;
30 class TQDate;
31 class TQTime;
32 class TQPoint;
33 class TQSize;
34 class TQRect;
35 class TQRegion;
36 class KURL;
37 class TQStringList;
38 class TQColor;
39 class TQPen;
40 class TQBrush;
41 class TQVariant;
42 template <class T>
43 class TQValueList;
44 
45 class kdbgstream;
46 class kndbgstream;
47 
55 typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function
56 typedef kndbgstream & (*KNDBGFUNC)(kndbgstream &); // manipulator function
57 
58 #ifdef __GNUC__
59 #define k_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
60 #else
61 #define k_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
62 #endif
63 
64 #define k_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
65 
66 class kdbgstreamprivate;
80 class TDECORE_EXPORT kdbgstream {
81  public:
85  kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) :
86  area(_area), level(_level), print(_print) { }
87  kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true) :
88  output(TQString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { }
90  kdbgstream(kdbgstream &str);
91  kdbgstream(const kdbgstream &str) :
92  output(str.output), area(str.area), level(str.level), print(str.print) {}
93  ~kdbgstream();
99  kdbgstream& operator<<(bool i) {
100  if (!print) return *this;
101  output += TQString::fromLatin1(i ? "true" : "false");
102  return *this;
103  }
109  kdbgstream& operator<<(short i) {
110  if (!print) return *this;
111  TQString tmp; tmp.setNum(i); output += tmp;
112  return *this;
113  }
119  kdbgstream& operator<<(unsigned short i) {
120  if (!print) return *this;
121  TQString tmp; tmp.setNum(i); output += tmp;
122  return *this;
123  }
129  kdbgstream& operator<<(char ch);
135  kdbgstream& operator<<(unsigned char ch) {
136  return operator<<( static_cast<char>( ch ) );
137  }
143  kdbgstream& operator<<(int i) {
144  if (!print) return *this;
145  TQString tmp; tmp.setNum(i); output += tmp;
146  return *this;
147  }
153  kdbgstream& operator<<(unsigned int i) {
154  if (!print) return *this;
155  TQString tmp; tmp.setNum(i); output += tmp;
156  return *this;
157  }
163  kdbgstream& operator<<(long i) {
164  if (!print) return *this;
165  TQString tmp; tmp.setNum(i); output += tmp;
166  return *this;
167  }
173  kdbgstream& operator<<(unsigned long i) {
174  if (!print) return *this;
175  TQString tmp; tmp.setNum(i); output += tmp;
176  return *this;
177  }
183  kdbgstream& operator<<(TQ_LLONG i) {
184  if (!print) return *this;
185  TQString tmp; tmp.setNum(i); output += tmp;
186  return *this;
187  }
193  kdbgstream& operator<<(TQ_ULLONG i) {
194  if (!print) return *this;
195  TQString tmp; tmp.setNum(i); output += tmp;
196  return *this;
197  }
198 
202  void flush(); //AB: maybe this should be virtual! would save some trouble for some 3rd party projects
203 
210  kdbgstream& operator<<(TQChar ch);
216  kdbgstream& operator<<(const TQString& string) {
217  if (!print) return *this;
218  output += string;
219  if (output.at(output.length() -1 ) == (TQChar)'\n')
220  flush();
221  return *this;
222  }
228  kdbgstream& operator<<(const char *string) {
229  if (!print) return *this;
230  output += TQString::fromUtf8(string);
231  if (output.at(output.length() - 1) == (TQChar)'\n')
232  flush();
233  return *this;
234  }
240  kdbgstream& operator<<(const TQCString& string) {
241  *this << string.data();
242  return *this;
243  }
249  kdbgstream& operator<<(const void * p) {
250  form("%p", p);
251  return *this;
252  }
258  kdbgstream& operator<<(KDBGFUNC f) {
259  if (!print) return *this;
260  return (*f)(*this);
261  }
267  kdbgstream& operator<<(double d) {
268  TQString tmp; tmp.setNum(d); output += tmp;
269  return *this;
270  }
277  kdbgstream& form(const char *format, ...)
278 #ifdef __GNUC__
279  __attribute__ ( ( format ( printf, 2, 3 ) ) )
280 #endif
281  ;
282 
288  kdbgstream& operator<< (const TQWidget* widget);
289  kdbgstream& operator<< (TQWidget* widget); // KDE4 merge
290 
296  kdbgstream& operator<< ( const TQDateTime& dateTime );
297 
303  kdbgstream& operator<< ( const TQDate& date );
304 
310  kdbgstream& operator<< ( const TQTime& time );
311 
317  kdbgstream& operator<< ( const TQPoint& point );
318 
324  kdbgstream& operator<< ( const TQSize& size );
325 
331  kdbgstream& operator<< ( const TQRect& rect);
332 
338  kdbgstream& operator<< ( const TQRegion& region);
339 
345  kdbgstream& operator<< ( const KURL& url );
346 
352  // ### KDE4: Remove in favor of template operator for TQValueList<T> below
353  kdbgstream& operator<< ( const TQStringList& list);
354 
360  kdbgstream& operator<< ( const TQColor& color);
361 
368  kdbgstream& operator<< ( const TQPen& pen );
369 
375  kdbgstream& operator<< ( const TQBrush& brush );
376 
383  kdbgstream& operator<< ( const TQVariant& variant );
384 
391  kdbgstream& operator<< ( const TQByteArray& data );
392 
399  template <class T>
400  kdbgstream& operator<< ( const TQValueList<T> &list );
401 
402  private:
403  TQString output;
404  unsigned int area, level;
405  bool print;
406  kdbgstreamprivate* d;
407 };
408 
409 template <class T>
410 kdbgstream& kdbgstream::operator<<( const TQValueList<T> &list )
411 {
412  *this << "(";
413  typename TQValueList<T>::ConstIterator it = list.begin();
414  if ( !list.isEmpty() ) {
415  *this << *it++;
416  }
417  for ( ; it != list.end(); ++it ) {
418  *this << "," << *it;
419  }
420  *this << ")";
421  return *this;
422 }
423 
430 inline kdbgstream& endl( kdbgstream &s) { s << "\n"; return s; }
431 
438 inline kdbgstream& flush( kdbgstream &s) { s.flush(); return s; }
439 
440 TDECORE_EXPORT kdbgstream& perror( kdbgstream &s);
441 
448 class TDECORE_EXPORT kndbgstream {
449  public:
451  kndbgstream() {}
452  ~kndbgstream() {}
457  kndbgstream& operator<<(short int ) { return *this; }
462  kndbgstream& operator<<(unsigned short int ) { return *this; }
467  kndbgstream& operator<<(char ) { return *this; }
472  kndbgstream& operator<<(unsigned char ) { return *this; }
477  kndbgstream& operator<<(int ) { return *this; }
482  kndbgstream& operator<<(unsigned int ) { return *this; }
486  void flush() {}
491  kndbgstream& operator<<(TQChar) { return *this; }
496  kndbgstream& operator<<(const TQString& ) { return *this; }
501  kndbgstream& operator<<(const TQCString& ) { return *this; }
506  kndbgstream& operator<<(const char *) { return *this; }
511  kndbgstream& operator<<(const void *) { return *this; }
516  kndbgstream& operator<<(void *) { return *this; }
521  kndbgstream& operator<<(double) { return *this; }
526  kndbgstream& operator<<(long) { return *this; }
531  kndbgstream& operator<<(unsigned long) { return *this; }
536  kndbgstream& operator<<(TQ_LLONG) { return *this; }
541  kndbgstream& operator<<(TQ_ULLONG) { return *this; }
546  kndbgstream& operator<<(KNDBGFUNC) { return *this; }
551  kndbgstream& operator<< (const TQWidget*) { return *this; }
552  kndbgstream& operator<< (TQWidget*) { return *this; } // KDE4 merge
557  kndbgstream& form(const char *, ...) { return *this; }
558 
559  kndbgstream& operator<<( const TQDateTime& ) { return *this; }
560  kndbgstream& operator<<( const TQDate& ) { return *this; }
561  kndbgstream& operator<<( const TQTime& ) { return *this; }
562  kndbgstream& operator<<( const TQPoint & ) { return *this; }
563  kndbgstream& operator<<( const TQSize & ) { return *this; }
564  kndbgstream& operator<<( const TQRect & ) { return *this; }
565  kndbgstream& operator<<( const TQRegion & ) { return *this; }
566  kndbgstream& operator<<( const KURL & ) { return *this; }
567  kndbgstream& operator<<( const TQStringList & ) { return *this; }
568  kndbgstream& operator<<( const TQColor & ) { return *this; }
569  kndbgstream& operator<<( const TQPen & ) { return *this; }
570  kndbgstream& operator<<( const TQBrush & ) { return *this; }
571  kndbgstream& operator<<( const TQVariant & ) { return *this; }
572  kndbgstream& operator<<( const TQByteArray & ) { return *this; }
573 
574  template <class T>
575  kndbgstream& operator<<( const TQValueList<T> & ) { return *this; }
576 };
577 
583 inline kndbgstream& endl( kndbgstream & s) { return s; }
589 inline kndbgstream& flush( kndbgstream & s) { return s; }
590 inline kndbgstream& perror( kndbgstream & s) { return s; }
591 
599 TDECORE_EXPORT kdbgstream kdDebug(int area = 0);
600 TDECORE_EXPORT kdbgstream kdDebug(bool cond, int area = 0);
608 TDECORE_EXPORT TQString kdBacktrace(int levels=-1);
618 TDECORE_EXPORT void kdBacktraceFD(int fd=2);
624 inline kndbgstream kndDebug(int area = 0) { Q_UNUSED(area); return kndbgstream(); }
625 inline kndbgstream kndDebug(bool , int = 0) { return kndbgstream(); }
632 TDECORE_EXPORT kdbgstream kdWarning(int area = 0);
633 TDECORE_EXPORT kdbgstream kdWarning(bool cond, int area = 0);
640 TDECORE_EXPORT kdbgstream kdError(int area = 0);
641 TDECORE_EXPORT kdbgstream kdError(bool cond, int area = 0);
648 TDECORE_EXPORT kdbgstream kdFatal(int area = 0);
649 TDECORE_EXPORT kdbgstream kdFatal(bool cond, int area = 0);
650 
656 TDECORE_EXPORT void kdClearDebugConfig();
657 
660 #ifdef NDEBUG
661 #define kdDebug kndDebug
662 #endif
663 
664 #endif
665 
kdbgstream::operator<<
kdbgstream & operator<<(KDBGFUNC f)
Invokes the given function.
Definition: kdebug.h:258
KURL
Represents and parses a URL.
Definition: kurl.h:127
TDEGlobal::kdBacktrace
TQString kdBacktrace(int levels=-1)
Definition: kdebug.cpp:797
kndbgstream::operator<<
kndbgstream & operator<<(TQChar)
Does nothing.
Definition: kdebug.h:491
kdbgstream::operator<<
kdbgstream & operator<<(const void *p)
Prints the given value.
Definition: kdebug.h:249
flush
kndbgstream & flush(kndbgstream &s)
Does nothing.
Definition: kdebug.h:589
kndbgstream::operator<<
kndbgstream & operator<<(int)
Does nothing.
Definition: kdebug.h:477
kdbgstream::operator<<
kdbgstream & operator<<(unsigned short i)
Prints the given value.
Definition: kdebug.h:119
kdbgstream::flush
void flush()
Flushes the output.
Definition: kdebug.cpp:385
kdbgstream::operator<<
kdbgstream & operator<<(TQ_ULLONG i)
Prints the given value.
Definition: kdebug.h:193
TDEGlobal::kdError
kdbgstream kdError(int area=0)
Definition: kdebug.cpp:372
kdbgstream::operator<<
kdbgstream & operator<<(unsigned long i)
Prints the given value.
Definition: kdebug.h:173
kndDebug
kndbgstream kndDebug(int area=0)
Returns a dummy debug stream.
Definition: kdebug.h:624
kdbgstream
kdbgstream is a text stream that allows you to print debug messages.
Definition: kdebug.h:80
kndbgstream::operator<<
kndbgstream & operator<<(const void *)
Does nothing.
Definition: kdebug.h:511
kndbgstream::operator<<
kndbgstream & operator<<(unsigned int)
Does nothing.
Definition: kdebug.h:482
TDEGlobal::kdDebug
kdbgstream kdDebug(int area=0)
Definition: kdebug.cpp:369
kndbgstream::operator<<
kndbgstream & operator<<(unsigned long)
Does nothing.
Definition: kdebug.h:531
kndbgstream::operator<<
kndbgstream & operator<<(unsigned short int)
Does nothing.
Definition: kdebug.h:462
kndbgstream::operator<<
kndbgstream & operator<<(KNDBGFUNC)
Does nothing.
Definition: kdebug.h:546
kndbgstream::form
kndbgstream & form(const char *,...)
Does nothing.
Definition: kdebug.h:557
kdbgstream::operator<<
kdbgstream & operator<<(double d)
Prints the given value.
Definition: kdebug.h:267
kndbgstream::operator<<
kndbgstream & operator<<(long)
Does nothing.
Definition: kdebug.h:526
kndbgstream::operator<<
kndbgstream & operator<<(TQ_ULLONG)
Does nothing.
Definition: kdebug.h:541
TDEGlobal::flush
kdbgstream & flush(kdbgstream &s)
Definition: kdebug.h:438
kndbgstream::operator<<
kndbgstream & operator<<(char)
Does nothing.
Definition: kdebug.h:467
kndbgstream::operator<<
kndbgstream & operator<<(double)
Does nothing.
Definition: kdebug.h:521
TDEGlobal::kdWarning
kdbgstream kdWarning(int area=0)
Definition: kdebug.cpp:374
kdbgstream::operator<<
kdbgstream & operator<<(const TQString &string)
Prints the given value.
Definition: kdebug.h:216
kdbgstream::operator<<
kdbgstream & operator<<(short i)
Prints the given value.
Definition: kdebug.h:109
kndbgstream::operator<<
kndbgstream & operator<<(const TQCString &)
Does nothing.
Definition: kdebug.h:501
kdbgstream::operator<<
kdbgstream & operator<<(const char *string)
Prints the given value.
Definition: kdebug.h:228
kdbgstream::operator<<
kdbgstream & operator<<(TQ_LLONG i)
Prints the given value.
Definition: kdebug.h:183
kdbgstream::operator<<
kdbgstream & operator<<(long i)
Prints the given value.
Definition: kdebug.h:163
TDEGlobal::kdBacktraceFD
void kdBacktraceFD(int fd=2)
Definition: kdebug.cpp:838
kdbgstream::operator<<
kdbgstream & operator<<(const TQCString &string)
Prints the given value.
Definition: kdebug.h:240
kdbgstream::operator<<
kdbgstream & operator<<(int i)
Prints the given value.
Definition: kdebug.h:143
kndbgstream::operator<<
kndbgstream & operator<<(unsigned char)
Does nothing.
Definition: kdebug.h:472
kdbgstream::operator<<
kdbgstream & operator<<(unsigned char ch)
Prints the given value.
Definition: kdebug.h:135
kdbgstream::operator<<
kdbgstream & operator<<(unsigned int i)
Prints the given value.
Definition: kdebug.h:153
kndbgstream::operator<<
kndbgstream & operator<<(short int)
Does nothing.
Definition: kdebug.h:457
TDEGlobal::kdFatal
kdbgstream kdFatal(int area=0)
Definition: kdebug.cpp:376
kndbgstream::operator<<
kndbgstream & operator<<(TQ_LLONG)
Does nothing.
Definition: kdebug.h:536
kndbgstream::kndbgstream
kndbgstream()
Default constructor.
Definition: kdebug.h:451
kndbgstream::flush
void flush()
Does nothing.
Definition: kdebug.h:486
TDEGlobal::kdClearDebugConfig
void kdClearDebugConfig()
Definition: kdebug.cpp:849
kndbgstream
Definition: kdebug.h:448
kndbgstream::operator<<
kndbgstream & operator<<(const TQString &)
Does nothing.
Definition: kdebug.h:496
kdbgstream::operator<<
kdbgstream & operator<<(bool i)
Prints the given value.
Definition: kdebug.h:99
kndbgstream::operator<<
kndbgstream & operator<<(void *)
Does nothing.
Definition: kdebug.h:516
TDEGlobal::endl
kdbgstream & endl(kdbgstream &s)
Definition: kdebug.h:430
kndbgstream::operator<<
kndbgstream & operator<<(const char *)
Does nothing.
Definition: kdebug.h:506

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.