本文整理汇总了C++中MojObject::visit方法的典型用法代码示例。如果您正苦于以下问题:C++ MojObject::visit方法的具体用法?C++ MojObject::visit怎么用?C++ MojObject::visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojObject
的用法示例。
在下文中一共展示了MojObject::visit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assertContains
MojErr MojDbIndexTest::assertContains(TestIndex& ti, MojObject id, MojObject key)
{
MojObjectWriter writer;
MojErr err = key.visit(writer);
MojTestErrCheck(err);
err = id.visit(writer);
MojTestErrCheck(err);
MojDbKey compoundKey;
err = compoundKey.assign(writer.buf());
MojTestErrCheck(err);
err = assertContains(ti, id, compoundKey);
MojTestErrCheck(err);
return MojErrNone;
}
示例2: assertContainsText
MojErr MojDbIndexTest::assertContainsText(TestIndex& ti, MojObject id, const MojChar* str)
{
MojString strObj;
MojErr err = strObj.assign(str);
MojErrCheck(err);
MojRefCountedPtr<MojDbTextCollator> collator(new MojDbTextCollator);
MojAllocCheck(collator.get());
err = collator->init(_T("en_US"), MojDbCollationPrimary);
MojTestErrCheck(err);
MojDbKey key;
err = collator->sortKey(strObj, key);
MojTestErrCheck(err);
MojObjectWriter writer;
err = id.visit(writer);
MojTestErrCheck(err);
const MojByte* idData = NULL;
MojSize idSize = 0;
err = writer.buf().data(idData, idSize);
MojTestErrCheck(err);
err = key.byteVec().append(idData, idData + idSize);
MojTestErrCheck(err);
err = assertContains(ti, id, key);
MojTestErrCheck(err);
return MojErrNone;
}
示例3: reply
MojErr MojServiceMessage::reply(const MojObject& payload)
{
MojErr err = payload.visit(writer());
MojErrCheck(err);
err = reply();
MojErrCheck(err);
return MojErrNone;
}
示例4: send
MojErr MojServiceRequest::send(ExtendedReplySignal::SlotRef handler, const MojChar* service, const MojChar* method,
const MojObject& payload, MojUInt32 numReplies)
{
MojAssert(service && method && numReplies);
MojErr err = payload.visit(writer());
MojErrCheck(err);
err = send(handler, service, method, numReplies);
MojErrCheck(err);
return MojErrNone;
}
示例5: handleReserveIds
MojErr MojDbServiceHandler::handleReserveIds(MojServiceMessage* msg, MojObject& payload, MojDbReq& req)
{
MojAssert(msg);
MojLogTrace(s_log);
// check space level
if( MojDbServiceHandlerInternal::spaceAlertLevel() == MojDbServiceHandlerInternal::AlertLevelHigh)
return MojErrDbQuotaExceeded;
MojInt64 count;
MojErr err = payload.getRequired(MojDbServiceDefs::CountKey, count);
MojErrCheck(err);
MojObjectVisitor& writer = msg->writer();
err = writer.beginObject();
MojErrCheck(err);
err = writer.boolProp(MojServiceMessage::ReturnValueKey, true);
MojErrCheck(err);
err = writer.propName(MojDbServiceDefs::IdsKey);
MojErrCheck(err);
err = writer.beginArray();
MojErrCheck(err);
if (count > (MojInt64) MaxReserveIdCount) {
MojErrThrowMsg(MojErrDbMaxCountExceeded, _T("cannot reserve more than %d ids"), MaxReserveIdCount);
}
for (MojInt64 i = 0; i < count; ++i) {
MojObject id;
err = m_db.reserveId(id);
MojErrCheck(err);
err = id.visit(writer);
MojErrCheck(err);
}
err = writer.endArray();
MojErrCheck(err);
err = writer.endObject();
MojErrCheck(err);
return MojErrNone;
}
示例6: putObj
MojErr MojDb::putObj(const MojObject& id, MojObject& obj, const MojObject* oldObj,
MojDbStorageItem* oldItem, MojDbReq& req, MojDbOp op, bool checkSchema)
{
MojLogTrace(s_log);
// if nothing changed, don't do the update
if (oldObj != NULL && obj == *oldObj)
return MojErrNone;
// update revision
MojInt64 rev;
MojErr err = nextId(rev);
MojErrCheck(err);
err = obj.put(RevKey, rev);
MojErrCheck(err);
// assign id
MojObject putId = id;
if (putId.undefined()) {
err = m_idGenerator.id(putId);
MojErrCheck(err);
err = obj.put(IdKey, putId);
MojErrCheck(err);
}
// assign ids to subobjects in arrays - only for regular objects
MojString kindName;
bool found = false;
err = obj.get(MojDb::KindKey, kindName, found);
MojErrCheck(err);
if (!found)
MojErrThrow(MojErrDbKindNotSpecified);
if (!kindName.startsWith(MojDbKindEngine::KindKindIdPrefix)) {
err = assignIds(obj);
MojErrCheck(err);
}
// validate, update indexes, etc.
MojTokenSet tokenSet;
err = m_kindEngine.update(&obj, oldObj, req, op, tokenSet, checkSchema);
MojErrCheck(err);
// serialize object
MojDbObjectHeader header(putId);
err = header.extractFrom(obj);
MojErrCheck(err);
MojBuffer buf;
err = header.write(buf, m_kindEngine);
MojErrCheck(err);
MojObjectWriter writer(buf, &tokenSet);
err = obj.visit(writer);
MojErrCheck(err);
// store it in the db
if (oldItem) {
err = m_objDb->update(putId, buf, oldItem, req.txn());
MojErrCheck(err);
} else {
err = m_objDb->insert(putId, buf, req.txn());
MojErrCheck(err);
}
// put header back in the object for response purposes
err = header.addTo(obj);
MojErrCheck(err);
return MojErrNone;
}