19 #ifndef UNITY_SCOPES_VARIANT_H
20 #define UNITY_SCOPES_VARIANT_H
64 enum Type { Null, Int, Bool, String, Double, Dict, Array };
76 explicit
Variant(
int val) noexcept;
81 explicit
Variant(
double val) noexcept;
86 explicit
Variant(
bool val) noexcept;
91 explicit
Variant(std::
string const& val);
96 explicit
Variant(
char const* val);
118 Variant& operator=(Variant const&);
119 Variant& operator=(Variant&&);
128 Variant& operator=(
int val) noexcept;
129 Variant& operator=(
double val) noexcept;
130 Variant& operator=(
bool val) noexcept;
131 Variant& operator=(std::
string const& val);
132 Variant& operator=(
char const* val);
145 bool operator==(Variant const&) const noexcept;
146 bool operator<(Variant const&) const noexcept;
156 double get_double() const;
157 bool get_bool() const;
158 std::
string get_string() const;
181 void swap(Variant& other) noexcept;
197 Variant(internal::NullVariant const&);
199 std::unique_ptr<internal::VariantImpl> p;
200 friend class VariantImpl;
206 void swap(Variant&, Variant&) noexcept;
std::vector< Variant > VariantArray
An array of variants.
Definition: Variant.h:44
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:58
bool is_null() const
Test if variant holds null value.
Definition: Variant.cpp:251
void swap(Variant &other) noexcept
Swaps the contents of this Variant with other.
Definition: Variant.cpp:262
Variant() noexcept
The default constructor creates a Variant instance containing a null.
Definition: Variant.cpp:57
static Variant deserialize_json(std::string const &json_string)
Deserializes a JSON encoded string to a Variant.
Definition: Variant.cpp:278
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
Type
Type of value held by a Variant instance.
Definition: Variant.h:64
std::string serialize_json() const
Serializes the variant to a JSON encoded string.
Definition: Variant.cpp:272
Type which() const noexcept
Returns the type of value currently stored by this Variant.
Definition: Variant.cpp:256
static Variant const & null()
Construct a null variant.
Definition: Variant.cpp:106