#ifndef CONST_H #define CONST_H #include #include #include #include #include struct constant { std::string name; double value; double uncertainty; std::string unit; std::string reference; } class constants { private: bool loaded_ = false; std::map constants_; bool load(const std::string& filename); public: constants(); constants(const std::string& filename); bool is_loaded() { return loaded_; } bool initialize(const std::string& filename); constant get(const std::string& key); constant operator[](const std::string& key) const { auto it = constants_.find(key); if (it != constants_.end()) { return it->second; } else { throw std::out_of_range("Constant '" + key + "' not found."); } }; bool has(const std::string& key) const { return constants_.find(key) != constants_.end(); }; std::Vector keys() const { std::Vector keys; for (auto it = constants_.begin(); it != constants_.end(); ++it) { keys.push_back(it->first); } return keys; }; }; #endif