interest+data: convert to span
Update span-lite to commit 8f7935ff4e502ee023990d356d6578b8293eda74
Change-Id: I511bc3541e8ba683661bc69656e83088dd06e97a
diff --git a/ndn-cxx/data.cpp b/ndn-cxx/data.cpp
index db0b745..fff95b8 100644
--- a/ndn-cxx/data.cpp
+++ b/ndn-cxx/data.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -259,15 +259,21 @@
}
Data&
+Data::setContent(span<const uint8_t> value)
+{
+ m_content = makeBinaryBlock(tlv::Content, value.data(), value.size());
+ resetWire();
+ return *this;
+}
+
+Data&
Data::setContent(const uint8_t* value, size_t length)
{
if (value == nullptr && length != 0) {
NDN_THROW(std::invalid_argument("Content buffer cannot be nullptr"));
}
- m_content = makeBinaryBlock(tlv::Content, value, length);
- resetWire();
- return *this;
+ return setContent(make_span(value, length));
}
Data&
diff --git a/ndn-cxx/data.hpp b/ndn-cxx/data.hpp
index beca2cd..c75e138 100644
--- a/ndn-cxx/data.hpp
+++ b/ndn-cxx/data.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -184,11 +184,21 @@
setContent(const Block& block);
/**
+ * @brief Set Content by copying from a contiguous sequence of bytes
+ * @param value buffer with the TLV-VALUE of the content
+ * @return a reference to this Data, to allow chaining
+ */
+ Data&
+ setContent(span<const uint8_t> value);
+
+ /**
* @brief Set Content by copying from a raw buffer
* @param value buffer with the TLV-VALUE of the content; may be nullptr if @p length is zero
* @param length size of the buffer
* @return a reference to this Data, to allow chaining
+ * @deprecated Use setContent(span<const uint8_t>)
*/
+ [[deprecated("use the overload that takes a span<>")]]
Data&
setContent(const uint8_t* value, size_t length);
diff --git a/ndn-cxx/detail/nonstd/span-lite.hpp b/ndn-cxx/detail/nonstd/span-lite.hpp
index 17f87c8..4382f99 100644
--- a/ndn-cxx/detail/nonstd/span-lite.hpp
+++ b/ndn-cxx/detail/nonstd/span-lite.hpp
@@ -1068,40 +1068,42 @@
#if !span_BETWEEN( span_COMPILER_MSVC_VERSION, 120, 130 )
-#if span_COMPILER_GNUC_VERSION >= 900
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Winit-list-lifetime"
-#endif
template< extent_t U = Extent
span_REQUIRES_T((
U != dynamic_extent
))
>
+#if span_COMPILER_GNUC_VERSION >= 900 // prevent GCC's "-Winit-list-lifetime"
+ span_constexpr14 explicit span( std::initializer_list<value_type> il ) span_noexcept
+ {
+ data_ = il.begin();
+ size_ = il.size();
+ }
+#else
span_constexpr explicit span( std::initializer_list<value_type> il ) span_noexcept
: data_( il.begin() )
, size_( il.size() )
{}
-#if span_COMPILER_GNUC_VERSION >= 900
-# pragma GCC diagnostic pop
#endif
#endif // MSVC 120 (VS2013)
-#if span_COMPILER_GNUC_VERSION >= 900
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Winit-list-lifetime"
-#endif
template< extent_t U = Extent
span_REQUIRES_T((
U == dynamic_extent
))
>
+#if span_COMPILER_GNUC_VERSION >= 900 // prevent GCC's "-Winit-list-lifetime"
+ span_constexpr14 /*explicit*/ span( std::initializer_list<value_type> il ) span_noexcept
+ {
+ data_ = il.begin();
+ size_ = il.size();
+ }
+#else
span_constexpr /*explicit*/ span( std::initializer_list<value_type> il ) span_noexcept
: data_( il.begin() )
, size_( il.size() )
{}
-#if span_COMPILER_GNUC_VERSION >= 900
-# pragma GCC diagnostic pop
#endif
#endif // P2447
diff --git a/ndn-cxx/interest.cpp b/ndn-cxx/interest.cpp
index ea0302c..66e240a 100644
--- a/ndn-cxx/interest.cpp
+++ b/ndn-cxx/interest.cpp
@@ -492,16 +492,22 @@
}
Interest&
+Interest::setApplicationParameters(span<const uint8_t> value)
+{
+ setApplicationParametersInternal(makeBinaryBlock(tlv::ApplicationParameters, value.data(), value.size()));
+ addOrReplaceParametersDigestComponent();
+ m_wire.reset();
+ return *this;
+}
+
+Interest&
Interest::setApplicationParameters(const uint8_t* value, size_t length)
{
if (value == nullptr && length != 0) {
NDN_THROW(std::invalid_argument("ApplicationParameters buffer cannot be nullptr"));
}
- setApplicationParametersInternal(makeBinaryBlock(tlv::ApplicationParameters, value, length));
- addOrReplaceParametersDigestComponent();
- m_wire.reset();
- return *this;
+ return setApplicationParameters(make_span(value, length));
}
Interest&
diff --git a/ndn-cxx/interest.hpp b/ndn-cxx/interest.hpp
index 4abfe0c..e470aa8 100644
--- a/ndn-cxx/interest.hpp
+++ b/ndn-cxx/interest.hpp
@@ -96,7 +96,7 @@
friend std::ostream&
operator<<(std::ostream& os, const Nonce& nonce)
{
- printHex(os, nonce.data(), nonce.size(), false);
+ printHex(os, nonce, false);
return os;
}
};
@@ -345,10 +345,8 @@
setApplicationParameters(const Block& block);
/**
- * @brief Set ApplicationParameters by copying from a raw buffer.
- * @param value points to a buffer from which the TLV-VALUE of the parameters will be copied;
- * may be nullptr if @p length is zero
- * @param length size of the buffer
+ * @brief Set ApplicationParameters by copying from a contiguous sequence of bytes.
+ * @param value buffer from which the TLV-VALUE of the parameters will be copied
* @return a reference to this Interest
*
* This function will also recompute the value of the ParametersSha256DigestComponent in the
@@ -356,6 +354,22 @@
* be appended to it.
*/
Interest&
+ setApplicationParameters(span<const uint8_t> value);
+
+ /**
+ * @brief Set ApplicationParameters by copying from a raw buffer.
+ * @param value points to a buffer from which the TLV-VALUE of the parameters will be copied;
+ * may be nullptr if @p length is zero
+ * @param length size of the buffer
+ * @return a reference to this Interest
+ * @deprecated Use setApplicationParameters(span<const uint8_t>)
+ *
+ * This function will also recompute the value of the ParametersSha256DigestComponent in the
+ * Interest's name. If the name does not contain a ParametersSha256DigestComponent, one will
+ * be appended to it.
+ */
+ [[deprecated("use the overload that takes a span<>")]]
+ Interest&
setApplicationParameters(const uint8_t* value, size_t length);
/**
diff --git a/ndn-cxx/link.cpp b/ndn-cxx/link.cpp
index 54e9321..9110bf8 100644
--- a/ndn-cxx/link.cpp
+++ b/ndn-cxx/link.cpp
@@ -50,11 +50,11 @@
setContentType(tlv::ContentType_Link);
if (m_delegations.empty()) {
- setContent(nullptr, 0);
- return;
+ setContent(span<uint8_t>{});
}
-
- setContent(makeNestedBlock(tlv::Content, m_delegations.begin(), m_delegations.end()));
+ else {
+ setContent(makeNestedBlock(tlv::Content, m_delegations.begin(), m_delegations.end()));
+ }
}
void
diff --git a/ndn-cxx/meta-info.hpp b/ndn-cxx/meta-info.hpp
index 9503e44..a4155cd 100644
--- a/ndn-cxx/meta-info.hpp
+++ b/ndn-cxx/meta-info.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -35,26 +35,25 @@
const time::milliseconds DEFAULT_FRESHNESS_PERIOD = time::milliseconds::zero();
/**
- * A MetaInfo holds the meta info which is signed inside the data packet.
+ * @brief A MetaInfo holds the meta info which is signed inside the data packet.
*
- * The class allows experimentation with application-defined meta information blocks,
- * which slightly violates NDN-TLV specification. When using the application-defined
- * meta information blocks be aware that this may result in packet drop (NFD and
- * previous versions of ndn-cxx will gracefully accept such packet).
+ * The class allows experimentation with application-defined meta-information elements.
+ * When using these application-defined elements, be aware that it may result in dropped
+ * packets (NFD and previous versions of ndn-cxx will gracefully accept such packets).
*
- * The following definition of MetaInfo block is assumed in this implementation (compared
- * to the NDN-TLV spec, definition extended to allow optional AppMetaInfo TLV blocks):
+ * The following definition of the MetaInfo element is assumed in this implementation (compared
+ * to the NDN-TLV spec, the definition is extended to allow optional AppMetaInfo elements):
*
- * MetaInfo ::= META-INFO-TYPE TLV-LENGTH
- * ContentType?
- * FreshnessPeriod?
- * FinalBlockId?
- * AppMetaInfo*
+ * MetaInfo = META-INFO-TYPE TLV-LENGTH
+ * [ContentType]
+ * [FreshnessPeriod]
+ * [FinalBlockId]
+ * *AppMetaInfo
*
- * AppMetaInfo ::= any TLV block with type in the restricted application range [128, 252]
+ * Note that AppMetaInfo elements are application-defined and must have a TLV-TYPE inside
+ * the range reserved for application use, i.e., `[128, 252]`.
*
- * Note that AppMetaInfo blocks are application-defined and must have TLV type from
- * the restricted application range [128, 252].
+ * @sa https://named-data.net/doc/NDN-packet-spec/0.3/data.html#metainfo
*/
class MetaInfo
{
@@ -133,8 +132,6 @@
/**
* @brief Get all app-defined MetaInfo items
*
- * @note Warning: Experimental API, which may change or disappear in the future
- *
* @note If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock
* is called before *AppMetaInfo, all app-defined blocks will be lost
*/
@@ -147,9 +144,7 @@
* This method will replace all existing app-defined MetaInfo items, if they existed.
*
* @throw Error if some block in @p info has type not in the application range
- * (http://named-data.net/doc/ndn-tlv/types.html)
- *
- * @note Warning: Experimental API, which may change or disappear in the future
+ * (https://named-data.net/doc/NDN-packet-spec/0.3/types.html)
*
* @note If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock
* is called before *AppMetaInfo, all app-defined blocks will be lost
@@ -161,9 +156,7 @@
* @brief Add an app-defined MetaInfo item
*
* @throw Error if @p block has type not in the application range
- * (http://named-data.net/doc/ndn-tlv/types.html)
- *
- * @note Warning: Experimental API, which may change or disappear in the future
+ * (https://named-data.net/doc/NDN-packet-spec/0.3/types.html)
*
* @note If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock
* is called before *AppMetaInfo, all app-defined blocks will be lost
@@ -176,8 +169,6 @@
*
* @return true if an item was deleted
*
- * @note Warning: Experimental API, which may change or disappear in the future
- *
* @note If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock
* is called before *AppMetaInfo, all app-defined blocks will be lost
*/
@@ -190,9 +181,7 @@
* @return NULL if an item is not found, otherwise const pointer to the item
*
* @throw Error if @p tlvType is not in the application range
- * (http://named-data.net/doc/ndn-tlv/types.html)
- *
- * @note Warning: Experimental API, which may change or disappear in the future
+ * (https://named-data.net/doc/NDN-packet-spec/0.3/types.html)
*
* @note If MetaInfo is decoded from wire and setType, setFreshnessPeriod, or setFinalBlock
* is called before *AppMetaInfo, all app-defined blocks will be lost
diff --git a/ndn-cxx/security/key-chain.cpp b/ndn-cxx/security/key-chain.cpp
index 1c649dc..0b55c91 100644
--- a/ndn-cxx/security/key-chain.cpp
+++ b/ndn-cxx/security/key-chain.cpp
@@ -576,7 +576,7 @@
certificate.setFreshnessPeriod(1_h);
// set content
- certificate.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+ certificate.setContent(key.getPublicKey());
// set signature-info
SignatureInfo signatureInfo;
diff --git a/ndn-cxx/security/transform/buffer-source.cpp b/ndn-cxx/security/transform/buffer-source.cpp
index 515964f..ea2b3d2 100644
--- a/ndn-cxx/security/transform/buffer-source.cpp
+++ b/ndn-cxx/security/transform/buffer-source.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -53,7 +53,7 @@
for (auto buffer : m_bufs) {
while (!buffer.empty()) {
size_t nBytesWritten = m_next->write(buffer);
- buffer = buffer.last(buffer.size() - nBytesWritten);
+ buffer = buffer.subspan(nBytesWritten);
}
}
diff --git a/ndn-cxx/security/transform/transform-base.cpp b/ndn-cxx/security/transform/transform-base.cpp
index aa6de28..731b22c 100644
--- a/ndn-cxx/security/transform/transform-base.cpp
+++ b/ndn-cxx/security/transform/transform-base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -70,7 +70,7 @@
if (isOutputBufferEmpty())
return;
- size_t nWritten = m_next->write(make_span(*m_oBuffer).last(m_oBuffer->size() - m_outputOffset));
+ size_t nWritten = m_next->write(make_span(*m_oBuffer).subspan(m_outputOffset));
m_outputOffset += nWritten;
}
diff --git a/tests/key-chain-fixture.cpp b/tests/key-chain-fixture.cpp
index 92518a3..73e27c4 100644
--- a/tests/key-chain-fixture.cpp
+++ b/tests/key-chain-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -56,7 +56,7 @@
cert.setFreshnessPeriod(1_h);
// set content
- cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+ cert.setContent(key.getPublicKey());
// set signature info
ndn::SignatureInfo info;
diff --git a/tests/unit/data.t.cpp b/tests/unit/data.t.cpp
index d6bb6bb..2ab660e 100644
--- a/tests/unit/data.t.cpp
+++ b/tests/unit/data.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -182,7 +182,7 @@
Data d("/local/ndn/prefix");
d.setContentType(tlv::ContentType_Blob);
d.setFreshnessPeriod(10_s);
- d.setContent(CONTENT1, sizeof(CONTENT1));
+ d.setContent(CONTENT1);
SignatureInfo signatureInfo;
signatureInfo.setSignatureType(tlv::SignatureSha256WithRsa);
@@ -397,7 +397,7 @@
Data d(Name("/local/ndn/prefix"));
d.setContentType(tlv::ContentType_Blob);
d.setFreshnessPeriod(10_s);
- d.setContent(CONTENT1, sizeof(CONTENT1));
+ d.setContent(CONTENT1);
BOOST_CHECK_THROW(d.getFullName(), Data::Error); // FullName is unavailable without signing
m_keyChain.sign(d);
@@ -527,16 +527,17 @@
// Block overload, default constructed (invalid)
BOOST_CHECK_THROW(d.setContent(Block{}), std::invalid_argument);
- // raw buffer overload
- d.setContent(nested, sizeof(nested));
+ // span overload
+ d.setContent(nested);
BOOST_CHECK_EQUAL(d.hasContent(), true);
BOOST_CHECK_EQUAL(d.getContent().type(), tlv::Content);
BOOST_CHECK_EQUAL_COLLECTIONS(d.getContent().value_begin(), d.getContent().value_end(),
nested, nested + sizeof(nested));
- d.setContent(nullptr, 0);
+ d.setContent(span<uint8_t>{});
BOOST_CHECK_EQUAL(d.hasContent(), true);
BOOST_CHECK_EQUAL(d.getContent().type(), tlv::Content);
BOOST_CHECK_EQUAL(d.getContent().value_size(), 0);
+ // raw buffer overload (deprecated)
BOOST_CHECK_THROW(d.setContent(nullptr, 1), std::invalid_argument);
// ConstBufferPtr overload
@@ -631,11 +632,11 @@
BOOST_CHECK_EQUAL(a != b, false);
static const uint8_t someData[] = "someData";
- a.setContent(someData, sizeof(someData));
+ a.setContent(someData);
BOOST_CHECK_EQUAL(a == b, false);
BOOST_CHECK_EQUAL(a != b, true);
- b.setContent(someData, sizeof(someData));
+ b.setContent(someData);
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
diff --git a/tests/unit/ims/in-memory-storage.t.cpp b/tests/unit/ims/in-memory-storage.t.cpp
index 594837b..54ceeb0 100644
--- a/tests/unit/ims/in-memory-storage.t.cpp
+++ b/tests/unit/ims/in-memory-storage.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -62,17 +62,17 @@
Name name("/a");
- uint32_t content1 = 1;
- shared_ptr<Data> data1 = makeData(name);
+ const uint8_t content1[] = {1, 2, 3, 4};
+ auto data1 = makeData(name);
data1->setFreshnessPeriod(99999_ms);
- data1->setContent(reinterpret_cast<const uint8_t*>(&content1), sizeof(content1));
+ data1->setContent(content1);
signData(data1);
ims.insert(*data1);
- uint32_t content2 = 2;
- shared_ptr<Data> data2 = makeData(name);
+ const uint8_t content2[] = {5, 6, 7, 8};
+ auto data2 = makeData(name);
data2->setFreshnessPeriod(99999_ms);
- data2->setContent(reinterpret_cast<const uint8_t*>(&content2), sizeof(content2));
+ data2->setContent(content2);
signData(data2);
ims.insert(*data2);
@@ -186,15 +186,15 @@
T ims;
Name name("/a");
- uint32_t content1 = 1;
- shared_ptr<Data> data1 = makeData(name);
- data1->setContent(reinterpret_cast<const uint8_t*>(&content1), sizeof(content1));
+ const uint8_t content1[] = {1, 2, 3, 4};
+ auto data1 = makeData(name);
+ data1->setContent(content1);
signData(data1);
ims.insert(*data1);
- uint32_t content2 = 2;
- shared_ptr<Data> data2 = makeData(name);
- data2->setContent(reinterpret_cast<const uint8_t*>(&content2), sizeof(content2));
+ const uint8_t content2[] = {5, 6, 7, 8};
+ auto data2 = makeData(name);
+ data2->setContent(content2);
signData(data2);
auto found = ims.find(data2->getFullName());
@@ -207,17 +207,17 @@
Name name("/insertandremovebyname");
- uint32_t content1 = 1;
- shared_ptr<Data> data1 = makeData(name);
+ const uint8_t content1[] = {1, 2, 3, 4};
+ auto data1 = makeData(name);
data1->setFreshnessPeriod(99999_ms);
- data1->setContent(reinterpret_cast<const uint8_t*>(&content1), sizeof(content1));
+ data1->setContent(content1);
signData(data1);
ims.insert(*data1);
- uint32_t content2 = 2;
- shared_ptr<Data> data2 = makeData(name);
+ const uint8_t content2[] = {5, 6, 7, 8};
+ auto data2 = makeData(name);
data2->setFreshnessPeriod(99999_ms);
- data2->setContent(reinterpret_cast<const uint8_t*>(&content2), sizeof(content2));
+ data2->setContent(content2);
signData(data2);
ims.insert(*data2);
@@ -451,7 +451,7 @@
const time::milliseconds& freshWindow = InMemoryStorage::INFINITE_WINDOW)
{
auto data = makeData(name);
- data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
+ data->setContent(make_span(reinterpret_cast<const uint8_t*>(&id), sizeof(id)));
if (modifyData != nullptr) {
modifyData(*data);
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index 482eac8..d36e0a9 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -889,11 +889,12 @@
BOOST_CHECK_EQUAL(i.getApplicationParameters(), "24038001C1"_block);
BOOST_CHECK_THROW(i.setApplicationParameters(Block{}), std::invalid_argument);
- // raw buffer+size overload
- i.setApplicationParameters(PARAMETERS1, sizeof(PARAMETERS1));
+ // span overload
+ i.setApplicationParameters(PARAMETERS1);
BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2401C1"_block);
- i.setApplicationParameters(nullptr, 0);
+ i.setApplicationParameters(span<uint8_t>{});
BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2400"_block);
+ // raw buffer+size overload (deprecated)
BOOST_CHECK_THROW(i.setApplicationParameters(nullptr, 42), std::invalid_argument);
// ConstBufferPtr overload
@@ -983,7 +984,7 @@
"/I/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a");
BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true);
- i.setApplicationParameters(nullptr, 0); // updates ParametersSha256DigestComponent
+ i.setApplicationParameters(span<uint8_t>{}); // updates ParametersSha256DigestComponent
BOOST_CHECK_EQUAL(i.getName(),
"/I/params-sha256=33b67cb5385ceddad93d0ee960679041613bed34b8b4a5e6362fe7539ba2d3ce");
BOOST_CHECK_EQUAL(i.hasApplicationParameters(), true);
@@ -1141,7 +1142,7 @@
});
// Test failure with missing InterestSignatureInfo
- i3.setApplicationParameters(nullptr, 0);
+ i3.setApplicationParameters(span<uint8_t>{});
BOOST_CHECK_EXCEPTION(i3.extractSignedRanges(), tlv::Error, [] (const auto& e) {
return e.what() == "Interest missing InterestSignatureInfo"s;
});
diff --git a/tests/unit/security/certificate.t.cpp b/tests/unit/security/certificate.t.cpp
index 1069584..7626e04 100644
--- a/tests/unit/security/certificate.t.cpp
+++ b/tests/unit/security/certificate.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -163,7 +163,7 @@
Certificate certificate;
certificate.setName("/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B");
certificate.setFreshnessPeriod(1_h);
- certificate.setContent(PUBLIC_KEY, sizeof(PUBLIC_KEY));
+ certificate.setContent(PUBLIC_KEY);
generateFakeSignature(certificate);
BOOST_CHECK_EQUAL(certificate.getName(), "/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B");
@@ -185,7 +185,7 @@
Certificate certificate;
certificate.setName("/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B");
certificate.setFreshnessPeriod(1_h);
- certificate.setContent(PUBLIC_KEY, sizeof(PUBLIC_KEY));
+ certificate.setContent(PUBLIC_KEY);
generateFakeSignature(certificate);
BOOST_CHECK_EQUAL(certificate.isValid(), true);
@@ -237,14 +237,14 @@
BOOST_FIXTURE_TEST_CASE(EmptyContent, InvalidCertFixture)
{
Data data(m_certBase);
- data.setContent(nullptr, 0);
+ data.setContent(span<uint8_t>{});
generateFakeSignature(data);
- BOOST_CHECK_THROW((Certificate(data)), Certificate::Error);
- BOOST_CHECK_THROW((Certificate(std::move(data))), Certificate::Error);
+ BOOST_CHECK_THROW(Certificate{data}, Certificate::Error);
+ BOOST_CHECK_THROW(Certificate{std::move(data)}, Certificate::Error);
Certificate cert(m_certBase);
- cert.setContent(nullptr, 0);
+ cert.setContent(span<uint8_t>{});
generateFakeSignature(cert);
BOOST_CHECK_THROW(cert.getPublicKey(), Certificate::Error);
}
@@ -270,7 +270,7 @@
Certificate certificate(Block(CERT, sizeof(CERT)));
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(certificate), expectedCertificateInfo);
- // @todo Check output formats of other certificates
+ // TODO: Check output formats of other certificates
}
BOOST_AUTO_TEST_SUITE_END() // TestCertificate
diff --git a/tests/unit/util/segment-fetcher.t.cpp b/tests/unit/util/segment-fetcher.t.cpp
index 55247fe..cd74372 100644
--- a/tests/unit/util/segment-fetcher.t.cpp
+++ b/tests/unit/util/segment-fetcher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -46,7 +46,7 @@
{
const uint8_t buffer[] = "Hello, world!";
auto data = makeData(Name(baseName).appendSegment(segment));
- data->setContent(buffer, sizeof(buffer));
+ data->setContent(buffer);
data->setFreshnessPeriod(1_s);
if (isFinal) {
data->setFinalBlock(data->getName()[-1]);
@@ -559,7 +559,7 @@
const uint8_t buffer[] = "Hello, world!";
auto data = makeData("/hello/world/version0/no-segment");
data->setFreshnessPeriod(1_s);
- data->setContent(buffer, sizeof(buffer));
+ data->setContent(buffer);
face.receive(*data);
advanceClocks(10_ms);
diff --git a/tools/ndnsec/sign-req.cpp b/tools/ndnsec/sign-req.cpp
index 6151714..f4655af 100644
--- a/tools/ndnsec/sign-req.cpp
+++ b/tools/ndnsec/sign-req.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -95,7 +95,7 @@
certificate.setFreshnessPeriod(1_h);
// set content
- certificate.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+ certificate.setContent(key.getPublicKey());
// set signature-info
SignatureInfo signatureInfo;