encoding: delete deprecated overload of Block::Block
Change-Id: I5e7a702e6cf7ea7389a923bc0b62f523f46ab229
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 09acafd..13b10bc 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -131,11 +131,6 @@
m_valueBegin = m_begin + typeLengthSize;
}
-Block::Block(const void* buf, size_t bufSize)
- : Block(reinterpret_cast<const uint8_t*>(buf), bufSize)
-{
-}
-
Block::Block(uint32_t type)
: m_type(type)
, m_size(tlv::sizeOfVarNumber(m_type) + tlv::sizeOfVarNumber(0))
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index 177d1f2..2e0601d 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -119,11 +119,6 @@
*/
Block(const uint8_t* buf, size_t bufSize);
- /** @brief Parse Block from a raw buffer
- * @deprecated use Block(const uint8_t*, size_t)
- */
- Block(const void* buf, size_t bufSize);
-
/** @brief Create an empty Block with specified TLV-TYPE
* @param type TLV-TYPE
*/
diff --git a/src/util/sqlite3-statement.cpp b/src/util/sqlite3-statement.cpp
index f1871db..736b266 100644
--- a/src/util/sqlite3-statement.cpp
+++ b/src/util/sqlite3-statement.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -33,7 +33,7 @@
Sqlite3Statement::Sqlite3Statement(sqlite3* database, const std::string& statement)
{
- int res = sqlite3_prepare_v2(database, statement.c_str(), -1, &m_stmt, nullptr);
+ int res = sqlite3_prepare_v2(database, statement.data(), -1, &m_stmt, nullptr);
if (res != SQLITE_OK)
BOOST_THROW_EXCEPTION(std::domain_error("bad SQL statement: " + statement));
}
@@ -78,7 +78,8 @@
Block
Sqlite3Statement::getBlock(int column)
{
- return Block(sqlite3_column_blob(m_stmt, column), sqlite3_column_bytes(m_stmt, column));
+ return Block(reinterpret_cast<const uint8_t*>(sqlite3_column_blob(m_stmt, column)),
+ sqlite3_column_bytes(m_stmt, column));
}
int
diff --git a/tests/unit-tests/encoding/block.t.cpp b/tests/unit-tests/encoding/block.t.cpp
index 0036175..f094460 100644
--- a/tests/unit-tests/encoding/block.t.cpp
+++ b/tests/unit-tests/encoding/block.t.cpp
@@ -473,18 +473,21 @@
BOOST_AUTO_TEST_CASE(Equality)
{
- Block a("\x08\x00", 2);
- Block b("\x08\x00", 2);;
+ const uint8_t one[] = {0x08, 0x00};
+ Block a(one, sizeof(one));
+ Block b(one, sizeof(one));
BOOST_CHECK_EQUAL(a == b, true);
BOOST_CHECK_EQUAL(a != b, false);
- Block c("\x06\x00", 2);
- Block d("\x08\x00", 2);;
+ const uint8_t two[] = {0x06, 0x00};
+ Block c(two, sizeof(two));
+ Block d(one, sizeof(one));
BOOST_CHECK_EQUAL(c == d, false);
BOOST_CHECK_EQUAL(c != d, true);
- Block e("\x06\x00", 2);
- Block f("\x06\x01\xcc", 3);;
+ const uint8_t three[] = {0x06, 0x01, 0xcc};
+ Block e(two, sizeof(two));
+ Block f(three, sizeof(three));
BOOST_CHECK_EQUAL(e == f, false);
BOOST_CHECK_EQUAL(e != f, true);
}
diff --git a/tests/unit-tests/mgmt/dispatcher.t.cpp b/tests/unit-tests/mgmt/dispatcher.t.cpp
index b9577cb..535e8bd 100644
--- a/tests/unit-tests/mgmt/dispatcher.t.cpp
+++ b/tests/unit-tests/mgmt/dispatcher.t.cpp
@@ -304,21 +304,23 @@
BOOST_AUTO_TEST_CASE(StatusDataset)
{
- static Block smallBlock("\x81\x01\0x01", 3);
- static Block largeBlock = [] () -> Block {
+ const uint8_t smallBuf[] = {0x81, 0x01, 0x01};
+ const Block smallBlock(smallBuf, sizeof(smallBuf));
+ Block largeBlock;
+ {
EncodingBuffer encoder;
for (size_t i = 0; i < 2500; ++i) {
encoder.prependByte(1);
}
encoder.prependVarNumber(2500);
encoder.prependVarNumber(129);
- return encoder.block();
- }();
+ largeBlock = encoder.block();
+ }
dispatcher.addStatusDataset("test/small",
makeTestAuthorization(),
- [] (const Name& prefix, const Interest& interest,
- StatusDatasetContext& context) {
+ [&smallBlock] (const Name& prefix, const Interest& interest,
+ StatusDatasetContext& context) {
context.append(smallBlock);
context.append(smallBlock);
context.append(smallBlock);
@@ -327,8 +329,8 @@
dispatcher.addStatusDataset("test/large",
makeTestAuthorization(),
- [] (const Name& prefix, const Interest& interest,
- StatusDatasetContext& context) {
+ [&largeBlock] (const Name& prefix, const Interest& interest,
+ StatusDatasetContext& context) {
context.append(largeBlock);
context.append(largeBlock);
context.append(largeBlock);
@@ -436,8 +438,8 @@
BOOST_AUTO_TEST_CASE(NotificationStream)
{
- static Block block("\x82\x01\x02", 3);
-
+ const uint8_t buf[] = {0x82, 0x01, 0x02};
+ const Block block(buf, sizeof(buf));
auto post = dispatcher.addNotificationStream("test");
post(block);
diff --git a/tests/unit-tests/mgmt/status-dataset-context.t.cpp b/tests/unit-tests/mgmt/status-dataset-context.t.cpp
index be7b198..5c432a7 100644
--- a/tests/unit-tests/mgmt/status-dataset-context.t.cpp
+++ b/tests/unit-tests/mgmt/status-dataset-context.t.cpp
@@ -253,13 +253,15 @@
BOOST_AUTO_TEST_CASE(AppendReject)
{
- BOOST_CHECK_NO_THROW(context.append(Block("\x82\x01\x02", 3)));
+ const uint8_t buf[] = {0x82, 0x01, 0x02};
+ BOOST_CHECK_NO_THROW(context.append(Block(buf, sizeof(buf))));
BOOST_CHECK_THROW(context.reject(), std::domain_error);
}
BOOST_AUTO_TEST_CASE(AppendEndReject)
{
- BOOST_CHECK_NO_THROW(context.append(Block("\x82\x01\x02", 3)));
+ const uint8_t buf[] = {0x82, 0x01, 0x02};
+ BOOST_CHECK_NO_THROW(context.append(Block(buf, sizeof(buf))));
BOOST_CHECK_NO_THROW(context.end());
BOOST_CHECK_THROW(context.reject(), std::domain_error);
}
@@ -268,7 +270,8 @@
{
BOOST_CHECK_NO_THROW(context.end());
// end, append -> error
- BOOST_CHECK_THROW(context.append(Block("\x82\x01\x02", 3)), std::domain_error);
+ const uint8_t buf[] = {0x82, 0x01, 0x02};
+ BOOST_CHECK_THROW(context.append(Block(buf, sizeof(buf))), std::domain_error);
}
BOOST_AUTO_TEST_CASE(EndEnd)
@@ -286,7 +289,8 @@
BOOST_AUTO_TEST_CASE(RejectAppend)
{
BOOST_CHECK_NO_THROW(context.reject());
- BOOST_CHECK_THROW(context.append(Block("\x82\x01\x02", 3)), std::domain_error);
+ const uint8_t buf[] = {0x82, 0x01, 0x02};
+ BOOST_CHECK_THROW(context.append(Block(buf, sizeof(buf))), std::domain_error);
}
BOOST_AUTO_TEST_CASE(RejectEnd)