The RCSString
interface provides an abstract interface to the text
strings associated with RCS files. Behind the abstract interface are
hidden a number of different implementations, each appropriate for a
different situation. The goal of this approach is efficiency.
For example, most strings that were present in the original RCS file are implemented as pointers into the memory-mapped image of the file itself. Thus, those strings can contain huge numbers of characters without consuming any memory resources.
INTERFACETheRCSString ; CONST Brand = "RCSString"; TYPE T = OBJECT METHODS toText(): TEXT := NIL; numLines(): CARDINAL := NIL; iterate(): Iterator := NIL; END; Iterator = OBJECT METHODS next(VAR line: T): BOOLEAN := NIL; END;
toText
method returns a TEXT
representation of the entire
string. It should be avoided for very large strings. Instead, the
iterate
method should be used to access large strings one line at a
time.
The numLines
method returns the number of lines in the string. If
the last line does not have a terminating newline character, it still
counts as a line.
The iterate
method constructs an iterator that accesses the
individual lines of the string in sequence. Each call to the
Iterator
's next
method sets the VAR
parameter to the next
line of the string, and returns TRUE
. If there are no more
lines, next
returns FALSE
.
Each returned line includes its terminating newline, if any. The last line won't necessarily end with a newline.
PROCEDURE FromText(text: TEXT): T;
Construct anRCSString.T
from the givenTEXT
.
END RCSString.