diff --git a/include/SQLiteCpp/Column.h b/include/SQLiteCpp/Column.h index 7e1da29..2d8e47b 100644 --- a/include/SQLiteCpp/Column.h +++ b/include/SQLiteCpp/Column.h @@ -106,7 +106,7 @@ public: * */ std::string getString() const noexcept; // nothrow - + /** * @brief Return the type of the value of the column * @@ -198,7 +198,7 @@ public: { return getBlob(); } - + #if !(defined(_MSC_VER) && _MSC_VER < 1900) // NOTE : the following is required by GCC and Clang to cast a Column result in a std::string // (error: conversion from ‘SQLite::Column’ to non-scalar type ‘std::string {aka std::basic_string}’) @@ -217,7 +217,7 @@ public: return getString(); } #endif - + // NOTE : the following is required by GCC and Clang to cast a Column result in a long/int64_t /// @brief Inline cast operator to long as 64bits integer inline operator long() const diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index 8da3f74..9cd8458 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -135,14 +136,14 @@ public: * @note This uses the SQLITE_TRANSIENT flag, making a copy of the data, for SQLite internal use */ void bind(const int aIndex, const std::string& aValue); - + /** * @brief Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * * @note This uses the SQLITE_STATIC flag, NOT making a copy of the data. It must exist while executing the statement. */ void bindNoCopy(const int aIndex, const std::string& aValue); - + /** * @brief Bind a text value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * @@ -155,14 +156,14 @@ public: * @note This uses the SQLITE_TRANSIENT flag, making a copy of the data, for SQLite internal use */ void bind(const int aIndex, const void* apValue, const int aSize); - + /** * @brief Bind a binary blob value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) * * @note This uses the SQLITE_STATIC flag, NOT making a copy of the data. It must exist while executing the statement. */ void bindNoCopy(const int aIndex, const void* apValue, const int aSize); - + /** * @brief Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) */ diff --git a/src/Column.cpp b/src/Column.cpp index d4ec564..1503039 100644 --- a/src/Column.cpp +++ b/src/Column.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace SQLite @@ -81,8 +82,7 @@ std::string Column::getString() const noexcept // nothrow // Note: using sqlite3_column_blob and not sqlite3_column_text // - no need for sqlite3_column_text to add a \0 on the end, as we're getting the bytes length directly const char *data = static_cast(sqlite3_column_blob(mStmtPtr, mIndex)); - - // Note: C++ order of argument evaluation is unspecified, so not calling _blob and _bytes both directly in std::string constructor + // SQLite docs: "The safest policy is to invoke… sqlite3_column_blob() followed by sqlite3_column_bytes()" // Note: std::string is ok to pass nullptr as first arg, if length is 0 return std::string(data, sqlite3_column_bytes(mStmtPtr, mIndex)); diff --git a/src/Statement.cpp b/src/Statement.cpp index f94c06a..1074f26 100644 --- a/src/Statement.cpp +++ b/src/Statement.cpp @@ -53,7 +53,7 @@ mColumnNames(std::move(other.mColumnNames)), mbOk(other.mbOk), mbDone(other.mbDone) { - //other.mStmtPtr = nullptr; // doesn't support reassigning + // other.mStmtPtr = nullptr; // doesn't support reassigning other.mColumnCount = 0; other.mbOk = false; other.mbDone = false; @@ -117,7 +117,7 @@ void Statement::bind(const int aIndex, const std::string& aValue) static_cast(aValue.size()), SQLITE_TRANSIENT); check(ret); } - + // Bind a string value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement void Statement::bindNoCopy(const int aIndex, const std::string& aValue) {