blob: 6cdae60f4a085eb4d1a176da186dc6d2c3cd742c [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;
}
}
}