summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f029b8c)
raw | patch | inline | side by side (parent: f029b8c)
author | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Fri, 12 Aug 2011 16:24:22 +0000 (18:24 +0200) | ||
committer | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Fri, 12 Aug 2011 16:24:22 +0000 (18:24 +0200) |
alien.cc | patch | blob | history | |
textmodel.cc | patch | blob | history | |
textmodel.h | patch | blob | history |
diff --git a/alien.cc b/alien.cc
index d82a33ca1a2f120a008e9561e197ad644018fd8a..49d19fe5c9b06829bdc8deac3a688890da957b78 100644 (file)
--- a/alien.cc
+++ b/alien.cc
AlienPart::AlienPart(Store * const _store): store(_store) {}
std::string AlienPart::toString() {
- return store->toString();
+ if (store != 0)
+ return store->toString();
+ else
+ return "NULL";
}
Alien::Alien(INTEGER id, const TypePath &path): Store(id), d_path(path), d_comps() {}
diff --git a/textmodel.cc b/textmodel.cc
index 6ecd89e7ec8718ef0d22d032c4ace512647f6ef8..2028c2e5621c2c733f0254728740272d0b896f36 100644 (file)
--- a/textmodel.cc
+++ b/textmodel.cc
#include <vector>
#include <assert.h>
+//#include <fstream>
+//#include <iostream>
+
namespace odc {
const std::string TextModel::TYPENAME("TextModels.Model^");
const std::string StdTextModel::TYPENAME("TextModels.StdModel^");
const TypeProxy<StdTextModel> StdTextModel::PROXY;
-StdTextModel::StdTextModel(INTEGER id) : TextModel(id) {}
+StdTextModel::StdTextModel(INTEGER id) : TextModel(id), d_pieces() {}
const std::string &StdTextModel::getType() {
return TYPENAME;
if (reader.isCancelled()) return;
std::vector<Store *> dict;
- std::vector<TextPiece *> pieces;
INTEGER len = reader.readInt();
BYTE ano = reader.readByte();
std::cout << "len " << len << " ano " << (int)ano << std::endl;
INTEGER pieceLen = reader.readInt();
if (pieceLen > 0) { // shortchar piece
std::cout << "Found SChar piece" << std::endl;
- pieces.push_back(new ShortPiece(pieceLen));
+ d_pieces.push_back(new ShortPiece(pieceLen));
// NEW(sp); sp.len := len; sp.attr := attr;
// sp.file := rd.rider.Base(); sp.org := org; un := sp;
// INC(org, len) -- increment org by len ?
} else if (pieceLen < 0) { // longchar piece
std::cout << "Found LChar piece" << std::endl;
assert(pieceLen % 2 == 0);
- pieces.push_back(new LongPiece(pieceLen / 2));
+ d_pieces.push_back(new LongPiece(pieceLen / 2));
// len := -len; ASSERT(~ODD(len), 100);
// NEW(lp); lp.len := len DIV 2; lp.attr := attr;
// lp.file := rd.rider.Base(); lp.org := org; un := lp;
// rd.ReadInt(v.w); rd.ReadInt(v.h); Views.ReadView(rd, v.view);
// v.view.InitContext(NewContext(v, t));
// un := v; INC(org) -- increment org by one?? WTH?
- pieces.push_back(new ViewPiece());
+ d_pieces.push_back(new ViewPiece(view));
++skip;
}
ano = reader.readByte();
}
- for (int i = 0; i < pieces.size(); ++i) {
- pieces[i]->read(reader);
+ for (int i = 0; i < d_pieces.size(); ++i) {
+ d_pieces[i]->read(reader);
}
// rd.SetPos(org);
}
// END Internalize;
//
+std::string StdTextModel::toString() {
+ std::string sofar = "StdTextModel { ";
+ for (int i = 0; i < d_pieces.size(); ++i) {
+ sofar += d_pieces[i]->toString() + " ";
+ }
+ return sofar + "}";
+}
+
TextPiece::TextPiece(size_t len): d_len(len) {}
LongPiece::LongPiece(size_t len): TextPiece(len) {}
delete buf;
}
+std::string LongPiece::toString() {
+ return std::string("LongPiece");
+}
+
ShortPiece::ShortPiece(size_t len): TextPiece(len) {}
void ShortPiece::read(Reader &reader) {
+// static char piece[] = "pieceA";
SHORTCHAR *buf = new SHORTCHAR[d_len + 1];
reader.readSChar(buf, d_len);
buf[d_len] = 0;
+// std::ofstream ofs(piece, std::ios::out);
+// ofs.write(buf, d_len);
+// ofs.close();
+// ++piece[5];
delete buf;
}
-ViewPiece::ViewPiece(): TextPiece(0) {}
+std::string ShortPiece::toString() {
+ return std::string("ShortPiece");
+}
+
+ViewPiece::ViewPiece(Store *view): TextPiece(0), d_view(view) {}
void ViewPiece::read(Reader &reader) {
reader.readByte();
}
+std::string ViewPiece::toString() {
+ return std::string("ViewPiece { ") + d_view->toString() + " }";
+}
+
} // namespace odc
diff --git a/textmodel.h b/textmodel.h
index 93fa5b7aeba80aabbbddad13534b784484322f11..bc1480873fbb389c0ad386654f330ed462afd8d4 100644 (file)
--- a/textmodel.h
+++ b/textmodel.h
const size_t d_len;
TextPiece(size_t len);
virtual void read(Reader &reader) = 0;
+ virtual std::string toString() = 0;
};
class LongPiece : public TextPiece {
public:
LongPiece(size_t len);
virtual void read(Reader &reader);
+ virtual std::string toString();
};
class ShortPiece : public TextPiece {
public:
ShortPiece(size_t len);
virtual void read(Reader &reader);
+ virtual std::string toString();
};
class ViewPiece : public TextPiece {
+ Store *d_view;
public:
- ViewPiece();
+ ViewPiece(Store *view);
virtual void read(Reader &reader);
+ virtual std::string toString();
};
class StdTextModel : public TextModel {
private:
static const std::string TYPENAME;
static const TypeProxy<StdTextModel> PROXY;
+ std::vector<TextPiece *> d_pieces;
public:
StdTextModel(INTEGER id);
static const std::string *getSuper();
virtual const std::string &getTypeName() const;
virtual void internalize(Reader &reader);
+
+ virtual std::string toString();
};
} // namespace odc