当前位置: 首页>>代码示例>>C++>>正文


C++ EncodingImpl::prependByteArray方法代码示例

本文整理汇总了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;
}
开发者ID:named-data,项目名称:ndn-cxx,代码行数:10,代码来源:name-component.cpp

示例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;
}
开发者ID:cawka,项目名称:ndn-cxx,代码行数:44,代码来源:interest.cpp

示例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;
}
开发者ID:WeiqiJust,项目名称:NDN-total,代码行数:43,代码来源:nfd-control-parameters.cpp

示例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;
}
开发者ID:named-data,项目名称:Consumer-Producer-API,代码行数:38,代码来源:manifest.cpp


注:本文中的EncodingImpl::prependByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。