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::upCast(keyData); }
53 
54  NameLite&
55  getKeyName() { return NameLite::upCast(keyName); }
56 
57  const NameLite&
58  getKeyName() const { return NameLite::upCast(keyName); }
59 
60  ndn_KeyNameType
61  getKeyNameType() const { return keyNameType; }
62 
69  ndn_Error
71  {
72  return NameLite::upCast(this->keyName).set(keyName);
73  }
74 
75  void
76  setType(ndn_KeyLocatorType type) { this->type = type; }
77 
82  void
84  {
85  BlobLite::upCast(this->keyData) = keyData;
86  }
87 
88  void
89  setKeyNameType(ndn_KeyNameType keyNameType) { this->keyNameType = keyNameType; }
90 
97  ndn_Error
98  set(const KeyLocatorLite& other);
99 
105  static KeyLocatorLite&
106  upCast(ndn_KeyLocator& keyLocator) { return *(KeyLocatorLite*)&keyLocator; }
107 
108  static const KeyLocatorLite&
109  upCast(const ndn_KeyLocator& keyLocator) { return *(KeyLocatorLite*)&keyLocator; }
110 
111 private:
118  KeyLocatorLite(const KeyLocatorLite& other);
119 
125  KeyLocatorLite& operator=(const KeyLocatorLite& other);
126 };
127 
128 }
129 
130 #endif
Copyright (C) 2013-2015 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:53
static KeyLocatorLite & upCast(ndn_KeyLocator &keyLocator)
Upcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:106
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:34
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:52
static BlobLite & upCast(ndn_Blob &blob)
Upcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:69
A KeyLocatorLite holds a type and other info to represent the key which signs a Data packet...
Definition: key-locator-lite.hpp:34
ndn_KeyNameType keyNameType
The type of data for keyName, -1 for none.
Definition: key-types.h:64
ndn_Error set(const NameLite &other)
Set this name to have the values from the other name.
Definition: name-lite.cpp:181
An ndn_KeyLocator holds the type of key locator and related data.
Definition: key-types.h:51
Copyright (C) 2015 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:83
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:70
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:62
static NameLite & upCast(ndn_Name &name)
Upcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:377