10#include "LHAPDF/Utils.h"
11#include "LHAPDF/Paths.h"
12#include "LHAPDF/Exceptions.h"
36 Info(
const std::string& path) {
51 void load(
const std::string& filepath);
71 std::vector<std::string> rtn;
73 for (
const auto& kv :
_metadict) rtn.push_back(kv.first);
82 std::vector<std::string>
keys()
const {
100 virtual bool has_key(
const std::string& key)
const {
108 throw MetadataError(
"Metadata for key: " + key +
" not found.");
119 virtual const std::string&
get_entry(
const std::string& key)
const {
125 virtual const std::string&
get_entry(
const std::string& key,
const std::string& fallback)
const {
138 template <
typename T>
146 template <
typename T>
157 template <
typename T>
184 if (s ==
"true" || s ==
"on" || s ==
"yes")
return true;
185 if (s ==
"false" || s ==
"off" || s ==
"no")
return false;
187 throw MetadataError(
"'" + s +
"' is not a valid string for conversion to bool type");
192 static const string delim =
",";
195 if (
startswith(strval,
"[")) strval = strval.substr(1, strval.size()-1);
196 if (
endswith(strval,
"]")) strval = strval.substr(0, strval.size()-1);
198 return split(strval, delim);
205 rtn.reserve(strs.size());
207 assert(rtn.size() == strs.size());
215 rtn.reserve(strs.size());
217 assert(rtn.size() == strs.size());
Metadata base class for PDFs, PDF sets, or global configuration.
Definition Info.h:29
void load(const std::string &filepath)
Info(const std::string &path)
Constructor.
Definition Info.h:36
virtual ~Info()
Virtual destructor to allow inheritance.
Definition Info.h:41
virtual const std::string & get_entry(const std::string &key) const
Definition Info.h:119
void set_entry(const std::string &key, const T &val)
Set a keyed value entry.
Definition Info.h:158
std::vector< std::string > keys_local() const
Get the keys defined on this specific object.
Definition Info.h:70
virtual const std::string & get_entry(const std::string &key, const std::string &fallback) const
Retrieve a metadata string by key name, with a default fallback.
Definition Info.h:125
Info()
Default constructor.
Definition Info.h:33
std::map< std::string, std::string > _metadict
The string -> string native metadata storage container.
Definition Info.h:168
std::vector< std::string > keys() const
Definition Info.h:82
T get_entry_as(const std::string &key, const T &fallback) const
Retrieve a metadata entry by key name, with an inline type cast and default fallback.
Definition Info.h:147
const std::string & get_entry_local(const std::string &key) const
Retrieve a metadata string by key name, as defined on this specific object.
Definition Info.h:106
virtual bool has_key(const std::string &key) const
Definition Info.h:100
T get_entry_as(const std::string &key) const
Definition Info.h:139
bool has_key_local(const std::string &key) const
Is a value defined for the given key on this specific object?
Definition Info.h:87
std::string to_str(const T &val)
Make a string representation of val.
Definition Utils.h:61
bool startswith(const std::string &s, const std::string &sub)
Does a string s start with the sub substring?
Definition Utils.h:115
T lexical_cast(const U &in)
Convert between types via stringstream.
Definition Utils.h:47
bool endswith(const std::string &s, const std::string &sub)
Does a string s end with the sub substring?
Definition Utils.h:120
std::string trim(const std::string &s)
Strip leading and trailing spaces (not in-place)
Definition Utils.h:130
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split a string by a given separator.
Definition Utils.h:95
Namespace for all LHAPDF functions and classes.
Definition AlphaS.h:14