Remove use of deprecated code
Change-Id: I721e9d0f9b41e7a53d75b1fde4a718c349273eeb
Refs: #3988
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