Exponent::IO::CFileStream Class Reference

List of all members.

Detailed Description

Binary file stream, writes platform independant (ie endian swapped) data in binary format.

Wrapper class around FILE read and write

Date:
11/04/2006
Author:
Paul Chana
Version:
1.0.0 Initial version

1.0.1 Added advance stream function

Note:
All contents of this source code are copyright 2005 Exp Digital Uk.
This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
Certain sections of this code may come from other sources. They are credited where applicable.
If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk
Id
CFileStream.hpp,v 1.9 2007/02/08 21:06:44 paul Exp

Definition at line 35 of file CFileStream.hpp.

Public Types

Public Member Functions

Protected Member Functions

Protected Attributes

Static Protected Attributes


Member Enumeration Documentation

enum Exponent::IO::CFileStream::EStreamMode

Enumeration of stream mmodes.

Enumerator:
e_input  Input mode
e_output  Output mode

Definition at line 51 of file CFileStream.hpp.


Constructor & Destructor Documentation

Exponent::IO::CFileStream::CFileStream (  ) 

Construction

Exponent::IO::CFileStream::CFileStream ( const CSystemString filename,
const EStreamMode  status,
const bool  fileIsLittleEndian = true 
)

Construction which opens a binary file

Parameters:
filename The name of the file
status The status with which to open the file
fileIsLittleEndian If true bytes are little endian order, else big endian

virtual Exponent::IO::CFileStream::~CFileStream (  )  [virtual]

Destruction


Member Function Documentation

bool Exponent::IO::CFileStream::advanceStream ( const long  amount  ) 

Advance the stream, can be used to move backwards by using a negative value for amount

Parameters:
amount The amount to move on by
Return values:
bool True if moved, false otherwise

void Exponent::IO::CFileStream::closeStream (  ) 

Close the stream

long Exponent::IO::CFileStream::getStreamPosition (  ) 

Get the stream position

Return values:
long The current file position, -1 on error
See also:
ftell

long Exponent::IO::CFileStream::getStreamSize (  ) 

Get the stream size

Return values:
long -1 on error or if stream open for write, length in bytes otherwise

bool Exponent::IO::CFileStream::hasErrorOccurred (  )  const [inline]

Has an error occurred

Return values:
bool True if an error has occurred recently

Definition at line 315 of file CFileStream.hpp.

References m_errorState.

bool Exponent::IO::CFileStream::hasReachEndOfFile (  )  const

Have we reached the end of the file

Return values:
bool True if reach eof, flse otherwise

bool Exponent::IO::CFileStream::isStreamOpen (  )  const [inline]

Is the stream open

Return values:
bool True if stream open, false otherwise

Definition at line 99 of file CFileStream.hpp.

References m_streamIsOpen.

bool Exponent::IO::CFileStream::moveToStreamPosition ( const long  position  ) 

Move to a stream postion

Parameters:
position The position to mvoe to
Return values:
bool True if moved, false otherwise

bool Exponent::IO::CFileStream::moveToStreamStart (  ) 

Move to stream beggining

bool Exponent::IO::CFileStream::openStream ( const CSystemString path,
const EStreamMode  mode,
const bool  fileIsLittleEndian = true 
)

Open the stream

Parameters:
path The path to the file to read / write
mode The streaming mode to use
fileIsLittleEndian If true bytes are little endian order, else big endian
Return values:
bool True if opened properly, false otherwise

CFileStream& Exponent::IO::CFileStream::operator<< ( const double &  value  ) 

Stream output of a long (64 bit)

Parameters:
value The value to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const float &  value  ) 

Stream output of a long (32 bit)

Parameters:
value The value to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const unsigned long &  value  ) 

Stream output of a long (32 bit)

Parameters:
value The long to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const long &  value  ) 

Stream output of a long (32 bit)

Parameters:
value The value to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const unsigned short &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const short &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const bool &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The bool to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const unsigned char &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator<< ( const char &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( double &  value  ) 

Stream output of a long (64 bit)

Parameters:
value The value to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( float &  value  ) 

Stream output of a long (32 bit)

Parameters:
value The value to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( unsigned long &  value  ) 

Stream output of a long (32 bit)

Parameters:
value The long to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( long &  value  ) 

Stream output of a long (32 bit)

Parameters:
value The value to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( unsigned short &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( short &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( bool &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The bool to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( unsigned char &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

CFileStream& Exponent::IO::CFileStream::operator>> ( char &  byte  ) 

Stream output of a character (BYTE)

Parameters:
byte The character to write
Return values:
CFileStream & A reference to this

void Exponent::IO::CFileStream::read16Bits ( void *  value  )  [protected]

Read a 16 bit value swapping byte order as necessary

Parameters:
value The value to read

void Exponent::IO::CFileStream::read32Bits ( void *  value  )  [protected]

Read a 32 bit value swapping byte order as necessary

Parameters:
value The value to read

void Exponent::IO::CFileStream::read64Bits ( void *  value  )  [protected]

Read a 64 bit value swapping byte order as necessary

Parameters:
value The value to read

bool Exponent::IO::CFileStream::readDataFromStream ( void *  data,
const size_t  numberOfBytes 
)

Read a block of data from the stream

Parameters:
data The data to read in to on return holds the data. Must be at least numberOfBytes in size
numberOfBytes The size of the data in bytes
Return values:
bool True if read from the stream, false otherwise

bool Exponent::IO::CFileStream::readShortsFromStream ( short *  data,
const unsigned long  numberOfElements 
)

Read a block of shorts from the stream

Parameters:
data The data to read in to, on return holds the data. Must be at least numberOfElements in size
numberOfElements The size of the data in elements
Return values:
bool True if read from the stream, false otherwise

void Exponent::IO::CFileStream::setStreamEndianess ( const bool  fileIsLittleEndian = true  ) 

Set the stream endianess

Parameters:
fileIsLittleEndian True if little endian, false otherwise

bool Exponent::IO::CFileStream::swapBits (  )  const [protected]

Should swap bits

Return values:
bool True if bits need to be swapped

bool Exponent::IO::CFileStream::validForInput (  ) 

Valid for output

Return values:
bool True if file is open for input, false otherwise

bool Exponent::IO::CFileStream::validForOutput (  ) 

Valid for output

Return values:
bool True if file is open for output, false otherwise

void Exponent::IO::CFileStream::write16Bits ( const void *  value  )  [protected]

Write a 16 bit value swapping byte order as necessary

Parameters:
value The value to write

void Exponent::IO::CFileStream::write32Bits ( const void *  value  )  [protected]

Write a 32 bit value swapping byte order as necessary

Parameters:
value The value to write

void Exponent::IO::CFileStream::write64Bits ( const void *  value  )  [protected]

Write a 64 bit value swapping byte order as necessary

Parameters:
value The value to write

bool Exponent::IO::CFileStream::writeDataToStream ( const void *  data,
const size_t  numberOfBytes 
)

Write a block of data to the stream

Parameters:
data The data to write
numberOfBytes The size of the data in bytes
Return values:
bool True if written to the stream, false otherwise


Member Data Documentation

const unsigned int Exponent::IO::CFileStream::CFILESTREAM_16BIT_SIZE = 2 [static, protected]

Size of 16 bit

Definition at line 378 of file CFileStream.hpp.

const unsigned int Exponent::IO::CFileStream::CFILESTREAM_32BIT_SIZE = 4 [static, protected]

Size of eight bit

Definition at line 379 of file CFileStream.hpp.

const unsigned int Exponent::IO::CFileStream::CFILESTREAM_64BIT_SIZE = 8 [static, protected]

Size of eight bit

Definition at line 380 of file CFileStream.hpp.

const unsigned int Exponent::IO::CFileStream::CFILESTREAM_8BIT_SIZE = 1 [static, protected]

Size of 8 bit

Definition at line 377 of file CFileStream.hpp.

bool Exponent::IO::CFileStream::m_errorState [protected]

Has an error occurred

Definition at line 387 of file CFileStream.hpp.

Referenced by hasErrorOccurred().

FILE* Exponent::IO::CFileStream::m_file [protected]

The file we are writing to

Definition at line 384 of file CFileStream.hpp.

bool Exponent::IO::CFileStream::m_fileIsLittleEndian [protected]

Are bytes little or big endian

Definition at line 388 of file CFileStream.hpp.

bool Exponent::IO::CFileStream::m_streamIsOpen [protected]

Is the file open

Definition at line 386 of file CFileStream.hpp.

Referenced by isStreamOpen().

EStreamMode Exponent::IO::CFileStream::m_streamStatus [protected]

Status of the stream

Definition at line 385 of file CFileStream.hpp.


Infinity API - Exponent::IO::CFileStream Class Reference generated on 7 Mar 2007