Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
config_file.hpp
Go to the documentation of this file.
1#pragma once
2
53
54#include <cstddef>
55#include <filesystem>
56#include <iosfwd>
57#include <span>
58#include <stdexcept>
59#include <string>
60#include <string_view>
61
63
64namespace orrery::sim {
65
73class ConfigurationError : public std::runtime_error {
74public:
78 ConfigurationError(const std::string& message, std::string origin, std::size_t line);
79
81 [[nodiscard]] const std::string& origin() const noexcept { return origin_; }
82
84 [[nodiscard]] std::size_t line() const noexcept { return line_; }
85
86private:
87 std::string origin_;
88 std::size_t line_;
89};
90
100[[nodiscard]] Configuration parse_configuration(std::istream& in, std::string_view origin);
101
116void apply_settings(Configuration& configuration, std::span<const std::string> assignments,
117 std::string_view origin);
118
124[[nodiscard]] Configuration read_configuration_file(const std::filesystem::path& path);
125
136void write_configuration(std::ostream& out, const Configuration& configuration);
137
138} // namespace orrery::sim
ConfigurationError(const std::string &message, std::string origin, std::size_t line)
origin is the file name, or whatever else names the stream for a caller that parsed something other t...
std::size_t line() const noexcept
The line the problem was on, counting from one.
Definition config_file.hpp:84
const std::string & origin() const noexcept
The name of what was being parsed.
Definition config_file.hpp:81
void write_configuration(std::ostream &out, const Configuration &configuration)
Write configuration in the format above.
Configuration parse_configuration(std::istream &in, std::string_view origin)
Read a configuration from in, whose name for error messages is origin.
void apply_settings(Configuration &configuration, std::span< const std::string > assignments, std::string_view origin)
Apply key = value assignments on top of an existing configuration.
Configuration read_configuration_file(const std::filesystem::path &path)
Read a configuration from a file.
Everything a run is, as data.
A whole run, as data.
Definition configuration.hpp:332