本文整理汇总了C++中SharedBuffer::getSomeData方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedBuffer::getSomeData方法的具体用法?C++ SharedBuffer::getSomeData怎么用?C++ SharedBuffer::getSomeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedBuffer
的用法示例。
在下文中一共展示了SharedBuffer::getSomeData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyFromSharedBuffer
static unsigned copyFromSharedBuffer(char* buffer, unsigned bufferLength, const SharedBuffer& sharedBuffer, unsigned offset)
{
unsigned bytesExtracted = 0;
const char* moreData;
while (unsigned moreDataLength = sharedBuffer.getSomeData(moreData, offset)) {
unsigned bytesToCopy = std::min(bufferLength - bytesExtracted, moreDataLength);
memcpy(buffer + bytesExtracted, moreData, bytesToCopy);
bytesExtracted += bytesToCopy;
if (bytesExtracted == bufferLength)
break;
offset += bytesToCopy;
}
return bytesExtracted;
}
示例2: decode
bool decode(const SharedBuffer& data, bool sizeOnly)
{
m_decodingSizeOnly = sizeOnly;
// We need to do the setjmp here. Otherwise bad things will happen.
if (setjmp(JMPBUF(m_png)))
return m_decoder->setFailed();
const char* segment;
while (unsigned segmentLength = data.getSomeData(segment, m_readOffset)) {
m_readOffset += segmentLength;
m_currentBufferSize = m_readOffset;
png_process_data(m_png, m_info, reinterpret_cast<png_bytep>(const_cast<char*>(segment)), segmentLength);
if (sizeOnly ? m_decoder->isDecodedSizeAvailable() : m_decoder->frameIsCompleteAtIndex(0))
return true;
}
return false;
}
示例3: decode
bool decode(const SharedBuffer& data, bool sizeOnly)
{
m_decodingSizeOnly = sizeOnly;
PNGImageDecoder* decoder = static_cast<PNGImageDecoder*>(png_get_progressive_ptr(m_png));
// We need to do the setjmp here. Otherwise bad things will happen.
if (setjmp(JMPBUF(m_png)))
return decoder->setFailed();
const char* segment;
while (unsigned segmentLength = data.getSomeData(segment, m_readOffset)) {
m_readOffset += segmentLength;
m_currentBufferSize = m_readOffset;
png_process_data(m_png, m_info, reinterpret_cast<png_bytep>(const_cast<char*>(segment)), segmentLength);
// We explicitly specify the superclass isSizeAvailable() because we
// merely want to check if we've managed to set the size, not
// (recursively) trigger additional decoding if we haven't.
if (sizeOnly ? decoder->ImageDecoder::isSizeAvailable() : decoder->isComplete())
return true;
}
return false;
}