From: fred Date: Thu, 10 Oct 1996 11:50:13 +0000 (+0000) Subject: lilypond-0.0.2 X-Git-Tag: release/1.5.59~7123 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=de8624579339e2a5d03c1efced99a30dcf4aed4f;p=lilypond.git lilypond-0.0.2 --- diff --git a/dstream.cc b/dstream.cc index 197e5300cf..1326b8b667 100644 --- a/dstream.cc +++ b/dstream.cc @@ -1,17 +1,58 @@ -// implementation of debug/TeX stream. #include #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 <<")"; +} + +