blob: 7548968dae43f5a87d0cddf95a3826b2a8079322 [file] [log] [blame]
/**
* @author: Jeff Thompson
* See COPYING for copyright and distribution information.
*/
#include "common.hpp"
#include "key.hpp"
using namespace std;
namespace ndn {
void KeyLocator::get(struct ndn_KeyLocator &keyLocatorStruct) const
{
keyLocatorStruct.type = type_;
keyLocatorStruct.keyDataLength = keyData_.size();
if (keyData_.size() > 0)
keyLocatorStruct.keyData = (unsigned char *)&keyData_[0];
else
keyLocatorStruct.keyData = 0;
keyName_.get(keyLocatorStruct.keyName);
keyLocatorStruct.keyNameType = keyNameType_;
}
void KeyLocator::set(const struct ndn_KeyLocator &keyLocatorStruct)
{
type_ = keyLocatorStruct.type;
setVector(keyData_, keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength);
if (keyLocatorStruct.type == ndn_KeyLocatorType_KEYNAME) {
keyName_.set(keyLocatorStruct.keyName);
keyNameType_ = keyLocatorStruct.keyNameType;
}
else {
keyName_.clear();
keyNameType_ = (ndn_KeyNameType)-1;
}
}
}