Loading...
Searching...
No Matches
FileManager.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5/*
6 * IOManager.h
7 *
8 * Created on: 17 Jun 2020
9 * Author: Maxim Masterov
10 * Company: SURFSara
11 */
12
13#ifndef MANAGERS_IO_FILEMANAGER_H_
14#define MANAGERS_IO_FILEMANAGER_H_
15
16#include <algorithm>
17#include <cassert>
18#include <fstream>
19#include <iostream>
20#include <map>
21#include <regex>
22#include <string>
23#include <type_traits>
24#include <vector>
25
28
29namespace gpr {
30namespace io {
35public:
37 virtual ~FileManager();
38
47 void readInputFile(const std::string file_name,
48 gpr::InputParameters &parameters);
49
59 template <typename T>
60 void readDataFile(const std::string file_name,
61 std::map<std::string, T *> &data);
62
72 template <typename T>
73 bool readFromPlainFile(const std::string file_name, T &field);
74
75 template <typename T>
76 bool writePlainFile(const std::string file_name, const T &field,
77 std::ios::openmode mode);
78
79 bool writeXYZFile(const std::string file_name, const gpr::Coord &field,
80 std::ios::openmode mode);
81
82private:
89 inline std::vector<std::string> splitString(const std::string &str,
90 const std::string _regex);
91
101 template <typename T>
102 void convertStringToValue(
103 std::map<std::string, std::vector<std::string> > &input_data,
104 gpr::KeyValuePair<T> &parameters);
105
115 template <typename T>
116 void convertStringToString(
117 std::map<std::string, std::vector<std::string> > &input_data,
118 gpr::KeyValuePair<T> &parameters);
119
130 template <typename T>
131 void convertStringToValueArray(
132 std::map<std::string, std::vector<std::string> > &input_data,
133 gpr::KeyValuePair<T> &parameters);
134
145 template <typename T>
146 void convertStringToStringArray(
147 std::map<std::string, std::vector<std::string> > &input_data,
148 gpr::KeyValuePair<T> &parameters);
149};
150
151} /* namespace io */
152} /* namespace gpr */
153
154#include "FileManager.inl"
155
156#endif /* MANAGERS_IO_FILEMANAGER_H_ */
bool writePlainFile(const std::string file_name, const T &field, std::ios::openmode mode)
bool writeXYZFile(const std::string file_name, const gpr::Coord &field, std::ios::openmode mode)
bool readFromPlainFile(const std::string file_name, T &field)
Read plain ASCII data file. This function reads data line-by-line from a plain text file....
void readDataFile(const std::string file_name, std::map< std::string, T * > &data)
Read data file. The method reads data file written in ASCII format. The values of data should point t...
void readInputFile(const std::string file_name, gpr::InputParameters &parameters)
Read data from the input file and populates structure of parameters. The input file may have empty li...
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
FieldMatrixd Coord
Definition Macros.h:35
Structure of the input parameters. All input parameters are pairs of string names and values.
Definition Structures.h:370
Structure of a string key and template value.
Definition Structures.h:35