15#include <unordered_map>
21namespace Experimental {
45 virtual bool GetBool()
const {
return false; }
46 virtual int GetInt()
const {
return 0; }
48 virtual std::string
GetString()
const {
return ""; }
50 virtual std::unique_ptr<Value_t>
Copy()
const = 0;
52 template<
typename T>
T Get()
const;
54 template <
typename RET_TYPE,
typename MATCH_TYPE =
void>
64 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<BoolValue_t>(
v); }
74 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<IntValue_t>(
v); }
84 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<DoubleValue_t>(
v); }
95 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<StringValue_t>(
v); }
102 std::unordered_map<std::string, std::unique_ptr<Value_t>>
m;
109 RAttrMap &
Add(
const std::string &
name, std::unique_ptr<Value_t> &&value) {
m[
name] = std::move(value);
return *
this; }
118 for (
const auto &pair : src.
m)
119 m[pair.first] = pair.second->Copy();
125 for (
const auto &pair : src.
m)
126 m[pair.first] = pair.second->Copy();
132 auto entry =
m.find(
name);
133 return (entry !=
m.end()) ? entry->second.get() :
nullptr;
138 auto entry =
m.find(
name);
139 if (entry !=
m.end())
144 auto end()
const {
return m.end(); }
147template<>
bool RAttrMap::Value_t::Get<bool>()
const;
148template<>
int RAttrMap::Value_t::Get<int>()
const;
149template<>
double RAttrMap::Value_t::Get<double>()
const;
150template<> std::string RAttrMap::Value_t::Get<std::string>()
const;
152template<>
bool RAttrMap::Value_t::GetValue<bool,void>(
const Value_t *rec);
153template<>
int RAttrMap::Value_t::GetValue<int,void>(
const Value_t *rec);
154template<>
double RAttrMap::Value_t::GetValue<double,void>(
const Value_t *rec);
155template<> std::string RAttrMap::Value_t::GetValue<std::string,void>(
const Value_t *rec);
156template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,void>(
const Value_t *rec);
157template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,bool>(
const Value_t *rec);
158template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,int>(
const Value_t *rec);
159template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,double>(
const Value_t *rec);
160template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,std::string>(
const Value_t *rec);
Base class for all attributes, used with RDrawable.
EValuesKind Kind() const final
std::unique_ptr< Value_t > Copy() const final
BoolValue_t(bool _v=false)
bool GetBool() const final
bool IsEqual(const Value_t &tgt) const final
std::unique_ptr< Value_t > Copy() const final
bool IsEqual(const Value_t &tgt) const final
double GetDouble() const final
DoubleValue_t(double _v=0)
EValuesKind Kind() const final
EValuesKind Kind() const final
std::unique_ptr< Value_t > Copy() const final
bool IsEqual(const Value_t &tgt) const final
std::string GetString() const final
bool IsEqual(const Value_t &tgt) const final
StringValue_t(const std::string _v="")
std::string v
string value
std::unique_ptr< Value_t > Copy() const final
EValuesKind Kind() const final
virtual std::string GetString() const
virtual bool GetBool() const
virtual ~Value_t()=default
virtual EValuesKind Kind() const =0
virtual std::unique_ptr< Value_t > Copy() const =0
static RET_TYPE GetValue(const Value_t *rec)
virtual int GetInt() const
virtual bool Compatible(EValuesKind kind) const
virtual double GetDouble() const
virtual bool IsEqual(const Value_t &) const
RAttrMap & AddDefaults(const RAttrBase &vis)
RAttrMap & AddString(const std::string &name, const std::string &value)
const Value_t * Find(const std::string &name) const
RAttrMap & AddDouble(const std::string &name, double value)
RAttrMap & operator=(const RAttrMap &src)
RAttrMap(const RAttrMap &src)
std::unordered_map< std::string, std::unique_ptr< Value_t > > m
JSON_object.
RAttrMap & AddInt(const std::string &name, int value)
RAttrMap & AddBool(const std::string &name, bool value)
void Clear(const std::string &name)
RAttrMap & Add(const std::string &name, std::unique_ptr< Value_t > &&value)
RAttrMap()=default
JSON_asbase - store as map object.