DEADSOFTWARE

Disable debug output, read TextPieces into memory
authorGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Mon, 7 Nov 2011 18:54:24 +0000 (18:54 +0000)
committerGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Mon, 7 Nov 2011 18:54:24 +0000 (18:54 +0000)
odcread.cc
textmodel.cc
textmodel.h

index 27117ddeab85d2240d89bd82ce6a3c82d6ae7577..6d506685882012eef28356b70f36ef21e8fd51cb 100644 (file)
@@ -30,11 +30,13 @@ int main(int argc, char *argv[]) {
        }
        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;
 }
index 281042002423e99527fa8677237c2f6034d93ff0..81ac03dfe725872d202f4efec16d8243b8802a27 100644 (file)
@@ -89,8 +89,8 @@ void StdTextModel::internalize(Reader &reader) {
 //                             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));
@@ -161,33 +161,40 @@ TextPiece::TextPiece(size_t len): d_len(len) {}
 
 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) {}
index bc1480873fbb389c0ad386654f330ed462afd8d4..9cab44db5d1c115f280980522af8ede7b98394f2 100644 (file)
@@ -29,15 +29,21 @@ namespace odc {
        };
 
        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();
        };