AstraLog-HPC
Loading...
Searching...
No Matches
io.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <common/errors.hpp>
8#include <fstream>
9#include <ios>
10#include <string>
11#include <vector>
12
13namespace astralog {
14
24inline std::ifstream openInputFile(const std::string& path,
25 const std::string& what = "file",
26 std::ios::openmode mode = std::ios::in) {
27 std::ifstream file(path, mode);
28 if (!file.is_open())
29 throw IoError("Could not open " + what + ": " + path);
30 return file;
31}
32
33
40size_t countSensors(const std::string& sensors_path);
41
48std::vector<std::string> loadSensorIds(const std::string& sensors_path);
49
50} // namespace astralog
A file could not be opened, read, or written.
Definition errors.hpp:55
Unified exception hierarchy for AstraLog-HPC.
Definition io.cpp:5
std::ifstream openInputFile(const std::string &path, const std::string &what="file", std::ios::openmode mode=std::ios::in)
Opens an input file stream or throws on failure.
Definition io.hpp:24
std::vector< std::string > loadSensorIds(const std::string &sensors_path)
Reads the sensor IDs listed in a sensors.yaml configuration file.
Definition io.cpp:22
size_t countSensors(const std::string &sensors_path)
Counts the sensors declared in a sensors.yaml configuration file.
Definition io.cpp:7