handles: avoid deprecate Block::fromBuffer overloads
refs #2553
Change-Id: I08fe046deec5583d257fe7a5f2b18a363fa8157b
diff --git a/src/handles/tcp-bulk-insert-handle.cpp b/src/handles/tcp-bulk-insert-handle.cpp
index 6c06b23..a445110 100644
--- a/src/handles/tcp-bulk-insert-handle.cpp
+++ b/src/handles/tcp-bulk-insert-handle.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2015, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -162,31 +162,30 @@
bool isOk = true;
Block element;
- while (m_inputBufferSize - offset > 0)
- {
- isOk = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset, element);
- if (!isOk)
- break;
+ while (m_inputBufferSize - offset > 0) {
+ std::tie(isOk, element) = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset);
+ if (!isOk)
+ break;
- offset += element.size();
- BOOST_ASSERT(offset <= m_inputBufferSize);
+ offset += element.size();
+ BOOST_ASSERT(offset <= m_inputBufferSize);
- if (element.type() == ndn::tlv::Data)
- {
- try {
- Data data(element);
- bool isOk = m_writer.getStorageHandle().insertData(data);
- if (isOk)
- std::cerr << "Successfully injected " << data.getName() << std::endl;
- else
- std::cerr << "FAILED to inject " << data.getName() << std::endl;
- }
- catch (std::runtime_error& error) {
- /// \todo Catch specific error after determining what wireDecode() can throw
- std::cerr << "Error decoding received Data packet" << std::endl;
- }
- }
+ if (element.type() == ndn::tlv::Data) {
+ try {
+ Data data(element);
+ bool isInserted = m_writer.getStorageHandle().insertData(data);
+ if (isInserted)
+ std::cerr << "Successfully injected " << data.getName() << std::endl;
+ else
+ std::cerr << "FAILED to inject " << data.getName() << std::endl;
+ }
+ catch (std::runtime_error& error) {
+ /// \todo Catch specific error after determining what wireDecode() can throw
+ std::cerr << "Error decoding received Data packet" << std::endl;
+ }
}
+ }
+
if (!isOk && m_inputBufferSize == MAX_NDN_PACKET_SIZE && offset == 0)
{
boost::system::error_code error;