util: remove ndn::optional, use std::optional directly

Change-Id: I503e8f250e80e0ff7708070effc2e84e3b38b3b7
This commit is contained in:
Davide Pesavento committed 2023-03-13 15:12:06 -04:00
1 parent a2fbc35f12
commit f6b458930f
64 files changed
+301 -2175

No files matched your search

-3
View File
@@ -9,9 +9,6 @@ ndn-cxx relies on third-party software, licensed under the following licenses:
- OpenSSL is licensed under the - OpenSSL is licensed under the
[Apache License 2.0](https://www.openssl.org/source/license.html) [Apache License 2.0](https://www.openssl.org/source/license.html)
- optional-lite by Martin Moene is licensed under the
[Boost Software License 1.0](https://github.com/martinmoene/optional-lite/blob/master/LICENSE.txt)
- scope-lite by Martin Moene is licensed under the - scope-lite by Martin Moene is licensed under the
[Boost Software License 1.0](https://github.com/martinmoene/scope-lite/blob/master/LICENSE.txt) [Boost Software License 1.0](https://github.com/martinmoene/scope-lite/blob/master/LICENSE.txt)
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -351,7 +351,7 @@ Data::setFreshnessPeriod(time::milliseconds freshnessPeriod)
} }
Data& Data&
Data::setFinalBlock(optional<name::Component> finalBlockId) Data::setFinalBlock(std::optional<name::Component> finalBlockId)
{ {
if (finalBlockId != m_metaInfo.getFinalBlock()) { if (finalBlockId != m_metaInfo.getFinalBlock()) {
m_metaInfo.setFinalBlock(std::move(finalBlockId)); m_metaInfo.setFinalBlock(std::move(finalBlockId));
+8 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -299,14 +299,14 @@ public: // MetaInfo fields
Data& Data&
setFreshnessPeriod(time::milliseconds freshnessPeriod); setFreshnessPeriod(time::milliseconds freshnessPeriod);
const optional<name::Component>& const std::optional<name::Component>&
getFinalBlock() const getFinalBlock() const
{ {
return m_metaInfo.getFinalBlock(); return m_metaInfo.getFinalBlock();
} }
Data& Data&
setFinalBlock(optional<name::Component> finalBlockId); setFinalBlock(std::optional<name::Component> finalBlockId);
public: // SignatureInfo fields public: // SignatureInfo fields
/** /**
@@ -322,10 +322,13 @@ public: // SignatureInfo fields
/** /**
* @brief Get the `KeyLocator` element. * @brief Get the `KeyLocator` element.
*/ */
optional<KeyLocator> std::optional<KeyLocator>
getKeyLocator() const noexcept getKeyLocator() const noexcept
{ {
return m_signatureInfo.hasKeyLocator() ? make_optional(m_signatureInfo.getKeyLocator()) : nullopt; if (m_signatureInfo.hasKeyLocator()) {
return m_signatureInfo.getKeyLocator();
}
return std::nullopt;
} }
protected: protected:
-1
View File
@@ -54,7 +54,6 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <iosfwd> #include <iosfwd>
#include <limits>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
File diff suppressed because it is too large. Load diff
+4 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -22,7 +22,9 @@
#ifndef NDN_CXX_ENCODING_NFD_CONSTANTS_HPP #ifndef NDN_CXX_ENCODING_NFD_CONSTANTS_HPP
#define NDN_CXX_ENCODING_NFD_CONSTANTS_HPP #define NDN_CXX_ENCODING_NFD_CONSTANTS_HPP
#include "ndn-cxx/detail/common.hpp" #include <cstdint>
#include <iosfwd>
#include <limits>
namespace ndn { namespace ndn {
namespace nfd { namespace nfd {
+14 -13
View File
@@ -26,6 +26,7 @@
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
#include <limits>
#include <ostream> #include <ostream>
#include <vector> #include <vector>
@@ -168,10 +169,10 @@ isCriticalType(uint32_t type) noexcept
* @brief Read VAR-NUMBER in NDN-TLV encoding. * @brief Read VAR-NUMBER in NDN-TLV encoding.
* @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type
* *
* @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after
* the read VAR-NUMBER * the read VAR-NUMBER
* @param [in] end End of the buffer * @param[in] end End of the buffer
* @param [out] number Read VAR-NUMBER * @param[out] number Read VAR-NUMBER
* *
* @return true if number was successfully read from input, false otherwise * @return true if number was successfully read from input, false otherwise
*/ */
@@ -183,10 +184,10 @@ readVarNumber(Iterator& begin, Iterator end, uint64_t& number) noexcept;
* @brief Read TLV-TYPE. * @brief Read TLV-TYPE.
* @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type
* *
* @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after
* the read TLV-TYPE * the read TLV-TYPE
* @param [in] end End of the buffer * @param[in] end End of the buffer
* @param [out] type Read TLV-TYPE * @param[out] type Read TLV-TYPE
* *
* @return true if TLV-TYPE was successfully read from input, false otherwise * @return true if TLV-TYPE was successfully read from input, false otherwise
* @note This function is largely equivalent to readVarNumber(), except that it returns false if * @note This function is largely equivalent to readVarNumber(), except that it returns false if
@@ -200,9 +201,9 @@ readType(Iterator& begin, Iterator end, uint32_t& type) noexcept;
* @brief Read VAR-NUMBER in NDN-TLV encoding. * @brief Read VAR-NUMBER in NDN-TLV encoding.
* @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type
* *
* @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after
* the read VAR-NUMBER * the read VAR-NUMBER
* @param [in] end End of the buffer * @param[in] end End of the buffer
* *
* @throw tlv::Error VAR-NUMBER cannot be read * @throw tlv::Error VAR-NUMBER cannot be read
*/ */
@@ -214,9 +215,9 @@ readVarNumber(Iterator& begin, Iterator end);
* @brief Read TLV-TYPE. * @brief Read TLV-TYPE.
* @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type
* *
* @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after
* the read TLV-TYPE * the read TLV-TYPE
* @param [in] end End of the buffer * @param[in] end End of the buffer
* *
* @throw tlv::Error TLV-TYPE cannot be read * @throw tlv::Error TLV-TYPE cannot be read
* @note This function is largely equivalent to readVarNumber(), except that it throws if * @note This function is largely equivalent to readVarNumber(), except that it throws if
@@ -243,10 +244,10 @@ writeVarNumber(std::ostream& os, uint64_t number);
* @brief Read a NonNegativeInteger in NDN-TLV encoding. * @brief Read a NonNegativeInteger in NDN-TLV encoding.
* @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type * @tparam Iterator an iterator or pointer that dereferences to uint8_t or compatible type
* *
* @param [in] size size of the NonNegativeInteger * @param[in] size size of the NonNegativeInteger
* @param [inout] begin Begin of the buffer, will be incremented to point to the first byte after * @param[in,out] begin Begin of the buffer, will be incremented to point to the first byte after
* the read NonNegativeInteger * the read NonNegativeInteger
* @param [in] end End of the buffer * @param[in] end End of the buffer
* *
* @throw tlv::Error number cannot be read * @throw tlv::Error number cannot be read
* @note How many bytes to read is directly controlled by \p size, which can be either 1, 2, 4, or 8. * @note How many bytes to read is directly controlled by \p size, which can be either 1, 2, 4, or 8.
+2 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -23,7 +23,6 @@
#include "ndn-cxx/encoding/tlv.hpp" #include "ndn-cxx/encoding/tlv.hpp"
#include "ndn-cxx/impl/face-impl.hpp" #include "ndn-cxx/impl/face-impl.hpp"
#include "ndn-cxx/net/face-uri.hpp" #include "ndn-cxx/net/face-uri.hpp"
#include "ndn-cxx/security/signing-helpers.hpp"
#include "ndn-cxx/util/config-file.hpp" #include "ndn-cxx/util/config-file.hpp"
#include "ndn-cxx/util/scope.hpp" #include "ndn-cxx/util/scope.hpp"
#include "ndn-cxx/util/time.hpp" #include "ndn-cxx/util/time.hpp"
@@ -252,7 +251,7 @@ Face::registerPrefix(const Name& prefix,
nfd::CommandOptions options; nfd::CommandOptions options;
options.setSigningInfo(signingInfo); options.setSigningInfo(signingInfo);
auto id = m_impl->registerPrefix(prefix, onSuccess, onFailure, flags, options, nullopt, nullptr); auto id = m_impl->registerPrefix(prefix, onSuccess, onFailure, flags, options, std::nullopt, nullptr);
return RegisteredPrefixHandle(m_impl, id); return RegisteredPrefixHandle(m_impl, id);
} }
+3 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -30,7 +30,9 @@
// STL headers to precompile // STL headers to precompile
#include <atomic> #include <atomic>
#include <iterator> #include <iterator>
#include <limits>
#include <list> #include <list>
#include <optional>
#include <ostream> #include <ostream>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
+8 -6
View File
@@ -154,17 +154,17 @@ public: // consumer
/** /**
* @return A Nack to be sent to the forwarder, or nullopt if no Nack should be sent. * @return A Nack to be sent to the forwarder, or nullopt if no Nack should be sent.
*/ */
optional<lp::Nack> std::optional<lp::Nack>
nackPendingInterests(const lp::Nack& nack) nackPendingInterests(const lp::Nack& nack)
{ {
optional<lp::Nack> outNack; std::optional<lp::Nack> outNack;
m_pendingInterestTable.removeIf([&] (PendingInterest& entry) { m_pendingInterestTable.removeIf([&] (PendingInterest& entry) {
if (!nack.getInterest().matchesInterest(*entry.getInterest())) { if (!nack.getInterest().matchesInterest(*entry.getInterest())) {
return false; return false;
} }
NDN_LOG_DEBUG(" nacking " << *entry.getInterest() << " from " << entry.getOrigin()); NDN_LOG_DEBUG(" nacking " << *entry.getInterest() << " from " << entry.getOrigin());
optional<lp::Nack> outNack1 = entry.recordNack(nack); auto outNack1 = entry.recordNack(nack);
if (!outNack1) { if (!outNack1) {
return false; return false;
} }
@@ -234,7 +234,7 @@ public: // producer
putNack(const lp::Nack& nack) putNack(const lp::Nack& nack)
{ {
NDN_LOG_DEBUG("<N " << nack.getInterest() << '~' << nack.getHeader().getReason()); NDN_LOG_DEBUG("<N " << nack.getInterest() << '~' << nack.getHeader().getReason());
optional<lp::Nack> outNack = nackPendingInterests(nack); auto outNack = nackPendingInterests(nack);
if (!outNack) { if (!outNack) {
return; return;
} }
@@ -255,8 +255,10 @@ public: // prefix registration
registerPrefix(const Name& prefix, registerPrefix(const Name& prefix,
const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixSuccessCallback& onSuccess,
const RegisterPrefixFailureCallback& onFailure, const RegisterPrefixFailureCallback& onFailure,
uint64_t flags, const nfd::CommandOptions& options, uint64_t flags,
const optional<InterestFilter>& filter, const InterestCallback& onInterest) const nfd::CommandOptions& options,
const std::optional<InterestFilter>& filter,
const InterestCallback& onInterest)
{ {
NDN_LOG_INFO("registering prefix: " << prefix); NDN_LOG_INFO("registering prefix: " << prefix);
auto id = m_registeredPrefixTable.allocateId(); auto id = m_registeredPrefixTable.allocateId();
+4 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -114,7 +114,7 @@ public:
* @return Least severe Nack if all destinations where the Interest was forwarded have Nacked; * @return Least severe Nack if all destinations where the Interest was forwarded have Nacked;
* otherwise, @c nullopt. * otherwise, @c nullopt.
*/ */
optional<lp::Nack> std::optional<lp::Nack>
recordNack(const lp::Nack& nack) recordNack(const lp::Nack& nack)
{ {
--m_nNotNacked; --m_nNotNacked;
@@ -124,7 +124,7 @@ public:
m_leastSevereNack = nack; m_leastSevereNack = nack;
} }
return m_nNotNacked > 0 ? nullopt : m_leastSevereNack; return m_nNotNacked > 0 ? std::nullopt : m_leastSevereNack;
} }
/** /**
@@ -180,7 +180,7 @@ private:
TimeoutCallback m_timeoutCallback; TimeoutCallback m_timeoutCallback;
scheduler::ScopedEventId m_timeoutEvent; scheduler::ScopedEventId m_timeoutEvent;
int m_nNotNacked = 0; ///< number of Interest destinations that have not Nacked int m_nNotNacked = 0; ///< number of Interest destinations that have not Nacked
optional<lp::Nack> m_leastSevereNack; std::optional<lp::Nack> m_leastSevereNack;
}; };
} // namespace ndn } // namespace ndn
+2 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -25,6 +25,7 @@
#include "ndn-cxx/ims/in-memory-storage-entry.hpp" #include "ndn-cxx/ims/in-memory-storage-entry.hpp"
#include <iterator> #include <iterator>
#include <limits>
#include <stack> #include <stack>
#include <boost/multi_index_container.hpp> #include <boost/multi_index_container.hpp>
+5 -5
View File
@@ -411,7 +411,7 @@ Interest::getNonce() const
} }
Interest& Interest&
Interest::setNonce(optional<Interest::Nonce> nonce) Interest::setNonce(std::optional<Interest::Nonce> nonce)
{ {
if (nonce != m_nonce) { if (nonce != m_nonce) {
m_nonce = nonce; m_nonce = nonce;
@@ -448,7 +448,7 @@ Interest::setInterestLifetime(time::milliseconds lifetime)
} }
Interest& Interest&
Interest::setHopLimit(optional<uint8_t> hopLimit) Interest::setHopLimit(std::optional<uint8_t> hopLimit)
{ {
if (hopLimit != m_hopLimit) { if (hopLimit != m_hopLimit) {
m_hopLimit = hopLimit; m_hopLimit = hopLimit;
@@ -527,14 +527,14 @@ Interest::isSigned() const noexcept
m_name[-1].type() == tlv::ParametersSha256DigestComponent; m_name[-1].type() == tlv::ParametersSha256DigestComponent;
} }
optional<SignatureInfo> std::optional<SignatureInfo>
Interest::getSignatureInfo() const Interest::getSignatureInfo() const
{ {
auto blockIt = findFirstParameter(tlv::InterestSignatureInfo); auto blockIt = findFirstParameter(tlv::InterestSignatureInfo);
if (blockIt != m_parameters.end()) { if (blockIt != m_parameters.end()) {
return make_optional<SignatureInfo>(*blockIt, SignatureInfo::Type::Interest); return std::make_optional<SignatureInfo>(*blockIt, SignatureInfo::Type::Interest);
} }
return nullopt; return std::nullopt;
} }
Interest& Interest&
+6 -6
View File
@@ -256,7 +256,7 @@ public: // element access
* Use `setNonce(nullopt)` to remove any nonce from the Interest. * Use `setNonce(nullopt)` to remove any nonce from the Interest.
*/ */
Interest& Interest&
setNonce(optional<Nonce> nonce); setNonce(std::optional<Nonce> nonce);
/** /**
* @brief Change nonce value. * @brief Change nonce value.
@@ -286,7 +286,7 @@ public: // element access
/** /**
* @brief Get the %Interest's hop limit. * @brief Get the %Interest's hop limit.
*/ */
optional<uint8_t> std::optional<uint8_t>
getHopLimit() const noexcept getHopLimit() const noexcept
{ {
return m_hopLimit; return m_hopLimit;
@@ -298,7 +298,7 @@ public: // element access
* Use `setHopLimit(nullopt)` to remove any hop limit from the Interest. * Use `setHopLimit(nullopt)` to remove any hop limit from the Interest.
*/ */
Interest& Interest&
setHopLimit(optional<uint8_t> hopLimit); setHopLimit(std::optional<uint8_t> hopLimit);
/** /**
* @brief Return whether this Interest has any `ApplicationParameters` element. * @brief Return whether this Interest has any `ApplicationParameters` element.
@@ -388,7 +388,7 @@ public: // element access
* @brief Get the `InterestSignatureInfo` element. * @brief Get the `InterestSignatureInfo` element.
* @retval nullopt The element is not present. * @retval nullopt The element is not present.
*/ */
optional<SignatureInfo> std::optional<SignatureInfo>
getSignatureInfo() const; getSignatureInfo() const;
/** /**
@@ -494,9 +494,9 @@ private:
Name m_name; Name m_name;
std::vector<Name> m_forwardingHint; std::vector<Name> m_forwardingHint;
mutable optional<Nonce> m_nonce; mutable std::optional<Nonce> m_nonce;
time::milliseconds m_interestLifetime = DEFAULT_INTEREST_LIFETIME; time::milliseconds m_interestLifetime = DEFAULT_INTEREST_LIFETIME;
optional<uint8_t> m_hopLimit; std::optional<uint8_t> m_hopLimit;
bool m_canBePrefix = false; bool m_canBePrefix = false;
bool m_mustBeFresh = false; bool m_mustBeFresh = false;
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2019 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -35,7 +35,7 @@ PrefixAnnouncementHeader::PrefixAnnouncementHeader(const Block& block)
PrefixAnnouncementHeader::PrefixAnnouncementHeader(PrefixAnnouncement prefixAnn) PrefixAnnouncementHeader::PrefixAnnouncementHeader(PrefixAnnouncement prefixAnn)
: m_prefixAnn(std::move(prefixAnn)) : m_prefixAnn(std::move(prefixAnn))
{ {
if (m_prefixAnn->getData() == nullopt) { if (!m_prefixAnn->getData()) {
NDN_THROW(Error("PrefixAnnouncement does not contain Data")); NDN_THROW(Error("PrefixAnnouncement does not contain Data"));
} }
} }
@@ -44,7 +44,7 @@ template<encoding::Tag TAG>
size_t size_t
PrefixAnnouncementHeader::wireEncode(EncodingImpl<TAG>& encoder) const PrefixAnnouncementHeader::wireEncode(EncodingImpl<TAG>& encoder) const
{ {
if (m_prefixAnn == nullopt) { if (!m_prefixAnn) {
NDN_THROW(Error("PrefixAnnouncementHeader does not contain a PrefixAnnouncement")); NDN_THROW(Error("PrefixAnnouncementHeader does not contain a PrefixAnnouncement"));
} }
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -61,14 +61,14 @@ public:
void void
wireDecode(const Block& wire); wireDecode(const Block& wire);
const optional<PrefixAnnouncement>& const std::optional<PrefixAnnouncement>&
getPrefixAnn() const getPrefixAnn() const
{ {
return m_prefixAnn; return m_prefixAnn;
} }
private: private:
optional<PrefixAnnouncement> m_prefixAnn; std::optional<PrefixAnnouncement> m_prefixAnn;
}; };
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(PrefixAnnouncementHeader); NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(PrefixAnnouncementHeader);
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -63,7 +63,7 @@ MetaInfo::setFreshnessPeriod(time::milliseconds freshnessPeriod)
} }
MetaInfo& MetaInfo&
MetaInfo::setFinalBlock(optional<name::Component> finalBlockId) MetaInfo::setFinalBlock(std::optional<name::Component> finalBlockId)
{ {
m_wire.reset(); m_wire.reset();
m_finalBlockId = std::move(finalBlockId); m_finalBlockId = std::move(finalBlockId);
@@ -215,7 +215,7 @@ MetaInfo::wireDecode(const Block& wire)
++val; ++val;
} }
else { else {
m_finalBlockId = nullopt; m_finalBlockId = std::nullopt;
} }
// AppMetaInfo (if any) // AppMetaInfo (if any)
+9 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -25,10 +25,10 @@
#include "ndn-cxx/name-component.hpp" #include "ndn-cxx/name-component.hpp"
#include "ndn-cxx/encoding/block.hpp" #include "ndn-cxx/encoding/block.hpp"
#include "ndn-cxx/encoding/encoding-buffer.hpp" #include "ndn-cxx/encoding/encoding-buffer.hpp"
#include "ndn-cxx/util/optional.hpp"
#include "ndn-cxx/util/time.hpp" #include "ndn-cxx/util/time.hpp"
#include <list> #include <list>
#include <optional>
namespace ndn { namespace ndn {
@@ -118,18 +118,20 @@ public: // getter/setter
MetaInfo& MetaInfo&
setFreshnessPeriod(time::milliseconds freshnessPeriod); setFreshnessPeriod(time::milliseconds freshnessPeriod);
/** @brief Return the value of `FinalBlockId`. /**
* @brief Return the value of `FinalBlockId`.
*/ */
const optional<name::Component>& const std::optional<name::Component>&
getFinalBlock() const getFinalBlock() const
{ {
return m_finalBlockId; return m_finalBlockId;
} }
/** @brief Set `FinalBlockId`. /**
* @brief Set `FinalBlockId`.
*/ */
MetaInfo& MetaInfo&
setFinalBlock(optional<name::Component> finalBlockId); setFinalBlock(std::optional<name::Component> finalBlockId);
public: // app-defined MetaInfo items public: // app-defined MetaInfo items
/** /**
@@ -195,7 +197,7 @@ public: // app-defined MetaInfo items
private: private:
uint32_t m_type; uint32_t m_type;
time::milliseconds m_freshnessPeriod; time::milliseconds m_freshnessPeriod;
optional<name::Component> m_finalBlockId; std::optional<name::Component> m_finalBlockId;
std::list<Block> m_appMetaInfo; std::list<Block> m_appMetaInfo;
mutable Block m_wire; mutable Block m_wire;
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -53,7 +53,7 @@ Data
MetadataObject::makeData(Name discoveryInterestName, MetadataObject::makeData(Name discoveryInterestName,
KeyChain& keyChain, KeyChain& keyChain,
const ndn::security::SigningInfo& si, const ndn::security::SigningInfo& si,
optional<uint64_t> version, std::optional<uint64_t> version,
time::milliseconds freshnessPeriod) const time::milliseconds freshnessPeriod) const
{ {
if (discoveryInterestName.empty() || discoveryInterestName[-1] != getKeywordComponent()) { if (discoveryInterestName.empty() || discoveryInterestName[-1] != getKeywordComponent()) {
+1 -1
View File
@@ -83,7 +83,7 @@ public:
makeData(Name discoveryInterestName, makeData(Name discoveryInterestName,
KeyChain& keyChain, KeyChain& keyChain,
const ndn::security::SigningInfo& si = security::SigningInfo(), const ndn::security::SigningInfo& si = security::SigningInfo(),
optional<uint64_t> version = nullopt, std::optional<uint64_t> version = std::nullopt,
time::milliseconds freshnessPeriod = 10_ms) const; time::milliseconds freshnessPeriod = 10_ms) const;
/** /**
+9 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2019 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -119,7 +119,7 @@ FaceQueryFilter::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_faceId = nullopt; m_faceId = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::UriScheme) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::UriScheme) {
@@ -151,7 +151,7 @@ FaceQueryFilter::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_faceScope = nullopt; m_faceScope = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
@@ -159,7 +159,7 @@ FaceQueryFilter::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_facePersistency = nullopt; m_facePersistency = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
@@ -167,7 +167,7 @@ FaceQueryFilter::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_linkType = nullopt; m_linkType = std::nullopt;
} }
} }
@@ -195,7 +195,7 @@ FaceQueryFilter&
FaceQueryFilter::unsetFaceId() FaceQueryFilter::unsetFaceId()
{ {
m_wire.reset(); m_wire.reset();
m_faceId = nullopt; m_faceId = std::nullopt;
return *this; return *this;
} }
@@ -253,7 +253,7 @@ FaceQueryFilter&
FaceQueryFilter::unsetFaceScope() FaceQueryFilter::unsetFaceScope()
{ {
m_wire.reset(); m_wire.reset();
m_faceScope = nullopt; m_faceScope = std::nullopt;
return *this; return *this;
} }
@@ -269,7 +269,7 @@ FaceQueryFilter&
FaceQueryFilter::unsetFacePersistency() FaceQueryFilter::unsetFacePersistency()
{ {
m_wire.reset(); m_wire.reset();
m_facePersistency = nullopt; m_facePersistency = std::nullopt;
return *this; return *this;
} }
@@ -285,7 +285,7 @@ FaceQueryFilter&
FaceQueryFilter::unsetLinkType() FaceQueryFilter::unsetLinkType()
{ {
m_wire.reset(); m_wire.reset();
m_linkType = nullopt; m_linkType = std::nullopt;
return *this; return *this;
} }
+7 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -24,7 +24,8 @@
#include "ndn-cxx/encoding/block.hpp" #include "ndn-cxx/encoding/block.hpp"
#include "ndn-cxx/encoding/nfd-constants.hpp" #include "ndn-cxx/encoding/nfd-constants.hpp"
#include "ndn-cxx/util/optional.hpp"
#include <optional>
namespace ndn { namespace ndn {
namespace nfd { namespace nfd {
@@ -204,13 +205,13 @@ public: // getters & setters
unsetLinkType(); unsetLinkType();
private: private:
optional<uint64_t> m_faceId; std::optional<uint64_t> m_faceId;
std::string m_uriScheme; std::string m_uriScheme;
std::string m_remoteUri; std::string m_remoteUri;
std::string m_localUri; std::string m_localUri;
optional<FaceScope> m_faceScope; std::optional<FaceScope> m_faceScope;
optional<FacePersistency> m_facePersistency; std::optional<FacePersistency> m_facePersistency;
optional<LinkType> m_linkType; std::optional<LinkType> m_linkType;
mutable Block m_wire; mutable Block m_wire;
}; };
+9 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2019 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -148,7 +148,7 @@ FaceStatus::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_expirationPeriod = nullopt; m_expirationPeriod = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
@@ -180,7 +180,7 @@ FaceStatus::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_baseCongestionMarkingInterval = nullopt; m_baseCongestionMarkingInterval = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::DefaultCongestionThreshold) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::DefaultCongestionThreshold) {
@@ -188,7 +188,7 @@ FaceStatus::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_defaultCongestionThreshold = nullopt; m_defaultCongestionThreshold = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::Mtu) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::Mtu) {
@@ -196,7 +196,7 @@ FaceStatus::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_mtu = nullopt; m_mtu = std::nullopt;
} }
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) { if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
@@ -284,7 +284,7 @@ FaceStatus&
FaceStatus::unsetExpirationPeriod() FaceStatus::unsetExpirationPeriod()
{ {
m_wire.reset(); m_wire.reset();
m_expirationPeriod = nullopt; m_expirationPeriod = std::nullopt;
return *this; return *this;
} }
@@ -300,7 +300,7 @@ FaceStatus&
FaceStatus::unsetBaseCongestionMarkingInterval() FaceStatus::unsetBaseCongestionMarkingInterval()
{ {
m_wire.reset(); m_wire.reset();
m_baseCongestionMarkingInterval = nullopt; m_baseCongestionMarkingInterval = std::nullopt;
return *this; return *this;
} }
@@ -316,7 +316,7 @@ FaceStatus&
FaceStatus::unsetDefaultCongestionThreshold() FaceStatus::unsetDefaultCongestionThreshold()
{ {
m_wire.reset(); m_wire.reset();
m_defaultCongestionThreshold = nullopt; m_defaultCongestionThreshold = std::nullopt;
return *this; return *this;
} }
@@ -332,7 +332,7 @@ FaceStatus&
FaceStatus::unsetMtu() FaceStatus::unsetMtu()
{ {
m_wire.reset(); m_wire.reset();
m_mtu = nullopt; m_mtu = std::nullopt;
return *this; return *this;
} }
+7 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -23,9 +23,10 @@
#define NDN_CXX_MGMT_NFD_FACE_STATUS_HPP #define NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
#include "ndn-cxx/mgmt/nfd/face-traits.hpp" #include "ndn-cxx/mgmt/nfd/face-traits.hpp"
#include "ndn-cxx/util/optional.hpp"
#include "ndn-cxx/util/time.hpp" #include "ndn-cxx/util/time.hpp"
#include <optional>
namespace ndn { namespace ndn {
namespace nfd { namespace nfd {
@@ -220,10 +221,10 @@ public: // getters & setters
setNOutBytes(uint64_t nOutBytes); setNOutBytes(uint64_t nOutBytes);
private: private:
optional<time::milliseconds> m_expirationPeriod; std::optional<time::milliseconds> m_expirationPeriod;
optional<time::nanoseconds> m_baseCongestionMarkingInterval; std::optional<time::nanoseconds> m_baseCongestionMarkingInterval;
optional<uint64_t> m_defaultCongestionThreshold; std::optional<uint64_t> m_defaultCongestionThreshold;
optional<uint64_t> m_mtu; std::optional<uint64_t> m_mtu;
uint64_t m_nInInterests; uint64_t m_nInInterests;
uint64_t m_nInData; uint64_t m_nInData;
uint64_t m_nInNacks; uint64_t m_nInNacks;
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2019 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -94,7 +94,7 @@ Route::setExpirationPeriod(time::milliseconds expirationPeriod)
Route& Route&
Route::unsetExpirationPeriod() Route::unsetExpirationPeriod()
{ {
m_expirationPeriod = nullopt; m_expirationPeriod = std::nullopt;
m_wire.reset(); m_wire.reset();
return *this; return *this;
} }
@@ -185,7 +185,7 @@ Route::wireDecode(const Block& block)
++val; ++val;
} }
else { else {
m_expirationPeriod = nullopt; m_expirationPeriod = std::nullopt;
} }
} }
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -122,7 +122,7 @@ private:
RouteOrigin m_origin; RouteOrigin m_origin;
uint64_t m_cost; uint64_t m_cost;
uint64_t m_flags; uint64_t m_flags;
optional<time::milliseconds> m_expirationPeriod; std::optional<time::milliseconds> m_expirationPeriod;
mutable Block m_wire; mutable Block m_wire;
}; };
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -227,13 +227,13 @@ Name::set(ssize_t i, Component&& component)
} }
Name& Name&
Name::appendVersion(const optional<uint64_t>& version) Name::appendVersion(const std::optional<uint64_t>& version)
{ {
return append(Component::fromVersion(version.value_or(time::toUnixTimestamp(time::system_clock::now()).count()))); return append(Component::fromVersion(version.value_or(time::toUnixTimestamp(time::system_clock::now()).count())));
} }
Name& Name&
Name::appendTimestamp(const optional<time::system_clock::time_point>& timestamp) Name::appendTimestamp(const std::optional<time::system_clock::time_point>& timestamp)
{ {
return append(Component::fromTimestamp(timestamp.value_or(time::system_clock::now()))); return append(Component::fromTimestamp(timestamp.value_or(time::system_clock::now())));
} }
+3 -3
View File
@@ -23,9 +23,9 @@
#define NDN_CXX_NAME_HPP #define NDN_CXX_NAME_HPP
#include "ndn-cxx/name-component.hpp" #include "ndn-cxx/name-component.hpp"
#include "ndn-cxx/util/optional.hpp"
#include <iterator> #include <iterator>
#include <optional>
namespace ndn { namespace ndn {
@@ -447,7 +447,7 @@ public: // modifiers
* https://named-data.net/publications/techreports/ndn-tr-22-3-ndn-memo-naming-conventions/ * https://named-data.net/publications/techreports/ndn-tr-22-3-ndn-memo-naming-conventions/
*/ */
Name& Name&
appendVersion(const optional<uint64_t>& version = nullopt); appendVersion(const std::optional<uint64_t>& version = std::nullopt);
/** /**
* @brief Append a timestamp component. * @brief Append a timestamp component.
@@ -457,7 +457,7 @@ public: // modifiers
* https://named-data.net/publications/techreports/ndn-tr-22-3-ndn-memo-naming-conventions/ * https://named-data.net/publications/techreports/ndn-tr-22-3-ndn-memo-naming-conventions/
*/ */
Name& Name&
appendTimestamp(const optional<time::system_clock::time_point>& timestamp = nullopt); appendTimestamp(const std::optional<time::system_clock::time_point>& timestamp = std::nullopt);
/** /**
* @brief Append a sequence number component. * @brief Append a sequence number component.
+2 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2018 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -20,6 +20,7 @@
*/ */
#include "ndn-cxx/net/impl/link-type-helper.hpp" #include "ndn-cxx/net/impl/link-type-helper.hpp"
#include "ndn-cxx/detail/config.hpp"
#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS #ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
#error "This file should not be compiled ..." #error "This file should not be compiled ..."
+3 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2021 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -24,6 +24,8 @@
#include "ndn-cxx/encoding/nfd-constants.hpp" #include "ndn-cxx/encoding/nfd-constants.hpp"
#include <string>
namespace ndn { namespace ndn {
namespace net { namespace net {
namespace detail { namespace detail {
+15 -15
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2021 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -26,7 +26,6 @@
#include "ndn-cxx/detail/common.hpp" #include "ndn-cxx/detail/common.hpp"
#include "ndn-cxx/net/ethernet.hpp" #include "ndn-cxx/net/ethernet.hpp"
#include "ndn-cxx/util/optional.hpp"
#ifndef NDN_CXX_HAVE_NETLINK #ifndef NDN_CXX_HAVE_NETLINK
#error "This file should not be included ..." #error "This file should not be included ..."
@@ -38,6 +37,7 @@
#include <cstring> #include <cstring>
#include <map> #include <map>
#include <optional>
#include <boost/asio/ip/address.hpp> #include <boost/asio/ip/address.hpp>
@@ -227,12 +227,12 @@ public:
} }
template<typename U> template<typename U>
optional<U> std::optional<U>
getAttributeByType(uint16_t attrType) const getAttributeByType(uint16_t attrType) const
{ {
auto it = m_attrs.find(attrType); auto it = m_attrs.find(attrType);
if (it == m_attrs.end()) if (it == m_attrs.end())
return nullopt; return std::nullopt;
return convertAttrValue(getAttributeValue(it->second), return convertAttrValue(getAttributeValue(it->second),
getAttributeValueLength(it->second), getAttributeValueLength(it->second),
@@ -261,48 +261,48 @@ private:
} }
template<typename Integral> template<typename Integral>
static std::enable_if_t<std::is_integral<Integral>::value, optional<Integral>> static std::enable_if_t<std::is_integral<Integral>::value, std::optional<Integral>>
convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<Integral>) convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<Integral>)
{ {
if (len < sizeof(Integral)) if (len < sizeof(Integral))
return nullopt; return std::nullopt;
Integral i; Integral i;
std::memcpy(&i, val, sizeof(Integral)); std::memcpy(&i, val, sizeof(Integral));
return i; return i;
} }
static optional<std::string> static std::optional<std::string>
convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<std::string>) convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<std::string>)
{ {
auto str = reinterpret_cast<const char*>(val); auto str = reinterpret_cast<const char*>(val);
if (::strnlen(str, len) >= len) if (::strnlen(str, len) >= len)
return nullopt; return std::nullopt;
return std::string(str); return std::make_optional<std::string>(str);
} }
static optional<ethernet::Address> static std::optional<ethernet::Address>
convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<ethernet::Address>) convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<ethernet::Address>)
{ {
if (len < ethernet::ADDR_LEN) if (len < ethernet::ADDR_LEN)
return nullopt; return std::nullopt;
return ethernet::Address(val); return std::make_optional<ethernet::Address>(val);
} }
template<typename IpAddress> template<typename IpAddress>
static std::enable_if_t<std::is_same<IpAddress, boost::asio::ip::address_v4>::value || static std::enable_if_t<std::is_same<IpAddress, boost::asio::ip::address_v4>::value ||
std::is_same<IpAddress, boost::asio::ip::address_v6>::value, std::is_same<IpAddress, boost::asio::ip::address_v6>::value,
optional<IpAddress>> std::optional<IpAddress>>
convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<IpAddress>) convertAttrValue(const uint8_t* val, size_t len, AttrValueTypeTag<IpAddress>)
{ {
typename IpAddress::bytes_type bytes; typename IpAddress::bytes_type bytes;
if (len < bytes.size()) if (len < bytes.size())
return nullopt; return std::nullopt;
std::copy_n(val, bytes.size(), bytes.begin()); std::copy_n(val, bytes.size(), bytes.begin());
return IpAddress(bytes); return std::make_optional<IpAddress>(bytes);
} }
private: private:
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -68,7 +68,7 @@ PrefixAnnouncement::PrefixAnnouncement(Data data)
const Data& const Data&
PrefixAnnouncement::toData(KeyChain& keyChain, const ndn::security::SigningInfo& si, PrefixAnnouncement::toData(KeyChain& keyChain, const ndn::security::SigningInfo& si,
optional<uint64_t> version) const std::optional<uint64_t> version) const
{ {
if (!m_data) { if (!m_data) {
Name dataName = m_announcedName; Name dataName = m_announcedName;
@@ -112,7 +112,7 @@ PrefixAnnouncement::setExpiration(time::milliseconds expiration)
} }
PrefixAnnouncement& PrefixAnnouncement&
PrefixAnnouncement::setValidityPeriod(optional<security::ValidityPeriod> validity) PrefixAnnouncement::setValidityPeriod(std::optional<security::ValidityPeriod> validity)
{ {
m_data.reset(); m_data.reset();
m_validity = std::move(validity); m_validity = std::move(validity);
+7 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2021 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -58,7 +58,7 @@ public:
/** \brief Get the Data representing the prefix announcement, if available. /** \brief Get the Data representing the prefix announcement, if available.
*/ */
const optional<Data>& const std::optional<Data>&
getData() const getData() const
{ {
return m_data; return m_data;
@@ -74,7 +74,7 @@ public:
const Data& const Data&
toData(KeyChain& keyChain, toData(KeyChain& keyChain,
const ndn::security::SigningInfo& si = security::SigningInfo(), const ndn::security::SigningInfo& si = security::SigningInfo(),
optional<uint64_t> version = nullopt) const; std::optional<uint64_t> version = std::nullopt) const;
/** \brief Return announced name. /** \brief Return announced name.
*/ */
@@ -107,7 +107,7 @@ public:
/** \brief Return absolute validity period. /** \brief Return absolute validity period.
*/ */
optional<security::ValidityPeriod> std::optional<security::ValidityPeriod>
getValidityPeriod() const getValidityPeriod() const
{ {
return m_validity; return m_validity;
@@ -117,7 +117,7 @@ public:
* \post getData() == nullopt * \post getData() == nullopt
*/ */
PrefixAnnouncement& PrefixAnnouncement&
setValidityPeriod(optional<security::ValidityPeriod> validity); setValidityPeriod(std::optional<security::ValidityPeriod> validity);
public: // static methods public: // static methods
/** /**
@@ -127,10 +127,10 @@ public: // static methods
getKeywordComponent(); getKeywordComponent();
private: private:
mutable optional<Data> m_data; mutable std::optional<Data> m_data;
Name m_announcedName; Name m_announcedName;
time::milliseconds m_expiration = 0_ms; time::milliseconds m_expiration = 0_ms;
optional<security::ValidityPeriod> m_validity; std::optional<security::ValidityPeriod> m_validity;
}; };
/** /**
+3 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -21,6 +21,8 @@
#include "ndn-cxx/security/impl/openssl-helper.hpp" #include "ndn-cxx/security/impl/openssl-helper.hpp"
#include <limits>
namespace ndn { namespace ndn {
namespace security { namespace security {
namespace detail { namespace detail {
+1 -1
View File
@@ -733,7 +733,7 @@ KeyChain::prepareSignatureInfoWithIdentity(const SigningInfo& params, const pib:
std::tuple<Name, SignatureInfo> std::tuple<Name, SignatureInfo>
KeyChain::prepareSignatureInfoWithKey(const SigningInfo& params, const pib::Key& key, KeyChain::prepareSignatureInfoWithKey(const SigningInfo& params, const pib::Key& key,
const optional<Name>& certName) const std::optional<Name>& certName)
{ {
auto sigInfo = params.getSignatureInfo(); auto sigInfo = params.getSignatureInfo();
sigInfo.setSignatureType(getSignatureType(key.getKeyType(), params.getDigestAlgorithm())); sigInfo.setSignatureType(getSignatureType(key.getKeyType(), params.getDigestAlgorithm()));
+4 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -50,7 +50,7 @@ struct MakeCertificateOptions
* *
* Default is deriving from current timestamp using the logic of Name::appendVersion() . * Default is deriving from current timestamp using the logic of Name::appendVersion() .
*/ */
optional<uint64_t> version; std::optional<uint64_t> version;
/** /**
* @brief Certificate packet FreshnessPeriod. * @brief Certificate packet FreshnessPeriod.
@@ -70,7 +70,7 @@ struct MakeCertificateOptions
* *
* Default is a ValidityPeriod from now until 365 days later. * Default is a ValidityPeriod from now until 365 days later.
*/ */
optional<ValidityPeriod> validity; std::optional<ValidityPeriod> validity;
}; };
inline namespace v2 { inline namespace v2 {
@@ -498,7 +498,7 @@ private: // signing
static std::tuple<Name, SignatureInfo> static std::tuple<Name, SignatureInfo>
prepareSignatureInfoWithKey(const SigningInfo& params, const pib::Key& key, prepareSignatureInfoWithKey(const SigningInfo& params, const pib::Key& key,
const optional<Name>& certName = nullopt); const std::optional<Name>& certName = std::nullopt);
/** /**
* @brief Generate and return a raw signature for the byte ranges in @p bufs using * @brief Generate and return a raw signature for the byte ranges in @p bufs using
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -71,7 +71,7 @@ KeyImpl::removeCertificate(const Name& certName)
if (m_defaultCert && m_defaultCert->getName() == certName) { if (m_defaultCert && m_defaultCert->getName() == certName) {
NDN_LOG_DEBUG("Removing default certificate " << certName); NDN_LOG_DEBUG("Removing default certificate " << certName);
m_defaultCert = nullopt; m_defaultCert = std::nullopt;
} }
m_certificates.remove(certName); m_certificates.remove(certName);
} }
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -131,7 +131,7 @@ private:
const shared_ptr<PibImpl> m_pib; const shared_ptr<PibImpl> m_pib;
CertificateContainer m_certificates; CertificateContainer m_certificates;
mutable optional<Certificate> m_defaultCert; mutable std::optional<Certificate> m_defaultCert;
}; };
} // namespace detail } // namespace detail
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -127,7 +127,7 @@ private:
std::string m_tpmLocator; std::string m_tpmLocator;
std::set<Name> m_identities; std::set<Name> m_identities;
optional<Name> m_defaultIdentity; std::optional<Name> m_defaultIdentity;
/// identity name => default key name /// identity name => default key name
std::map<Name, Name> m_defaultKeys; std::map<Name, Name> m_defaultKeys;
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -142,9 +142,9 @@ ValidationPolicySignedInterest::checkIncomingInterest(const shared_ptr<Validatio
void void
ValidationPolicySignedInterest::insertRecord(const Name& keyName, ValidationPolicySignedInterest::insertRecord(const Name& keyName,
optional<time::system_clock::TimePoint> timestamp, std::optional<time::system_clock::TimePoint> timestamp,
optional<uint64_t> seqNum, std::optional<uint64_t> seqNum,
optional<SigNonce> nonce) std::optional<SigNonce> nonce)
{ {
// If key record exists, update last refreshed time. Otherwise, create new record. // If key record exists, update last refreshed time. Otherwise, create new record.
Container::nth_index<0>::type::iterator it; Container::nth_index<0>::type::iterator it;
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -158,9 +158,9 @@ private:
void void
insertRecord(const Name& keyName, insertRecord(const Name& keyName,
optional<time::system_clock::TimePoint> timestamp, std::optional<time::system_clock::TimePoint> timestamp,
optional<uint64_t> seqNum, std::optional<uint64_t> seqNum,
optional<SigNonce> nonce); std::optional<SigNonce> nonce);
private: private:
Options m_options; Options m_options;
@@ -181,8 +181,8 @@ private:
struct LastInterestRecord struct LastInterestRecord
{ {
LastInterestRecord(const Name& keyName, LastInterestRecord(const Name& keyName,
optional<time::system_clock::TimePoint> timestamp, std::optional<time::system_clock::TimePoint> timestamp,
optional<uint64_t> seqNum) std::optional<uint64_t> seqNum)
: keyName(keyName) : keyName(keyName)
, timestamp(timestamp) , timestamp(timestamp)
, seqNum(seqNum) , seqNum(seqNum)
@@ -191,8 +191,8 @@ private:
} }
Name keyName; Name keyName;
optional<time::system_clock::TimePoint> timestamp; std::optional<time::system_clock::TimePoint> timestamp;
optional<uint64_t> seqNum; std::optional<uint64_t> seqNum;
NonceContainer observedNonces; NonceContainer observedNonces;
time::steady_clock::TimePoint lastRefreshed; time::steady_clock::TimePoint lastRefreshed;
}; };
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -92,7 +92,7 @@ DataValidationState::~DataValidationState()
} }
void void
DataValidationState::verifyOriginalPacket(const optional<Certificate>& trustedCert) DataValidationState::verifyOriginalPacket(const std::optional<Certificate>& trustedCert)
{ {
if (verifySignature(m_data, trustedCert)) { if (verifySignature(m_data, trustedCert)) {
NDN_LOG_TRACE_DEPTH("OK signature for data `" << m_data.getName() << "`"); NDN_LOG_TRACE_DEPTH("OK signature for data `" << m_data.getName() << "`");
@@ -145,7 +145,7 @@ InterestValidationState::~InterestValidationState()
} }
void void
InterestValidationState::verifyOriginalPacket(const optional<Certificate>& trustedCert) InterestValidationState::verifyOriginalPacket(const std::optional<Certificate>& trustedCert)
{ {
if (verifySignature(m_interest, trustedCert)) { if (verifySignature(m_interest, trustedCert)) {
NDN_LOG_TRACE_DEPTH("OK signature for interest `" << m_interest.getName() << "`"); NDN_LOG_TRACE_DEPTH("OK signature for interest `" << m_interest.getName() << "`");
+7 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -106,12 +106,12 @@ private: // Interface intended to be used only by Validator class
/** /**
* @brief Verify signature of the original packet * @brief Verify signature of the original packet
* *
* @param trustCert The certificate that signs the original packet, nullopt if certificate is * @param trustedCert The certificate that signs the original packet, nullopt if certificate
* not needed for verification (e.g., sha256 digest or attribute based * is not needed for verification (e.g., sha256 digest or attribute based
* signature) * signature)
*/ */
virtual void virtual void
verifyOriginalPacket(const optional<Certificate>& trustedCert) = 0; verifyOriginalPacket(const std::optional<Certificate>& trustedCert) = 0;
/** /**
* @brief Call success callback of the original packet without signature validation * @brief Call success callback of the original packet without signature validation
@@ -191,7 +191,7 @@ public:
private: private:
void void
verifyOriginalPacket(const optional<Certificate>& trustedCert) final; verifyOriginalPacket(const std::optional<Certificate>& trustedCert) final;
void void
bypassValidation() final; bypassValidation() final;
@@ -243,7 +243,7 @@ public:
private: private:
void void
verifyOriginalPacket(const optional<Certificate>& trustedCert) final; verifyOriginalPacket(const std::optional<Certificate>& trustedCert) final;
void void
bypassValidation() final; bypassValidation() final;
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -129,7 +129,7 @@ Validator::requestCertificate(const shared_ptr<CertificateRequest>& certRequest,
} }
if (certRequest->interest.getName() == SigningInfo::getDigestSha256Identity()) { if (certRequest->interest.getName() == SigningInfo::getDigestSha256Identity()) {
state->verifyOriginalPacket(nullopt); state->verifyOriginalPacket(std::nullopt);
return; return;
} }
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -216,7 +216,7 @@ verifySignature(const Interest& interest, const pib::Key& key)
} }
bool bool
verifySignature(const Data& data, const optional<Certificate>& cert) verifySignature(const Data& data, const std::optional<Certificate>& cert)
{ {
auto parsed = parse(data); auto parsed = parse(data);
if (cert) { if (cert) {
@@ -232,7 +232,7 @@ verifySignature(const Data& data, const optional<Certificate>& cert)
} }
bool bool
verifySignature(const Interest& interest, const optional<Certificate>& cert) verifySignature(const Interest& interest, const std::optional<Certificate>& cert)
{ {
auto parsed = parse(interest); auto parsed = parse(interest);
if (cert) { if (cert) {
+2 -2
View File
@@ -108,7 +108,7 @@ verifySignature(const Interest& interest, const pib::Key& key);
* If @p cert is nullopt, @p data assumed to be self-verifiable (with digest or attributes) * If @p cert is nullopt, @p data assumed to be self-verifiable (with digest or attributes)
*/ */
[[nodiscard]] bool [[nodiscard]] bool
verifySignature(const Data& data, const optional<Certificate>& cert); verifySignature(const Data& data, const std::optional<Certificate>& cert);
/** /**
* @brief Verify @p interest using @p cert. * @brief Verify @p interest using @p cert.
@@ -117,7 +117,7 @@ verifySignature(const Data& data, const optional<Certificate>& cert);
* If @p cert is nullptr, @p interest assumed to be self-verifiable (with digest or attributes) * If @p cert is nullptr, @p interest assumed to be self-verifiable (with digest or attributes)
*/ */
[[nodiscard]] bool [[nodiscard]] bool
verifySignature(const Interest& interest, const optional<Certificate>& cert); verifySignature(const Interest& interest, const std::optional<Certificate>& cert);
/** /**
* @brief Verify @p data using @p tpm and @p keyName with the @p digestAlgorithm. * @brief Verify @p data using @p tpm and @p keyName with the @p digestAlgorithm.
+16 -16
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -37,7 +37,7 @@ static_assert(std::is_base_of<tlv::Error, SignatureInfo::Error>::value,
SignatureInfo::SignatureInfo() = default; SignatureInfo::SignatureInfo() = default;
SignatureInfo::SignatureInfo(tlv::SignatureTypeValue type, optional<KeyLocator> keyLocator) SignatureInfo::SignatureInfo(tlv::SignatureTypeValue type, std::optional<KeyLocator> keyLocator)
: m_type(type) : m_type(type)
, m_keyLocator(std::move(keyLocator)) , m_keyLocator(std::move(keyLocator))
{ {
@@ -117,7 +117,7 @@ void
SignatureInfo::wireDecode(const Block& wire, SignatureInfo::Type type) SignatureInfo::wireDecode(const Block& wire, SignatureInfo::Type type)
{ {
m_type = -1; m_type = -1;
m_keyLocator = nullopt; m_keyLocator = std::nullopt;
m_otherTlvs.clear(); m_otherTlvs.clear();
m_wire = wire; m_wire = wire;
@@ -196,7 +196,7 @@ SignatureInfo::getKeyLocator() const
} }
SignatureInfo& SignatureInfo&
SignatureInfo::setKeyLocator(optional<KeyLocator> keyLocator) SignatureInfo::setKeyLocator(std::optional<KeyLocator> keyLocator)
{ {
if (keyLocator != m_keyLocator) { if (keyLocator != m_keyLocator) {
m_keyLocator = std::move(keyLocator); m_keyLocator = std::move(keyLocator);
@@ -216,7 +216,7 @@ SignatureInfo::getValidityPeriod() const
} }
SignatureInfo& SignatureInfo&
SignatureInfo::setValidityPeriod(optional<security::ValidityPeriod> validityPeriod) SignatureInfo::setValidityPeriod(std::optional<security::ValidityPeriod> validityPeriod)
{ {
if (!validityPeriod) { if (!validityPeriod) {
removeCustomTlv(tlv::ValidityPeriod); removeCustomTlv(tlv::ValidityPeriod);
@@ -227,18 +227,18 @@ SignatureInfo::setValidityPeriod(optional<security::ValidityPeriod> validityPeri
return *this; return *this;
} }
optional<std::vector<uint8_t>> std::optional<std::vector<uint8_t>>
SignatureInfo::getNonce() const SignatureInfo::getNonce() const
{ {
auto it = findOtherTlv(tlv::SignatureNonce); auto it = findOtherTlv(tlv::SignatureNonce);
if (it == m_otherTlvs.end()) { if (it == m_otherTlvs.end()) {
return nullopt; return std::nullopt;
} }
return std::vector<uint8_t>(it->value_begin(), it->value_end()); return std::vector<uint8_t>(it->value_begin(), it->value_end());
} }
SignatureInfo& SignatureInfo&
SignatureInfo::setNonce(optional<span<const uint8_t>> nonce) SignatureInfo::setNonce(std::optional<span<const uint8_t>> nonce)
{ {
if (!nonce) { if (!nonce) {
removeCustomTlv(tlv::SignatureNonce); removeCustomTlv(tlv::SignatureNonce);
@@ -249,18 +249,18 @@ SignatureInfo::setNonce(optional<span<const uint8_t>> nonce)
return *this; return *this;
} }
optional<time::system_clock::time_point> std::optional<time::system_clock::time_point>
SignatureInfo::getTime() const SignatureInfo::getTime() const
{ {
auto it = findOtherTlv(tlv::SignatureTime); auto it = findOtherTlv(tlv::SignatureTime);
if (it == m_otherTlvs.end()) { if (it == m_otherTlvs.end()) {
return nullopt; return std::nullopt;
} }
return time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*it))); return time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*it)));
} }
SignatureInfo& SignatureInfo&
SignatureInfo::setTime(optional<time::system_clock::time_point> time) SignatureInfo::setTime(std::optional<time::system_clock::time_point> time)
{ {
if (!time) { if (!time) {
removeCustomTlv(tlv::SignatureTime); removeCustomTlv(tlv::SignatureTime);
@@ -272,18 +272,18 @@ SignatureInfo::setTime(optional<time::system_clock::time_point> time)
return *this; return *this;
} }
optional<uint64_t> std::optional<uint64_t>
SignatureInfo::getSeqNum() const SignatureInfo::getSeqNum() const
{ {
auto it = findOtherTlv(tlv::SignatureSeqNum); auto it = findOtherTlv(tlv::SignatureSeqNum);
if (it == m_otherTlvs.end()) { if (it == m_otherTlvs.end()) {
return nullopt; return std::nullopt;
} }
return readNonNegativeInteger(*it); return readNonNegativeInteger(*it);
} }
SignatureInfo& SignatureInfo&
SignatureInfo::setSeqNum(optional<uint64_t> seqNum) SignatureInfo::setSeqNum(std::optional<uint64_t> seqNum)
{ {
if (!seqNum) { if (!seqNum) {
removeCustomTlv(tlv::SignatureSeqNum); removeCustomTlv(tlv::SignatureSeqNum);
@@ -294,12 +294,12 @@ SignatureInfo::setSeqNum(optional<uint64_t> seqNum)
return *this; return *this;
} }
optional<Block> std::optional<Block>
SignatureInfo::getCustomTlv(uint32_t type) const SignatureInfo::getCustomTlv(uint32_t type) const
{ {
auto it = findOtherTlv(type); auto it = findOtherTlv(type);
if (it == m_otherTlvs.end()) { if (it == m_otherTlvs.end()) {
return nullopt; return std::nullopt;
} }
return *it; return *it;
} }
+12 -12
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -50,7 +50,7 @@ public:
/** @brief Create with the specified type and KeyLocator /** @brief Create with the specified type and KeyLocator
*/ */
explicit explicit
SignatureInfo(tlv::SignatureTypeValue type, optional<KeyLocator> keyLocator = nullopt); SignatureInfo(tlv::SignatureTypeValue type, std::optional<KeyLocator> keyLocator = std::nullopt);
/** @brief Create from wire encoding /** @brief Create from wire encoding
* @param wire Wire to decode from * @param wire Wire to decode from
@@ -143,7 +143,7 @@ public: // field access
* @return A reference to this SignatureInfo, to allow chaining. * @return A reference to this SignatureInfo, to allow chaining.
*/ */
SignatureInfo& SignatureInfo&
setKeyLocator(optional<KeyLocator> keyLocator); setKeyLocator(std::optional<KeyLocator> keyLocator);
/** @brief Get the `ValidityPeriod` element. /** @brief Get the `ValidityPeriod` element.
* @throw Error This SignatureInfo does not contain a ValidityPeriod * @throw Error This SignatureInfo does not contain a ValidityPeriod
@@ -158,12 +158,12 @@ public: // field access
* @return A reference to this SignatureInfo, to allow chaining. * @return A reference to this SignatureInfo, to allow chaining.
*/ */
SignatureInfo& SignatureInfo&
setValidityPeriod(optional<security::ValidityPeriod> validityPeriod); setValidityPeriod(std::optional<security::ValidityPeriod> validityPeriod);
/** @brief Get SignatureNonce /** @brief Get SignatureNonce
* @retval nullopt SignatureNonce is not set * @retval nullopt SignatureNonce is not set
*/ */
optional<std::vector<uint8_t>> std::optional<std::vector<uint8_t>>
getNonce() const; getNonce() const;
/** @brief Append or replace SignatureNonce /** @brief Append or replace SignatureNonce
@@ -173,12 +173,12 @@ public: // field access
* @return A reference to this SignatureInfo, to allow chaining. * @return A reference to this SignatureInfo, to allow chaining.
*/ */
SignatureInfo& SignatureInfo&
setNonce(optional<span<const uint8_t>> nonce); setNonce(std::optional<span<const uint8_t>> nonce);
/** @brief Get SignatureTime /** @brief Get SignatureTime
* @retval nullopt SignatureTime is not set * @retval nullopt SignatureTime is not set
*/ */
optional<time::system_clock::time_point> std::optional<time::system_clock::time_point>
getTime() const; getTime() const;
/** @brief Append or replace SignatureTime /** @brief Append or replace SignatureTime
@@ -188,12 +188,12 @@ public: // field access
* @return A reference to this SignatureInfo, to allow chaining. * @return A reference to this SignatureInfo, to allow chaining.
*/ */
SignatureInfo& SignatureInfo&
setTime(optional<time::system_clock::time_point> time = time::system_clock::now()); setTime(std::optional<time::system_clock::time_point> time = time::system_clock::now());
/** @brief Get SignatureSeqNum /** @brief Get SignatureSeqNum
* @retval nullopt SignatureSeqNum is not set * @retval nullopt SignatureSeqNum is not set
*/ */
optional<uint64_t> std::optional<uint64_t>
getSeqNum() const; getSeqNum() const;
/** @brief Append or replace SignatureSeqNum /** @brief Append or replace SignatureSeqNum
@@ -203,13 +203,13 @@ public: // field access
* @return A reference to this SignatureInfo, to allow chaining. * @return A reference to this SignatureInfo, to allow chaining.
*/ */
SignatureInfo& SignatureInfo&
setSeqNum(optional<uint64_t> seqNum); setSeqNum(std::optional<uint64_t> seqNum);
/** @brief Get first custom TLV element with the specified TLV-TYPE /** @brief Get first custom TLV element with the specified TLV-TYPE
* @param type TLV-TYPE of element to get * @param type TLV-TYPE of element to get
* @retval nullopt No custom TLV elements with the specified TLV-TYPE exist * @retval nullopt No custom TLV elements with the specified TLV-TYPE exist
*/ */
optional<Block> std::optional<Block>
getCustomTlv(uint32_t type) const; getCustomTlv(uint32_t type) const;
/** @brief Append an arbitrary TLV element to this SignatureInfo /** @brief Append an arbitrary TLV element to this SignatureInfo
@@ -231,7 +231,7 @@ private:
private: private:
int32_t m_type = -1; int32_t m_type = -1;
optional<KeyLocator> m_keyLocator; std::optional<KeyLocator> m_keyLocator;
std::vector<Block> m_otherTlvs; std::vector<Block> m_otherTlvs;
mutable Block m_wire; mutable Block m_wire;
+1 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -24,7 +24,6 @@
#include "ndn-cxx/encoding/block.hpp" #include "ndn-cxx/encoding/block.hpp"
#include "ndn-cxx/util/concepts.hpp" #include "ndn-cxx/util/concepts.hpp"
#include "ndn-cxx/util/optional.hpp"
#include <fstream> #include <fstream>
-42
View File
@@ -1,42 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received copies of the GNU General Public License and GNU Lesser
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
* <http://www.gnu.org/licenses/>.
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
#ifndef NDN_CXX_UTIL_OPTIONAL_HPP
#define NDN_CXX_UTIL_OPTIONAL_HPP
#define optional_CONFIG_SELECT_OPTIONAL optional_OPTIONAL_NONSTD
#define optional_CONFIG_NO_EXTENSIONS 1
#include "ndn-cxx/detail/nonstd/optional-lite.hpp"
namespace ndn {
using ::nonstd::optional;
using ::nonstd::bad_optional_access;
using ::nonstd::nullopt;
using ::nonstd::nullopt_t;
using ::nonstd::make_optional;
using ::nonstd::in_place;
using ::nonstd::in_place_t;
} // namespace ndn
#endif // NDN_CXX_UTIL_OPTIONAL_HPP
+3 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -27,6 +27,8 @@
#include <boost/asio/wait_traits.hpp> #include <boost/asio/wait_traits.hpp>
#include <boost/chrono.hpp> #include <boost/chrono.hpp>
#include <limits>
namespace ndn { namespace ndn {
namespace time { namespace time {
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2020 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -25,8 +25,8 @@ namespace ndn {
namespace tests { namespace tests {
shared_ptr<Interest> shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix, optional<time::milliseconds> lifetime, makeInterest(const Name& name, bool canBePrefix, std::optional<time::milliseconds> lifetime,
optional<Interest::Nonce> nonce) std::optional<Interest::Nonce> nonce)
{ {
auto interest = std::make_shared<Interest>(name); auto interest = std::make_shared<Interest>(name);
interest->setCanBePrefix(canBePrefix); interest->setCanBePrefix(canBePrefix);
+4 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2020 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -35,8 +35,8 @@ namespace tests {
*/ */
shared_ptr<Interest> shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix = false, makeInterest(const Name& name, bool canBePrefix = false,
optional<time::milliseconds> lifetime = nullopt, std::optional<time::milliseconds> lifetime = std::nullopt,
optional<Interest::Nonce> nonce = nullopt); std::optional<Interest::Nonce> nonce = std::nullopt);
/** /**
* \brief Create a Data with a null (i.e., empty) signature * \brief Create a Data with a null (i.e., empty) signature
@@ -70,7 +70,7 @@ makeNack(Interest interest, lp::NackReason reason);
/** /**
* \brief Replace a name component in a packet * \brief Replace a name component in a packet
* \param[inout] pkt the packet * \param[in,out] pkt the packet
* \param index the index of the name component to replace * \param index the index of the name component to replace
* \param args arguments to name::Component constructor * \param args arguments to name::Component constructor
*/ */
+6 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -427,14 +427,14 @@ BOOST_AUTO_TEST_CASE(PutNack)
BOOST_CHECK_EQUAL(face.sentNacks.size(), 0); BOOST_CHECK_EQUAL(face.sentNacks.size(), 0);
face.put(makeNack(*makeInterest("/unsolicited", false, nullopt, 18645250), face.put(makeNack(*makeInterest("/unsolicited", false, std::nullopt, 18645250),
lp::NackReason::NO_ROUTE)); lp::NackReason::NO_ROUTE));
advanceClocks(10_ms); advanceClocks(10_ms);
BOOST_CHECK_EQUAL(face.sentNacks.size(), 0); // unsolicited Nack would not be sent BOOST_CHECK_EQUAL(face.sentNacks.size(), 0); // unsolicited Nack would not be sent
auto interest1 = makeInterest("/Hello/World", false, nullopt, 14247162); auto interest1 = makeInterest("/Hello/World", false, std::nullopt, 14247162);
face.receive(*interest1); face.receive(*interest1);
auto interest2 = makeInterest("/another/prefix", false, nullopt, 92203002); auto interest2 = makeInterest("/another/prefix", false, std::nullopt, 92203002);
face.receive(*interest2); face.receive(*interest2);
advanceClocks(10_ms); advanceClocks(10_ms);
@@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(PutMultipleNack)
face.setInterestFilter("/", bind([&] { hasInterest2 = true; })); face.setInterestFilter("/", bind([&] { hasInterest2 = true; }));
advanceClocks(10_ms); advanceClocks(10_ms);
auto interest = makeInterest("/A", false, nullopt, 14333271); auto interest = makeInterest("/A", false, std::nullopt, 14333271);
face.receive(*interest); face.receive(*interest);
advanceClocks(10_ms); advanceClocks(10_ms);
BOOST_CHECK(hasInterest1); BOOST_CHECK(hasInterest1);
@@ -496,7 +496,7 @@ BOOST_AUTO_TEST_CASE(PutMultipleNackLoopback)
face.setInterestFilter(InterestFilter("/").allowLoopback(false), face.setInterestFilter(InterestFilter("/").allowLoopback(false),
bind([] { BOOST_ERROR("Unexpected Interest on second InterestFilter"); })); bind([] { BOOST_ERROR("Unexpected Interest on second InterestFilter"); }));
auto interest = makeInterest("/A", false, nullopt, 28395852); auto interest = makeInterest("/A", false, std::nullopt, 28395852);
face.expressInterest(*interest, face.expressInterest(*interest,
bind([] { BOOST_FAIL("Unexpected data"); }), bind([] { BOOST_FAIL("Unexpected data"); }),
[&] (const Interest&, const lp::Nack& nack) { [&] (const Interest&, const lp::Nack& nack) {
+16 -16
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -57,11 +57,11 @@ BOOST_AUTO_TEST_CASE(DefaultConstructor)
BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true);
BOOST_CHECK_EQUAL(i.hasNonce(), false); BOOST_CHECK_EQUAL(i.hasNonce(), false);
BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
BOOST_CHECK(i.getHopLimit() == nullopt); BOOST_CHECK(i.getHopLimit() == std::nullopt);
BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false);
BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false);
BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true);
BOOST_CHECK(i.getSignatureInfo() == nullopt); BOOST_CHECK(i.getSignatureInfo() == std::nullopt);
BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false);
BOOST_CHECK_EQUAL(i.isSigned(), false); BOOST_CHECK_EQUAL(i.isSigned(), false);
} }
@@ -96,10 +96,10 @@ BOOST_AUTO_TEST_CASE(Basic)
BOOST_CHECK_EQUAL(i2.hasNonce(), true); BOOST_CHECK_EQUAL(i2.hasNonce(), true);
BOOST_CHECK_EQUAL(i2.getNonce(), 0x01020304); BOOST_CHECK_EQUAL(i2.getNonce(), 0x01020304);
BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
BOOST_CHECK(i2.getHopLimit() == nullopt); BOOST_CHECK(i2.getHopLimit() == std::nullopt);
BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), false);
BOOST_CHECK_EQUAL(i2.getApplicationParameters().isValid(), false); BOOST_CHECK_EQUAL(i2.getApplicationParameters().isValid(), false);
BOOST_CHECK(i2.getSignatureInfo() == nullopt); BOOST_CHECK(i2.getSignatureInfo() == std::nullopt);
BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false);
BOOST_CHECK_EQUAL(i2.isSigned(), false); BOOST_CHECK_EQUAL(i2.isSigned(), false);
} }
@@ -140,10 +140,10 @@ BOOST_AUTO_TEST_CASE(WithParameters)
BOOST_CHECK_EQUAL(i2.hasNonce(), true); BOOST_CHECK_EQUAL(i2.hasNonce(), true);
BOOST_CHECK_EQUAL(i2.getNonce(), 0x1); BOOST_CHECK_EQUAL(i2.getNonce(), 0x1);
BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
BOOST_CHECK(i2.getHopLimit() == nullopt); BOOST_CHECK(i2.getHopLimit() == std::nullopt);
BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), true); BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), true);
BOOST_CHECK_EQUAL(i2.getApplicationParameters(), "2404C0C1C2C3"_block); BOOST_CHECK_EQUAL(i2.getApplicationParameters(), "2404C0C1C2C3"_block);
BOOST_CHECK(i2.getSignatureInfo() == nullopt); BOOST_CHECK(i2.getSignatureInfo() == std::nullopt);
BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false);
BOOST_CHECK_EQUAL(i2.isSigned(), false); BOOST_CHECK_EQUAL(i2.isSigned(), false);
} }
@@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(NameOnly)
BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true);
BOOST_CHECK_EQUAL(i.hasNonce(), false); BOOST_CHECK_EQUAL(i.hasNonce(), false);
BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
BOOST_CHECK(i.getHopLimit() == nullopt); BOOST_CHECK(i.getHopLimit() == std::nullopt);
BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false);
BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false);
@@ -422,7 +422,7 @@ BOOST_AUTO_TEST_CASE(NameCanBePrefix)
BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true);
BOOST_CHECK_EQUAL(i.hasNonce(), false); BOOST_CHECK_EQUAL(i.hasNonce(), false);
BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME);
BOOST_CHECK(i.getHopLimit() == nullopt); BOOST_CHECK(i.getHopLimit() == std::nullopt);
BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false);
BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false);
} }
@@ -789,7 +789,7 @@ BOOST_AUTO_TEST_CASE(SetNonce)
BOOST_CHECK_EQUAL(i2.getNonce(), 2); BOOST_CHECK_EQUAL(i2.getNonce(), 2);
BOOST_CHECK_EQUAL(i1.getNonce(), 1); // should not affect i1's Nonce (Bug #4168) BOOST_CHECK_EQUAL(i1.getNonce(), 1); // should not affect i1's Nonce (Bug #4168)
i2.setNonce(nullopt); i2.setNonce(std::nullopt);
BOOST_CHECK(!i2.hasNonce()); BOOST_CHECK(!i2.hasNonce());
} }
@@ -852,11 +852,11 @@ BOOST_AUTO_TEST_CASE(SetInterestLifetime)
BOOST_AUTO_TEST_CASE(SetHopLimit) BOOST_AUTO_TEST_CASE(SetHopLimit)
{ {
Interest i; Interest i;
BOOST_CHECK(i.getHopLimit() == nullopt); BOOST_CHECK(i.getHopLimit() == std::nullopt);
i.setHopLimit(42); i.setHopLimit(42);
BOOST_CHECK(i.getHopLimit() == 42); BOOST_CHECK(i.getHopLimit() == 42);
i.setHopLimit(nullopt); i.setHopLimit(std::nullopt);
BOOST_CHECK(i.getHopLimit() == nullopt); BOOST_CHECK(i.getHopLimit() == std::nullopt);
} }
BOOST_AUTO_TEST_CASE(SetApplicationParameters) BOOST_AUTO_TEST_CASE(SetApplicationParameters)
@@ -901,7 +901,7 @@ BOOST_AUTO_TEST_CASE(SetSignature)
return e.what() == "InterestSignatureInfo must be present to set InterestSignatureValue"s; return e.what() == "InterestSignatureInfo must be present to set InterestSignatureValue"s;
}); });
BOOST_CHECK(i.getSignatureInfo() == nullopt); BOOST_CHECK(i.getSignatureInfo() == std::nullopt);
BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false);
BOOST_CHECK_EQUAL(i.isSigned(), false); BOOST_CHECK_EQUAL(i.isSigned(), false);
@@ -1010,7 +1010,7 @@ BOOST_AUTO_TEST_CASE(ParametersSha256DigestComponent)
BOOST_CHECK(i.getSignatureInfo() == si); BOOST_CHECK(i.getSignatureInfo() == si);
i.unsetApplicationParameters(); // removes ParametersSha256DigestComponent and InterestSignatureInfo i.unsetApplicationParameters(); // removes ParametersSha256DigestComponent and InterestSignatureInfo
BOOST_CHECK(i.getSignatureInfo() == nullopt); BOOST_CHECK(i.getSignatureInfo() == std::nullopt);
BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false);
BOOST_CHECK_EQUAL(i.getName(), "/A/B/C"); BOOST_CHECK_EQUAL(i.getName(), "/A/B/C");
@@ -1157,7 +1157,7 @@ BOOST_AUTO_TEST_CASE(ToUri)
i.setCanBePrefix(false); i.setCanBePrefix(false);
i.setMustBeFresh(false); i.setMustBeFresh(false);
i.setHopLimit(nullopt); i.setHopLimit(std::nullopt);
i.setApplicationParameters("2402CAFE"_block); i.setApplicationParameters("2402CAFE"_block);
BOOST_CHECK_EQUAL(i.toUri(), BOOST_CHECK_EQUAL(i.toUri(),
"/foo/params-sha256=8621f5e8321f04104640c8d02877d7c5142cad6e203c5effda1783b1a0e476d6" "/foo/params-sha256=8621f5e8321f04104640c8d02877d7c5142cad6e203c5effda1783b1a0e476d6"
+2 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -20,7 +20,6 @@
*/ */
#include "ndn-cxx/meta-info.hpp" #include "ndn-cxx/meta-info.hpp"
#include "ndn-cxx/data.hpp"
#include "tests/boost-test.hpp" #include "tests/boost-test.hpp"
@@ -35,7 +34,7 @@ BOOST_AUTO_TEST_CASE(EncodeDecode)
MetaInfo a("1406 type=180100 freshness=190100"_block); MetaInfo a("1406 type=180100 freshness=190100"_block);
BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob); BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob);
BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms); BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms);
BOOST_CHECK(a.getFinalBlock() == nullopt); BOOST_CHECK(a.getFinalBlock() == std::nullopt);
MetaInfo b; MetaInfo b;
BOOST_CHECK_NE(a.wireEncode(), b.wireEncode()); BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());
+4 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -43,7 +43,7 @@ public:
} }
void void
checkFindByInterest(const Name& name, bool canBePrefix, optional<Certificate> expected) const checkFindByInterest(const Name& name, bool canBePrefix, std::optional<Certificate> expected) const
{ {
Interest interest(name); Interest interest(name);
interest.setCanBePrefix(canBePrefix); interest.setCanBePrefix(canBePrefix);
@@ -95,10 +95,10 @@ BOOST_AUTO_TEST_CASE(FindByInterest)
checkFindByInterest(cert.getIdentity(), true, cert); checkFindByInterest(cert.getIdentity(), true, cert);
checkFindByInterest(cert.getKeyName(), true, cert); checkFindByInterest(cert.getKeyName(), true, cert);
checkFindByInterest(cert.getName(), false, cert); checkFindByInterest(cert.getName(), false, cert);
checkFindByInterest(Name(cert.getName()).appendVersion(), true, nullopt); checkFindByInterest(Name(cert.getName()).appendVersion(), true, std::nullopt);
advanceClocks(12_s); advanceClocks(12_s);
checkFindByInterest(cert.getIdentity(), true, nullopt); checkFindByInterest(cert.getIdentity(), true, std::nullopt);
} }
BOOST_AUTO_TEST_SUITE_END() // TestCertificateCache BOOST_AUTO_TEST_SUITE_END() // TestCertificateCache
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -366,7 +366,7 @@ Signature Information:
sigInfo.removeCustomTlv(tlv::AdditionalDescription); sigInfo.removeCustomTlv(tlv::AdditionalDescription);
sigInfo.addCustomTlv(makeStringBlock(tlv::ValidityPeriod, "malformed")); sigInfo.addCustomTlv(makeStringBlock(tlv::ValidityPeriod, "malformed"));
sigInfo.setSignatureType(tlv::DigestSha256); sigInfo.setSignatureType(tlv::DigestSha256);
sigInfo.setKeyLocator(nullopt); sigInfo.setKeyLocator(std::nullopt);
Certificate cert6(cert3); Certificate cert6(cert3);
cert6.setSignatureInfo(sigInfo); cert6.setSignatureInfo(sigInfo);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(cert6), expected6); BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(cert6), expected6);
+7 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -427,7 +427,7 @@ struct AsymmetricSigningBase : protected KeyChainFixture, protected PacketType
const uint32_t expectedSigType = SignatureTypeTlvValue; const uint32_t expectedSigType = SignatureTypeTlvValue;
const bool shouldHaveKeyLocator = true; const bool shouldHaveKeyLocator = true;
const optional<KeyLocator> expectedKeyLocator = cert.getName(); const std::optional<KeyLocator> expectedKeyLocator = cert.getName();
bool bool
verify(const SigningInfo&) const verify(const SigningInfo&) const
@@ -504,7 +504,7 @@ struct HmacSigning : protected KeyChainFixture, protected PacketType
const uint32_t expectedSigType = SignatureTypeTlvValue; const uint32_t expectedSigType = SignatureTypeTlvValue;
const bool shouldHaveKeyLocator = true; const bool shouldHaveKeyLocator = true;
const optional<KeyLocator> expectedKeyLocator = nullopt; // don't check KeyLocator value const std::optional<KeyLocator> expectedKeyLocator = std::nullopt; // don't check KeyLocator value
bool bool
verify(const SigningInfo& si) const verify(const SigningInfo& si) const
@@ -524,12 +524,12 @@ struct Sha256Signing : protected KeyChainFixture, protected PacketType
const uint32_t expectedSigType = tlv::DigestSha256; const uint32_t expectedSigType = tlv::DigestSha256;
const bool shouldHaveKeyLocator = false; const bool shouldHaveKeyLocator = false;
const optional<KeyLocator> expectedKeyLocator = nullopt; const std::optional<KeyLocator> expectedKeyLocator = std::nullopt;
bool bool
verify(const SigningInfo&) const verify(const SigningInfo&) const
{ {
return verifySignature(this->packet, nullopt); return verifySignature(this->packet, std::nullopt);
} }
}; };
@@ -591,7 +591,8 @@ public:
} }
void void
checkKeyLocatorName(const Certificate& cert, const optional<Name>& klName = nullopt) const checkKeyLocatorName(const Certificate& cert,
const std::optional<Name>& klName = std::nullopt) const
{ {
auto kl = cert.getKeyLocator(); auto kl = cert.getKeyLocator();
if (!kl.has_value()) { if (!kl.has_value()) {
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -20,7 +20,6 @@
*/ */
#include "ndn-cxx/security/trust-anchor-container.hpp" #include "ndn-cxx/security/trust-anchor-container.hpp"
#include "ndn-cxx/util/io.hpp"
#include "tests/boost-test.hpp" #include "tests/boost-test.hpp"
#include "tests/key-chain-fixture.hpp" #include "tests/key-chain-fixture.hpp"
@@ -61,7 +60,7 @@ public:
} }
void void
checkFindByInterest(const Name& name, bool canBePrefix, optional<Certificate> expected) const checkFindByInterest(const Name& name, bool canBePrefix, std::optional<Certificate> expected) const
{ {
Interest interest(name); Interest interest(name);
interest.setCanBePrefix(canBePrefix); interest.setCanBePrefix(canBePrefix);
@@ -172,7 +171,7 @@ BOOST_AUTO_TEST_CASE(FindByInterest)
checkFindByInterest(identity1.getName().getPrefix(-1), true, cert1); checkFindByInterest(identity1.getName().getPrefix(-1), true, cert1);
checkFindByInterest(cert1.getKeyName(), true, cert1); checkFindByInterest(cert1.getKeyName(), true, cert1);
checkFindByInterest(cert1.getName(), false, cert1); checkFindByInterest(cert1.getName(), false, cert1);
checkFindByInterest(Name(identity1.getName()).appendVersion(), true, nullopt); checkFindByInterest(Name(identity1.getName()).appendVersion(), true, std::nullopt);
auto makeIdentity1Cert = [=] (const std::string& issuerId) { auto makeIdentity1Cert = [=] (const std::string& issuerId) {
auto key = identity1.getDefaultKey(); auto key = identity1.getDefaultKey();
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -64,16 +64,16 @@ class ValidationPolicyCommandInterestFixture
{ {
protected: protected:
Interest Interest
makeCommandInterest(const Identity& identity, SignedInterestFormat format = SignedInterestFormat::V02) makeCommandInterest(const Identity& id, SignedInterestFormat format = SignedInterestFormat::V02)
{ {
Name name = identity.getName(); Name name = id.getName();
name.append("CMD"); name.append("CMD");
switch (format) { switch (format) {
case SignedInterestFormat::V02: case SignedInterestFormat::V02:
return m_signer.makeCommandInterest(name, signingByIdentity(identity)); return m_signer.makeCommandInterest(name, signingByIdentity(id));
case SignedInterestFormat::V03: { case SignedInterestFormat::V03: {
Interest interest(name); Interest interest(name);
m_signer.makeSignedInterest(interest, signingByIdentity(identity)); m_signer.makeSignedInterest(interest, signingByIdentity(id));
return interest; return interest;
} }
} }
@@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(BadTimestampV03)
{ {
auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03); auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03);
auto si = i1.getSignatureInfo().value(); auto si = i1.getSignatureInfo().value();
si.setTime(nullopt); si.setTime(std::nullopt);
i1.setSignatureInfo(si); i1.setSignatureInfo(si);
VALIDATE_FAILURE(i1, "Should fail (timestamp is missing)"); VALIDATE_FAILURE(i1, "Should fail (timestamp is missing)");
BOOST_TEST(lastError.getCode() == ValidationError::POLICY_ERROR); BOOST_TEST(lastError.getCode() == ValidationError::POLICY_ERROR);
@@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(MissingKeyLocatorV03)
{ {
auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03); auto i1 = makeCommandInterest(identity, SignedInterestFormat::V03);
auto si = i1.getSignatureInfo().value(); auto si = i1.getSignatureInfo().value();
si.setKeyLocator(nullopt); si.setKeyLocator(std::nullopt);
i1.setSignatureInfo(si); i1.setSignatureInfo(si);
VALIDATE_FAILURE(i1, "Should fail (missing KeyLocator)"); VALIDATE_FAILURE(i1, "Should fail (missing KeyLocator)");
BOOST_TEST(lastError.getCode() == ValidationError::INVALID_KEY_LOCATOR); BOOST_TEST(lastError.getCode() == ValidationError::INVALID_KEY_LOCATOR);
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -158,7 +158,7 @@ public:
private: private:
void void
verifyOriginalPacket(const optional<Certificate>&) override verifyOriginalPacket(const std::optional<Certificate>&) override
{ {
// do nothing // do nothing
} }
+12 -12
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -632,21 +632,21 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(VerifyDigest, Dataset, DigestDatasets)
Interest interestOldFormat(dataset.goodInterestOldFormat); Interest interestOldFormat(dataset.goodInterestOldFormat);
Interest badSigInterestOldFormat(dataset.badSigInterestOldFormat); Interest badSigInterestOldFormat(dataset.badSigInterestOldFormat);
BOOST_CHECK(verifySignature(data, nullopt)); BOOST_CHECK(verifySignature(data, std::nullopt));
BOOST_CHECK(verifySignature(interest, nullopt)); BOOST_CHECK(verifySignature(interest, std::nullopt));
BOOST_CHECK(verifySignature(interestOldFormat, nullopt)); BOOST_CHECK(verifySignature(interestOldFormat, std::nullopt));
BOOST_CHECK(!verifySignature(badSigData, nullopt)); BOOST_CHECK(!verifySignature(badSigData, std::nullopt));
BOOST_CHECK(!verifySignature(badSigInterest, nullopt)); BOOST_CHECK(!verifySignature(badSigInterest, std::nullopt));
BOOST_CHECK(!verifySignature(badSigInterestOldFormat, nullopt)); BOOST_CHECK(!verifySignature(badSigInterestOldFormat, std::nullopt));
Data unsignedData("/some/data"); Data unsignedData("/some/data");
Interest unsignedInterest1("/some/interest/with/several/name/components"); Interest unsignedInterest1("/some/interest/with/several/name/components");
Interest unsignedInterest2("/interest-with-one-name-component"); Interest unsignedInterest2("/interest-with-one-name-component");
BOOST_CHECK(!verifySignature(unsignedData, nullopt)); BOOST_CHECK(!verifySignature(unsignedData, std::nullopt));
BOOST_CHECK(!verifySignature(unsignedInterest1, nullopt)); BOOST_CHECK(!verifySignature(unsignedInterest1, std::nullopt));
BOOST_CHECK(!verifySignature(unsignedInterest2, nullopt)); BOOST_CHECK(!verifySignature(unsignedInterest2, std::nullopt));
} }
const uint8_t sha256DataUnrecognizedElements[] = { const uint8_t sha256DataUnrecognizedElements[] = {
@@ -673,8 +673,8 @@ BOOST_AUTO_TEST_CASE(VerifyWithUnrecognizedElements) // Bug #4583
Data data(Block{sha256DataUnrecognizedElements}); Data data(Block{sha256DataUnrecognizedElements});
Interest interest(Block{sha256InterestUnrecognizedElements}); Interest interest(Block{sha256InterestUnrecognizedElements});
BOOST_CHECK(verifySignature(data, nullopt)); BOOST_CHECK(verifySignature(data, std::nullopt));
BOOST_CHECK(verifySignature(interest, nullopt)); BOOST_CHECK(verifySignature(interest, std::nullopt));
} }
BOOST_AUTO_TEST_SUITE_END() // TestVerificationHelpers BOOST_AUTO_TEST_SUITE_END() // TestVerificationHelpers
+6 -6
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* /*
* Copyright (c) 2013-2022 Regents of the University of California. * Copyright (c) 2013-2023 Regents of the University of California.
* *
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
* *
@@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(KeyLocatorField)
info.wireEncode(); info.wireEncode();
BOOST_CHECK_EQUAL(info.hasWire(), true); BOOST_CHECK_EQUAL(info.hasWire(), true);
info.setKeyLocator(nullopt); info.setKeyLocator(std::nullopt);
BOOST_CHECK_EQUAL(info.hasKeyLocator(), false); BOOST_CHECK_EQUAL(info.hasKeyLocator(), false);
BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error); BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error);
BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK_EQUAL(info.hasWire(), false);
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(SignatureNonce)
info.wireEncode(); info.wireEncode();
BOOST_CHECK_EQUAL(info.hasWire(), true); BOOST_CHECK_EQUAL(info.hasWire(), true);
info.setNonce(nullopt); info.setNonce(std::nullopt);
BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK_EQUAL(info.hasWire(), false);
BOOST_CHECK(!info.getNonce()); BOOST_CHECK(!info.getNonce());
} }
@@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(SignatureTime)
info.wireEncode(); info.wireEncode();
BOOST_CHECK_EQUAL(info.hasWire(), true); BOOST_CHECK_EQUAL(info.hasWire(), true);
info.setTime(nullopt); info.setTime(std::nullopt);
BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK_EQUAL(info.hasWire(), false);
BOOST_CHECK(!info.getTime()); BOOST_CHECK(!info.getTime());
} }
@@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(SignatureSeqNum)
info.wireEncode(); info.wireEncode();
BOOST_CHECK_EQUAL(info.hasWire(), true); BOOST_CHECK_EQUAL(info.hasWire(), true);
info.setSeqNum(nullopt); info.setSeqNum(std::nullopt);
BOOST_CHECK_EQUAL(info.hasWire(), false); BOOST_CHECK_EQUAL(info.hasWire(), false);
BOOST_CHECK(!info.getSeqNum()); BOOST_CHECK(!info.getSeqNum());
} }
@@ -452,7 +452,7 @@ BOOST_AUTO_TEST_CASE(ValidityPeriod)
info2.wireEncode(); info2.wireEncode();
BOOST_CHECK_EQUAL(info2.hasWire(), true); BOOST_CHECK_EQUAL(info2.hasWire(), true);
info2.setValidityPeriod(nullopt); info2.setValidityPeriod(std::nullopt);
BOOST_CHECK_THROW(info2.getValidityPeriod(), SignatureInfo::Error); BOOST_CHECK_THROW(info2.getValidityPeriod(), SignatureInfo::Error);
BOOST_CHECK_EQUAL(info2.hasWire(), false); BOOST_CHECK_EQUAL(info2.hasWire(), false);
} }