cppDataPipeline 0.3.0
C++ Implementation of the FAIR Data Pipeline API
Loading...
Searching...
No Matches
data_io.hxx
1
11#ifndef __FDP_DATA_IO_HXX__
12#define __FDP_DATA_IO_HXX__
13
14#include "toml.hpp"
15#include <cstdlib>
16#include <ghc/filesystem.hpp>
17#include <stdexcept>
18#include <string>
19#include <vector>
20#include <yaml-cpp/yaml.h>
21#include <ghc/filesystem.hpp>
22
23#include <iostream>
24
26#include "fdp/objects/metadata.hxx"
27#include "fdp/utilities/logging.hxx"
28#include "fdp/utilities/semver.hxx"
29#include "fdp/exceptions.hxx"
30
31namespace FairDataPipeline {
32
48double read_point_estimate_from_toml(const ghc::filesystem::path file_path);
49double read_point_estimate_from_toml(const ghc::filesystem::path file_path, const std::string &component);
50toml::value read_parameter_from_toml(const ghc::filesystem::path file_path,
51 const std::string &parameter);
52toml::value read_parameter_from_toml(const ghc::filesystem::path file_path,
53 const std::string &parameter,
54 const std::string &component);
55toml::value read_data_from_toml(const ghc::filesystem::path file_path);
56toml::value read_component_from_toml(const ghc::filesystem::path file_path, const std::string &component);
57
58ghc::filesystem::path write_toml_data(ghc::filesystem::path file_path,
59 const std::string &component,
60 const toml::value &data);
61
70template <typename T>
71ghc::filesystem::path write_toml_parameter(T &value,
72 const std::string &parameter,
73 const std::string &component,
74 const ghc::filesystem::path file_path
75 ) {
76
77 const toml::value data_{
78 {component, {{"type", parameter}, {"value", value}}}};
79 return write_toml_data(file_path, component, data_);
80
81}
82
83
84template <typename T>
85ghc::filesystem::path
86write_point_estimate(T &value, const std::string &component,
87 const ghc::filesystem::path file_path) {
88 return write_toml_parameter(value, "point-estimate",
89 component, file_path);
90}
91
92std::string get_first_component(const ghc::filesystem::path &file_path);
93
94bool component_exists(const ghc::filesystem::path &file_path, const std::string &component);
95
96}; // namespace FairDataPipeline
97
98#endif