Evo C++ Library v0.5.1
Public Member Functions | Protected Attributes | List of all members
IoBase Struct Reference

#include <evo/iobase.h>

Inheritance diagram for IoBase:
Inheritance graph
[legend]

Detailed Description

Base binary stream interface.

Public Member Functions

 IoBase ()
 Constructor. More...
 
virtual ~IoBase ()
 Destructor. More...
 
Error error () const
 Get error code from last operation. More...
 
bool excep () const
 Get whether exceptions are enabled. More...
 
void excep (bool val)
 Set whether exceptions are enabled. More...
 
virtual bool flush ()
 Flush any pending output in stream write buffer, if buffered. More...
 
virtual bool isopen () const
 Get whether stream is open. More...
 
 operator SafeBoolType () const
 Safe (explicit) evaluation as bool type. More...
 
bool operator! () const
 Negation operator checks whether an error was set by a previous operation. More...
 
virtual ulong readbin (void *buf, ulong size)
 Read binary input from stream. More...
 
virtual ulong writebin (const void *buf, ulong size)
 Write binary output to stream. More...
 

Protected Attributes

Error error_
 Last error code. More...
 
bool excep_
 Whether to throw exceptions. More...
 

Constructor & Destructor Documentation

◆ IoBase()

IoBase ( )
inline

Constructor.

◆ ~IoBase()

virtual ~IoBase ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ error()

Error error ( ) const
inline

Get error code from last operation.

Returns
Error code, ENone for success (no error)

◆ excep() [1/2]

bool excep ( ) const
inline

Get whether exceptions are enabled.

Returns
Whether exceptions enabled

◆ excep() [2/2]

void excep ( bool  val)
inline

Set whether exceptions are enabled.

Parameters
valWhether to enable exceptions

◆ flush()

virtual bool flush ( )
inlinevirtual

Flush any pending output in stream write buffer, if buffered.

  • This is a no-op if writes aren't buffered
  • Call error() to check error code
Returns
Whether successful, false on error

Reimplemented in Stream< T >, Stream< IoFile >, Stream< IoSocket >, StreamOut< T >, and StreamOut< IoFile >.

◆ isopen()

virtual bool isopen ( ) const
inlinevirtual

Get whether stream is open.

Returns
Whether open

Reimplemented in Stream< T >, Stream< IoFile >, Stream< IoSocket >, StreamOut< T >, StreamOut< IoFile >, StreamIn< T >, and StreamIn< IoFile >.

◆ operator SafeBoolType()

operator SafeBoolType ( ) const
inlineinherited

Safe (explicit) evaluation as bool type.

  • This is called when object is directly evaluated as a bool, and is equivalent to: !operator!()
  • See SafeBool

◆ operator!()

bool operator! ( ) const
inline

Negation operator checks whether an error was set by a previous operation.

  • Call error() to get last error code
  • Alternatively, use SafeBool evaluation to check whether previous operations were successful
Returns
Whether last operation set an error

◆ readbin()

virtual ulong readbin ( void *  buf,
ulong  size 
)
inlinevirtual

Read binary input from stream.

  • This does a binary read – no conversion on newlines
  • Depending on the stream type, this may:
    • be a blocking call
    • read at least 1 byte, but less than requested
    • return a read error, some stream types may timeout
  • Call error() to check error code
  • This never throws any exception
Parameters
bufBuffer to store data read
sizeSize to read
Returns
Bytes read and stored in buf, 0 if end-of-stream or error

Reimplemented in SocketCast, Stream< T >, Stream< IoFile >, Stream< IoSocket >, StreamIn< T >, and StreamIn< IoFile >.

◆ writebin()

virtual ulong writebin ( const void *  buf,
ulong  size 
)
inlinevirtual

Write binary output to stream.

  • This does a binary write – no conversion on newlines
  • Depending on the stream type, this may:
    • be a blocking call
    • write at least 1 byte, but less than requested
    • return a write error, some stream types may timeout
  • Call error() to check error code
Parameters
bufData to write
sizeSize to write
Returns
Bytes written, 0 on error

Reimplemented in SocketCast, Stream< T >, Stream< IoFile >, Stream< IoSocket >, StreamOut< T >, and StreamOut< IoFile >.

Member Data Documentation

◆ error_

Error error_
protected

Last error code.

◆ excep_

bool excep_
protected

Whether to throw exceptions.


The documentation for this struct was generated from the following file: