20 #ifndef __ardour_variant_h__
21 #define __ardour_variant_h__
54 explicit Variant(
bool value) : _type(BOOL) { _bool = value; }
55 explicit Variant(
double value) : _type(DOUBLE) { _double = value; }
56 explicit Variant(
float value) : _type(FLOAT) { _float = value; }
57 explicit Variant(int32_t value) : _type(INT) { _int = value; }
58 explicit Variant(int64_t value) : _type(LONG) { _long = value; }
83 _double = (double)value;
86 _float = (float)value;
89 _int = (int32_t)lrint(std::max((
double)INT32_MIN,
90 std::min(value, (
double)INT32_MAX)));
93 _long = (int64_t)lrint(std::max((
double)INT64_MIN,
94 std::min(value, (
double)INT64_MAX)));
108 case BOOL:
return _bool;
109 case DOUBLE:
return _double;
110 case FLOAT:
return _float;
111 case INT:
return _int;
112 case LONG:
return _long;
113 case BEATS:
return _beats.to_double();
118 bool get_bool()
const { ensure_type(BOOL);
return _bool; }
119 double get_double()
const { ensure_type(DOUBLE);
return _double; }
120 float get_float()
const { ensure_type(FLOAT);
return _float; }
121 int get_int()
const { ensure_type(INT);
return _int; }
122 long get_long()
const { ensure_type(LONG);
return _long; }
124 bool operator==(
bool v)
const {
return _type == BOOL && _bool == v; }
125 double operator==(
double v)
const {
return _type == DOUBLE && _double == v; }
126 float operator==(
float v)
const {
return _type == FLOAT && _float == v; }
127 int operator==(
int v)
const {
return _type == INT && _int == v; }
128 long operator==(
long v)
const {
return _type == LONG && _long == v; }
136 const std::string&
get_path()
const { ensure_type(PATH);
return _string; }
137 const std::string&
get_string()
const { ensure_type(STRING);
return _string; }
138 const std::string&
get_uri()
const { ensure_type(URI);
return _string; }
141 if (_type != v.
_type) {
146 case NOTHING:
return true;
147 case BEATS:
return _beats == v.
_beats;
148 case BOOL:
return _bool == v.
_bool;
149 case DOUBLE:
return _double == v.
_double;
150 case FLOAT:
return _float == v.
_float;
151 case INT:
return _int == v.
_int;
152 case LONG:
return _long == v.
_long;
155 case URI:
return _string == v.
_string;
162 return _type == BEATS && _beats == v;
174 ensure_type(BEATS);
return _beats;
181 case BOOL:
case DOUBLE:
case FLOAT:
case INT:
case LONG:
case BEATS:
190 static const char* names[] = {
191 "bool",
"double",
"float",
"int",
"long",
"path",
"string",
"uri"
199 throw std::domain_error(
201 type_name(type), type_name(_type)));
221 #endif // __ardour_variant_h__
Evoral::Beats _beats
BEATS.
void ensure_type(const Type type) const
bool operator==(bool v) const
C float (32-bit IEEE-754)
bool operator==(const Evoral::Beats &v) const
double operator==(double v) const
Variant & operator=(Evoral::Beats v)
Variant & operator=(long v)
std::string _string
PATH, STRING, URI.
Variant & operator=(int v)
const std::string & get_uri() const
Variant & operator=(float v)
static const char * type_name(const Type type)
float operator==(float v) const
Raw string (no semantics)
const Evoral::Beats & get_beats() const
const std::string & get_path() const
Variant & operator=(bool v)
Variant(const Evoral::Beats &beats)
Variant(Type type, const std::string &value)
bool operator==(const Variant &v) const
Variant(Type type, double value)
C double (64-bit IEEE-754)
const std::string & get_string() const
LIBEVORAL_API uint64_t Beats
int operator==(int v) const
double get_double() const
long operator==(long v) const
static bool type_is_numeric(Type type)
Variant & operator=(double v)
std::string string_compose(const std::string &fmt, const T1 &o1)