I was debugging a plugin I am working on to find an issue ...
After finding the actual cause of the problem, I just couldn't believe this.
So, I made a test CommandData
plugin with only the problematic code as part of the Execute
Bool MyCommand::Execute(BaseDocument* doc)
{
BaseContainer bc1;
bc1.SetInt32(1, 1234);
bc1.SetString(2, "abcd"_s);
bc1.SetFloat(3, 0.1234);
bc1.SetBool(4, true);
BaseContainer bc2;
bc2.SetString(2, "abcd"_s);
bc2.SetFloat(3, 0.1234);
bc2.SetBool(4, true);
bc2.SetInt32(1, 1234); // this line was moved from being the first to being the last
ApplicationOutput("BaseContainer 1 equals BaseContainer 2: @", bc1 == bc2);
ApplicationOutput("BaseContainer 1 not equals BaseContainer 2: @", bc1 != bc2);
return true;
}
Notice that the second BaseContainer
is just a duplicate of the first one. The only thing which differs, is that I moved the first line of data assignment to be the last one.
In other works: the IDs and values are E-X-A-C-T-L-Y identical, only the order/sequence in which they are applied is different.
According to the documentation:
Bool operator== ( const BaseContainer & d ) const
Equality operator. Checks if the containers have the same IDs, the same values and all values are equal.
Parameters
[in] d The container to compare against.
Returns
true if the containers have the same IDs, the same values and all values are equal, otherwise false.
Bool operator!= ( const BaseContainer & d ) const
Not equal operator. Checks if the containers have different IDs, different values or values are different.
Parameters
[in] d The container to compare against.
Returns
true if the containers have different IDs, different values or values are different, otherwise false.
Same IDs, same values. You would thus expect the two to be equal.
And yet, when I execute the plugin, following is the result shown in the console:
BaseContainer 1 equals BaseContainer 2: false
BaseContainer 1 not equals BaseContainer 2: true
As this is just a fundamental check, and it provides me a result which is opposite to what is to be expected (from logic and from what documentation says) ... I must be doing something wrong here, right?
So, what am I overlooking this time?