[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: [RFC] kdebug patch
From:       Thomas Braxton <brax108 () cox ! net>
Date:       2005-09-01 19:44:53
Message-ID: 200509011444.53279.brax108 () cox ! net
[Download RAW message or body]

On Thursday 01 September 2005 01:06 pm, David Faure wrote:
> The latter is enough, since no application code has to use kndbgstream
> directly, so there's no need for detailed API docs there. But indeed a note
> in both classes would be useful to avoid the usual problem of forgetting to
> keep the other one in sync.
>
here's a patch you might want to check it, I'm not really sure if I worded it 
correctly.

> > 2) The implementation of operator<< for most classes should modify
> > d->output directly instead of calling operator<<(QString).
> > If you want I can get these changed right away, then I think I'll be done
> > with kdebug
>
> Interesting - sounds like a speedup, but also it would avoid the repeated
> area name in front of every newline in the printed string, AFAICS?
> Feel free to submit a patch for that (or to ask for a SVN account if you
> plan on doing more work on KDE ;)
I'm working on this now, should have a patch soon.

["kdebug_h_apidoc.patch" (text/x-diff)]

Index: kdecore/kdebug.h
===================================================================
--- kdecore/kdebug.h	(revision 455967)
+++ kdecore/kdebug.h	(working copy)
@@ -49,7 +49,9 @@
  * \addtogroup kdebug Debug message generators
  *  @{
  * KDE debug message streams let you and the user control just how many debug
- * messages you see.
+ * messages you see. Debug message printing is controlled by (un)defining
+ * NDEBUG when compiling your source. If NDEBUG is defined then no debug
+ * messages are printed.
  */
 
 typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function
@@ -63,26 +65,33 @@
 
 #define k_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
 
-class kdbgstreamprivate;
 /**
  * kdbgstream is a text stream that allows you to print debug messages.
  * Using the overloaded "<<" operator you can send messages. Usually
  * you do not create the kdbgstream yourself, but use kdDebug()
- * kdWarning(), kdError() or kdFatal to obtain one.
+ * kdWarning(), kdError() or kdFatal() to obtain one. 
  *
  * Example:
  * \code
  *    int i = 5;
  *    kdDebug() << "The value of i is " << i << endl;
  * \endcode
+ * @note
+ * The API of kndbgstream must be kept in sync with kdbgstream. This means:
+ *   - every member function must be copied in kndbgstream doing nothing.
+ *   - every function that operates on a kdbgstream must have a corresponding
+ *     function that operates on kndbgstream that does nothing.
  * @see kndbgstream
  */
 class KDECORE_EXPORT kdbgstream {
  public:
-  /**
-   * @internal
-   */
+    /**
+     * @internal
+     */
     kdbgstream(unsigned int _area, unsigned int _level, bool _print = true);
+    /**
+     * @internal
+     */
     kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true);
     /// Copy constructor
     kdbgstream(const kdbgstream &str);
@@ -378,7 +387,7 @@
 
 /**
  * \relates KGlobal
- * Prints an "\n".
+ * Prints a newline to the stream.
  * @param s the debug stream to write to
  * @return the debug stream (@p s)
  */
@@ -402,121 +411,43 @@
 KDECORE_EXPORT kdbgstream &perror( kdbgstream &s);
 
 /**
- * \relates KGlobal
- * kndbgstream is a dummy variant of kdbgstream. All functions do
- * nothing.
- * @see kndDebug()
+ * @internal
+ * kndbgstream is a dummy variant of kdbgstream, it is only here to allow
+ * compiling with/without debugging messages.
+ * All functions do nothing.
+ * @note
+ * The API of kndbgstream must be kept in sync with kdbgstream. This means:
+ *   - every member function must be copied from kdbgstream to do
+ *     nothing.
+ *   - every function that operates on a kdbgstream must have a corresponding
+ *     function that operates on kndbgstream that does nothing.
+ * @see kdbgstream
  */
 class KDECORE_EXPORT kndbgstream {
  public:
-    /// Default constructor.
     kndbgstream() {}
     ~kndbgstream() {}
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(short int )  { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(unsigned short int )  { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(char )  { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(unsigned char )  { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(int )  { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(unsigned int )  { return *this; }
-    /**
-     * Does nothing.
-     */
     void flush() {}
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(QChar)  { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(const QString& ) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(const QByteArray& ) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &operator<<(const char *) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(const void *) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(void *) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(double) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(long) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(unsigned long) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(qlonglong) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(qulonglong) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator<<(KNDBGFUNC) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream& operator << (const QWidget*) { return *this; }
-    /**
-     * Does nothing.
-     * @return this stream
-     */
     kndbgstream &form(const char *, ...) { return *this; }
-
     kndbgstream& operator<<( const QDateTime& ) { return *this; }
     kndbgstream& operator<<( const QDate&     ) { return *this; }
     kndbgstream& operator<<( const QTime&     ) { return *this; }
@@ -530,22 +461,11 @@
     kndbgstream& operator<<( const QPen & ) { return *this; }
     kndbgstream& operator<<( const QBrush & ) { return *this; }
     kndbgstream& operator<<( const QVariant & ) { return *this; }
-
     template <class T>
     kndbgstream& operator<<( const QList<T> & ) { return *this; }
 };
 
-/**
- * Does nothing.
- * @param s a stream
- * @return the given @p s
- */
 inline kndbgstream &endl( kndbgstream & s) { return s; }
-/**
- * Does nothing.
- * @param s a stream
- * @return the given @p s
- */
 inline kndbgstream &flush( kndbgstream & s) { return s; }
 inline kndbgstream &perror( kndbgstream & s) { return s; }
 
@@ -565,25 +485,16 @@
  * @param area an id to identify the output, 0 for default
  */
 KDECORE_EXPORT kdbgstream kdDebug(bool cond, int area = 0);
+
 /**
  * \relates KGlobal
  * Returns a backtrace.
- * @return a backtrace
- */
-//KDECORE_EXPORT QString kdBacktrace();
-/**
- * \relates KGlobal
- * Returns a backtrace.
  * @param levels the number of levels of the backtrace
  * @return a backtrace
  * @since 3.1
  */
 KDECORE_EXPORT QString kdBacktrace(int levels=-1);
-/**
- * Returns a dummy debug stream. The stream does not print anything.
- * @param area an id to identify the output, 0 for default
- * @see kdDebug()
- */
+
 inline kndbgstream kndDebug(int = 0) { return kndbgstream(); }
 inline kndbgstream kndDebug(bool , int  = 0) { return kndbgstream(); }
 inline QString kndBacktrace(int = -1) { return QString(); }


 =

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic