@@ -3216,6 +3216,26 @@ namespace Core {
32163216 return (*this );
32173217 }
32183218
3219+ bool operator ==(const ArrayType<ELEMENT>& RHS) const
3220+ {
3221+ const uint16_t aLength = this ->Length ();
3222+ if (aLength != RHS.Length ()) {
3223+ return false ;
3224+ }
3225+
3226+ for (uint16_t i = 0 ; i < aLength; ++i) {
3227+ if (!((*this )[i] == RHS[i])) {
3228+ return false ;
3229+ }
3230+ }
3231+ return true ;
3232+ }
3233+
3234+ bool operator !=(const ArrayType<ELEMENT>& RHS) const
3235+ {
3236+ return !(*this == RHS);
3237+ }
3238+
32193239 public:
32203240 // IElement and IMessagePack iface:
32213241 bool IsSet () const override
@@ -4537,6 +4557,9 @@ namespace Core {
45374557 return (*this );
45384558 }
45394559
4560+ bool operator ==(const Variant& other) const ;
4561+ bool operator !=(const Variant& other) const ;
4562+
45404563 inline void ToString (string& result) const ;
45414564
45424565 // IElement and IMessagePack iface:
@@ -4713,7 +4736,6 @@ namespace Core {
47134736 , _elements(std::move(move._elements))
47144737 {
47154738 Elements::iterator index (_elements.begin ());
4716-
47174739 while (index != _elements.end ()) {
47184740 ASSERT (HasLabel (index->first .c_str ()));
47194741 Container::Add (index->first .c_str (), &(index->second ));
@@ -4805,6 +4827,33 @@ namespace Core {
48054827 return (*this );
48064828 }
48074829
4830+ bool operator ==(const VariantContainer& RHS) const
4831+ {
4832+ if (this ->Size () != RHS.Size ()) {
4833+ return false ;
4834+ }
4835+
4836+ auto it = this ->Variants ();
4837+ while (it.Next ()) {
4838+ const TCHAR* key = it.Label ();
4839+ const JSON::Variant* valRHS = RHS.FindValue (key);
4840+
4841+ if (valRHS == nullptr ) {
4842+ return false ;
4843+ }
4844+
4845+ if (!(it.Current () == *valRHS)) {
4846+ return false ;
4847+ }
4848+ }
4849+ return true ;
4850+ }
4851+
4852+ bool operator !=(const VariantContainer& RHS) const
4853+ {
4854+ return !(*this == RHS);
4855+ }
4856+
48084857 void Set (const TCHAR fieldName[], const JSON::Variant& value)
48094858 {
48104859 Elements::iterator index (Find (fieldName));
@@ -4868,6 +4917,12 @@ namespace Core {
48684917 );
48694918 }
48704919
4920+ const JSON::Variant* FindValue (const TCHAR key[]) const
4921+ {
4922+ Elements::const_iterator index (Find (key));
4923+ return (index == _elements.end () ? nullptr : &index->second );
4924+ }
4925+
48714926 Iterator Variants () const
48724927 {
48734928 return (Iterator (_elements));
@@ -4944,6 +4999,40 @@ namespace Core {
49444999 return (result);
49455000 }
49465001
5002+ inline bool Variant::operator ==(const Variant& other) const
5003+ {
5004+ if (_type != other._type ) {
5005+ return false ;
5006+ }
5007+
5008+ switch (_type) {
5009+ case type::EMPTY:
5010+ return true ;
5011+ case type::BOOLEAN:
5012+ return Boolean () == other.Boolean ();
5013+ case type::STRING:
5014+ return String () == other.String ();
5015+ case type::NUMBER:
5016+ return Number () == other.Number ();
5017+ case type::FLOAT:
5018+ return Float () == other.Float ();
5019+ case type::DOUBLE:
5020+ return Double () == other.Double ();
5021+ case type::ARRAY:
5022+ return Array () == other.Array ();
5023+ case type::OBJECT:
5024+ return Object () == other.Object ();
5025+ default :
5026+ ASSERT (false );
5027+ }
5028+ return false ;
5029+ }
5030+
5031+ inline bool Variant::operator !=(const Variant& other) const
5032+ {
5033+ return !(*this == other);
5034+ }
5035+
49475036 inline bool Variant::IsValid () const {
49485037 bool result = false ;
49495038 switch (_type)
0 commit comments