pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
Public Member Functions | Static Public Member Functions
TextFile Class Reference

A utility class for reading and writing text files. More...

Inherits SmartPointerContainer< SmartPointerType, enableWeak >.

List of all members.

Public Member Functions

 TextFile () throw ()
 Creates a null object.
 TextFile (Text const &path) throw ()
 Creates a text file reader from the given path.
 TextFile (Text const &path, const bool writable, const bool clearContents=false) throw ()
 Creates a text file reader or writer from the given path.
 TextFile (const char *path) throw ()
 Creates a text file reader from the given path.
 TextFile (const char *path, const bool writable, const bool clearContents=false) throw ()
 Creates a text file reader or writer from the given path.
 TextFile (FilePathArray const &fileArray, const int multiMode) throw ()
 Creates a multiple text file reader from the array of files.
 TextFile (TextFileQueue const &fileQueue) throw ()
 Creates a multiple text file reader with a queue of files.
 TextFile (TextFile const &copy) throw ()
 Copy constructor.
TextFileoperator= (TextFile const &other) throw ()
 Assignment operator.
Text readLine (const int maximumLength=1024) throw ()
 Attempts to read a line of text from the file.
LongLong getPosition () const throw ()
 Gets the position of the file stream.
void setPosition (const LongLong position) throw ()
 Sets the position of the file stream.
void setEof () throw ()
 Sets the position of the file stream to the end of the file.
bool isEof () const throw ()
 Determines if the file stream is positioned at its end.
template<class ValueType >
void writeValue (const ValueType value) throw ()
 Write a numerical value as text to the file.
void write (const char *text) throw ()
 Write a string of text to the file.
void write (Text const &text) throw ()
 Write a string of text to the file.
void writeLine (const char *text) throw ()
 Write a string of text to the file and move to a new line.
void writeLine (Text const &text) throw ()
 Write a string of text to the file and move to a new line.

Static Public Member Functions

static TextFile fromWeak (Weak const &weak) throw ()
 Get a weakly linked copy of this object.

Detailed Description

A utility class for reading and writing text files.

See also:
BinaryFile

Constructor & Destructor Documentation

TextFile::TextFile ( ) throw () [inline]

Creates a null object.

This can't be used for reading or writing.

TextFile::TextFile ( Text const &  path) throw () [inline]

Creates a text file reader from the given path.

Parameters:
pathThe path of the file to read or write (this must already exist).
TextFile::TextFile ( Text const &  path,
const bool  writable,
const bool  clearContents = false 
) throw () [inline]

Creates a text file reader or writer from the given path.

Parameters:
pathThe path of the file to read or write. If writable is false then this file must exist.
writableIf true this creates a readable and writable file, otherwise it is a read-only file.
clearContentsIf false then an exisiting file's contents will be retained AND the write operations will always be appended to the end of the file. If true the file's contents will be erased and write operations can be repositioned. It is safer to update an existing file by using a temporary file and copy the contents when all the changes are complete. This must be false if writable is also false.
TextFile::TextFile ( const char *  path) throw () [inline]

Creates a text file reader from the given path.

TextFile::TextFile ( const char *  path,
const bool  writable,
const bool  clearContents = false 
) throw () [inline]

Creates a text file reader or writer from the given path.

Parameters:
pathThe path of the file to read or write. If writable is false then this file must exist.
writableIf true this creates a readable and writable file, otherwise it is a read-only file.
clearContentsIf false then an exisiting file's contents will be retained AND the write operations will always be appended to the end of the file. If true the file's contents will be erased and write operations can be repositioned. It is safer to update an existing file by using a temporary file and copy the contents when all the changes are complete. This must be false if writable is also false.
TextFile::TextFile ( TextFile const &  copy) throw () [inline]

Copy constructor.

Note that a deep copy is not made, the copy will refer to exactly the same data.


Member Function Documentation

static TextFile TextFile::fromWeak ( Weak const &  weak) throw () [inline, static]

Get a weakly linked copy of this object.

This will return a blank/empty/null object of this type if the original has already been deleted.

LongLong TextFile::getPosition ( ) const throw () [inline]

Gets the position of the file stream.

bool TextFile::isEof ( ) const throw () [inline]

Determines if the file stream is positioned at its end.

TextFile& TextFile::operator= ( TextFile const &  other) throw () [inline]

Assignment operator.

Text TextFile::readLine ( const int  maximumLength = 1024) throw () [inline]

Attempts to read a line of text from the file.

This is returned as Text and the file stream is repositioned.

void TextFile::setEof ( ) throw () [inline]

Sets the position of the file stream to the end of the file.

void TextFile::setPosition ( const LongLong  position) throw () [inline]

Sets the position of the file stream.

0 is the start of the stream.

void TextFile::write ( const char *  text) throw () [inline]

Write a string of text to the file.

void TextFile::write ( Text const &  text) throw () [inline]

Write a string of text to the file.

void TextFile::writeLine ( const char *  text) throw () [inline]

Write a string of text to the file and move to a new line.

void TextFile::writeLine ( Text const &  text) throw () [inline]

Write a string of text to the file and move to a new line.

template<class ValueType >
void TextFile::writeValue ( const ValueType  value) throw () [inline]

Write a numerical value as text to the file.

This must be one of: char, short, int, long or LongLong (and their unsigned versions).


The documentation for this class was generated from the following file:
 All Classes Functions Typedefs Enumerations Enumerator Properties