1#ifndef BITSIM_UTILS_IO_JSON_FILE_READER_H
2#define BITSIM_UTILS_IO_JSON_FILE_READER_H
4#include "bitsim/extern/nlohmann/json/json.hpp"
19 using json = nlohmann::json;
34 virtual void open() override final;
39 template <typename T> T
get_value(const std::
string &label) const;
48 template <typename T> T
at(const std::
string &label) const;
55 const
json &
get(const std::
string &label)
const {
return data_.at(label); };
65 throw std::logic_error(
"JSON file is not open. Have you called open()?");
67 return data_[label].template
get<T>();
74 throw std::logic_error(
"JSON file is not open. Have you called open()?");
77 auto data = data_.at(label);
bool is_open() const noexcept
Definition file_handler_base.h:113
FileReaderBase(const std::string &file_name, FileFormats::Type t)
Constructor.
Definition file_reader_base.cpp:15
nlohmann::json json
Definition json_file_reader.h:19
JSONFileReader(const std::string &filename)
Definition json_file_reader.cpp:9
const json & get(const std::string &label) const
Definition json_file_reader.h:55
virtual void open() override final
Attempts to open the file for reading.
Definition json_file_reader.cpp:19
T get_value(const std::string &label) const
Get the value specified by the label.
Definition json_file_reader.h:61
T at(const std::string &label) const
Definition json_file_reader.h:70
Definition csv_file_reader.cpp:12
Definition dc_motor_backend_base.h:9