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

tdecore

kdebug.h
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
00003                   2000-2002 Stephan Kulow (coolo@kde.org)
00004                   2002 Holger Freyther (freyther@kde.org)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef _KDEBUG_H_
00023 #define _KDEBUG_H_
00024 
00025 #include <tqstring.h>
00026 #include "tdelibs_export.h"
00027 
00028 class TQWidget;
00029 class TQDateTime;
00030 class TQDate;
00031 class TQTime;
00032 class TQPoint;
00033 class TQSize;
00034 class TQRect;
00035 class TQRegion;
00036 class KURL;
00037 class TQStringList;
00038 class TQColor;
00039 class TQPen;
00040 class TQBrush;
00041 class TQVariant;
00042 template <class T>
00043 class TQValueList;
00044 
00045 class kdbgstream;
00046 class kndbgstream;
00047 
00055 typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function
00056 typedef kndbgstream & (*KNDBGFUNC)(kndbgstream &); // manipulator function
00057 
00058 #ifdef __GNUC__
00059 #define k_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
00060 #else
00061 #define k_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
00062 #endif
00063 
00064 #define k_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
00065 
00066 class kdbgstreamprivate;
00080 class TDECORE_EXPORT kdbgstream {
00081  public:
00085     kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) :
00086       area(_area), level(_level),  print(_print) { }
00087     kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true) :
00088       output(TQString::fromLatin1(initialString)), area(_area), level(_level),  print(_print) { }
00090     kdbgstream(kdbgstream &str);
00091     kdbgstream(const kdbgstream &str) :
00092       output(str.output), area(str.area), level(str.level), print(str.print) {}
00093     ~kdbgstream();
00099     kdbgstream& operator<<(bool i)  {
00100     if (!print) return *this;
00101     output += TQString::fromLatin1(i ? "true" : "false");
00102     return *this;
00103     }
00109     kdbgstream& operator<<(short i)  {
00110     if (!print) return *this;
00111     TQString tmp; tmp.setNum(i); output += tmp;
00112     return *this;
00113     }
00119     kdbgstream& operator<<(unsigned short i) {
00120         if (!print) return *this;
00121         TQString tmp; tmp.setNum(i); output += tmp;
00122         return *this;
00123     }
00129     kdbgstream& operator<<(char ch);
00135     kdbgstream& operator<<(unsigned char ch) {
00136         return operator<<( static_cast<char>( ch ) );
00137     }
00143     kdbgstream& operator<<(int i)  {
00144     if (!print) return *this;
00145     TQString tmp; tmp.setNum(i); output += tmp;
00146     return *this;
00147     }
00153     kdbgstream& operator<<(unsigned int i) {
00154         if (!print) return *this;
00155         TQString tmp; tmp.setNum(i); output += tmp;
00156         return *this;
00157     }
00163     kdbgstream& operator<<(long i) {
00164         if (!print) return *this;
00165         TQString tmp; tmp.setNum(i); output += tmp;
00166         return *this;
00167     }
00173     kdbgstream& operator<<(unsigned long i) {
00174         if (!print) return *this;
00175         TQString tmp; tmp.setNum(i); output += tmp;
00176         return *this;
00177     }
00183     kdbgstream& operator<<(TQ_LLONG i) {
00184         if (!print) return *this;
00185         TQString tmp; tmp.setNum(i); output += tmp;
00186         return *this;
00187     }
00193     kdbgstream& operator<<(TQ_ULLONG i) {
00194         if (!print) return *this;
00195         TQString tmp; tmp.setNum(i); output += tmp;
00196         return *this;
00197     }
00198 
00202     void flush(); //AB: maybe this should be virtual! would save some trouble for some 3rd party projects
00203 
00210     kdbgstream& operator<<(TQChar ch);
00216     kdbgstream& operator<<(const TQString& string) {
00217     if (!print) return *this;
00218     output += string;
00219     if (output.at(output.length() -1 ) == (TQChar)'\n')
00220         flush();
00221     return *this;
00222     }
00228     kdbgstream& operator<<(const char *string) {
00229     if (!print) return *this;
00230     output += TQString::fromUtf8(string);
00231     if (output.at(output.length() - 1) == (TQChar)'\n')
00232         flush();
00233     return *this;
00234     }
00240     kdbgstream& operator<<(const TQCString& string) {
00241         *this << string.data();
00242         return *this;
00243     }
00249     kdbgstream& operator<<(const void * p) {
00250         form("%p", p);
00251         return *this;
00252     }
00258     kdbgstream& operator<<(KDBGFUNC f) {
00259     if (!print) return *this;
00260     return (*f)(*this);
00261     }
00267     kdbgstream& operator<<(double d) {
00268       TQString tmp; tmp.setNum(d); output += tmp;
00269       return *this;
00270     }
00277     kdbgstream& form(const char *format, ...)
00278 #ifdef __GNUC__
00279       __attribute__ ( ( format ( printf, 2, 3 ) ) )
00280 #endif
00281      ;
00282 
00288     kdbgstream& operator<< (const TQWidget* widget);
00289     kdbgstream& operator<< (TQWidget* widget); // KDE4 merge
00290 
00296     kdbgstream& operator<< ( const TQDateTime& dateTime );
00297 
00303     kdbgstream& operator<< ( const TQDate& date );
00304 
00310     kdbgstream& operator<< ( const TQTime& time );
00311 
00317     kdbgstream& operator<< ( const TQPoint& point );
00318 
00324     kdbgstream& operator<< ( const TQSize& size );
00325 
00331     kdbgstream& operator<< ( const TQRect& rect);
00332 
00338     kdbgstream& operator<< ( const TQRegion& region);
00339 
00345     kdbgstream& operator<< ( const KURL& url );
00346 
00352     // ### KDE4: Remove in favor of template operator for TQValueList<T> below
00353     kdbgstream& operator<< ( const TQStringList& list);
00354 
00360     kdbgstream& operator<< ( const TQColor& color);
00361 
00368     kdbgstream& operator<< ( const TQPen& pen );
00369 
00375     kdbgstream& operator<< ( const TQBrush& brush );
00376 
00383     kdbgstream& operator<< ( const TQVariant& variant );
00384 
00391     kdbgstream& operator<< ( const TQByteArray& data );
00392 
00399     template <class T>
00400     kdbgstream& operator<< ( const TQValueList<T> &list );
00401 
00402  private:
00403     TQString output;
00404     unsigned int area, level;
00405     bool print;
00406     kdbgstreamprivate* d;
00407 };
00408 
00409 template <class T>
00410 kdbgstream& kdbgstream::operator<<( const TQValueList<T> &list )
00411 {
00412     *this << "(";
00413     typename TQValueList<T>::ConstIterator it = list.begin();
00414     if ( !list.isEmpty() ) {
00415       *this << *it++;
00416     }
00417     for ( ; it != list.end(); ++it ) {
00418       *this << "," << *it;
00419     }
00420     *this << ")";
00421     return *this;
00422 }
00423 
00430 inline kdbgstream& endl( kdbgstream &s) { s << "\n"; return s; }
00431 
00438 inline kdbgstream& flush( kdbgstream &s) { s.flush(); return s; }
00439 
00440 TDECORE_EXPORT kdbgstream& perror( kdbgstream &s);
00441 
00448 class TDECORE_EXPORT kndbgstream {
00449  public:
00451     kndbgstream() {}
00452     ~kndbgstream() {}
00457     kndbgstream& operator<<(short int )  { return *this; }
00462     kndbgstream& operator<<(unsigned short int )  { return *this; }
00467     kndbgstream& operator<<(char )  { return *this; }
00472     kndbgstream& operator<<(unsigned char )  { return *this; }
00477     kndbgstream& operator<<(int )  { return *this; }
00482     kndbgstream& operator<<(unsigned int )  { return *this; }
00486     void flush() {}
00491     kndbgstream& operator<<(TQChar)  { return *this; }
00496     kndbgstream& operator<<(const TQString& ) { return *this; }
00501     kndbgstream& operator<<(const TQCString& ) { return *this; }
00506     kndbgstream& operator<<(const char *) { return *this; }
00511     kndbgstream& operator<<(const void *) { return *this; }
00516     kndbgstream& operator<<(void *) { return *this; }
00521     kndbgstream& operator<<(double) { return *this; }
00526     kndbgstream& operator<<(long) { return *this; }
00531     kndbgstream& operator<<(unsigned long) { return *this; }
00536     kndbgstream& operator<<(TQ_LLONG) { return *this; }
00541     kndbgstream& operator<<(TQ_ULLONG) { return *this; }
00546     kndbgstream& operator<<(KNDBGFUNC) { return *this; }
00551     kndbgstream& operator<< (const TQWidget*) { return *this; }
00552     kndbgstream& operator<< (TQWidget*) { return *this; } // KDE4 merge
00557     kndbgstream& form(const char *, ...) { return *this; }
00558 
00559     kndbgstream& operator<<( const TQDateTime& ) { return *this; }
00560     kndbgstream& operator<<( const TQDate&     ) { return *this; }
00561     kndbgstream& operator<<( const TQTime&     ) { return *this; }
00562     kndbgstream& operator<<( const TQPoint & )  { return *this; }
00563     kndbgstream& operator<<( const TQSize & )  { return *this; }
00564     kndbgstream& operator<<( const TQRect & )  { return *this; }
00565     kndbgstream& operator<<( const TQRegion & ) { return *this; }
00566     kndbgstream& operator<<( const KURL & )  { return *this; }
00567     kndbgstream& operator<<( const TQStringList & ) { return *this; }
00568     kndbgstream& operator<<( const TQColor & ) { return *this; }
00569     kndbgstream& operator<<( const TQPen & ) { return *this; }
00570     kndbgstream& operator<<( const TQBrush & ) { return *this; }
00571     kndbgstream& operator<<( const TQVariant & ) { return *this; }
00572     kndbgstream& operator<<( const TQByteArray & ) { return *this; }
00573 
00574     template <class T>
00575     kndbgstream& operator<<( const TQValueList<T> & ) { return *this; }
00576 };
00577 
00583 inline kndbgstream& endl( kndbgstream & s) { return s; }
00589 inline kndbgstream& flush( kndbgstream & s) { return s; }
00590 inline kndbgstream& perror( kndbgstream & s) { return s; }
00591 
00599 TDECORE_EXPORT kdbgstream kdDebug(int area = 0);
00600 TDECORE_EXPORT kdbgstream kdDebug(bool cond, int area = 0);
00608 TDECORE_EXPORT TQString kdBacktrace(int levels=-1);
00618 TDECORE_EXPORT void kdBacktraceFD(int fd=2);
00624 inline kndbgstream kndDebug(int area = 0) { Q_UNUSED(area); return kndbgstream(); }
00625 inline kndbgstream kndDebug(bool , int  = 0) { return kndbgstream(); }
00632 TDECORE_EXPORT kdbgstream kdWarning(int area = 0);
00633 TDECORE_EXPORT kdbgstream kdWarning(bool cond, int area = 0);
00640 TDECORE_EXPORT kdbgstream kdError(int area = 0);
00641 TDECORE_EXPORT kdbgstream kdError(bool cond, int area = 0);
00648 TDECORE_EXPORT kdbgstream kdFatal(int area = 0);
00649 TDECORE_EXPORT kdbgstream kdFatal(bool cond, int area = 0);
00650 
00656 TDECORE_EXPORT void kdClearDebugConfig();
00657 
00660 #ifdef NDEBUG
00661 #define kdDebug kndDebug
00662 #endif
00663 
00664 #endif
00665 

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
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.