LRAUV  revA
MappedIOStream Class Reference

Wraps Memory mapped file with an IOStream class. More...

#include <MappedIOStream.h>

Inheritance diagram for MappedIOStream:
Collaboration diagram for MappedIOStream:

Public Member Functions

 MappedIOStream (const Str &filename, bool clobber, size_t chunkSize)
 Constructor. More...
 
virtual ~MappedIOStream ()
 
void close ()
 
virtual IOStreamread (char *buffer, size_t num)
 reads num bytes from buffer to the output buffer/stream More...
 
bool seek (unsigned int location)
 
virtual bool eof ()
 Indicates if the end of file has been reached. More...
 
bool isReadable ()
 indicates whether the stream can actually be read from. More...
 
const char * getName ()
 returns name of the stream More...
 
const StrgetFilename ()
 
const struct stat getStat ()
 
IOStreamwrite (const char *buffer, size_t num)
 writes num bytes from buffer to the output buffer/stream More...
 
virtual IOStreamwrite (const char *buffer)
 writes zero-terminated buffer to the output buffer/stream More...
 
int tell ()
 
void flush ()
 
bool open (bool clobber)
 
bool isWritable ()
 indicates whether the stream can actually be written to. More...
 
- Public Member Functions inherited from InStream
virtual ~InStream ()
 Destructor. 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)
 
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...
 
- Public Member Functions inherited from OutStream
virtual ~OutStream ()
 Destructor. More...
 
virtual OutStreamwriteHex (const char *buffer, size_t num)
 writes num bytes from buffer to the output buffer/stream as hex chars More...
 
virtual OutStreamwriteHex (const char *buffer)
 writes zero-terminated buffer to the output buffer/stream More...
 
OutStreamoperator<< (const Str buffer)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const char buffer[])
 write a Str, using stream operator More...
 
OutStreamoperator<< (const char byte)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const signed char byte)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const unsigned char byte)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const int number)
 write a Str, using stream operator More...
 
OutStreamwriteChar (const signed char value)
 writes a single byte to the output buffer/stream More...
 
OutStreamwriteCharHex (const signed char byte)
 writes a single signed char to the output buffer/stream as 2 hex chars More...
 
OutStreamwriteUCharHex (const unsigned char byte)
 writes a single unsigned char to the output buffer/stream as 2 hex chars More...
 
OutStreamwriteInteger (const int number, const unsigned int radix=10)
 writes an integer as a base-radix string More...
 
OutStreamwriteNumber (const double number, const unsigned int radix=10)
 
OutStreamwriteShort (const short value)
 writes a single short to the output buffer/stream More...
 
OutStreamwriteShortHex (const short word)
 writes a single short to the output buffer/stream as 4 hex chars More...
 
OutStreamwriteUShortHex (const unsigned short word)
 writes a single unsigned short to the output buffer/stream as 4 hex chars More...
 
OutStreamwriteUShortCompact (const unsigned short &value)
 writes 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...
 
OutStreamwriteInt24 (const int medInt)
 writes a 3-byte integer to the output buffer/stream only works on little-endian machines! More...
 
OutStreamwriteInt (const int value)
 writes a 4-byte integer to the output buffer/stream More...
 
OutStreamwriteLongLong (const long long value)
 writes a 8-byte integer to the output buffer/stream More...
 
OutStreamwriteLongLongCompact (const long long &value)
 writes 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...
 
OutStreamwriteFloat (const float value)
 writes a 4-byte float to the output buffer/stream More...
 
OutStreamwriteFloat2 (const float value)
 writes a 2-byte float to the output buffer/stream More...
 
OutStreamwriteFloat3 (const float value)
 writes a 3-byte float to the output buffer/stream More...
 
OutStreamwriteDouble (const double value)
 writes a 8-byte double to the output buffer/stream More...
 
OutStreamwriteDouble6 (const double value)
 
size_t bytesWritten ()
 

Protected Member Functions

bool checkSize (size_t num)
 
- Protected Member Functions inherited from InStream
 InStream ()
 Protected Constructor for abstract class. More...
 
void zeroBytesRead ()
 
void incBytesRead ()
 
void incBytesRead (size_t incRead)
 
void setBytesRead (size_t lastRead)
 
void zeroTotalBytesRead ()
 
- Protected Member Functions inherited from OutStream
 OutStream ()
 Protected Constructor for abstract class. More...
 

Protected Attributes

int file_
 
Str filename_
 
size_t chunkSize_
 
size_t size_
 
unsigned char * ptr_
 
size_t pos_
 
- Protected Attributes inherited from OutStream
size_t lastWritten_
 

Private Member Functions

 MappedIOStream (const MappedIOStream &old)
 

Additional Inherited Members

- Static Protected Attributes inherited from OutStream
static const unsigned char HEX_CHARS [] = "0123456789ABCDEF"
 

Detailed Description

Wraps Memory mapped file with an IOStream class.

Should be faster than MappedIOStream, allocates new files in chunks.

Part of an attempt to avoid the standard template library

Constructor & Destructor Documentation

MappedIOStream::MappedIOStream ( const Str filename,
bool  clobber,
size_t  chunkSize = 4096 
)

Constructor.

References open().

MappedIOStream::~MappedIOStream ( )
virtual

References close().

MappedIOStream::MappedIOStream ( const MappedIOStream old)
private

Member Function Documentation

bool MappedIOStream::checkSize ( size_t  num)
protected

References chunkSize_, file_, ptr_, size_, and write().

Referenced by read(), seek(), and write().

void MappedIOStream::close ( )

References Str::cStr(), file_, filename_, ptr_, and size_.

Referenced by open(), and ~MappedIOStream().

bool MappedIOStream::eof ( )
virtual

Indicates if the end of file has been reached.

Implements InStream.

References isReadable(), pos_, and size_.

void MappedIOStream::flush ( )

References isWritable(), ptr_, and size_.

const Str& MappedIOStream::getFilename ( )
inline

References filename_.

const char* MappedIOStream::getName ( )
inlinevirtual

returns name of the stream

Implements InStream.

References Str::cStr(), and filename_.

const struct stat MappedIOStream::getStat ( )
bool MappedIOStream::isReadable ( )
inlinevirtual

indicates whether the stream can actually be read from.

Implements InStream.

References ptr_.

Referenced by eof(), and tell().

bool MappedIOStream::isWritable ( )
inlinevirtual

indicates whether the stream can actually be written to.

Implements OutStream.

References ptr_.

Referenced by flush().

bool MappedIOStream::open ( bool  clobber)
IOStream & MappedIOStream::read ( char *  buffer,
size_t  num 
)
virtual

reads num bytes from buffer to the output buffer/stream

reads num bytes from the stream to the buffer

Implements InStream.

References checkSize(), pos_, ptr_, and InStream::setBytesRead().

Referenced by MissionStateLogger::NewResume(), and MappedIOStream_Test::test2Read().

int MappedIOStream::tell ( )

References isReadable(), and pos_.

Referenced by MissionStateLogger::NewResume().

IOStream & MappedIOStream::write ( const char *  buffer,
size_t  num 
)
virtual
virtual IOStream& MappedIOStream::write ( const char *  buffer)
inlinevirtual

writes zero-terminated buffer to the output buffer/stream

Reimplemented from OutStream.

References write().

Member Data Documentation

size_t MappedIOStream::chunkSize_
protected

Referenced by checkSize(), and open().

int MappedIOStream::file_
protected

Referenced by checkSize(), close(), and open().

Str MappedIOStream::filename_
protected

Referenced by close(), getFilename(), getName(), and open().

size_t MappedIOStream::pos_
protected

Referenced by eof(), open(), read(), seek(), tell(), and write().

unsigned char* MappedIOStream::ptr_
protected
size_t MappedIOStream::size_
protected

Referenced by checkSize(), close(), eof(), flush(), and open().


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