Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends

alize::FileReader Class Reference

#include <FileReader.h>

Inheritance diagram for alize::FileReader:
Inheritance graph
[legend]
Collaboration diagram for alize::FileReader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileReader (const FileName &, const String &path, const String &extension, bool swap)
virtual ~FileReader ()
bool isClosed () const
bool isOpen () const
virtual void close ()
virtual void reset ()
char readChar ()
int readInt2 ()
long readInt4 ()
unsigned long readUInt4 ()
double readDouble ()
float readFloat ()
FloatVectorreadFloats (FloatVector &v)
unsigned long readSomeFloats (FloatVector &v)
const StringreadLine ()
const StringreadString (unsigned long length)
const StringgetFullFileName () const
const StringgetFileName () const
void open ()
unsigned long getFileLength ()
void seek (unsigned long pos)
void rewind ()
long tell ()
bool & swap ()
void swap2Bytes (void *src, void *dest)
void swap4Bytes (void *src, void *dest)
void swap4Bytes (void *src)
void swap8Bytes (void *src, void *dest)
virtual String toString () const
virtual String getClassName () const

Static Public Member Functions

static FileReadercreate (const FileName &f, const String &path, const String &extension, bool swap)

Protected Attributes

String _fullFileName

Private Member Functions

void read (void *buffer, unsigned long length)
 FileReader (const FileReader &)
const FileReaderoperator= (const FileReader &)
bool operator== (const FileReader &) const
bool operator!= (const FileReader &) const

Private Attributes

FILE * _pFileStruct
FileName _fileName
String _path
String _extension
unsigned long _fileLength
bool _fileLengthDefined
String _string
bool _swap

Friends

class TestFeatureFileReaderRaw
class TestFeatureFileReaderHTK
class TestFeatureFileReaderSPro4
class TestFeatureFileReader
class TestMixtureFileReaderRaw
class TestMixtureFileReaderAmiral

Detailed Description

Convenient class used to read a file. DO NOT USE ***

Author:
Frederic Wils frederic.wils@lia.univ-avignon.fr
Version:
1.0
Date:
2003

Definition at line 84 of file FileReader.h.


Constructor & Destructor Documentation

alize::FileReader::FileReader ( const FileName ,
const String path,
const String extension,
bool  swap 
) [explicit]
virtual alize::FileReader::~FileReader (  ) [virtual]

Close the opened file (if it is).

alize::FileReader::FileReader ( const FileReader  ) [private]

Member Function Documentation

virtual void alize::FileReader::close (  ) [virtual]

Closes the file and releases any system resources associated with the stream

Exceptions:
IOExceptionif an I/O error occurs

Referenced by alize::ConfigFileReaderXml::eventError(), alize::ConfigFileReaderXml::readConfig(), alize::ConfigFileReaderRaw::readConfig(), and alize::XListFileReader::readList().

static FileReader& alize::FileReader::create ( const FileName f,
const String path,
const String extension,
bool  swap 
) [static]
virtual String alize::FileReader::getClassName (  ) const [virtual]

Returns the name of the class

Returns:
the name of the class of the object as a String

Implements alize::Object.

unsigned long alize::FileReader::getFileLength (  )

Reads and returns the file length

Exceptions:
IOExceptionif an I/O error occurs
Returns:
the length of the file in bytes
const String& alize::FileReader::getFileName (  ) const

Returns the name of the file.

Returns:
the name of the file.
const String& alize::FileReader::getFullFileName (  ) const

Returns the full name of the file.

Returns:
the full name of the file.

Referenced by alize::ConfigFileReaderXml::eventError().

bool alize::FileReader::isClosed (  ) const

Tests whether the file is closed

Returns:
true if the file is closed; false otherwise
bool alize::FileReader::isOpen (  ) const

Tests whether the file is opened

Returns:
true if the file is opened; false otherwise
void alize::FileReader::open (  )

Opens the file. If it is already opened, closes it beforehand.

Exceptions:
FileNotFoundException
IOExceptionif an I/O error occurs
bool alize::FileReader::operator!= ( const FileReader  ) const [private]

Not implemented

const FileReader& alize::FileReader::operator= ( const FileReader  ) [private]

Not implemented

bool alize::FileReader::operator== ( const FileReader  ) const [private]

Not implemented

void alize::FileReader::read ( void *  buffer,
unsigned long  length 
) [private]

flag for numeric data Low-level method to read bytes from a file.

Parameters:
bufferA pointer to a memory area to store the data number of bytes to read
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
char alize::FileReader::readChar (  )

Reads an input byte

Returns:
the char value
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
double alize::FileReader::readDouble (  )

Reads eight input bytes

Returns:
the double value
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
float alize::FileReader::readFloat (  )

Reads four input bytes

Returns:
the float value
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
FloatVector& alize::FileReader::readFloats ( FloatVector v )

Reads a set of float value (4 bytes)

Parameters:
vthe vector to fill
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
int alize::FileReader::readInt2 (  )

Reads two input bytes

Returns:
the value in a integer variable
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
long alize::FileReader::readInt4 (  )

Reads FOUR input bytes

Returns:
the value in a long variable
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
const String& alize::FileReader::readLine (  )

Reads the next line of text from the input stream. It reads successive bytes until it encounters a line terminator or end of file. The characters read are then returned as a String. If end of file is encountered then a EOFException is thrown. If the character '
' is encountered, it is discarded and reading ceases. If the character '' is encountered, it is discarded and, if the following byte converts to the character '
', then that is discarded also; reading then ceases. If end of file is encountered before either of the characters '
' and '' is encountered, reading ceases. Once reading has ceased, a String is returned that contains all the characters read and not discarded, taken in order.

Returns:
the next line of text from the input stream
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif the end of file is encountered

Referenced by alize::ConfigFileReaderRaw::readConfig(), and alize::XListFileReader::readList().

unsigned long alize::FileReader::readSomeFloats ( FloatVector v )

Tries to read a set of float value (4 bytes). The number is determined by the smaller between vector size and the number of available float values in the stream before the end of its buffer

Parameters:
vthe vector to fill
Returns:
the number of float values read
Exceptions:
IOExceptionif an I/O error occurs
const String& alize::FileReader::readString ( unsigned long  length )

Reads a sequence of 'length' characters.

Parameters:
lengthnumber of characters to read
Returns:
a constant reference to a string of the characters read
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached

Referenced by alize::ConfigFileReaderXml::readOneChar().

unsigned long alize::FileReader::readUInt4 (  )

Reads four input bytes

Returns:
the value in an unsigned long variable
Exceptions:
IOExceptionif an I/O error occurs
EOFExceptionif end of file has been reached
virtual void alize::FileReader::reset (  ) [virtual]

Repositions the file position indicator to the beginning of the file (if it is opened). Does nothing if the file is closed.

Exceptions:
IOExceptionif an I/O error occurs
void alize::FileReader::rewind (  )
void alize::FileReader::seek ( unsigned long  pos )
Exceptions:
IOExceptionif an I/O error occurs
bool& alize::FileReader::swap (  )
void alize::FileReader::swap2Bytes ( void *  src,
void *  dest 
)
void alize::FileReader::swap4Bytes ( void *  src,
void *  dest 
)
void alize::FileReader::swap4Bytes ( void *  src )
void alize::FileReader::swap8Bytes ( void *  src,
void *  dest 
)
long alize::FileReader::tell (  )
virtual String alize::FileReader::toString (  ) const [virtual]

This method is frequently overridden in the derived classes. If it is not, it returns the name of the class of the object and the address of the object

Returns:
a description of the object

Reimplemented from alize::Object.


Friends And Related Function Documentation

friend class TestFeatureFileReader [friend]

Definition at line 90 of file FileReader.h.

friend class TestFeatureFileReaderHTK [friend]

Definition at line 88 of file FileReader.h.

friend class TestFeatureFileReaderRaw [friend]

Definition at line 87 of file FileReader.h.

friend class TestFeatureFileReaderSPro4 [friend]

Definition at line 89 of file FileReader.h.

friend class TestMixtureFileReaderAmiral [friend]

Definition at line 92 of file FileReader.h.

friend class TestMixtureFileReaderRaw [friend]

Definition at line 91 of file FileReader.h.


Member Data Documentation

Definition at line 261 of file FileReader.h.

unsigned long alize::FileReader::_fileLength [private]

Definition at line 262 of file FileReader.h.

Definition at line 263 of file FileReader.h.

current file descriptor. Can be NULL

Definition at line 259 of file FileReader.h.

Definition at line 253 of file FileReader.h.

Definition at line 260 of file FileReader.h.

Definition at line 258 of file FileReader.h.

String alize::FileReader::_string [mutable, private]

Definition at line 264 of file FileReader.h.

bool alize::FileReader::_swap [private]

to store temporary data

Definition at line 265 of file FileReader.h.


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