Browse Source

Implement get(struct ndn_Interest &)

pull/1/head
Jeff Thompson 12 years ago
parent
commit
d9e278c333
  1. 26
      ndn-cpp/Interest.cpp
  2. 7
      ndn-cpp/Interest.hpp

26
ndn-cpp/Interest.cpp

@ -29,6 +29,32 @@ void Interest::set(struct ndn_Interest &interestStruct)
nonce_.insert
(nonce_.begin(), interestStruct.nonce, interestStruct.nonce + interestStruct.nonceLength);
}
void Interest::get(struct ndn_Interest &interestStruct)
{
name_.get(interestStruct.name);
interestStruct.maxSuffixComponents = maxSuffixComponents_;
interestStruct.minSuffixComponents = minSuffixComponents_;
interestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
if (publisherPublicKeyDigest_.size() > 0)
interestStruct.publisherPublicKeyDigest = &publisherPublicKeyDigest_[0];
else
interestStruct.publisherPublicKeyDigest = 0;
// TODO: implement exclude.
interestStruct.childSelector = childSelector_;
interestStruct.answerOriginKind = answerOriginKind_;
interestStruct.scope = scope_;
interestStruct.interestLifetime = interestLifetime_;
interestStruct.nonceLength = nonce_.size();
if (nonce_.size() > 0)
interestStruct.nonce = &nonce_[0];
else
interestStruct.nonce = 0;
}
}

7
ndn-cpp/Interest.hpp

@ -38,6 +38,13 @@ public:
{
decode(&input[0], input.size());
}
/**
* Set the interestStruct to point to the components in this interest, without copying any memory.
* WARNING: The resulting pointers in interestStruct are invalid after a further use of this object which could reallocate memory.
* @param interestStruct a C ndn_Interest struct where the name components array is already allocated.
*/
void get(struct ndn_Interest &interestStruct);
Name &getName() { return name_; }

Loading…
Cancel
Save