comparison Core/SQLite/Statement.cpp @ 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
comparison
equal deleted inserted replaced
1220:9b9026560a5f 1221:2255e66da726
41 #endif 41 #endif
42 42
43 #include "Statement.h" 43 #include "Statement.h"
44 #include "Connection.h" 44 #include "Connection.h"
45 45
46 #include <boost/lexical_cast.hpp>
47 #include <sqlite3.h> 46 #include <sqlite3.h>
48 #include <string.h> 47 #include <string.h>
48 #include <stdio.h>
49 #include <algorithm>
49 50
50 namespace Orthanc 51 namespace Orthanc
51 { 52 {
52 namespace SQLite 53 namespace SQLite
53 { 54 {
54 int Statement::CheckError(int err) const 55 int Statement::CheckError(int err) const
55 { 56 {
56 bool succeeded = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); 57 bool succeeded = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
57 if (!succeeded) 58 if (!succeeded)
58 { 59 {
59 throw OrthancSQLiteException("SQLite error code " + boost::lexical_cast<std::string>(err)); 60 char buffer[128];
61 snprintf(buffer, sizeof(buffer) - 1, "SQLite error code %d", err);
62 throw OrthancSQLiteException(buffer);
60 } 63 }
61 64
62 return err; 65 return err;
63 } 66 }
64 67
69 // Binding to a non-existent variable is evidence of a serious error. 72 // Binding to a non-existent variable is evidence of a serious error.
70 throw OrthancSQLiteException("Bind value out of range"); 73 throw OrthancSQLiteException("Bind value out of range");
71 } 74 }
72 else if (err != SQLITE_OK) 75 else if (err != SQLITE_OK)
73 { 76 {
74 throw OrthancSQLiteException("SQLite error code " + boost::lexical_cast<std::string>(err)); 77 char buffer[128];
78 snprintf(buffer, sizeof(buffer) - 1, "SQLite error code %d", err);
79 throw OrthancSQLiteException(buffer);
75 } 80 }
76 } 81 }
77 82
78 83
79 Statement::Statement(Connection& database, 84 Statement::Statement(Connection& database,