libcommonc++  0.7
SerialPort Class Reference

A class representing a serial communications port. More...

#include <SerialPort.h++>

Inheritance diagram for SerialPort:
Collaboration diagram for SerialPort:

Public Types

enum  BaudRate {
  BaudOther = -1, Baud300 = 300, Baud600 = 600, Baud1200 = 1200,
  Baud1800 = 1800, Baud2400 = 2400, Baud4800 = 4800, Baud9600 = 9600,
  Baud19200 = 19200, Baud38400 = 38400, Baud57600 = 57600, Baud115200 = 115200,
  Baud230400 = 230400
}
 Baud rates. More...
 
enum  Parity {
  ParityOther = -1, ParityNone, ParityOdd, ParityEven,
  ParityMark, ParitySpace
}
 Parity types. More...
 
enum  DataBits {
  DataBitsOther = -1, DataBits5 = 5, DataBits6 = 6, DataBits7 = 7,
  DataBits8 = 8
}
 Data bits per byte. More...
 
enum  StopBits { StopBitsOther = -1, StopBits1 = 1, StopBits2 = 2, StopBits1_5 = 3 }
 Stop bits. More...
 
enum  FlowControl { FlowOther = -1, FlowOff, FlowHardware, FlowXOnXOff }
 Flow control modes. More...
 

Public Member Functions

 SerialPort (const String &device)
 Construct a new SerialPort for the given device. More...
 
virtual ~SerialPort ()
 Destructor. More...
 
virtual void open ()
 Open the serial port connection. More...
 
void flush ()
 Flush any pending I/O on the connection. More...
 
void setTimeout (timespan_ms_t timeout)
 Set the stream I/O timeout, in milliseconds. More...
 
void setBaudRate (BaudRate baud)
 Set the baud rate for the connection. More...
 
BaudRate getBaudRate ()
 Get the baud rate for the connection. More...
 
void setParity (Parity parity)
 Set the parity type for the connection. More...
 
Parity getParity ()
 Get the parity type for the connection. More...
 
void setDataBits (DataBits bits)
 Set the number of data bits for the connection. More...
 
DataBits getDataBits ()
 Get the data bits value for the connection. More...
 
void setStopBits (StopBits bits)
 Set the number of stop bits for the connection. More...
 
StopBits getStopBits ()
 Get the stop bits value for the connection. More...
 
void setFlowControl (FlowControl flow)
 Set the flow control mode for the connection. More...
 
FlowControl getFlowControl ()
 Get the flow control mode for the connection. More...
 
void sendBreak (uint_t duration)
 Send a break on the serial port for the specified amount of time. More...
 
String getDevice () const
 Get the device for this serial port. More...
 
virtual size_t read (ByteBuffer &buffer)
 Read data from the stream into a ByteBuffer. More...
 
virtual size_t read (CharBuffer &buffer)
 Read data from the stream into a CharBuffer. More...
 
template<typename T >
size_t read (Buffer< T > &buffer, size_t &partial)
 Read data from the stream into a Buffer of arbitrary type. More...
 
virtual size_t read (byte_t *buffer, size_t buflen)
 Read data from the stream into a raw buffer. More...
 
size_t read (byte_t *buffer, size_t buflen, int64_t offset, AsyncIOTask &task)
 Read data asynchronously from the stream into a raw buffer. More...
 
size_t read (ByteBuffer &buffer, int64_t offset, AsyncIOTask &task)
 Read data asynchronously from the stream into a Buffer. More...
 
virtual size_t read (MemoryBlock *vec, uint_t count)
 Read data from the stream into a series of I/O buffers. More...
 
size_t write (const byte_t *buffer, size_t buflen, int64_t offset, AsyncIOTask &task)
 Write data asynchronously to the stream from a raw buffer. More...
 
size_t write (ByteBuffer &buffer, int64_t offset, AsyncIOTask &task)
 Write data asynchronously to the stream from a Buffer. More...
 
virtual size_t write (ByteBuffer &buffer)
 Write data to the stream from a ByteBuffer. More...
 
virtual size_t write (CharBuffer &buffer)
 Write data to the stream from a CharBuffer. More...
 
template<typename T >
size_t write (Buffer< T > &buffer, size_t &partial)
 Write data to the stream from a Buffer of arbitrary type. More...
 
virtual size_t write (const byte_t *buffer, size_t buflen)
 Write data to the stream from a raw buffer, until either the entire buffer is written or an error or timeout occurs. More...
 
virtual size_t write (const MemoryBlock *vec, uint_t count)
 Write data to the stream from a series of I/O buffers. More...
 
virtual size_t readFully (ByteBuffer &buffer, size_t count=0)
 Read data from the stream into a ByteBuffer, until either the buffer is full or an error or timeout occurs. More...
 
virtual size_t readFully (CharBuffer &buffer, size_t count=0)
 Read data from the stream into a CharBuffer, until either the buffer is full or an error or timeout occurs. More...
 
template<typename T >
size_t readFully (Buffer< T > &buffer, size_t &partial)
 Read data from the stream into a Buffer of arbitrary type, until either the buffer is full or an error or timeout occurs. More...
 
virtual size_t readFully (byte_t *buffer, size_t buflen)
 Read data from the stream into a raw buffer, until either the buffer is full or an error or timeout occurs. More...
 
virtual size_t writeFully (ByteBuffer &buffer)
 Write data to the stream from a ByteBuffer, until either the entire buffer is written or an error or timeout occurs. More...
 
virtual size_t writeFully (CharBuffer &buffer)
 Write data to the stream from a CharBuffer, until either the entire buffer is written or an error or timeout occurs. More...
 
template<typename T >
size_t writeFully (Buffer< T > &buffer, size_t &partial)
 Write data to the stream from a Buffer of arbitrary type, until either the entire buffer is written or an error or timeout occurs. More...
 
virtual size_t writeFully (const byte_t *buffer, size_t buflen)
 Write data to the stream from a raw buffer. More...
 
virtual int64_t seek (int64_t offset, SeekMode mode=SeekAbsolute)
 Reposition the seek pointer in the stream. More...
 
virtual int64_t tell ()
 Get the current (absolute) offset of the seek pointer. More...
 
bool isOpen () const
 Test if the stream is open. More...
 
bool isSeekable () const
 Test if the stream supports seeking. More...
 
bool isReadable () const
 Test if the stream can be read from. More...
 
bool isWritable () const
 Test if the stream can be written to. More...
 
bool isFullDuplex () const
 Test if the stream is full-duplex (i.e., supports both reading and writing). More...
 
bool isHalfDuplex () const
 Test if the stream is half-duplex (i.e., supports either reading or writing, but not both). More...
 
virtual void close (IOMode mode=IOReadWrite)
 Close the stream for reading, writing, or both. More...
 
timespan_ms_t getTimeout () const
 Get the stream I/O timeout, in milliseconds. More...
 

Static Public Member Functions

static BaudRate lookupBaudRate (uint_t baudRate)
 Get the BaudRate enumeration value for the given baud rate value. More...
 

Static Public Attributes

static const uint_t MAX_IOBLOCK_COUNT = 16
 The maximum number of I/O buffers that can be passed to the vector I/O methods. More...
 

Protected Member Functions

void _init (FileHandle handle, bool seekable, bool readable, bool writable)
 Initialize the stream for use with an open file. More...
 

Detailed Description

A class representing a serial communications port.

Author
Mark Lindner

Member Enumeration Documentation

◆ BaudRate

enum BaudRate

Baud rates.

Enumerator
BaudOther 
Baud300 
Baud600 
Baud1200 
Baud1800 
Baud2400 
Baud4800 
Baud9600 
Baud19200 
Baud38400 
Baud57600 
Baud115200 
Baud230400 

◆ DataBits

enum DataBits

Data bits per byte.

Enumerator
DataBitsOther 
DataBits5 
DataBits6 
DataBits7 
DataBits8 

◆ FlowControl

Flow control modes.

Enumerator
FlowOther 
FlowOff 
FlowHardware 
FlowXOnXOff 

◆ Parity

enum Parity

Parity types.

Enumerator
ParityOther 
ParityNone 
ParityOdd 
ParityEven 
ParityMark 
ParitySpace 

◆ StopBits

enum StopBits

Stop bits.

Enumerator
StopBitsOther 
StopBits1 
StopBits2 
StopBits1_5 

Constructor & Destructor Documentation

◆ SerialPort()

SerialPort ( const String device)

Construct a new SerialPort for the given device.

Parameters
deviceThe device: a serial device file like "/dev/ttyS0" on Linux or "/dev/cu.serial0" on Mac OS X, or a label like "\\.\COM1" on Windows.

◆ ~SerialPort()

~SerialPort ( )
virtual

Destructor.

Closes the serial port connection.

Member Function Documentation

◆ _init()

void _init ( FileHandle  handle,
bool  seekable,
bool  readable,
bool  writable 
)
protectedinherited

Initialize the stream for use with an open file.

Parameters
handleThe handle to an open file.
seekableA flag indicating whether the stream is seekable.
readableA flag indicating whether the stream is readable.
writableA flag indicating whether the stream is writable.

◆ close()

void close ( IOMode  mode = IOReadWrite)
virtualinherited

Close the stream for reading, writing, or both.

Parameters
modeThe close mode.

Reimplemented in StreamSocket, and StreamPipe.

◆ flush()

void flush ( )

Flush any pending I/O on the connection.

Exceptions
IOExceptionIf an I/O error occurs, or if the conneciton is not open.

◆ getBaudRate()

SerialPort::BaudRate getBaudRate ( )

Get the baud rate for the connection.

Returns
The current baud rate; BaudOther if the baud rate is not one of the predefined enum values.
Exceptions
IOExceptionIf an I/O error occurs, or if the connection is not open.

◆ getDataBits()

SerialPort::DataBits getDataBits ( )

Get the data bits value for the connection.

Returns
The current data bits value; DataBitsOther if the value is not one of the predefined enum values.
Exceptions
IOExceptionIf an I/O error occurs, or if the connection is not open.

◆ getDevice()

String getDevice ( ) const
inline

Get the device for this serial port.

◆ getFlowControl()

SerialPort::FlowControl getFlowControl ( )

Get the flow control mode for the connection.

Returns
The current flow control mode; FlowControlOther if the flow control mode is not one of the predefined enum values.
Exceptions
IOExceptionIf an I/O error occurs, or if the connection is not open.

◆ getParity()

SerialPort::Parity getParity ( )

Get the parity type for the connection.

Returns
The current parity type; ParityOther if the parity type is not one of the predefined enum values.
Exceptions
IOExceptionIf an I/O error occurs, or if the connection is not open.

◆ getStopBits()

SerialPort::StopBits getStopBits ( )

Get the stop bits value for the connection.

Returns
The current stop bits value; StopBitsOther if the value is not one of the predefined enum values.
Exceptions
IOExceptionIf an I/O error occurs, or if the connection is not open.

◆ getTimeout()

timespan_ms_t getTimeout ( ) const
inlineinherited

Get the stream I/O timeout, in milliseconds.

◆ isFullDuplex()

bool isFullDuplex ( ) const
inlineinherited

Test if the stream is full-duplex (i.e., supports both reading and writing).

◆ isHalfDuplex()

bool isHalfDuplex ( ) const
inlineinherited

Test if the stream is half-duplex (i.e., supports either reading or writing, but not both).

◆ isOpen()

bool isOpen ( ) const
inlineinherited

Test if the stream is open.

◆ isReadable()

bool isReadable ( ) const
inlineinherited

Test if the stream can be read from.

◆ isSeekable()

bool isSeekable ( ) const
inlineinherited

Test if the stream supports seeking.

◆ isWritable()

bool isWritable ( ) const
inlineinherited

Test if the stream can be written to.

◆ lookupBaudRate()

SerialPort::BaudRate lookupBaudRate ( uint_t  baudRate)
static

Get the BaudRate enumeration value for the given baud rate value.

Parameters
baudRateA baud rate.
Returns
The BaudRate value that is closest to, but not greater than, the given baud rate.

◆ open()

void open ( )
virtual

Open the serial port connection.

This method must be called before any of the get*() or set*() methods can be used.

Exceptions
IOExceptionIf an I/O error occurs.

◆ read() [1/7]

size_t read ( ByteBuffer buffer)
virtualinherited

Read data from the stream into a ByteBuffer.

Parameters
bufferThe buffer to read into.
Returns
The number of bytes actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

Reimplemented in StreamSocket.

◆ read() [2/7]

size_t read ( CharBuffer buffer)
virtualinherited

Read data from the stream into a CharBuffer.

Parameters
bufferThe buffer to read into.
Returns
The number of characters actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

Reimplemented in StreamSocket.

◆ read() [3/7]

size_t read ( Buffer< T > &  buffer,
size_t &  partial 
)
inlineinherited

Read data from the stream into a Buffer of arbitrary type.

If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes read before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially read, the number of bytes of the element that were read will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue reading from the appropriate offset within the partially-read element.

Parameters
bufferThe buffer to read into.
partialThe number of bytes remaining to read for a partially-read element; on return, the number of bytes read of a partially-read element, or 0 if the last element was read completely. Should be set to 0 prior to the first call to this method for a fresh buffer.
Returns
The number of whole elements actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

◆ read() [4/7]

size_t read ( byte_t buffer,
size_t  buflen 
)
virtualinherited

Read data from the stream into a raw buffer.

Parameters
bufferThe buffer to read into.
buflenThe number of bytes to read.
Returns
The number of bytes actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

Reimplemented in StreamSocket.

◆ read() [5/7]

size_t read ( byte_t buffer,
size_t  buflen,
int64_t  offset,
AsyncIOTask task 
)
inherited

Read data asynchronously from the stream into a raw buffer.

Parameters
bufferThe buffer to read into.
buflenThe number of bytes to read.
offsetThe file offset to read from.
taskThe async I/O control block for monitoring the operation.
Returns
The number of bytes actually read, if the operation completed immediately, otherwise 0 to indicate that the operation has begun.
Exceptions
IOExceptionIf an I/O error occurred.

◆ read() [6/7]

size_t read ( ByteBuffer buffer,
int64_t  offset,
AsyncIOTask task 
)
inherited

Read data asynchronously from the stream into a Buffer.

Parameters
bufferThe Buffer to read into. This object must not be destroyed before the asynchronous I/O operation is completed or cancelled.
offsetThe file offset to read from.
taskThe async I/O control block for monitoring the operation.
Returns
The number of bytes actually read, if the operation completed immediately, otherwise 0 to indicate that the operation has begun.
Exceptions
IOExceptionIf an I/O error occurred.

◆ read() [7/7]

size_t read ( MemoryBlock vec,
uint_t  count 
)
virtualinherited

Read data from the stream into a series of I/O buffers.

This operation is known as "vector read" or "scatter read." The buffers are read into in order. On systems that support it, the operation is performed with a single system call.

Parameters
vecAn array of buffers to read into.
countThe number of buffers in the array.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

Reimplemented in StreamSocket.

◆ readFully() [1/4]

size_t readFully ( ByteBuffer buffer,
size_t  count = 0 
)
virtualinherited

Read data from the stream into a ByteBuffer, until either the buffer is full or an error or timeout occurs.

Parameters
bufferThe buffer to read into.
countThe number of bytes to read. If 0 or greater than the number of bytes between the position and the limit, reads up to the limit.
Returns
The number of bytes actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

◆ readFully() [2/4]

size_t readFully ( CharBuffer buffer,
size_t  count = 0 
)
virtualinherited

Read data from the stream into a CharBuffer, until either the buffer is full or an error or timeout occurs.

Parameters
bufferThe buffer to read into.
countThe number of characters to read. If 0 or greater than the number of bytes between the position and the limit, reads up to the limit.
Returns
The number of bytes actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

◆ readFully() [3/4]

size_t readFully ( Buffer< T > &  buffer,
size_t &  partial 
)
inlineinherited

Read data from the stream into a Buffer of arbitrary type, until either the buffer is full or an error or timeout occurs.

If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes read before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially read, the number of bytes of the element that were read will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue reading from the appropriate offset within the partially-read element.

Parameters
bufferThe buffer to read into.
partialThe number of bytes remaining to read for a partially-read element; on return, the number of bytes read of a partially-read element, or 0 if the last element was read completely. Should be set to 0 prior to the first call to this method for a fresh buffer.
Returns
The number of whole elements actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

◆ readFully() [4/4]

size_t readFully ( byte_t buffer,
size_t  buflen 
)
virtualinherited

Read data from the stream into a raw buffer, until either the buffer is full or an error or timeout occurs.

Parameters
bufferThe buffer to read into.
buflenThe number of bytes to read.
Returns
The number of bytes actually read.
Exceptions
IOExceptionIf the end-of-file was reached or some other I/O error occurred.

◆ seek()

int64_t seek ( int64_t  offset,
SeekMode  mode = SeekAbsolute 
)
virtualinherited

Reposition the seek pointer in the stream.

Parameters
offsetThe new offset.
modeThe seek mode.
Returns
The new position of the seek pointer.
Exceptions
IOExceptionIf the stream does not support seeking, or if some other I/O error occurred.

◆ sendBreak()

void sendBreak ( uint_t  duration)

Send a break on the serial port for the specified amount of time.

Parameters
durationThe duration. On Windows, the duration is specified in milliseconds. On other platforms, the meaning of the value is implementation-defined.

◆ setBaudRate()

void setBaudRate ( SerialPort::BaudRate  baud)

Set the baud rate for the connection.

Parameters
baudThe new baud rate.
Exceptions
IOExceptionIf an I/O error occurs, or if the supplied baud rate is BaudOther, or if the connection is not open.

◆ setDataBits()

void setDataBits ( SerialPort::DataBits  bits)

Set the number of data bits for the connection.

Parameters
bitsThe new data bits value.
Exceptions
IOExceptionIf an I/O error occurs, or if the supplied data bits value is DataBitsOther, or if the connection is not open.

◆ setFlowControl()

void setFlowControl ( SerialPort::FlowControl  flow)

Set the flow control mode for the connection.

Parameters
flowThe new flow control mode.
Exceptions
IOExceptionIf an I/O error occurs, or if the supplied flow control mode is FlowControlOther, or if the connection is not open.

◆ setParity()

void setParity ( SerialPort::Parity  parity)

Set the parity type for the connection.

Parameters
parityThe new parity type.
Exceptions
IOExceptionIf an I/O error occurs, or if the supplied parity type is ParityOther, or if the connection is not open.

◆ setStopBits()

void setStopBits ( SerialPort::StopBits  bits)

Set the number of stop bits for the connection.

Parameters
bitsThe new stop bits value.
Exceptions
IOExceptionIf an I/O error occurs, or if the supplied stop bits value is StopBitsOther, or if the connection is not open.

◆ setTimeout()

void setTimeout ( timespan_ms_t  timeout)
virtual

Set the stream I/O timeout, in milliseconds.

A timeout of 0 indicates no timeout, and a timeout of -1 indicates infinite timeout (blocking I/O).

Reimplemented from Stream.

◆ tell()

int64_t tell ( )
virtualinherited

Get the current (absolute) offset of the seek pointer.

Returns
The current offset, from the beginning of the stream.
Exceptions
IOExceptionIf the stream does not support seeking, or if some other I/O error occurred.

◆ write() [1/7]

size_t write ( const byte_t buffer,
size_t  buflen,
int64_t  offset,
AsyncIOTask task 
)
inherited

Write data asynchronously to the stream from a raw buffer.

Parameters
bufferThe buffer to write.
buflenThe number of bytes to write.
offsetThe file offset to write to.
taskThe async I/O control block for monitoring the operation.
Returns
The number of bytes actually written, if the operation completed immediately, otherwise 0 to indicate that the operation has begun.
Exceptions
IOExceptionIf an I/O error occurred.

◆ write() [2/7]

size_t write ( ByteBuffer buffer,
int64_t  offset,
AsyncIOTask task 
)
inherited

Write data asynchronously to the stream from a Buffer.

Parameters
bufferThe Buffer to write. This object must not be destroyed before the asynchronous I/O operation is completed or cancelled.
offsetThe file offset to write to.
taskThe async I/O control block for monitoring the operation.
Returns
The number of bytes actually written, if the operation completed immediately, otherwise 0 to indicate that the operation has begun.
Exceptions
IOExceptionIf an I/O error occurred.

◆ write() [3/7]

size_t write ( ByteBuffer buffer)
virtualinherited

Write data to the stream from a ByteBuffer.

Parameters
bufferThe buffer to write.
Returns
The number of bytes actually written.
Exceptions
IOExceptionIf an I/O error occurred.

Reimplemented in StreamSocket.

◆ write() [4/7]

size_t write ( CharBuffer buffer)
virtualinherited

Write data to the stream from a CharBuffer.

Parameters
bufferThe buffer to write.
Returns
The number of characters actually written.
Exceptions
IOExceptionIf an I/O error occurred.

Reimplemented in StreamSocket.

◆ write() [5/7]

size_t write ( Buffer< T > &  buffer,
size_t &  partial 
)
inlineinherited

Write data to the stream from a Buffer of arbitrary type.

If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes written before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially written, the number of bytes of the element that were written will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue writing from the appropriate offset within the partially-written element.

Parameters
bufferThe buffer to write.
partialThe number of bytes remaining to write for a partially-written element; on return, the number of bytes written of a partially-written element, or 0 if the last element was written completely. Should be set to 0 prior to the first call to this method for a fresh buffer.
Returns
The number of whole elements actually written.
Exceptions
IOExceptionIf an I/O error occurred.

◆ write() [6/7]

size_t write ( const byte_t buffer,
size_t  buflen 
)
virtualinherited

Write data to the stream from a raw buffer, until either the entire buffer is written or an error or timeout occurs.

Parameters
bufferA pointer to the buffer.
buflenThe number of bytes to write.
Returns
The number of bytes actually written.
Exceptions
IOExceptionIf an I/O error occurred.

Reimplemented in StreamSocket.

◆ write() [7/7]

size_t write ( const MemoryBlock vec,
uint_t  count 
)
virtualinherited

Write data to the stream from a series of I/O buffers.

This operation is known as "vector write" or "gather write." The buffers are written in order. On systems that support it, the operation is performed with a single system call.

Parameters
vecAn array of buffers to write.
countThe number of buffers in the array.
Exceptions
IOExceptionIf an I/O error occurred.

Reimplemented in StreamSocket.

◆ writeFully() [1/4]

size_t writeFully ( ByteBuffer buffer)
virtualinherited

Write data to the stream from a ByteBuffer, until either the entire buffer is written or an error or timeout occurs.

Parameters
bufferThe buffer to write.
Returns
The number of bytes actually written.
Exceptions
IOExceptionIf and I/O error occurred.

◆ writeFully() [2/4]

size_t writeFully ( CharBuffer buffer)
virtualinherited

Write data to the stream from a CharBuffer, until either the entire buffer is written or an error or timeout occurs.

Parameters
bufferThe buffer to write.
Returns
The number of bytes actually written.
Exceptions
IOExceptionIf an I/O error occurred.

◆ writeFully() [3/4]

size_t writeFully ( Buffer< T > &  buffer,
size_t &  partial 
)
inlineinherited

Write data to the stream from a Buffer of arbitrary type, until either the entire buffer is written or an error or timeout occurs.

If sizeof(T) is greater than 1 byte, then there can be no guarantee that the number of bytes written before a timeout or error occurs will be evenly divisible by sizeof(T). If the final element was partially written, the number of bytes of the element that were written will be stored in partial; this value should be passed unmodified to the next invocation of this method to continue writing from the appropriate offset within the partially-written element.

Parameters
bufferThe buffer to write.
partialThe number of bytes remaining to write for a partially-written element; on return, the number of bytes written of a partially-written element, or 0 if the last element was written completely. Should be set to 0 prior to the first call to this method for a fresh buffer.
Returns
The number of whole elements actually written.
Exceptions
IOExceptionIf an I/O error occurred.

◆ writeFully() [4/4]

size_t writeFully ( const byte_t buffer,
size_t  buflen 
)
virtualinherited

Write data to the stream from a raw buffer.

Parameters
bufferA pointer to the buffer.
buflenThe number of bytes to write.
Returns
The number of bytes actually written.
Exceptions
IOExceptionIf an I/O error occurred.

Member Data Documentation

◆ MAX_IOBLOCK_COUNT

const uint_t MAX_IOBLOCK_COUNT = 16
staticinherited

The maximum number of I/O buffers that can be passed to the vector I/O methods.


The documentation for this class was generated from the following files: