DocBook|Search
Class Reference
%IO.LibraryStream
   
Server:basexml
Instance:SOAXML
User:UnknownUser
 
-
  [BASEXML] >  [%IO] >  [LibraryStream]
Private  Storage  

class %IO.LibraryStream extends %Library.AbstractStream

Adapts %IO stream classes to provide a legacy %Library.AbstractStream interface

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
5 22


Summary

Properties
%Location AtEnd Attributes IOStream Id
LastModified LineTerminator Size

Methods
%%OIDGet %AddToSaveSet %CheckUnique %ClassIsLatestVersion
%ClassName %ConstructClone %Delete %DeleteExtent
%DeleteId %DispatchClassMethod %DispatchGetModified %DispatchGetProperty
%DispatchMethod %DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty
%Exists %ExistsId %Extends %GetParameter
%GetSwizzleObject %Id %IsA %IsModified
%KillExtent %LocationSet %LockStream %New
%NormalizeObject %ObjectModified %Oid %Open
%OpenId %OriginalNamespace %PackageName %ReleaseLock
%Reload %RemoveFromSaveSet %RollBack %Save
%SerializeObject %SetModified %UnlockStream %ValidateObject
AtEndGet Clear CopyFrom CopyFromAndSave
DeleteAttribute DeleteStream FindAt Flush
GetAttribute GetStreamId InputFromDevice IsCharacter
IsDefinedAttribute IsNull LastModifiedGet LineTerminatorGet
LineTerminatorSet MoveTo MoveToEnd NextAttribute
OpenStream OutputToDevice OutputToDeviceAt Read
ReadLine ReadLineIntoStream ReadSQL Rewind
SaveStream SerializeToSyncSet SetAttribute SizeGet
StreamOIDIsNull SyncStreamIn Write WriteLine


Properties

• property AtEnd as %Boolean;
The AtEnd property is set to true (1) when, during a read, a stream has reached the end of its data source.
• property IOStream as %IO.I.Stream;
The %IO.I.Stream that we are wrapping
• property LastModified as %TimeStamp [ Calculated,ReadOnly ];
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 "".
• property LineTerminator as %String(MAXLEN=10);
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'.
• property Size as %Integer [ Calculated ];
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.
VMS does not support moving to a position in a file or providing the current position in a file. On VMS if a BOM is included at the start of the file it may be included in the size calculated.


Methods

• method AtEndGet() as %Boolean
This is a Get accessor method for the AtEnd property.
• method Clear() as %Status
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.

• method CopyFrom(source As %Stream.Object) as %Status
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
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.

• method FindAt(position As %Integer, target As %CacheString, ByRef tmpstr As %CacheString) as %Integer
Find the first occurance of target in the stream starting the search at position. It returns the position at this match starting at the begining of the stream. If it can 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
Flush any output in the stream not already saved.
• method InputFromDevice(ByRef len As %Integer = 0, timeout As %Integer = 20) as %Status
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
This is a Get accessor method for the LastModified property.
• method LineTerminatorGet() as %String
This is a Get accessor method for the LineTerminator property.
• method LineTerminatorSet(terminator As %String) as %Status
This is a Set accessor method for the LineTerminator property.
• method MoveTo(position As %Integer) as %Boolean
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
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
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
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 %CacheString
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 ("").

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 %CacheString
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 ! } }
• method ReadLineIntoStream(ByRef sc As %Status) as %Library.AbstractStream
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
Go back to the start of the stream.
• method SizeGet() as %Integer
This is a Get accessor method for the Size property.
• method Write(data As %CacheString) as %Status
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 %CacheString = "") as %Status
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.