MeteoIODoc 20261119.86f8ff36
Environmental timeseries pre-processing
Loading...
Searching...
No Matches
mio::ofilestream Class Reference

Detailed Description

A class that extends std::ofstream, adding some output functionality. Limiting the write access of the software, writing non-existing output directories, and adding a timestamp to output filenames.

Author
Patrick Leibersperger
Date
2023-11-21

#include <FStream.h>

Public Member Functions

 ofilestream ()
 
 ofilestream (const char *filename, std::ios_base::openmode mode=std::ios_base::out)
 Constructor.
 
 ofilestream (const char *filename, const Config &cfgreader, std::ios_base::openmode mode=std::ios_base::out)
 Constructor.
 
 ofilestream (const std::string filename, std::ios_base::openmode mode=std::ios_base::out)
 
 ofilestream (const std::string filename, const Config &cfgreader, std::ios_base::openmode mode=std::ios_base::out)
 
void open (const char *filename, std::ios_base::openmode mode=std::ios_base::out)
 The actual writing function.
 

Static Public Member Functions

static void createDirectoriesOfFile (const char *filename)
 
static bool getDefault ()
 
static std::string prepareWrite (const char *filename, const Config &cfgreader)
 Prepare the writing of a file, as done by the constructors: check that its directory is within the output sandbox (if enabled), create its directory if missing (if allowed by WRITE_DIRECTORIES) and add a timestamp to its name if old files are kept (KEEP_OLD_FILES, see IOManager)
 
static std::string prepareWrite (const char *filename, bool write_directories)
 Prepare the writing of a file, see prepareWrite(const char*, const Config&)
 

Friends

void IOManager::setOfstreamDefault (const Config &i_cfg)
 

Constructor & Destructor Documentation

◆ ofilestream() [1/5]

mio::ofilestream::ofilestream ( )
inline

◆ ofilestream() [2/5]

mio::ofilestream::ofilestream ( const char *  filename,
std::ios_base::openmode  mode = std::ios_base::out 
)

Constructor.

Parameters
filenamefile to write
modemode to open the file in

◆ ofilestream() [3/5]

mio::ofilestream::ofilestream ( const char *  filename,
const Config &  cfgreader,
std::ios_base::openmode  mode = std::ios_base::out 
)

Constructor.

Parameters
filenamefile to write
cfgreaderinstance of Config, to read the inishell config keywords
modemode to open the file in

◆ ofilestream() [4/5]

mio::ofilestream::ofilestream ( const std::string  filename,
std::ios_base::openmode  mode = std::ios_base::out 
)

◆ ofilestream() [5/5]

mio::ofilestream::ofilestream ( const std::string  filename,
const Config &  cfgreader,
std::ios_base::openmode  mode = std::ios_base::out 
)

Member Function Documentation

◆ createDirectoriesOfFile()

void mio::ofilestream::createDirectoriesOfFile ( const char *  filename)
static

◆ getDefault()

bool mio::ofilestream::getDefault ( )
static

◆ open()

void mio::ofilestream::open ( const char *  filename,
std::ios_base::openmode  mode = std::ios_base::out 
)

The actual writing function.

works the same as std::ofstream::open, but with the additional functionality

Parameters
filenamefile to write
modemode to open the file in

◆ prepareWrite() [1/2]

std::string mio::ofilestream::prepareWrite ( const char *  filename,
bool  write_directories 
)
static

Prepare the writing of a file, see prepareWrite(const char*, const Config&)

Parameters
filenamefile to write
write_directoriescreate the directory of the file if missing? (see getDefault())
Returns
the path of the file to open

◆ prepareWrite() [2/2]

std::string mio::ofilestream::prepareWrite ( const char *  filename,
const Config &  cfgreader 
)
static

Prepare the writing of a file, as done by the constructors: check that its directory is within the output sandbox (if enabled), create its directory if missing (if allowed by WRITE_DIRECTORIES) and add a timestamp to its name if old files are kept (KEEP_OLD_FILES, see IOManager)

This is also used by the other output streams (such as OGZstream), so that they behave the same.

Parameters
filenamefile to write
cfgreaderinstance of Config, to read WRITE_DIRECTORIES in the [Output] section
Returns
the path of the file to open

Friends And Related Symbol Documentation

◆ IOManager::setOfstreamDefault

void IOManager::setOfstreamDefault ( const Config &  i_cfg)
friend

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