本文整理汇总了C++中MojObject::del方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::del方法的具体用法?C++ MojObject::del怎么用?C++ MojObject::del使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojObject
的用法示例。
在下文中一共展示了MojObject::del方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timeUpdateKind
MojErr MojDbPerfUpdateTest::timeUpdateKind(MojDb& db, const MojChar* kindJson, MojObject& kindObj, MojTime& addIndexTime, MojTime& dropIndexTime)
{
MojTime startTime;
MojTime endTime;
MojObject origKindObj;
MojErr err = origKindObj.fromJson(kindJson);
MojTestErrCheck(err);
for (MojUInt64 i = 0; i < numUpdateKindIterations; i++) {
err = MojGetCurrentTime(startTime);
MojTestErrCheck(err);
bool found;
err = kindObj.del(MojDb::RevKey, found);
MojTestErrCheck(err);
err = db.putKind(kindObj);
MojTestErrCheck(err);
err = MojGetCurrentTime(endTime);
MojTestErrCheck(err);
addIndexTime += (endTime - startTime);
totalTestTime += (endTime - startTime);
err = MojGetCurrentTime(startTime);
MojTestErrCheck(err);
err = origKindObj.del(MojDb::RevKey, found);
MojTestErrCheck(err);
err = db.putKind(origKindObj);
MojTestErrCheck(err);
err = MojGetCurrentTime(endTime);
MojTestErrCheck(err);
dropIndexTime += (endTime - startTime);
totalTestTime += (endTime - startTime);
}
return MojErrNone;
}
示例2: emptyTest
MojErr MojObjectTest::emptyTest(MojObject& obj)
{
MojObject obj2;
MojString str1;
MojString str2;
bool found = false;
MojTestAssert(obj.size() == 0);
MojTestAssert(obj.empty());
MojTestAssert(obj.boolValue() == false);
MojTestAssert(obj.intValue() == 0);
MojTestAssert(obj.decimalValue() == MojDecimal());
MojTestAssert(obj.begin() == obj.end());
MojTestAssert(!obj.contains(_T("hello")));
MojTestAssert(!obj.get(_T("hi"), obj2));
MojErr err = obj.del(_T("hello"), found);
MojTestErrCheck(err);
obj2.assign(obj);
MojTestAssert(obj2.type() == obj.type());
MojTestAssert(obj2 == obj);
MojTestAssert(!(obj2 != obj));
err = obj.stringValue(str1);
MojTestErrCheck(err);
err = obj2.stringValue(str2);
MojTestErrCheck(err);
MojTestAssert(str1 == str2);
return MojErrNone;
}
示例3: MojErrCheck
MojErr MojDbSearchCache::QueryKey::setQuery(const MojDbQuery& query)
{
MojObject obj;
MojErr err = query.toObject(obj);
MojErrCheck(err);
bool foundOut=false;
obj.del(MojDbQuery::PageKey, foundOut);
obj.del(MojDbQuery::LimitKey, foundOut);
err = obj.toJson(m_query);
MojErrCheck(err);
setKind(query.from());
return err;
}
示例4: Response
MojErr Response(MojObject& response, MojErr err)
{
bool success = true;
bool getSuccess = response.get("returnValue", success);
if (err || !getSuccess || !success) {
// unfortunately file cache doesn't use regular C++ mojo error codes
// & more unfortunately all the various failure reasons for define are hidden
// behind 1 error code
MojInt64 errorCode;
if (response.get("errorCode", errorCode)) {
FileCacheFailure failure = (FileCacheFailure)errorCode;
// be generous in the error code that can be used
if (failure == FCDefineError || failure == FCExistsError) {
MojString mojErrorText;
string errorText;
std::string nakOkSuffix = "' already exists.";
response.getRequired("errorText", mojErrorText);
errorText = mojErrorText.data();
if (endsWith(errorText, nakOkSuffix)) {
LOG_DEBUG("caching negative response for %s", m_config.c_str());
bool found = false;
response.del("errorCode", found);
response.del("errorText", found);
err = response.putBool("returnValue", true);
MarkConfigured();
} else {
LOG_WARNING(MSGID_FILE_CACHE_CONFIG_WARNING, 2,
PMLOGKS("error", errorText.c_str()),
PMLOGKS("suffix", nakOkSuffix.c_str()),
"File cache failed to register type (`%s' doesn't end with `%s'", errorText.c_str(), nakOkSuffix.c_str());
}
} else {
LOG_WARNING(MSGID_FILE_CACHE_CONFIG_WARNING, 1,
PMLOGKFV("error", "%d", (int)errorCode),
"Unrecognized errorCode %d", (int)errorCode);
}
} else {
LOG_WARNING(MSGID_FILE_CACHE_CONFIG_WARNING, 0, "errorCode not provided in request failure");
}
} else {
LOG_DEBUG("FileCacheConfigurator response for %s contained no problems", m_config.c_str());
}
return DelegateResponse(response, err);
}
示例5: delIndex
MojErr MojDbKindState::delIndex(const MojChar* indexName, MojDbReq& req)
{
MojAssert(indexName);
MojThreadGuard guard(m_lock);
MojObject obj;
MojRefCountedPtr<MojDbStorageItem> item;
MojErr err = readIds(IndexIdsKey, req, obj, item);
MojErrCheck(err);
bool found = false;
err = obj.del(indexName, found);
MojErrCheck(err);
MojAssert(found);
err = writeIds(IndexIdsKey, obj, req, item);
MojErrCheck(err);
return MojErrNone;
}
示例6: WriteToFileCache
void SaveEmailCommand::WriteToFileCache(MojObject &part, const MojString &pathName)
{
MojErr err;
MojString content;
err = part.getRequired("content", content);
ErrorToException(err);
// FIXME: make this async
FILE *fp = fopen(pathName.data(), "w");
if(fp) {
fwrite(content.data(), sizeof(MojChar), content.length(), fp);
fclose(fp);
} else {
throw MailException("error opening file cache path", __FILE__, __LINE__);
}
// Cancel subscription to signal that we're done writing
m_fileCacheInsertedSlot.cancel();
MojString type;
err = part.getRequired(EmailSchema::Part::TYPE, type);
ErrorToException(err);
if (type == EmailSchema::Part::Type::BODY) {
std::string previewText = PreviewTextGenerator::GeneratePreviewText(content.data(), MAX_SUMMARY_LENGTH, true);
err = m_email.putString(EmailSchema::SUMMARY, previewText.c_str());
ErrorToException(err);
}
// Delete content field so it doesn't get written to the database
bool wasDeleted;
part.del("content", wasDeleted);
// Next step
if(m_partsIt == m_partsArray.arrayEnd())
PersistToDatabase(); // done
else
CreateNextCacheObject(); // more parts remaining
return;
}
示例7: privatelogIMMessage
/**
* Log the json for an incoming IM payload so we can troubleshoot errors in the field in
* non debug builds.
*
* removes "private" data - ie. message body
*/
MojErr IMServiceHandler::privatelogIMMessage(const MojChar* format, MojObject IMObject, const MojChar* messageTextKey) {
MojString mojStringJson;
MojString msgText;
// replace the message body
// not much we can do about errors here...
bool found = false;
MojErr err = IMObject.del(messageTextKey, found);
MojErrCheck(err);
if (found) {
msgText.assign(_T("***IM Body Removed***"));
IMObject.put(messageTextKey, msgText);
}
// log it (non debug)
IMObject.toJson(mojStringJson);
MojLogNotice(IMServiceApp::s_log, format, mojStringJson.data());
return MojErrNone;
}
示例8: dumpObj
MojErr MojDb::dumpObj(MojFile& file, MojObject obj, MojSize& bytesWrittenOut, MojUInt32 maxBytes)
{
// remove the rev key before dumping the object
bool found = false;
MojErr err = obj.del(RevKey, found);
MojErrCheck(err);
MojString str;
err = obj.toJson(str);
MojErrCheck(err);
err = str.append(_T("\n"));
MojErrCheck(err);
MojSize len = str.length() * sizeof(MojChar);
// if writing this object will put us over the max length, throw an error
if (maxBytes && bytesWrittenOut + len > maxBytes) {
MojErrThrow(MojErrDbBackupFull);
}
err = file.writeString(str, bytesWrittenOut);
MojErrCheck(err);
return MojErrNone;
}
示例9: Response
MojErr Response(MojObject& response, MojErr err)
{
bool success = true;
response.get("returnValue", success);
if (err || !success) {
MojInt64 errorCode;
if (response.get("errorCode", errorCode)) {
if (errorCode == MojErrExists) {
MojLogInfo(Logger(), "caching ok negative response for %s", m_config.c_str());
bool found = false;
response.del("errorCode", found);
response.del("errorText", found);
err = response.putBool("returnValue", true);
MarkConfigured();
} else {
MojLogWarning(Logger(), "Unrecognized errorCode %d", (int)errorCode);
}
} else {
MojLogWarning(Logger(), "errorCode not provided in request failure");
}
}
return DelegateResponse(response, err);
}
示例10: RemoveKey
static void RemoveKey(MojObject& object, const MojChar *key)
{
bool keydeleted;
object.del(key, keydeleted);
}