Skip to main content

%IO.I.Stream

Class %IO.I.Stream Extends %RegisteredObject [ Abstract, System = 2 ]

Abstract base class of all streams The methods of this class work for both Byte and Character streams

Properties

IsOpen

Property IsOpen As %Boolean [ InitialExpression = 0, ReadOnly ];

Name

Property Name As %String(MAXLEN = 500, TRUNCATE = 1);

DefaultFlushOnWrite

Property DefaultFlushOnWrite As %Boolean [ Calculated, ReadOnly ];

InputStream interface Does this class flush after writes by default?

AtEnd

Property AtEnd As %Boolean [ InitialExpression = 1, ReadOnly ];

IsCharacter

Property IsCharacter As %Boolean [ Calculated, ReadOnly ];

Methods

DefaultFlushOnWriteGet

Method DefaultFlushOnWriteGet() [ CodeMode = expression ]

Read

Method Read(pMaxReadLen As %Integer = {$$$MaxLocalLength}, ByRef pTimeout As %Numeric = -1, Output pSC As %Status) As %String [ Abstract ]

Read until pMaxReadLen chars are gotten or pTimeout expires On return, if pTimeout is unchanged it means the full timeout period expired. If the timeout period expired and the returned string is shorter than pMaxReadLen, then AtEnd will be 1.

Write

Method Write(pData As %String, pFlush As %Boolean, Output pSC As %Status) [ Abstract ]

Write pData to the stream buffer. If pFlush is True, ensure that the data are actually sent to the stream.

Flush

Method Flush(Output pSC As %Status)

Ensure that any data already written to the stream buffer are actually sent to the stream.

CopyFrom

Method CopyFrom(pSource As %IO.I.Stream, ByRef pTimeout As %Numeric = -1, pFlush As %Boolean = {..DefaultFlushOnWrite}, Output pSC As %Status) As %Integer

Copy all available data from pSource to the current stream buffer. If pFlush is True, ensure that all data are actually sent to the stream.

OutputToDevice

Method OutputToDevice(pLength As %Integer = -1, ByRef pTimeout As %Numeric = -1, Output pSC As %Status) As %Integer

Copy all available data from the current stream to the current system device.

InputFromDevice

Method InputFromDevice(ByRef pTotal As %Integer = 0, ByRef pTimeout As %Integer = -1, ByRef pIdleTimeout As %Integer = 20, Output pStatus As %Status) As %Integer

delegateRead

ClassMethod delegateRead(s As %RegisteredObject, ByRef pMaxReadLen As %Integer, ByRef pTimeout As %Numeric, Output pSC As %Status) [ Internal, Private ]

Close

Method Close(Output pSC As %Status) As %Boolean

Close the current stream

%OnClose

Method %OnClose() As %Status [ Internal, Private ]

IsCharacterGet

Method IsCharacterGet() As %Boolean [ CodeMode = expression, Internal ]

ReadUntil

Method ReadUntil(pMaxReadLen As %Integer, ByRef pTimeout As %Numeric, pIdleTimeout As %Numeric, pPrevBuf As %String, pInsensitive As %Boolean, Output pWhich As %Integer, Output pSC As %Status, pTarget...) As %String

Read until one of the Target strings is found or a timeout occurs.

Return any data read until pTimeout seconds have elapsed, or until pIdleTimeout seconds elapse with no further data read, or up until any of the optional pTarget strings is encountered.

If pTarget strings are provided the pWhich output argument will contain an integer indicating which of them was matched. A value of 0 in pWhich indicates that none was matched and therefore the timeout expired or an error occurred.

Setting pInsensitive=1 means the pTarget strings will match data received in a case-insensitive way against the pTargets strings.

If pPrevBuf is provided, it is prepended to any data read, and is included in the attempt to find a matching target string.

ReadUntilArray

Method ReadUntilArray(pMaxReadLen As %Integer, ByRef pTimeout As %Numeric = -1, pIdleTimeout As %Numeric = 5, pPrevBuf As %String = "", pInsensitive As %Boolean = 0, Output pWhich As %Integer, Output pSC As %Status, ByRef pTargets) As %String

Read until one of the Target strings is found or a timeout occurs.

Return any data read until pTimeout seconds have elapsed, or until pIdleTimeout seconds elapse with no further data read, or up until any of the optional pTargets strings is encountered.

If pTargets strings are provided the pWhich output argument will contain an integer indicating which of them was matched. A value of 0 in pWhich indicates that none was matched and therefore the timeout expired or an error occurred.

Setting pInsensitive=1 means the pTarget strings will match data received in a case-insensitive way against the pTargets strings.

If pPrevBuf is provided, it is prepended to any data read, and is included in the attempt to find a matching target string.

CopyReplace

Method CopyReplace(pDest As %IO.I.Stream, pMaxReadLen As %Integer, ByRef pTimeout As %Numeric, pIdleTimeout As %Numeric, pPrevBuf As %String, pFlush As %Boolean, pInsensitive As %Boolean, pRewind As %String, Output pSC As %Status, pSearchReplace...) As %Integer

Replace from the current stream the strings contained in a list of alternating search and replace target string arguments. Accepts a destination stream pDest into which the modified result will be written. If not supplied, pDest will be returned containing a newly created GlobalCharacter stream. Reads until a maximum number of characters pMaxReadLen has been read or until a timeout pTimeout has occurred, or until pIdleTimeout seconds have elapsed with no further data read.

Setting pInsensitive=1 means the search strings will match in a case-insensitive way.

If pPrevBuf is provided, it is prepended to any data read, and is included in the attempt to find matching search strings. Replaces from left to right and does not repeat and recurse. This means that once a substring is replaced the replacement result will not be searched or replaced again. Returns the total count of characters written to the destination stream If pRewind contains i the input stream will be rewound before copying If pRewind contains I the input stream will be rewound after copying If pRewind contains o the output stream will be rewound before copying If pRewind contains O the output stream will be rewound after copying If pRewind is 1 both streams will be rewound before and after copying. This is the default. If pRewind is empty or zero neither stream will be rewound before or after copying

CopyReplaceArray

Method CopyReplaceArray(pDest As %IO.I.Stream, pMaxReadLen As %Integer = -1, ByRef pTimeout As %Numeric = -1, pIdleTimeout As %Numeric = 5, pPrevBuf As %String = "", pFlush As %Boolean = {..DefaultFlushOnWrite}, pInsensitive As %Boolean = 0, pRewind As %String = 1, Output pSC As %Status, ByRef pSearchReplace = 0) As %Integer

Replace from the current stream the strings contained in an array of alternating search and replace target string values called pSearchReplace. Accepts a destination stream pDest into which the modified result will be written. If not supplied, pDest will be returned containing a newly created GlobalCharacter stream. Reads until a maximum number of characters pMaxReadLen has been read or until a timeout pTimeout has occurred, or until pIdleTimeout seconds have elapsed with no further data read.

Setting pInsensitive=1 means the search strings will match in a case-insensitive way.

If pPrevBuf is provided, it is prepended to any data read, and is included in the attempt to find matching search strings. Replaces from left to right and does not repeat and recurse. This means that once a substring is replaced the replacement result will not be searched or replaced again. Returns the total count of characters written to the destination stream