aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/sqlite3
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-11-19 13:11:17 -0500
committerJack Lloyd <[email protected]>2017-11-26 11:34:12 -0500
commit9df1c8dab0c3b7218cbf40d743d73e9bd36c24cd (patch)
tree137e9107e7ca8b024ef5c36ce847b9cb75f1d3e9 /src/lib/utils/sqlite3
parentfa5254e8982644b6b69d617b5fa2755a236cf028 (diff)
PSK Database
Diffstat (limited to 'src/lib/utils/sqlite3')
-rw-r--r--src/lib/utils/sqlite3/sqlite3.cpp13
-rw-r--r--src/lib/utils/sqlite3/sqlite3.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/utils/sqlite3/sqlite3.cpp b/src/lib/utils/sqlite3/sqlite3.cpp
index 09a964a46..a1fdfaa21 100644
--- a/src/lib/utils/sqlite3/sqlite3.cpp
+++ b/src/lib/utils/sqlite3/sqlite3.cpp
@@ -7,6 +7,7 @@
#include <botan/sqlite3.h>
#include <botan/exceptn.h>
+#include <botan/mem_ops.h>
#include <sqlite3.h>
namespace Botan {
@@ -108,7 +109,7 @@ void Sqlite3_Database::Sqlite3_Statement::bind(int column, const uint8_t* p, siz
std::pair<const uint8_t*, size_t> Sqlite3_Database::Sqlite3_Statement::get_blob(int column)
{
- BOTAN_ASSERT(::sqlite3_column_type(m_stmt, 0) == SQLITE_BLOB,
+ BOTAN_ASSERT(::sqlite3_column_type(m_stmt, column) == SQLITE_BLOB,
"Return value is a blob");
const void* session_blob = ::sqlite3_column_blob(m_stmt, column);
@@ -120,6 +121,16 @@ std::pair<const uint8_t*, size_t> Sqlite3_Database::Sqlite3_Statement::get_blob(
static_cast<size_t>(session_blob_size));
}
+std::string Sqlite3_Database::Sqlite3_Statement::get_str(int column)
+ {
+ BOTAN_ASSERT(::sqlite3_column_type(m_stmt, column) == SQLITE_TEXT,
+ "Return value is text");
+
+ const unsigned char* str = ::sqlite3_column_text(m_stmt, column);
+
+ return std::string(cast_uint8_ptr_to_char(str));
+ }
+
size_t Sqlite3_Database::Sqlite3_Statement::get_size_t(int column)
{
BOTAN_ASSERT(::sqlite3_column_type(m_stmt, column) == SQLITE_INTEGER,
diff --git a/src/lib/utils/sqlite3/sqlite3.h b/src/lib/utils/sqlite3/sqlite3.h
index 3f11b60e2..08a0f0ae7 100644
--- a/src/lib/utils/sqlite3/sqlite3.h
+++ b/src/lib/utils/sqlite3/sqlite3.h
@@ -38,6 +38,7 @@ class BOTAN_PUBLIC_API(2,0) Sqlite3_Database final : public SQL_Database
void bind(int column, const uint8_t* data, size_t len) override;
std::pair<const uint8_t*, size_t> get_blob(int column) override;
+ std::string get_str(int column) override;
size_t get_size_t(int column) override;
size_t spin() override;