Ardour  9.0-pre0-582-g084a23a80d
ARDOUR::Variant Class Reference

#include <variant.h>

Public Types

enum  Type {
  NOTHING , BEATS , BOOL , DOUBLE ,
  FLOAT , INT , LONG , PATH ,
  STRING , URI
}
 

Public Member Functions

 Variant ()
 
 Variant (bool value)
 
 Variant (double value)
 
 Variant (float value)
 
 Variant (int32_t value)
 
 Variant (int64_t value)
 
 Variant (const Temporal::Beats &beats)
 
 Variant (Type type, const std::string &value)
 
 Variant (Type type, double value)
 
double to_double () const
 
bool get_bool () const
 
double get_double () const
 
float get_float () const
 
int get_int () const
 
long get_long () const
 
bool operator== (bool v) const
 
double operator== (double v) const
 
float operator== (float v) const
 
int operator== (int v) const
 
long operator== (long v) const
 
Variantoperator= (bool v)
 
Variantoperator= (double v)
 
Variantoperator= (float v)
 
Variantoperator= (int v)
 
Variantoperator= (long v)
 
const std::string & get_path () const
 
const std::string & get_string () const
 
const std::string & get_uri () const
 
bool operator== (const Variant &v) const
 
bool operator== (const Temporal::Beats &v) const
 
bool operator! () const
 
Variantoperator= (Temporal::Beats v)
 
const Temporal::Beatsget_beats () const
 
Type type () const
 

Static Public Member Functions

static bool type_is_numeric (Type type)
 

Private Member Functions

void ensure_type (const Type type) const
 

Static Private Member Functions

static const char * type_name (const Type type)
 

Private Attributes

Type _type
 Type tag. More...
 
std::string _string
 PATH, STRING, URI. More...
 
Temporal::Beats _beats
 BEATS. More...
 
union {
   bool   _bool
 
   double   _double
 
   float   _float
 
   int32_t   _int
 
   int64_t   _long
 
}; 
 

Detailed Description

A value with dynamic type (tagged union).

Definition at line 34 of file variant.h.

Member Enumeration Documentation

◆ Type

Enumerator
NOTHING 

Nothing (void)

BEATS 

Beats+ticks.

BOOL 

Boolean.

DOUBLE 

C double (64-bit IEEE-754)

FLOAT 

C float (32-bit IEEE-754)

INT 

Signed 32-bit int.

LONG 

Signed 64-bit int.

PATH 

File path string.

STRING 

Raw string (no semantics)

URI 

URI string.

Definition at line 37 of file variant.h.

Constructor & Destructor Documentation

◆ Variant() [1/9]

ARDOUR::Variant::Variant ( )
inline

Definition at line 50 of file variant.h.

◆ Variant() [2/9]

ARDOUR::Variant::Variant ( bool  value)
inlineexplicit

Definition at line 52 of file variant.h.

◆ Variant() [3/9]

ARDOUR::Variant::Variant ( double  value)
inlineexplicit

Definition at line 53 of file variant.h.

◆ Variant() [4/9]

ARDOUR::Variant::Variant ( float  value)
inlineexplicit

Definition at line 54 of file variant.h.

◆ Variant() [5/9]

ARDOUR::Variant::Variant ( int32_t  value)
inlineexplicit

Definition at line 55 of file variant.h.

◆ Variant() [6/9]

ARDOUR::Variant::Variant ( int64_t  value)
inlineexplicit

Definition at line 56 of file variant.h.

◆ Variant() [7/9]

ARDOUR::Variant::Variant ( const Temporal::Beats beats)
inlineexplicit

Definition at line 58 of file variant.h.

◆ Variant() [8/9]

ARDOUR::Variant::Variant ( Type  type,
const std::string &  value 
)
inline

Make a variant of a specific string type (string types only)

Definition at line 64 of file variant.h.

◆ Variant() [9/9]

ARDOUR::Variant::Variant ( Type  type,
double  value 
)
inline

Make a numeric variant from a double (numeric types only).

If conversion is impossible, the variant will have type NOTHING.

Definition at line 73 of file variant.h.

Member Function Documentation

◆ ensure_type()

void ARDOUR::Variant::ensure_type ( const Type  type) const
inlineprivate

Definition at line 195 of file variant.h.

◆ get_beats()

const Temporal::Beats& ARDOUR::Variant::get_beats ( ) const
inline

Definition at line 171 of file variant.h.

◆ get_bool()

bool ARDOUR::Variant::get_bool ( ) const
inline

Definition at line 116 of file variant.h.

◆ get_double()

double ARDOUR::Variant::get_double ( ) const
inline

Definition at line 117 of file variant.h.

◆ get_float()

float ARDOUR::Variant::get_float ( ) const
inline

Definition at line 118 of file variant.h.

◆ get_int()

int ARDOUR::Variant::get_int ( ) const
inline

Definition at line 119 of file variant.h.

◆ get_long()

long ARDOUR::Variant::get_long ( ) const
inline

Definition at line 120 of file variant.h.

◆ get_path()

const std::string& ARDOUR::Variant::get_path ( ) const
inline

Definition at line 134 of file variant.h.

◆ get_string()

const std::string& ARDOUR::Variant::get_string ( ) const
inline

Definition at line 135 of file variant.h.

◆ get_uri()

const std::string& ARDOUR::Variant::get_uri ( ) const
inline

Definition at line 136 of file variant.h.

◆ operator!()

bool ARDOUR::Variant::operator! ( ) const
inline

Definition at line 163 of file variant.h.

◆ operator=() [1/6]

Variant& ARDOUR::Variant::operator= ( bool  v)
inline

Definition at line 128 of file variant.h.

◆ operator=() [2/6]

Variant& ARDOUR::Variant::operator= ( double  v)
inline

Definition at line 129 of file variant.h.

◆ operator=() [3/6]

Variant& ARDOUR::Variant::operator= ( float  v)
inline

Definition at line 130 of file variant.h.

◆ operator=() [4/6]

Variant& ARDOUR::Variant::operator= ( int  v)
inline

Definition at line 131 of file variant.h.

◆ operator=() [5/6]

Variant& ARDOUR::Variant::operator= ( long  v)
inline

Definition at line 132 of file variant.h.

◆ operator=() [6/6]

Variant& ARDOUR::Variant::operator= ( Temporal::Beats  v)
inline

Definition at line 165 of file variant.h.

◆ operator==() [1/7]

bool ARDOUR::Variant::operator== ( bool  v) const
inline

Definition at line 122 of file variant.h.

◆ operator==() [2/7]

bool ARDOUR::Variant::operator== ( const Temporal::Beats v) const
inline

Definition at line 159 of file variant.h.

◆ operator==() [3/7]

bool ARDOUR::Variant::operator== ( const Variant v) const
inline

Definition at line 138 of file variant.h.

◆ operator==() [4/7]

double ARDOUR::Variant::operator== ( double  v) const
inline

Definition at line 123 of file variant.h.

◆ operator==() [5/7]

float ARDOUR::Variant::operator== ( float  v) const
inline

Definition at line 124 of file variant.h.

◆ operator==() [6/7]

int ARDOUR::Variant::operator== ( int  v) const
inline

Definition at line 125 of file variant.h.

◆ operator==() [7/7]

long ARDOUR::Variant::operator== ( long  v) const
inline

Definition at line 126 of file variant.h.

◆ to_double()

double ARDOUR::Variant::to_double ( ) const
inline

Convert a numeric variant to a double.

Definition at line 104 of file variant.h.

◆ type()

Type ARDOUR::Variant::type ( ) const
inline

Definition at line 175 of file variant.h.

◆ type_is_numeric()

static bool ARDOUR::Variant::type_is_numeric ( Type  type)
inlinestatic

Definition at line 177 of file variant.h.

◆ type_name()

static const char* ARDOUR::Variant::type_name ( const Type  type)
inlinestaticprivate

Definition at line 187 of file variant.h.

Member Data Documentation

◆ 

union { ... }

◆ _beats

Temporal::Beats ARDOUR::Variant::_beats
private

BEATS.

Definition at line 205 of file variant.h.

◆ _bool

bool ARDOUR::Variant::_bool

Definition at line 209 of file variant.h.

◆ _double

double ARDOUR::Variant::_double

Definition at line 210 of file variant.h.

◆ _float

float ARDOUR::Variant::_float

Definition at line 211 of file variant.h.

◆ _int

int32_t ARDOUR::Variant::_int

Definition at line 212 of file variant.h.

◆ _long

int64_t ARDOUR::Variant::_long

Definition at line 213 of file variant.h.

◆ _string

std::string ARDOUR::Variant::_string
private

PATH, STRING, URI.

Definition at line 204 of file variant.h.

◆ _type

Type ARDOUR::Variant::_type
private

Type tag.

Definition at line 203 of file variant.h.


The documentation for this class was generated from the following file: