DEADSOFTWARE

Completely convert .odc to .txt using Visitor
[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> View::PROXY;
9 View::View(INTEGER id) : Store(id) {}
11 const std::string &View::getType() {
12 return TYPENAME;
13 }
15 const std::string *View::getSuper() {
16 return &Store::getType();
17 }
19 const std::string &View::getTypeName() const {
20 return getType();
21 }
23 void View::internalize(Reader &reader) {
24 Store::internalize(reader);
25 if (reader.isCancelled()) return;
26 reader.readVersion(0, 0);
27 }
29 const std::string Fold::TYPENAME("StdFolds.Fold^");
30 const TypeProxy<Fold> Fold::PROXY;
32 Fold::Fold(INTEGER id) : View(id) {}
34 const std::string &Fold::getType() {
35 return TYPENAME;
36 }
38 const std::string *Fold::getSuper() {
39 return &View::getType();
40 }
42 const std::string &Fold::getTypeName() const {
43 return getType();
44 }
46 void Fold::internalize(Reader &reader) {
47 View::internalize(reader);
48 if (reader.isCancelled()) return;
49 reader.readVersion(0, 0);
50 if (reader.isCancelled()) return;
51 // rd.ReadXInt(xint);fold.leftSide := xint = 0;
52 reader.readSInt();
53 // rd.ReadXInt(xint); fold.collapsed := xint = 0;
54 SHORTINT c = reader.readSInt();
55 d_collapsed = (c == 0);
56 // rd.ReadXString(fold.label);
57 d_label = new SHORTCHAR[32];
58 reader.readSString(d_label); // the label
59 // rd.ReadStore(store);
60 d_hidden = reader.readStore(); // the hidden part
61 // IF store # NIL THEN fold.hidden := store(TextModels.Model); Stores.Join(fold.hidden, fold)
62 // ELSE fold.hidden := NIL
63 // END;
64 // fold.leftSide := store # NIL
65 }
67 std::string Fold::toString() {
68 if (d_hidden == 0) {
69 return std::string("Fold(right)");
70 }
71 return std::string("Fold(left) \"") + std::string(d_label) + std::string("\" { ") + d_hidden->toString() + std::string(" }");
72 }
74 void Fold::accept(Visitor &visitor) const {
75 if (d_hidden == 0) { // right part
76 visitor.foldRight();
77 } else { // left part
78 visitor.foldLeft(d_collapsed);
79 d_hidden->accept(visitor);
80 }
81 }
83 } // namespace odc