LRAUV  revA
FileOutStream Class Reference

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

#include <FileOutStream.h>

Inheritance diagram for FileOutStream:
Collaboration diagram for FileOutStream:

Public Member Functions

 FileOutStream (FILE *file=NULL, bool autoClose=false)
 Constructor. More...
 
 FileOutStream (const char *filename, bool append=true, bool rewrite=false)
 Constructor. More...
 
virtual ~FileOutStream ()
 
OutStreamwrite (const char *buffer, size_t num)
 writes num bytes from buffer to the output buffer/stream More...
 
virtual OutStreamwrite (const char *buffer)
 writes zero-terminated buffer to the output buffer/stream More...
 
void setFile (FILE *file)
 Change the assoicated file. More...
 
bool seek (unsigned int location)
 
int tell ()
 
void close ()
 
void flush ()
 
bool open (const char *filename, bool append=true, bool rewrite=false)
 
bool isWritable ()
 indicates whether the stream can actually be written to. More...
 
const char * getName ()
 
- 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 Attributes

FILE * file_
 
bool autoClose_
 
Mutex fileMutex_
 
- Protected Attributes inherited from OutStream
size_t lastWritten_
 

Private Member Functions

 FileOutStream (const FileOutStream &old)
 

Private Attributes

Str filename_
 

Additional Inherited Members

- Protected Member Functions inherited from OutStream
 OutStream ()
 Protected Constructor for abstract class. More...
 
- Static Protected Attributes inherited from OutStream
static const unsigned char HEX_CHARS [] = "0123456789ABCDEF"
 

Detailed Description

Wraps a c FILE* handle with an OutStream class.

Part of an attempt to avoid the standard template library

Constructor & Destructor Documentation

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

Constructor.

FileOutStream::FileOutStream ( const char *  filename,
bool  append = true,
bool  rewrite = false 
)

Constructor.

References open().

FileOutStream::~FileOutStream ( )
virtual

References autoClose_, and close().

FileOutStream::FileOutStream ( const FileOutStream old)
private

Member Function Documentation

void FileOutStream::close ( )

References file_, and fileMutex_.

Referenced by FileLogWriter::close(), open(), and ~FileOutStream().

void FileOutStream::flush ( )

References file_, and fileMutex_.

Referenced by FileLogWriter::endCycle(), and FileLogWriter::write().

const char* FileOutStream::getName ( void  )
inline

References Str::cStr(), and filename_.

Referenced by MtxOutStream::write().

bool FileOutStream::isWritable ( )
inlinevirtual

indicates whether the stream can actually be written to.

Implements OutStream.

References file_.

Referenced by FileLogWriter::isWritable().

bool FileOutStream::open ( const char *  filename,
bool  append = true,
bool  rewrite = false 
)

References close(), file_, and fileMutex_.

Referenced by FileOutStream(), and FileLogWriter::open().

bool FileOutStream::seek ( unsigned int  location)

References file_, and fileMutex_.

void FileOutStream::setFile ( FILE *  file)
inline

Change the assoicated file.

References file_.

int FileOutStream::tell ( )

References file_, and fileMutex_.

OutStream & FileOutStream::write ( const char *  buffer,
size_t  num 
)
virtual

writes num bytes from buffer to the output buffer/stream

Implements OutStream.

References file_, fileMutex_, and OutStream::lastWritten_.

Referenced by write().

virtual OutStream& FileOutStream::write ( const char *  buffer)
inlinevirtual

writes zero-terminated buffer to the output buffer/stream

Reimplemented from OutStream.

References write().

Member Data Documentation

bool FileOutStream::autoClose_
protected

Referenced by ~FileOutStream().

FILE* FileOutStream::file_
protected
Mutex FileOutStream::fileMutex_
protected

Referenced by close(), flush(), open(), seek(), tell(), and write().

Str FileOutStream::filename_
private

Referenced by getName().


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