34 : m_container(nullptr)
41 , m_container(&container)
48 BOOST_ASSERT(m_container !=
nullptr);
49 return m_container->get(*m_it);
70 bool isThisEnd = m_container ==
nullptr || m_it == m_container->m_keyNames.end();
71 bool isOtherEnd = other.m_container ==
nullptr || other.m_it == other.m_container->m_keyNames.end();
72 return ((isThisEnd || isOtherEnd) ?
73 (isThisEnd == isOtherEnd) :
74 m_container->m_impl == other.m_container->m_impl && m_it == other.m_it);
80 return !(*
this == other);
83 KeyContainer::KeyContainer(
const Name& identity, shared_ptr<PibImpl> impl)
84 : m_identity(identity)
87 BOOST_ASSERT(impl !=
nullptr);
88 m_keyNames = impl->getKeysOfIdentity(identity);
112 return m_keyNames.size();
119 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` does not match identity "
120 "`" + m_identity.
toUri() +
"`"));
123 if (m_keyNames.count(keyName) == 0) {
124 m_keyNames.insert(keyName);
125 m_keys[keyName] = shared_ptr<detail::KeyImpl>(
new detail::KeyImpl(keyName, key, keyLen, m_impl));
135 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` does not match identity "
136 "`" + m_identity.
toUri() +
"`"));
139 m_keyNames.erase(keyName);
140 m_keys.erase(keyName);
141 m_impl->removeKey(keyName);
148 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` does not match identity "
149 "`" + m_identity.
toUri() +
"`"));
152 shared_ptr<detail::KeyImpl> key;
153 auto it = m_keys.find(keyName);
155 if (it != m_keys.end()) {
159 key = shared_ptr<detail::KeyImpl>(
new detail::KeyImpl(keyName, m_impl));
160 m_keys[keyName] = key;
169 return m_keyNames == m_impl->getKeysOfIdentity(m_identity);
const_iterator find(const Name &keyName) const
const_iterator begin() const
Copyright (c) 2013-2016 Regents of the University of California.
bool operator==(const const_iterator &other)
void remove(const Name &keyName)
Remove a key with keyName from the container.
bool isConsistent() const
Check if the container is consistent with the backend storage.
#define NDN_CXX_ASSERT_FORWARD_ITERATOR(T)
assert T is a forward iterator
bool operator!=(const const_iterator &other)
std::string toUri() const
Encode this name as a URI.
Container of keys of an identity.
A frontend handle of a key instance.
Key add(const uint8_t *key, size_t keyLen, const Name &keyName)
Add key of keyLen bytes with keyName into the container.
Name abstraction to represent an absolute name.
Key get(const Name &keyName) const
Get a key with keyName from the container.
const_iterator & operator++()
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
const_iterator end() const