]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.2
authorfred <fred>
Thu, 10 Oct 1996 11:50:13 +0000 (11:50 +0000)
committerfred <fred>
Thu, 10 Oct 1996 11:50:13 +0000 (11:50 +0000)
dstream.cc

index 197e5300cf778a607738a428631eee8e9f97babf..1326b8b667c289b76d40fdc4de34eb4905bd44b5 100644 (file)
@@ -1,17 +1,58 @@
-// implementation of debug/TeX stream.
 #include <fstream.h>
 
 #include "dstream.hh"
 #include "string.hh"
+#include "textdb.hh"
 
 
+/*
+  should use Regexp library.
+  */
+static String
+strip_pretty(String pret)
+{
+    String cl(pret.left(pret.pos('(')-1));
+    int l = cl.lastPos(' ');
+    cl = cl.right(cl.len() -l);
+    return cl;
+}
+
+static String
+strip_member(String pret)
+{
+    String cl(pret.left(pret.lastPos(':')-2));
+    return cl;
+}
+
+Dstream&
+Dstream::identify_as(String name)
+{
+    String mem(strip_pretty(name));
+    String cl(strip_member(mem));
+    
+    if(!silent.elt_query(cl))
+       silent[cl] = false;
+    local_silence = silent[cl];
+    if (classname != cl && !local_silence) {
+       classname=cl;
+       *os << "[" << classname << ":]";
+    }
+    return *this;
+}
 
-dstream mtor(cout);
+void
+Dstream::switch_output(String name,bool b)
+{
+    silent[name] = b;
+}
 
 ///
-dstream &
-dstream::operator<<(String s)
-{       
+Dstream &
+Dstream::operator<<(String s)
+{
+    if (local_silence)
+       return *this;
+    
     for (const char *cp = s  ; *cp; cp++)
        switch(*cp) 
            {
@@ -37,10 +78,31 @@ dstream::operator<<(String s)
                *os << *cp;
                break;
            }
-    return *this;
-    
+    return *this;    
 }
 
 /** only output possibility. Delegates all conversion to String class.
  */
 
+Dstream::Dstream(ostream &r, const char * cfg_nm )
+{
+    os = &r;
+    indentlvl = 0;
+    
+    const char * fn =cfg_nm ? cfg_nm : ".dstreamrc";
+    {
+       ifstream ifs(fn);       // can't open
+       if (!ifs)
+           return;
+    }
+    cerr << "(" << fn;
+    Text_db cfg(fn);
+    while (! cfg.eof()){            
+        Text_record  r(  cfg++);
+        assert(r.sz() == 2);
+        silent[r[0]] = r[1].to_bool();
+    }
+    cerr <<")";
+}
+
+