LRAUV  revA
FileInStream Class Reference

Wraps a c FILE* handle with an InStream class. More...

#include <FileInStream.h>

Inheritance diagram for FileInStream:
Collaboration diagram for FileInStream:

Public Member Functions

 FileInStream (FILE *file=NULL, bool autoClose=false)
 Constructor. More...
 
 FileInStream (const char *filename)
 Constructor. More...
 
virtual ~FileInStream ()
 
void close ()
 
virtual InStreamread (char *buffer, size_t num)
 reads num bytes from buffer to the output buffer/stream More...
 
void setFile (FILE *file, const char *filename)
 Change the assoicated file. More...
 
bool seek (unsigned int location)
 
virtual bool eof ()
 Indicates if the end of file has been reached. More...
 
virtual void clearErr ()
 
bool isReadable ()
 indicates whether the stream can actually be read from. More...
 
const char * getName ()
 returns name of the stream 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...
 

Protected Attributes

FILE * file_
 
bool autoClose_
 
Mutex fileMutex_
 

Private Member Functions

 FileInStream (const FileInStream &old)
 

Private Attributes

Str filename_
 

Additional Inherited Members

- 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 ()
 

Detailed Description

Wraps a c FILE* handle with an InStream class.

Part of an attempt to avoid the standard template library

Constructor & Destructor Documentation

FileInStream::FileInStream ( FILE *  file = NULL,
bool  autoClose = false 
)

Constructor.

FileInStream::FileInStream ( const char *  filename)

Constructor.

References file_, and filename_.

FileInStream::~FileInStream ( )
virtual

References autoClose_, and close().

FileInStream::FileInStream ( const FileInStream old)
private

Member Function Documentation

void FileInStream::clearErr ( )
virtual

References file_, and fileMutex_.

void FileInStream::close ( )

References file_, and fileMutex_.

Referenced by ~FileInStream().

bool FileInStream::eof ( )
virtual

Indicates if the end of file has been reached.

Implements InStream.

References file_, and fileMutex_.

Referenced by MissionManager::LogMission(), and FileLogReader::read().

const char* FileInStream::getName ( )
inlinevirtual

returns name of the stream

Implements InStream.

References Str::cStr(), and filename_.

bool FileInStream::isReadable ( )
inlinevirtual

indicates whether the stream can actually be read from.

Implements InStream.

References file_.

Referenced by FileLogReader::isReadable(), and NAL9602::sendingFillBuffer().

InStream & FileInStream::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 file_, fileMutex_, and InStream::setBytesRead().

Referenced by MissionManager::LogMission(), and NAL9602::sendingFillBuffer().

bool FileInStream::seek ( unsigned int  location)

References file_, and fileMutex_.

Referenced by MissionManager::LogMission().

void FileInStream::setFile ( FILE *  file,
const char *  filename 
)
inline

Change the assoicated file.

References file_, filename_, and InStream::zeroTotalBytesRead().

Referenced by FileLogReader::FileLogReader(), and FileLogReader::read().

Member Data Documentation

bool FileInStream::autoClose_
protected

Referenced by ~FileInStream().

FILE* FileInStream::file_
protected
Mutex FileInStream::fileMutex_
protected

Referenced by clearErr(), close(), eof(), read(), and seek().

Str FileInStream::filename_
private

Referenced by FileInStream(), getName(), and setFile().


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