#include <streambuf_tmpnam.h>
Public Member Functions | |
filgen_tmpnam () | |
This class allows to use anonymous file stream buffers. | |
const char * | operator() (void) const |
We create the filename only if this is necessary. | |
virtual | ~filgen_tmpnam () |
The file may not have been created? but removed if there. | |
Private Attributes | |
char | _file [L_tmpnam] |
Concats a format string to the result of tmpnam(). Very simple for creating temporary filenames in a test program. This functor returns a new file name as a char ptr. This is an unsafe routine but is available anywhere.
rpa::filgen_tmpnam::filgen_tmpnam | ( | ) |
This class allows to use anonymous file stream buffers.
For creating temporary file names, for test programs. Concats a format string to the result of tmpnam(). Very simple for creating temporary filenames in a test program. It would be worth to use the thread id ! That is, they get automatically a temporary file name at creation. The function 'tmpnam' has a security hole, so this is just an example. Would be fine to have P=pid, T=tid, C=creationTime H=host etc... Consider using gettid().
rpa::filgen_tmpnam::~filgen_tmpnam | ( | ) | [virtual] |
The file may not have been created? but removed if there.
May need a hint to check that is if the method was not called.
This backdoor allows to debug easily by seeing the content of the temporary file, NOT deleted if the environment variable is set.
const char * rpa::filgen_tmpnam::operator() | ( | void | ) | const |
We create the filename only if this is necessary.
Note that all temp file generators must have a 'operator() const'. This method is required by the framework. The return type determines the type of file streambuf with which it can be used.
char rpa::filgen_tmpnam::_file[L_tmpnam] [private] |
This must be big enough to hold a filename returned by tmpnam, but nothing else. So, no need to make it bigger.