26 #ifndef FALAISE_PROPERTY_READER_H 27 #define FALAISE_PROPERTY_READER_H 39 #include <boost/mpl/contains.hpp> 40 #include <boost/mpl/vector.hpp> 41 #include <boost/utility/enable_if.hpp> 54 typedef boost::mpl::vector<int, double, bool, std::string, std::vector<int>, std::vector<double>,
56 std::vector<std::string>
66 namespace type_check_visitor {
86 static_assert(boost::mpl::contains<AllowedTypes, T>::type::value,
87 "Unsupported type for visitation");
102 if (!type_check_visitor::visit<T>(p, key)) {
103 throw WrongType(
"Key '" + key +
"' has incorrect type");
113 template <
typename T>
118 if (!type_check_visitor::visit<T>(p, key)) {
119 throw WrongType(
"Key '" + key +
"' is set but has incorrect type");
130 #endif // FALAISE_PROPERTY_READER_H std::logic_error MissingKey
Definition: property_reader.h:51
bool visit_impl(const datatools::properties &p, const std::string &key, int)
T getValueOrDefault(const datatools::properties &p, const std::string &key, T defaultValue)
Definition: property_reader.h:114
Definition: metadata_utils.h:35
bool visit(const datatools::properties &p, const std::string &key)
Definition: property_reader.h:84
T getRequiredValue(const datatools::properties &p, const std::string &key)
Definition: property_reader.h:98
boost::mpl::vector< int, double, bool, std::string, std::vector< int >, std::vector< double >, std::vector< bool >, std::vector< std::string > > AllowedTypes
List of types that can be stored in and read from datatools::properties.
Definition: property_reader.h:63
std::logic_error WrongType
Definition: property_reader.h:50