property LastModified as %TimeStamp [ Calculated , ReadOnly ];
Inherited description: LastModified is a read-only property containing the %TimeStamp of
the last modification to this stream. If the stream is null then it will report "".
Inherited description: Type of line terminator we use for this stream, defaults to Cr/Lf. Maximum length is 10 characters.
This is stored as an attribute of the stream called 'LineTerminator'.
Inherited description: Size is a read-only property containing the current size of the stream (in bytes
for a binary stream and characters for a character stream).
If a specific stream implementation cannot determine the size of the stream then
Size will be equal to -1.
private method %OnNew(initvalue As %String) as %Status [ Language = objectscript ]
Inherited description: This callback method is invoked by the %New() method to
provide notification that a new instance of an object is being created.
If this method returns an error then the object will not be created.
It is passed the arguments provided in the %New call.
When customizing this method, override the arguments with whatever variables and types you expect to receive from %New().
For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:
Method %OnNew(dob as %Date = "", name as %Name = "") as %Status
If instead of returning a %Status code this returns an oref and this oref is a subclass of the current
class then this oref will be the one returned to the caller of %New method.
method AtEndGet() as %Boolean [ Language = objectscript ]
method Clear() as %Status [ Language = objectscript ]
Inherited description: Clear the contents of this Stream from permanent storage. This will remove the permanent stream storage and
any temporary stream and initialise the stream to its initial state that it starts in, including removing all
the stream attributes.
Returns a %Status value indicating success or failure.
Copy the contents of the given source %IO, %Library or %Stream stream to the wrappered %IO stream
method CopyFromAndSave(source As %Stream.Object) as %Status [ Language = objectscript ]
Inherited description: Copy the stream from source into the current stream ignoring anything already in the current stream
and save the result to the permanent location. This is used to optimise the copying of say a
%GlobalCharacterStream to another %GlobalCharacterStream to avoid copying into
temporary storage first and then moving this to the permanent storage when SaveStream() is called.
Note that any locking or transaction handling must be done by the caller.
Find the first occurrence of target in the stream starting the
search at position. It returns the position at this match starting
at the beginning of the stream. If it does not find the target string then
return -1. If position=-1 then start searching from the current
location and just return the offset from the last search, useful for searching
through the entire file. If you are doing this you should pass in tmpstr
by reference in every call which is used as a temporary location to store information
being read so the next call will start where the last one left off.
method Flush() as %Status [ Language = objectscript ]
Inherited description: Flush any output in the stream not already saved.
method InputFromDevice(ByRef len As %Integer = 0, timeout As %Integer = 20) as %Status [ Language = objectscript ]
Input len characters from the current device into the stream. This is equivalent to doing a series of
reads and calling Write() for each of them but it may be optimised by the subclasses. On return
len will be the number of characters still to read in (if no timeout has occured this should be 0).
method LastModifiedGet() as %TimeStamp [ Language = objectscript ]
method LineTerminatorGet() as %String [ Language = objectscript ]
method LineTerminatorSet(terminator As %String) as %Status [ Language = objectscript ]
method MoveTo(position As %Integer) as %Boolean [ Language = objectscript ]
Inherited description: Move to this position in the stream. If this suceeds then return
true, else return false. Note this implementation is not efficient because it
searches from the start of the stream, it can be improved upon in specific subclasses.
Note that moving to position 1 will be at the start of the stream, position 2 will be
at the second character of the stream, etc.
method MoveToEnd() as %Status [ Language = objectscript ]
Inherited description: Move to the end of the stream so the next Write will be appended to the end.
This allows you to read from a stream, then MoveToEnd() and append new data, where just calling
Write() after a read will clear the stream before writing new data.
Returns a %Status value indicating success or failure.
method OutputToDevice(ByRef len As %Integer = -1) as %Status [ Language = objectscript ]
Write out len characters of the stream to the current device starting from the current position. This
method is optimised for performance by the various sub classes. If len is omitted or set to -1 then
it will write out the entire stream starting at the beginning.
method OutputToDeviceAt(position As %Integer, ByRef length As %Integer) as %Status [ Language = objectscript ]
Output the stream to the current device starting at position of length
length. The length if passed by reference returns the number of characters
output.
method Read(ByRef len As %Integer = 32000, ByRef sc As %Status) as %RawString [ Language = objectscript ]
Inherited description: Reads up to len characters from the current position
in the stream. The current position is advanced by the number of
characters read. Upon exit, len is set to the actual
number of characters read. If a read occurs when the stream position
is at the end of the stream, len will be set to -1 and
Read() will return a null string (""). If no len
is passed in, ie. 'Read()()' then it is up to the Read implementation as to
how much data to return. Some stream classes use this to optimize the amount of
data returned to align this with the underlying storage of the stream.
You must call Rewind() if you want to read a stream from the beginning
again. Calling Read() after Write() implicitly ends the Write()
operation and rewinds to the start of the stream.
Returns a string up to len characters long. The byref argument sc will
return a %Status if any error occurred during the read.
method ReadLine(ByRef len As %Integer = 32000, ByRef sc As %Status, ByRef eol As %Boolean) as %RawString [ Language = objectscript ]
Inherited description: Read a line from the stream. This will look for the line terminator in the stream and
once it finds the terminator it will return the string minus the terminator character/s. If it reaches the
end of the stream before it finds a terminator it will return the data it has so far, and if you specify a
maximum size in len it will only read up to this number of characters. On exit len
will contain the actual number of characters read. The byref argument sc will
return a %Status() if any error occured during the read and the byref argument eol
is true if it found the line terminator and false otherwise. So for example you can read in a stream
a line at a time and output the results to the current device with:
While 'stream.AtEnd { Write stream.ReadLine(,.sc,.eol) If $$$ISERR(sc) { Write "ERROR" Quit } If eol { Write ! } }
Inherited description: This reads from the stream until it find the LineTerminator and returns
this as a stream. If the stream does not contain the line terminator this can potentially be the
entire stream.
method Rewind() as %Status [ Language = objectscript ]
Inherited description: Go back to the start of the stream.
method SizeGet() as %Integer [ Language = objectscript ]
method Write(data As %RawString) as %Status [ Language = objectscript ]
Inherited description: Appends the string data to the stream and advances the
current stream position by the number of characters in data.
Note that a write operation immediately following a read or rewind
will clear out the existing data in the stream.
Returns a %Status value indicating success or failure.
method WriteLine(data As %RawString = "") as %Status [ Language = objectscript ]
Appends the string data along with a line terminator to the stream and advances the
current stream position by the number of characters in data plus the line terminator.
Returns a %Status value indicating success or failure.