# Section 8.17.3.6:
FRUNES

###### class FRUNES < $FTEXT_STRING{RUNE,RUNES,FRUNES}

#### Formal Types

types
SAME = FRUNES ;
FRUNES = seq of RUNE

This class implements the concept of a fast (mutable) text string - in this particular case a string of runes (characters, each with individual numbers of encodings).

#### External specifications

The following features are required to be implemented for this class in accordance with the specifications given in $BINARY :-

- create(storage : BINSTR) : SAME
- build(cursor : BIN_CURSOR) : SAME
- read(cursor : BIN_CURSOR) : SAME
- binstr : BINSTR
- write(fyle : BIN_FILE)

create( sz : CARD, lib : LIBCHARS ) : SAME pre ~void(lib) post ~void(result) is -- This routine creates a new buffer for the given code count. create( sz : CARD ) : SAME is -- This routine creates a new buffer of the given storage size. create( lib : LIBCHARS ) : SAME is -- This routine creates a new buffer of the given storage size. create : SAME is -- This routine returns a new buffer. create( src : RUNES ) : SAME is -- This routine creates and fills a buffer from src. binstr : BINSTR pre ~void(self) and (loc > 0) post (result.size = loc) is -- This routine returns the text string as a binary string. size : CARD pre true post ((void(self) or (loc = 0)) and (result = 0)) or (result = indices.size) is -- This routine returns the number of runes in self or, if self is -- void, then zero. push( elem : RUNE ) : SAME pre void(self) or (index_lib = elem.lib) post (result.size = (initial(size) + 1)) is -- This routine appends a new element to the end of self and returns it. -- If self is void, create a new list. plus( elem : RUNE ) : SAME pre true post ~void(result) and ((void(self) and (result.loc = 1)) or (result.loc = initial(self.loc) + 1)) is -- This routine appends elem to self and returns it. plus( fstr : SAME ) : SAME pre (index_lib = fstr.index_lib) post ~void(result) and ((void(self) and (result.loc = str.size)) or (result.loc = initial(self.loc) + str.size)) is -- This routine appends the rune string fstr to self and returns it. plus( str : RUNES ) : SAME pre ~void(self) and (index_lib = str.index_lib) post ~void(result) and ((void(self) and (result.loc = str.size)) or (result.loc = initial(self.loc) + str.size)) is -- This routine appends the string str to self and returns the resulting -- string. aget( index : CARD ) : RUNE pre ~void(self) and (index < indices.size) post true is -- This routine is the 'array' indexing facility for runes in a string -- of runes, returning the rune indexed. aset( index : CARD, elem : RUNE ) pre ~void(self) and ~void(elem) and (index <= size) post true is -- This routine is the 'array' indexing facility for a rune string which -- is only applicable if it is known that either the element to be set is at -- the end of the current contents and there is space for the element or that -- the size of the element to be inserted is identical to the size of that -- being replaced. vset( index : CARD, elem : RUNE ) : SAME pre ~void(self) and (index <= (indices.size - 1)) post true is -- This routine is the 'array' indexing facility for the case where -- the number of codes in elem is different from the number currently at that -- index position in the string. A new rune string has to be produced if the -- resulting length is different from that currently allocated. buffer_scan pre ~void(self) and (loc > 0) post (indices.size = size) is -- This routine scans the buffer and sets up a new index list from -- the actual contents. append_file( name : STR ) : SAME pre true post (result = self) -- if file couldn't be found or (result.size > initial(size)) -- and contains the file contents is -- This routine attempts to open the file which has the given name. If -- successful then the contents of the file are appended to self which is -- returned after closing the file. -- -- NOTE If there is a file reading error then an exception is raised! append_file_range( name : STR, start, size : CARD ) : SAME pre true post (result = self) -- if file couldn't be found or (result.size > initial(size)) -- and contains the file contents is -- This routine attempts to open the named file and append the contents -- (starting at start for size octets) to self. If the file cannot be opened -- then nothing is done. separate!( str : RUNES ) : RUNES pre ~void(str) and ~void(self) and (index_lib = str.index_lib) post (result = str.str) or (result = self.str + str.str) is -- On the first iteration this iter yields the string str. On successive -- iterations it yields self followed by str. Created for use in forming -- lists whose elements are separated by self. runes : RUNES pre ~void(self) post ~void(result) -- |||recursive||| create(result) = self is -- This routine returns a text string version of self.

| Language Index |  | Library Index |  | Text Index

Comments or enquiries should be made to Keith Hopper. Page last modified: Thursday, 30 November 2000. |