47#include "configor/json.hpp"
53inline const char *
basename(
const char *filepath) {
54 const char *base = strrchr(filepath,
'/');
56 if (!base) base = strrchr(filepath,
'\\');
58 return base ? (base + 1) : filepath;
64#define LOC() (std::string(basename(__FILE__)) + ":" + std::to_string(__LINE__))
84 using JSON = configor::json;
127 bool has_key(
const std::string &key);
129 std::shared_ptr<JSON>
pjson();
133 bool get_bool(
const std::string &key,
const std::string &loc,
const bool &default_value);
134 bool get_bool(
const std::string &key,
const std::string &loc =
"__loc__");
136 int get_int(
const std::string &key,
const std::string &loc,
const int &default_value);
137 int get_int(
const std::string &key,
const std::string &loc =
"__loc__");
139 std::string
get_string(
const std::string &key,
const std::string &loc,
const std::string &default_value);
140 std::string
get_string(
const std::string &key,
const std::string &loc =
"__loc__");
143 const double &default_value =
double());
144 double get_double(
const std::string &key,
const std::string &loc,
const double &default_value);
145 double get_double(
const std::string &key,
const std::string &loc =
"__loc__");
148 std::shared_ptr<JSON>
pj;
158 template <
typename T,
bool Require = false>
159 T
get(
const std::string &key,
const std::string &loc,
const phys::dimension7 &qdim,
const T &default_value);
const char * basename(const char *filepath)
return the base of filename
this class provides an interface wrapper for the parameter data.
T get(const std::string &key, const std::string &loc, const phys::dimension7 &qdim, const T &default_value)
get parameter
@ fromString
construct Param from string
@ fromFile
construct Param from file
Param(const std::string &input, LoadOption option)
double get_double(const std::string &key, const std::string &loc, const phys::dimension7 &qdim, const double &default_value=double())
configor::configor_exception JSON_Exception
std::shared_ptr< JSON > pjson()
std::string get_string(const std::string &key, const std::string &loc, const std::string &default_value)
int get_int(const std::string &key, const std::string &loc, const int &default_value)
bool get_bool(const std::string &key, const std::string &loc, const bool &default_value)
std::shared_ptr< JSON > pj
bool has_key(const std::string &key)
Param &operator[](const std::string &key) { if (!has_key(key)) { throw param_illegal_key_error(key); ...
< http://warp.povusers.org/FunctionParser/fparser.html