ardour
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
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 Evoral::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 Evoral::Beats &v) const
 
bool operator! () const
 
Variantoperator= (Evoral::Beats v)
 
const Evoral::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...
 
Evoral::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 36 of file variant.h.

Member Enumeration Documentation

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 39 of file variant.h.

Constructor & Destructor Documentation

ARDOUR::Variant::Variant ( )
inline

Definition at line 52 of file variant.h.

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

Definition at line 54 of file variant.h.

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

Definition at line 55 of file variant.h.

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

Definition at line 56 of file variant.h.

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

Definition at line 57 of file variant.h.

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

Definition at line 58 of file variant.h.

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

Definition at line 60 of file variant.h.

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

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

Definition at line 66 of file variant.h.

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 75 of file variant.h.

Member Function Documentation

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

Definition at line 197 of file variant.h.

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

Definition at line 173 of file variant.h.

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

Definition at line 118 of file variant.h.

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

Definition at line 119 of file variant.h.

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

Definition at line 120 of file variant.h.

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

Definition at line 121 of file variant.h.

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

Definition at line 122 of file variant.h.

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

Definition at line 136 of file variant.h.

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

Definition at line 137 of file variant.h.

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

Definition at line 138 of file variant.h.

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

Definition at line 165 of file variant.h.

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

Definition at line 130 of file variant.h.

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

Definition at line 131 of file variant.h.

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

Definition at line 132 of file variant.h.

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

Definition at line 133 of file variant.h.

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

Definition at line 134 of file variant.h.

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

Definition at line 167 of file variant.h.

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

Definition at line 124 of file variant.h.

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

Definition at line 125 of file variant.h.

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

Definition at line 126 of file variant.h.

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

Definition at line 127 of file variant.h.

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

Definition at line 128 of file variant.h.

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

Definition at line 140 of file variant.h.

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

Definition at line 161 of file variant.h.

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

Convert a numeric variant to a double.

Definition at line 106 of file variant.h.

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

Definition at line 177 of file variant.h.

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

Definition at line 179 of file variant.h.

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

Definition at line 189 of file variant.h.

Member Data Documentation

union { ... }
Evoral::Beats ARDOUR::Variant::_beats
private

BEATS.

Definition at line 207 of file variant.h.

bool ARDOUR::Variant::_bool

Definition at line 211 of file variant.h.

double ARDOUR::Variant::_double

Definition at line 212 of file variant.h.

float ARDOUR::Variant::_float

Definition at line 213 of file variant.h.

int32_t ARDOUR::Variant::_int

Definition at line 214 of file variant.h.

int64_t ARDOUR::Variant::_long

Definition at line 215 of file variant.h.

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

PATH, STRING, URI.

Definition at line 206 of file variant.h.

Type ARDOUR::Variant::_type
private

Type tag.

Definition at line 205 of file variant.h.


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