• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ block::element_const_iterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中block::element_const_iterator的典型用法代码示例。如果您正苦于以下问题:C++ element_const_iterator类的具体用法?C++ element_const_iterator怎么用?C++ element_const_iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了element_const_iterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wireDecode

 void
 wireDecode(const Block& wire)
 {
   m_statusList.clear();
   
   if (!wire.hasWire())
     std::cerr << "The supplied block does not contain wire format" << std::endl;
   
   if (wire.type() != statusCollector::tlv::CollectorReply)
     std::cerr << "Unexpected TLV type when decoding CollectorReply: " +
       boost::lexical_cast<std::string>(wire.type()) <<std::endl;
   
   wire.parse();
   
   for (Block::element_const_iterator it = wire.elements_begin();
        it != wire.elements_end(); it++)
   {
     if (it->type() == statusCollector::tlv::FaceStatus)
     {
       m_statusList.push_back(FaceStatus(*it));
     }
     else
       std::cerr << "No FaceStatus entry when decoding CollectorReply!!" << std::endl;
   }
 }
开发者ID:WU-ARL,项目名称:ndnTestbedDataCollector,代码行数:25,代码来源:ndnTestbedDataCollector.hpp


示例2: parser

  void
  decodeFibEntryBlock(const Data& data)
  {
    Block payload = data.getContent();

    m_buffer.appendByteArray(payload.value(), payload.value_size());

    BOOST_CHECK_NO_THROW(data.getName()[-1].toSegment());
    if (data.getFinalBlockId() != data.getName()[-1])
      {
        return;
      }

    // wrap the FIB Entry blocks in a single Content TLV for easy parsing
    m_buffer.prependVarNumber(m_buffer.size());
    m_buffer.prependVarNumber(ndn::Tlv::Content);

    ndn::Block parser(m_buffer.buf(), m_buffer.size());
    parser.parse();

    BOOST_REQUIRE_EQUAL(parser.elements_size(), m_referenceEntries.size());

    for (Block::element_const_iterator i = parser.elements_begin();
         i != parser.elements_end();
         ++i)
      {
        if (i->type() != ndn::tlv::nfd::FibEntry)
          {
            BOOST_FAIL("expected fib entry, got type #" << i->type());
          }

        validateFibEntry(*i);
      }
    m_finished = true;
  }
开发者ID:PhilipsIII,项目名称:NFD,代码行数:35,代码来源:fib-enumeration-publisher-common.hpp


示例3: prefix

  void
  validateFibEntry(const Block& entry)
  {
    entry.parse();

    Block::element_const_iterator i = entry.elements_begin();
    BOOST_REQUIRE(i != entry.elements_end());


    BOOST_REQUIRE(i->type() == ndn::Tlv::Name);
    Name prefix(*i);
    ++i;

    std::set<shared_ptr<fib::Entry> >::const_iterator referenceIter =
      std::find_if(m_referenceEntries.begin(), m_referenceEntries.end(),
                   bind(&FibEnumerationPublisherFixture::entryHasPrefix,
                        this, _1, prefix));

    BOOST_REQUIRE(referenceIter != m_referenceEntries.end());

    const shared_ptr<fib::Entry>& reference = *referenceIter;
    BOOST_REQUIRE_EQUAL(prefix, reference->getPrefix());

    // 0 or more next hop records
    size_t nRecords = 0;
    const fib::NextHopList& referenceNextHops = reference->getNextHops();
    for (; i != entry.elements_end(); ++i)
      {
        const ndn::Block& nextHopRecord = *i;
        BOOST_REQUIRE(nextHopRecord.type() == ndn::tlv::nfd::NextHopRecord);
        nextHopRecord.parse();

        Block::element_const_iterator j = nextHopRecord.elements_begin();

        FaceId faceId =
          checkedReadNonNegativeIntegerType(j,
                                            entry.elements_end(),
                                            ndn::tlv::nfd::FaceId);

        uint64_t cost =
          checkedReadNonNegativeIntegerType(j,
                                            entry.elements_end(),
                                            ndn::tlv::nfd::Cost);

        BOOST_REQUIRE(hasNextHopWithCost(referenceNextHops, faceId, cost));

        BOOST_REQUIRE(j == nextHopRecord.elements_end());
        nRecords++;
      }
    BOOST_REQUIRE_EQUAL(nRecords, referenceNextHops.size());

    BOOST_REQUIRE(i == entry.elements_end());
    m_referenceEntries.erase(referenceIter);
  }
开发者ID:PhilipsIII,项目名称:NFD,代码行数:54,代码来源:fib-enumeration-publisher-common.hpp


示例4: Error

void
DefaultParam::wireDecode(const Block& wire)
{
  if (!wire.hasWire()) {
    throw Error("The supplied block does not contain wire format");
  }

  m_wire = wire;
  m_wire.parse();

  if (m_wire.type() != tlv::pib::DefaultParam)
    throw Error("Unexpected TLV type when decoding DefaultParam");

  Block::element_const_iterator it = m_wire.elements_begin();

  // the first block must be PibType
  if (it != m_wire.elements_end() && it->type() == tlv::pib::Type) {
    m_targetType = static_cast<pib::Type>(readNonNegativeInteger(*it));
    it++;
  }
  else
    throw Error("DefaultParam requires the first sub-TLV to be PibType");

  // the second block must be PibType
  if (it != m_wire.elements_end() && it->type() == tlv::pib::Type) {
    m_originType = static_cast<pib::Type>(readNonNegativeInteger(*it));
    it++;
  }
  else
    throw Error("DefaultParam requires the second sub-TLV to be PibType");

  switch (m_originType) {
  case TYPE_ID:
  case TYPE_KEY:
  case TYPE_CERT:
    {
      if (it != m_wire.elements_end()) {
        // the third block, if exists, must be Name
        m_originName.wireDecode(*it);
        return;
      }
      else {
        throw Error("DefaultParam requires the third sub-TLV to be Name");
      }
    }
  case TYPE_USER:
    return;
  default:
    throw Error("DefaultParam::wireDecode: unsupported PibType: " +
                boost::lexical_cast<std::string>(m_originType));
  }
}
开发者ID:CSUL,项目名称:ndn-tools,代码行数:52,代码来源:default-param.cpp


示例5: readNonNegativeInteger

void
MetaInfo::wireDecode(const Block& wire)
{
  m_wire = wire;
  m_wire.parse();

  // MetaInfo ::= META-INFO-TYPE TLV-LENGTH
  //                ContentType?
  //                FreshnessPeriod?
  //                FinalBlockId?
  //                AppMetaInfo*


  Block::element_const_iterator val = m_wire.elements_begin();

  // ContentType
  if (val != m_wire.elements_end() && val->type() == tlv::ContentType) {
    m_type = readNonNegativeInteger(*val);
    ++val;
  }
  else {
    m_type = TYPE_DEFAULT;
  }

  // FreshnessPeriod
  if (val != m_wire.elements_end() && val->type() == tlv::FreshnessPeriod) {
    m_freshnessPeriod = time::milliseconds(readNonNegativeInteger(*val));
    ++val;
  }
  else {
    m_freshnessPeriod = time::milliseconds::min();
  }

  // FinalBlockId
  if (val != m_wire.elements_end() && val->type() == tlv::FinalBlockId) {
    m_finalBlockId = val->blockFromValue();
    if (m_finalBlockId.type() != tlv::NameComponent)
      {
        /// @todo May or may not throw exception later...
        m_finalBlockId.reset();
      }
    ++val;
  }
  else {
    m_finalBlockId.reset();
  }

  // AppMetaInfo (if any)
  for (; val != m_wire.elements().end(); ++val) {
    m_appMetaInfo.push_back(*val);
  }
}
开发者ID:nnaren1902,项目名称:ndn-cxx,代码行数:52,代码来源:meta-info.cpp


示例6: Error

void
Exclude::wireDecode(const Block& wire)
{
  clear();

  if (wire.type() != tlv::Exclude)
    throw tlv::Error("Unexpected TLV type when decoding Exclude");

  m_wire = wire;
  m_wire.parse();

  if (m_wire.elements_size() == 0) {
    throw Error("Exclude element cannot be empty");
  }

  // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
  // Any     ::= ANY-TYPE TLV-LENGTH(=0)

  Block::element_const_iterator i = m_wire.elements_begin();
  if (i->type() == tlv::Any) {
    appendExclude(name::Component(), true);
    ++i;
  }

  while (i != m_wire.elements_end()) {
    name::Component excludedComponent;
    try {
      excludedComponent = std::move(name::Component(*i));
    }
    catch (const name::Component::Error&) {
      throw Error("Incorrect format of Exclude filter");
    }

    ++i;

    if (i != m_wire.elements_end()) {
      if (i->type() == tlv::Any) {
        appendExclude(excludedComponent, true);
        ++i;
      }
      else {
        appendExclude(excludedComponent, false);
      }
    }
    else {
      appendExclude(excludedComponent, false);
    }
  }
}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:49,代码来源:exclude.cpp


示例7: hubUri

void
MulticastDiscovery::onSuccess(Data& data)
{
  const Block& content = data.getContent();
  content.parse();

  // Get Uri
  Block::element_const_iterator blockValue = content.find(tlv::nfd::Uri);
  if (blockValue == content.elements_end()) {
    m_nextStageOnFailure("Incorrect reply to multicast discovery stage");
    return;
  }
  std::string hubUri(reinterpret_cast<const char*>(blockValue->value()), blockValue->value_size());
  this->connectToHub(hubUri);
}
开发者ID:MobinRanjbar,项目名称:NFD,代码行数:15,代码来源:multicast-discovery.cpp


示例8: clear

void
Exclude::wireDecode(const Block& wire)
{
  clear();

  if (wire.type() != tlv::Exclude)
    BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding Exclude"));

  m_wire = wire;
  m_wire.parse();

  if (m_wire.elements_size() == 0) {
    BOOST_THROW_EXCEPTION(Error("Exclude element cannot be empty"));
  }

  // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (GenericNameComponent (Any)?)+
  // Any     ::= ANY-TYPE TLV-LENGTH(=0)

  Block::element_const_iterator i = m_wire.elements_begin();
  if (i->type() == tlv::Any) {
    this->appendEntry(true, true);
    ++i;
  }

  while (i != m_wire.elements_end()) {
    name::Component component;
    try {
      component = name::Component(*i);
    }
    catch (const name::Component::Error&) {
      BOOST_THROW_EXCEPTION(Error("Incorrect format of Exclude filter"));
    }
    if (!component.isGeneric() && !component.isImplicitSha256Digest()) {
      BOOST_THROW_EXCEPTION(Error("Excluded component must be generic or ImplicitSha256Digest"));
    }
    ++i;

    if (i != m_wire.elements_end() && i->type() == tlv::Any) {
      this->appendEntry(component, true);
      ++i;
    }
    else {
      this->appendEntry(component, false);
    }
  }
}
开发者ID:cawka,项目名称:ndn-cxx,代码行数:46,代码来源:exclude.cpp


示例9: name

void
Manifest::decode()
{
    Block content = getContent();
    content.parse();

    // Manifest ::= CONTENT-TLV TLV-LENGTH
    //                Catalogue?
    //                  Name*
    //                KeyValuePair*

    for ( Block::element_const_iterator val = content.elements_begin();
            val != content.elements_end(); ++val)
    {
        if (val->type() == tlv::ManifestCatalogue)
        {
            val->parse();
            for ( Block::element_const_iterator catalogueNameElem = val->elements_begin();
                    catalogueNameElem != val->elements_end(); ++catalogueNameElem)
            {
                if (catalogueNameElem->type() == tlv::Name)
                {
                    Name name(*catalogueNameElem);
                    m_catalogueNames.push_back(name);
                }
            }
        }
        else if (val->type() == tlv::KeyValuePair)
        {
            std::string str((char*)val->value(), val->value_size());

            size_t index = str.find_first_of('=');
            if (index == std::string::npos || index == 0 || (index == str.size() - 1))
                continue;

            std::string key = str.substr(0, index);
            std::string value = str.substr(index + 1, str.size() - index - 1);
            addKeyValuePair(key, value);
        }
    }
}
开发者ID:named-data,项目名称:Consumer-Producer-API,代码行数:41,代码来源:manifest.cpp


示例10:

void
CachePolicy::wireDecode(const Block& wire)
{
  if (wire.type() != tlv::CachePolicy) {
    BOOST_THROW_EXCEPTION(Error("expecting CachePolicy block"));
  }

  m_wire = wire;
  m_wire.parse();

  Block::element_const_iterator it = m_wire.elements_begin();
  if (it != m_wire.elements_end() && it->type() == tlv::CachePolicyType) {
    m_policy = static_cast<CachePolicyType>(readNonNegativeInteger(*it));
    if (this->getPolicy() == CachePolicyType::NONE) {
      BOOST_THROW_EXCEPTION(Error("unknown CachePolicyType"));
    }
  }
  else {
    BOOST_THROW_EXCEPTION(Error("expecting CachePolicyType block"));
  }
}
开发者ID:cawka,项目名称:ndn-cxx,代码行数:21,代码来源:cache-policy.cpp


示例11: Error

void
EndorseExtension::wireDecode(const Block& endorseWire)
{
  m_wire = endorseWire;
  m_wire.parse();

  // EndorseExtension := ENDORSE-EXTENSION-TYPE TLV-LENGTH
  //                       EntryData+
  //
  // EntryData := ENTRYDATA-TYPE TLV-LENGTH
  //                String
  //

  if (m_wire.type() != tlv::EndorseExtension)
    throw Error("Unexpected TLV number when decoding endorse extension packet");

  // EntryData
  Block::element_const_iterator i = m_wire.elements_begin();
  if (i == m_wire.elements_end())
    throw Error("Missing Entry Data");
  if (i->type() != tlv::EntryData)
    throw Error("Expect Entry Data but get TLV Type " + std::to_string(i->type()));

   while (i != m_wire.elements_end() && i->type() == tlv::EntryData) {
     m_entries.push_back(std::string(reinterpret_cast<const char* >(i->value()),
                                     i->value_size()));
     ++i;
  }

  if (i != m_wire.elements_end()) {
    throw Error("Unexpected element");
  }
}
开发者ID:bruinfish,项目名称:ChronoChat,代码行数:33,代码来源:endorse-extension.cpp


示例12: Error

void
StrategyChoice::wireDecode(const Block& block)
{
    if (block.type() != tlv::nfd::StrategyChoice) {
        throw Error("expecting StrategyChoice block");
    }
    m_wire = block;
    m_wire.parse();
    Block::element_const_iterator val = m_wire.elements_begin();

    if (val != m_wire.elements_end() && val->type() == tlv::Name) {
        m_name.wireDecode(*val);
        ++val;
    }
    else {
        throw Error("missing required Name field");
    }

    if (val != m_wire.elements_end() && val->type() == tlv::nfd::Strategy) {
        val->parse();
        if (val->elements().empty()) {
            throw Error("expecting Strategy/Name");
        }
        else {
            m_strategy.wireDecode(*val->elements_begin());
        }
        ++val;
    }
    else {
        throw Error("missing required Strategy field");
    }
}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:32,代码来源:nfd-strategy-choice.cpp


示例13: if

void
FibEntry::wireDecode(const Block& wire)
{
  m_prefix.clear();
  m_nextHopRecords.clear();

  m_wire = wire;

  if (m_wire.type() != tlv::nfd::FibEntry) {
    std::stringstream error;
    error << "Requested decoding of FibEntry, but Block is of a different type: #"
          << m_wire.type();
    BOOST_THROW_EXCEPTION(Error(error.str()));
  }

  m_wire.parse();

  Block::element_const_iterator val = m_wire.elements_begin();
  if (val == m_wire.elements_end()) {
    BOOST_THROW_EXCEPTION(Error("Unexpected end of FibEntry"));
  }
  else if (val->type() != tlv::Name) {
    std::stringstream error;
    error << "Expected Name, but Block is of a different type: #"
          << val->type();
    BOOST_THROW_EXCEPTION(Error(error.str()));
  }
  m_prefix.wireDecode(*val);
  ++val;

  for (; val != m_wire.elements_end(); ++val) {
    if (val->type() != tlv::nfd::NextHopRecord) {
      std::stringstream error;
      error << "Expected NextHopRecords, but Block is of a different type: #"
            << val->type();
      BOOST_THROW_EXCEPTION(Error(error.str()));
    }
    m_nextHopRecords.push_back(NextHopRecord(*val));
  }
}
开发者ID:2nd-ndn-hackathon,项目名称:ndn-cxx-logging,代码行数:40,代码来源:nfd-fib-entry.cpp


示例14: Error

void
RibEntry::wireDecode(const Block& wire)
{
  m_prefix.clear();
  m_routes.clear();

  m_wire = wire;

  if (m_wire.type() != tlv::nfd::RibEntry) {
    std::stringstream error;
    error << "Expected RibEntry Block, but Block is of a different type: #"
          << m_wire.type();
    throw Error(error.str());
  }

  m_wire.parse();

  Block::element_const_iterator val = m_wire.elements_begin();

  if (val != m_wire.elements_end() && val->type() == tlv::Name) {
    m_prefix.wireDecode(*val);
    ++val;
  }
  else {
    throw Error("Missing required Name field");
  }

  for (; val != m_wire.elements_end(); ++val) {

    if (val->type() == tlv::nfd::Route) {
      m_routes.push_back(Route(*val));
    }
    else {
      std::stringstream error;
      error << "Expected Route Block, but Block is of a different type: #"
            << m_wire.type();
      throw Error(error.str());
    }
  }
}
开发者ID:WeiqiJust,项目名称:NDN-total,代码行数:40,代码来源:nfd-rib-entry.cpp


示例15:

void
NackHeader::wireDecode(const Block& wire)
{
  if (wire.type() != tlv::Nack) {
    BOOST_THROW_EXCEPTION(ndn::tlv::Error("expecting Nack block"));
  }

  m_wire = wire;
  m_wire.parse();
  m_reason = NackReason::NONE;

  if (m_wire.elements_size() > 0) {
    Block::element_const_iterator it = m_wire.elements_begin();

    if (it->type() == tlv::NackReason) {
      m_reason = static_cast<NackReason>(readNonNegativeInteger(*it));
    }
    else {
      BOOST_THROW_EXCEPTION(ndn::tlv::Error("expecting NackReason block"));
    }
  }
}
开发者ID:2nd-ndn-hackathon,项目名称:ndn-cxx-logging,代码行数:22,代码来源:nack-header.cpp


示例16: parser

  static void
  decodeRibEntryBlock(const Data& data, const Name& referenceName, const FaceEntry& referenceFace)
  {
    ndn::EncodingBuffer buffer;

    Block payload = data.getContent();

    buffer.appendByteArray(payload.value(), payload.value_size());
    buffer.prependVarNumber(buffer.size());
    buffer.prependVarNumber(ndn::Tlv::Content);

    ndn::Block parser(buffer.buf(), buffer.size());
    parser.parse();

    Block::element_const_iterator i = parser.elements_begin();

    if (i->type() != ndn::tlv::nfd::RibEntry) {
      BOOST_FAIL("expected RibEntry, got type #" << i->type());
    }
    else {
      validateRibEntry(*i, referenceName, referenceFace);
    }
  }
开发者ID:PhilipsIII,项目名称:NFD,代码行数:23,代码来源:rib-status-publisher-common.hpp


示例17: parser

  void
  decodeFaceStatusBlock(const Data& data)
  {
    Block payload = data.getContent();

    m_buffer.appendByteArray(payload.value(), payload.value_size());

    BOOST_CHECK_NO_THROW(data.getName()[-1].toSegment());
    if (data.getFinalBlockId() != data.getName()[-1])
      {
        return;
      }

    // wrap the Face Statuses in a single Content TLV for easy parsing
    m_buffer.prependVarNumber(m_buffer.size());
    m_buffer.prependVarNumber(tlv::Content);

    ndn::Block parser(m_buffer.buf(), m_buffer.size());
    parser.parse();

    BOOST_REQUIRE_EQUAL(parser.elements_size(), m_referenceFaces.size());

    std::list<shared_ptr<Face> >::const_iterator iReference = m_referenceFaces.begin();
    for (Block::element_const_iterator i = parser.elements_begin();
         i != parser.elements_end();
         ++i)
      {
        if (i->type() != ndn::tlv::nfd::FaceStatus)
          {
            BOOST_FAIL("expected face status, got type #" << i->type());
          }
        validateFaceStatus(*i, *iReference);
        ++iReference;
      }
    m_finished = true;
  }
开发者ID:AaronTien,项目名称:NFD,代码行数:36,代码来源:face-status-publisher-common.hpp


示例18: readNonNegativeInteger

void
FaceQueryFilter::wireDecode(const Block& block)
{
  //all fields are optional
  if (block.type() != tlv::nfd::FaceQueryFilter) {
    BOOST_THROW_EXCEPTION(Error("expecting FaceQueryFilter block"));
  }

  m_wire = block;
  m_wire.parse();
  Block::element_const_iterator val = m_wire.elements_begin();

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
    m_faceId = readNonNegativeInteger(*val);
    m_hasFaceId = true;
    ++val;
  }
  else {
    m_hasFaceId = false;
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::UriScheme) {
    m_uriScheme.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
    m_hasUriScheme = true;
    ++val;
  }
  else {
    m_hasUriScheme = false;
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
    m_remoteUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
    m_hasRemoteUri = true;
    ++val;
  }
  else {
    m_hasRemoteUri = false;
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
    m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
    m_hasLocalUri = true;
    ++val;
  }
  else {
    m_hasLocalUri = false;
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
    m_faceScope = static_cast<FaceScope>(readNonNegativeInteger(*val));
    m_hasFaceScope = true;
    ++val;
  }
  else {
    m_hasFaceScope = false;
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
    m_facePersistency = static_cast<FacePersistency>(readNonNegativeInteger(*val));
    m_hasFacePersistency = true;
    ++val;
  }
  else {
    m_hasFacePersistency = false;
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
    m_linkType = static_cast<LinkType>(readNonNegativeInteger(*val));
    m_hasLinkType = true;
    ++val;
  }
  else {
    m_hasLinkType = false;
  }

}
开发者ID:named-data-ndnSIM,项目名称:ndn-cxx,代码行数:76,代码来源:face-query-filter.cpp


示例19: readNonNegativeInteger

void
FaceStatus::wireDecode(const Block& block)
{
  if (block.type() != tlv::nfd::FaceStatus) {
    BOOST_THROW_EXCEPTION(Error("expecting FaceStatus block"));
  }
  m_wire = block;
  m_wire.parse();
  Block::element_const_iterator val = m_wire.elements_begin();

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
    m_faceId = readNonNegativeInteger(*val);
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required FaceId field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
    m_remoteUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required Uri field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
    m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required LocalUri field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::ExpirationPeriod) {
    m_expirationPeriod = time::milliseconds(readNonNegativeInteger(*val));
    m_hasExpirationPeriod = true;
    ++val;
  }
  else {
    m_hasExpirationPeriod = false;
    // ExpirationPeriod is optional
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
    m_faceScope = static_cast<FaceScope>(readNonNegativeInteger(*val));
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required FaceScope field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
    m_facePersistency = static_cast<FacePersistency>(readNonNegativeInteger(*val));
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required FacePersistency field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
    m_linkType = static_cast<LinkType>(readNonNegativeInteger(*val));
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required LinkType field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
    m_nInInterests = readNonNegativeInteger(*val);
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required NInInterests field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInDatas) {
    m_nInDatas = readNonNegativeInteger(*val);
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required NInDatas field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInNacks) {
    m_nInNacks = readNonNegativeInteger(*val);
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required NInNacks field"));
  }

  if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutInterests) {
    m_nOutInterests = readNonNegativeInteger(*val);
    ++val;
  }
  else {
    BOOST_THROW_EXCEPTION(Error("missing required NOutInterests field"));
  }

//.........这里部分代码省略.........
开发者ID:named-data-ndnSIM,项目名称:ndn-cxx,代码行数:101,代码来源:face-status.cpp


示例20: while

void
Schedule::wireDecode(const Block& wire)
{
  if (wire.type() != tlv::Schedule)
    BOOST_THROW_EXCEPTION(tlv::Error("Unexpected TLV type when decoding RepetitiveInterval"));

  m_wire = wire;
  m_wire.parse();

  if (m_wire.elements_size() != 2)
    BOOST_THROW_EXCEPTION(tlv::Error("RepetitiveInterval tlv does not have two sub-TLVs"));

  Block::element_const_iterator it = m_wire.elements_begin();

  if (it != m_wire.elements_end() && it->type() == tlv::WhiteIntervalList) {
    it->parse();
    Block::element_const_iterator tempIt = it->elements_begin();
    while (tempIt != it->elements_end() && tempIt->type() == tlv::RepetitiveInterval) {
      m_whiteIntervalList.insert(RepetitiveInterval(*tempIt));
      tempIt++;
    }
    it++;
  }

  if (it != m_wire.elements_end() && it->type() == tlv::BlackIntervalList) {
    it->parse();
    Block::element_const_iterator tempIt = it->elements_begin();
    while (tempIt != it->elements_end() && tempIt->type() == tlv::RepetitiveInterval) {
      m_blackIntervalList.insert(RepetitiveInterval(*tempIt));
      tempIt++;
    }
    it++;
  }
}
开发者ID:BarryChang,项目名称:ndn-group-based-encryption,代码行数:34,代码来源:schedule.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ blockdataregion::referenced_vars_iterator类代码示例发布时间:2022-05-31
下一篇:
C++ block::BlockPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap