libcommonc++
0.7
|
An abstract base class for data readers. More...
#include <DataReader.h++>
Public Member Functions | |
virtual | ~DataReader () |
Destructor. More... | |
DataReader & | operator>> (bool &v) |
Read operator. More... | |
DataReader & | operator>> (byte_t &v) |
Read operator. More... | |
DataReader & | operator>> (byte_t *v) |
Read operator. More... | |
DataReader & | operator>> (char &v) |
Read operator. More... | |
DataReader & | operator>> (char *v) |
Read operator. More... | |
DataReader & | operator>> (int16_t &v) |
Read operator. More... | |
DataReader & | operator>> (int16_t *v) |
Read operator. More... | |
DataReader & | operator>> (uint16_t &v) |
Read operator. More... | |
DataReader & | operator>> (uint16_t *v) |
Read operator. More... | |
DataReader & | operator>> (int32_t &v) |
Read operator. More... | |
DataReader & | operator>> (int32_t *v) |
Read operator. More... | |
DataReader & | operator>> (uint32_t &v) |
Read operator. More... | |
DataReader & | operator>> (uint32_t *v) |
Read operator. More... | |
DataReader & | operator>> (int64_t &v) |
Read operator. More... | |
DataReader & | operator>> (int64_t *v) |
Read operator. More... | |
DataReader & | operator>> (uint64_t &v) |
Read operator. More... | |
DataReader & | operator>> (uint64_t *v) |
Read operator. More... | |
DataReader & | operator>> (float &v) |
Read operator. More... | |
DataReader & | operator>> (float *v) |
Read operator. More... | |
DataReader & | operator>> (double &v) |
Read operator. More... | |
DataReader & | operator>> (double *v) |
Read operator. More... | |
DataReader & | operator>> (Blob &v) |
Read operator. More... | |
DataReader & | operator>> (String &v) |
Read operator. More... | |
DataReader & | operator>> (const Manipulator &manip) |
Read operator. More... | |
size_t | readBytes (byte_t *buf, size_t len) |
Read raw bytes. More... | |
void | readFully (byte_t *buf, size_t len) |
Read raw bytes, throwing an EOFException if the exact number of bytes requested could not be read. More... | |
virtual void | reset () |
Reset the encoder. More... | |
void | pushContext () |
Push a new encoder context. More... | |
void | popContext () |
Pop the active encoder context. More... | |
bool | isTopContext () const |
Determine if the active context is the topmost (and only) context. More... | |
uint_t | getContextDepth () const |
Get the current context depth. More... | |
void | setEndianness (Endianness endianness) |
Specify the byte-endianness for reading/writing primitive integer types in the active context. More... | |
Endianness | getEndianness () const |
Get the byte-endianness in the active context. More... | |
void | setLength (size_t length) |
Specify the length of String, Blob, and array values for subsequent reading/writing in the active context. More... | |
size_t | getLength () const |
Get the current length for string values. More... | |
void | setLimit (int64_t limit) |
Specify the maximum number of bytes that can be read/written in the active context. More... | |
int64_t | getLimit () const |
Get the current limit. More... | |
int64_t | getOffset () const |
Get the current encoding/decoding offset. More... | |
virtual void | setOffset (int64_t offset)=0 |
Set the current reading/writing offset. More... | |
int64_t | getCumulativeOffset () const |
Get the cumulative reading/writing offset. More... | |
int64_t | getRemaining () const |
Get the number of bytes between the current offset and the limit, i.e., the number of bytes remaining to be read or written. More... | |
void | align (size_t size) |
Skip past enough bytes to re-align the data stream at a specified boundary. More... | |
virtual void | skip (size_t count)=0 |
Skip past the given number of bytes in the data stream. More... | |
Protected Member Functions | |
DataReader () | |
Constructor. More... | |
virtual size_t | read (byte_t *buf, size_t count)=0 |
Read raw data from the input source. More... | |
virtual void | readString (String &v, uint32_t length) |
Read a string from the input source. More... | |
bool | isSameEndianness () const |
Test if the endianness of the encoder is the same as the endianness of the host system. More... | |
Context & | currentContext () |
Get a reference to the current context. More... | |
const Context & | currentContext () const |
Get a reference to the current context. More... | |
void | checkRemaining (const Context &ctx, size_t count) const |
Check if at least the given number of bytes are available to be read or written. More... | |
An abstract base class for data readers.
A data reader reads raw bytes from an input source and converts them to primitive values such as integers and strings.
|
virtual |
Destructor.
|
protected |
Constructor.
|
inherited |
Skip past enough bytes to re-align the data stream at a specified boundary.
When reading, the bytes are simply skipped over; when writing, the bytes are filled with NULs.
size | The alignment size. Typical values include 2, 4, or 8. Other values are allowed but are of limited usefulness. |
IOException | If an I/O error occurs. |
|
protectedinherited |
Check if at least the given number of bytes are available to be read or written.
ctx | The context to check. |
count | The number of bytes. |
IOException | If there are not enough bytes remaining. |
|
protectedinherited |
Get a reference to the current context.
|
protectedinherited |
Get a reference to the current context.
|
inherited |
Get the current context depth.
|
inherited |
Get the cumulative reading/writing offset.
This is a sum of the offsets across all contexts.
|
inherited |
Get the byte-endianness in the active context.
|
inherited |
Get the current length for string values.
|
inherited |
Get the current limit.
|
inherited |
Get the current encoding/decoding offset.
|
inherited |
Get the number of bytes between the current offset and the limit, i.e., the number of bytes remaining to be read or written.
|
protectedinherited |
Test if the endianness of the encoder is the same as the endianness of the host system.
|
inherited |
Determine if the active context is the topmost (and only) context.
DataReader & operator>> | ( | bool & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | byte_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | byte_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | char & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | char * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | int16_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | int16_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | uint16_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | uint16_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | int32_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | int32_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | uint32_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | uint32_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | int64_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | int64_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | uint64_t & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | uint64_t * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | float & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | float * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | double & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | double * | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | Blob & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | String & | v | ) |
Read operator.
IOException | If an I/O error occurs. |
DataReader & operator>> | ( | const Manipulator & | manip | ) |
Read operator.
IOException | If an I/O error occurs. |
|
inherited |
Pop the active encoder context.
The previous context becomes the active context, and the offset in the current context is incremented by the offset of the popped context.
|
inherited |
Push a new encoder context.
|
protectedpure virtual |
Read raw data from the input source.
buf | The buffer to read into. |
count | The number of bytes to read. |
IOException | If an I/O error occurs. |
Implemented in StreamDataReader, CircularByteBufferDataReader, ByteArrayDataReader, and ByteBufferDataReader.
size_t readBytes | ( | byte_t * | buf, |
size_t | len | ||
) |
Read raw bytes.
The number of bytes read may be less than the number requested, if an end-of-file condition occurs.
buf | The buffer in which to place the bytes. |
len | The maximum number of bytes to read. |
IOException | If an I/O error occurs. |
void readFully | ( | byte_t * | buf, |
size_t | len | ||
) |
Read raw bytes, throwing an EOFException if the exact number of bytes requested could not be read.
buf | The buffer in which to place the bytes. |
len | The exact number of bytes to read. |
IOException | If an I/O error occurs. |
|
protectedvirtual |
Read a string from the input source.
v | The String to read into. |
length | The length of the string to read, or 0 to read a String that is preceded by a 32-bit length. |
IOException | If an I/O error occurs. |
Reimplemented in CircularByteBufferDataReader.
|
virtualinherited |
Reset the encoder.
Discards all but the topmost context, and resets the topmost context to default values.
IOException | If an I/O error occurs. |
Reimplemented in ByteArrayDataWriter, CircularByteBufferDataWriter, ByteBufferDataWriter, CircularByteBufferDataReader, StreamDataReader, ByteArrayDataReader, and ByteBufferDataReader.
|
inherited |
Specify the byte-endianness for reading/writing primitive integer types in the active context.
|
inherited |
|
inherited |
Specify the maximum number of bytes that can be read/written in the active context.
Attempts to read/write past this limit will raise an IOException.
IOException | If an I/O error occurs. |
|
pure virtualinherited |
Set the current reading/writing offset.
IOException | If an I/O error occurs. |
Implemented in ByteArrayDataWriter, CircularByteBufferDataWriter, StreamDataWriter, ByteBufferDataWriter, CircularByteBufferDataReader, StreamDataReader, ByteArrayDataReader, and ByteBufferDataReader.
|
pure virtualinherited |
Skip past the given number of bytes in the data stream.
When reading, the bytes are simply skipped over; when writing, the bytes are filled with NULs.
count | The number of bytes to skip. |
IOException | If an I/O error occurs. |
Implemented in StreamDataWriter, ByteArrayDataWriter, CircularByteBufferDataReader, StreamDataReader, ByteArrayDataReader, ByteBufferDataReader, ByteBufferDataWriter, and DataWriter.