void ProvisioningAttrList::deleteAttrElements(UtlContainable* pAttrElements) { UtlString* pMemberName; UtlContainable* pMemberValue; if (UtlString(pAttrElements->getContainableType()) == "UtlHashMap") { UtlHashMapIterator structureIterator(*dynamic_cast<UtlHashMap*>(pAttrElements)); while ((pMemberName = dynamic_cast<UtlString*>(structureIterator())) != NULL) { pMemberValue = dynamic_cast<UtlHashMap*>(pAttrElements)->findValue(pMemberName); if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap" || UtlString(pMemberValue->getContainableType()) == "UtlSList") { deleteAttrElements(pMemberValue); } delete pMemberName; delete pMemberValue; } } else if (UtlString(pAttrElements->getContainableType()) == "UtlSList") { UtlSListIterator arrayIterator(*dynamic_cast<UtlSList*>(pAttrElements)); while ((pMemberValue = arrayIterator()) != NULL) { if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap" || UtlString(pMemberValue->getContainableType()) == "UtlSList") { deleteAttrElements(pMemberValue); } delete pMemberValue; } } }
int WriteResult::_createUpserts(const BSONElement& upserted, const std::vector<WriteOperation*>& ops) { int nUpserted = 0; BSONObjIterator arrayIterator(upserted.Obj()); while (arrayIterator.more()) { _createUpsert(arrayIterator.next(), ops); nUpserted++; } return nUpserted; }
void WriteResult::_mergeCommandResult( const std::vector<WriteOperation*>& ops, const BSONObj& result ) { int affected = _getIntOrDefault(result, "n"); // Handle Write Batch switch (ops.front()->operationType()) { case dbWriteInsert: _nInserted += affected; break; case dbWriteDelete: _nRemoved += affected; break; case dbWriteUpdate: if (result.hasField("upserted")) { int nUpserted = _createUpserts(result.getField("upserted"), ops); _nUpserted += nUpserted; _nMatched += (affected - nUpserted); } else { _nMatched += affected; } _setModified(result); break; } // Handle Write Errors if (result.hasField("writeErrors")) { BSONElement writeErrors = result.getField("writeErrors"); BSONObjIterator arrayIterator(writeErrors.Obj()); BSONElement current; while (arrayIterator.more()) _createWriteError(arrayIterator.next().Obj(), ops); } // Handle Write Concern Errors if (result.hasField("writeConcernError")) { BSONObj writeConcernError = result.getObjectField("writeConcernError"); _createWriteConcernError(writeConcernError); } }
void ProvisioningAttrList::dumpAttributes(const UtlContainable* pAttribute) { static UtlString* pMemberName; UtlContainable* pMemberValue; if (UtlString(pAttribute->getContainableType()) == "UtlHashMap") { UtlHashMapIterator structureIterator(*dynamic_cast<const UtlHashMap*>(pAttribute)); while ((pMemberName = dynamic_cast<UtlString*>(structureIterator())) != NULL) { pMemberValue = dynamic_cast<const UtlHashMap*>(pAttribute)->findValue(pMemberName); if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap" || UtlString(pMemberValue->getContainableType()) == "UtlSList") { dumpAttributes(pMemberValue); } if (UtlString(pMemberValue->getContainableType()) == "UtlBool") { osPrintf("{%s} = (BOOL) %s\n", pMemberName->data(), (dynamic_cast<UtlBool*>(pMemberValue)->getValue() ? "TRUE" : "FALSE")); } else if (UtlString(pMemberValue->getContainableType()) == "UtlInt") { osPrintf("{%s} = (INT) %d\n", pMemberName->data(), dynamic_cast<UtlInt*>(pMemberValue)->getValue()); } else if (UtlString(pMemberValue->getContainableType()) == "UtlString") { osPrintf("{%s} = (STRING) \"%s\"\n", pMemberName->data(), dynamic_cast<UtlString*>(pMemberValue)->data()); } } } else if (UtlString(pAttribute->getContainableType()) == "UtlSList") { UtlSListIterator arrayIterator(*dynamic_cast<const UtlSList*>(pAttribute)); int arrayIndex = 0; while ((pMemberValue = arrayIterator()) != NULL) { if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap" || UtlString(pMemberValue->getContainableType()) == "UtlSList") { dumpAttributes(pMemberValue); } if (UtlString(pMemberValue->getContainableType()) == "UtlBool") { osPrintf("{%s}[%d] = (BOOL) %s\n", pMemberName->data(), arrayIndex++, (dynamic_cast<UtlBool*>(pMemberValue)->getValue() ? "TRUE" : "FALSE")); } else if (UtlString(pMemberValue->getContainableType()) == "UtlInt") { osPrintf("{%s}[%d] = (INT) %d\n", pMemberName->data(), arrayIndex++, dynamic_cast<UtlInt*>(pMemberValue)->getValue()); } else if (UtlString(pMemberValue->getContainableType()) == "UtlString") { osPrintf("{%s}[%d] = (STRING) \"%s\"\n", pMemberName->data(), arrayIndex++, dynamic_cast<UtlString*>(pMemberValue)->data()); } } } }