本文整理汇总了C++中MojDbKey::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDbKey::empty方法的具体用法?C++ MojDbKey::empty怎么用?C++ MojDbKey::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDbKey
的用法示例。
在下文中一共展示了MojDbKey::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activate
MojErr MojDbWatcher::activate(const MojDbKey& limitKey)
{
MojAssert(m_index);
MojThreadGuard guard(m_mutex);
m_state = StateActive;
bool fired = !m_fireKey.empty();
bool inRange = fired &&
(limitKey.empty() ||
(m_desc && m_fireKey >= limitKey) ||
(!m_desc && m_fireKey <= limitKey));
if (inRange) {
// we were fired before activation, so if the maxKey our cursor returned
// is >= the minKey with which we were fired, go ahead and do the fire
MojErr err = fireImpl();
MojErrCheck(err);
} else {
// keep limit so we can reject fires for larger keys
m_limitKey = limitKey;
}
MojLogDebug(MojDb::s_log, _T("Watcher_activate: state= %d; fired = %d; inrange = %d; index name = %s; domain = %s\n"), (int)m_state,
(int)fired, (int)inRange, ((m_index) ? m_index->name().data(): NULL), ((m_domain) ? m_domain.data(): NULL));
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;
}