class STORE |
---|
**** | Used to store objects in an ascii readable way. Requires the -reflect compiler option
_ Usage: _____ob1,ob2:_FOO_.... _____f:_FILE_:=_FILE::open_for_write("myfile"); _____store_::=_#STORE(f); _____store+ob1; _____store+ob2; Or _____s:_STR_STREAM_:=_#; _____store2_::=_#STORE(s); _____store2+ob1; _____store2+ob2; _____#OUT+s.str;_--_holds_the_string_representation_of_ob1_and_ob2 _ Objects are written out in the following form ______Each_reference_object_has_an_integer_index_-_starting_at_0_and ______increasing. ______Object_->_Reference_|_SeenBefore_|_Array ______Reference_->_#<typename>(_Objectfields) ______Objectfields_->_<name_=_Object><,<name=Object>>* ______Array_->_#[num_array_elts]<typename>(Object_Fields)[_Arrayfields] ______Arrayfields_->_<Object><,Object>* ______SeenBefore_->_[object_index] ______Special_kinds_of_objects: ______INT_->_<digits> ______FLT_->_<digits>.<digits> ______FLTD_->_<digits>.<digits>d ______BOOL_->_true|false ______STR_->_"__" ______CHAR_->_' ______void_->_v |
attr output: $OSTREAM; |
---|
**** | Stream onto which data is written |
check_output: BOOL |
---|
create(o: $OSTREAM): SAME |
---|
**** | Create a new store using the output stream "o" |
plus(ob: $OB) |
---|
**** | Append another object to the output stream |
plus(ob: $OB): SAME |
---|
**** | Append another object to the output stream self must exist.
_ Limitations. Cannot store a "top level" void value. Particularly bad for immutable objects. Best to box up any immutable objects into some other top-level object for storage. Note that there is no problem with void values *within* the object. |
attr already_stored: H_MAP{$OB,$OB}; |
---|
**** | Mapping from objects that have already been stored to indices integer to be used as an id for a reference object. Problems could arise if too many reference objects are being stored causing the counter to cycle. Always access via "next_index", not directly |
attr already_stored: H_MAP{$OB,$OB}; |
---|
**** | Mapping from objects that have already been stored to indices integer to be used as an id for a reference object. Problems could arise if too many reference objects are being stored causing the counter to cycle. Always access via "next_index", not directly |
app(s: STR) |
---|
app_nonl(s: STR) |
---|
attr cur_indent: INT; |
---|
attr cur_indent: INT; |
---|
attr cur_index: INT; |
---|
**** | Indicates the index of the next integer to be used as an id for a reference object. Problems could arise if too many reference objects are being stored causing the counter to cycle. Always access via "next_index", not directly |
attr cur_index: INT; |
---|
**** | Indicates the index of the next integer to be used as an id for a reference object. Problems could arise if too many reference objects are being stored causing the counter to cycle. Always access via "next_index", not directly |
deb(msg: STR): BOOL |
---|
const debug: BOOL := false; |
---|
**** | that have already been stored to indices integer to be used as an id for a reference object. Problems could arise if too many reference objects are being stored causing the counter to cycle. Always access via "next_index", not directly |
do_newline |
---|
downindent |
---|
get_id(ob: $OB, out id: INT): BOOL |
---|
**** | Return an identifier "id" for the object "ob" Returns true if the object has already been packed Otherwise return false |
next_index: INT |
---|
**** | Return the next unique integer for this packing context |
attr output: $OSTREAM; |
---|
**** | Stream onto which data is written |
pack_object(ob: $OB) |
---|
**** | Pack starting at a particular indent level Attributes are copied starting at this level |
upindent |
---|