本文整理汇总了C++中EncodingImpl::prependByteArray方法的典型用法代码示例。如果您正苦于以下问题:C++ EncodingImpl::prependByteArray方法的具体用法?C++ EncodingImpl::prependByteArray怎么用?C++ EncodingImpl::prependByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EncodingImpl
的用法示例。
在下文中一共展示了EncodingImpl::prependByteArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
size_t
Component::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
if (value_size() > 0)
totalLength += encoder.prependByteArray(value(), value_size());
totalLength += encoder.prependVarNumber(value_size());
totalLength += encoder.prependVarNumber(type());
return totalLength;
}
示例2: prependNonNegativeIntegerBlock
size_t
Interest::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
// Interest ::= INTEREST-TYPE TLV-LENGTH
// Name
// Selectors?
// Nonce
// InterestLifetime?
// ForwardingHint?
// (reverse encoding)
// ForwardingHint
if (m_forwardingHint.size() > 0) {
totalLength += m_forwardingHint.wireEncode(encoder);
}
// InterestLifetime
if (getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) {
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::InterestLifetime,
getInterestLifetime().count());
}
// Nonce
uint32_t nonce = this->getNonce(); // assigns random Nonce if needed
totalLength += encoder.prependByteArray(reinterpret_cast<uint8_t*>(&nonce), sizeof(nonce));
totalLength += encoder.prependVarNumber(sizeof(nonce));
totalLength += encoder.prependVarNumber(tlv::Nonce);
// Selectors
if (hasSelectors()) {
totalLength += getSelectors().wireEncode(encoder);
}
// Name
totalLength += getName().wireEncode(encoder);
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::Interest);
return totalLength;
}
示例3: prependNonNegativeIntegerBlock
size_t
ControlParameters::wireEncode(EncodingImpl<T>& encoder) const
{
size_t totalLength = 0;
if (this->hasExpirationPeriod()) {
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::ExpirationPeriod, m_expirationPeriod.count());
}
if (this->hasStrategy()) {
totalLength += prependNestedBlock(encoder, tlv::nfd::Strategy, m_strategy);
}
if (this->hasFlags()) {
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Flags, m_flags);
}
if (this->hasCost()) {
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Cost, m_cost);
}
if (this->hasOrigin()) {
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Origin, m_origin);
}
if (this->hasLocalControlFeature()) {
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::LocalControlFeature, m_localControlFeature);
}
if (this->hasUri()) {
size_t valLength = encoder.prependByteArray(
reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
totalLength += valLength;
totalLength += encoder.prependVarNumber(valLength);
totalLength += encoder.prependVarNumber(tlv::nfd::Uri);
}
if (this->hasFaceId()) {
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceId, m_faceId);
}
if (this->hasName()) {
totalLength += m_name.wireEncode(encoder);
}
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::nfd::ControlParameters);
return totalLength;
}
示例4: prependBlock
size_t
Manifest::wireEncode(EncodingImpl<T>& blk) const
{
// Manifest ::= CONTENT-TLV TLV-LENGTH
// Catalogue?
// Name*
// KeyValuePair*
size_t totalLength = 0;
size_t catalogueLength = 0;
for (std::map<std::string, std::string>::const_reverse_iterator it = m_keyValuePairs.rbegin();
it != m_keyValuePairs.rend(); ++it)
{
std::string keyValue = it->first + "=" + it->second;
totalLength += blk.prependByteArray(reinterpret_cast<const uint8_t*>(keyValue.c_str()), keyValue.size());
totalLength += blk.prependVarNumber(keyValue.size());
totalLength += blk.prependVarNumber(tlv::KeyValuePair);
}
for (std::list<Name>::const_reverse_iterator it = m_catalogueNames.rbegin();
it != m_catalogueNames.rend(); ++it)
{
size_t blockSize = prependBlock(blk, it->wireEncode());
totalLength += blockSize;
catalogueLength += blockSize;
}
if (catalogueLength > 0)
{
totalLength += blk.prependVarNumber(catalogueLength);
totalLength += blk.prependVarNumber(tlv::ManifestCatalogue);
}
//totalLength += blk.prependVarNumber(totalLength);
//totalLength += blk.prependVarNumber(tlv::Content);
return totalLength;
}