DEADSOFTWARE

Completely convert .odc to .txt using Visitor
[odcread.git] / fold.cc
diff --git a/fold.cc b/fold.cc
index b416401ede108ab39c71e3c7ab11c64de0560a00..37e0fd667756bff233d05d0a9f911d6257b373b8 100644 (file)
--- a/fold.cc
+++ b/fold.cc
@@ -51,7 +51,8 @@ void Fold::internalize(Reader &reader) {
 //             rd.ReadXInt(xint);fold.leftSide := xint = 0;
        reader.readSInt();
 //             rd.ReadXInt(xint); fold.collapsed := xint = 0;
-       reader.readSInt();
+       SHORTINT c = reader.readSInt();
+       d_collapsed = (c == 0);
 //             rd.ReadXString(fold.label);
        d_label = new SHORTCHAR[32];
        reader.readSString(d_label); // the label
@@ -67,7 +68,16 @@ std::string Fold::toString() {
        if (d_hidden == 0) {
                return std::string("Fold(right)");
        }
-       return std::string("Fold(left)") + std::string(" { ") + d_hidden->toString() + std::string("  }");
+       return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string("  }");
+}
+
+void Fold::accept(Visitor &visitor) const {
+       if (d_hidden == 0) { // right part
+               visitor.foldRight();
+       } else { // left part
+               visitor.foldLeft(d_collapsed);
+               d_hidden->accept(visitor);
+       }
 }
 
 } // namespace odc