encoding+util: remove several deprecated functions
Change-Id: I51c1019d10217406fa649c32a10e36cd88390daf
diff --git a/ndn-cxx/encoding/block-helpers.hpp b/ndn-cxx/encoding/block-helpers.hpp
index 9472061..2c4f1a7 100644
--- a/ndn-cxx/encoding/block-helpers.hpp
+++ b/ndn-cxx/encoding/block-helpers.hpp
@@ -242,20 +242,6 @@
}
/**
- * @brief Create a TLV block copying the TLV-VALUE from a char buffer.
- * @param type TLV-TYPE number
- * @param value raw buffer as TLV-VALUE
- * @param length length of value buffer
- * @deprecated Use makeStringBlock()
- */
-[[deprecated("use makeStringBlock()")]]
-inline Block
-makeBinaryBlock(uint32_t type, const char* value, size_t length)
-{
- return makeBinaryBlock(type, {reinterpret_cast<const uint8_t*>(value), length});
-}
-
-/**
* @brief Prepend a TLV element containing a string.
* @param encoder an EncodingBuffer or EncodingEstimator
* @param type TLV-TYPE number
diff --git a/ndn-cxx/encoding/block.cpp b/ndn-cxx/encoding/block.cpp
index c7ed7b8..fd4c72e 100644
--- a/ndn-cxx/encoding/block.cpp
+++ b/ndn-cxx/encoding/block.cpp
@@ -252,17 +252,23 @@
// ---- wire format ----
-void
-Block::reset() noexcept
+const uint8_t*
+Block::data() const
{
- *this = {};
+ if (!hasWire())
+ NDN_THROW(Error("Underlying wire buffer is empty"));
+
+ return &*m_begin;
}
-void
-Block::resetWire() noexcept
+size_t
+Block::size() const
{
- m_buffer.reset(); // discard underlying buffer by resetting shared_ptr
- m_begin = m_end = m_valueBegin = m_valueEnd = {};
+ if (!isValid()) {
+ NDN_THROW(Error("Cannot determine size of invalid block"));
+ }
+
+ return m_size;
}
Block::const_iterator
@@ -283,23 +289,17 @@
return m_end;
}
-const uint8_t*
-Block::data() const
+void
+Block::reset() noexcept
{
- if (!hasWire())
- NDN_THROW(Error("Underlying wire buffer is empty"));
-
- return &*m_begin;
+ *this = {};
}
-size_t
-Block::size() const
+void
+Block::resetWire() noexcept
{
- if (!isValid()) {
- NDN_THROW(Error("Cannot determine size of invalid block"));
- }
-
- return m_size;
+ m_buffer.reset(); // discard underlying buffer by resetting shared_ptr
+ m_begin = m_end = m_valueBegin = m_valueEnd = {};
}
// ---- value ----
diff --git a/ndn-cxx/encoding/block.hpp b/ndn-cxx/encoding/block.hpp
index e0d21b8..a9b819f 100644
--- a/ndn-cxx/encoding/block.hpp
+++ b/ndn-cxx/encoding/block.hpp
@@ -183,10 +183,11 @@
fromStream(std::istream& is);
public: // wire format
- /** @brief Check if the Block is valid
+ /**
+ * @brief Check if the Block is valid.
*
- * A Block is valid unless it has an invalid TLV-TYPE or is default-constructed.
- * In particular, a Block with zero-length TLV-VALUE *is valid*.
+ * A Block is valid unless it has an invalid TLV-TYPE or is default-constructed.
+ * In particular, a Block with zero-length TLV-VALUE *is valid*.
*/
bool
isValid() const noexcept
@@ -194,28 +195,11 @@
return m_type != tlv::Invalid;
}
- /** @brief Reset the Block to a default-constructed state
+ /**
+ * @brief Check if the Block contains a fully encoded wire representation.
*
- * Equivalent to `*this = Block()`.
- *
- * @post `isValid() == false`
- * @sa resetWire()
- */
- void
- reset() noexcept;
-
- /** @brief Reset wire buffer but keep TLV-TYPE and sub-elements (if any)
- * @post `hasWire() == false`
- * @post `hasValue() == false`
- * @sa reset()
- */
- void
- resetWire() noexcept;
-
- /** @brief Check if the Block contains a fully encoded wire representation
- *
- * A Block has a fully encoded wire if the underlying buffer exists and contains the full
- * Type-Length-Value instead of just the TLV-VALUE field.
+ * A Block has a fully encoded wire if the underlying buffer exists and contains the full
+ * Type-Length-Value instead of just the TLV-VALUE field.
*/
bool
hasWire() const noexcept
@@ -224,6 +208,22 @@
}
/**
+ * @brief Returns a raw pointer to the beginning of the encoded wire, i.e., the whole TLV.
+ * @pre `hasWire() == true`
+ * @sa value()
+ */
+ const uint8_t*
+ data() const;
+
+ /**
+ * @brief Returns the size of the encoded wire, i.e., of the whole TLV.
+ * @pre `isValid() == true`
+ * @sa value_size()
+ */
+ size_t
+ size() const;
+
+ /**
* @brief Returns an iterator to the beginning of the encoded wire.
* @pre `hasWire() == true`
*/
@@ -238,32 +238,6 @@
end() const;
/**
- * @brief Returns the size of the encoded wire, i.e., of the whole TLV.
- * @pre `isValid() == true`
- * @sa value_size()
- */
- size_t
- size() const;
-
- /**
- * @brief Returns a raw pointer to the beginning of the encoded wire, i.e., the whole TLV.
- * @pre `hasWire() == true`
- * @sa value()
- */
- const uint8_t*
- data() const;
-
- /**
- * @deprecated Use data()
- */
- [[deprecated("use data()")]]
- const uint8_t*
- wire() const
- {
- return data();
- }
-
- /**
* @brief Returns the underlying buffer.
*/
ConstBufferPtr
@@ -272,6 +246,26 @@
return m_buffer;
}
+ /**
+ * @brief Reset the Block to a default-constructed state.
+ *
+ * Equivalent to `*this = Block()`.
+ *
+ * @post `isValid() == false`
+ * @sa resetWire()
+ */
+ void
+ reset() noexcept;
+
+ /**
+ * @brief Reset wire buffer but keep TLV-TYPE and sub-elements (if any).
+ * @post `hasWire() == false`
+ * @post `hasValue() == false`
+ * @sa reset()
+ */
+ void
+ resetWire() noexcept;
+
public: // type and value
/**
* @brief Return the TLV-TYPE of the Block.
@@ -298,26 +292,6 @@
}
/**
- * @brief Get begin iterator of TLV-VALUE.
- * @pre `hasValue() == true`
- */
- const_iterator
- value_begin() const noexcept
- {
- return m_valueBegin;
- }
-
- /**
- * @brief Get end iterator of TLV-VALUE.
- * @pre `hasValue() == true`
- */
- const_iterator
- value_end() const noexcept
- {
- return m_valueEnd;
- }
-
- /**
* @brief Return the size of TLV-VALUE, i.e., the TLV-LENGTH.
* @sa size()
*/
@@ -347,6 +321,26 @@
value() const noexcept;
/**
+ * @brief Get begin iterator of TLV-VALUE.
+ * @pre `hasValue() == true`
+ */
+ const_iterator
+ value_begin() const noexcept
+ {
+ return m_valueBegin;
+ }
+
+ /**
+ * @brief Get end iterator of TLV-VALUE.
+ * @pre `hasValue() == true`
+ */
+ const_iterator
+ value_end() const noexcept
+ {
+ return m_valueEnd;
+ }
+
+ /**
* @brief Return a new Block constructed from the TLV-VALUE of this Block.
* @pre `value_size() > 0`
*/
diff --git a/ndn-cxx/name-component.hpp b/ndn-cxx/name-component.hpp
index 7bc90e8..23128e7 100644
--- a/ndn-cxx/name-component.hpp
+++ b/ndn-cxx/name-component.hpp
@@ -224,21 +224,6 @@
/**
* @brief Decode NameComponent from a URI component.
- *
- * The URI component is read from `[input+beginOffset, input+endOffset)` range.
- *
- * @throw Error URI component does not represent a valid NameComponent.
- * @deprecated Use fromEscapedString(std::string_view)
- */
- [[deprecated("use the string_view overload")]]
- static Component
- fromEscapedString(const char* input, size_t beginOffset, size_t endOffset)
- {
- return fromEscapedString(std::string_view(input + beginOffset, endOffset - beginOffset));
- }
-
- /**
- * @brief Decode NameComponent from a URI component.
* @throw Error URI component does not represent a valid NameComponent.
*/
static Component
diff --git a/ndn-cxx/util/string-helper.hpp b/ndn-cxx/util/string-helper.hpp
index 9aa58c9..410b83f 100644
--- a/ndn-cxx/util/string-helper.hpp
+++ b/ndn-cxx/util/string-helper.hpp
@@ -157,13 +157,6 @@
void
escape(std::ostream& os, std::string_view str);
-[[deprecated("use the string_view overload")]]
-inline void
-escape(std::ostream& os, const char* str, size_t len)
-{
- escape(os, {str, len});
-}
-
/**
* @brief Decode a percent-encoded string.
*
@@ -184,13 +177,6 @@
void
unescape(std::ostream& os, std::string_view str);
-[[deprecated("use the string_view overload")]]
-inline void
-unescape(std::ostream& os, const char* str, size_t len)
-{
- unescape(os, {str, len});
-}
-
} // namespace ndn
#endif // NDN_CXX_UTIL_STRING_HELPER_HPP
diff --git a/tests/unit/encoding/block-helpers.t.cpp b/tests/unit/encoding/block-helpers.t.cpp
index 18fce9a..59a7652 100644
--- a/tests/unit/encoding/block-helpers.t.cpp
+++ b/tests/unit/encoding/block-helpers.t.cpp
@@ -99,17 +99,12 @@
const uint8_t buf2[]{1, 1, 1, 1};
const std::list<uint8_t> buf3{1, 1, 1, 1};
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- Block b1 = makeBinaryBlock(100, buf1.data(), buf1.size()); // char* overload (deprecated)
-#pragma GCC diagnostic pop
- Block b2 = makeBinaryBlock(100, buf2); // span overload
- Block b3 = makeBinaryBlock(100, buf1.begin(), buf1.end()); // fast encoding (random access iterator)
- Block b4 = makeBinaryBlock(100, buf3.begin(), buf3.end()); // slow encoding (general iterator)
+ Block b1 = makeBinaryBlock(100, buf2); // span overload
+ Block b2 = makeBinaryBlock(100, buf1.begin(), buf1.end()); // fast encoding (random access iterator)
+ Block b3 = makeBinaryBlock(100, buf3.begin(), buf3.end()); // slow encoding (general iterator)
BOOST_TEST(b1 == b2);
BOOST_TEST(b1 == b3);
- BOOST_TEST(b1 == b4);
BOOST_TEST(b1.type() == 100);
BOOST_TEST(b1.value_size() == sizeof(buf2));
BOOST_TEST(b1.value_bytes() == buf2, boost::test_tools::per_element());