tvariant.h
Go to the documentation of this file.
/***************************************************************************
copyright : (C) 2023 by Urs Fleisch
email : ufleisch@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_VARIANT_H
#define TAGLIB_VARIANT_H
#include <sstream>
#include "tlist.h"
#include "tmap.h"
#include "taglib_export.h"
// Forward declaration needed for friend function
namespace TagLib { class Variant; }
TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::Variant &v);
namespace TagLib {
class String;
class StringList;
class ByteVector;
class ByteVectorList;
class TAGLIB_EXPORT Variant
{
public:
// The number and order of these types must correspond to the template
// parameters for StdVariantType in tvariant.cpp!
enum Type {
Void,
Bool,
Int,
UInt,
LongLong,
ULongLong,
Double,
String,
StringList,
ByteVector,
ByteVectorList,
VariantList,
VariantMap
};
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);
private:
friend TAGLIB_EXPORT std::ostream& ::operator<<(std::ostream &s, const TagLib::Variant &v);
class VariantPrivate;
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
std::shared_ptr<VariantPrivate> d;
};
using VariantList = TagLib::List<TagLib::Variant>;
using VariantMap = TagLib::Map<TagLib::String, TagLib::Variant>;
extern template TAGLIB_EXPORT bool Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT int Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT unsigned int Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT long long Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT unsigned long long Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT double Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT String Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT StringList Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT ByteVector Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT ByteVectorList Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT VariantList Variant::value(bool *ok) const;
extern template TAGLIB_EXPORT VariantMap Variant::value(bool *ok) const;
} // namespace TagLib
#endif
TagLib::ByteVectorList
A list of ByteVectors.
Definition tbytevectorlist.h:42
TagLib::ByteVector
A byte vector.
Definition tbytevector.h:46
TagLib::List
A generic, implicitly shared list.
Definition tlist.h:54
TagLib::Map
A generic, implicitly shared map.
Definition tmap.h:45
TagLib::StringList
A list of strings.
Definition tstringlist.h:44
TagLib::String
A wide string class suitable for unicode.
Definition tstring.h:83
TagLib::Variant
An implicitly shared discriminated union.
Definition tvariant.h:61
TagLib::Variant::Variant
Variant(double val)
TagLib::Variant::value
T value(bool *ok=nullptr) const
TagLib::Variant::toStringList
TagLib::StringList toStringList(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(unsigned int val)
TagLib::Variant::toUInt
unsigned int toUInt(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(const TagLib::List< TagLib::Variant > &val)
TagLib::Variant::Variant
Variant(int val)
TagLib::Variant::Variant
Variant(const TagLib::String &val)
TagLib::Variant::toList
TagLib::List< TagLib::Variant > toList(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(const TagLib::ByteVector &val)
TagLib::Variant::toByteVectorList
TagLib::ByteVectorList toByteVectorList(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(const char *val)
TagLib::Variant::Variant
Variant(const TagLib::ByteVectorList &val)
TagLib::Variant::toBool
bool toBool(bool *ok=nullptr) const
TagLib::Variant::operator!=
bool operator!=(const Variant &v) const
TagLib::Variant::toInt
int toInt(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(bool val)
TagLib::Variant::Type
Type
Definition tvariant.h:68
TagLib::Variant::UInt
@ UInt
unsigned int
Definition tvariant.h:72
TagLib::Variant::VariantList
@ VariantList
VariantList
Definition tvariant.h:80
TagLib::Variant::String
@ String
String.
Definition tvariant.h:76
TagLib::Variant::LongLong
@ LongLong
long long
Definition tvariant.h:73
TagLib::Variant::VariantMap
@ VariantMap
VariantMap
Definition tvariant.h:81
TagLib::Variant::Int
@ Int
int
Definition tvariant.h:71
TagLib::Variant::Void
@ Void
variant is empty
Definition tvariant.h:69
TagLib::Variant::ByteVector
@ ByteVector
ByteVector.
Definition tvariant.h:78
TagLib::Variant::Bool
@ Bool
bool
Definition tvariant.h:70
TagLib::Variant::ByteVectorList
@ ByteVectorList
ByteVectorList.
Definition tvariant.h:79
TagLib::Variant::Double
@ Double
double
Definition tvariant.h:75
TagLib::Variant::StringList
@ StringList
StringList.
Definition tvariant.h:77
TagLib::Variant::ULongLong
@ ULongLong
unsigned long long
Definition tvariant.h:74
TagLib::Variant::Variant
Variant(const Variant &v)
TagLib::Variant::Variant
Variant(const TagLib::Map< TagLib::String, TagLib::Variant > &val)
TagLib::Variant::isEmpty
bool isEmpty() const
TagLib::Variant::toULongLong
unsigned long long toULongLong(bool *ok=nullptr) const
TagLib::Variant::toDouble
double toDouble(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant()
TagLib::Variant::operator=
Variant & operator=(const Variant &v)
TagLib::Variant::type
Type type() const
TagLib::Variant::operator<<
TAGLIB_EXPORT std::ostream & operator<<(std::ostream &s, const TagLib::Variant &v)
TagLib::Variant::toMap
TagLib::Map< TagLib::String, TagLib::Variant > toMap(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(unsigned long long val)
TagLib::Variant::~Variant
~Variant()
TagLib::Variant::toString
TagLib::String toString(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(long long val)
TagLib::Variant::toByteVector
TagLib::ByteVector toByteVector(bool *ok=nullptr) const
TagLib::Variant::Variant
Variant(const TagLib::StringList &val)
TagLib::Variant::toLongLong
long long toLongLong(bool *ok=nullptr) const
TagLib::Variant::operator==
bool operator==(const Variant &v) const
TagLib
A namespace for all TagLib related classes and functions.
Definition apefile.h:41
TagLib::VariantMap
TagLib::Map< TagLib::String, TagLib::Variant > VariantMap
Definition tvariant.h:195
TagLib::VariantList
TagLib::List< TagLib::Variant > VariantList
Definition tvariant.h:192
taglib_export.h
TAGLIB_EXPORT
#define TAGLIB_EXPORT
Definition taglib_export.h:40
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition taglib_export.h:55
tlist.h
tmap.h