예제 #1
0
 bool JSONObject::isEqualTo(JSONValue* value) {
     assert(value != nullptr);
     
     if (JSONValue::isEqualTo(value) == true)
         return true;
     
     JSONObject *objectValue = (JSONObject*)(value);
     
     //for this first pass/implementation, it will be a bit slow as many , we'll gather all the keys
     //then, if the number of keys is equal on both objects, then check if all the keys are equlals, and finally if these objects are equal one by one.
     shared_ptr<JSONArray> keysA = this->keys();
     shared_ptr<JSONArray> keysB = objectValue->keys();
     
     if (keysA->getCount() != keysB->getCount())
         return false;
     
     if (keysA->isEqualTo(keysB.get()) == false)
         return false;
     
     JSONValueVectorRef allKeys = keysA->values();
     for (size_t i = 0 ; i < allKeys.size() ; i++) {
         shared_ptr<JSONString> key = static_pointer_cast<JSONString>(allKeys[i]);
         
         shared_ptr<JSONValue> objA = this->getValue(key->getString());
         shared_ptr<JSONValue> objB = objectValue->getValue(key->getString());
         if (objA->isEqualTo(objB.get()) == false) {
             return false;
         }
     }
     
     return true;
 }
예제 #2
0
파일: GLTFMesh.cpp 프로젝트: Meai/glTF
 size_t GLTFMesh::getPrimitivesCount() {
     size_t count = 0;
     shared_ptr<JSONArray> primitives = this->getPrimitives();
     if (primitives) {
         JSONValueVectorRef values = primitives->values();
         count = values.size();
     }
     return count;
 }
예제 #3
0
파일: GLTFMesh.cpp 프로젝트: Meai/glTF
 shared_ptr<GLTFMesh> GLTFMesh::clone() {
     
     shared_ptr<GLTFMesh> clonedMesh(new GLTFMesh());
     
     clonedMesh->setID(this->getID());
     clonedMesh->setName(this->getName());
     clonedMesh->_semanticToMeshAttributes = this->_semanticToMeshAttributes;
     
     JSONValueVectorRef primitives =  this->getPrimitives()->values();
     for (size_t i = 0 ; i < primitives.size() ; i++) {
         shared_ptr <GLTFPrimitive> primitive = static_pointer_cast<GLTFPrimitive>(primitives[i]);
         clonedMesh->appendPrimitive(primitive->clone());
     }
     
     return clonedMesh;
 }