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

An abstract interface for performing both unformatted and formatted output operations. More...

Public Member Functions

void Close ()
 Flushes any unwritten output and closes the stream.
void Flush ()
 Flushes any unwritten output.
OutputStream * PrintStr (const char *str)
 Writes a string of characters to the output stream. Writing stops at the first null character.
OutputStream * PrintB (bool value)
 Writes a formatted Boolean value to the output stream.
OutputStream * PrintC (char value)
 Writes a single character to the output stream.
OutputStream * PrintI (int value)
 Writes a formatted int to the output stream.
OutputStream * PrintUI (uint value)
 Writes a formatted uint to the output stream.
OutputStream * PrintL (long value)
 Writes a formatted long to the output stream.
OutputStream * PrintUL (ulong value)
 Writes a formatted ulong to the output stream.
OutputStream * PrintF (float value)
 Writes a formatted float to the output stream.
OutputStream * PrintD (double value)
 Writes a formatted double to the output stream.
OutputStream * Put (uchar byte)
 Writes a single unformatted byte to the output stream.
OutputStream * Write (void *bytes, uint numBytes)
 Writes an array of unformatted bytes to the output stream.
int GetFlags () const
 Returns the stream's current format flags as a bitmask of values from the IO::Flags enum.
OutputStream * SetFlags (int flags)
 Enables the format flags in the given bitmask of values from the IO::Flags enum.
OutputStream * UnsetFlags (int flags)
 Disables the format flags in the given bitmask of values from the IO::Flags enum.
OutputStream * ClearFlags ()
 Disables all of the format flags.
int GetPrecision () const
 Returns the precision used when writing floating-point values. The default is 6.
OutputStream * SetPrecision (int precision)
 Assigns the precision used when writing floating-point values.
int GetWidth () const
 Returns the current minimum field width.
OutputStream * SetWidth (int width)
 Assigns the minimum field width of the next formatted output operation.
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 output operation.
void ClearError ()
 Clears the error flag.

Detailed Description

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

Except for Close, using a stream after it has been closed raises an error.

Member Function Documentation

◆ AddOffset()

void Bond::OutputStream::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::OutputStream::ClearError ( )

Clears the error flag.

◆ ClearFlags()

OutputStream * Bond::OutputStream::ClearFlags ( )

Disables all of the format flags.

The format flags modify how the stream formats output.

Returns
The stream on which this function was called.

◆ Close()

void Bond::OutputStream::Close ( )

Flushes any unwritten output and closes the stream.

Closing a stream that is already closed has no effect. Closing a stream does not free it.

◆ Flush()

void Bond::OutputStream::Flush ( )

Flushes any unwritten output.

◆ GetEndPosition()

int Bond::OutputStream::GetEndPosition ( ) const

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

◆ GetFlags()

int Bond::OutputStream::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 formats output.

◆ GetPosition()

int Bond::OutputStream::GetPosition ( ) const

Returns the stream's current position measured in bytes.

◆ GetPrecision()

int Bond::OutputStream::GetPrecision ( ) const

Returns the precision used when writing floating-point values. The default is 6.

◆ GetWidth()

int Bond::OutputStream::GetWidth ( ) const

Returns the current minimum field width.

The width is reset to 0 by every formatted output operation.

◆ HasError()

bool Bond::OutputStream::HasError ( ) const

Returns whether an error has occurred during an output operation.

◆ IsEof()

bool Bond::OutputStream::IsEof ( ) const

Returns whether the end of the stream has been reached.

◆ PrintB()

OutputStream * Bond::OutputStream::PrintB ( bool value)

Writes a formatted Boolean value to the output stream.

If the IO::BoolAlpha flag is set, the values true and false are written as the strings "true" and "false" respectively, otherwise they are written as the integers 1 and 0 as by PrintI.

Parameters
valueThe Boolean value to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintC()

OutputStream * Bond::OutputStream::PrintC ( char value)

Writes a single character to the output stream.

The character is padded to the field width (see SetWidth) with spaces, on the left, or on the right if the IO::Left flag is set.

Parameters
valueThe character to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintD()

OutputStream * Bond::OutputStream::PrintD ( double value)

Writes a formatted double to the output stream.

If the IO::Fixed or IO::Scientific flag is set, the number is written in decimal notation or scientific notation respectively, with the precision (see SetPrecision) giving the number of digits after the decimal point. If neither flag is set, the precision gives the number of significant digits, trailing zeros are removed, and the number is written in scientific notation if its exponent is less than -4 or greater than or equal to the precision, otherwise in decimal notation. The value is padded to the field width (see SetWidth). If the IO::Zero flag is set, it is zero padded to the left. If the IO::Left flag is set, the value is left-justified instead of right-justified, and padded with spaces. If the IO::ShowPoint flag is set, a decimal point is always written and trailing zeros are kept.

Parameters
valueThe floating-point number to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintF()

OutputStream * Bond::OutputStream::PrintF ( float value)

Writes a formatted float to the output stream.

If the IO::Fixed or IO::Scientific flag is set, the number is written in decimal notation or scientific notation respectively, with the precision (see SetPrecision) giving the number of digits after the decimal point. If neither flag is set, the precision gives the number of significant digits, trailing zeros are removed, and the number is written in scientific notation if its exponent is less than -4 or greater than or equal to the precision, otherwise in decimal notation. The value is padded to the field width (see SetWidth). If the IO::Zero flag is set, it is zero padded to the left. If the IO::Left flag is set, the value is left-justified instead of right-justified, and padded with spaces. If the IO::ShowPoint flag is set, a decimal point is always written and trailing zeros are kept.

Parameters
valueThe floating-point number to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintI()

OutputStream * Bond::OutputStream::PrintI ( int value)

Writes a formatted int to the output stream.

If the IO::Hex or IO::Oct flag is set, the integer is written in base 16 or 8 respectively, otherwise it is written in base 10. If the IO::ShowBase flag is set in addition to IO::Hex, the string "0x" is written before a non-zero number. If the IO::ShowBase flag is set in addition to IO::Oct, the number is written with a leading "0". The value is padded to the field width (see SetWidth). If the IO::Zero flag is set, it is zero padded to the left. If the IO::Left flag is set, the value is left-justified instead of right-justified, and padded with spaces.

Parameters
valueThe integer to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintL()

OutputStream * Bond::OutputStream::PrintL ( long value)

Writes a formatted long to the output stream.

If the IO::Hex or IO::Oct flag is set, the integer is written in base 16 or 8 respectively, otherwise it is written in base 10. If the IO::ShowBase flag is set in addition to IO::Hex, the string "0x" is written before a non-zero number. If the IO::ShowBase flag is set in addition to IO::Oct, the number is written with a leading "0". The value is padded to the field width (see SetWidth). If the IO::Zero flag is set, it is zero padded to the left. If the IO::Left flag is set, the value is left-justified instead of right-justified, and padded with spaces.

Parameters
valueThe integer to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintStr()

OutputStream * Bond::OutputStream::PrintStr ( const char * str)

Writes a string of characters to the output stream. Writing stops at the first null character.

The string is padded to the field width (see SetWidth) with spaces, on the left, or on the right if the IO::Left flag is set.

Parameters
strPointer to a string of characters to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintUI()

OutputStream * Bond::OutputStream::PrintUI ( uint value)

Writes a formatted uint to the output stream.

If the IO::Hex or IO::Oct flag is set, the integer is written in base 16 or 8 respectively, otherwise it is written in base 10. If the IO::ShowBase flag is set in addition to IO::Hex, the string "0x" is written before a non-zero number. If the IO::ShowBase flag is set in addition to IO::Oct, the number is written with a leading "0". The value is padded to the field width (see SetWidth). If the IO::Zero flag is set, it is zero padded to the left. If the IO::Left flag is set, the value is left-justified instead of right-justified, and padded with spaces.

Parameters
valueThe integer to be written to the stream.
Returns
The stream on which this function was called.

◆ PrintUL()

OutputStream * Bond::OutputStream::PrintUL ( ulong value)

Writes a formatted ulong to the output stream.

If the IO::Hex or IO::Oct flag is set, the integer is written in base 16 or 8 respectively, otherwise it is written in base 10. If the IO::ShowBase flag is set in addition to IO::Hex, the string "0x" is written before a non-zero number. If the IO::ShowBase flag is set in addition to IO::Oct, the number is written with a leading "0". The value is padded to the field width (see SetWidth). If the IO::Zero flag is set, it is zero padded to the left. If the IO::Left flag is set, the value is left-justified instead of right-justified, and padded with spaces.

Parameters
valueThe integer to be written to the stream.
Returns
The stream on which this function was called.

◆ Put()

OutputStream * Bond::OutputStream::Put ( uchar byte)

Writes a single unformatted byte to the output stream.

Parameters
byteThe byte to be written to the stream.
Returns
The stream on which this function was called.

◆ SetFlags()

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

Enables 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 formats output.

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

◆ SetPosition()

void Bond::OutputStream::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::OutputStream::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.

◆ SetPrecision()

OutputStream * Bond::OutputStream::SetPrecision ( int precision)

Assigns the precision used when writing floating-point values.

If the IO::Fixed or IO::Scientific flag is set, the precision is the number of digits written after the decimal point, otherwise it is the maximum number of significant digits. Unlike the field width, the precision remains in effect until it is changed.

Parameters
precisionThe new precision.
Returns
The stream on which this function was called.

◆ SetWidth()

OutputStream * Bond::OutputStream::SetWidth ( int width)

Assigns the minimum field width of the next formatted output operation.

The minimum field width specifies the minimum number of characters to be written in a formatted output operation. If the number of characters in the written value is less than the field width, it is padded to the left, or to the right if the IO::Left flag is set. It is padded with spaces, except for numbers written with the IO::Zero flag set. The width applies only to the next formatted output operation, after which it is reset to 0.

Parameters
widthThe new minimum field width.
Returns
The stream on which this function was called.

◆ UnsetFlags()

OutputStream * Bond::OutputStream::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 formats output.

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

◆ Write()

OutputStream * Bond::OutputStream::Write ( void * bytes,
uint numBytes )

Writes an array of unformatted bytes to the output stream.

Parameters
bytesPointer to the array of bytes to be written to the stream.
numBytesThe number of bytes to be written.
Returns
The stream on which this function was called.

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