X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=textmodel.h;h=e6faa6ec8ee2a25d792f6fd451ca2f29d61fd43e;hb=7a97d981de20c2e9e9fa27d06f5b2c69ea09de16;hp=abfe13d24f6c6ad38b2dae6a333c05d88aa076c8;hpb=2466c23751f131a07432df964658c2de90315e7b;p=odcread.git diff --git a/textmodel.h b/textmodel.h index abfe13d..e6faa6e 100644 --- a/textmodel.h +++ b/textmodel.h @@ -16,18 +16,38 @@ namespace odc { virtual const std::string &getTypeName() const; TextModel(INTEGER id); + /** + * Just calls super and reads the version and checks that its in the allowed range. + */ virtual void internalize(Reader &reader); }; + /** + * A TextPiece is just a component of an StdTextModel. + * It has a certain length in bytes, which is known construction time (due + * to meta-data in the StdTextModel header) and contents which are read + * later. + */ class TextPiece { public: + /** + * The number of bytes that will be read. + */ const size_t d_len; TextPiece(size_t len); virtual void read(Reader &reader) = 0; virtual std::string toString() const = 0; virtual void accept(Visitor &visitor) const = 0; + /** + * Size in bytes, excluding the null-character that terminates the string (i.e. the size that is read from file). + */ + unsigned size() const; }; + /** + * TextPiece consisting of 16-bit unicode characters. + * Not sure if the encoding is UCS-2 or UTF-16. + */ class LongPiece : public TextPiece { private: CHAR *d_buf; @@ -36,10 +56,17 @@ namespace odc { ~LongPiece(); virtual void read(Reader &reader); virtual std::string toString() const; - virtual std::wstring getText() const; virtual void accept(Visitor &visitor) const; + + /** + * Get the buffer contents as 16-bit (UCS-2 or UTF-16 I don't know) unicode. + */ + CHAR *getBuffer() const; }; + /** + * TextPiece consisting of 8-bit characters in the Latin-1 extension of ASCII. + */ class ShortPiece : public TextPiece { private: SHORTCHAR *d_buf; @@ -48,19 +75,31 @@ namespace odc { ~ShortPiece(); virtual void read(Reader &reader); virtual std::string toString() const; - virtual std::string getText() const; virtual void accept(Visitor &visitor) const; + + /** + * Get the buffer contents as 8-bit (Latin-1) characters. + */ + SHORTCHAR *getBuffer() const; }; + /** + * TextPiece that embeds a View. + */ class ViewPiece : public TextPiece { Store *d_view; public: ViewPiece(Store *view); + ~ViewPiece(); virtual void read(Reader &reader); virtual std::string toString() const; virtual void accept(Visitor &visitor) const; }; + /** + * Default implementation of a TextModel. + * Essentially it is a series of TextPieces. + */ class StdTextModel : public TextModel { private: static const TypeProxy PROXY; @@ -71,6 +110,11 @@ namespace odc { virtual const std::string &getTypeName() const; StdTextModel(INTEGER id); + /** + * Calls super and reads the version and checks that its in the allowed range. + * Then the text model meta-data is read, including information on all the pieces. + * After reading the meta-data, the pieces themselves are read. + */ virtual void internalize(Reader &reader); virtual std::string toString();