Update style to (almost) conform to ndn-cxx style using clang-format
diff --git a/src/db-helper.cpp b/src/db-helper.cpp
index 7b8115d..e677a75 100644
--- a/src/db-helper.cpp
+++ b/src/db-helper.cpp
@@ -25,7 +25,7 @@
 #include <boost/ref.hpp>
 #include <boost/throw_exception.hpp>
 
-INIT_LOGGER ("DbHelper");
+INIT_LOGGER("DbHelper");
 
 using namespace boost;
 namespace fs = boost::filesystem;
@@ -34,223 +34,201 @@
     PRAGMA foreign_keys = ON;      \
 ";
 
-DbHelper::DbHelper (const fs::path &path, const std::string &dbname)
+DbHelper::DbHelper(const fs::path& path, const std::string& dbname)
 {
-  fs::create_directories (path);
+  fs::create_directories(path);
 
-  int res = sqlite3_open((path / dbname).c_str (), &m_db);
-  if (res != SQLITE_OK)
-    {
-      BOOST_THROW_EXCEPTION (Error::Db ()
-                             << errmsg_info_str ("Cannot open/create dabatabase: [" + (path / dbname).string () + "]"));
-    }
+  int res = sqlite3_open((path / dbname).c_str(), &m_db);
+  if (res != SQLITE_OK) {
+    BOOST_THROW_EXCEPTION(Error::Db() << errmsg_info_str("Cannot open/create dabatabase: [" +
+                                                         (path / dbname).string() + "]"));
+  }
 
-  res = sqlite3_create_function (m_db, "hash", 2, SQLITE_ANY, 0, 0,
-                                 DbHelper::hash_xStep, DbHelper::hash_xFinal);
-  if (res != SQLITE_OK)
-    {
-      BOOST_THROW_EXCEPTION (Error::Db ()
-                             << errmsg_info_str ("Cannot create function ``hash''"));
-    }
+  res = sqlite3_create_function(m_db, "hash", 2, SQLITE_ANY, 0, 0, DbHelper::hash_xStep,
+                                DbHelper::hash_xFinal);
+  if (res != SQLITE_OK) {
+    BOOST_THROW_EXCEPTION(Error::Db() << errmsg_info_str("Cannot create function ``hash''"));
+  }
 
-  res = sqlite3_create_function (m_db, "is_prefix", 2, SQLITE_ANY, 0, DbHelper::is_prefix_xFun, 0, 0);
-  if (res != SQLITE_OK)
-    {
-      BOOST_THROW_EXCEPTION (Error::Db ()
-                             << errmsg_info_str ("Cannot create function ``is_prefix''"));
-    }
+  res = sqlite3_create_function(m_db, "is_prefix", 2, SQLITE_ANY, 0, DbHelper::is_prefix_xFun, 0, 0);
+  if (res != SQLITE_OK) {
+    BOOST_THROW_EXCEPTION(Error::Db() << errmsg_info_str("Cannot create function ``is_prefix''"));
+  }
 
-  res = sqlite3_create_function (m_db, "directory_name", -1, SQLITE_ANY, 0, DbHelper::directory_name_xFun, 0, 0);
-  if (res != SQLITE_OK)
-    {
-      BOOST_THROW_EXCEPTION (Error::Db ()
-                             << errmsg_info_str ("Cannot create function ``directory_name''"));
-    }
+  res = sqlite3_create_function(m_db, "directory_name", -1, SQLITE_ANY, 0,
+                                DbHelper::directory_name_xFun, 0, 0);
+  if (res != SQLITE_OK) {
+    BOOST_THROW_EXCEPTION(Error::Db()
+                          << errmsg_info_str("Cannot create function ``directory_name''"));
+  }
 
-  res = sqlite3_create_function (m_db, "is_dir_prefix", 2, SQLITE_ANY, 0, DbHelper::is_dir_prefix_xFun, 0, 0);
-  if (res != SQLITE_OK)
-    {
-      BOOST_THROW_EXCEPTION (Error::Db ()
-                             << errmsg_info_str ("Cannot create function ``is_dir_prefix''"));
-    }
+  res = sqlite3_create_function(m_db, "is_dir_prefix", 2, SQLITE_ANY, 0,
+                                DbHelper::is_dir_prefix_xFun, 0, 0);
+  if (res != SQLITE_OK) {
+    BOOST_THROW_EXCEPTION(Error::Db() << errmsg_info_str("Cannot create function ``is_dir_prefix''"));
+  }
 
-  sqlite3_exec (m_db, INIT_DATABASE.c_str (), NULL, NULL, NULL);
-  _LOG_DEBUG_COND (sqlite3_errcode (m_db) != SQLITE_OK, sqlite3_errmsg (m_db));
+  sqlite3_exec(m_db, INIT_DATABASE.c_str(), NULL, NULL, NULL);
+  _LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_OK, sqlite3_errmsg(m_db));
 }
 
-DbHelper::~DbHelper ()
+DbHelper::~DbHelper()
 {
-  int res = sqlite3_close (m_db);
-  if (res != SQLITE_OK)
-    {
-      // complain
-    }
+  int res = sqlite3_close(m_db);
+  if (res != SQLITE_OK) {
+    // complain
+  }
 }
 
 void
-DbHelper::hash_xStep (sqlite3_context *context, int argc, sqlite3_value **argv)
+DbHelper::hash_xStep(sqlite3_context* context, int argc, sqlite3_value** argv)
 {
-  if (argc != 2)
-    {
-      // _LOG_ERROR ("Wrong arguments are supplied for ``hash'' function");
-      sqlite3_result_error (context, "Wrong arguments are supplied for ``hash'' function", -1);
-      return;
-    }
-  if (sqlite3_value_type (argv[0]) != SQLITE_BLOB ||
-      sqlite3_value_type (argv[1]) != SQLITE_INTEGER)
-    {
-      // _LOG_ERROR ("Hash expects (blob,integer) parameters");
-      sqlite3_result_error (context, "Hash expects (blob,integer) parameters", -1);
-      return;
-    }
+  if (argc != 2) {
+    // _LOG_ERROR ("Wrong arguments are supplied for ``hash'' function");
+    sqlite3_result_error(context, "Wrong arguments are supplied for ``hash'' function", -1);
+    return;
+  }
+  if (sqlite3_value_type(argv[0]) != SQLITE_BLOB || sqlite3_value_type(argv[1]) != SQLITE_INTEGER) {
+    // _LOG_ERROR ("Hash expects (blob,integer) parameters");
+    sqlite3_result_error(context, "Hash expects (blob,integer) parameters", -1);
+    return;
+  }
 
-  EVP_MD_CTX **hash_context = reinterpret_cast<EVP_MD_CTX **> (sqlite3_aggregate_context (context, sizeof (EVP_MD_CTX *)));
+  EVP_MD_CTX** hash_context =
+    reinterpret_cast<EVP_MD_CTX**>(sqlite3_aggregate_context(context, sizeof(EVP_MD_CTX*)));
 
-  if (hash_context == 0)
-    {
-      sqlite3_result_error_nomem (context);
-      return;
-    }
+  if (hash_context == 0) {
+    sqlite3_result_error_nomem(context);
+    return;
+  }
 
-  if (*hash_context == 0)
-    {
-      *hash_context = EVP_MD_CTX_create ();
-      EVP_DigestInit_ex (*hash_context, HASH_FUNCTION (), 0);
-    }
+  if (*hash_context == 0) {
+    *hash_context = EVP_MD_CTX_create();
+    EVP_DigestInit_ex(*hash_context, HASH_FUNCTION(), 0);
+  }
 
-  int nameBytes       = sqlite3_value_bytes (argv[0]);
-  const void *name    = sqlite3_value_blob  (argv[0]);
-  sqlite3_int64 seqno = sqlite3_value_int64 (argv[1]);
+  int nameBytes = sqlite3_value_bytes(argv[0]);
+  const void* name = sqlite3_value_blob(argv[0]);
+  sqlite3_int64 seqno = sqlite3_value_int64(argv[1]);
 
-  EVP_DigestUpdate (*hash_context, name, nameBytes);
-  EVP_DigestUpdate (*hash_context, &seqno, sizeof(sqlite3_int64));
+  EVP_DigestUpdate(*hash_context, name, nameBytes);
+  EVP_DigestUpdate(*hash_context, &seqno, sizeof(sqlite3_int64));
 }
 
 void
-DbHelper::hash_xFinal (sqlite3_context *context)
+DbHelper::hash_xFinal(sqlite3_context* context)
 {
-  EVP_MD_CTX **hash_context = reinterpret_cast<EVP_MD_CTX **> (sqlite3_aggregate_context (context, sizeof (EVP_MD_CTX *)));
+  EVP_MD_CTX** hash_context =
+    reinterpret_cast<EVP_MD_CTX**>(sqlite3_aggregate_context(context, sizeof(EVP_MD_CTX*)));
 
-  if (hash_context == 0)
-    {
-      sqlite3_result_error_nomem (context);
-      return;
-    }
+  if (hash_context == 0) {
+    sqlite3_result_error_nomem(context);
+    return;
+  }
 
   if (*hash_context == 0) // no rows
-    {
-      char charNullResult = 0;
-      sqlite3_result_blob (context, &charNullResult, 1, SQLITE_TRANSIENT); //SQLITE_TRANSIENT forces to make a copy
-      return;
-    }
+  {
+    char charNullResult = 0;
+    sqlite3_result_blob(context, &charNullResult, 1,
+                        SQLITE_TRANSIENT); //SQLITE_TRANSIENT forces to make a copy
+    return;
+  }
 
-  unsigned char *hash = new unsigned char [EVP_MAX_MD_SIZE];
+  unsigned char* hash = new unsigned char[EVP_MAX_MD_SIZE];
   unsigned int hashLength = 0;
 
-  int ok = EVP_DigestFinal_ex (*hash_context,
-			       hash, &hashLength);
+  int ok = EVP_DigestFinal_ex(*hash_context, hash, &hashLength);
 
-  sqlite3_result_blob (context, hash, hashLength, SQLITE_TRANSIENT); //SQLITE_TRANSIENT forces to make a copy
-  delete [] hash;
+  sqlite3_result_blob(context, hash, hashLength,
+                      SQLITE_TRANSIENT); //SQLITE_TRANSIENT forces to make a copy
+  delete[] hash;
 
-  EVP_MD_CTX_destroy (*hash_context);
+  EVP_MD_CTX_destroy(*hash_context);
 }
 
 void
-DbHelper::is_prefix_xFun (sqlite3_context *context, int argc, sqlite3_value **argv)
+DbHelper::is_prefix_xFun(sqlite3_context* context, int argc, sqlite3_value** argv)
 {
-  int len1 = sqlite3_value_bytes (argv[0]);
-  int len2 = sqlite3_value_bytes (argv[1]);
+  int len1 = sqlite3_value_bytes(argv[0]);
+  int len2 = sqlite3_value_bytes(argv[1]);
 
-  if (len1 == 0)
-    {
-      sqlite3_result_int (context, 1);
-      return;
-    }
+  if (len1 == 0) {
+    sqlite3_result_int(context, 1);
+    return;
+  }
 
   if (len1 > len2) // first parameter should be at most equal in length to the second one
-    {
-      sqlite3_result_int (context, 0);
-      return;
-    }
+  {
+    sqlite3_result_int(context, 0);
+    return;
+  }
 
-  if (memcmp (sqlite3_value_blob (argv[0]), sqlite3_value_blob (argv[1]), len1) == 0)
-    {
-      sqlite3_result_int (context, 1);
-    }
-  else
-    {
-      sqlite3_result_int (context, 0);
-    }
+  if (memcmp(sqlite3_value_blob(argv[0]), sqlite3_value_blob(argv[1]), len1) == 0) {
+    sqlite3_result_int(context, 1);
+  }
+  else {
+    sqlite3_result_int(context, 0);
+  }
 }
 
 void
-DbHelper::directory_name_xFun (sqlite3_context *context, int argc, sqlite3_value **argv)
+DbHelper::directory_name_xFun(sqlite3_context* context, int argc, sqlite3_value** argv)
 {
-  if (argc != 1)
-    {
-      sqlite3_result_error (context, "``directory_name'' expects 1 text argument", -1);
-      sqlite3_result_null (context);
-      return;
-    }
+  if (argc != 1) {
+    sqlite3_result_error(context, "``directory_name'' expects 1 text argument", -1);
+    sqlite3_result_null(context);
+    return;
+  }
 
-  if (sqlite3_value_bytes (argv[0]) == 0)
-    {
-      sqlite3_result_null (context);
-      return;
-    }
+  if (sqlite3_value_bytes(argv[0]) == 0) {
+    sqlite3_result_null(context);
+    return;
+  }
 
-  boost::filesystem::path filePath (std::string (reinterpret_cast<const char*> (sqlite3_value_text (argv[0])), sqlite3_value_bytes (argv[0])));
-  std::string dirPath = filePath.parent_path ().generic_string ();
-  // _LOG_DEBUG ("directory_name FUN: " << dirPath);
-  if (dirPath.size () == 0)
-    {
-      sqlite3_result_null (context);
-    }
-  else
-    {
-      sqlite3_result_text (context, dirPath.c_str (), dirPath.size (), SQLITE_TRANSIENT);
-    }
+  boost::filesystem::path filePath(
+    std::string(reinterpret_cast<const char*>(sqlite3_value_text(argv[0])),
+                sqlite3_value_bytes(argv[0])));
+  std::string dirPath = filePath.parent_path().generic_string();
+  // _LOG_DEBUG("directory_name FUN: " << dirPath);
+  if (dirPath.size() == 0) {
+    sqlite3_result_null(context);
+  }
+  else {
+    sqlite3_result_text(context, dirPath.c_str(), dirPath.size(), SQLITE_TRANSIENT);
+  }
 }
 
 void
-DbHelper::is_dir_prefix_xFun (sqlite3_context *context, int argc, sqlite3_value **argv)
+DbHelper::is_dir_prefix_xFun(sqlite3_context* context, int argc, sqlite3_value** argv)
 {
-  int len1 = sqlite3_value_bytes (argv[0]);
-  int len2 = sqlite3_value_bytes (argv[1]);
+  int len1 = sqlite3_value_bytes(argv[0]);
+  int len2 = sqlite3_value_bytes(argv[1]);
 
-  if (len1 == 0)
-    {
-      sqlite3_result_int (context, 1);
-      return;
-    }
+  if (len1 == 0) {
+    sqlite3_result_int(context, 1);
+    return;
+  }
 
   if (len1 > len2) // first parameter should be at most equal in length to the second one
-    {
-      sqlite3_result_int (context, 0);
-      return;
-    }
+  {
+    sqlite3_result_int(context, 0);
+    return;
+  }
 
-  if (memcmp (sqlite3_value_blob (argv[0]), sqlite3_value_blob (argv[1]), len1) == 0)
-    {
-      if (len1 == len2)
-        {
-          sqlite3_result_int (context, 1);
-        }
-      else
-        {
-          if (reinterpret_cast<const char*> (sqlite3_value_blob (argv[1]))[len1] == '/')
-            {
-              sqlite3_result_int (context, 1);
-            }
-          else
-            {
-              sqlite3_result_int (context, 0);
-            }
-        }
+  if (memcmp(sqlite3_value_blob(argv[0]), sqlite3_value_blob(argv[1]), len1) == 0) {
+    if (len1 == len2) {
+      sqlite3_result_int(context, 1);
     }
-  else
-    {
-      sqlite3_result_int (context, 0);
+    else {
+      if (reinterpret_cast<const char*>(sqlite3_value_blob(argv[1]))[len1] == '/') {
+        sqlite3_result_int(context, 1);
+      }
+      else {
+        sqlite3_result_int(context, 0);
+      }
     }
+  }
+  else {
+    sqlite3_result_int(context, 0);
+  }
 }