From 4610f06807135d724a73686467cffae61c43caee Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 16 Aug 1996 21:11:00 +0000 Subject: [PATCH] lilypond-0.0.1 --- dstream.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ dstream.hh | 29 +++++++++++++++++++++++++++++ notename.hh | 2 ++ 3 files changed, 77 insertions(+) create mode 100644 dstream.cc create mode 100644 dstream.hh create mode 100644 notename.hh diff --git a/dstream.cc b/dstream.cc new file mode 100644 index 0000000000..197e5300cf --- /dev/null +++ b/dstream.cc @@ -0,0 +1,46 @@ +// implementation of debug/TeX stream. +#include + +#include "dstream.hh" +#include "string.hh" + + + +dstream mtor(cout); + +/// +dstream & +dstream::operator<<(String s) +{ + for (const char *cp = s ; *cp; cp++) + switch(*cp) + { + case '{': + case '[': + case '(': indentlvl += INDTAB; + *os << *cp; + break; + + case ')': + case ']': + case '}': + indentlvl -= INDTAB; + *os << *cp ; + + if (indentlvl<0) indentlvl = 0; + break; + + case '\n': + *os << '\n' << String (' ', indentlvl) << flush; + break; + default: + *os << *cp; + break; + } + return *this; + +} + +/** only output possibility. Delegates all conversion to String class. + */ + diff --git a/dstream.hh b/dstream.hh new file mode 100644 index 0000000000..3a47a84784 --- /dev/null +++ b/dstream.hh @@ -0,0 +1,29 @@ +// debug_stream + +#ifndef DSTREAM_HH +#define DSTREAM_HH + +#include "string.hh" + +const char eol= '\n'; + +/// debug stream +class dstream +{ + ostream *os; + int indentlvl; + + /// indent of each level + const INDTAB = 3; +public: + dstream(ostream &r){ + os = &r; + indentlvl = 0; + } + dstream &operator << (String s); +}; + /** + a class for providing debug output of nested structures, + with indents according to \{\}()[] + */ +#endif diff --git a/notename.hh b/notename.hh new file mode 100644 index 0000000000..ef04a0da7c --- /dev/null +++ b/notename.hh @@ -0,0 +1,2 @@ + +void lookup_notename(int &large, int &small, String s); -- 2.39.5