changeset 1221:2255e66da726

getting rid of the dependency against Boost in the SQLite C++ wrapper
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Nov 2014 17:05:50 +0100
parents 9b9026560a5f
children 410c27e04a23
files Core/SQLite/Connection.h Core/SQLite/FunctionContext.h Core/SQLite/IScalarFunction.h Core/SQLite/NonCopyable.h Core/SQLite/Statement.cpp Core/SQLite/Statement.h Core/SQLite/StatementReference.h Core/SQLite/Transaction.h
diffstat 8 files changed, 78 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/Core/SQLite/Connection.h	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/Connection.h	Mon Nov 10 17:05:50 2014 +0100
@@ -41,7 +41,6 @@
 #include "IScalarFunction.h"
 
 #include <string>
-#include <boost/noncopyable.hpp>
 #include <map>
 
 struct sqlite3;
@@ -53,7 +52,7 @@
 {
   namespace SQLite
   {
-    class Connection : boost::noncopyable
+    class Connection : NonCopyable
     {
       friend class Statement;
       friend class Transaction;
--- a/Core/SQLite/FunctionContext.h	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/FunctionContext.h	Mon Nov 10 17:05:50 2014 +0100
@@ -34,8 +34,6 @@
 
 #pragma once
 
-#include <boost/noncopyable.hpp>
-
 #include "Statement.h"
 
 struct sqlite3_context;
@@ -45,7 +43,7 @@
 {
   namespace SQLite
   {
-    class FunctionContext : public boost::noncopyable
+    class FunctionContext : public NonCopyable
     {
       friend class Connection;
 
--- a/Core/SQLite/IScalarFunction.h	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/IScalarFunction.h	Mon Nov 10 17:05:50 2014 +0100
@@ -34,13 +34,14 @@
 
 #pragma once
 
+#include "NonCopyable.h"
 #include "FunctionContext.h"
 
 namespace Orthanc
 {
   namespace SQLite
   {
-    class IScalarFunction : public boost::noncopyable
+    class IScalarFunction : public NonCopyable
     {
     public:
       virtual ~IScalarFunction()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Core/SQLite/NonCopyable.h	Mon Nov 10 17:05:50 2014 +0100
@@ -0,0 +1,60 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ *
+ * Copyright (C) 2012-2014 Sebastien Jodogne <s.jodogne@gmail.com>,
+ * Medical Physics Department, CHU of Liege, Belgium
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *    * Neither the name of Google Inc., the name of the CHU of Liege,
+ * nor the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **/
+
+
+#pragma once
+
+namespace Orthanc
+{
+  namespace SQLite
+  {
+    // This class mimics "boost::noncopyable"
+    class NonCopyable
+    {
+    private:
+      NonCopyable(const NonCopyable&);
+
+      NonCopyable& operator= (const NonCopyable&);
+
+    protected:
+      NonCopyable()
+      {
+      }
+
+      ~NonCopyable()
+      {
+      }
+    };
+  }
+}
--- a/Core/SQLite/Statement.cpp	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/Statement.cpp	Mon Nov 10 17:05:50 2014 +0100
@@ -43,9 +43,10 @@
 #include "Statement.h"
 #include "Connection.h"
 
-#include <boost/lexical_cast.hpp>
 #include <sqlite3.h>
 #include <string.h>
+#include <stdio.h>
+#include <algorithm>
 
 namespace Orthanc
 {
@@ -56,7 +57,9 @@
       bool succeeded = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
       if (!succeeded)
       {
-        throw OrthancSQLiteException("SQLite error code " + boost::lexical_cast<std::string>(err));
+        char buffer[128];
+        snprintf(buffer, sizeof(buffer) - 1, "SQLite error code %d", err);
+        throw OrthancSQLiteException(buffer);
       }
 
       return err;
@@ -71,7 +74,9 @@
       }
       else if (err != SQLITE_OK)
       {
-        throw OrthancSQLiteException("SQLite error code " + boost::lexical_cast<std::string>(err));
+        char buffer[128];
+        snprintf(buffer, sizeof(buffer) - 1, "SQLite error code %d", err);
+        throw OrthancSQLiteException(buffer);
       }
     }
 
--- a/Core/SQLite/Statement.h	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/Statement.h	Mon Nov 10 17:05:50 2014 +0100
@@ -37,13 +37,13 @@
 
 #pragma once
 
+#include "NonCopyable.h"
 #include "OrthancSQLiteException.h"
 #include "StatementId.h"
 #include "StatementReference.h"
 
 #include <vector>
 #include <stdint.h>
-#include <boost/noncopyable.hpp>
 
 #if ORTHANC_BUILD_UNIT_TESTS == 1
 #include <gtest/gtest_prod.h>
@@ -69,7 +69,7 @@
       COLUMN_TYPE_NULL = 5
     };
 
-    class Statement : public boost::noncopyable
+    class Statement : public NonCopyable
     {
       friend class Connection;
 
--- a/Core/SQLite/StatementReference.h	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/StatementReference.h	Mon Nov 10 17:05:50 2014 +0100
@@ -37,7 +37,8 @@
 
 #pragma once
 
-#include <boost/noncopyable.hpp>
+#include "NonCopyable.h"
+
 #include <stdint.h>
 #include <cassert>
 #include <stdlib.h>
@@ -49,7 +50,7 @@
 {
   namespace SQLite
   {
-    class StatementReference : boost::noncopyable
+    class StatementReference : NonCopyable
     {
     private:
       StatementReference* root_;   // Only used for non-root nodes
--- a/Core/SQLite/Transaction.h	Mon Nov 10 16:33:51 2014 +0100
+++ b/Core/SQLite/Transaction.h	Mon Nov 10 17:05:50 2014 +0100
@@ -43,7 +43,7 @@
 {
   namespace SQLite
   {
-    class Transaction : public boost::noncopyable
+    class Transaction : public NonCopyable
     {
     private:
       Connection& connection_;