summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDejan Jovanović <dejan.jovanovic@gmail.com>2011-03-17 03:48:53 +0000
committerDejan Jovanović <dejan.jovanovic@gmail.com>2011-03-17 03:48:53 +0000
commitd0186bbce6187def699545d072bf2f95211398cc (patch)
treec0cd9df9b5698218cb2e973981dacd5c98b51d54 /src
parent84146b42ed0e1c0298b0e2a894c33f357a4483ef (diff)
push and pop manipulators for output stream so that one can indent the output
ueful for me, maybe someone else finds it useful also
Diffstat (limited to 'src')
-rw-r--r--src/util/output.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/util/output.h b/src/util/output.h
index d722b10d1..dd5007747 100644
--- a/src/util/output.h
+++ b/src/util/output.h
@@ -134,9 +134,19 @@ extern NullC nullCvc4Stream CVC4_PUBLIC;
class CVC4_PUBLIC CVC4ostream {
std::ostream* d_os;
+ // Current indentation
+ unsigned d_indent;
+
+ std::ostream& (*d_endl)(std::ostream&);
+
public:
CVC4ostream() : d_os(NULL) {}
- CVC4ostream(std::ostream* os) : d_os(os) {}
+ CVC4ostream(std::ostream* os) : d_os(os), d_indent(0) {
+ d_endl = &std::endl;
+ }
+
+ void pushIndent() { d_indent ++; };
+ void popIndent() { if (d_indent > 0) -- d_indent; }
void flush() {
if(d_os != NULL) {
@@ -160,6 +170,11 @@ public:
if(d_os != NULL) {
d_os = &(*d_os << pf);
}
+ if (pf == d_endl) {
+ for (unsigned i = 0; i < d_indent; ++ i) {
+ d_os = &(*d_os << '\t');
+ }
+ }
return *this;
}
CVC4ostream& operator<<(std::ios& (*pf)(std::ios&)) {
@@ -174,9 +189,23 @@ public:
}
return *this;
}
-
+ CVC4ostream& operator<<(CVC4ostream& (*pf)(CVC4ostream&)) {
+ return pf(*this);
+ }
};/* class CVC4ostream */
+inline CVC4ostream& push(CVC4ostream& stream)
+{
+ stream.pushIndent();
+ return stream;
+}
+
+inline CVC4ostream& pop(CVC4ostream& stream)
+{
+ stream.popIndent();
+ return stream;
+}
+
/** The debug output class */
class CVC4_PUBLIC DebugC {
std::set<std::string> d_tags;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback