52 explicit Variant(
bool value) : _type(BOOL) { _bool = value; }
53 explicit Variant(
double value) : _type(DOUBLE) { _double = value; }
54 explicit Variant(
float value) : _type(FLOAT) { _float = value; }
55 explicit Variant(int32_t value) : _type(INT) { _int = value; }
56 explicit Variant(int64_t value) : _type(LONG) { _long = value; }
81 _double = (double)value;
84 _float = (float)value;
87 _int = (int32_t)lrint(std::max((
double)INT32_MIN,
88 std::min(value, (
double)INT32_MAX)));
91 _long = (int64_t)lrint(std::max((
double)INT64_MIN,
92 std::min(value, (
double)INT64_MAX)));
106 case BOOL:
return _bool;
107 case DOUBLE:
return _double;
108 case FLOAT:
return _float;
109 case INT:
return _int;
110 case LONG:
return _long;
116 bool get_bool()
const { ensure_type(BOOL);
return _bool; }
117 double get_double()
const { ensure_type(DOUBLE);
return _double; }
118 float get_float()
const { ensure_type(FLOAT);
return _float; }
119 int get_int()
const { ensure_type(INT);
return _int; }
120 long get_long()
const { ensure_type(LONG);
return _long; }
122 bool operator==(
bool v)
const {
return _type == BOOL && _bool == v; }
123 double operator==(
double v)
const {
return _type == DOUBLE && _double == v; }
124 float operator==(
float v)
const {
return _type == FLOAT && _float == v; }
125 int operator==(
int v)
const {
return _type == INT && _int == v; }
126 long operator==(
long v)
const {
return _type == LONG && _long == v; }
134 const std::string&
get_path()
const { ensure_type(PATH);
return _string; }
135 const std::string&
get_string()
const { ensure_type(STRING);
return _string; }
136 const std::string&
get_uri()
const { ensure_type(URI);
return _string; }
139 if (_type != v.
_type) {
146 case BOOL:
return _bool == v.
_bool;
147 case DOUBLE:
return _double == v.
_double;
148 case FLOAT:
return _float == v.
_float;
149 case INT:
return _int == v.
_int;
150 case LONG:
return _long == v.
_long;
153 case URI:
return _string == v.
_string;
160 return _type ==
BEATS && _beats == v;
172 ensure_type(
BEATS);
return _beats;
179 case BOOL:
case DOUBLE:
case FLOAT:
case INT:
case LONG:
case BEATS:
188 static const char* names[] = {
189 "bool",
"double",
"float",
"int",
"long",
"path",
"string",
"uri"
197 throw std::domain_error(
199 type_name(type), type_name(_type)));
long operator==(long v) const
double operator==(double v) const
const std::string & get_path() const
Variant & operator=(Temporal::Beats v)
int operator==(int v) const
std::string _string
PATH, STRING, URI.
Variant & operator=(bool v)
Variant(Type type, const std::string &value)
Variant & operator=(int v)
const Temporal::Beats & get_beats() const
bool operator==(const Variant &v) const
const std::string & get_string() const
const std::string & get_uri() const
Variant & operator=(float v)
Variant & operator=(long v)
Variant(Type type, double value)
Variant & operator=(double v)
Temporal::Beats _beats
BEATS.
static bool type_is_numeric(Type type)
float operator==(float v) const
Variant(const Temporal::Beats &beats)
double get_double() const
@ STRING
Raw string (no semantics)
@ FLOAT
C float (32-bit IEEE-754)
@ DOUBLE
C double (64-bit IEEE-754)
bool operator==(bool v) const
static const char * type_name(const Type type)
void ensure_type(const Type type) const
bool operator==(const Temporal::Beats &v) const
static Beats from_double(double beats)
std::string string_compose(const std::string &fmt, const T1 &o1)