pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
Rcfile.h
1#ifndef Rcfile_h_included_
2#define Rcfile_h_included_
3
4#include <string>
5#include <vector>
6
7namespace YAML {
8 class Node;
9}
10
11class Rcmap {
12 public:
13 Rcmap();
14 ~Rcmap();
15
16 void addFile(YAML::Node*);
17
19 bool has_key(const std::string& keyname) const;
20
22 bool is_vector(const std::string& keyname) const;
23
24
26 bool is_map(const std::string& keyname) const;
27
29 Rcmap getMap(const std::string& keyname) const;
30
33
35 std::vector<bool> getVBool(const std::string& keyname) const;
36
38 std::vector<int> getVInt(const std::string& keyname) const;
39
41 std::string getString(const std::string& keyname) const;
42
44 bool getBool(const std::string& keyname) const;
45
47 int getInt(const std::string& keyname) const;
48
49 protected:
51};
52
54class Rcfile {
55 public:
56 Rcfile();
57
59 void load(const std::string& file);
60
61 Rcmap& contents() { return contents_; }
62 void help();
63
64 void declareVString(const std::string& key, const std::string& description);
65 void declareString(const std::string& key, const std::string& description);
66 void declareVBool(const std::string& key, const std::string& description);
67 void declareBool(const std::string& key, const std::string& description);
68 void declareVInt(const std::string& key, const std::string& description);
69 void declareInt(const std::string& key, const std::string& description);
70
71 private:
72 struct HelpInfo {
73 std::string key, description, type;
74 };
75 Rcmap contents_;
76 std::vector<HelpInfo> helpInfo_;
77};
78
79#endif // Rcfile_h_included_
YAML-based RC file.
Definition: Rcfile.h:54
void load(const std::string &file)
first file takes priority
Definition: Rcfile.cc:159
Definition: Rcfile.h:11
Rcmap getMap(const std::string &keyname) const
get item as map
Definition: Rcfile.cc:44
bool getBool(const std::string &keyname) const
get item as scalar bool
Definition: Rcfile.cc:103
bool is_map(const std::string &keyname) const
Is this key a submap?
Definition: Rcfile.cc:34
std::string getString(const std::string &keyname) const
get item as scalar string
Definition: Rcfile.cc:84
bool is_vector(const std::string &keyname) const
Is this key a vector?
Definition: Rcfile.cc:23
bool has_key(const std::string &keyname) const
Does this map have the given key ?
Definition: Rcfile.cc:16
std::vector< int > getVInt(const std::string &keyname) const
get item as vector of ints
Definition: Rcfile.cc:65
std::vector< bool > getVBool(const std::string &keyname) const
get item as vector of bools
Definition: Rcfile.cc:74
std::vector< std::string > getVString(const std::string &keyname) const
get item as vector of strings
Definition: Rcfile.cc:55
int getInt(const std::string &keyname) const
get item as scalar int
Definition: Rcfile.cc:94
Definition: Rcfile.h:72