本文整理汇总了C++中sf::Archive::verifyAgainstArchiveSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Archive::verifyAgainstArchiveSize方法的具体用法?C++ Archive::verifyAgainstArchiveSize怎么用?C++ Archive::verifyAgainstArchiveSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Archive
的用法示例。
在下文中一共展示了Archive::verifyAgainstArchiveSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializeString
inline void serializeString(SF::Archive & ar, std::basic_string<C,T,A> & s)
{
if (ar.isRead())
{
boost::uint32_t count = 0;
ar & count;
SF::IStream &is = *ar.getIstream();
s.resize(0);
std::size_t minSerializedLength = sizeof(C);
if (ar.verifyAgainstArchiveSize(count*minSerializedLength))
{
if (count > s.capacity())
{
s.reserve(count);
}
}
boost::uint32_t charsRemaining = count;
const boost::uint32_t BufferSize = 512;
C buffer[BufferSize];
while (charsRemaining)
{
boost::uint32_t charsToRead = RCF_MIN(BufferSize, charsRemaining);
boost::uint32_t bytesToRead = charsToRead*sizeof(C);
RCF_VERIFY(
is.read( (char *) buffer, bytesToRead) == bytesToRead,
RCF::Exception(RCF::_SfError_ReadFailure()))
(bytesToRead)(BufferSize)(count);
s.append(buffer, charsToRead);
charsRemaining -= charsToRead;
}
}
else if (ar.isWrite())
{
boost::uint32_t count = static_cast<boost::uint32_t >(s.length());
ar & count;
ar.getOstream()->writeRaw(
(char *) s.c_str(),
count*sizeof(C));
}
}