summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9199c6d)
raw | patch | inline | side by side (parent: 9199c6d)
author | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Mon, 7 Nov 2011 18:54:24 +0000 (18:54 +0000) | ||
committer | Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl> | |
Mon, 7 Nov 2011 18:54:24 +0000 (18:54 +0000) |
odcread.cc | patch | blob | history | |
textmodel.cc | patch | blob | history | |
textmodel.h | patch | blob | history |
diff --git a/odcread.cc b/odcread.cc
index 27117ddeab85d2240d89bd82ce6a3c82d6ae7577..6d506685882012eef28356b70f36ef21e8fd51cb 100644 (file)
--- a/odcread.cc
+++ b/odcread.cc
}
std::ifstream in(argv[1], std::ios::in | std::ios::binary);
odc::Store* s = odc::importDocument(in);
- //std::cout << s->toString() << std::endl;
- //std::cout << in.tellg() << " " << in.eof() << std::endl;
+ std::cout << std::endl << std::endl;
+
+ std::cout << s->toString() << std::endl;
+ std::cout << in.tellg() << " " << in.eof() << std::endl;
odc::TypePath path;
odc::ContainerModel(0).getTypePath(&path);
- //std::cout << path.toString() << std::endl;
+ std::cout << path.toString() << std::endl;
return 0;
}
diff --git a/textmodel.cc b/textmodel.cc
index 281042002423e99527fa8677237c2f6034d93ff0..81ac03dfe725872d202f4efec16d8243b8802a27 100644 (file)
--- a/textmodel.cc
+++ b/textmodel.cc
// INC(org, len) -- increment org by len ?
} else { // embedded view
//std::cout << "Found View piece" << std::endl;
- reader.readInt(); reader.readInt();
- Store *view = reader.readStore(); // fixme: save somewhere
+ reader.readInt(); reader.readInt(); // view width + height: ignore
+ Store *view = reader.readStore();
// NEW(v); v.len := 1; v.attr := attr;
// rd.ReadInt(v.w); rd.ReadInt(v.h); Views.ReadView(rd, v.view);
// v.view.InitContext(NewContext(v, t));
LongPiece::LongPiece(size_t len): TextPiece(len) {}
+LongPiece::~LongPiece() {
+ delete d_buf;
+}
+
void LongPiece::read(Reader &reader) {
- CHAR *buf = new CHAR[d_len];
- reader.readLChar(buf, d_len);
- delete buf;
+ d_buf = new CHAR[d_len];
+ reader.readLChar(d_buf, d_len);
}
std::string LongPiece::toString() {
- return std::string("LongPiece");
+ return std::string("LongPiece(FIXME)");// + std::wstring((wchar_t*)d_buf) + std::string(")");
}
ShortPiece::ShortPiece(size_t len): TextPiece(len) {}
+ShortPiece::~ShortPiece() {
+ delete d_buf;
+}
+
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::cout.write(buf, d_len);
+ d_buf = new SHORTCHAR[d_len + 1];
+ reader.readSChar(d_buf, d_len);
+ d_buf[d_len] = 0;
+// std::cout.write(buf, d_len);
// std::ofstream ofs(piece, std::ios::out);
// ofs.write(buf, d_len);
// ofs.close();
// ++piece[5];
- delete buf;
+// delete buf;
}
std::string ShortPiece::toString() {
- return std::string("ShortPiece");
+ return std::string("ShortPiece(") + std::string(d_buf) + std::string(")");
}
ViewPiece::ViewPiece(Store *view): TextPiece(0), d_view(view) {}
diff --git a/textmodel.h b/textmodel.h
index bc1480873fbb389c0ad386654f330ed462afd8d4..9cab44db5d1c115f280980522af8ede7b98394f2 100644 (file)
--- a/textmodel.h
+++ b/textmodel.h
};
class LongPiece : public TextPiece {
+ private:
+ CHAR *d_buf;
public:
LongPiece(size_t len);
+ ~LongPiece();
virtual void read(Reader &reader);
virtual std::string toString();
};
class ShortPiece : public TextPiece {
+ private:
+ SHORTCHAR *d_buf;
public:
ShortPiece(size_t len);
+ ~ShortPiece();
virtual void read(Reader &reader);
virtual std::string toString();
};