encoding: Fixing Block (and as a result Name) encoding bugs
As of this commit, all non-const operations on Block will call resetWire
to remove all references to the wire, so it will be recreated next time
"encode" method is called. Also, all getter methods now have only const
versions and non-const access to the internal data structure is
prohibited.
Change-Id: If4b485dd62541d9d4d168a44490068e4deff56c1
diff --git a/src/interest.cpp b/src/interest.cpp
index da3cab6..99e5040 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -134,7 +134,7 @@
(booleanBlock(Tlv::MustBeFresh));
}
- if (!selectors.getAll().empty())
+ if (!selectors.elements().empty())
{
selectors.encode();
wire_.push_back(selectors);
@@ -180,64 +180,64 @@
name_.wireDecode(wire_.get(Tlv::Name));
// Selectors
- Block::element_iterator selectors = wire_.find(Tlv::Selectors);
- if (selectors != wire_.getAll().end())
+ Block::element_const_iterator selectors = wire_.find(Tlv::Selectors);
+ if (selectors != wire_.elements_end())
{
selectors->parse();
// MinSuffixComponents
- Block::element_iterator val = selectors->find(Tlv::MinSuffixComponents);
- if (val != selectors->getAll().end())
+ Block::element_const_iterator val = selectors->find(Tlv::MinSuffixComponents);
+ if (val != selectors->elements_end())
{
minSuffixComponents_ = readNonNegativeInteger(*val);
}
// MaxSuffixComponents
val = selectors->find(Tlv::MaxSuffixComponents);
- if (val != selectors->getAll().end())
+ if (val != selectors->elements_end())
{
maxSuffixComponents_ = readNonNegativeInteger(*val);
}
// Exclude
val = selectors->find(Tlv::Exclude);
- if (val != selectors->getAll().end())
+ if (val != selectors->elements_end())
{
exclude_.wireDecode(*val);
}
// ChildSelector
val = selectors->find(Tlv::ChildSelector);
- if (val != selectors->getAll().end())
+ if (val != selectors->elements_end())
{
childSelector_ = readNonNegativeInteger(*val);
}
//MustBeFresh aka AnswerOriginKind
val = selectors->find(Tlv::MustBeFresh);
- if (val != selectors->getAll().end())
+ if (val != selectors->elements_end())
{
mustBeFresh_ = true;
}
}
// Nonce
- Block::element_iterator val = wire_.find(Tlv::Nonce);
- if (val != wire_.getAll().end())
+ Block::element_const_iterator val = wire_.find(Tlv::Nonce);
+ if (val != wire_.elements_end())
{
nonce_ = readNonNegativeInteger(*val);
}
// Scope
val = wire_.find(Tlv::Scope);
- if (val != wire_.getAll().end())
+ if (val != wire_.elements_end())
{
scope_ = readNonNegativeInteger(*val);
}
// InterestLifetime
val = wire_.find(Tlv::InterestLifetime);
- if (val != wire_.getAll().end())
+ if (val != wire_.elements_end())
{
interestLifetime_ = readNonNegativeInteger(*val);
}