Fix operator== for Value and String comparisons

refs #7472
This commit is contained in:
Gunnar Beutner 2014-10-30 13:04:00 +01:00
parent ae1dcf6258
commit ff12522a62
2 changed files with 11 additions and 6 deletions

View File

@ -31,6 +31,7 @@
#include "base/initialize.hpp" #include "base/initialize.hpp"
#include "base/scriptvariable.hpp" #include "base/scriptvariable.hpp"
#include "base/workqueue.hpp" #include "base/workqueue.hpp"
#include "base/context.hpp"
#include <fstream> #include <fstream>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/exception/errinfo_api_function.hpp> #include <boost/exception/errinfo_api_function.hpp>
@ -125,6 +126,8 @@ void DynamicObject::Start(void)
void DynamicObject::Activate(void) void DynamicObject::Activate(void)
{ {
CONTEXT("Activating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
Start(); Start();
@ -152,6 +155,8 @@ void DynamicObject::Stop(void)
void DynamicObject::Deactivate(void) void DynamicObject::Deactivate(void)
{ {
CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
SetAuthority(false); SetAuthority(false);

View File

@ -131,6 +131,12 @@ bool Value::operator!=(const String& rhs) const
bool Value::operator==(const Value& rhs) const bool Value::operator==(const Value& rhs) const
{ {
if ((IsNumber() || IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(IsEmpty() && rhs.IsEmpty()))
return static_cast<double>(*this) == static_cast<double>(rhs);
if ((IsString() || IsEmpty()) && (rhs.IsString() || rhs.IsEmpty()) && !(IsEmpty() && rhs.IsEmpty()))
return static_cast<String>(*this) == static_cast<String>(rhs);
if (IsEmpty() != rhs.IsEmpty()) if (IsEmpty() != rhs.IsEmpty())
return false; return false;
@ -162,12 +168,6 @@ bool Value::operator==(const Value& rhs) const
return static_cast<Object::Ptr>(*this) == static_cast<Object::Ptr>(rhs); return static_cast<Object::Ptr>(*this) == static_cast<Object::Ptr>(rhs);
} }
if ((IsNumber() || IsEmpty()) && (rhs.IsNumber() || rhs.IsEmpty()) && !(IsEmpty() && rhs.IsEmpty()))
return static_cast<double>(*this) == static_cast<double>(rhs);
if ((IsString() || IsEmpty()) && (rhs.IsString() || rhs.IsEmpty()) && !(IsEmpty() && rhs.IsEmpty()))
return static_cast<String>(*this) == static_cast<String>(rhs);
return false; return false;
} }