DEADSOFTWARE

94ed5878f6f00a1831f2f3b671f3285118ac925d
[odcread.git] / fold / fold.cc
1 #include "fold/fold.ih"
3 namespace odc {
5 const std::string View::TYPENAME("Views.View^");
6 const TypeProxy<View, Store> View::PROXY;
8 View::View(INTEGER id) : Store(id) {}
10 const std::string &View::getTypeName() const {
11 return TYPENAME;
12 }
14 void View::internalize(Reader &reader) {
15 Store::internalize(reader);
16 if (reader.isCancelled()) return;
17 reader.readVersion(0, 0);
18 }
20 const std::string Fold::TYPENAME("StdFolds.Fold^");
21 const TypeProxy<Fold, View> Fold::PROXY;
23 Fold::Fold(INTEGER id) : View(id) {}
25 const std::string &Fold::getTypeName() const {
26 return TYPENAME;
27 }
29 void Fold::internalize(Reader &reader) {
30 View::internalize(reader);
31 if (reader.isCancelled()) return;
32 reader.readVersion(0, 0);
33 if (reader.isCancelled()) return;
34 // rd.ReadXInt(xint);fold.leftSide := xint = 0;
35 reader.readSInt();
36 // rd.ReadXInt(xint); fold.collapsed := xint = 0;
37 SHORTINT c = reader.readSInt();
38 d_collapsed = (c == 0);
39 // rd.ReadXString(fold.label);
40 d_label = new SHORTCHAR[32];
41 reader.readSString(d_label); // the label
42 // rd.ReadStore(store);
43 d_hidden = reader.readStore(); // the hidden part
44 // IF store # NIL THEN fold.hidden := store(TextModels.Model); Stores.Join(fold.hidden, fold)
45 // ELSE fold.hidden := NIL
46 // END;
47 // fold.leftSide := store # NIL
48 }
50 std::string Fold::toString() {
51 if (d_hidden == 0) {
52 return std::string("Fold(right)");
53 }
54 return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string(" }");
55 }
57 void Fold::accept(Visitor &visitor) const {
58 if (d_hidden == 0) { // right part
59 visitor.foldRight();
60 } else { // left part
61 visitor.foldLeft(d_collapsed);
62 d_hidden->accept(visitor);
63 }
64 }
66 } // namespace odc