本文整理汇总了C++中ConstBufferPtr::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstBufferPtr::begin方法的具体用法?C++ ConstBufferPtr::begin怎么用?C++ ConstBufferPtr::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstBufferPtr
的用法示例。
在下文中一共展示了ConstBufferPtr::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Block
bool
Block::fromBuffer(const ConstBufferPtr& wire, size_t offset, Block& block)
{
Buffer::const_iterator tempBegin = wire->begin() + offset;
uint32_t type;
bool isOk = Tlv::readType(tempBegin, wire->end(), type);
if (!isOk)
return false;
uint64_t length;
isOk = Tlv::readVarNumber(tempBegin, wire->end(), length);
if (!isOk)
return false;
if (length > static_cast<uint64_t>(wire->end() - tempBegin))
{
return false;
}
block = Block(wire, type,
wire->begin() + offset, tempBegin + length,
tempBegin, tempBegin + length);
return true;
}
示例2: make_tuple
std::tuple<bool, Block>
Block::fromBuffer(ConstBufferPtr buffer, size_t offset)
{
Buffer::const_iterator tempBegin = buffer->begin() + offset;
uint32_t type;
bool isOk = tlv::readType(tempBegin, buffer->end(), type);
if (!isOk)
return std::make_tuple(false, Block());
uint64_t length;
isOk = tlv::readVarNumber(tempBegin, buffer->end(), length);
if (!isOk)
return std::make_tuple(false, Block());
if (length > static_cast<uint64_t>(buffer->end() - tempBegin))
return std::make_tuple(false, Block());
return std::make_tuple(true, Block(buffer, type,
buffer->begin() + offset, tempBegin + length,
tempBegin, tempBegin + length));
}