1 #ifndef EUDAQ_INCLUDED_Configuration
2 #define EUDAQ_INCLUDED_Configuration
5 #include "eudaq/Exception.hh"
6 #include "eudaq/Platform.hh"
15 const std::string §ion =
"");
16 Configuration(std::istream &conffile,
const std::string §ion =
"");
18 void Save(std::ostream &file)
const;
19 void Load(std::istream &file,
const std::string §ion);
20 bool SetSection(
const std::string §ion)
const;
21 bool SetSection(
const std::string §ion);
22 std::string operator[](
const std::string &key)
const {
23 return GetString(key);
25 std::string Get(
const std::string &key,
const std::string &def)
const;
26 double Get(
const std::string &key,
double def)
const;
27 int64_t Get(
const std::string &key, int64_t def)
const;
28 uint64_t Get(
const std::string &key, uint64_t def)
const;
29 template <
typename T> T Get(
const std::string &key, T def)
const {
32 int Get(
const std::string &key,
int def)
const;
34 T Get(
const std::string &key,
const std::string fallback,
36 return Get(key, Get(fallback, def));
38 std::string Get(
const std::string &key,
const char *def)
const {
39 std::string ret(Get(key, std::string(def)));
42 std::string Get(
const std::string &key,
const std::string fallback,
43 std::string def)
const {
44 return Get(key, Get(fallback, def));
47 template <
typename T>
void Set(
const std::string &key,
const T &val);
48 std::string Name()
const;
50 void Print(std::ostream &out)
const;
54 std::string GetString(
const std::string &key)
const;
55 void SetString(
const std::string &key,
const std::string &val);
56 typedef std::map<std::string, std::string> section_t;
57 typedef std::map<std::string, section_t> map_t;
59 mutable std::string m_section;
60 mutable section_t *m_cur;
63 inline std::ostream &operator<<(std::ostream &os,
const Configuration &c) {
69 inline void Configuration::Set(
const std::string &key,
const T &val) {
74 #endif // EUDAQ_INCLUDED_Configuration
Definition: Configuration.hh:12
T DLLEXPORT from_string(const std::string &x, const T &def=0)
Definition: Utils.hh:115
std::string to_string(const T &x, int digits=0)
Definition: Utils.hh:54