Skip to content

Commit

Permalink
Fix build on Linux, including cpplint warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
DouglasHeriot committed Jun 25, 2016
1 parent d1fc9c3 commit a3ea94c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/SQLiteCpp/Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Column
*
*/
std::string getString() const noexcept; // nothrow

/**
* @brief Return the type of the value of the column
*
Expand Down Expand Up @@ -198,7 +198,7 @@ class Column
{
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<char>}’)
Expand All @@ -217,7 +217,7 @@ class Column
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
Expand Down
9 changes: 5 additions & 4 deletions include/SQLiteCpp/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sqlite3.h>
#include <string>
#include <map>
#include <stdint.h>

#include <SQLiteCpp/Exception.h>

Expand Down Expand Up @@ -135,14 +136,14 @@ class Statement
* @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)
*
Expand All @@ -155,14 +156,14 @@ class Statement
* @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)
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <SQLiteCpp/Column.h>

#include <iostream>
#include <string>


namespace SQLite
Expand Down Expand Up @@ -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<const char *>(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));
Expand Down
4 changes: 2 additions & 2 deletions src/Statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -119,7 +119,7 @@ void Statement::bind(const int aIndex, const std::string& aValue)
static_cast<int>(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)
{
Expand Down

0 comments on commit a3ea94c

Please sign in to comment.