// Created by Lars Gullik Bjønnes
// Copyright 1999 Lars Gullik Bjønnes (larsbj@lyx.org)
-// Released under the Gnu General Public License
+// Released into the public domain.
// Implemented and tested on g++ 2.7.2.3
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include "LOstream.h"
#ifdef TEST_DEBUGSTREAM
#include <string>
+///
struct Debug {
///
enum type {
/** A function to convert symbolic string names on debug levels
to their numerical value.
*/
- static Debug::type value(std::string const & val) {
+ static Debug::type value(string const & val) {
if (val == "NONE") return Debug::NONE;
if (val == "INFO") return Debug::INFO;
if (val == "WARN") return Debug::WARN;
};
#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;
debug[Debug::type(Debug::INFO | Debug::CRIT)] << "...info/crit...\n";
*/
-class DebugStream : public ostream {
+
+// This workaround is needed only for gcc 2.8.1 (and possibly egcs
+// 1.0.x), which generates a compiler error when subclassing from
+// std::. (JMarc)
+#ifdef CXX_WORKING_NAMESPACES
+///
+class DebugStream : public std::ostream
+#else
+///
+class DebugStream : public ostream
+#endif
+{
public:
/// Constructor, sets the debug level to t.
- DebugStream(Debug::type t = Debug::NONE);
+ 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);
///
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;
};
#endif
+
+