class RESTORE
****
Restore an object from a string. Usage:
___myfoo:_FOO_:=_....
___f:_FILE_:=_FILE::open_for_write("foo");
___store:_STORE_:=_#(f);
___store+myfoo;__--_Store_some_arbitrary_object_onto_the_file_"f"
_
___f:_FILE_:=_FILE::open_for_read("foo");
___file_str:STR_:=_f.get_str
___r:_RESTORE_:=_#(file_str);
___ob:_$OB;
___if_r.next_object(out_ob)_then_..._use_ob_
___else_#ERR+"Bad_object_read"_end;
___




Public


Constants
const debug: BOOL := false;
**** that have been read in read or being read

Features
check_restore: BOOL
create(st: STR): SAME
**** Create a new unpacking context
next_object(out ob: $OB): BOOL
**** Return true if the next object was found Store the next object in "ob" if one was found


Private

check_sc(msg: STR)
**** Raise an error if the string cursor has an error
attr cur_object_index: INT;
**** Index of the most recent object read or being read
attr cur_object_index: INT;
**** Index of the most recent object read or being read
deb(msg: STR): BOOL
err(msg: STR): STORE_EXC
get_and_check_char(c: CHAR,msg:STR)
get_char(msg: STR): CHAR
get_int(msg: STR): INT
get_registered_ob(id: INT): $OB
get_word(msg: STR): STR
next_int: INT
**** Generator of integers to indicate successive objects. Back references are done by indicating the integer index of the object This must essentially replicate the behavior on the "STORE" end
parse_basic(out res:$OB): BOOL
parse_object: $OB
**** Restore from the string "st" start_index indicates where in the string to start reading from and fin_index is set to the last character consumed.
register_ob(id: INT, ob: $OB)
**** If ob is not immutable, register it
attr registry: H_MAP{$OB,$OB};
**** Mapping from ids to objects that have been read in read or being read
attr registry: H_MAP{$OB,$OB};
**** Mapping from ids to objects that have been read in read or being read
attr sc: STR_CURSOR;
**** String cursor on the current source
attr sc: STR_CURSOR;
**** String cursor on the current source
set_attrib_named(ob:$OB,field:STR,to:$OB)
**** Set the field named "field" in the object "meta" to the value "ob" Error if no such field exists in the current object

The Sather Home Page