本文整理汇总了C++中block::element_const_iterator::value方法的典型用法代码示例。如果您正苦于以下问题:C++ element_const_iterator::value方法的具体用法?C++ element_const_iterator::value怎么用?C++ element_const_iterator::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block::element_const_iterator
的用法示例。
在下文中一共展示了element_const_iterator::value方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wireDecode
void
wireDecode(const Block& block)
{
if (block.type() != statusCollector::tlv::ScriptPacket)
{
std::stringstream error;
error << "Expected ScriptPacket block, but block is of different type: #" << block.type();
std::cerr << error.str() << std::endl;
}
m_block = block;
m_block.parse();
Block::element_const_iterator val = m_block.elements_begin();
Block::element_const_iterator oldVal;
while (val != m_block.elements_end())
{
oldVal = val;
if (val != m_block.elements_end() && val->type() == ndn::statusCollector::tlv::ScriptData)
{
m_data.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
++val;
}
if(oldVal == val)
{
std::cout << "ERROR!!: About to exit" << std::endl;
exit(1);
}
}
}
示例2: 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");
}
}
示例3: 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())
{
if (i->type() != tlv::NameComponent)
throw Error("Incorrect format of Exclude filter");
name::Component excludedComponent(i->value(), i->value_size());
++i;
if (i != m_wire.elements_end())
{
if (i->type() == tlv::Any)
{
appendExclude(excludedComponent, true);
++i;
}
else
{
appendExclude(excludedComponent, false);
}
}
else
{
appendExclude(excludedComponent, false);
}
}
}
示例4: 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);
}
示例5: 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);
}
}
}
示例6: Error
void
FaceEventNotification::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::FaceEventNotification) {
throw Error("expecting FaceEventNotification 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::FaceEventKind) {
m_kind = static_cast<FaceEventKind>(readNonNegativeInteger(*val));
++val;
}
else {
throw Error("missing required FaceEventKind field");
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
m_faceId = readNonNegativeInteger(*val);
++val;
}
else {
throw 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 {
throw 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 {
throw Error("missing required LocalUri field");
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
m_faceScope = static_cast<FaceScope>(readNonNegativeInteger(*val));
++val;
}
else {
throw 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 {
throw 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 {
throw Error("missing required LinkType field");
}
}
示例7: Error
void
ControlParameters::wireDecode(const Block& block)
{
if (block.type() != tlv::nfd::ControlParameters) {
throw Error("expecting TLV-TYPE ControlParameters");
}
m_wire = block;
m_wire.parse();
Block::element_const_iterator val;
val = m_wire.find(tlv::Name);
m_hasFields[CONTROL_PARAMETER_NAME] = val != m_wire.elements_end();
if (this->hasName()) {
m_name.wireDecode(*val);
}
val = m_wire.find(tlv::nfd::FaceId);
m_hasFields[CONTROL_PARAMETER_FACE_ID] = val != m_wire.elements_end();
if (this->hasFaceId()) {
m_faceId = static_cast<uint64_t>(readNonNegativeInteger(*val));
}
val = m_wire.find(tlv::nfd::Uri);
m_hasFields[CONTROL_PARAMETER_URI] = val != m_wire.elements_end();
if (this->hasUri()) {
m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
}
val = m_wire.find(tlv::nfd::LocalControlFeature);
m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = val != m_wire.elements_end();
if (this->hasLocalControlFeature()) {
m_localControlFeature = static_cast<LocalControlFeature>(readNonNegativeInteger(*val));
}
val = m_wire.find(tlv::nfd::Origin);
m_hasFields[CONTROL_PARAMETER_ORIGIN] = val != m_wire.elements_end();
if (this->hasOrigin()) {
m_origin = static_cast<uint64_t>(readNonNegativeInteger(*val));
}
val = m_wire.find(tlv::nfd::Cost);
m_hasFields[CONTROL_PARAMETER_COST] = val != m_wire.elements_end();
if (this->hasCost()) {
m_cost = static_cast<uint64_t>(readNonNegativeInteger(*val));
}
val = m_wire.find(tlv::nfd::Flags);
m_hasFields[CONTROL_PARAMETER_FLAGS] = val != m_wire.elements_end();
if (this->hasFlags()) {
m_flags = static_cast<uint64_t>(readNonNegativeInteger(*val));
}
val = m_wire.find(tlv::nfd::Strategy);
m_hasFields[CONTROL_PARAMETER_STRATEGY] = val != m_wire.elements_end();
if (this->hasStrategy()) {
val->parse();
if (val->elements().empty()) {
throw Error("expecting Strategy/Name");
}
else {
m_strategy.wireDecode(*val->elements_begin());
}
}
val = m_wire.find(tlv::nfd::ExpirationPeriod);
m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = val != m_wire.elements_end();
if (this->hasExpirationPeriod()) {
m_expirationPeriod = time::milliseconds(readNonNegativeInteger(*val));
}
}
示例8: 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"));
}
//.........这里部分代码省略.........
示例9: 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;
}
}