DEADSOFTWARE

Successful read of StdTextModel (including actual text)
[odcread.git] / reader.h
index 208cf287a34875be20020ec159fe3fb44fb009fb..21178f304e2ba32ee0d0ff86d6a74c39c8d2a028 100644 (file)
--- a/reader.h
+++ b/reader.h
 
 namespace odc {
 
-class TypeEntry {
-       public:
-       SHORTCHAR *name;
+struct TypeEntry {
+       const std::string name;
        INTEGER baseId;
 
-       TypeEntry(SHORTCHAR *typeName) : name(typeName), baseId(-1) {}
+       TypeEntry(const std::string &typeName) : name(typeName), baseId(-1) {}
 };
 
 /**
@@ -26,6 +25,9 @@ class TypeEntry {
  */ 
 class Reader {
 private:
+       static const unsigned int TYPENOTFOUND = 1;
+       static const unsigned int ALIENVERSION = 2;
+
        /*
         * rider-: Files.Reader
         * The file rider which links a Reader to a file.
@@ -34,7 +36,7 @@ private:
 
        /*
         * cancelled-: BOOLEAN  valid during a Store.Internalize call
-        * Tells whether the currently executing Internalize has been called by ReadVersion or TurnIntoAlien.
+        * Tells whether the currently executing Internalize has been cancelled by ReadVersion or TurnIntoAlien.
         */
        bool d_cancelled;
 
@@ -44,6 +46,11 @@ private:
         */
        bool d_readAlien;
 
+       /**
+        * Cause of current read being alien.
+        */
+       unsigned int d_cause;
+
        std::vector<TypeEntry*> d_typeList;
 
        std::vector<Store*> d_elemList; // FIXME: WTH, why are these different?
@@ -63,8 +70,6 @@ private:
        };
        ReaderState *d_state;
 
-       INTEGER d_cause;
-
        public:
        /**
         * Construct a reader from the istream rider.
@@ -126,21 +131,26 @@ private:
         * Reads a short character (00X..0FFX).
         */ 
        SHORTCHAR readSChar();
+       void readSChar(SHORTCHAR *buf, size_t len);
        /* PROCEDURE (VAR rd: Reader) ReadXChar (OUT x: CHAR)
         * NEW
         * Same as ReadSChar, but has a CHAR-type parameter.
         * This procedure is provided to simplify migration from Release 1.2 to 1.3.
         */
-       CHAR readXChar();
        /** 
         * PROCEDURE (VAR rd: Reader) ReadChar (OUT x: CHAR)
         * NEW
         * Reads a character (0000X..0FFFFX).
-        * 
+        */ 
+       CHAR readLChar();
+       void readLChar(CHAR *buf, size_t len);
+       /**
         * PROCEDURE (VAR rd: Reader) ReadByte (OUT x: BYTE)
         * NEW
         * Reads a very short integer (-128..127).
-        * 
+        */ 
+       BYTE readByte();
+       /**
         * PROCEDURE (VAR rd: Reader) ReadSInt (OUT x: SHORTINT)
         * NEW
         * Reads a short integer (-32768..32767).
@@ -245,7 +255,9 @@ private:
         *      rd.cause = alienVersion
         *      rd.cancelled
         *      rd.readAlien
-        * 
+        */ 
+       INTEGER readVersion(INTEGER min, INTEGER max);
+       /*
         * PROCEDURE (VAR rd: Reader) TurnIntoAlien (cause: INTEGER)
         * NEW
         * A store which is currently being internalized can turn itself into an alien, e.g., if it has read a component store which is an alien.
@@ -253,6 +265,9 @@ private:
         * Pre
         * 20   cause > 0
         */
+       void turnIntoAlien(int cause);
+
+       bool isCancelled();
 
        private:
        Store *readStoreOrElemStore(bool isElem);
@@ -261,26 +276,12 @@ private:
        Store *readNewLinkStore();
        void internalizeAlien(Alien *alien, std::streampos down, std::streampos end);
        
-       /*
-               TypeName* = ARRAY 64 OF CHAR;
-               TypePath* = ARRAY 16 OF TypeName;
-               OpName* = ARRAY 32 OF CHAR;
-        */
-       inline SHORTCHAR *newTypeName() {
-               return new SHORTCHAR[64];
-       }
-       inline SHORTCHAR **newTypePath() {
-               SHORTCHAR **out = new SHORTCHAR*[16];
-               for (int i = 0; i < 16; ++i) {
-                       out[i] = newTypeName();
-               }
-               return out;
-       }
-       void readPath(SHORTCHAR **path);
+       std::string &fixTypeName(std::string &name);
+       TypePath readPath();
        /**
         * Add another component to the current path. If first==true, start a new path.
         */
-       void addPathComponent(bool first, SHORTCHAR *typeName);
+       void addPathComponent(bool first, const std::string &typeName);
 };
 
 } // namespace odc