本文整理汇总了C++中KeyV1类的典型用法代码示例。如果您正苦于以下问题:C++ KeyV1类的具体用法?C++ KeyV1怎么用?C++ KeyV1使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyV1类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toBson
bool KeyV1::woEqual(const KeyV1& right) const {
const unsigned char *l = _keyData;
const unsigned char *r = right._keyData;
if( (*l|*r) == IsBSON ) {
return toBson().equal(right.toBson());
}
while( 1 ) {
char lval = *l;
char rval = *r;
if( (lval&(cCANONTYPEMASK|cHASMORE)) != (rval&(cCANONTYPEMASK|cHASMORE)) )
return false;
l++;
r++;
switch( lval&cCANONTYPEMASK ) {
case coid:
if( *((unsigned*) l) != *((unsigned*) r) )
return false;
l += 4;
r += 4;
case cdate:
case cdouble:
if( *((unsigned long long *) l) != *((unsigned long long *) r) )
return false;
l += 8;
r += 8;
break;
case cstring:
{
unsigned sz = ((unsigned) *l) + 1;
if( memcmp(l, r, sz) ) // first byte checked is the length byte
return false;
l += sz;
r += sz;
break;
}
case cbindata:
{
int len = binDataCodeToLength(*l) + 1;
if( memcmp(l, r, len) )
return false;
l += len;
r += len;
break;
}
case cminkey:
case cnull:
case cfalse:
case ctrue:
case cmaxkey:
break;
default:
assert(false);
}
if( (lval&cHASMORE) == 0 )
break;
}
return true;
}
示例2: toBson
bool KeyV1::woEqual(const KeyV1& right) const {
const unsigned char *l = _keyData;
const unsigned char *r = right._keyData;
if( (*l|*r) == IsBSON ) {
return toBson().equal(right.toBson());
}
while( 1 ) {
char lval = *l;
char rval = *r;
if( (lval&(cCANONTYPEMASK|cHASMORE)) != (rval&(cCANONTYPEMASK|cHASMORE)) )
return false;
l++; r++;
switch( lval&cCANONTYPEMASK ) {
case coid:
if( *((unsigned*) l) != *((unsigned*) r) )
return false;
l += 4; r += 4;
case cdate:
if( *((unsigned long long *) l) != *((unsigned long long *) r) )
return false;
l += 8; r += 8;
break;
case cdouble:
if( (reinterpret_cast< const PackedDouble* > (l))->d != (reinterpret_cast< const PackedDouble* >(r))->d )
return false;
l += 8; r += 8;
break;
case cstring:
{
if( *l != *r )
return false; // not same length
unsigned sz = ((unsigned) *l) + 1;
if( memcmp(l, r, sz) )
return false;
l += sz; r += sz;
break;
}
case cbindata:
{
if( *l != *r )
return false; // len or subtype mismatch
int len = binDataCodeToLength(*l) + 1;
if( memcmp(l, r, len) )
return false;
l += len; r += len;
break;
}
case cminkey:
case cnull:
case cfalse:
case ctrue:
case cmaxkey:
break;
default:
verify(false);
}
if( (lval&cHASMORE) == 0 )
break;
}
return true;
}
示例3: dassert
KeyV1Owned::KeyV1Owned(const KeyV1& rhs) {
b.appendBuf( rhs.data(), rhs.dataSize() );
_keyData = (const unsigned char *) b.buf();
dassert( b.len() == dataSize() ); // check datasize method is correct
dassert( (*_keyData & cNOTUSED) == 0 );
}