Luna::Variant::operator==
bool operator==(const Variant &rhs) const
Compares two variant for equality.
Parameters
-
in rhs
The variant to compare.
Return value
Returns true
if two variants are equal. Returns false
otherwise.
Remark
The comparison is proceeded as follows:1. If this->type() != ths.type()
, returns false
.
-
Otherwise, checks the type of the variant:1. If
type()
isVariantType::null
, returnstrue
. -
If
type()
isVariantType::object
, returnstrue
if two variants have the same key-value pairs. Every element ofrhs
will be compared with the element with the same key in*this
recursively. -
If
type()
isVariantType::array
, returnstrue
if two variants have the same array data and size. Every element will be compared with the element with the same index in*this
recursively. -
If
type()
isVariantType::number
, returnstrue
if two variants have the same number type and value. -
If
type()
isVariantType::string
, returnstrue
if two variants have the same string data. The string data is compared by comparing the underlying Name objects that contain the string. -
If
type()
isVariantType::boolean
, returnstrue
if two variants have the same Boolean value. -
If
type()
isVariantType::blob
, returnstrue
if two variants have the same blob data. The blob data is compared using memcmp.