TagLib::Variant Class Reference

An implicitly shared discriminated union. More...

`#include <tvariant.h>`

## Public Types

enum | Type { Void , Bool , Int , UInt , LongLong , ULongLong , Double , String , StringList , ByteVector , ByteVectorList , VariantList , VariantMap }

## Public Member Functions

| Variant ()
| Variant (int val)
| Variant (unsigned int val)
| Variant (long long val)
| Variant (unsigned long long val)
| Variant (bool val)
| Variant (double val)
| Variant (const char *val)
| Variant (const TagLib::String &val)
| Variant (const TagLib::StringList &val)
| Variant (const TagLib::ByteVector &val)
| Variant (const TagLib::ByteVectorList &val)
| Variant (const TagLib::List< TagLib::Variant > &val)
| Variant (const TagLib::Map< TagLib::String, TagLib::Variant > &val)
| Variant (const Variant &v)
| ~Variant ()
Type | type () const
bool | isEmpty () const
int | toInt (bool *ok=nullptr) const
unsigned int | toUInt (bool *ok=nullptr) const
long long | toLongLong (bool *ok=nullptr) const
unsigned long long | toULongLong (bool *ok=nullptr) const
bool | toBool (bool *ok=nullptr) const
double | toDouble (bool *ok=nullptr) const
TagLib::String | toString (bool *ok=nullptr) const
TagLib::StringList | toStringList (bool *ok=nullptr) const
TagLib::ByteVector | toByteVector (bool *ok=nullptr) const
TagLib::ByteVectorList | toByteVectorList (bool *ok=nullptr) const
TagLib::List< TagLib::Variant > | toList (bool *ok=nullptr) const
TagLib::Map< TagLib::String, TagLib::Variant > | toMap (bool *ok=nullptr) const
template<typename T>
T | value (bool *ok=nullptr) const
bool | operator== (const Variant &v) const
bool | operator!= (const Variant &v) const
Variant & | operator= (const Variant &v)

## Friends

TAGLIB_EXPORT std::ostream & | operator<< (std::ostream &s, const TagLib::Variant &v)

## Related Symbols

(Note that these are not member symbols.)
TAGLIB_EXPORT std::ostream & | operator<< (std::ostream &s, const TagLib::Variant &v)

## Detailed Description

An implicitly shared discriminated union.

This is an implicitly shared discriminated union.

The use of implicit sharing means that copying a variant is cheap. These Variant objects are immutable (have only const methods).

## Member Enumeration Documentation

## Type

enum TagLib::Variant::Type

Types which can be stored in a variant.

Enumerator
Void | variant is empty
Bool | `bool`
Int | `int`
UInt | unsigned int
LongLong | long long
ULongLong | unsigned long long
Double | `double`
String | String.
StringList | StringList.
ByteVector | ByteVector.
ByteVectorList | ByteVectorList.
VariantList | VariantList
VariantMap | VariantMap

## Constructor & Destructor Documentation

## Variant() [1/15]

TagLib::Variant::Variant | ( |  | ) |

Constructs an empty Variant.

Referenced by operator!=(), operator=(), operator==(), and Variant().

## Variant() [2/15]

TagLib::Variant::Variant | ( | int | val | ) |

## Variant() [3/15]

TagLib::Variant::Variant | ( | unsigned int | val | ) |

## Variant() [4/15]

TagLib::Variant::Variant | ( | long long | val | ) |

## Variant() [5/15]

TagLib::Variant::Variant | ( | unsigned long long | val | ) |

## Variant() [6/15]

TagLib::Variant::Variant | ( | bool | val | ) |

## Variant() [7/15]

TagLib::Variant::Variant | ( | double | val | ) |

## Variant() [8/15]

TagLib::Variant::Variant | ( | const char * | val | ) |

## Variant() [9/15]

TagLib::Variant::Variant | ( | const TagLib::String & | val | ) |

## Variant() [10/15]

TagLib::Variant::Variant | ( | const TagLib::StringList & | val | ) |

## Variant() [11/15]

TagLib::Variant::Variant | ( | const TagLib::ByteVector & | val | ) |

## Variant() [12/15]

TagLib::Variant::Variant | ( | const TagLib::ByteVectorList & | val | ) |

## Variant() [13/15]

TagLib::Variant::Variant | ( | const TagLib::List< TagLib::Variant > & | val | ) |

## Variant() [14/15]

TagLib::Variant::Variant | ( | const TagLib::Map< TagLib::String, TagLib::Variant > & | val | ) |

## Variant() [15/15]

TagLib::Variant::Variant | ( | const Variant & | v | ) |

Make a shallow, implicitly shared, copy of v. Because this is implicitly shared, this method is lightweight and suitable for pass-by-value usage.

References Variant().

## ~Variant()

TagLib::Variant::~Variant | ( |  | ) |

Destroys this Variant instance.

## Member Function Documentation

## isEmpty()

bool TagLib::Variant::isEmpty | ( |  | ) | const

Returns `true` if the Variant is empty.

## operator!=()

bool TagLib::Variant::operator!= | ( | const Variant & | v | ) | const

Returns `true` if the Variant and v differ in type or value.

References Variant().

## operator=()

Variant & TagLib::Variant::operator= | ( | const Variant & | v | ) |

Performs a shallow, implicitly shared, copy of v, overwriting the Variant's current data.

References Variant().

## operator==()

bool TagLib::Variant::operator== | ( | const Variant & | v | ) | const

Returns `true` if the Variant and v are of the same type and contain the same value.

References Variant().

## toBool()

bool TagLib::Variant::toBool | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toByteVector()

TagLib::ByteVector TagLib::Variant::toByteVector | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toByteVectorList()

TagLib::ByteVectorList TagLib::Variant::toByteVectorList | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toDouble()

double TagLib::Variant::toDouble | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toInt()

int TagLib::Variant::toInt | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toList()

TagLib::List< TagLib::Variant > TagLib::Variant::toList | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toLongLong()

long long TagLib::Variant::toLongLong | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toMap()

TagLib::Map< TagLib::String, TagLib::Variant > TagLib::Variant::toMap | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toString()

TagLib::String TagLib::Variant::toString | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toStringList()

TagLib::StringList TagLib::Variant::toStringList | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toUInt()

unsigned int TagLib::Variant::toUInt | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## toULongLong()

unsigned long long TagLib::Variant::toULongLong | ( | bool * | ok = nullptr | ) | const

Extracts a value from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## type()

Type TagLib::Variant::type | ( |  | ) | const

Get the type which is currently stored in this Variant.

## value()

template<typename T>

template TAGLIB_EXPORT VariantMap TagLib::Variant::value | ( | bool * | ok = nullptr | ) | const

Extracts value of type T from the Variant. If ok is passed, its boolean variable will be set to `true` if the Variant contains the correct type, and the returned value is the value of the Variant. Otherwise, the ok variable is set to `false` and a dummy default value is returned.

## Friends And Related Symbol Documentation

## operator<< [1/2]

TAGLIB_EXPORT std::ostream & operator<< | ( | std::ostream & | s,
|  | const TagLib::Variant & | v )

friend

References TAGLIB_EXPORT, and TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE.

## operator<<() [2/2]

TAGLIB_EXPORT std::ostream & operator<< | ( | std::ostream & | s,
|  | const TagLib::Variant & | v )

related

Send the variant to an output stream.

References ByteVector, ByteVectorList, String, StringList, and TAGLIB_EXPORT.

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

- tvariant.h