DUECA/DUSIME
Public Member Functions | List of all members
dueca::UniqueFile Class Reference

Create a numbered, unique, empty, writeable file, according to a format. More...

Inheritance diagram for dueca::UniqueFile:
Inheritance graph
[legend]
Collaboration diagram for dueca::UniqueFile:
Collaboration graph
[legend]

Public Member Functions

 UniqueFile ()
 Default constructor, no arguments.
 
void open (const char *fmt, unsigned start_at=0, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
 Open call for a file. More...
 
unsigned getOrdinal ()
 Get the sequence number. More...
 
const char * getName ()
 Get the file name. More...
 

Detailed Description

Create a numbered, unique, empty, writeable file, according to a format.

This class is derived from the std::ofstream class. Instead of a file name it accepts a c-style format that should work with a long integer. Opening a new file with that format is attempted, with the integer running from 0 to 999 (1000 unique files). The open method is overridden, for the rest of the methods this class follows the ofstream interface.

A suggestion for the format might be "myfile%03d.ext". This would produce files with names such as myfile000.ext, myfile001.ext, myfile002.ext etcetera.

Member Function Documentation

◆ open()

void dueca::UniqueFile::open ( const char *  fmt,
unsigned  start_at = 0,
ios_base::openmode  __mode = ios_base::out|ios_base::trunc 
)

Open call for a file.

Parameters
fmtc-style format
start_atcounter start for the file name search
__modefile open mode.

◆ getOrdinal()

unsigned dueca::UniqueFile::getOrdinal ( )
inline

Get the sequence number.

◆ getName()

const char* dueca::UniqueFile::getName ( )
inline

Get the file name.


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