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