Skip to content

Commit

Permalink
bool argument support for lambda function call
Browse files Browse the repository at this point in the history
  • Loading branch information
semsevens committed Jul 9, 2016
1 parent 39fc7fd commit ab9ef24
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hdr/sqlite_modern_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ namespace sqlite {
template<typename T> friend void get_col_from_db(database_binder& db, int inx, std::unique_ptr<T>& val);
template<typename T> friend T operator++(database_binder& db, int);
// for nontemplate functions
friend database_binder& operator<<(database_binder& db, const bool& val);
friend void get_col_from_db(database_binder& db, int inx, bool& val);
friend database_binder& operator<<(database_binder& db, const int& val);
friend void get_col_from_db(database_binder& db, int inx, int& val);
friend database_binder& operator <<(database_binder& db, const sqlite_int64& val);
Expand Down Expand Up @@ -382,6 +384,23 @@ namespace sqlite {
}
};

// bool
inline database_binder& operator<<(database_binder& db, const bool& val) {
int hresult;
if((hresult = sqlite3_bind_int(db._stmt.get(), db._inx, val)) != SQLITE_OK) {
exceptions::throw_sqlite_error(hresult);
}
++db._inx;
return db;
}
inline void get_col_from_db(database_binder& db, int inx, bool& val) {
if(sqlite3_column_type(db._stmt.get(), inx) == SQLITE_NULL) {
val = false;
} else {
val = sqlite3_column_int(db._stmt.get(), inx);
}
}

// int
inline database_binder& operator<<(database_binder& db, const int& val) {
int hresult;
Expand Down

0 comments on commit ab9ef24

Please sign in to comment.