DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dueca::UniqueFile Class Reference

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

#include <UniqueFile.hxx>

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.
 
unsigned getOrdinal ()
 Get the sequence number.
 
const chargetName ()
 Get the file name.
 

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.

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