15#include <unordered_map>
21namespace Experimental {
48 virtual bool GetBool()
const {
return false; }
49 virtual int GetInt()
const {
return 0; }
51 virtual std::string
GetString()
const {
return ""; }
53 virtual std::unique_ptr<Value_t>
Copy()
const = 0;
55 template<
typename T> T
Get()
const;
57 template <
typename RET_TYPE,
typename MATCH_TYPE =
void>
65 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<NoValue_t>(); }
77 int GetInt() const final {
return v ? 1 : 0; }
79 std::string
GetString() const final {
return v ?
"true" :
"false"; }
80 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<BoolValue_t>(
v); }
91 bool GetBool() const final {
return v ? true :
false; }
94 std::string
GetString() const final {
return std::to_string(
v); }
95 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<IntValue_t>(
v); }
106 bool GetBool() const final {
return v ? true :
false; }
109 std::string
GetString() const final {
return std::to_string(
v); }
110 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<DoubleValue_t>(
v); }
123 bool GetBool() const final {
return v.compare(
"true") == 0; }
126 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<StringValue_t>(
v); }
133 std::unordered_map<std::string, std::unique_ptr<Value_t>>
m;
141 RAttrMap &
Add(
const std::string &
name, std::unique_ptr<Value_t> &&value) {
m[
name] = std::move(value);
return *
this; }
165 for (
const auto &pair : src.
m)
166 m[pair.first] = pair.second->Copy();
172 for (
const auto &pair : src.
m)
173 m[pair.first] = pair.second->Copy();
179 auto entry =
m.find(
name);
180 return (entry !=
m.end()) ? entry->second.get() :
nullptr;
186 auto entry =
m.find(
name);
187 if (entry !=
m.end())
191 bool Change(
const std::string &
name, Value_t *value =
nullptr);
194 auto end()
const {
return m.end(); }
197template<>
bool RAttrMap::Value_t::Get<bool>()
const;
198template<>
int RAttrMap::Value_t::Get<int>()
const;
199template<>
double RAttrMap::Value_t::Get<double>()
const;
200template<> std::string RAttrMap::Value_t::Get<std::string>()
const;
201template<> RPadLength RAttrMap::Value_t::Get<RPadLength>()
const;
203template<>
bool RAttrMap::Value_t::GetValue<bool,void>(
const Value_t *rec);
204template<>
int RAttrMap::Value_t::GetValue<int,void>(
const Value_t *rec);
205template<>
double RAttrMap::Value_t::GetValue<double,void>(
const Value_t *rec);
206template<> std::string RAttrMap::Value_t::GetValue<std::string,void>(
const Value_t *rec);
207template<> RPadLength RAttrMap::Value_t::GetValue<RPadLength,void>(
const Value_t *rec);
209template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,void>(
const Value_t *rec);
210template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,bool>(
const Value_t *rec);
211template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,int>(
const Value_t *rec);
212template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,double>(
const Value_t *rec);
213template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,std::string>(
const Value_t *rec);
214template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,RPadLength>(
const Value_t *rec);
Base class for all attributes, used with RDrawable.
EValuesKind Kind() const final
std::unique_ptr< Value_t > Copy() const final
double GetDouble() const final
bool CanConvertFrom(EValuesKind kind) const final
bool CanConvertTo(EValuesKind kind) const final
std::string GetString() 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 CanConvertFrom(EValuesKind kind) const final
bool IsEqual(const Value_t &tgt) const final
double GetDouble() const final
DoubleValue_t(double _v=0)
std::string GetString() const final
EValuesKind Kind() const final
bool GetBool() const final
bool CanConvertTo(EValuesKind kind) const final
double GetDouble() const final
EValuesKind Kind() const final
bool CanConvertFrom(EValuesKind kind) const final
bool GetBool() const final
std::string GetString() const final
bool CanConvertTo(EValuesKind kind) const final
std::unique_ptr< Value_t > Copy() const final
bool IsEqual(const Value_t &tgt) const final
bool IsEqual(const Value_t &tgt) const final
EValuesKind Kind() const final
std::unique_ptr< Value_t > Copy() const final
std::string GetString() const final
bool GetBool() const final
bool IsEqual(const Value_t &tgt) const final
StringValue_t(const std::string _v="")
std::string v
string value
bool CanConvertTo(EValuesKind kind) const final
std::unique_ptr< Value_t > Copy() const final
bool CanConvertFrom(EValuesKind) const final
EValuesKind Kind() const final
virtual std::string GetString() const
virtual bool CanConvertTo(EValuesKind kind) const
virtual bool GetBool() const
virtual ~Value_t()=default
virtual EValuesKind Kind() const =0
virtual std::unique_ptr< Value_t > Copy() const =0
virtual bool CanConvertFrom(EValuesKind kind) const
static RET_TYPE GetValue(const Value_t *rec)
virtual int GetInt() const
virtual double GetDouble() const
virtual bool IsEqual(const Value_t &) const
RAttrMap & AddString(const std::string &name, const std::string &value)
const Value_t * Find(const std::string &name) const
RAttrMap & AddValue(const std::string &name, bool value)
RAttrMap & AddDouble(const std::string &name, double value)
RAttrMap & AddNoValue(const std::string &name)
RAttrMap & operator=(const RAttrMap &src)
RAttrMap(const RAttrMap &src)
RAttrMap & AddValue(const std::string &name, double value)
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 & AddPadLength(const std::string &name, const RPadLength &value)
RAttrMap & AddBool(const std::string &name, bool value)
RAttrMap & AddValue(const std::string &name, const RPadLength &value)
RAttrMap & AddDefaults(const RAttrBase &vis)
Add defaults values form sub attribute.
void Clear(const std::string &name)
Clear specified attribute.
void AddBestMatch(const std::string &name, const std::string &value)
Add attribute, converting to best possible type Tested boolean, int, double.
RAttrMap & Add(const std::string &name, std::unique_ptr< Value_t > &&value)
RAttrMap & AddValue(const std::string &name, const std::string &value)
RAttrMap()=default
JSON_asbase - store as map object.
RAttrMap & AddValue(const std::string &name, int value)
std::string AsString() const
Converts RPadLength to string like "0.1 + 25px" User coordinates not (yet) supported.
A set of defaults for graphics attributes, e.g.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...