本文整理汇总了C++中EncodingImpl类的典型用法代码示例。如果您正苦于以下问题:C++ EncodingImpl类的具体用法?C++ EncodingImpl怎么用?C++ EncodingImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EncodingImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Error
size_t
Exclude::wireEncode(EncodingImpl<TAG>& encoder) const
{
if (m_exclude.empty()) {
throw Error("Exclude filter cannot be empty");
}
size_t totalLength = 0;
// Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
// Any ::= ANY-TYPE TLV-LENGTH(=0)
for (const auto& item : m_exclude) {
if (item.second) {
totalLength += prependEmptyBlock(encoder, tlv::Any);
}
if (!item.first.empty() || !item.second) {
totalLength += item.first.wireEncode(encoder);
}
}
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::Exclude);
return totalLength;
}
示例2: prependNonNegativeIntegerBlock
size_t
Route::wireEncode(EncodingImpl<T>& block) const
{
size_t totalLength = 0;
// Absence of an ExpirationPeriod signifies non-expiration
if (!m_hasInfiniteExpirationPeriod) {
totalLength += prependNonNegativeIntegerBlock(block,
ndn::tlv::nfd::ExpirationPeriod,
m_expirationPeriod.count());
}
totalLength += prependNonNegativeIntegerBlock(block,
ndn::tlv::nfd::Flags,
m_flags);
totalLength += prependNonNegativeIntegerBlock(block,
ndn::tlv::nfd::Cost,
m_cost);
totalLength += prependNonNegativeIntegerBlock(block,
ndn::tlv::nfd::Origin,
m_origin);
totalLength += prependNonNegativeIntegerBlock(block,
ndn::tlv::nfd::FaceId,
m_faceId);
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(ndn::tlv::nfd::Route);
return totalLength;
}
示例3: prependEmptyBlock
size_t
Exclude::wireEncode(EncodingImpl<TAG>& encoder) const
{
if (m_entries.empty()) {
BOOST_THROW_EXCEPTION(Error("cannot encode empty Exclude selector"));
}
size_t totalLength = 0;
// Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (GenericNameComponent (Any)?)+
// Any ::= ANY-TYPE TLV-LENGTH(=0)
for (const Entry& entry : m_entries) {
if (entry.second) {
totalLength += prependEmptyBlock(encoder, tlv::Any);
}
if (!entry.first.isNegInf) {
totalLength += entry.first.component.wireEncode(encoder);
}
}
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::Exclude);
return totalLength;
}
示例4: wireEncode
size_t
wireEncode(EncodingImpl<T>& encoder) const
{
size_t totalLength = 0;
totalLength += prependNonNegativeIntegerBlock(encoder,
ndn::statusCollector::tlv::RX,
m_rx);
totalLength += prependNonNegativeIntegerBlock(encoder,
ndn::statusCollector::tlv::TX,
m_tx);
totalLength += prependNonNegativeIntegerBlock(encoder,
ndn::statusCollector::tlv::FaceId,
m_faceId);
totalLength += encoder.prependByteArrayBlock(ndn::statusCollector::tlv::LinkIp,
reinterpret_cast<const uint8_t*>(m_linkIp.c_str()), m_linkIp.size());
totalLength += encoder.prependByteArrayBlock(ndn::statusCollector::tlv::CurrentTime,
reinterpret_cast<const uint8_t*>(m_timestamp.c_str()), m_timestamp.size());
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(statusCollector::tlv::FaceStatus);
return totalLength;
}
示例5: prependNonNegativeIntegerBlock
size_t
FaceEventNotification::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Flags, m_flags);
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::LinkType, m_linkType);
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::FacePersistency, m_facePersistency);
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::FaceScope, m_faceScope);
totalLength += encoder.prependByteArrayBlock(tlv::nfd::LocalUri,
reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
totalLength += encoder.prependByteArrayBlock(tlv::nfd::Uri,
reinterpret_cast<const uint8_t*>(m_remoteUri.c_str()), m_remoteUri.size());
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::FaceId, m_faceId);
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::FaceEventKind, m_kind);
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::nfd::FaceEventNotification);
return totalLength;
}
示例6: Error
size_t
Exclude::wireEncode(EncodingImpl<T>& block) const
{
if (m_exclude.empty()) {
throw Error("Exclude filter cannot be empty");
}
size_t totalLength = 0;
// Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
// Any ::= ANY-TYPE TLV-LENGTH(=0)
for (Exclude::const_iterator i = m_exclude.begin(); i != m_exclude.end(); i++)
{
if (i->second)
{
totalLength += prependBooleanBlock(block, tlv::Any);
}
if (!i->first.empty())
{
totalLength += i->first.wireEncode(block);
}
}
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(tlv::Exclude);
return totalLength;
}
示例7: switch
size_t
KeyLocator::wireEncode(EncodingImpl<TAG>& encoder) const
{
// KeyLocator ::= KEY-LOCATOR-TYPE TLV-LENGTH (Name | KeyDigest)
// KeyDigest ::= KEY-DIGEST-TYPE TLV-LENGTH BYTE+
size_t totalLength = 0;
switch (m_type) {
case KeyLocator_None:
break;
case KeyLocator_Name:
totalLength += m_name.wireEncode(encoder);
break;
case KeyLocator_KeyDigest:
totalLength += encoder.prependBlock(m_keyDigest);
break;
default:
NDN_THROW(Error("Unsupported KeyLocator type " + to_string(m_type)));
}
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::KeyLocator);
return totalLength;
}
示例8: Error
size_t
DefaultParam::wireEncode(EncodingImpl<T>& block) const
{
size_t totalLength = 0;
switch (m_originType) {
case TYPE_ID:
case TYPE_KEY:
case TYPE_CERT:
{
totalLength += m_originName.wireEncode(block);
break;
}
case TYPE_USER:
break;
default:
throw Error("DefaultParam::wireEncode: unsupported PibType: " +
boost::lexical_cast<std::string>(m_originType));
}
totalLength += prependNonNegativeIntegerBlock(block, tlv::pib::Type, m_originType);
totalLength += prependNonNegativeIntegerBlock(block, tlv::pib::Type, m_targetType);
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(tlv::pib::DefaultParam);
return totalLength;
}
示例9: prependNonNegativeIntegerBlock
size_t
Interest::wireEncode(EncodingImpl<TAG>& block) const
{
size_t totalLength = 0;
// Interest ::= INTEREST-TYPE TLV-LENGTH
// Name
// Selectors?
// Nonce
// Scope?
// InterestLifetime?
// Link?
// SelectedDelegation?
// (reverse encoding)
if (hasLink()) {
if (hasSelectedDelegation()) {
totalLength += prependNonNegativeIntegerBlock(block,
tlv::SelectedDelegation,
m_selectedDelegationIndex);
}
totalLength += prependBlock(block, m_link);
}
else {
BOOST_ASSERT(!hasSelectedDelegation());
}
// InterestLifetime
if (getInterestLifetime() >= time::milliseconds::zero() &&
getInterestLifetime() != DEFAULT_INTEREST_LIFETIME)
{
totalLength += prependNonNegativeIntegerBlock(block,
tlv::InterestLifetime,
getInterestLifetime().count());
}
// Scope
if (getScope() >= 0)
{
totalLength += prependNonNegativeIntegerBlock(block, tlv::Scope, getScope());
}
// Nonce
getNonce(); // to ensure that Nonce is properly set
totalLength += block.prependBlock(m_nonce);
// Selectors
if (hasSelectors())
{
totalLength += getSelectors().wireEncode(block);
}
// Name
totalLength += getName().wireEncode(block);
totalLength += block.prependVarNumber(totalLength);
totalLength += block.prependVarNumber(tlv::Interest);
return totalLength;
}
示例10: prependNonNegativeIntegerBlock
size_t
Interest::encode03(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
// Encode as NDN Packet Format v0.3
// Interest ::= INTEREST-TYPE TLV-LENGTH
// Name
// CanBePrefix?
// MustBeFresh?
// ForwardingHint?
// Nonce?
// InterestLifetime?
// HopLimit?
// ApplicationParameters?
// (reverse encoding)
// ApplicationParameters
if (hasApplicationParameters()) {
totalLength += encoder.prependBlock(getApplicationParameters());
}
// HopLimit: not yet supported
// InterestLifetime
if (getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) {
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::InterestLifetime,
static_cast<uint64_t>(getInterestLifetime().count()));
}
// Nonce
uint32_t nonce = getNonce(); // if nonce was unset, getNonce generates a random nonce
totalLength += encoder.prependByteArrayBlock(tlv::Nonce, reinterpret_cast<uint8_t*>(&nonce), sizeof(nonce));
// ForwardingHint
if (!getForwardingHint().empty()) {
totalLength += getForwardingHint().wireEncode(encoder);
}
// MustBeFresh
if (getMustBeFresh()) {
totalLength += prependEmptyBlock(encoder, tlv::MustBeFresh);
}
// CanBePrefix
if (getCanBePrefix()) {
totalLength += prependEmptyBlock(encoder, tlv::CanBePrefix);
}
// Name
totalLength += getName().wireEncode(encoder);
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::Interest);
return totalLength;
}
示例11: prependNonNegativeIntegerBlock
size_t
NackHeader::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t length = 0;
length += prependNonNegativeIntegerBlock(encoder, tlv::NackReason,
static_cast<uint32_t>(m_reason));
length += encoder.prependVarNumber(length);
length += encoder.prependVarNumber(tlv::Nack);
return length;
}
示例12:
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;
}
示例13: prependNestedBlock
size_t
StrategyChoice::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
totalLength += prependNestedBlock(encoder, tlv::nfd::Strategy, m_strategy);
totalLength += m_name.wireEncode(encoder);
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::nfd::StrategyChoice);
return totalLength;
}
示例14: prependNestedBlock
inline size_t
prependNestedBlock(EncodingImpl<TAG>& encoder, uint32_t type, const U& value)
{
BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<U>));
size_t valueLength = value.wireEncode(encoder);
size_t totalLength = valueLength;
totalLength += encoder.prependVarNumber(valueLength);
totalLength += encoder.prependVarNumber(type);
return totalLength;
}
示例15: prependStringBlock
size_t
ValidityPeriod::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
totalLength += prependStringBlock(encoder, tlv::NotAfter, time::toIsoString(m_notAfter));
totalLength += prependStringBlock(encoder, tlv::NotBefore, time::toIsoString(m_notBefore));
totalLength += encoder.prependVarNumber(totalLength);
totalLength += encoder.prependVarNumber(tlv::ValidityPeriod);
return totalLength;
}