@@ -210,8 +210,12 @@ namespace sqlite {
210
210
211
211
template <typename T> friend database_binder::chain_type& operator <<(database_binder::chain_type& db, const T& val);
212
212
template <typename T> friend void get_col_from_db (database_binder& db, int inx, T& val);
213
+ /* for vector<T> support */
213
214
template <typename T> friend database_binder::chain_type& operator <<(database_binder::chain_type& db, const std::vector<T>& val);
214
215
template <typename T> friend void get_col_from_db (database_binder& db, int inx, std::vector<T>& val);
216
+ /* for nullptr & unique_ptr support */
217
+ friend database_binder::chain_type& operator <<(database_binder::chain_type& db, std::nullptr_t );
218
+ template <typename T> friend void get_col_from_db (database_binder& db, int inx, std::unique_ptr<T>& val);
215
219
template <typename T> friend T operator ++(database_binder& db, int );
216
220
217
221
@@ -458,6 +462,27 @@ namespace sqlite {
458
462
}
459
463
}
460
464
465
+ /* for nullptr support */
466
+ inline database_binder::chain_type& operator <<(database_binder::chain_type& db, std::nullptr_t ) {
467
+ int hresult;
468
+ if ((hresult = sqlite3_bind_null (db->_stmt .get (), db->_inx )) != SQLITE_OK) {
469
+ exceptions::throw_sqlite_error (hresult);
470
+ }
471
+ ++db->_inx ;
472
+ return db;
473
+ }
474
+
475
+ /* for unique_ptr<T> support */
476
+ template <typename T> inline void get_col_from_db (database_binder& db, int inx, std::unique_ptr<T>& _ptr_) {
477
+ if (sqlite3_column_type (db._stmt .get (), inx) == SQLITE_NULL) {
478
+ _ptr_ = nullptr ;
479
+ } else {
480
+ auto underling_ptr = new T ();
481
+ get_col_from_db (db, inx, *underling_ptr);
482
+ _ptr_.reset (underling_ptr);
483
+ }
484
+ }
485
+
461
486
// std::string
462
487
template <> inline void get_col_from_db (database_binder& db, int inx, std::string & s) {
463
488
if (sqlite3_column_type (db._stmt .get (), inx) == SQLITE_NULL) {
0 commit comments