WRAPPERS::File Class Reference

Wrapper for FILE* obtained by fopen. More...

#include <Wrappers.h>

List of all members.

Public Member Functions

 File (FILE *fp=0)
 Create a File from a FILE* initialized by fopen().
 File (const char *path, const char *mode)
 Create a File by specifying a name and mode.
 File (File &o)
 Create a File from a File object.
 ~File ()
 Close the file.
 operator const FILE * () const
 The File object can be passed on as a const FILE*.
FILE * get ()
 Bypassing the File wrapper.
const Fileoperator= (File &rhs)
 File assignment operator.

Private Member Functions

void close (FILE *fp) const

Private Attributes

FILE * m_fp


Detailed Description

Wrapper for FILE* obtained by fopen.

The file is automatically closed when the File object is destroyed. Copying a File copies the FILE* and transfers ownership to the destination. If more than one File owns the same FILE* at the same time the behavior of the program is undefined.


Constructor & Destructor Documentation

WRAPPERS::File::File ( FILE *  fp = 0  )  [inline]

Create a File from a FILE* initialized by fopen().

Parameters:
fp a FILE* returned by fopen or similar, the default is NULL
After creation the FILE* is owned by the File object and should not be released (closed) other then by destroying the File object.

WRAPPERS::File::File ( const char *  path,
const char *  mode 
) [inline]

Create a File by specifying a name and mode.

Parameters:
path the path of the file to create.
mode a mode in which to open the file, the mode must be accepted by fopen().

WRAPPERS::File::File ( File o  )  [inline]

Create a File from a File object.

Parameters:
o an initialized File object
This object now owns the FILE* previously owned by o, which has given up ownsership.

WRAPPERS::File::~File (  )  [inline]

Close the file.


Member Function Documentation

void WRAPPERS::File::close ( FILE *  fp  )  const [inline, private]

FILE* WRAPPERS::File::get (  )  [inline]

Bypassing the File wrapper.

Returns:
The raw FILE* being managed.
You can get a copy of the FILE* that this object owns, for situations such as passing to a function which only accepts a raw FILE*. For situations where a const FILE* is sufficient you don't need this function.

Note:
This File still owns the FILE* and will close it when destroyed.

WRAPPERS::File::operator const FILE * (  )  const [inline]

The File object can be passed on as a const FILE*.

const File& WRAPPERS::File::operator= ( File rhs  )  [inline]

File assignment operator.

Parameters:
rhs Another File
This object now owns the FILE* previously owned by rhs, which has given up ownsership. The FILE* that this one used to own and track has been closed.


Member Data Documentation

FILE* WRAPPERS::File::m_fp [private]


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 15:33:27 2007 for MetalWarriors by  doxygen 1.4.7