|
Bond 0.9
Bond Standard Library API Documentation
|
An abstract interface for performing both unformatted and formatted input operations. More...
Public Member Functions | |
| void | Close () |
| Discards any unread input and closes the stream. | |
| void | ScanStr (char *str, uint bufferSize) |
| Reads a string of characters from the input stream into a character buffer. | |
| bool | ScanB () |
| Reads and returns a formatted Boolean value from the input stream. | |
| char | ScanC () |
| Reads and returns a single character from the input stream. | |
| int | ScanI () |
| Reads and returns a formatted integer as an int from the input stream. | |
| uint | ScanUI () |
| Reads and returns a formatted unsigned integer as a uint from the input stream. | |
| long | ScanL () |
| Reads and returns a formatted integer as a long from the input stream. | |
| ulong | ScanUL () |
| Reads and returns a formatted unsigned integer as a ulong from the input stream. | |
| float | ScanF () |
| Reads and returns a formatted floating-point number as a float from the input stream. | |
| double | ScanD () |
| Reads and returns a formatted floating-point number as a double from the input stream. | |
| int | Get () |
| Reads and returns a single unformatted byte from the input stream. | |
| uint | Read (void *bytes, uint numBytes) |
| Attempts to read the specified number of unformatted bytes into the given buffer. | |
| int | GetFlags () const |
| Returns the stream's current format flags as a bitmask of values from the IO::Flags enum. | |
| InputStream * | SetFlags (int flags) |
| Enables the format flags in the given bitmask of values from the IO::Flags enum. | |
| InputStream * | UnsetFlags (int flags) |
| Disables the format flags in the given bitmask of values from the IO::Flags enum. | |
| InputStream * | ClearFlags () |
| Disables all of the format flags. | |
| int | GetPosition () const |
| Returns the stream's current position measured in bytes. | |
| int | GetEndPosition () const |
| Returns the position of the stream's end measured in bytes. | |
| void | SetPosition (int offset) |
| Sets the stream's position relative to its beginning measured in bytes. | |
| void | SetPositionFromEnd (int offset) |
| Sets the stream's position relative to its end measured in bytes. | |
| void | AddOffset (int offset) |
| Moves the stream by the specified number of bytes relative to its current position. | |
| bool | IsEof () const |
| Returns whether the end of the stream has been reached. | |
| bool | HasError () const |
| Returns whether an I/O error has occurred during an input operation. | |
| void | ClearError () |
| Clears the error flag. | |
An abstract interface for performing both unformatted and formatted input operations.
Except for Close, using a stream after it has been closed raises an error.
| void Bond::InputStream::AddOffset | ( | int | offset | ) |
Moves the stream by the specified number of bytes relative to its current position.
| offset | The number of bytes by which the stream is repositioned. |
| void Bond::InputStream::ClearError | ( | ) |
Clears the error flag.
| InputStream * Bond::InputStream::ClearFlags | ( | ) |
Disables all of the format flags.
The format flags modify how the stream interprets input.
| void Bond::InputStream::Close | ( | ) |
Discards any unread input and closes the stream.
Closing a stream that is already closed has no effect. Closing a stream does not free it.
| int Bond::InputStream::Get | ( | ) |
Reads and returns a single unformatted byte from the input stream.
If the end of the stream has been reached and there is no data to return, the value IO::Eof is returned.
| int Bond::InputStream::GetEndPosition | ( | ) | const |
Returns the position of the stream's end measured in bytes.
| int Bond::InputStream::GetFlags | ( | ) | const |
Returns the stream's current format flags as a bitmask of values from the IO::Flags enum.
The format flags modify how the stream interprets input.
| int Bond::InputStream::GetPosition | ( | ) | const |
Returns the stream's current position measured in bytes.
| bool Bond::InputStream::HasError | ( | ) | const |
Returns whether an I/O error has occurred during an input operation.
Input that does not match the requested format is not an error.
| bool Bond::InputStream::IsEof | ( | ) | const |
Returns whether the end of the stream has been reached.
| uint Bond::InputStream::Read | ( | void * | bytes, |
| uint | numBytes ) |
Attempts to read the specified number of unformatted bytes into the given buffer.
Fewer bytes are read if the end of the stream is reached.
| bytes | The buffer into which the read bytes are stored. |
| numBytes | The requested number of bytes to be read. |
| bool Bond::InputStream::ScanB | ( | ) |
Reads and returns a formatted Boolean value from the input stream.
If the IO::BoolAlpha flag is set, an attempt is made to read the string "true" or "false", otherwise an integer is read, in base 16 if it begins with 0x, in base 8 if it begins with 0, or in base 10 otherwise. If the string "true" or a non-zero value is read, true is returned. If no valid input can be read, false is returned and the stream is left at the first character that did not match.
| char Bond::InputStream::ScanC | ( | ) |
Reads and returns a single character from the input stream.
Whitespace is skipped first if the IO::SkipWhite flag is set. If the end of the stream has been reached, 0 is returned.
| double Bond::InputStream::ScanD | ( | ) |
Reads and returns a formatted floating-point number as a double from the input stream.
Leading whitespace is skipped. If no floating-point number can be read, 0 is returned and the stream is left at the first character that did not match.
| float Bond::InputStream::ScanF | ( | ) |
Reads and returns a formatted floating-point number as a float from the input stream.
Leading whitespace is skipped. If no floating-point number can be read, 0 is returned and the stream is left at the first character that did not match.
| int Bond::InputStream::ScanI | ( | ) |
Reads and returns a formatted integer as an int from the input stream.
If the IO::Dec, IO::Hex or IO::Oct flag is set, the integer is read in base 10, 16 or 8 respectively, checked in that order. If none of those flags are set, the integer is read in base 16 if it begins with 0x, in base 8 if it begins with 0, or in base 10 otherwise. Leading whitespace is skipped. If no integer can be read, 0 is returned and the stream is left at the first character that did not match.
| long Bond::InputStream::ScanL | ( | ) |
Reads and returns a formatted integer as a long from the input stream.
If the IO::Dec, IO::Hex or IO::Oct flag is set, the integer is read in base 10, 16 or 8 respectively, checked in that order. If none of those flags are set, the integer is read in base 16 if it begins with 0x, in base 8 if it begins with 0, or in base 10 otherwise. Leading whitespace is skipped. If no integer can be read, 0 is returned and the stream is left at the first character that did not match.
| void Bond::InputStream::ScanStr | ( | char * | str, |
| uint | bufferSize ) |
Reads a string of characters from the input stream into a character buffer.
Leading whitespace is skipped. The scan stops at the first whitespace character or when the buffer is full. The string is null terminated. At most bufferSize-1 characters are read to leave space for the null terminator. If the end of the stream is reached before any character is read, the buffer is left unchanged.
| str | Pointer to a character buffer where characters are stored. |
| bufferSize | Length of the buffer pointed to by str. It must be at least 1. |
| uint Bond::InputStream::ScanUI | ( | ) |
Reads and returns a formatted unsigned integer as a uint from the input stream.
If the IO::Dec, IO::Hex or IO::Oct flag is set, the integer is read in base 10, 16 or 8 respectively, checked in that order. If none of those flags are set, the integer is read in base
| ulong Bond::InputStream::ScanUL | ( | ) |
Reads and returns a formatted unsigned integer as a ulong from the input stream.
If the IO::Dec, IO::Hex or IO::Oct flag is set, the integer is read in base 10, 16 or 8 respectively, checked in that order. If none of those flags are set, the integer is read in base 16 if it begins with 0x, in base 8 if it begins with 0, or in base 10 otherwise. Leading whitespace is skipped. If no integer can be read, 0 is returned and the stream is left at the first character that did not match.
| InputStream * Bond::InputStream::SetFlags | ( | int | flags | ) |
| void Bond::InputStream::SetPosition | ( | int | offset | ) |
Sets the stream's position relative to its beginning measured in bytes.
| offset | The number of bytes from the beginning to which the stream is repositioned. |
| void Bond::InputStream::SetPositionFromEnd | ( | int | offset | ) |
Sets the stream's position relative to its end measured in bytes.
| offset | The number of bytes from the end to which the stream is repositioned. |
| InputStream * Bond::InputStream::UnsetFlags | ( | int | flags | ) |
Disables the format flags in the given bitmask of values from the IO::Flags enum.
All other flags are left untouched. The format flags modify how the stream interprets input.
| flags | The bitmask of flags from the IO::Flags enum to disable. |