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