X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=fold.cc;h=37e0fd667756bff233d05d0a9f911d6257b373b8;hb=d7f2452e20b04d1559b7bdd3aa49b6fbf7d0abaf;hp=4be4081d8b3fd1d479b4c8fad85d7ab35be14138;hpb=5abab2c54b3da53cc9d64cbf0f369fc7486d194c;p=odcread.git diff --git a/fold.cc b/fold.cc index 4be4081..37e0fd6 100644 --- a/fold.cc +++ b/fold.cc @@ -26,7 +26,7 @@ void View::internalize(Reader &reader) { reader.readVersion(0, 0); } -const std::string Fold::TYPENAME("Folds.Fold^"); +const std::string Fold::TYPENAME("StdFolds.Fold^"); const TypeProxy Fold::PROXY; Fold::Fold(INTEGER id) : View(id) {} @@ -44,19 +44,40 @@ const std::string &Fold::getTypeName() const { } void Fold::internalize(Reader &reader) { - Store::internalize(reader); + View::internalize(reader); if (reader.isCancelled()) return; reader.readVersion(0, 0); if (reader.isCancelled()) return; - reader.readSInt(); // FIXME IMPLEMENT // rd.ReadXInt(xint);fold.leftSide := xint = 0; + reader.readSInt(); // rd.ReadXInt(xint); fold.collapsed := xint = 0; + SHORTINT c = reader.readSInt(); + d_collapsed = (c == 0); // rd.ReadXString(fold.label); + d_label = new SHORTCHAR[32]; + reader.readSString(d_label); // the label // rd.ReadStore(store); + d_hidden = reader.readStore(); // the hidden part // IF store # NIL THEN fold.hidden := store(TextModels.Model); Stores.Join(fold.hidden, fold) // ELSE fold.hidden := NIL // END; // fold.leftSide := store # NIL } +std::string Fold::toString() { + if (d_hidden == 0) { + return std::string("Fold(right)"); + } + 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