class Standard . ReadBuffer {
int32 bufferLimit;
string bufferedData;
int32 bytesInBuffer;
oid clientObj;
any delimeter;
int32 eofEncountered;
int32 requestedBytes;
oid requestor;
oid srcObj;
int32 waitForLine;
} inherits from Object;
The ReadBuffer class implements a powerful convenience class for handling either asynchronous input sources and or record-oriented streams.
ReadBuffer:create(oid ioObj, optional int32 bfrLimit)
The create method takes one mandatory argument, which is the object Id of the IOobject from which data should be obtained. An optional second argument, bfrLimit can be provided that specifies the maximum size of the input buffer. There are tradeoffs in performance and memory utilization that can be altered through this parameter, but most users will want to leave it unspecified. /p>
Note: an allomorphic-equivalent to IOobject that provides implementations for selectForRead and readBytes can be used for ioObj.
ReadBuffer:setDelimeter(string delim)
The setDelimeter method is used to work in record-oriented mode. The delim pattern marks the end of each logical record in the input stream and can be more than one byte in length (for example, a carriage return/line feed pair).
This method does not return a value.
ReadBuffer:selectForRead(optional oid notifyClient)
The selectForRead method is used to request notification when data or a complete logical record is available in the buffer. If the notifyClient is not specified, it will default to fromObject.
This method does not return a value.
ReadBuffer:readBytes(int32 desiredBytes)
The readBytes method reads the specified number of bytes. If the desired amount of data is currently available, it is immediately returned; otherwise the request is queued until it can be satisfied.
ReadBuffer:readLine()
The readLine method is used when working in record-oriented mode. The end-of-line pattern should be specified using the setDelimeter method; however, if no delimeter was set, it will be forced to the newline character.
If the requested record is currently available, it is immediately returned; otherwise the request is queued until it can be satisfied. An end-of-file indication is returned as a nil value.
ReadBuffer:getLength()
Returns an integer that indicates the bytes currently in the buffer.
ReadBuffer:peekBufferContents()
Returns a string that is a copy of the buffer's current contents. No data is removed from the buffer.
ReadBuffer:deleteInitialBytes(int32 bytes)
Deletes an indicated number of bytes from the front of the buffer.
An integer that indicates the number of bytes left in the buffer is returned.