libcommonc++  0.7
FilePtr Class Reference

A smart pointer for stdio streams. More...

#include <FilePtr.h++>

Public Member Functions

 FilePtr (const char *name, const char *mode)
 Construct a new FilePtr for the given filename and attributes. More...
 
 FilePtr (const String &name, const String &mode)
 Construct a new FilePtr for the given filename and attributes. More...
 
 FilePtr (FILE *fp)
 Construct a new FilePtr for an existing stdio stream. More...
 
 ~FilePtr ()
 Destructor. More...
 
 operator FILE * ()
 Cast operator. More...
 
bool isValid () const
 Determine if the stream is valid (non-NULL). More...
 
bool operator! ()
 Determine if the stream is invalid (NULL). More...
 

Detailed Description

A smart pointer for stdio streams.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ FilePtr() [1/3]

FilePtr ( const char *  name,
const char *  mode 
)

Construct a new FilePtr for the given filename and attributes.

The constructor calls fopen() to open the stream.

Parameters
nameThe filename.
modeThe open mode.

◆ FilePtr() [2/3]

FilePtr ( const String name,
const String mode 
)

Construct a new FilePtr for the given filename and attributes.

The constructor calls fopen() to open the stream.

Parameters
nameThe filename.
modeThe open mode.

◆ FilePtr() [3/3]

FilePtr ( FILE *  fp)

Construct a new FilePtr for an existing stdio stream.

Parameters
fpThe stream pointer.

◆ ~FilePtr()

~FilePtr ( )

Destructor.

Closes the stream.

Member Function Documentation

◆ isValid()

bool isValid ( ) const
inline

Determine if the stream is valid (non-NULL).

◆ operator FILE *()

operator FILE * ( )
inline

Cast operator.

◆ operator!()

bool operator! ( )
inline

Determine if the stream is invalid (NULL).


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