]> git.lyx.org Git - features.git/blobdiff - src/support/DebugStream.h
Replace LString.h with support/std_string.h,
[features.git] / src / support / DebugStream.h
index f20067da2b75d3b721a4a1b1ddf1a109d5c6cd19..b29039d02ca886cb89580f48230bc62fc4d40197 100644 (file)
@@ -1,41 +1,29 @@
 // -*- C++ -*-
-
-// Created by Lars Gullik Bjønnes
-// Copyright 1999 Lars Gullik Bjønnes (larsbj@lyx.org)
-// Released into the public domain.
-
-// Implemented and tested on g++ 2.7.2.3
-
-// Primarily developed for use in the LyX Project http://www.lyx.org/
-// but should be adaptable to any project.
+/**
+ * \file DebugStream.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
 #ifndef DEBUGSTREAM_H
 #define DEBUGSTREAM_H
 
-#include <iostream>
-
-using std::ostream;
+#include "std_ostream.h"
 
 #ifdef TEST_DEBUGSTREAM
 #include <string>
 struct Debug {
-       ///
        enum type {
-               ///
                NONE = 0,
-               ///
                INFO       = (1 << 0),   // 1
-               ///
                WARN       = (1 << 1),   // 2
-               ///
                CRIT       = (1 << 2)   // 4
        };
-       ///
        static const type ANY = type(INFO | WARN | CRIT);
-
-       /** A function to convert symbolic string names on debug levels
-           to their numerical value.
-       */
        static Debug::type value(string const & val) {
                if (val == "NONE") return Debug::NONE;
                if (val == "INFO") return Debug::INFO;
@@ -43,13 +31,12 @@ struct Debug {
                if (val == "CRIT") return Debug::CRIT;
                return Debug::NONE;
        }
-
 };
 #endif
 
-/** DebugStream is a ostream intended for debug output. It has also support
-    for a logfile. Debug output is output to cerr and if the logfile is set,
-    to the logfile.
+/** DebugStream is a ostream intended for debug output.
+    It has also support for a logfile. Debug output is output to cerr
+    and if the logfile is set, to the logfile.
 
     Example of Usage:
     DebugStream debug;
@@ -62,12 +49,12 @@ struct Debug {
     INFO
     Always
 
-    If you want to have debug output from time critical code you should 
+    If you want to have debug output from time critical code you should
     use this construct:
     if (debug.debugging(Debug::INFO)) {
-         debug << "...debug output...\n";
+        debug << "...debug output...\n";
     }
-    
+
     To give debug info even if no debug (NONE) is requested:
     debug << "... always output ...\n";
 
@@ -84,17 +71,19 @@ struct Debug {
     debug[Debug::type(Debug::INFO | Debug::CRIT)] << "...info/crit...\n";
 
 */
-class DebugStream : public ostream {
+class DebugStream : public std::ostream
+{
 public:
        /// Constructor, sets the debug level to t.
        explicit DebugStream(Debug::type t = Debug::NONE);
-       
+
        /// Constructor, sets the log file to f, and the debug level to t.
+       explicit
        DebugStream(char const * f, Debug::type t = Debug::NONE);
 
        ///
-       virtual ~DebugStream();
-       
+       ~DebugStream();
+
        /// Sets the debug level to t.
        void level(Debug::type t) {
                dt = Debug::type(t & Debug::ANY);
@@ -117,7 +106,7 @@ public:
 
        /// Sets the debugstreams' logfile to f.
        void logFile(char const * f);
-       
+
        /// Returns true if t is part of the current debug level.
        bool debugging(Debug::type t = Debug::ANY) const
        {
@@ -125,29 +114,31 @@ public:
                return false;
        }
 
-       
+
        /** Returns the no-op stream if t is not part of the
            current debug level otherwise the real debug stream
            is used.
        */
-       ostream & debug(Debug::type t = Debug::ANY) {
+       std::ostream & debug(Debug::type t = Debug::ANY) {
                if (dt & t) return *this;
                return nullstream;
        }
 
-       
+
        /** This is an operator to give a more convenient use:
            dbgstream[Debug::INFO] << "Info!\n";
        */
-       ostream & operator[](Debug::type t) {
+       std::ostream & operator[](Debug::type t) {
                return debug(t);
        }
 private:
        /// The current debug level
        Debug::type dt;
        /// The no-op stream.
-       ostream nullstream;
+       std::ostream nullstream;
+       ///
        struct debugstream_internal;
+       ///
        debugstream_internal * internal;
 };