Gel2D - The free/open source game creation suite

Public Member Functions
gel::GelTextStream Class Reference

Text data stream. More...

#include <gelDataStream.h>

List of all members.

Public Member Functions

 GelTextStream ()
 Default constructor.
 GelTextStream (const GelString &filename, FileMode mode)
 Convenience constructor.
 ~GelTextStream ()
 Destructor.
bool open (const GelString &filename, FileMode mode)
 Opens a file from disk.
bool close ()
 Closes the file associated with this stream.
GelString read (int maxlen)
 Reads a specified number of characters.
GelString readAll ()
 Reads the entire stream.
GelString readLine (int maxlen)
 Reads a line of text.
GelChar readChar ()
 Reads a character from the stream.
bool writeString (const GelString &str)
 Writes text to the stream.
bool writeChar (GelChar chr)
 Writes a character to the stream.
bool flush ()
 Flushes the stream.
long getSize () const
 Gets the size of the file.
long tell () const
 Gets the current value of the stream's position indicator.
bool seek (long offset, DataSeek origin)
 Sets the position of the stream's position indicator.
bool atEnd () const
 Checks if the end of the stream has been reached.

Detailed Description

Text data stream.


Constructor & Destructor Documentation

gel::GelTextStream::GelTextStream ( ) [inline]

Default constructor.

gel::GelTextStream::GelTextStream ( const GelString filename,
FileMode  mode 
)

Convenience constructor.

Opens a file from disk.

See also:
open()
gel::GelTextStream::~GelTextStream ( )

Destructor.

Closes the file associated with this stream.

See also:
close()

Member Function Documentation

bool gel::GelTextStream::open ( const GelString filename,
FileMode  mode 
)

Opens a file from disk.

Parameters:
filename: The name of the file to open.
mode: The mode to open the file with.
Returns:
True if successful, else false.
bool gel::GelTextStream::close ( )

Closes the file associated with this stream.

Returns:
True if the file was closed successfully, else false.
GelString gel::GelTextStream::read ( int  maxlen)

Reads a specified number of characters.

Parameters:
maxlen: The maximum number of characters that will be read.
Returns:
The characters read as a GelString.
GelString gel::GelTextStream::readAll ( )

Reads the entire stream.

This function can consume a significant amount of memory when reading from large files.

Returns:
The characters read as a GelString.
GelString gel::GelTextStream::readLine ( int  maxlen)

Reads a line of text.

Parameters:
maxlen: The maximum line length.
Returns:
A line of text as a GelString.
GelChar gel::GelTextStream::readChar ( )

Reads a character from the stream.

Returns:
The character read as a GelChar.
bool gel::GelTextStream::writeString ( const GelString str)

Writes text to the stream.

Parameters:
str: The string to write
bool gel::GelTextStream::writeChar ( GelChar  chr)

Writes a character to the stream.

Parameters:
chr: The character to write
bool gel::GelTextStream::flush ( )

Flushes the stream.

If the file was open for writing, any unwritten data in the buffer will be written to the file.

Returns:
True if successful, else false.
long gel::GelTextStream::getSize ( ) const [inline]

Gets the size of the file.

Returns:
The size of the file.
long gel::GelTextStream::tell ( ) const

Gets the current value of the stream's position indicator.

Returns:
If successful, the current value of the stream's position indicator, else 0.
bool gel::GelTextStream::seek ( long  offset,
DataSeek  origin 
)

Sets the position of the stream's position indicator.

Parameters:
offset: The new position relative to origin
origin: The reference position to add offset to.
Returns:
True if successful, else false.
bool gel::GelTextStream::atEnd ( ) const

Checks if the end of the stream has been reached.

Returns:
True if the end of the stream has been reached, else false.

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