CoreIOReader Class Reference

The core input class. More...

#include <core_io_reader.h>

Inheritance diagram for CoreIOReader:

Console FileReader

List of all members.

Public Member Functions

 CoreIOReader (FILE *_inputBuffer, bool _isUnicode, LineEndingType _lnEnding=CC_LN_NATIVE)
 The constructor.
virtual ~CoreIOReader ()
 The destructor.
virtual bool EndOfFile ()
 Determines whether the end of the file has been reached.
virtual cc_int64_t Length ()
 Determines the length of the file buffer.
virtual bool IsOpen ()
 Validates that the file buffer isn't NULL.
virtual int Read (char *_buffer, size_t _bufferLength, size_t _bufferIndex, size_t _count)
 Reads a block of data from the file buffer.
virtual int ReadLine (std::string &_string)
 Reads a line of data.
virtual int ReadLine (char *_buffer, size_t _bufferLength)
 Reads a line of data.
virtual CrissCross::Errors SetLineEndings (LineEndingType _ending)
 Sets the line ending convention used by this CoreIOReader instance.
virtual cc_int64_t Position ()
 Gets the current position in the buffer.
virtual int Seek (cc_int64_t _position)
 Seeks to a location in the buffer.
virtual int Forward (cc_int64_t _position)
 Moves forward to a location in the buffer.
void Flush ()
 Flushes the input buffer.

Protected Member Functions

int Seek (cc_int64_t _position, int _origin)
 Seeks to a location in the buffer.

Protected Attributes

char m_lineEnding [4]
 Line ending buffer.
FILE * m_fileInputPointer
 Input/output FILE pointer.
bool m_unicode
 Indicates whether the buffer is to be read in unicode or not. (UNIMPLEMENTED).
CrissCross::System::Mutex m_ioMutex
 Thread-safe mutex.


Detailed Description

The core input class.

A class inherited by most I/O classes, including Console and FileReader.


Constructor & Destructor Documentation

CoreIOReader ( FILE *  _inputBuffer,
bool  _isUnicode,
LineEndingType  _lnEnding = CC_LN_NATIVE 
)

The constructor.

Creates a new CoreIOReader instance. Will initialize line endings to the platform's default, also initializes CoreIOReader::m_ioMutex.

Parameters:
_inputBuffer The buffer to be used for read operations.
_isUnicode The buffer is going to be a Unicode read buffer. (UNIMPLEMENTED)
_lnEnding The line ending to use.


Member Function Documentation

virtual bool EndOfFile (  )  [virtual]

Determines whether the end of the file has been reached.

Returns:
Boolean indicating whether the end of the file has been reached.

Reimplemented in Console.

virtual int Forward ( cc_int64_t  _position  )  [virtual]

Moves forward to a location in the buffer.

Parameters:
_position Position to seek to, relative to the current position in the buffer.
Returns:
An integer indicating the result of the operation. 0 indicates success. Any non-zero number indicates failure.

Reimplemented in Console.

virtual bool IsOpen (  )  [virtual]

Validates that the file buffer isn't NULL.

Returns:
Boolean indicating whether the file is safe to read from.

virtual cc_int64_t Length (  )  [virtual]

Determines the length of the file buffer.

Returns:
Indicates the length of the buffer in bytes.

Reimplemented in Console.

virtual cc_int64_t Position (  )  [virtual]

Gets the current position in the buffer.

Returns:
The current position in the buffer.

virtual int Read ( char *  _buffer,
size_t  _bufferLength,
size_t  _bufferIndex,
size_t  _count 
) [virtual]

Reads a block of data from the file buffer.

Parameters:
_buffer The output buffer to read to.
_bufferLength The size of _buffer (in bytes).
_bufferIndex The position in _buffer to begin writing.
_count The number of bytes to read.
Returns:
The actual number of bytes read.

Reimplemented in Console.

virtual int ReadLine ( char *  _buffer,
size_t  _bufferLength 
) [virtual]

Reads a line of data.

Parameters:
_buffer A character buffer for the data to be stored in.
_bufferLength The length of the buffer specified in _buffer.
Returns:
The number of bytes read. On failure, -1 is returned.

virtual int ReadLine ( std::string &  _string  )  [virtual]

Reads a line of data.

Data returned by this function should be copied to another location before being parsed.

Parameters:
_string A reference of an std::string where the data will be stored.
Returns:
The number of bytes read. On failure, -1 is returned.

int Seek ( cc_int64_t  _position,
int  _origin 
) [protected]

Seeks to a location in the buffer.

Parameters:
_position Position to seek to, relative to _origin.
_origin Can be one of SEEK_SET, SEEK_CUR, or SEEK_END.
Returns:
An integer indicating the result of the operation. 0 indicates success. Any non-zero number indicates failure.

virtual int Seek ( cc_int64_t  _position  )  [virtual]

Seeks to a location in the buffer.

Parameters:
_position Position to seek to, relative to the first byte of the buffer.
Returns:
An integer indicating the result of the operation. 0 indicates success. Any non-zero number indicates failure.

Reimplemented in Console.

virtual CrissCross::Errors SetLineEndings ( LineEndingType  _ending  )  [virtual]

Sets the line ending convention used by this CoreIOReader instance.

Parameters:
_ending Any of the LineEndingType values.


Member Data Documentation

Thread-safe mutex.

Prevents more than one read from occurring simultaneously.

char m_lineEnding[4] [protected]

Line ending buffer.

Stores the line ending selected by CoreIOReader::SetLineEndings.


Generated on Sun Feb 8 11:10:00 2009 for CrissCross by  doxygen 1.5.8