key-locator-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_KEY_LOCATOR_LITE_HPP
23 #define NDN_KEY_LOCATOR_LITE_HPP
24 
25 #include "name-lite.hpp"
26 #include "../c/key-types.h"
27 
28 namespace ndn {
29 
34 class KeyLocatorLite : private ndn_KeyLocator {
35 public:
46  KeyLocatorLite(ndn_NameComponent* keyNameComponents, size_t maxKeyNameComponents);
47 
48  ndn_KeyLocatorType
49  getType() const { return type; }
50 
51  const BlobLite&
52  getKeyData() const { return BlobLite::downCast(keyData); }
53 
54  NameLite&
55  getKeyName() { return NameLite::downCast(keyName); }
56 
57  const NameLite&
58  getKeyName() const { return NameLite::downCast(keyName); }
59 
66  ndn_Error
68  {
69  return NameLite::downCast(this->keyName).set(keyName);
70  }
71 
72  void
73  setType(ndn_KeyLocatorType type) { this->type = type; }
74 
79  void
81  {
82  BlobLite::downCast(this->keyData) = keyData;
83  }
84 
91  ndn_Error
92  set(const KeyLocatorLite& other);
93 
99  static KeyLocatorLite&
100  downCast(ndn_KeyLocator& keyLocator) { return *(KeyLocatorLite*)&keyLocator; }
101 
102  static const KeyLocatorLite&
103  downCast(const ndn_KeyLocator& keyLocator) { return *(KeyLocatorLite*)&keyLocator; }
104 
105 private:
111  KeyLocatorLite(const KeyLocatorLite& other);
112 
118  KeyLocatorLite& operator=(const KeyLocatorLite& other);
119 };
120 
121 }
122 
123 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
struct ndn_Blob keyData
A Blob whose value is a pointer to a pre-allocated buffer for the key data as follows: If type is ndn...
Definition: key-types.h:40
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:34
static KeyLocatorLite & downCast(ndn_KeyLocator &keyLocator)
Downcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:100
KeyLocatorLite(ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents)
Create a KeyLocatorLite with the pre-allocated nameComponents, and defaults for all the values...
Definition: key-locator-lite.cpp:28
ndn_Error set(const KeyLocatorLite &other)
Set this key locator to have the values from the other key locator.
Definition: key-locator-lite.cpp:34
ndn_KeyLocatorType type
-1 for none
Definition: key-types.h:39
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:76
A KeyLocatorLite holds a type and other info to represent the key which signs a Data packet...
Definition: key-locator-lite.hpp:34
ndn_Error set(const NameLite &other)
Set this name to have the values from the other name.
Definition: name-lite.cpp:216
An ndn_KeyLocator holds the type of key locator and related data.
Definition: key-types.h:38
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33
void setKeyData(const BlobLite &keyData)
Set the key data.
Definition: key-locator-lite.hpp:80
ndn_Error setKeyName(const NameLite &keyName)
Set this object's key name to have the values from the given keyName.
Definition: key-locator-lite.hpp:67
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
struct ndn_Name keyName
The key name (only used if type is ndn_KeyLocatorType_KEYNAME.)
Definition: key-types.h:43
static NameLite & downCast(ndn_Name &name)
Downcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:429