本文整理汇总了C++中DataStream::SetBytesUsed方法的典型用法代码示例。如果您正苦于以下问题:C++ DataStream::SetBytesUsed方法的具体用法?C++ DataStream::SetBytesUsed怎么用?C++ DataStream::SetBytesUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStream
的用法示例。
在下文中一共展示了DataStream::SetBytesUsed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadBytes
/// Reads x bytes into the file, continuing from previous location (or start if newly opened).
bool File::ReadBytes(DataStream & intoStream, int numBytes)
{
if (!this->IsOpen())
return false;
if (numBytes <= 0)
return false;
uchar * bytes = intoStream.GetData();
this->fileStream.read((char*)bytes, numBytes);
intoStream.SetBytesUsed(numBytes);
return true;
}
示例2: ReadAllBytes
bool File::ReadAllBytes(DataStream & intoStream)
{
if (!this->IsOpen())
return false;
/// Check required size.
int fileSize = FileSize();
/// Allocated stream to required size.
intoStream.Allocate(fileSize);
///
uchar * bytes = intoStream.GetData();
this->fileStream.read((char*)bytes, fileSize);
intoStream.SetBytesUsed(fileSize);
return true;
}