本文整理汇总了C++中framework::CStream类的典型用法代码示例。如果您正苦于以下问题:C++ CStream类的具体用法?C++ CStream怎么用?C++ CStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Seek
uint32 CIoman::Seek(uint32 handle, uint32 position, uint32 whence)
{
CLog::GetInstance().Print(LOG_NAME, "Seek(handle = %d, position = 0x%X, whence = %d);\r\n",
handle, position, whence);
uint32 result = 0xFFFFFFFF;
try
{
Framework::CStream* stream = GetFileStream(handle);
switch(whence)
{
case SEEK_DIR_SET:
whence = Framework::STREAM_SEEK_SET;
break;
case SEEK_DIR_CUR:
whence = Framework::STREAM_SEEK_CUR;
break;
case SEEK_DIR_END:
whence = Framework::STREAM_SEEK_END;
break;
}
stream->Seek(position, static_cast<Framework::STREAM_SEEK_DIRECTION>(whence));
result = static_cast<uint32>(stream->Tell());
}
catch(const std::exception& except)
{
CLog::GetInstance().Print(LOG_NAME, "%s: Error occured while trying to seek file : %s\r\n", __FUNCTION__, except.what());
}
return result;
}
示例2: WriteString
void CDialog::WriteString(const std::wstring& str, Framework::CStream& stream)
{
for(wchar_t character : str)
{
stream.Write16(character);
}
stream.Write16(0);
}
示例3: Read
void CPwibSection::Read(Framework::CStream& inputStream)
{
uint32 signature = inputStream.Read32();
assert(signature == 'BIWP');
uint32 fileSize = inputStream.Read32_MSBF();
uint32 unknown = inputStream.Read32_MSBF();
m_dataOffset = inputStream.Read32_MSBF();
auto child = CSectionLoader::ReadSection(shared_from_this(), inputStream);
}
示例4: Read
void CStreamChunk::Read(Framework::CStream& inputStream)
{
CBaseChunk::Read(inputStream);
m_numElements = inputStream.Read32_MSBF();
m_vertexCount = inputStream.Read32_MSBF();
m_bytesPerVertex = inputStream.Read32_MSBF();
m_unknown1 = inputStream.Read32_MSBF();
ReadElements(inputStream);
ReadStream(inputStream);
}
示例5: ReadString
std::wstring CDialog::ReadString(Framework::CStream& stream)
{
std::wstring str;
wchar_t ch = stream.Read16();
while(ch)
{
str += ch;
ch = stream.Read16();
}
return str;
}
示例6: LoadChildren
void CContainerChunk::LoadChildren(Framework::CStream& inputStream)
{
for(uint32 i = 0; i < m_childrenCount; i++)
{
uint64 baseOffset = inputStream.Tell();
auto chunk = CChunkLoader::Load(shared_from_this(), inputStream);
AddChild(chunk);
uint64 nextOffset = baseOffset + chunk->GetNextChunkOffset();
inputStream.Seek(nextOffset, Framework::STREAM_SEEK_SET);
}
}
示例7: Read
void CContainerChunk::Read(Framework::CStream& inputStream)
{
CBaseChunk::Read(inputStream);
m_childrenCount = inputStream.Read32_MSBF();
m_unknown1 = inputStream.Read32_MSBF();
m_unknown2 = inputStream.Read32_MSBF();
m_unknown3 = inputStream.Read32_MSBF();
LoadChildren(inputStream);
}
示例8: WriteSzOrOrd
void CDialog::WriteSzOrOrd(const SZ_OR_ORD& szOrOrd, Framework::CStream& stream)
{
stream.Write16(szOrOrd.isString);
if(szOrOrd.isString == 0xFFFF)
{
stream.Write16(szOrOrd.ord);
}
else if(szOrOrd.isString != 0)
{
WriteString(szOrOrd.str, stream);
}
}
示例9: ExtractCompressed
void CPatchFile::ExtractCompressed(Framework::CStream& outputStream, Framework::CStream& inputStream, uint32 compressedSize)
{
z_stream zStream;
zStream.zalloc = Z_NULL;
zStream.zfree = Z_NULL;
zStream.opaque = Z_NULL;
zStream.avail_in = 0;
zStream.next_in = Z_NULL;
if(inflateInit(&zStream) != Z_OK)
{
throw std::runtime_error("zlib stream initialization error.");
}
const uint32 bufferSize = 0x4000;
uint8 inBuffer[bufferSize];
uint8 outBuffer[bufferSize];
while(1)
{
if(zStream.avail_in == 0)
{
if(compressedSize == 0)
{
//EOF
break;
}
uint32 toRead = std::min<uint32>(bufferSize, compressedSize);
inputStream.Read(inBuffer, toRead);
compressedSize -= toRead;
zStream.avail_in = toRead;
zStream.next_in = inBuffer;
}
zStream.avail_out = bufferSize;
zStream.next_out = outBuffer;
int ret = inflate(&zStream, Z_NO_FLUSH);
if(ret < 0)
{
throw std::runtime_error("Error occured while inflating.");
break;
}
int have = bufferSize - zStream.avail_out;
outputStream.Write(outBuffer, have);
if(ret == Z_STREAM_END)
{
break;
}
}
inflateEnd(&zStream);
}
示例10: ExtractUncompressed
void CPatchFile::ExtractUncompressed(Framework::CStream& outputStream, Framework::CStream& inputStream, uint32 compressedSize)
{
const uint32 bufferSize = 0x4000;
uint8 buffer[bufferSize];
while(compressedSize != 0)
{
uint32 toRead = std::min<uint32>(bufferSize, compressedSize);
inputStream.Read(buffer, toRead);
outputStream.Write(buffer, toRead);
compressedSize -= toRead;
}
}
示例11: Read
void CDdsImage::Read(Framework::CStream& inputStream)
{
uint32 signature = inputStream.Read32();
if(signature != ' SDD')
{
assert(0);
throw std::runtime_error("Invalid DDS image (Invalid signature).");
}
inputStream.Read(&m_header, sizeof(DDS_HEADER));
if(m_header.size != sizeof(DDS_HEADER))
{
assert(0);
throw std::runtime_error("Invalid DDS image (Invalid header size).");
}
if(m_header.ddspf.size != sizeof(DDS_PIXELFORMAT))
{
assert(0);
throw std::runtime_error("Invalid DDS image (Invalid header size).");
}
const uint32 mandatoryFlags = DDS_HEADER_FLAG_CAPS | DDS_HEADER_FLAG_HEIGHT | DDS_HEADER_FLAG_WIDTH | DDS_HEADER_FLAG_PIXELFORMAT;
if((m_header.flags & mandatoryFlags) != mandatoryFlags)
{
assert(0);
throw std::runtime_error("Invalid DDS image (Missing flags).");
}
assert((m_header.ddspf.flags & (DDS_PIXELFORMAT_FLAG_RGB | DDS_PIXELFORMAT_FLAG_ALPHAPIXELS)) != 0);
uint32 surfaceSize = (m_header.ddspf.rgbBitCount / 8) * m_header.width * m_header.height;
if(m_header.caps2 & DDS_HEADER_CAP2_CUBEMAP)
{
const uint32 fullCubeMapFlags =
DDS_HEADER_CAP2_CUBEMAP_POSITIVE_X | DDS_HEADER_CAP2_CUBEMAP_NEGATIVE_X |
DDS_HEADER_CAP2_CUBEMAP_POSITIVE_Y | DDS_HEADER_CAP2_CUBEMAP_NEGATIVE_Y |
DDS_HEADER_CAP2_CUBEMAP_POSITIVE_Z | DDS_HEADER_CAP2_CUBEMAP_NEGATIVE_Z;
assert((m_header.caps2 & fullCubeMapFlags) == fullCubeMapFlags);
for(unsigned int i = 0; i < 6; i++)
{
SurfaceByteArray surface(surfaceSize);
inputStream.Read(surface.data(), surfaceSize);
m_surfaces.push_back(std::move(surface));
}
}
}
示例12: ReadSzOrOrd
CDialog::SZ_OR_ORD CDialog::ReadSzOrOrd(Framework::CStream& stream)
{
SZ_OR_ORD szOrOrd;
szOrOrd.ord = 0;
szOrOrd.isString = stream.Read16();
if(szOrOrd.isString == 0xFFFF)
{
szOrOrd.ord = stream.Read16();
}
else if(szOrOrd.isString != 0)
{
szOrOrd.str = ReadString(stream);
}
return szOrOrd;
}
示例13: Read
uint32 CIoman::Read(uint32 handle, uint32 size, void* buffer)
{
CLog::GetInstance().Print(LOG_NAME, "Read(handle = %d, size = 0x%X, buffer = ptr);\r\n", handle, size);
uint32 result = 0xFFFFFFFF;
try
{
Framework::CStream* stream = GetFileStream(handle);
result = static_cast<uint32>(stream->Read(buffer, size));
}
catch(const std::exception& except)
{
CLog::GetInstance().Print(LOG_NAME, "%s: Error occured while trying to read file : %s\r\n", __FUNCTION__, except.what());
}
return result;
}
示例14: Read
void CTextureSection::Read(Framework::CStream& inputStream)
{
CBaseSection::Read(inputStream);
inputStream.Read(m_header, sizeof(m_header));
auto gtex = std::make_shared<CGtexData>();
AddChild(gtex);
gtex->Read(inputStream);
}
示例15: Read
void CBoundingBoxChunk::Read(Framework::CStream& inputStream)
{
CBaseChunk::Read(inputStream);
uint32 minXInt = inputStream.Read32_MSBF();
uint32 minYInt = inputStream.Read32_MSBF();
uint32 minZInt = inputStream.Read32_MSBF();
uint32 maxXInt = inputStream.Read32_MSBF();
uint32 maxYInt = inputStream.Read32_MSBF();
uint32 maxZInt = inputStream.Read32_MSBF();
m_minX = *reinterpret_cast<float*>(&minXInt);
m_minY = *reinterpret_cast<float*>(&minYInt);
m_minZ = *reinterpret_cast<float*>(&minZInt);
m_maxX = *reinterpret_cast<float*>(&maxXInt);
m_maxY = *reinterpret_cast<float*>(&maxYInt);
m_maxZ = *reinterpret_cast<float*>(&maxZInt);
}