Bond 0.9
Bond Standard Library API Documentation
Loading...
Searching...
No Matches
Bond::InputStream Struct Reference

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.
InputStreamSetFlags (int flags)
 Enables the format format flags in the given bitmask of values from the IO::Flags enum if they are not already enabled.
InputStreamUnsetFlags (int flags)
 Disables the format format flags in the given bitmask of values from the IO::Flags enum if they are not already disabled.
InputStreamClearFlags ()
 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 error has occurred during an input operation.
void ClearError ()
 Clears the error flag.

Detailed Description

An abstract interface for performing both unformatted and formatted input operations.

Member Function Documentation

◆ AddOffset()

void Bond::InputStream::AddOffset ( int offset)

Moves the stream by the specified number of bytes relative to its current position.

Parameters
offsetThe number of bytes by which the stream is repositioned.

◆ ClearError()

void Bond::InputStream::ClearError ( )

Clears the error flag.

◆ ClearFlags()

InputStream * Bond::InputStream::ClearFlags ( )

Disables all of the format flags.

The format flags modify how the stream interprets input.

Returns
The stream on which this function was called.

◆ Close()

void Bond::InputStream::Close ( )

Discards any unread input and closes the stream.

◆ Get()

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.

◆ GetEndPosition()

int Bond::InputStream::GetEndPosition ( ) const

Returns the position of the stream's end measured in bytes.

◆ GetFlags()

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.

◆ GetPosition()

int Bond::InputStream::GetPosition ( ) const

Returns the stream's current position measured in bytes.

◆ HasError()

bool Bond::InputStream::HasError ( ) const

Returns whether an error has occurred during an input operation.

◆ IsEof()

bool Bond::InputStream::IsEof ( ) const

Returns whether the end of the stream has been reached.

◆ Read()

uint Bond::InputStream::Read ( void * bytes,
uint numBytes )

Attempts to read the specified number of unformatted bytes into the given buffer.

Fewer bytes may be read if the end of the stream is reached or the stream is closed.

Parameters
bytesThe buffer into which the read bytes are stored.
numBytesThe requested number of bytes to be read.
Returns
The number of bytes read.

◆ ScanB()

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 strings "true" or "false", otherwise an integer is read. If a non-zero value, or the string "true" is read, the value true is returned. If no input that could be interpreted as a bool is read, HasError() returns true.

◆ ScanC()

char Bond::InputStream::ScanC ( )

Reads and returns a single character from the input stream.

◆ ScanD()

double Bond::InputStream::ScanD ( )

Reads and returns a formatted floating-point number as a double from the input stream.

If no input that could be interpreted as a floating-point number is read, HasError() returns true.

◆ ScanF()

float Bond::InputStream::ScanF ( )

Reads and returns a formatted floating-point number as a float from the input stream.

If no input that could be interpreted as a floating-point number is read, HasError() returns true.

◆ ScanI()

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. 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. If no input that could be interpreted as an integer is read, HasError() returns true.

◆ ScanL()

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. 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. If no input that could be interpreted as an integer is read, HasError() returns true.

◆ ScanStr()

void Bond::InputStream::ScanStr ( char * str,
uint bufferSize )

Reads a string of characters from the input stream into a character buffer.

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.

Parameters
strPointer to a character buffer where characters are stored.
bufferSizeLength of the buffer pointed to by str.

◆ ScanUI()

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. 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. If no input that could be interpreted as an integer is read, HasError() returns true.

◆ ScanUL()

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. 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. If no input that could be interpreted as an integer is read, HasError() returns true.

◆ SetFlags()

InputStream * Bond::InputStream::SetFlags ( int flags)

Enables the format format flags in the given bitmask of values from the IO::Flags enum if they are not already enabled.

All other flags are left untouched. The format flags modify how the stream interprets input.

Parameters
flagsThe bitmask of flags from the IO::Flags enum to enable.
Returns
The stream on which this function was called.

◆ SetPosition()

void Bond::InputStream::SetPosition ( int offset)

Sets the stream's position relative to its beginning measured in bytes.

Parameters
offsetThe number of bytes from the beginning to which the stream is repositioned.

◆ SetPositionFromEnd()

void Bond::InputStream::SetPositionFromEnd ( int offset)

Sets the stream's position relative to its end measured in bytes.

Parameters
offsetThe number of bytes from the end to which the stream is repositioned.

◆ UnsetFlags()

InputStream * Bond::InputStream::UnsetFlags ( int flags)

Disables the format format flags in the given bitmask of values from the IO::Flags enum if they are not already disabled.

All other flags are left untouched. The format flags modify how the stream interprets input.

Parameters
flagsThe bitmask of flags from the IO::Flags enum to disable.
Returns
The stream on which this function was called.

The documentation for this struct was generated from the following file:
  • build/libdoc/io.bond