]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dstream.hh
release: 0.1.57
[lilypond.git] / flower / include / dstream.hh
1 /*
2   dstream.hh -- declare Dstream
3
4   source file of the Flower Library
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #ifndef DSTREAM_HH
10 #define DSTREAM_HH
11
12 #include "string.hh"
13
14 const char eol= '\n';
15
16 template<class K,class V>
17 struct Assoc;
18
19 /**  Debug stream. 
20    a class for providing debug output of nested structures,
21    with indents according to \{\}()[].
22
23    One can turn on and off specific messages using the Assoc silent.
24    This can be done automatically:
25
26    #define DEBUG  dstream_.identify_as (__PRETTY_FUNCTION__) 
27
28    DEBUG << "a message\n";
29    
30    Init for the class names which should be silent can be given in a rc file. 
31    
32    TODO:
33    make a baseclass for indentable streams.
34   */
35 class Dstream
36 {
37   ostream *os_l_;
38   int indent_level_i_;
39   bool local_silence_b_;
40   bool default_silence_b_;
41   String current_classname_str_;
42   void output (String s);
43   Assoc<String, bool> *silent_assoc_p_;
44 public:
45   void clear_silence();
46   bool silent_b (String) const;
47     
48   /**
49      if rcfile == 0, then do not read any rc file.
50   */
51   Dstream (ostream *r, char const * rcfile);
52   virtual ~Dstream();
53   Dstream &identify_as (String s);
54
55   /** Output a string via the Dstream. This is the only output
56       interface. It delegates all conversion to String class.  */
57   Dstream &operator << (String s);
58   /**
59      Output memory locations.
60   */
61   Dstream &operator << (void const *);
62   Dstream &operator << (char const *);
63 };
64 #endif
65