14 const std::string name
;
17 TypeEntry(const std::string
&typeName
) : name(typeName
), baseId(-1) {}
21 * Used by Store.internalize() to read from file.
26 * The store was read as an Alien because its type is not registered.
29 static const unsigned int TYPENOTFOUND
= 1;
31 * The store was read as an Alien because its version is not in the accepted range.
33 static const unsigned int ALIENVERSION
= 2;
36 * The input stream associated with this reader.
38 std::istream
&d_rider
;
41 * Whether the currently executing Store.internalize() has been cancelled.
42 * If so, it will be read as an Alien.
47 * Cause of current read being an Alien.
52 * Whether any alien has been read from the input stream.
57 * The TypeList should be used for consistency checking on type paths.
60 std::vector
<TypeEntry
*> d_typeList
;
63 * List of stores that have been read already, to enable repeated occurences
64 * of a single store to reference them.
65 * Elem type stores have IDs that are separate from the IDs of other stores.
67 std::vector
<Store
*> d_elemList
;
69 * List of stores that have been read already, to enable repeated occurences
70 * of a single store to reference them.
71 * Elem type stores have IDs that are separate from the IDs of other stores.
73 std::vector
<Store
*> d_storeList
;
76 * Stores the reader state so that we can rewind a failed Store.internalize().
80 * Position of the next store in the current level
84 * Position just after the last read store
90 * The store that is currently being read.
95 * Reader state at the start of reading the current store (before calling Store.internalize())....
101 * Construct a reader from the istream rider.
102 * @param rider An istream (binary mode).
104 Reader(std::istream
&rider
);
106 /* Omitted reading methods:
108 * There are a number of ReadX* methods that read a SHORT type but return a LONG type. Those have been omitted.
110 * PROCEDURE (VAR rd: Reader) ReadBool (OUT x: BOOLEAN)
112 * Reads a Boolean value.
114 * PROCEDURE (VAR rd: Reader) ReadLong (OUT x: LONGINT)
116 * Reads a long integer (-9223372036854775808..9223372036854775807).
118 * PROCEDURE (VAR rd: Reader) ReadSReal (OUT x: SHORTREAL)
120 * Reads a short real (32-bit IEEE number).
122 * PROCEDURE (VAR rd: Reader) ReadReal (OUT x: REAL)
124 * Reads a real (64-bit IEEE number).
126 * PROCEDURE (VAR rd: Reader) ReadSet (OUT x: SET)
128 * Reads a set (32 elements).
130 * PROCEDURE (VAR rd: Reader) ReadString (OUT x: ARRAY OF CHAR)
132 * Reads a 0X-terminated string.
135 * Reads a short character (00X..0FFX).
137 SHORTCHAR
readSChar();
139 * Reads a string of short characters (00X..0FFX).
141 void readSChar(SHORTCHAR
*buf
, size_t len
);
143 * Reads a character (0000X..0FFFFX).
147 * Reads a string of characters (0000X..0FFFFX).
149 void readLChar(CHAR
*buf
, size_t len
);
151 * Reads a very short integer (-128..127).
155 * Reads a short integer (-32768..32767).
159 * Reads an integer (-2147483648..2147483647).
163 * Reads a 0X-terminated short string.
164 * Used to read string that have a known maximum length.
166 void readSString(SHORTCHAR
*out
);
168 * (Explanation from the BlackBox source.)
169 * Reads a store's type, allocates it, and then reads its contents, by calling the store's Internalize procedure. x may also be NIL, or an alien if the store's module cannot be loaded, or if internalization has been cancelled by the Internalize procedure.
170 * If the store has already been read in, a pointer to the same store is returned instead of allocating a new one. This means that arbitrary graphs that have been written with WriteStore are reconstructed correctly, including alias pointers to the same store, cycles, etc.
171 * If the file on which the reader operates does not contain correct input, then an assertion trap will be caused (traps 101 to trap 106).
175 * (Explanation from the BlackBox source.)
176 * Read a version byte and return it in version. If version is not in the
177 * specified range [min .. max], the store currently being read is turned
178 * into an alien, with cause = alienVersion.
180 INTEGER
readVersion(INTEGER min
, INTEGER max
);
182 * (Explanation from the BlackBox source.)
183 * A store which is currently being internalized can turn itself into an
184 * alien, e.g., if it has read a component store which is an alien.
186 void turnIntoAlien(int cause
);
189 * @return Whether the current read has been cancelled.
197 Store
*readStoreOrElemStore(bool isElem
);
199 * Read a Nil store. A Nil store doesn't contain anything, but may require us to skip some bytes.
201 Store
*readNilStore();
203 * Read a link to an Elem-type store.
205 Store
*readLinkStore();
207 * Read a link to a non-Elem-type store.
209 Store
*readNewLinkStore();
211 * Read an alien store.
213 void internalizeAlien(Alien
*alien
, std::streampos down
, std::streampos end
);
216 * Make store name consistent with names found in BlackBox source.
218 std::string
&fixTypeName(std::string
&name
);
225 * Add another component to the current path. If first==true, start a new path.
227 void addPathComponent(bool first
, const std::string
&typeName
);