<commit_before>/*
 * Copyright (c) 2007 Digital Bazaar, Inc.  All rights reserved.
 */
#include "db/util/DynamicObject.h"
#include "db/util/DynamicObjectIterator.h"

using namespace db::rt;
using namespace db::util;

DynamicObject::DynamicObject() :
   Collectable<DynamicObjectImpl>(new DynamicObjectImpl())
{
}

DynamicObject::DynamicObject(DynamicObjectImpl* impl) :
   Collectable<DynamicObjectImpl>(impl)
{
}

DynamicObject::DynamicObject(const DynamicObject& rhs) :
   Collectable<DynamicObjectImpl>(rhs)
{
}

DynamicObject::~DynamicObject()
{
}

bool DynamicObject::operator==(const DynamicObject& rhs)
{
   bool rval = false;
   
   DynamicObject* left = (DynamicObject*)this;
   DynamicObject* right = (DynamicObject*)&rhs;
   
   if(this == &rhs)
   {
      rval = true;
   }
   else if(this->mReference == rhs.mReference)
   {
      rval = true;
   }
   else if((*left)->getType() == (*right)->getType())
   {
      int index = 0;
      DynamicObjectIterator i;
      switch((*left)->getType())
      {
         case String:
            rval = (strcmp((*left)->getString(), (*right)->getString()) == 0);
            break;
         case Boolean:
            rval = (*left)->getBoolean() == (*right)->getBoolean();
            break;
         case Int32:
            rval = (*left)->getInt32() == (*right)->getInt32();
            break;
         case UInt32:
            rval = (*left)->getUInt32() == (*right)->getUInt32();
            break;
         case Int64:
            rval = (*left)->getInt64() == (*right)->getInt64();
            break;
         case UInt64:
            rval = (*left)->getUInt64() == (*right)->getUInt64();
            break;
         case Double:
            rval = (*left)->getDouble() == (*right)->getDouble();
            break;<commit_msg>Added NULL check in equals operator for DynamicObject.<commit_after>/*
 * Copyright (c) 2007 Digital Bazaar, Inc.  All rights reserved.
 */
#include "db/util/DynamicObject.h"
#include "db/util/DynamicObjectIterator.h"

using namespace db::rt;
using namespace db::util;

DynamicObject::DynamicObject() :
   Collectable<DynamicObjectImpl>(new DynamicObjectImpl())
{
}

DynamicObject::DynamicObject(DynamicObjectImpl* impl) :
   Collectable<DynamicObjectImpl>(impl)
{
}

DynamicObject::DynamicObject(const DynamicObject& rhs) :
   Collectable<DynamicObjectImpl>(rhs)
{
}

DynamicObject::~DynamicObject()
{
}

bool DynamicObject::operator==(const DynamicObject& rhs)
{
   bool rval = false;
   
   DynamicObject* left = (DynamicObject*)this;
   DynamicObject* right = (DynamicObject*)&rhs;
   
   if(this == &rhs)
   {
      rval = true;
   }
   else if(this->mReference == rhs.mReference)
   {
      rval = true;
   }
   else if(this->mReference == NULL || rhs.mReference == NULL)
   {
      // one is NULL, other is not, so not equal
   }
   else if((*left)->getType() == (*right)->getType())
   {
      int index = 0;
      DynamicObjectIterator i;
      switch((*left)->getType())
      {
         case String:
            rval = (strcmp((*left)->getString(), (*right)->getString()) == 0);
            break;
         case Boolean:
            rval = (*left)->getBoolean() == (*right)->getBoolean();
            break;
         case Int32:
            rval = (*left)->getInt32() == (*right)->getInt32();
            break;
         case UInt32:
            rval = (*left)->getUInt32() == (*right)->getUInt32();
            break;
         case Int64:
            rval = (*left)->getInt64() == (*right)->getInt64();
            break;
         case UInt64:
            rval = (*left)->getUInt64() == (*right)->getUInt64();
            break;
         case Double:
            rval = (*left)->getDouble() == (*right)->getDouble();
            break;
{'fraction_non_alphanumeric': 0.1629589922272849, 'fraction_numerical': 0.016081479496113642, 'mean_word_length': 2.547528517110266, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2745227', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1118, 'n_words': 230}