Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP |
| 7 | #define NDN_PUBLISHERPUBLICKEYDIGEST_HPP |
| 8 | |
| 9 | #include <vector> |
| 10 | #include "c/PublisherPublicKeyDigest.h" |
| 11 | |
| 12 | namespace ndn { |
| 13 | |
| 14 | /** |
| 15 | * A PublisherPublicKeyDigest holds the publisher public key digest value, if any. |
| 16 | * We make a separate class since this is used by multiple other classes. |
| 17 | */ |
| 18 | class PublisherPublicKeyDigest { |
| 19 | public: |
| 20 | PublisherPublicKeyDigest() { |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Set the publisherPublicKeyDigestStruct to point to the entries in this PublisherPublicKeyDigest, without copying any memory. |
| 25 | * WARNING: The resulting pointers in publisherPublicKeyDigestStruct are invalid after a further use of this object which could reallocate memory. |
| 26 | * @param publisherPublicKeyDigestStruct a C ndn_PublisherPublicKeyDigest struct to receive the pointer |
| 27 | */ |
| 28 | void get(struct ndn_PublisherPublicKeyDigest &publisherPublicKeyDigestStruct) const |
| 29 | { |
| 30 | publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size(); |
| 31 | if (publisherPublicKeyDigest_.size() > 0) |
| 32 | publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)&publisherPublicKeyDigest_[0]; |
| 33 | else |
| 34 | publisherPublicKeyDigestStruct.publisherPublicKeyDigest = 0; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct. |
| 39 | * @param excludeStruct a C ndn_Exclude struct |
| 40 | */ |
Jeff Thompson | dd3d229 | 2013-07-10 11:59:44 -0700 | [diff] [blame^] | 41 | void set(const struct ndn_PublisherPublicKeyDigest &publisherPublicKeyDigestStruct) |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 42 | { |
| 43 | publisherPublicKeyDigest_.clear(); |
| 44 | if (publisherPublicKeyDigestStruct.publisherPublicKeyDigest) |
| 45 | publisherPublicKeyDigest_.insert |
| 46 | (publisherPublicKeyDigest_.begin(), publisherPublicKeyDigestStruct.publisherPublicKeyDigest, |
| 47 | publisherPublicKeyDigestStruct.publisherPublicKeyDigest + publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength); |
| 48 | } |
| 49 | |
| 50 | const std::vector<unsigned char> &getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; } |
| 51 | |
| 52 | private: |
| 53 | std::vector<unsigned char> publisherPublicKeyDigest_; |
| 54 | }; |
| 55 | |
| 56 | } |
| 57 | |
| 58 | #endif |