本文整理汇总了C++中trpgReadBuffer::SkipToLimit方法的典型用法代码示例。如果您正苦于以下问题:C++ trpgReadBuffer::SkipToLimit方法的具体用法?C++ trpgReadBuffer::SkipToLimit怎么用?C++ trpgReadBuffer::SkipToLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trpgReadBuffer
的用法示例。
在下文中一共展示了trpgReadBuffer::SkipToLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
/* Parse Buffer
This runs through the given buffer parsing token sets until
it (1) runs out of buffer or (2) fails.
Note: Good place to return an exception, but keep it simple for now.
*/
bool trpgr_Parser::Parse(trpgReadBuffer &buf)
{
bool ret = true;
try
{
while (!buf.isEmpty())
{
/* We're expecting the following
Token (int32)
Length (int32)
Data (variable)
*/
trpgToken tok;
int32 len;
if (!buf.Get(tok)) throw 1;
// Push and Pop are special - no data
if (tok != TRPG_PUSH && tok != TRPG_POP)
{
if (!buf.Get(len)) throw 1;
if (!TokenIsValid(tok)) throw 1;
if (len < 0) throw 1;
// Limit what we're reading to the length of this
buf.PushLimit(len);
}
// Call our token handler for this one
try
{
const trpgr_Token *tcb = NULL;
tok_map::const_iterator p = tokenMap.find(tok);
if (p != tokenMap.end())
tcb = &(*p).second;
if (!tcb)
// No such token, call the default
tcb = &defCb;
// Run the callback
if (tcb->cb)
{
void *ret = tcb->cb->Parse(tok,buf);
// Note: Do something with the return value
lastObject = ret;
}
}
catch (...)
{
// Don't want to screw up the limit stack
}
// No limit to worry about with push and pop
if (tok != TRPG_PUSH && tok != TRPG_POP)
{
buf.SkipToLimit();
buf.PopLimit();
}
}
}
catch (...)
{
// Failed to parse.
ret = false;
}
return ret;
}