From: Zofia Abramowska Date: Tue, 7 Jul 2015 12:57:07 +0000 (+0200) Subject: Support std::string in SqlConnection binding X-Git-Tag: accepted/tizen/mobile/20150813.012102~8 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git;a=commitdiff_plain;h=53495035be7c2fafd7885b93f60018bc5a39d818 Support std::string in SqlConnection binding Change-Id: I24bc608cfece4849639fcf529148cfdcf4af27a7 --- diff --git a/src/dpl/db/include/dpl/db/sql_connection.h b/src/dpl/db/include/dpl/db/sql_connection.h index 510bacb..185af59 100644 --- a/src/dpl/db/include/dpl/db/sql_connection.h +++ b/src/dpl/db/include/dpl/db/sql_connection.h @@ -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 * diff --git a/src/dpl/db/src/sql_connection.cpp b/src/dpl/db/src/sql_connection.cpp index fdb4fe4..ccea00b 100644 --- a/src/dpl/db/src/sql_connection.cpp +++ b/src/dpl/db/src/sql_connection.cpp @@ -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 &value)