DataReader Class Reference

An abstract base class for data readers. More...

#include <DataReader.h++>

Inheritance diagram for DataReader:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~DataReader () throw ()
 Destructor.
DataReaderoperator>> (bool &v) throw (IOException)
 Read operator.
DataReaderoperator>> (byte_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (byte_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (char &v) throw (IOException)
 Read operator.
DataReaderoperator>> (char *v) throw (IOException)
 Read operator.
DataReaderoperator>> (int16_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (int16_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (uint16_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (uint16_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (int32_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (int32_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (uint32_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (uint32_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (int64_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (int64_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (uint64_t &v) throw (IOException)
 Read operator.
DataReaderoperator>> (uint64_t *v) throw (IOException)
 Read operator.
DataReaderoperator>> (float &v) throw (IOException)
 Read operator.
DataReaderoperator>> (float *v) throw (IOException)
 Read operator.
DataReaderoperator>> (double &v) throw (IOException)
 Read operator.
DataReaderoperator>> (double *v) throw (IOException)
 Read operator.
DataReaderoperator>> (Blob &v) throw (IOException)
 Read operator.
DataReaderoperator>> (String &v) throw (IOException)
 Read operator.
DataReaderoperator>> (const Manipulator &manip) throw (IOException)
 Read operator.
virtual void reset () throw (IOException)
 Reset the encoder.
void pushContext ()
 Push a new encoder context.
void popContext ()
 Pop the active encoder context.
bool isTopContext () const throw ()
 Determine if the active context is the topmost (and only) context.
uint_t getContextDepth () const throw ()
 Get the current context depth.
void setEndianness (Endianness endianness) throw ()
 Specify the byte-endianness for reading/writing primitive integer types in the active context.
Endianness getEndianness () const throw ()
 Get the byte-endianness in the active context.
void setLength (size_t length) throw ()
 Specify the length of String, Blob, and array values for subsequent reading/writing in the active context.
size_t getLength () const throw ()
 Get the current length for string values.
void setLimit (int64_t limit) throw (IOException)
 Specify the maximum number of bytes that can be read/written in the active context.
int64_t getLimit () const throw ()
 Get the current limit.
void setStringPadding (bool stringPadding) throw ()
 Enables or disable string padding in the active context.
bool getStringPadding () const throw ()
 Get the current string padding status.
int64_t getOffset () const throw ()
 Get the current encoding/decoding offset.
virtual void setOffset (int64_t offset)=0 throw (IOException)
 Set the current reading/writing offset.
int64_t getCumulativeOffset () const throw ()
 Get the cumulative reading/writing offset.
int64_t getRemaining () const throw ()
 Get the number of bytes between the current offset and the limit, i.e., the number of bytes remaining to be read or written.
void align (size_t size) throw (IOException)
 Skip past enough bytes to re-align the data stream at a specified boundary.
virtual void skip (size_t count)=0 throw (IOException)
 Skip past the given number of bytes in the data stream.

Protected Member Functions

 DataReader () throw ()
 Constructor.
virtual size_t read (byte_t *buf, size_t count)=0 throw (IOException)
 Read raw data from the input source.
bool isSameEndianness () const throw ()
 Test if the endianness of the encoder is the same as the endianness of the host system.
ContextcurrentContext ()
 Get a reference to the current context.
const ContextcurrentContext () const
 Get a reference to the current context.
void checkRemaining (const Context &ctx, size_t count) const throw (IOException)
 Check if at least the given number of bytes are available to be read or written.

Detailed Description

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.

Author:
Mark Lindner

Constructor & Destructor Documentation

~DataReader (  )  throw () [virtual]

Destructor.

DataReader (  )  throw () [protected]

Constructor.


Member Function Documentation

void align ( size_t  size  )  throw (IOException) [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.

Parameters:
size The alignment size. Typical values include 2, 4, or 8. Other values are allowed but are of limited usefulness.
Exceptions:
IOException If an I/O error occurs.
void checkRemaining ( const Context ctx,
size_t  count 
) const throw (IOException) [protected, inherited]

Check if at least the given number of bytes are available to be read or written.

Parameters:
ctx The context to check.
count The number of bytes.
Exceptions:
IOException If there are not enough bytes remaining.
const DataEncoder::Context & currentContext (  )  const [protected, inherited]

Get a reference to the current context.

DataEncoder::Context & currentContext (  )  [protected, inherited]

Get a reference to the current context.

uint_t getContextDepth (  )  const throw () [inherited]

Get the current context depth.

int64_t getCumulativeOffset (  )  const throw () [inherited]

Get the cumulative reading/writing offset.

This is a sum of the offsets across all contexts.

Endianness getEndianness (  )  const throw () [inherited]

Get the byte-endianness in the active context.

size_t getLength (  )  const throw () [inherited]

Get the current length for string values.

int64_t getLimit (  )  const throw () [inherited]

Get the current limit.

int64_t getOffset (  )  const throw () [inherited]

Get the current encoding/decoding offset.

int64_t getRemaining (  )  const throw () [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.

bool getStringPadding (  )  const throw () [inherited]

Get the current string padding status.

bool isSameEndianness (  )  const throw () [protected, inherited]

Test if the endianness of the encoder is the same as the endianness of the host system.

bool isTopContext (  )  const throw () [inherited]

Determine if the active context is the topmost (and only) context.

DataReader & operator>> ( const Manipulator manip  )  throw (IOException)

Read operator.

DataReader & operator>> ( String v  )  throw (IOException)

Read operator.

DataReader & operator>> ( Blob v  )  throw (IOException)

Read operator.

DataReader & operator>> ( double *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( double &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( float *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( float &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( uint64_t *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( uint64_t &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( int64_t *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( int64_t &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( uint32_t *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( uint32_t &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( int32_t *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( int32_t &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( uint16_t *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( uint16_t &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( int16_t *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( int16_t &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( char *  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( char &  v  )  throw (IOException)

Read operator.

DataReader & operator>> ( byte_t v  )  throw (IOException)

Read operator.

DataReader & operator>> ( byte_t v  )  throw (IOException)

Read operator.

DataReader & operator>> ( bool &  v  )  throw (IOException)

Read operator.

void popContext (  )  [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.

void pushContext (  )  [inherited]

Push a new encoder context.

virtual size_t read ( byte_t buf,
size_t  count 
) throw (IOException) [protected, pure virtual]

Read raw data from the input source.

Implemented in ByteArrayDataReader, ByteBufferDataReader, and StreamDataReader.

void reset (  )  throw (IOException) [virtual, inherited]

Reset the encoder.

Discards all but the topmost context, and resets the topmost context to default values.

Reimplemented in ByteArrayDataReader, ByteArrayDataWriter, ByteBufferDataReader, ByteBufferDataWriter, and StreamDataReader.

void setEndianness ( Endianness  endianness  )  throw () [inherited]

Specify the byte-endianness for reading/writing primitive integer types in the active context.

void setLength ( size_t  length  )  throw () [inherited]

Specify the length of String, Blob, and array values for subsequent reading/writing in the active context.

Depending on whether string padding is enabled or disabled, written strings will be padded with either space characters or NUL bytes, respectively.

void setLimit ( int64_t  limit  )  throw (IOException) [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.

virtual void setOffset ( int64_t  offset  )  throw (IOException) [pure virtual, inherited]
void setStringPadding ( bool  stringPadding  )  throw () [inherited]

Enables or disable string padding in the active context.

When enabled, strings are padded with spaces during writing; otherwise they are padded with NUL bytes.

Parameters:
stringPadding A flag indicating the type of padding; true for spaces, false for NUL bytes.
virtual void skip ( size_t  count  )  throw (IOException) [pure virtual, inherited]

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.

Parameters:
count The number of bytes to skip.
Exceptions:
IOException If an I/O error occurs.

Implemented in ByteArrayDataReader, ByteArrayDataWriter, ByteBufferDataReader, ByteBufferDataWriter, DataWriter, StreamDataReader, and StreamDataWriter.


The documentation for this class was generated from the following files:
Generated on Sat Nov 26 16:49:09 2011 for libcommonc++ by  doxygen 1.6.3