RAII wrapper on stdio.h FILE pointers (use a derived class though).
More...
#include <l_stdio_wrap.h>
|
void | throw_io_error (const std::string &pathname, const char *mode) |
| this is what we do when things go terribly wrong More...
|
|
| File_Ptr (const std::string &pathname, const char *mode) |
| ctor needs the pathname and a mode; mode is set by derived class More...
|
|
| File_Ptr () |
| default ctor wraps a null pointer (to set up a later swap maybe) More...
|
|
void | swap (File_Ptr &that) |
| swap the contents of two wrappers More...
|
|
RAII wrapper on stdio.h FILE pointers (use a derived class though).
If you have the misfortune of needing to use stdio.h routines for file IO, consider using one of the derived classes of this class as an RAII wrapper on the pointer object. When done correctly, it means never having to call the close function yourself, because the dtor will do it for you.
This is a base class not meant to be instantiated directly. Instead, use one of the following derived classes (list not necessarily exhaustive):
kjb::File_Ptr::File_Ptr |
( |
const std::string & |
pathname, |
|
|
const char * |
mode |
|
) |
| |
|
inlineprotected |
ctor needs the pathname and a mode; mode is set by derived class
- Exceptions
-
kjb::File_Ptr::File_Ptr |
( |
| ) |
|
|
inlineprotected |
default ctor wraps a null pointer (to set up a later swap maybe)
virtual kjb::File_Ptr::~File_Ptr |
( |
| ) |
|
|
inlinevirtual |
dtor can simply call close() because closing a null ptr is OK.
virtual int kjb::File_Ptr::close |
( |
| ) |
|
|
inlinevirtual |
close file before destruction; rarely needed; safe to do twice.
Reimplemented in kjb::Temporary_File.
kjb::File_Ptr::operator FILE * |
( |
| ) |
const |
|
inline |
transparently use this object wherever a FILE* is used!
void kjb::File_Ptr::swap |
( |
File_Ptr & |
that | ) |
|
|
inlineprotected |
swap the contents of two wrappers
void kjb::File_Ptr::throw_io_error |
( |
const std::string & |
pathname, |
|
|
const char * |
mode |
|
) |
| |
|
inlineprotected |
this is what we do when things go terribly wrong
- Exceptions
-
The documentation for this class was generated from the following file: