MeteoIODoc 20260620.13b5b0a5
Environmental timeseries pre-processing
Loading...
Searching...
No Matches
FStream.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/* Copyright 2014 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3/***********************************************************************************/
4/* This file is part of MeteoIO.
5 MeteoIO is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 MeteoIO is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef FSTREAM_H
20#define FSTREAM_H
21
22#include <fstream>
23#include <string>
24#include <meteoio/IOManager.h>
25
26namespace mio {
27
36class ofilestream : public std::ofstream
37{
38 public:
40 ofilestream(const char* filename, std::ios_base::openmode mode = std::ios_base::out);
41 ofilestream(const char* filename, const Config& cfgreader, std::ios_base::openmode mode = std::ios_base::out);
42 ofilestream(const std::string filename, std::ios_base::openmode mode = std::ios_base::out);
43 ofilestream(const std::string filename, const Config& cfgreader, std::ios_base::openmode mode = std::ios_base::out);
44
45
46 void open(const char* filename, std::ios_base::openmode mode = std::ios_base::out);
47 static void createDirectoriesOfFile(const char* filename);
48
49 static bool getDefault();
50
51 private:
52 static std::string prepareWrite(const char* filename, const Config& cfgreader);
53 static std::string prepareWrite(const char* filename, bool write_directories);
54 static bool write_directories_default;
55 static bool keep_old_files;
56 friend void IOManager::setOfstreamDefault(const Config& i_cfg);
57
58 static bool warn_abs_path;
59};
60
68class ifilestream : public std::ifstream
69{
70 public:
72 ifilestream(const char* filename, std::ios_base::openmode mode = std::ios_base::in);
73 ifilestream(const std::string filename, std::ios_base::openmode mode = std::ios_base::in);
74
75 void open(const char* filename, std::ios_base::openmode mode = std::ios_base::in);
76};
77}
78
79#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition Config.h:79
void setOfstreamDefault(const Config &i_cfg)
Definition IOManager.cc:316
A class that extends std::ifstream, adding sandbox validation.
Definition FStream.h:69
ifilestream()
Definition FStream.h:71
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::in)
Definition FStream.cc:146
A class that extends std::ofstream, adding some output functionality. Limiting the write access of th...
Definition FStream.h:37
static bool getDefault()
Definition FStream.cc:122
ofilestream()
Definition FStream.h:39
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::out)
The actual writing function.
Definition FStream.cc:89
static void createDirectoriesOfFile(const char *filename)
Definition FStream.cc:127
Definition Config.cc:34