diff Core/SQLite/Statement.cpp @ 1220:9b9026560a5f

SQLite wrapper is now fully independent of Orthanc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Nov 2014 16:33:51 +0100
parents a811bdf8b8eb
children 2255e66da726
line wrap: on
line diff
--- a/Core/SQLite/Statement.cpp	Fri Nov 07 15:52:53 2014 +0100
+++ b/Core/SQLite/Statement.cpp	Mon Nov 10 16:33:51 2014 +0100
@@ -1,7 +1,8 @@
 /**
  * Orthanc - A Lightweight, RESTful DICOM Store
- * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
- * Belgium
+ *
+ * Copyright (C) 2012-2014 Sebastien Jodogne <s.jodogne@gmail.com>,
+ * Medical Physics Department, CHU of Liege, Belgium
  *
  * Copyright (c) 2012 The Chromium Authors. All rights reserved.
  *
@@ -34,16 +35,17 @@
  **/
 
 
+#if ORTHANC_SQLITE_STANDALONE != 1
 #include "../PrecompiledHeaders.h"
-#include "Statement.h"
+#include <glog/logging.h>
+#endif
 
+#include "Statement.h"
 #include "Connection.h"
-#include "../Toolbox.h"
 
 #include <boost/lexical_cast.hpp>
 #include <sqlite3.h>
 #include <string.h>
-#include <glog/logging.h>
 
 namespace Orthanc
 {
@@ -54,7 +56,7 @@
       bool succeeded = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
       if (!succeeded)
       {
-        throw OrthancException("SQLite error code " + boost::lexical_cast<std::string>(err));
+        throw OrthancSQLiteException("SQLite error code " + boost::lexical_cast<std::string>(err));
       }
 
       return err;
@@ -65,11 +67,11 @@
       if (err == SQLITE_RANGE)
       {
         // Binding to a non-existent variable is evidence of a serious error.
-        throw OrthancException("Bind value out of range");
+        throw OrthancSQLiteException("Bind value out of range");
       }
       else if (err != SQLITE_OK)
       {
-        throw OrthancException("SQLite error code " + boost::lexical_cast<std::string>(err));
+        throw OrthancSQLiteException("SQLite error code " + boost::lexical_cast<std::string>(err));
       }
     }
 
@@ -108,13 +110,19 @@
 
     bool Statement::Run()
     {
+#if ORTHANC_SQLITE_STANDALONE != 1
       VLOG(1) << "SQLite::Statement::Run " << sqlite3_sql(GetStatement());
+#endif
+
       return CheckError(sqlite3_step(GetStatement())) == SQLITE_DONE;
     }
 
     bool Statement::Step()
     {
+#if ORTHANC_SQLITE_STANDALONE != 1
       VLOG(1) << "SQLite::Statement::Step " << sqlite3_sql(GetStatement());
+#endif
+
       return CheckError(sqlite3_step(GetStatement())) == SQLITE_ROW;
     }
 
@@ -206,7 +214,7 @@
     ColumnType Statement::GetDeclaredColumnType(int col) const 
     {
       std::string column_type(sqlite3_column_decltype(GetStatement(), col));
-      Toolbox::ToLowerCase(column_type);
+      std::transform(column_type.begin(), column_type.end(), column_type.begin(), tolower);
 
       if (column_type == "integer")
         return COLUMN_TYPE_INTEGER;