LRAUV  revA
InStream Class Referenceabstract

This is a very abstract class that can be implemented by classes that want to receive stream input. More...

#include <InStream.h>

Inheritance diagram for InStream:

Public Member Functions

virtual ~InStream ()
 Destructor. More...
 
virtual InStreamread (char *buffer, size_t num)=0
 reads num bytes from stream to the buffer More...
 
virtual const char * getName ()=0
 returns name of the stream More...
 
virtual bool isReadable ()=0
 indicates whether the stream can actually be read from. More...
 
InStreamreadChar (signed char &value)
 reads a single byte to the input buffer/stream More...
 
InStreamreadCharHex (signed char &byte)
 reads a single unsigned char from the input buffer/stream as 2 hex chars More...
 
InStreamreadUCharHex (unsigned char &byte)
 reads a single unsigned char from the input buffer/stream as 2 hex chars More...
 
virtual InStreamreadLine (char *buf, unsigned int bufsize)
 
InStreamreadShort (short &value)
 reads a single short from the input buffer/stream More...
 
InStreamreadShort (unsigned short &value)
 reads a single short from the input buffer/stream More...
 
InStreamreadShortHex (short &word)
 reads a single short from the input buffer/stream as 4 hex chars More...
 
InStreamreadUShortHex (unsigned short &value)
 reads a single unsigned short from the input buffer/stream as 4 hex chars More...
 
InStreamreadUShortCompact (unsigned short &value)
 reads an unsigned short integer as 1 to 3 bytes, encoded as follows: xxxxxxx0 - 7 bit value, encoded in 1 byte xxxxxx01+1byte - 14 bit value, encoded in 2 bytes xxxxx011+2bytes - 16 bit value, encoded in 3 bytes More...
 
InStreamreadInt24 (int &medInt)
 reads a 3-byte integer to the input buffer/stream only works on little-endian machines! More...
 
InStreamreadInt (int &value)
 reads a 4-byte integer to the input buffer/stream More...
 
InStreamreadLongLong (long long &value)
 reads a 8-byte integer to the input buffer/stream More...
 
InStreamreadLongLongCompact (long long &value)
 reads a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value, encoded in 1 byte 10xxxxxx+1byte - 14 bit value, encoded in 2 bytes 110xxxxx+2bytes - 21 bit value, encoded in 3 bytes 1110xxxx+3bytes - 28 bit value, encoded in 4 bytes 11110xxx+4bytes - 35 bit value, encoded in 5 bytes 111110xx+5bytes - 42 bit value, encoded in 6 bytes 1111110x+6bytes - 49 bit value, encoded in 7 bytes 11111110+7bytes - 56 bit value, encoded in 8 bytes 11111111+8bytes - 64 bit value, encoded in 9 bytes More...
 
InStreamreadFloat (float &value)
 reads a 4-byte float to the input buffer/stream More...
 
InStreamreadFloat2 (float &value)
 reads a 2-byte float to the input buffer/stream More...
 
InStreamreadFloat3 (float &value)
 reads a 3-byte float to the input buffer/stream More...
 
InStreamreadDouble (double &value)
 reads a 8-byte double to the input buffer/stream More...
 
virtual InStreamreadUntil (char *buf, unsigned int num, unsigned char match)
 
virtual bool eof ()=0
 Indicates if the end of file has been reached. More...
 
size_t bytesRead ()
 Indicates the number of bytes read in the last operation. More...
 
size_t getBytesRead ()
 Indicates the number of bytes read in the last operation. More...
 
size_t getTotalBytesRead ()
 Indicates the total number of bytes read;. More...
 

Protected Member Functions

 InStream ()
 Protected Constructor for abstract class. More...
 
void zeroBytesRead ()
 
void incBytesRead ()
 
void incBytesRead (size_t incRead)
 
void setBytesRead (size_t lastRead)
 
void zeroTotalBytesRead ()
 

Private Member Functions

 InStream (const InStream &old)
 

Private Attributes

size_t lastRead_
 
size_t totalBytesRead_
 

Detailed Description

This is a very abstract class that can be implemented by classes that want to receive stream input.

Provides basic input functions such as read(), as well as specialized functions for reading in data formats such as readCharHex, etc.

Part of an attempt to avoid the standard template library

Constructor & Destructor Documentation

virtual InStream::~InStream ( )
inlinevirtual

Destructor.

InStream::InStream ( )
inlineprotected

Protected Constructor for abstract class.

InStream::InStream ( const InStream old)
private

Member Function Documentation

virtual bool InStream::eof ( )
pure virtual
size_t InStream::getBytesRead ( )
inline

Indicates the number of bytes read in the last operation.

References lastRead_.

Referenced by UartStream::read(), UartStream::readLines(), UartStream::readUntil(), and NAL9602::retrieveAndQueueIncoming().

virtual const char* InStream::getName ( )
pure virtual

returns name of the stream

Implemented in UartStream, FileInStream, FileIOStream, DeviceIOStream, StrIOStream, and MappedIOStream.

Referenced by DirectoryEntry::Read().

size_t InStream::getTotalBytesRead ( )
inline

Indicates the total number of bytes read;.

References totalBytesRead_.

Referenced by DirectoryEntry::Read(), and DataEntry::Read().

void InStream::incBytesRead ( )
inlineprotected
void InStream::incBytesRead ( size_t  incRead)
inlineprotected

References lastRead_, and totalBytesRead_.

virtual bool InStream::isReadable ( )
pure virtual

indicates whether the stream can actually be read from.

Implemented in NullInStream, UartStream, StrIOStream, FileInStream, FileIOStream, NullIOStream, MappedIOStream, and DeviceIOStream.

Referenced by LogReader::isValid().

InStream& InStream::readChar ( signed char &  value)
inline

reads a single byte to the input buffer/stream

References read().

Referenced by MissionStateLogger::NewResume(), DirectoryEntry::Read(), EventEntry::Read(), readLongLongCompact(), and readUShortCompact().

InStream & InStream::readCharHex ( signed char &  byte)

reads a single unsigned char from the input buffer/stream as 2 hex chars

reads a single unsigned char to the input buffer/stream as 2 hex chars

References read().

Referenced by ElementURI::Read(), and DataAccess::Read().

InStream& InStream::readDouble ( double &  value)
inline

reads a 8-byte double to the input buffer/stream

References read().

InStream& InStream::readFloat ( float &  value)
inline

reads a 4-byte float to the input buffer/stream

References read().

Referenced by MissionStateLogger::NewResume(), and MtxIOStream::read().

InStream& InStream::readFloat2 ( float &  value)
inline

reads a 2-byte float to the input buffer/stream

References read().

InStream& InStream::readFloat3 ( float &  value)
inline

reads a 3-byte float to the input buffer/stream

References read().

InStream& InStream::readInt ( int &  value)
inline

reads a 4-byte integer to the input buffer/stream

References read().

Referenced by MtxIOStream::append(), MissionStateLogger::NewResume(), and MtxIOStream::read().

InStream& InStream::readInt24 ( int &  medInt)
inline

reads a 3-byte integer to the input buffer/stream only works on little-endian machines!

References read().

Referenced by EventEntry::Read().

InStream & InStream::readLine ( char *  buf,
unsigned int  bufsize 
)
virtual

References bytesRead(), eof(), lastRead_, and read().

InStream& InStream::readLongLong ( long long &  value)
inline

reads a 8-byte integer to the input buffer/stream

References read().

InStream & InStream::readLongLongCompact ( long long &  value)

reads a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value, encoded in 1 byte 10xxxxxx+1byte - 14 bit value, encoded in 2 bytes 110xxxxx+2bytes - 21 bit value, encoded in 3 bytes 1110xxxx+3bytes - 28 bit value, encoded in 4 bytes 11110xxx+4bytes - 35 bit value, encoded in 5 bytes 111110xx+5bytes - 42 bit value, encoded in 6 bytes 1111110x+6bytes - 49 bit value, encoded in 7 bytes 11111110+7bytes - 56 bit value, encoded in 8 bytes 11111111+8bytes - 64 bit value, encoded in 9 bytes

reads a signed long long integer as 1 to 9 bytes, encoded as follows: xxxxxxx0 - 7 bit value, encoded in 1 byte xxxxxx01+1byte - 14 bit value, encoded in 2 bytes xxxxx011+2bytes - 21 bit value, encoded in 3 bytes xxxx0111+3bytes - 28 bit value, encoded in 4 bytes xxx01111+4bytes - 35 bit value, encoded in 5 bytes xx011111+5bytes - 42 bit value, encoded in 6 bytes x0111111+6bytes - 49 bit value, encoded in 7 bytes 01111111+7bytes - 56 bit value, encoded in 8 bytes 11111111+8bytes - 64 bit value, encoded in 9 bytes

References bytesRead(), lastRead_, read(), and readChar().

Referenced by LogEntry::ReadTimestamp(), and StrIOStream_Test::testLongLongCompact().

InStream& InStream::readShort ( short &  value)
inline

reads a single short from the input buffer/stream

References read().

Referenced by MissionStateLogger::NewResume(), and DataEntry::Read().

InStream& InStream::readShort ( unsigned short &  value)
inline

reads a single short from the input buffer/stream

References read().

InStream & InStream::readShortHex ( short &  word)

reads a single short from the input buffer/stream as 4 hex chars

reads a single short to the input buffer/stream as 4 hex chars

References read().

Referenced by CodedStr::Read(), DirectoryEntry::Read(), ElementURI::Read(), and DataAccess::Read().

InStream & InStream::readUCharHex ( unsigned char &  byte)

reads a single unsigned char from the input buffer/stream as 2 hex chars

References read().

Referenced by ElementURI::Read(), and DataAccess::Read().

InStream & InStream::readUntil ( char *  buf,
unsigned int  num,
unsigned char  match 
)
virtual
InStream & InStream::readUShortCompact ( unsigned short &  value)

reads an unsigned short integer as 1 to 3 bytes, encoded as follows: xxxxxxx0 - 7 bit value, encoded in 1 byte xxxxxx01+1byte - 14 bit value, encoded in 2 bytes xxxxx011+2bytes - 16 bit value, encoded in 3 bytes

References bytesRead(), lastRead_, read(), and readChar().

Referenced by LogEntry::Read(), SyslogEntry::Read(), and EventEntry::Read().

InStream & InStream::readUShortHex ( unsigned short &  value)

reads a single unsigned short from the input buffer/stream as 4 hex chars

reads a single unsigned short to the input buffer/stream as 4 hex chars

References read().

Referenced by ElementURI::Read().

void InStream::setBytesRead ( size_t  lastRead)
inlineprotected
void InStream::zeroBytesRead ( )
inlineprotected
void InStream::zeroTotalBytesRead ( )
inlineprotected

References totalBytesRead_, and zeroBytesRead().

Referenced by FileInStream::setFile().

Member Data Documentation

size_t InStream::totalBytesRead_
private

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