]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dstream.hh
release: 0.0.57
[lilypond.git] / flower / include / dstream.hh
1
2 #ifndef DSTREAM_HH
3 #define DSTREAM_HH
4
5 #include "string.hh"
6
7 const char eol= '\n';
8
9 template<class K,class V>
10 struct Assoc;
11
12 /**  debug stream. 
13    a class for providing debug output of nested structures,
14    with indents according to \{\}()[].
15
16    One can turn on and off specific messages using the Assoc silent.
17    This can be done automatically:
18
19    #define DEBUG  dstream_.identify_as(__PRETTY_FUNCTION__) 
20
21    DEBUG << "a message\n";
22    
23    Init for the class names which should be silent can be given in a rc file. 
24    
25    TODO:
26    make a baseclass for indentable streams.
27   */
28 class Dstream
29 {
30     ostream *os;
31     int indentlvl;
32     bool local_silence;
33     String classname;
34     void output(String s);
35     Assoc<String, bool> *silent;
36 public:
37
38     bool silence(String);
39     
40     /**
41       if rcfile == 0, then do not read any rc file.
42       */
43       
44     Dstream(ostream *r, char const * rcfile);
45     virtual ~Dstream();
46     Dstream &identify_as(String s);
47
48     Dstream &operator << (String s);
49     /**
50       Output memory locations.
51      */
52     Dstream &operator << (void const *);
53     Dstream &operator << (char const *);
54 };
55 #endif
56