]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/dstream.cc
release: 0.1.9
[lilypond.git] / flower / dstream.cc
index f6d1d48867faf0090bac8093052c83bd4c356cd0..f11576d5900e1fafc0575e5737653f66d54e3119 100644 (file)
@@ -23,88 +23,91 @@ const INDTAB = 2;
 static String
 strip_pretty (String pretty_str)
 {
-    int i = pretty_str.index_i ('(');
-    if (i>=0)
+  int i = pretty_str.index_i ('(');
+  if (i>=0)
        pretty_str = pretty_str.left_str (i);
-    
-    int l = pretty_str.index_last_i (' '); // strip until last ' '
-    if (l>=0)
+  
+  int l = pretty_str.index_last_i (' '); // strip until last ' '
+  if (l>=0)
        pretty_str = pretty_str.nomid_str (0,l+1);
-    return pretty_str;
+  return pretty_str;
 }
 
 static String
 strip_member (String pret)
 {
-    int l=pret.index_last_i (':')-1;
-    if (l>=0)
+  int l=pret.index_last_i (':')-1;
+  if (l>=0)
        pret = pret.left_str (l);
-    return pret;
+  return pret;
 }
 
 Dstream&
 Dstream::identify_as (String name)
 {
-    if (!os_l_)
+  if (!os_l_)
        return *this;
-    
-    String mem (strip_pretty (name));
-    String cl (strip_member (mem));
-    String idx = cl;
-    
-    if (silent_assoc_p_->elt_b (mem))
+  
+  String mem (strip_pretty (name));
+  String cl (strip_member (mem));
+  String idx = cl;
+  
+  if (silent_assoc_p_->elt_b (mem))
        idx  = mem;
-    else if (silent_assoc_p_->elt_b (cl))
+  else if (silent_assoc_p_->elt_b (cl))
        idx = cl;
-    else {
+  else 
+    {
        (*silent_assoc_p_)[idx] = false;
     }
-    local_silence_b_ = (*silent_assoc_p_)[idx];
-    if (current_classname_str_ != idx && !local_silence_b_) {
+  local_silence_b_ = (*silent_assoc_p_)[idx];
+  if (current_classname_str_ != idx && !local_silence_b_) 
+    {
        current_classname_str_=idx;
        if (!(*silent_assoc_p_)["Dstream"])
            *os_l_ << "[" << current_classname_str_ << ":]"; // messy.
     }
-    return *this;
+  return *this;
 }
 
 bool
 Dstream::silence (String s)
 {
-    if (!silent_assoc_p_->elt_b (s))
+  if (!silent_assoc_p_->elt_b (s))
        return false;
-    return (*silent_assoc_p_)[s];
+  return (*silent_assoc_p_)[s];
 }
 
 Dstream &
 Dstream::operator<<(String s)
 {
-    output (s);
-    return *this;
+  output (s);
+  return *this;
 }
 
 Dstream &
 Dstream::operator<<(void const *v_l)
 {
-    output (String_convert::pointer_str (v_l));
-    return *this;
+  output (String_convert::pointer_str (v_l));
+  return *this;
 }
 
 Dstream &
 Dstream::operator<<(char const *ch_l)
 {
-    output (ch_l);
-    return *this;
+  output (ch_l);
+  return *this;
 }
 
 void
 Dstream::output (String s)
 {
-    if (local_silence_b_|| !os_l_)
+  if (local_silence_b_|| !os_l_)
        return ;
-    
-    for (char const *cp = s  ; *cp; cp++)
-       switch (*cp) {
+  
+  for (char const *cp = s  ; *cp; cp++)
+       switch (*cp) 
+         {
            case '{':
            case '[':
            case '(': indent_level_i_ += INDTAB;
@@ -126,33 +129,34 @@ Dstream::output (String s)
            default:
                *os_l_ << *cp;
                break;
-           }
-    return ;    
+             }
+  return ;    
 }
 
 
 Dstream::Dstream (ostream *r, char const * cfg_nm)
 {
-    os_l_ = r;
-    silent_assoc_p_ = new Assoc<String,bool>;
-    indent_level_i_ = 0;
-    if (!os_l_)
+  os_l_ = r;
+  silent_assoc_p_ = new Assoc<String,bool>;
+  indent_level_i_ = 0;
+  if (!os_l_)
        return;
-    
-    char const * fn =cfg_nm ? cfg_nm : ".dstreamrc";
-    {
+  
+  char const * fn =cfg_nm ? cfg_nm : ".dstreamrc";
+  {
        ifstream ifs (fn);      // can't open
        if (!ifs)
            return;
     }
 
-    Text_db cfg (fn);
-    while (! cfg.eof()){            
+  Text_db cfg (fn);
+  while (! cfg.eof()){      
         Text_record  r (cfg++);
-        if (r.size() != 2) {
+        if (r.size() != 2) 
+          {
             r.message ("not enough fields in Dstream init.");
             continue;
-        }
+          }
         (*silent_assoc_p_)[r[0]] = (bool)(int)(Scalar (r[1]));
     }
 
@@ -161,14 +165,15 @@ Dstream::Dstream (ostream *r, char const * cfg_nm)
 
 Dstream::~Dstream()
 {    
-    delete silent_assoc_p_;
-    assert (!indent_level_i_) ;
+  delete silent_assoc_p_;
+  assert (!indent_level_i_) ;
 }
 
 void
 Dstream::clear_silence() 
 {
-    for (Assoc_iter<String, bool> i (*silent_assoc_p_); i.ok(); i++) {
+  for (Assoc_iter<String, bool> i (*silent_assoc_p_); i.ok(); i++) 
+    {
        i.val() = 0;
     }
 }