summaryrefslogtreecommitdiff
path: root/flower/dstream.hh
blob: 72d0897201a5210fc63aec7700b9c22161add756 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// debug_stream

#ifndef DSTREAM_HH
#define DSTREAM_HH

#include "string.hh"
#include "assoc.hh"

const char eol= '\n';

/// debug stream
class Dstream
{
    ostream *os;
    int indentlvl;
    bool local_silence;
    String classname;

    Assoc<String, bool> silent;
public:

    bool silence(String);
    
    Dstream(ostream *r, const char  * rcfile);
    /**
      if rcfile == 0, then do not read any rc file
      */
      
    Dstream &identify_as(String s);
    
    Dstream &operator << (String s);
};
 /**
   a class for providing debug output of nested structures,
   with indents according to \{\}()[].

   One can turn on and off specific messages using the Assoc silent.
   This can be done automatically:

   #define DEBUG  dstream_.identify_as(__PRETTY_FUNCTION__) 

   DEBUG << "a message\n";
   
   Init for the class names which should be silent can be given in a rc file. 
   
  */
#endif