Remove use of deprecated code
Change-Id: I721e9d0f9b41e7a53d75b1fde4a718c349273eeb
Refs: #3988
diff --git a/src/handles/base-handle.hpp b/src/handles/base-handle.hpp
index 95b8caa..a598883 100644
--- a/src/handles/base-handle.hpp
+++ b/src/handles/base-handle.hpp
@@ -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-2017, 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.
@@ -31,7 +31,7 @@
class BaseHandle : noncopyable
{
public:
- class Error : std::runtime_error
+ class Error : public std::runtime_error
{
public:
explicit
diff --git a/src/handles/delete-handle.cpp b/src/handles/delete-handle.cpp
index 5cd0506..5cfbea2 100644
--- a/src/handles/delete-handle.cpp
+++ b/src/handles/delete-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-2017, 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.
@@ -40,7 +40,7 @@
void
DeleteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
- throw Error("Delete prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Delete prefix registration failed"));
}
@@ -54,7 +54,7 @@
void
DeleteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
{
- throw Error("Delete check prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Delete check prefix registration failed"));
}
@@ -194,4 +194,4 @@
}
}
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/tcp-bulk-insert-handle.cpp b/src/handles/tcp-bulk-insert-handle.cpp
index a445110..1d81b17 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-2015, Regents of the University of California.
+ * Copyright (c) 2014-2017, 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.
@@ -84,7 +84,7 @@
ip::tcp::resolver::iterator end;
if (endpoint == end)
- throw Error("Cannot listen on [" + host + ":" + port + "]");
+ BOOST_THROW_EXCEPTION(Error("Cannot listen on [" + host + ":" + port + "]"));
m_localEndpoint = *endpoint;
std::cerr << "Start listening on " << m_localEndpoint << std::endl;
@@ -179,7 +179,7 @@
else
std::cerr << "FAILED to inject " << data.getName() << std::endl;
}
- catch (std::runtime_error& error) {
+ catch (const std::runtime_error& error) {
/// \todo Catch specific error after determining what wireDecode() can throw
std::cerr << "Error decoding received Data packet" << std::endl;
}
diff --git a/src/handles/watch-handle.cpp b/src/handles/watch-handle.cpp
index 9e80212..25ce278 100644
--- a/src/handles/watch-handle.cpp
+++ b/src/handles/watch-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-2017, 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.
@@ -68,7 +68,7 @@
WatchHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << reason << std::endl;
- throw Error("watch prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("watch prefix registration failed"));
}
void
@@ -106,7 +106,7 @@
}
void
-WatchHandle::onData(const Interest& interest, ndn::Data& data, const Name& name)
+WatchHandle::onData(const Interest& interest, const ndn::Data& data, const Name& name)
{
m_validator.validate(data,
bind(&WatchHandle::onDataValidated, this, interest, _1, name),
@@ -148,10 +148,11 @@
++m_interestNum;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, name),
+ bind(&WatchHandle::onTimeout, this, _1, name), // Nack
bind(&WatchHandle::onTimeout, this, _1, name));
}
else {
- throw Error("Insert into Repo Failed");
+ BOOST_THROW_EXCEPTION(Error("Insert into Repo Failed"));
}
m_processes[name].first.setInsertNum(m_size);
}
@@ -190,6 +191,7 @@
++m_interestNum;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, name),
+ bind(&WatchHandle::onTimeout, this, _1, name), // Nack
bind(&WatchHandle::onTimeout, this, _1, name));
}
@@ -211,6 +213,7 @@
++m_interestNum;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, name),
+ bind(&WatchHandle::onTimeout, this, _1, name), // Nack
bind(&WatchHandle::onTimeout, this, _1, name));
}
@@ -310,7 +313,7 @@
WatchHandle::deferredDeleteProcess(const Name& name)
{
getScheduler().scheduleEvent(PROCESS_DELETE_TIME,
- ndn::bind(&WatchHandle::deleteProcess, this, name));
+ bind(&WatchHandle::deleteProcess, this, name));
}
void
@@ -351,6 +354,7 @@
m_interestNum++;
getFace().expressInterest(fetchInterest,
bind(&WatchHandle::onData, this, _1, _2, parameter.getName()),
+ bind(&WatchHandle::onTimeout, this, _1, parameter.getName()), // Nack
bind(&WatchHandle::onTimeout, this, _1, parameter.getName()));
}
@@ -377,4 +381,4 @@
return true;
}
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/watch-handle.hpp b/src/handles/watch-handle.hpp
index 2fde3cf..f34b1fb 100644
--- a/src/handles/watch-handle.hpp
+++ b/src/handles/watch-handle.hpp
@@ -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-2017, 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.
@@ -87,7 +87,7 @@
* @brief fetch data and send next interest
*/
void
- onData(const Interest& interest, Data& data, const Name& name);
+ onData(const Interest& interest, const Data& data, const Name& name);
/**
* @brief handle when fetching one data timeout
@@ -169,4 +169,4 @@
} // namespace repo
-#endif // REPO_HANDLES_Watch_HANDLE_HPP
+#endif // REPO_HANDLES_WATCH_HANDLE_HPP
diff --git a/src/handles/write-handle.cpp b/src/handles/write-handle.cpp
index 08e951b..16c622e 100644
--- a/src/handles/write-handle.cpp
+++ b/src/handles/write-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-2017, 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.
@@ -59,7 +59,7 @@
WriteHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << reason << std::endl;
- throw Error("Insert prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Insert prefix registration failed"));
}
// onRegisterFailed for insert.
@@ -67,7 +67,7 @@
WriteHandle::onCheckRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << reason << std::endl;
- throw Error("Insert check prefix registration failed");
+ BOOST_THROW_EXCEPTION(Error("Insert check prefix registration failed"));
}
void
@@ -106,7 +106,7 @@
}
void
-WriteHandle::onData(const Interest& interest, Data& data, ProcessId processId)
+WriteHandle::onData(const Interest& interest, const Data& data, ProcessId processId)
{
m_validator.validate(data,
bind(&WriteHandle::onDataValidated, this, interest, _1, processId),
@@ -143,7 +143,7 @@
}
void
-WriteHandle::onSegmentData(const Interest& interest, Data& data, ProcessId processId)
+WriteHandle::onSegmentData(const Interest& interest, const Data& data, ProcessId processId)
{
m_validator.validate(data,
bind(&WriteHandle::onSegmentDataValidated, this, interest, _1, processId),
@@ -247,6 +247,7 @@
interest.setInterestLifetime(m_interestLifetime);
getFace().expressInterest(interest,
bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+ bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
process.credit--;
processRetry[segment] = 0;
@@ -341,6 +342,7 @@
fetchInterest.setInterestLifetime(m_interestLifetime);
getFace().expressInterest(fetchInterest,
bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+ bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
//When an interest is expressed, processCredit--
processCredit--;
@@ -392,6 +394,7 @@
retryInterest.setInterestLifetime(m_interestLifetime);
getFace().expressInterest(retryInterest,
bind(&WriteHandle::onSegmentData, this, _1, _2, processId),
+ bind(&WriteHandle::onSegmentTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onSegmentTimeout, this, _1, processId));
}
@@ -464,7 +467,7 @@
WriteHandle::deferredDeleteProcess(ProcessId processId)
{
getScheduler().scheduleEvent(PROCESS_DELETE_TIME,
- ndn::bind(&WriteHandle::deleteProcess, this, processId));
+ bind(&WriteHandle::deleteProcess, this, processId));
}
void
@@ -491,6 +494,7 @@
}
getFace().expressInterest(fetchInterest,
bind(&WriteHandle::onData, this, _1, _2, processId),
+ bind(&WriteHandle::onTimeout, this, _1, processId), // Nack
bind(&WriteHandle::onTimeout, this, _1, processId));
}
@@ -569,4 +573,4 @@
reply(interest, response);
}
-} //namespace repo
+} // namespace repo
diff --git a/src/handles/write-handle.hpp b/src/handles/write-handle.hpp
index 1c64437..a02f675 100644
--- a/src/handles/write-handle.hpp
+++ b/src/handles/write-handle.hpp
@@ -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-2017, 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.
@@ -125,7 +125,7 @@
* @brief fetch one data
*/
void
- onData(const Interest& interest, Data& data, ProcessId processId);
+ onData(const Interest& interest, const Data& data, ProcessId processId);
void
onDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
@@ -145,7 +145,7 @@
* @brief fetch segmented data
*/
void
- onSegmentData(const Interest& interest, Data& data, ProcessId processId);
+ onSegmentData(const Interest& interest, const Data& data, ProcessId processId);
void
onSegmentDataValidated(const Interest& interest, const std::shared_ptr<const Data>& data,
diff --git a/src/repo-command-parameter.hpp b/src/repo-command-parameter.hpp
index 22a8bcd..3648679 100644
--- a/src/repo-command-parameter.hpp
+++ b/src/repo-command-parameter.hpp
@@ -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-2017, 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.
@@ -38,7 +38,7 @@
/**
* @brief Class defining abstraction of parameter of command for NDN Repo Protocol
-* @sa link http://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#RepoCommandParameter
+* @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#RepoCommandParameter
**/
class RepoCommandParameter
@@ -370,7 +370,7 @@
m_wire.parse();
if (m_wire.type() != tlv::RepoCommandParameter)
- throw Error("Requested decoding of RepoCommandParameter, but Block is of different type");
+ BOOST_THROW_EXCEPTION(Error("Requested decoding of RepoCommandParameter, but Block is of different type"));
// Name
Block::element_const_iterator val = m_wire.find(tlv::Name);
diff --git a/src/repo-command-response.hpp b/src/repo-command-response.hpp
index 79dc027..d8f1fe8 100644
--- a/src/repo-command-response.hpp
+++ b/src/repo-command-response.hpp
@@ -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-2017, 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.
@@ -35,7 +35,7 @@
/**
* @brief Class defining abstraction of Response for NDN Repo Protocol
-* @sa link http://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
+* @sa link https://redmine.named-data.net/projects/repo-ng/wiki/Repo_Protocol_Specification#Repo-Command-Response
*/
class RepoCommandResponse
{
@@ -262,8 +262,9 @@
totalLength += variableLength;
totalLength += encoder.prependVarNumber(variableLength);
totalLength += encoder.prependVarNumber(tlv::StatusCode);
- } else {
- throw Error("required field StatusCode is missing");
+ }
+ else {
+ BOOST_THROW_EXCEPTION(Error("required field StatusCode is missing"));
}
if (m_hasProcessId) {
@@ -311,7 +312,7 @@
Block::element_const_iterator val;
if (m_wire.type() != tlv::RepoCommandResponse)
- throw Error("RepoCommandResponse malformed");
+ BOOST_THROW_EXCEPTION(Error("RepoCommandResponse malformed"));
// StartBlockId
val = m_wire.find(tlv::StartBlockId);
@@ -344,8 +345,9 @@
m_hasStatusCode = true;
m_statusCode = readNonNegativeInteger(*val);
- } else {
- throw Error("required field StatusCode is missing");
+ }
+ else {
+ BOOST_THROW_EXCEPTION(Error("required field StatusCode is missing"));
}
// InsertNum
diff --git a/src/repo.cpp b/src/repo.cpp
index 0ec3837..dcf7007 100644
--- a/src/repo.cpp
+++ b/src/repo.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-2017, 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.
@@ -31,15 +31,15 @@
std::ifstream fin(configPath.c_str());
if (!fin.is_open())
- throw Repo::Error("failed to open configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("failed to open configuration file '"+ configPath +"'"));
using namespace boost::property_tree;
ptree propertyTree;
try {
read_info(fin, propertyTree);
}
- catch (ptree_error& e) {
- throw Repo::Error("failed to read configuration file '"+ configPath +"'");
+ catch (const ptree_error& e) {
+ BOOST_THROW_EXCEPTION(Repo::Error("failed to read configuration file '"+ configPath +"'"));
}
ptree repoConf = propertyTree.get_child("repo");
@@ -55,8 +55,8 @@
if (it->first == "prefix")
repoConfig.dataPrefixes.push_back(Name(it->second.get_value<std::string>()));
else
- throw Repo::Error("Unrecognized '" + it->first + "' option in 'data' section in "
- "configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'data' section in "
+ "configuration file '"+ configPath +"'"));
}
ptree commandConf = repoConf.get_child("command");
@@ -67,8 +67,8 @@
if (it->first == "prefix")
repoConfig.repoPrefixes.push_back(Name(it->second.get_value<std::string>()));
else
- throw Repo::Error("Unrecognized '" + it->first + "' option in 'command' section in "
- "configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'command' section in "
+ "configuration file '"+ configPath +"'"));
}
ptree tcpBulkInsert = repoConf.get_child("tcp_bulk_insert");
@@ -92,15 +92,16 @@
port = it->second.get_value<std::string>();
}
else
- throw Repo::Error("Unrecognized '" + it->first + "' option in 'tcp_bulk_insert' section in "
- "configuration file '"+ configPath +"'");
+ BOOST_THROW_EXCEPTION(Repo::Error("Unrecognized '" + it->first + "' option in 'tcp_bulk_insert' section in "
+ "configuration file '"+ configPath +"'"));
}
if (isTcpBulkEnabled) {
repoConfig.tcpBulkInsertEndpoints.push_back(std::make_pair(host, port));
}
- if (repoConf.get<std::string>("storage.method") != "sqlite")
- throw Repo::Error("Only 'sqlite' storage method is supported");
+ if (repoConf.get<std::string>("storage.method") != "sqlite") {
+ BOOST_THROW_EXCEPTION(Repo::Error("Only 'sqlite' storage method is supported"));
+ }
repoConfig.dbPath = repoConf.get<std::string>("storage.path");
diff --git a/src/storage/index.cpp b/src/storage/index.cpp
index 572dc97..3197a70 100644
--- a/src/storage/index.cpp
+++ b/src/storage/index.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-2017, 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.
@@ -67,7 +67,7 @@
Index::insert(const Data& data, int64_t id)
{
if (isFull())
- throw Error("The Index is Full. Cannot Insert Any Data!");
+ BOOST_THROW_EXCEPTION(Error("The Index is Full. Cannot Insert Any Data!"));
Entry entry(data, id);
bool isInserted = m_indexContainer.insert(entry).second;
if (isInserted)
@@ -80,7 +80,7 @@
const ndn::ConstBufferPtr& keyLocatorHash)
{
if (isFull())
- throw Error("The Index is Full. Cannot Insert Any Data!");
+ BOOST_THROW_EXCEPTION(Error("The Index is Full. Cannot Insert Any Data!"));
Entry entry(fullName, keyLocatorHash, id);
bool isInserted = m_indexContainer.insert(entry).second;
if (isInserted)
@@ -160,7 +160,7 @@
Index::computeKeyLocatorHash(const KeyLocator& keyLocator)
{
const Block& block = keyLocator.wireEncode();
- ndn::ConstBufferPtr keyLocatorHash = ndn::crypto::sha256(block.wire(), block.size());
+ ndn::ConstBufferPtr keyLocatorHash = ndn::crypto::computeSha256Digest(block.wire(), block.size());
return keyLocatorHash;
}
@@ -175,7 +175,7 @@
{
KeyLocator keyLocator = interest.getPublisherPublicKeyLocator();
const Block& block = keyLocator.wireEncode();
- hash = ndn::crypto::sha256(block.wire(), block.size());
+ hash = ndn::crypto::computeSha256Digest(block.wire(), block.size());
}
if (isLeftmost)
diff --git a/src/storage/repo-storage.cpp b/src/storage/repo-storage.cpp
index 381ccaa..49873d7 100644
--- a/src/storage/repo-storage.cpp
+++ b/src/storage/repo-storage.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-2017, 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.
@@ -46,7 +46,7 @@
{
bool isExist = m_index.hasData(data);
if (isExist)
- throw Error("The Entry Has Already In the Skiplist. Cannot be Inserted!");
+ BOOST_THROW_EXCEPTION(Error("The Entry Has Already In the Skiplist. Cannot be Inserted!"));
int64_t id = m_storage.insert(data);
if (id == -1)
return false;
diff --git a/src/storage/sqlite-storage.cpp b/src/storage/sqlite-storage.cpp
index 7edcda7..ae380ea 100644
--- a/src/storage/sqlite-storage.cpp
+++ b/src/storage/sqlite-storage.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-2017, 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.
@@ -40,7 +40,7 @@
boost::filesystem::file_status fsPathStatus = boost::filesystem::status(fsPath);
if (!boost::filesystem::is_directory(fsPathStatus)) {
if (!boost::filesystem::create_directory(boost::filesystem::path(fsPath))) {
- throw Error("Folder '" + dbPath + "' does not exists and cannot be created");
+ BOOST_THROW_EXCEPTION(Error("Folder '" + dbPath + "' does not exists and cannot be created"));
}
}
@@ -75,7 +75,7 @@
}
else {
std::cerr << "Database file open failure rc:" << rc << std::endl;
- throw Error("Database file open failure");
+ BOOST_THROW_EXCEPTION(Error("Database file open failure"));
}
sqlite3_exec(m_db, "PRAGMA synchronous = OFF", 0, 0, &errMsg);
sqlite3_exec(m_db, "PRAGMA journal_mode = WAL", 0, 0, &errMsg);
@@ -87,15 +87,14 @@
}
void
-SqliteStorage::fullEnumerate(const ndn::function
- <void(const Storage::ItemMeta)>& f)
+SqliteStorage::fullEnumerate(const std::function<void(const Storage::ItemMeta)>& f)
{
sqlite3_stmt* m_stmt = 0;
int rc = SQLITE_DONE;
string sql = string("SELECT id, name, keylocatorHash FROM NDN_REPO;");
rc = sqlite3_prepare_v2(m_db, sql.c_str(), -1, &m_stmt, 0);
if (rc != SQLITE_OK)
- throw Error("Initiation Read Entries from Database Prepare error");
+ BOOST_THROW_EXCEPTION(Error("Initiation Read Entries from Database Prepare error"));
int entryNumber = 0;
while (true) {
rc = sqlite3_step(m_stmt);
@@ -124,7 +123,7 @@
else {
std::cerr << "Initiation Read Entries rc:" << rc << std::endl;
sqlite3_finalize(m_stmt);
- throw Error("Initiation Read Entries error");
+ BOOST_THROW_EXCEPTION(Error("Initiation Read Entries error"));
}
}
m_size = entryNumber;
@@ -168,14 +167,14 @@
if (rc == SQLITE_CONSTRAINT) {
std::cerr << "Insert failed" << std::endl;
sqlite3_finalize(insertStmt);
- throw Error("Insert failed");
+ BOOST_THROW_EXCEPTION(Error("Insert failed"));
}
sqlite3_reset(insertStmt);
m_size++;
id = sqlite3_last_insert_rowid(m_db);
}
else {
- throw Error("Some error with insert");
+ BOOST_THROW_EXCEPTION(Error("Some error with insert"));
}
sqlite3_finalize(insertStmt);
@@ -193,7 +192,7 @@
if (sqlite3_prepare_v2(m_db, deleteSql.c_str(), -1, &deleteStmt, 0) != SQLITE_OK) {
sqlite3_finalize(deleteStmt);
std::cerr << "delete statement prepared failed" << std::endl;
- throw Error("delete statement prepared failed");
+ BOOST_THROW_EXCEPTION(Error("delete statement prepared failed"));
}
if (sqlite3_bind_int64(deleteStmt, 1, id) == SQLITE_OK) {
@@ -201,7 +200,7 @@
if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
std::cerr << " node delete error rc:" << rc << std::endl;
sqlite3_finalize(deleteStmt);
- throw Error(" node delete error");
+ BOOST_THROW_EXCEPTION(Error(" node delete error"));
}
if (sqlite3_changes(m_db) != 1)
return false;
@@ -210,7 +209,7 @@
else {
std::cerr << "delete bind error" << std::endl;
sqlite3_finalize(deleteStmt);
- throw Error("delete bind error");
+ BOOST_THROW_EXCEPTION(Error("delete bind error"));
}
sqlite3_finalize(deleteStmt);
return true;
@@ -239,20 +238,20 @@
else {
std::cerr << "Database query failure rc:" << rc << std::endl;
sqlite3_finalize(queryStmt);
- throw Error("Database query failure");
+ BOOST_THROW_EXCEPTION(Error("Database query failure"));
}
}
else {
std::cerr << "select bind error" << std::endl;
sqlite3_finalize(queryStmt);
- throw Error("select bind error");
+ BOOST_THROW_EXCEPTION(Error("select bind error"));
}
sqlite3_finalize(queryStmt);
}
else {
sqlite3_finalize(queryStmt);
std::cerr << "select statement prepared failed" << std::endl;
- throw Error("select statement prepared failed");
+ BOOST_THROW_EXCEPTION(Error("select statement prepared failed"));
}
return shared_ptr<Data>();
}
@@ -267,7 +266,7 @@
{
std::cerr << "Database query failure rc:" << rc << std::endl;
sqlite3_finalize(queryStmt);
- throw Error("Database query failure");
+ BOOST_THROW_EXCEPTION(Error("Database query failure"));
}
rc = sqlite3_step(queryStmt);
@@ -275,7 +274,7 @@
{
std::cerr << "Database query failure rc:" << rc << std::endl;
sqlite3_finalize(queryStmt);
- throw Error("Database query failure");
+ BOOST_THROW_EXCEPTION(Error("Database query failure"));
}
int64_t nDatas = sqlite3_column_int64(queryStmt, 0);
@@ -285,4 +284,4 @@
return nDatas;
}
-} //namespace repo
+} // namespace repo