20using namespace std::string_literals;
22template<>
bool RAttrMap::Value_t::Get<bool>()
const {
return GetBool(); }
23template<>
int RAttrMap::Value_t::Get<int>()
const {
return GetInt(); }
24template<>
double RAttrMap::Value_t::Get<double>()
const {
return GetDouble(); }
25template<> std::string RAttrMap::Value_t::Get<std::string>()
const {
return GetString(); }
26template<>
RPadLength RAttrMap::Value_t::Get<RPadLength>()
const {
return GetString(); }
28template<>
bool RAttrMap::Value_t::GetValue<bool,void>(
const Value_t *rec) {
return rec ? rec->
GetBool() :
false; }
29template<>
int RAttrMap::Value_t::GetValue<int,void>(
const Value_t *rec) {
return rec ? rec->
GetInt() : 0; }
30template<>
double RAttrMap::Value_t::GetValue<double,void>(
const Value_t *rec) {
return rec ? rec->GetDouble() : 0.; }
31template<> std::string RAttrMap::Value_t::GetValue<std::string,void>(
const Value_t *rec) {
return rec ? rec->GetString() :
""s; }
32template<>
RPadLength RAttrMap::Value_t::GetValue<RPadLength,void>(
const Value_t *rec) {
return rec ? rec->GetString() :
""s; }
34template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,void>(
const Value_t *rec) {
return rec; }
50 m[prefix+entry.first] = entry.second->Copy();
61 if ((value ==
"none"s) || (value ==
"null"s) || value.empty()) {
66 if (value ==
"true"s) {
71 if (value ==
"false"s) {
76 auto beg = value.begin();
78 bool int_conversion_fails =
false;
82 }
else if ((value.length() > 2) && (*beg ==
'0') && (value[1] ==
'x')) {
88 if (std::find_if(beg, value.end(), [](
unsigned char c) { return !std::isdigit(c); }) == value.end()) {
92 auto ivalue = std::stoll(base == 16 ? value.substr(2) : value,
nullptr, base);
94 if ((ivalue >= std::numeric_limits<int>::min()) && (ivalue <= std::numeric_limits<int>::max()))
102 int_conversion_fails =
true;
107 if (!int_conversion_fails && std::find_if(beg, value.end(), [](
unsigned char c) {
108 return !std::isdigit(c) && (c !=
'.') && (c !=
'-') && (c !=
'+') && (c !=
'e');
111 double dvalue = std::stod(value);
129 auto entry =
m.find(
name);
130 if ((entry ==
m.end()) || (entry->second->Kind() ==
kNoValue)) {
131 if (!value)
return false;
149 if (entry->second->IsEqual(*value))
152 switch (entry->second->Kind()) {
#define R__LOG_ERROR(...)
Base class for all attributes, used with RDrawable.
const std::string & GetPrefix() const
virtual const RAttrMap & GetDefaults() const
Return default values for attributes, empty for base class.
virtual std::string GetString() const
virtual bool CanConvertTo(EValuesKind kind) const
virtual bool GetBool() const
virtual std::unique_ptr< Value_t > Copy() const =0
virtual int GetInt() const
virtual double GetDouble() const
RAttrMap & AddString(const std::string &name, const std::string &value)
RAttrMap & AddDouble(const std::string &name, double value)
RAttrMap & AddNoValue(const std::string &name)
std::unordered_map< std::string, std::unique_ptr< Value_t > > m
JSON_object.
RAttrMap & AddInt(const std::string &name, int value)
bool Change(const std::string &name, Value_t *value=nullptr)
Change attribute using string value and kind Used to change attributes from JS side Returns true if v...
RAttrMap & AddBool(const std::string &name, bool value)
RAttrMap & AddDefaults(const RAttrBase &vis)
Add defaults values form sub attribute.
void AddBestMatch(const std::string &name, const std::string &value)
Add attribute, converting to best possible type Tested boolean, int, double.
RLogChannel & GPadLog()
Log channel for GPad diagnostics.