blob: 5ce4124a6898b1d7c40d32739edacde40836e3f2 [file] [log] [blame]
Jeff Thompson8238d002013-07-10 11:56:49 -07001/**
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
12namespace 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 */
18class PublisherPublicKeyDigest {
19public:
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 */
41 void set(struct ndn_PublisherPublicKeyDigest &publisherPublicKeyDigestStruct)
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
52private:
53 std::vector<unsigned char> publisherPublicKeyDigest_;
54};
55
56}
57
58#endif