本文整理汇总了C++中trpgReadBuffer::TestLimit方法的典型用法代码示例。如果您正苦于以下问题:C++ trpgReadBuffer::TestLimit方法的具体用法?C++ trpgReadBuffer::TestLimit怎么用?C++ trpgReadBuffer::TestLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trpgReadBuffer
的用法示例。
在下文中一共展示了trpgReadBuffer::TestLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
bool trpgModel::Read(trpgReadBuffer &buf, bool hasHandle)
{
// MD: added complexity here - written multiple ways by
// mistake, unraveling the various cases.
char tmpName[1024];
try {
buf.Get(type);
// TerraPage 2.2 will store the unique handle after the type
// we use a different token, so this is backwards compatible.
if(hasHandle) {
int32 tempHandle;
if(buf.Get(tempHandle))
{
handle = tempHandle;
}
else
{
handle = -1;
}
}
else
handle = -1;
if (type == Local) {
// two possibilities:
// name, diskRef, useCount
// diskRef, useCount
// diskRef + useCount = 12 bytes...
if (buf.TestLimit(13))
{
buf.Get(tmpName,1023);
SetName(tmpName);
}
buf.Get(diskRef);
buf.Get(useCount);
}
else
{
// two possibilities:
// name, diskRef, useCount
// name, useCount
buf.Get(tmpName,1023);
SetName(tmpName);
// useCount = 4 bytes...
if (buf.TestLimit(5))
buf.Get(diskRef);
buf.Get(useCount);
}
}
catch(...) {
return false;
}
// going to make this fail if the buffer isn't empty.
if (buf.TestLimit(1)) return false;
return isValid();
}