Support std::string in SqlConnection binding 65/43965/5
authorZofia Abramowska <z.abramowska@samsung.com>
Tue, 7 Jul 2015 12:57:07 +0000 (14:57 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Tue, 11 Aug 2015 08:19:47 +0000 (01:19 -0700)
Change-Id: I24bc608cfece4849639fcf529148cfdcf4af27a7

src/dpl/db/include/dpl/db/sql_connection.h
src/dpl/db/src/sql_connection.cpp

index 510bacb..185af59 100644 (file)
@@ -159,6 +159,14 @@ class SqlConnection
         void BindString(ArgumentIndex position, const String& value);
 
         /**
+         * Bind string to the prepared statement argument
+         *
+         * @param position Index of argument to bind value to
+         * @param value Value to bind
+         */
+        void BindString(ArgumentIndex position, const std::string& value);
+
+        /**
          * Bind optional int to the prepared statement argument.
          * If optional is not set null will be bound
          *
index fdb4fe4..ccea00b 100644 (file)
@@ -232,6 +232,18 @@ void SqlConnection::DataCommand::BindString(
     BindString(position, ToUTF8String(value).c_str());
 }
 
+void SqlConnection::DataCommand::BindString(
+        SqlConnection::ArgumentIndex position,
+        const std::string& value)
+{
+    CheckBindResult(sqlite3_bind_text(m_stmt, position,
+                                      value.c_str(), value.length(),
+                                      SQLITE_TRANSIENT));
+
+    LogPedantic("SQL data command bind string: ["
+                << position << "] -> " << value);
+}
+
 void SqlConnection::DataCommand::BindInteger(
     SqlConnection::ArgumentIndex position,
     const boost::optional<int> &value)