本文整理汇总了C++中MojDbKey::byteVec方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDbKey::byteVec方法的具体用法?C++ MojDbKey::byteVec怎么用?C++ MojDbKey::byteVec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDbKey
的用法示例。
在下文中一共展示了MojDbKey::byteVec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: rangesFromKeys
MojErr MojDbQueryPlan::rangesFromKeys(MojDbKey lowerKey, MojDbKey upperKey, MojDbKey prefix, MojUInt32 index,
const MojDbQuery::WhereClause* clause)
{
MojErr err = MojErrNone;
MojUInt32 group = 0;
MojDbQuery::CompOp lowerOp = MojDbQuery::OpEq;
MojDbQuery::CompOp upperOp = MojDbQuery::OpNone;
if (clause) {
lowerOp = clause->lowerOp();
upperOp = clause->upperOp();
}
// set up upper bound
switch (upperOp) {
case MojDbQuery::OpNone:
MojAssert(lowerOp != MojDbQuery::OpNone);
upperKey = prefix;
// no break. fall through to OpLessThanEq case
case MojDbQuery::OpLessThanEq:
// match while less-than ++upperKey
err = upperKey.increment();
MojErrCheck(err);
break;
default:
MojAssert(upperOp == MojDbQuery::OpLessThan);
break;
}
// set up lower bound
switch (lowerOp) {
case MojDbQuery::OpNone:
// seek to prefix and match while less than upperKey
MojAssert(upperOp != MojDbQuery::OpNone);
err = addRange(lowerKey, upperKey);
MojErrCheck(err);
break;
case MojDbQuery::OpSearch:
group = index % m_groupCount;
// no break. fall through to OpPrefix case
case MojDbQuery::OpPrefix:
// remove null terminator
MojAssert(!prefix.empty());
if (prefix.byteVec().back() == 0) {
err = prefix.byteVec().pop();
MojErrCheck(err);
}
// no break. fall through to OpEq case
case MojDbQuery::OpEq:
// seek to lowerKey and match while less than ++prefix
err = prefix.increment();
MojErrCheck(err);
err = addRange(lowerKey, prefix, group);
MojErrCheck(err);
break;
case MojDbQuery::OpNotEq:
// seek to prefix and match while less than lowerKey
err = addRange(prefix, lowerKey);
MojErrCheck(err);
// seek to ++lowerKey, and match while less than ++prefix
err = lowerKey.increment();
MojErrCheck(err);
err = prefix.increment();
MojErrCheck(err);
err = addRange(lowerKey, prefix);
MojErrCheck(err);
break;
case MojDbQuery::OpGreaterThan:
// seek to ++lowerKey and match while less than upperKey
err = lowerKey.increment();
MojErrCheck(err);
// no break. fall through to OpGreaterThanEq case
case MojDbQuery::OpGreaterThanEq:
// seek to lowerKey and match while less than upperKey
err = addRange(lowerKey, upperKey);
MojErrCheck(err);
break;
default:
MojAssertNotReached();
break;
}
return MojErrNone;
}