#include <StreamNative.hpp>
Public Types | |
enum | { DefaultBufferSize = 512 } |
enum | StreamState { StreamUnknown = 0 , StreamReady = 1 , StreamNotready = 2 , StreamEof = 3 , StreamError = 4 } |
Public Member Functions | |
StreamInfo (RexxObjectPtr s, const char *inputName) | |
void | setContext (RexxMethodContext *c, RexxObjectPtr d) |
char * | allocateBuffer (size_t length) |
char * | getDefaultBuffer (size_t &length) |
char * | extendBuffer (size_t &length) |
void | freeBuffer () |
bool | open (int openFlags, int openMode, int sharedFlag) |
int64_t | size () |
void | notreadyError () |
void | notreadyError (int error_code, RexxObjectPtr result=NULL) |
void | raiseException (int err) |
void | raiseException (int err, RexxObjectPtr sub1) |
void | raiseException (int err, RexxObjectPtr sub1, RexxObjectPtr sub2) |
void | raiseException (int err, RexxObjectPtr sub1, RexxObjectPtr sub2, RexxObjectPtr sub3) |
void | raiseException (int err, RexxObjectPtr sub1, RexxObjectPtr sub2, RexxObjectPtr sub3, RexxObjectPtr sub4) |
void | raiseException (int err, RexxObjectPtr sub1, RexxObjectPtr sub2, RexxObjectPtr sub3, RexxObjectPtr sub4, RexxObjectPtr sub5) |
void | eof (RexxObjectPtr) |
void | eof () |
void | checkEof () |
void | checkStreamType () |
void | close () |
const char * | openStd (const char *options) |
const char * | handleOpen (const char *options) |
void | resetFields () |
void | implicitOpen (int type) |
void | readSetup () |
void | writeSetup () |
RexxStringObject | readLine (char *buffer, size_t length, bool update_position) |
void | resolveStreamName () |
void | writeBuffer (const char *data, size_t length, size_t &bytesWritten) |
void | writeLine (const char *data, size_t length, size_t &bytesWritten) |
void | readBuffer (char *data, size_t length, size_t &bytesRead) |
void | completeLine (size_t writeLength) |
void | writeFixedLine (const char *data, size_t length) |
void | setPosition (int64_t position, int64_t &newPosition) |
void | setPosition (int64_t offset, int style, int64_t &newPosition) |
void | setReadPosition (int64_t position) |
void | setWritePosition (int64_t position) |
void | setCharReadPosition (int64_t position) |
void | setLineReadPosition (int64_t position) |
void | setCharWritePosition (int64_t position) |
void | setLineWritePosition (int64_t position) |
RexxStringObject | readVariableLine () |
void | appendVariableLine (RexxArrayObject r) |
void | lineReadIncrement () |
void | resetLinePositions () |
RexxStringObject | charin (bool setPosition, int64_t position, size_t read_length) |
size_t | charout (RexxStringObject data, bool setPosition, int64_t position) |
RexxStringObject | linein (bool setPosition, int64_t position, size_t count) |
int | arrayin (RexxArrayObject r) |
int64_t | lines (bool quick) |
int64_t | chars () |
int | lineout (RexxStringObject data, bool setPosition, int64_t position) |
const char * | streamClose () |
const char * | streamFlush () |
const char * | streamOpen (const char *options) |
void | setHandle (int fh) |
int64_t | streamPosition (const char *options) |
int64_t | getLineSize () |
int64_t | seekLinePosition (int64_t offset, int direction, int64_t ¤t_line, int64_t ¤t_position) |
int64_t | setLinePosition (int64_t new_line, int64_t ¤t_line, int64_t ¤t_position) |
int64_t | queryLinePosition (int64_t current_position) |
RexxObjectPtr | queryStreamPosition (const char *options) |
int64_t | getLineReadPosition () |
int64_t | getLineWritePosition () |
int64_t | readForwardByLine (int64_t offset, int64_t ¤t_line, int64_t ¤t_position) |
int64_t | seekToVariableLine (int64_t offset, int64_t ¤t_line, int64_t ¤t_position) |
int64_t | setLinePositions () |
const char * | getQualifiedName () |
const char * | streamExists () |
RexxObjectPtr | queryHandle () |
const char * | getStreamType () |
RexxObjectPtr | getStreamSize () |
const char * | getTimeStamp () |
const char * | getState () |
RexxStringObject | getDescription () |
int64_t | countStreamLines (int64_t currentLinePosition, int64_t currentPosition) |
void | setStandard () |
Protected Attributes | |
RexxMethodContext * | context |
RexxObjectPtr | self |
RexxObjectPtr | defaultResult |
char | stream_name [SysFileSystem::MaximumFileNameBuffer] |
char | qualified_name [SysFileSystem::MaximumFileNameLength] |
int64_t | charReadPosition |
int64_t | charWritePosition |
int64_t | lineReadPosition |
int64_t | lineWritePosition |
int64_t | lineReadCharPosition |
int64_t | lineWriteCharPosition |
int64_t | stream_line_size |
StreamState | state |
int | errorInfo |
size_t | binaryRecordLength |
char * | bufferAddress |
size_t | bufferLength |
SysFile | fileInfo |
bool | read_only |
bool | write_only |
bool | read_write |
bool | append |
bool | nobuffer |
bool | stdstream |
bool | last_op_was_read |
bool | opened_as_handle |
bool | transient |
bool | record_based |
bool | isopen |
Friends | |
class | LineBuffer |
Definition at line 65 of file StreamNative.hpp.
anonymous enum |
Enumerator | |
---|---|
DefaultBufferSize |
Definition at line 69 of file StreamNative.hpp.
Enumerator | |
---|---|
StreamUnknown | |
StreamReady | |
StreamNotready | |
StreamEof | |
StreamError |
Definition at line 74 of file StreamNative.hpp.
StreamInfo::StreamInfo | ( | RexxObjectPtr | s, |
const char * | inputName | ||
) |
Constructor for a StreamInfo object.
s | The Stream object this is attached to. |
inputName | The initial input name specified on the new call. |
Definition at line 3706 of file StreamNative.cpp.
References bufferAddress, bufferLength, SysFileSystem::MaximumPathLength, resetFields(), state, stream_name, and StreamUnknown.
char * StreamInfo::allocateBuffer | ( | size_t | length | ) |
Get the buffer attached to this stream. If the existing buffer is large enough for the requested usage, then use it. Otherwise, allocate a larger one.
length | Required buffer length |
Definition at line 204 of file StreamNative.cpp.
References bufferAddress, bufferLength, DefaultBufferSize, raiseException(), and Rexx_Error_System_service.
Referenced by extendBuffer(), and getDefaultBuffer().
void StreamInfo::appendVariableLine | ( | RexxArrayObject | result | ) |
Read in a variable length line, searching for the eol marker for the line.
Definition at line 1412 of file StreamNative.cpp.
References SysFile::atEof(), checkEof(), context, extendBuffer(), fileInfo, getDefaultBuffer(), SysFile::gets(), and lineReadIncrement().
Referenced by arrayin().
int StreamInfo::arrayin | ( | RexxArrayObject | result | ) |
Perform a line-oriented arrayin operation on the stream
setPosition | Indicates whether it is necessary to move the read pointer before reading. |
position | New target position. |
count | count of lines to read. |
Definition at line 1743 of file StreamNative.cpp.
References appendVariableLine(), binaryRecordLength, charReadPosition, context, readBuffer(), readSetup(), and record_based.
Referenced by RexxMethod2().
RexxStringObject StreamInfo::charin | ( | bool | _setPosition, |
int64_t | position, | ||
size_t | read_length | ||
) |
Perform a charin() operation on the stream.
setPosition | Indicates whether it is necessary to move the read pointer before reading. |
position | New target position. |
read_length | Length to read. |
Definition at line 1507 of file StreamNative.cpp.
References context, eof(), readBuffer(), readSetup(), resetLinePositions(), and setCharReadPosition().
Referenced by RexxMethod3().
size_t StreamInfo::charout | ( | RexxStringObject | data, |
bool | _setPosition, | ||
int64_t | position | ||
) |
Write character data to the stream.
data | The string object data we're writing. |
setPosition | An order to reset the position information. |
position | The new write position, if specified. |
Definition at line 1579 of file StreamNative.cpp.
References close(), context, defaultResult, notreadyError(), NULLOBJECT, resetLinePositions(), setCharWritePosition(), writeBuffer(), and writeSetup().
Referenced by RexxMethod3().
int64_t StreamInfo::chars | ( | ) |
Return the remaining character indicator for a stream. For transient streams, this is a 1/0 value. For persistent streams, this is the remaining data left in the stream.
Definition at line 1940 of file StreamNative.cpp.
References charReadPosition, fileInfo, SysFile::hasData(), implicitOpen(), isopen, SysFile::isTransient(), operation_nocreate, read_only, read_write, and size().
Referenced by RexxMethod1().
void StreamInfo::checkEof | ( | ) |
Raise the appropriate not ready condition, checking first for an eof condition.
result | A result object to be passed with the Notready condition. |
Definition at line 467 of file StreamNative.cpp.
References SysFile::atEof(), eof(), fileInfo, and notreadyError().
Referenced by appendVariableLine(), readLine(), readVariableLine(), and setPosition().
void StreamInfo::checkStreamType | ( | ) |
Get the type of the stream in question.
binary | Indicates whether we believe this to be a binary stream, or not. |
Definition at line 489 of file StreamNative.cpp.
References binaryRecordLength, fileInfo, SysFile::isTransient(), raiseException(), record_based, Rexx_Error_Incorrect_method, and size().
Referenced by handleOpen(), implicitOpen(), and streamOpen().
void StreamInfo::close | ( | ) |
Close stream, performing any data flushes that might be required.
This raises a NOTREADY condition if any errors occur on the close.
Definition at line 534 of file StreamNative.cpp.
References SysFile::close(), context, defaultResult, SysFile::errorInfo(), fileInfo, freeBuffer(), isopen, notreadyError(), state, and StreamUnknown.
Referenced by charout(), lineout(), streamClose(), and streamOpen().
void StreamInfo::completeLine | ( | size_t | writeLength | ) |
Write out the remainder of an output line for a record oriented I/O operation.
Definition at line 1134 of file StreamNative.cpp.
References writeBuffer().
Referenced by lineout(), and writeFixedLine().
Count the number of lines in the file. If we already have a pseudo line count, we can just return that.
currentLinePosition | The current line position we're scanning from. |
currentPosition | The position to start counting from. |
Definition at line 3746 of file StreamNative.cpp.
References SysFile::countLines(), fileInfo, notreadyError(), setPosition(), and stream_line_size.
Referenced by getLineSize(), and lines().
void StreamInfo::eof | ( | ) |
Process an EOF condition for a stream.
Definition at line 438 of file StreamNative.cpp.
References defaultResult.
Referenced by charin(), checkEof(), readLine(), and setCharReadPosition().
void StreamInfo::eof | ( | RexxObjectPtr | result | ) |
Process an EOF condition for a stream.
result | A result object returned with the NotReady condition. |
Definition at line 449 of file StreamNative.cpp.
References context, state, stream_name, and StreamEof.
char * StreamInfo::extendBuffer | ( | size_t & | length | ) |
Extend the current I/O buffer, keeping any data in the buffer intact.
length | The length of the extended buffer. |
Definition at line 260 of file StreamNative.cpp.
References allocateBuffer(), bufferAddress, bufferLength, and DefaultBufferSize.
Referenced by appendVariableLine(), and readVariableLine().
void StreamInfo::freeBuffer | ( | ) |
Release the buffer, if any, attached to this stream object.
Definition at line 273 of file StreamNative.cpp.
References bufferAddress, and bufferLength.
Referenced by close().
char * StreamInfo::getDefaultBuffer | ( | size_t & | length | ) |
Get a buffer of at least the default size, returning a to the buffer and the current size.
length | The returned buffer length. |
Definition at line 242 of file StreamNative.cpp.
References allocateBuffer(), bufferAddress, bufferLength, and DefaultBufferSize.
Referenced by appendVariableLine(), and readVariableLine().
RexxStringObject StreamInfo::getDescription | ( | ) |
Retrieve a description string for the stream.
Definition at line 3622 of file StreamNative.cpp.
References context, errorInfo, NULLOBJECT, state, StreamEof, StreamError, StreamNotready, StreamReady, StreamUnknown, and work.
Referenced by RexxMethod1().
int64_t StreamInfo::getLineReadPosition | ( | ) |
Calculate the line position of the stream based on the position and the type.
Definition at line 3170 of file StreamNative.cpp.
References binaryRecordLength, charReadPosition, lineReadCharPosition, lineReadPosition, queryLinePosition(), and record_based.
Referenced by queryStreamPosition().
int64_t StreamInfo::getLineSize | ( | ) |
Get the line size for this stream. If we're using fixed length records, we can calculate this directly from the size. If it is a variable-line stream, we might have already calculated the size and kept the information. If not, we're going to have go and count every line.
Definition at line 2865 of file StreamNative.cpp.
References binaryRecordLength, countStreamLines(), record_based, and size().
Referenced by seekLinePosition().
int64_t StreamInfo::getLineWritePosition | ( | ) |
Calculate the line position of the stream based on the defined I/O type.
Definition at line 3200 of file StreamNative.cpp.
References binaryRecordLength, charWritePosition, lineWriteCharPosition, lineWritePosition, queryLinePosition(), and record_based.
Referenced by queryStreamPosition().
const char * StreamInfo::getQualifiedName | ( | ) |
Return the qualified name of a stream.
Definition at line 3374 of file StreamNative.cpp.
References qualified_name, and resolveStreamName().
Referenced by RexxMethod1().
const char * StreamInfo::getState | ( | ) |
Get the stream state as a string. This value is a constant, and does not contain any addtional information.
Definition at line 3585 of file StreamNative.cpp.
References state, StreamEof, StreamError, StreamNotready, StreamReady, and StreamUnknown.
Referenced by RexxMethod1().
RexxObjectPtr StreamInfo::getStreamSize | ( | ) |
Get the size of the stream, regardless of whether it is open or not.
Definition at line 3507 of file StreamNative.cpp.
References context, fileInfo, SysFile::getSize(), isopen, qualified_name, and resolveStreamName().
Referenced by RexxMethod1().
const char * StreamInfo::getStreamType | ( | ) |
Return the type of stream (persistent or transient).
Definition at line 3475 of file StreamNative.cpp.
References isopen.
Referenced by RexxMethod1().
const char * StreamInfo::getTimeStamp | ( | ) |
Get the time stamp of the stream (in character form), regardless of whether it is open or not.
Definition at line 3537 of file StreamNative.cpp.
References fileInfo, SysFile::getTimeStamp(), isopen, qualified_name, and resolveStreamName().
Referenced by RexxMethod1().
const char * StreamInfo::handleOpen | ( | const char * | options | ) |
Do a stream open using a supplied file handle. This open process parses all of the open parameters, setting the appropriate state
options | The character string open optins. |
Definition at line 654 of file StreamNative.cpp.
References binaryRecordLength, BitOr, CallItem, charWritePosition, checkStreamType(), ctrl_z, fileInfo, isopen, SysFile::isTransient(), lineWriteCharPosition, lineWritePosition, MEB, MIB, nobuffer, notreadyError(), parser(), qualified_name, raiseException(), RDWR_CREAT, SysFile::read(), read_only, read_write, reclength_token(), record_based, resetFields(), Rexx_Error_Incorrect_method, RX_O_RDONLY, SetBool, setPosition(), size(), state, stream_name, StreamReady, unknown_tr(), WR_CREAT, and write_only.
Referenced by implicitOpen(), and streamOpen().
void StreamInfo::implicitOpen | ( | int | type | ) |
Do an implicit open of the stream...this fully parses the information to sort out how the open needs to proceed.
type | The type of open operation. |
Definition at line 813 of file StreamNative.cpp.
References charWritePosition, checkStreamType(), SysFile::clearErrors(), context, ctrl_z, defaultResult, SysFile::errorInfo(), fileInfo, handleOpen(), IREAD_IWRITE, SysFile::isOpen(), isopen, SysFile::isTransient(), lineWriteCharPosition, lineWritePosition, notreadyError(), NULLOBJECT, open(), opened_as_handle, openStd(), operation_nocreate, operation_write, RDWR_CREAT, SysFile::read(), read_only, read_write, resetFields(), resolveStreamName(), RX_O_RDONLY, RX_O_RDWR, RX_O_WRONLY, RX_S_IREAD, RX_SH_DENYWR, setPosition(), size(), state, stdstream, StreamReady, type, work, and write_only.
Referenced by chars(), lines(), readSetup(), setPosition(), streamPosition(), and writeSetup().
RexxStringObject StreamInfo::linein | ( | bool | _setPosition, |
int64_t | position, | ||
size_t | count | ||
) |
Perform a linein() operation on the stream.
setPosition | Indicates whether it is necessary to move the read pointer before reading. |
position | New target position. |
count | count of lines to read. |
Definition at line 1661 of file StreamNative.cpp.
References binaryRecordLength, charReadPosition, context, raiseException(), readBuffer(), readSetup(), readVariableLine(), record_based, Rexx_Error_Incorrect_method, and setLineReadPosition().
Referenced by RexxMethod3().
int StreamInfo::lineout | ( | RexxStringObject | data, |
bool | _setPosition, | ||
int64_t | position | ||
) |
Write a line out to the stream.
data | The string object to write. |
setPosition | Indicates whether we've been given a line position to use for the write. |
position | The provided line position. |
Definition at line 1998 of file StreamNative.cpp.
References append, binaryRecordLength, charWritePosition, close(), completeLine(), context, lineWriteCharPosition, lineWritePosition, NULLOBJECT, raiseException(), record_based, Rexx_Error_Incorrect_method, setLineWritePosition(), size(), stream_line_size, writeFixedLine(), writeLine(), and writeSetup().
Referenced by RexxMethod3().
void StreamInfo::lineReadIncrement | ( | ) |
Increments the read positions, including the line-orientated positions, after a single line has been read. Assumes one line has actually been read.
Definition at line 1462 of file StreamNative.cpp.
References charReadPosition, fileInfo, SysFile::getPosition(), last_op_was_read, lineReadCharPosition, lineReadPosition, and notreadyError().
Referenced by appendVariableLine(), and readVariableLine().
int64_t StreamInfo::lines | ( | bool | quick | ) |
Count the number lines in the stream.
quick | Controls whether we just return a 1/0 indicicator that there is more data, or do an actualy count of the lines. |
Definition at line 1817 of file StreamNative.cpp.
References binaryRecordLength, charReadPosition, countStreamLines(), fileInfo, SysFile::hasData(), implicitOpen(), isopen, SysFile::isTransient(), lineReadPosition, operation_nocreate, read_only, read_write, readSetup(), record_based, size(), and stream_line_size.
Referenced by RexxMethod2().
void StreamInfo::notreadyError | ( | ) |
Raise a stream error condition, including raising a NOTREADY condition.
Definition at line 315 of file StreamNative.cpp.
References defaultResult, SysFile::errorInfo(), and fileInfo.
Referenced by charout(), checkEof(), close(), countStreamLines(), handleOpen(), implicitOpen(), lineReadIncrement(), queryLinePosition(), queryStreamPosition(), readBuffer(), readForwardByLine(), setLinePositions(), streamFlush(), streamOpen(), streamPosition(), writeBuffer(), writeLine(), and writeSetup().
void StreamInfo::notreadyError | ( | int | error_code, |
RexxObjectPtr | result = NULL |
||
) |
Raise a stream error condition, including raising a NOTREADY condition.
error_code | The Rexx error condition to raise. |
result | A NOTREADY condition result object. |
Definition at line 327 of file StreamNative.cpp.
References SysFile::clearErrors(), context, defaultResult, errorInfo, fileInfo, NULLOBJECT, state, stream_name, and StreamError.
bool StreamInfo::open | ( | int | openFlags, |
int | openMode, | ||
int | sharedFlag | ||
) |
Open the stream in the specified mode.
openFlags | Open flags as defined by the _sopen() library function |
openMode | Mode flags as defined by the _sopen() function. |
sharedFlag | Sharing flags as defined by _sopen() |
Definition at line 294 of file StreamNative.cpp.
References fileInfo, SysFile::open(), and qualified_name.
Referenced by implicitOpen(), and streamOpen().
const char * StreamInfo::openStd | ( | const char * | options | ) |
Open a standard stream, using the provided options string.
options | Open parameters, in character string form. |
Definition at line 582 of file StreamNative.cpp.
References append, fileInfo, hasNoBufferOption(), isopen, SysFile::isTransient(), nobuffer, qualified_name, read_only, SysFile::setBuffering(), SysFile::setStdErr(), SysFile::setStdIn(), SysFile::setStdOut(), state, Utilities::strCaselessCompare(), stream_name, and StreamReady.
Referenced by implicitOpen(), and streamOpen().
RexxObjectPtr StreamInfo::queryHandle | ( | ) |
Return the handle value for the stream.
Definition at line 3449 of file StreamNative.cpp.
References context, fileInfo, SysFile::getHandle(), and isopen.
Referenced by RexxMethod1().
Determine the count of lines from the file beginning to specified stream location.
current_position | The target position we're trying to convert for a char position into a line position. |
Definition at line 3022 of file StreamNative.cpp.
References SysFile::countLines(), fileInfo, and notreadyError().
Referenced by getLineReadPosition(), and getLineWritePosition().
RexxObjectPtr StreamInfo::queryStreamPosition | ( | const char * | options | ) |
process a method-level stream query call.
options | The string options that determine the requested options. |
Definition at line 3046 of file StreamNative.cpp.
References BitOr, charReadPosition, charWritePosition, context, fileInfo, getLineReadPosition(), getLineWritePosition(), SysFile::getPosition(), isopen, ME, notreadyError(), parser(), query_char_position, query_line_position, query_read_position, query_system_position, query_write_position, raiseException(), Rexx_Error_Incorrect_method, unknown_tr(), and write_only.
Referenced by RexxMethod2().
void StreamInfo::raiseException | ( | int | err | ) |
Raise an exception for the stream code.
err | The raised error code. |
Definition at line 349 of file StreamNative.cpp.
References context.
Referenced by allocateBuffer(), checkStreamType(), handleOpen(), linein(), lineout(), queryStreamPosition(), setCharReadPosition(), setCharWritePosition(), setLineReadPosition(), setLineWritePosition(), streamOpen(), and streamPosition().
void StreamInfo::raiseException | ( | int | err, |
RexxObjectPtr | sub1 | ||
) |
Raise an exception for the stream code.
err | The raised error code. |
sub1 | First error substitution value. |
Definition at line 362 of file StreamNative.cpp.
References context.
void StreamInfo::raiseException | ( | int | err, |
RexxObjectPtr | sub1, | ||
RexxObjectPtr | sub2 | ||
) |
Raise an exception for the stream code.
err | The raised error code. |
sub1 | First error substitution value. |
sub2 | Second error substitution value. |
Definition at line 376 of file StreamNative.cpp.
References context.
void StreamInfo::raiseException | ( | int | err, |
RexxObjectPtr | sub1, | ||
RexxObjectPtr | sub2, | ||
RexxObjectPtr | sub3 | ||
) |
Raise an exception for the stream code.
err | The raised error code. |
sub1 | First error substitution value. |
sub2 | Second error substitution value. |
sub3 | Third error substitution value. |
Definition at line 392 of file StreamNative.cpp.
References context.
void StreamInfo::raiseException | ( | int | err, |
RexxObjectPtr | sub1, | ||
RexxObjectPtr | sub2, | ||
RexxObjectPtr | sub3, | ||
RexxObjectPtr | sub4 | ||
) |
Raise an exception for the stream code.
err | The raised error code. |
sub1 | First error substitution value. |
sub2 | Second error substitution value. |
sub3 | Third error substitution value. |
sub4 | Fourth error substitution value. |
Definition at line 409 of file StreamNative.cpp.
References context.
void StreamInfo::raiseException | ( | int | err, |
RexxObjectPtr | sub1, | ||
RexxObjectPtr | sub2, | ||
RexxObjectPtr | sub3, | ||
RexxObjectPtr | sub4, | ||
RexxObjectPtr | sub5 | ||
) |
Raise an exception for the stream code.
err | The raised error code. |
sub1 | First error substitution value. |
sub2 | Second error substitution value. |
sub3 | Third error substitution value. |
sub4 | Fourth error substitution value. |
sub5 | Fifth error substitution value. |
Definition at line 427 of file StreamNative.cpp.
References context.
void StreamInfo::readBuffer | ( | char * | data, |
size_t | length, | ||
size_t & | bytesRead | ||
) |
Read a buffer of data from the current position for the given length. This also updates our character input position information.
data | The location to place the data. |
length | The length to read. |
bytesRead | The number of bytes actually read. |
Definition at line 1119 of file StreamNative.cpp.
References charReadPosition, fileInfo, notreadyError(), and SysFile::read().
int64_t StreamInfo::readForwardByLine | ( | int64_t | offset, |
int64_t & | current_line, | ||
int64_t & | current_position | ||
) |
Move forward the specified number of lines in the file.
offset | Number of lines to move. |
current_line | Current line position in the file. |
current_position | The current character position to read from. |
Definition at line 3258 of file StreamNative.cpp.
References fileInfo, notreadyError(), readSetup(), SysFile::seekForwardLines(), setPosition(), and stream_line_size.
Referenced by seekToVariableLine().
RexxStringObject StreamInfo::readLine | ( | char * | buffer, |
size_t | length, | ||
bool | update_position | ||
) |
Read a line from the stream
buffer | The data to write to the stream |
length | The length of the data buffer. |
update_position | determines whether the read will also update the write position. |
Definition at line 1005 of file StreamNative.cpp.
References charReadPosition, checkEof(), context, defaultResult, eof(), fileInfo, and SysFile::read().
void StreamInfo::readSetup | ( | ) |
Set up the stream for reading.
Definition at line 933 of file StreamNative.cpp.
References charReadPosition, fileInfo, SysFile::getPosition(), implicitOpen(), isopen, SysFile::isTransient(), operation_nocreate, setPosition(), state, and StreamReady.
Referenced by arrayin(), charin(), linein(), lines(), readForwardByLine(), and setLinePositions().
RexxStringObject StreamInfo::readVariableLine | ( | ) |
Read in a variable length line, searching for the eol marker for the line.
Definition at line 1361 of file StreamNative.cpp.
References SysFile::atEof(), checkEof(), context, extendBuffer(), fileInfo, getDefaultBuffer(), SysFile::gets(), and lineReadIncrement().
Referenced by linein().
void StreamInfo::resetFields | ( | ) |
Reinitialize the stream fields to default values.
Definition at line 774 of file StreamNative.cpp.
References append, binaryRecordLength, charReadPosition, charWritePosition, fileInfo, isopen, last_op_was_read, lineReadCharPosition, lineReadPosition, lineWriteCharPosition, lineWritePosition, nobuffer, opened_as_handle, qualified_name, read_only, read_write, record_based, SysFile::reset(), stdstream, stream_line_size, and write_only.
Referenced by handleOpen(), implicitOpen(), StreamInfo(), and streamOpen().
void StreamInfo::resetLinePositions | ( | ) |
Reset all line-oriented position information after an operation that will invalidate the values (for example, a charin() or charout() operation).
Definition at line 1487 of file StreamNative.cpp.
References lineReadCharPosition, lineReadPosition, and stream_line_size.
Referenced by charin(), charout(), and streamPosition().
void StreamInfo::resolveStreamName | ( | ) |
Convert a specified stream name into it's fully qualified name.
Definition at line 1044 of file StreamNative.cpp.
References qualified_name, SysFileSystem::qualifyStreamName(), and stream_name.
Referenced by getQualifiedName(), getStreamSize(), getTimeStamp(), implicitOpen(), streamExists(), and streamOpen().
int64_t StreamInfo::seekLinePosition | ( | int64_t | offset, |
int | direction, | ||
int64_t & | current_line, | ||
int64_t & | current_position | ||
) |
Perform a seek operation by line position instead of character. The seek can be relative to either the front, end, or current positions.
offset | The offset to move. This can be negative for SEEK_CUR. |
direction | The position to seek from. This can be SEEK_SET, SEEK_CUR, or SEEK_END (using the stdio.h constants directly). |
current_line | The current line position we're seeking from. This can be either the stream read or write position. This value is updated on completion of the seek. |
current_position | The current character position associated with this operation. This is also updated with the seek. |
Definition at line 2909 of file StreamNative.cpp.
References getLineSize(), and setLinePosition().
Referenced by streamPosition().
int64_t StreamInfo::seekToVariableLine | ( | int64_t | offset, |
int64_t & | current_line, | ||
int64_t & | current_position | ||
) |
Seek to a specific line position
offset | The new target position |
current_line | The starting line position |
current_position | The starting character position. |
Definition at line 3300 of file StreamNative.cpp.
References readForwardByLine().
Referenced by setLinePosition().
void StreamInfo::setCharReadPosition | ( | int64_t | position | ) |
Set the current character read position, raising a NOTREADY condition of there is a problem.
position | The target stream position. |
result | A result object returned to the caller after raising the condition. |
Definition at line 1260 of file StreamNative.cpp.
References CHAR_positional, context, eof(), raiseException(), Rexx_Error_Incorrect_method_positive, Rexx_Error_Incorrect_method_stream_type, setReadPosition(), and size().
Referenced by charin().
void StreamInfo::setCharWritePosition | ( | int64_t | position | ) |
Set the char write position.
position | The target position. |
Definition at line 1313 of file StreamNative.cpp.
References CHAR_positional, context, raiseException(), Rexx_Error_Incorrect_method_positive, Rexx_Error_Incorrect_method_stream_type, and setWritePosition().
Referenced by charout().
|
inline |
Definition at line 84 of file StreamNative.hpp.
References context, and defaultResult.
Referenced by checkStreamInfo(), and RexxMethod1().
void StreamInfo::setHandle | ( | int | fh | ) |
Set a stream to be opened with a specified handle.
fh | The input file handle. |
Definition at line 2578 of file StreamNative.cpp.
References fileInfo, SysFile::open(), and opened_as_handle.
Referenced by RexxMethod2().
int64_t StreamInfo::setLinePosition | ( | int64_t | new_line, |
int64_t & | current_line, | ||
int64_t & | current_position | ||
) |
Set a line position to an explicit line number. This takes into account differences between record and variable line streams.
new_line | The target new_line position. |
current_line | The current line position we're seeking from. |
current_position | The current character position we're seeking from. |
Definition at line 2965 of file StreamNative.cpp.
References binaryRecordLength, record_based, and seekToVariableLine().
Referenced by seekLinePosition(), setLineReadPosition(), and setLineWritePosition().
int64_t StreamInfo::setLinePositions | ( | ) |
Make sure we have valid line positions set. If we've just been doing character operations up to this point, our line positions will not be set. This may require reading the file and counting up to the positions.
Definition at line 3326 of file StreamNative.cpp.
References charReadPosition, charWritePosition, SysFile::countLines(), fileInfo, lineReadCharPosition, lineReadPosition, lineWriteCharPosition, lineWritePosition, notreadyError(), and readSetup().
void StreamInfo::setLineReadPosition | ( | int64_t | position | ) |
Set the line read position.
position | The target position. |
Definition at line 1290 of file StreamNative.cpp.
References CHAR_positional, context, lineReadCharPosition, lineReadPosition, raiseException(), Rexx_Error_Incorrect_method_positive, Rexx_Error_Incorrect_method_stream_type, setLinePosition(), and setReadPosition().
Referenced by linein().
void StreamInfo::setLineWritePosition | ( | int64_t | position | ) |
Set the line write position.
position | The target position. |
result | A result value to be used when raising a condition. |
Definition at line 1333 of file StreamNative.cpp.
References CHAR_positional, context, lineWriteCharPosition, lineWritePosition, raiseException(), Rexx_Error_Incorrect_method_positive, Rexx_Error_Incorrect_method_stream_type, setLinePosition(), and setWritePosition().
Referenced by lineout().
Move the stream position, with error checking.
position | The target position. |
newPosition | The updated final position of the move. |
Definition at line 1208 of file StreamNative.cpp.
References checkEof(), fileInfo, and SysFile::seek().
Move the stream position, with error checking.
position | The target position. |
newPosition | The updated final position of the move. |
Definition at line 1181 of file StreamNative.cpp.
References checkEof(), fileInfo, implicitOpen(), isopen, operation_nocreate, and SysFile::seek().
Referenced by countStreamLines(), handleOpen(), implicitOpen(), readForwardByLine(), readSetup(), setReadPosition(), setWritePosition(), streamOpen(), streamPosition(), and writeSetup().
void StreamInfo::setReadPosition | ( | int64_t | position | ) |
Sets the current read position for the stream. This updates charReadPosition to point to the target location.
position | The target character position (Rexx coordinates, which means 1 based rather than the native zero-based). |
Definition at line 1234 of file StreamNative.cpp.
References charReadPosition, and setPosition().
Referenced by setCharReadPosition(), and setLineReadPosition().
|
inline |
void StreamInfo::setWritePosition | ( | int64_t | position | ) |
Sets the current write position for the stream. This updates charWritePosition to point to the target location.
position | The target character position (Rexx coordinates, which means 1 based rather than the native zero-based). |
Definition at line 1246 of file StreamNative.cpp.
References charWritePosition, and setPosition().
Referenced by setCharWritePosition(), and setLineWritePosition().
int64_t StreamInfo::size | ( | ) |
Retrieve the size of the stream, if available.
Definition at line 304 of file StreamNative.cpp.
References fileInfo, and SysFile::getSize().
Referenced by chars(), checkStreamType(), getLineSize(), handleOpen(), implicitOpen(), lineout(), lines(), setCharReadPosition(), and streamOpen().
const char * StreamInfo::streamClose | ( | ) |
Close the stream.
Definition at line 2107 of file StreamNative.cpp.
References close(), isopen, state, and StreamUnknown.
Referenced by RexxMethod1().
const char * StreamInfo::streamExists | ( | ) |
Check if a stream exists. If it does, the qualified name is returned. This does not need to be an open stream for this to succeed.
Definition at line 3401 of file StreamNative.cpp.
References SysFileSystem::fileExists(), fileInfo, SysFile::isDevice(), isopen, opened_as_handle, qualified_name, resolveStreamName(), and stream_name.
Referenced by RexxMethod1().
const char * StreamInfo::streamFlush | ( | ) |
Try to flush the stream, returning the appropriate error state if there is a problem.
Definition at line 2197 of file StreamNative.cpp.
References context, SysFile::errorInfo(), fileInfo, SysFile::flush(), notreadyError(), and work.
Referenced by RexxMethod1().
const char * StreamInfo::streamOpen | ( | const char * | options | ) |
Process explicit stream open requests, handling all of the open option variations.
options | The specified option strings. |
Definition at line 2240 of file StreamNative.cpp.
References append, binaryRecordLength, BitOr, CallItem, charWritePosition, checkStreamType(), close(), context, ctrl_z, SysFile::errorInfo(), SysFileSystem::fileExists(), fileInfo, handleOpen(), IREAD_IWRITE, SysFile::isDevice(), isopen, SysFile::isTransient(), lineWriteCharPosition, lineWritePosition, ME, MEB, MI, MIB, nobuffer, notreadyError(), open(), opened_as_handle, openStd(), parser(), qualified_name, raiseException(), RDWR_CREAT, SysFile::read(), read_only, read_write, reclength_token(), record_based, resetFields(), resolveStreamName(), Rexx_Error_Incorrect_method, RX_O_APPEND, RX_O_RDONLY, RX_O_RDWR, RX_O_TRUNC, RX_O_WRONLY, RX_S_IREAD, RX_S_IWRITE, RX_SH_DENYNO, RX_SH_DENYRD, RX_SH_DENYRW, RX_SH_DENYWR, SetBool, SysFile::setBuffering(), SetItem, setPosition(), size(), state, stdstream, StreamReady, unknown_tr(), work, WR_CREAT, and write_only.
Referenced by RexxMethod2().
int64_t StreamInfo::streamPosition | ( | const char * | options | ) |
Set the stream position as determined by the options.
options | The stream command string for positioning. |
Definition at line 2623 of file StreamNative.cpp.
References append, BitOr, CHAR_positional, charReadPosition, charWritePosition, context, implicitOpen(), isopen, last_op_was_read, lineReadCharPosition, lineReadPosition, lineWriteCharPosition, lineWritePosition, ME, MEB, notreadyError(), operation_nocreate, operation_read, operation_write, parser(), position_by_char, position_by_line, position_offset(), raiseException(), read_only, read_write, resetLinePositions(), Rexx_Error_Incorrect_method, Rexx_Error_Incorrect_method_noarg, Rexx_Error_Incorrect_method_stream_type, seekLinePosition(), SetBool, SetItem, setPosition(), state, stream_line_size, StreamReady, and write_only.
Referenced by RexxMethod2().
void StreamInfo::writeBuffer | ( | const char * | data, |
size_t | length, | ||
size_t & | bytesWritten | ||
) |
Write a buffer of data to the stream, raising an notready condition if it fails.
data | Pointer to the first byte of data |
length | length of the data buffer |
bytesWritten | Actual number of bytes written to the stream. |
Definition at line 1061 of file StreamNative.cpp.
References charWritePosition, fileInfo, SysFile::getPosition(), notreadyError(), and SysFile::write().
Referenced by charout(), completeLine(), and writeFixedLine().
void StreamInfo::writeFixedLine | ( | const char * | data, |
size_t | length | ||
) |
Write out a fixed record line, padding with blanks if the line is not of the correct size.
data | The data to write. |
length | length of the buffered data. |
Definition at line 1157 of file StreamNative.cpp.
References binaryRecordLength, charWritePosition, completeLine(), and writeBuffer().
Referenced by lineout().
void StreamInfo::writeLine | ( | const char * | data, |
size_t | length, | ||
size_t & | bytesWritten | ||
) |
Write a terminated line of data to the stream, raising an notready condition if it fails.
data | Pointer to the first byte of data |
length | length of the data buffer |
bytesWritten | Actual number of bytes written to the stream. |
Definition at line 1090 of file StreamNative.cpp.
References charWritePosition, fileInfo, SysFile::getPosition(), notreadyError(), and SysFile::putLine().
Referenced by lineout().
void StreamInfo::writeSetup | ( | ) |
Set up the stream for a write operation.
Definition at line 961 of file StreamNative.cpp.
References append, charWritePosition, fileInfo, SysFile::getPosition(), implicitOpen(), isopen, notreadyError(), operation_write, read_only, setPosition(), state, and StreamReady.
|
friend |
Definition at line 67 of file StreamNative.hpp.
|
protected |
Definition at line 195 of file StreamNative.hpp.
Referenced by lineout(), openStd(), resetFields(), streamOpen(), streamPosition(), and writeSetup().
|
protected |
Definition at line 184 of file StreamNative.hpp.
Referenced by arrayin(), checkStreamType(), getLineReadPosition(), getLineSize(), getLineWritePosition(), handleOpen(), linein(), lineout(), lines(), resetFields(), setLinePosition(), streamOpen(), and writeFixedLine().
|
protected |
Definition at line 186 of file StreamNative.hpp.
Referenced by allocateBuffer(), extendBuffer(), freeBuffer(), getDefaultBuffer(), and StreamInfo().
|
protected |
Definition at line 187 of file StreamNative.hpp.
Referenced by allocateBuffer(), extendBuffer(), freeBuffer(), getDefaultBuffer(), and StreamInfo().
|
protected |
Definition at line 175 of file StreamNative.hpp.
Referenced by arrayin(), chars(), getLineReadPosition(), linein(), lineReadIncrement(), lines(), queryStreamPosition(), readBuffer(), readLine(), readSetup(), resetFields(), setLinePositions(), setReadPosition(), and streamPosition().
|
protected |
Definition at line 176 of file StreamNative.hpp.
Referenced by getLineWritePosition(), handleOpen(), implicitOpen(), lineout(), queryStreamPosition(), resetFields(), setLinePositions(), setWritePosition(), streamOpen(), streamPosition(), writeBuffer(), writeFixedLine(), writeLine(), and writeSetup().
|
protected |
Definition at line 168 of file StreamNative.hpp.
Referenced by appendVariableLine(), arrayin(), charin(), charout(), close(), eof(), getDescription(), getStreamSize(), implicitOpen(), linein(), lineout(), notreadyError(), queryHandle(), queryStreamPosition(), raiseException(), readLine(), readVariableLine(), setCharReadPosition(), setCharWritePosition(), setContext(), setLineReadPosition(), setLineWritePosition(), streamFlush(), streamOpen(), and streamPosition().
|
protected |
Definition at line 170 of file StreamNative.hpp.
Referenced by charout(), close(), eof(), implicitOpen(), notreadyError(), readLine(), and setContext().
|
protected |
Definition at line 183 of file StreamNative.hpp.
Referenced by getDescription(), and notreadyError().
|
protected |
Definition at line 189 of file StreamNative.hpp.
Referenced by appendVariableLine(), chars(), checkEof(), checkStreamType(), close(), countStreamLines(), getStreamSize(), getTimeStamp(), handleOpen(), implicitOpen(), lineReadIncrement(), lines(), notreadyError(), open(), openStd(), queryHandle(), queryLinePosition(), queryStreamPosition(), readBuffer(), readForwardByLine(), readLine(), readSetup(), readVariableLine(), resetFields(), setHandle(), setLinePositions(), setPosition(), size(), streamExists(), streamFlush(), streamOpen(), writeBuffer(), writeLine(), and writeSetup().
|
protected |
Definition at line 202 of file StreamNative.hpp.
Referenced by chars(), close(), getStreamSize(), getStreamType(), getTimeStamp(), handleOpen(), implicitOpen(), lines(), openStd(), queryHandle(), queryStreamPosition(), readSetup(), resetFields(), setPosition(), streamClose(), streamExists(), streamOpen(), streamPosition(), and writeSetup().
|
protected |
Definition at line 198 of file StreamNative.hpp.
Referenced by lineReadIncrement(), resetFields(), and streamPosition().
|
protected |
Definition at line 179 of file StreamNative.hpp.
Referenced by getLineReadPosition(), lineReadIncrement(), resetFields(), resetLinePositions(), setLinePositions(), setLineReadPosition(), and streamPosition().
|
protected |
Definition at line 177 of file StreamNative.hpp.
Referenced by getLineReadPosition(), lineReadIncrement(), lines(), resetFields(), resetLinePositions(), setLinePositions(), setLineReadPosition(), and streamPosition().
|
protected |
Definition at line 180 of file StreamNative.hpp.
Referenced by getLineWritePosition(), handleOpen(), implicitOpen(), lineout(), resetFields(), setLinePositions(), setLineWritePosition(), streamOpen(), and streamPosition().
|
protected |
Definition at line 178 of file StreamNative.hpp.
Referenced by getLineWritePosition(), handleOpen(), implicitOpen(), lineout(), resetFields(), setLinePositions(), setLineWritePosition(), streamOpen(), and streamPosition().
|
protected |
Definition at line 196 of file StreamNative.hpp.
Referenced by handleOpen(), openStd(), resetFields(), and streamOpen().
|
protected |
Definition at line 199 of file StreamNative.hpp.
Referenced by implicitOpen(), resetFields(), setHandle(), streamExists(), and streamOpen().
|
protected |
Definition at line 174 of file StreamNative.hpp.
Referenced by getQualifiedName(), getStreamSize(), getTimeStamp(), handleOpen(), open(), openStd(), resetFields(), resolveStreamName(), streamExists(), and streamOpen().
|
protected |
Definition at line 192 of file StreamNative.hpp.
Referenced by chars(), handleOpen(), implicitOpen(), lines(), openStd(), resetFields(), streamOpen(), streamPosition(), and writeSetup().
|
protected |
Definition at line 194 of file StreamNative.hpp.
Referenced by chars(), handleOpen(), implicitOpen(), lines(), resetFields(), streamOpen(), and streamPosition().
|
protected |
Definition at line 201 of file StreamNative.hpp.
Referenced by arrayin(), checkStreamType(), getLineReadPosition(), getLineSize(), getLineWritePosition(), handleOpen(), linein(), lineout(), lines(), resetFields(), setLinePosition(), and streamOpen().
|
protected |
Definition at line 169 of file StreamNative.hpp.
|
protected |
Definition at line 182 of file StreamNative.hpp.
Referenced by close(), eof(), getDescription(), getState(), handleOpen(), implicitOpen(), notreadyError(), openStd(), readSetup(), streamClose(), StreamInfo(), streamOpen(), streamPosition(), and writeSetup().
|
protected |
Definition at line 197 of file StreamNative.hpp.
Referenced by implicitOpen(), resetFields(), setStandard(), and streamOpen().
|
protected |
Definition at line 181 of file StreamNative.hpp.
Referenced by countStreamLines(), lineout(), lines(), readForwardByLine(), resetFields(), resetLinePositions(), and streamPosition().
|
protected |
Definition at line 172 of file StreamNative.hpp.
Referenced by eof(), handleOpen(), notreadyError(), openStd(), resolveStreamName(), streamExists(), and StreamInfo().
|
protected |
Definition at line 200 of file StreamNative.hpp.
|
protected |
Definition at line 193 of file StreamNative.hpp.
Referenced by handleOpen(), implicitOpen(), queryStreamPosition(), resetFields(), streamOpen(), and streamPosition().