DEADSOFTWARE

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