DEADSOFTWARE

Testing odcread against a bunch of existing .odc files
[odcread.git] / fold.cc
diff --git a/fold.cc b/fold.cc
index ae4d016cfd3d602bfadc9c0318ea212dec6f88c7..b88d24b66a303e2b0602e755cfd01c6cbcdff707 100644 (file)
--- a/fold.cc
+++ b/fold.cc
@@ -4,20 +4,12 @@
 namespace odc {
 
 const std::string View::TYPENAME("Views.View^");
-const TypeProxy<View> View::PROXY;
+const TypeProxy<View, Store> View::PROXY;
 
 View::View(INTEGER id) : Store(id) {}
 
-const std::string &View::getType() {
-       return TYPENAME;
-}
-
-const std::string *View::getSuper() {
-       return &Store::getType();
-}
-
 const std::string &View::getTypeName() const {
-       return getType();
+       return TYPENAME;
 }
 
 void View::internalize(Reader &reader) {
@@ -27,20 +19,12 @@ void View::internalize(Reader &reader) {
 }
 
 const std::string Fold::TYPENAME("StdFolds.Fold^");
-const TypeProxy<Fold> Fold::PROXY;
+const TypeProxy<Fold, View> Fold::PROXY;
 
 Fold::Fold(INTEGER id) : View(id) {}
 
-const std::string &Fold::getType() {
-       return TYPENAME;
-}
-
-const std::string *Fold::getSuper() {
-       return &View::getType();
-}
-
 const std::string &Fold::getTypeName() const {
-       return getType();
+       return TYPENAME;
 }
 
 void Fold::internalize(Reader &reader) {
@@ -51,7 +35,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
@@ -70,11 +55,13 @@ std::string Fold::toString() {
        return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string("  }");
 }
 
-std::string Fold::toPlainText() {
-       if (d_hidden == 0) {
-               return 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);
        }
-       return std::string(d_label) + std::string("\n") + d_hidden->toPlainText();
 }
 
 } // namespace odc