PTLib  Version 2.10.4
PTextFile Class Reference

A class representing a a structured file that is portable accross CPU architectures. More...

#include <textfile.h>

Inheritance diagram for PTextFile:
PFile PChannel PObject

List of all members.

Public Member Functions

Construction
 PTextFile ()
 Create a text file object but do not open it.
 PTextFile (OpenMode mode, int opts=ModeDefault)
 Create a unique temporary file name, and open the file in the specified mode and using the specified options.
 PTextFile (const PFilePath &name, OpenMode mode=ReadWrite, int opts=ModeDefault)
 Create a text file object with the specified name and open it in the specified mode and with the specified options.
Line I/O functions
PBoolean ReadLine (PString &str)
 Read a line from the text file.
PBoolean WriteLine (const PString &str)
 Read a line from the text file.

Detailed Description

A class representing a a structured file that is portable accross CPU architectures.

Essentially this will normalise the end of line character which differs fromplatform to platform.


Constructor & Destructor Documentation

Create a text file object but do not open it.

It does not initially have a valid file name. However, an attempt to open the file using the PFile::Open() function will generate a unique temporary file.

PTextFile::PTextFile ( OpenMode  mode,
int  opts = ModeDefault 
)

Create a unique temporary file name, and open the file in the specified mode and using the specified options.

Note that opening a new, unique, temporary file name in ReadOnly mode will always fail. This would only be usefull in a mode and options that will create the file.

The PChannel::IsOpen() function may be used after object construction to determine if the file was successfully opened.

Parameters:
modeMode in which to open the file.
optsOpenOptions enum# for open operation.
PTextFile::PTextFile ( const PFilePath name,
OpenMode  mode = ReadWrite,
int  opts = ModeDefault 
)

Create a text file object with the specified name and open it in the specified mode and with the specified options.

The PChannel::IsOpen() function may be used after object construction to determine if the file was successfully opened.

Parameters:
nameName of file to open.
modeMode in which to open the file.
optsOpenOptions enum# for open operation.

Member Function Documentation

Read a line from the text file.

What constitutes an end of line in the file is platform dependent.

Use the PChannel::GetLastError() function to determine if there was some error other than end of file.

Returns:
true if successful, false if at end of file or a read error.
Parameters:
strString into which line of text is read.

Read a line from the text file.

What constitutes an end of line in the file is platform dependent.

Use the PChannel::GetLastError() function to determine the failure mode.

Returns:
true if successful, false if an error occurred.
Parameters:
strString to write with end of line terminator.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines