diff options
Diffstat (limited to 'src/database')
-rw-r--r-- | src/database/insert_query.hpp | 18 | ||||
-rw-r--r-- | src/database/row.hpp | 6 | ||||
-rw-r--r-- | src/database/select_query.hpp | 6 | ||||
-rw-r--r-- | src/database/table.hpp | 6 |
4 files changed, 18 insertions, 18 deletions
diff --git a/src/database/insert_query.hpp b/src/database/insert_query.hpp index 4965fc0..9e410ce 100644 --- a/src/database/insert_query.hpp +++ b/src/database/insert_query.hpp @@ -53,13 +53,13 @@ struct InsertQuery: public Query { auto statement = this->prepare(db); { - this->bind_param<0>(columns, statement); + this->bind_param(columns, statement); if (sqlite3_step(statement.get()) != SQLITE_DONE) log_error("Failed to execute query: ", sqlite3_errmsg(db)); } } - template <int N, typename... T> + template <int N=0, typename... T> typename std::enable_if<N < sizeof...(T), void>::type bind_param(const std::tuple<T...>& columns, Statement& statement) { @@ -69,7 +69,7 @@ struct InsertQuery: public Query this->bind_param<N+1>(columns, statement); } - template <int N, typename... T> + template <int N=0, typename... T> typename std::enable_if<N == sizeof...(T), void>::type bind_param(const std::tuple<T...>&, Statement&) {} @@ -78,11 +78,11 @@ struct InsertQuery: public Query void insert_values(const std::tuple<T...>& columns) { this->body += "VALUES ("; - this->insert_value<0>(columns); + this->insert_value(columns); this->body += ")"; } - template <int N, typename... T> + template <int N=0, typename... T> typename std::enable_if<N < sizeof...(T), void>::type insert_value(const std::tuple<T...>& columns) { @@ -93,7 +93,7 @@ struct InsertQuery: public Query add_param(*this, std::get<N>(columns)); this->insert_value<N+1>(columns); } - template <int N, typename... T> + template <int N=0, typename... T> typename std::enable_if<N == sizeof...(T), void>::type insert_value(const std::tuple<T...>&) { } @@ -102,11 +102,11 @@ struct InsertQuery: public Query void insert_col_names(const std::tuple<T...>& columns) { this->body += " ("; - this->insert_col_name<0>(columns); + this->insert_col_name(columns); this->body += ")\n"; } - template <int N, typename... T> + template <int N=0, typename... T> typename std::enable_if<N < sizeof...(T), void>::type insert_col_name(const std::tuple<T...>& columns) { @@ -119,7 +119,7 @@ struct InsertQuery: public Query this->insert_col_name<N+1>(columns); } - template <int N, typename... T> + template <int N=0, typename... T> typename std::enable_if<N == sizeof...(T), void>::type insert_col_name(const std::tuple<T...>&) {} diff --git a/src/database/row.hpp b/src/database/row.hpp index b6887cb..e7a58c4 100644 --- a/src/database/row.hpp +++ b/src/database/row.hpp @@ -23,7 +23,7 @@ update_id(std::tuple<T...>& columns, sqlite3* db) column.value = static_cast<Id::real_type>(res); } -template <std::size_t N, typename... T> +template <std::size_t N=0, typename... T> typename std::enable_if<N < sizeof...(T), void>::type update_autoincrement_id(std::tuple<T...>& columns, sqlite3* db) { @@ -32,7 +32,7 @@ update_autoincrement_id(std::tuple<T...>& columns, sqlite3* db) update_autoincrement_id<N+1>(columns, db); } -template <std::size_t N, typename... T> +template <std::size_t N=0, typename... T> typename std::enable_if<N == sizeof...(T), void>::type update_autoincrement_id(std::tuple<T...>&, sqlite3*) {} @@ -67,7 +67,7 @@ struct Row query.execute(this->columns, db); - update_autoincrement_id<0>(this->columns, db); + update_autoincrement_id(this->columns, db); } std::tuple<T...> columns; diff --git a/src/database/select_query.hpp b/src/database/select_query.hpp index d0c1d59..93d69ed 100644 --- a/src/database/select_query.hpp +++ b/src/database/select_query.hpp @@ -53,11 +53,11 @@ struct SelectQuery: public Query Query("SELECT"), table_name(table_name) { - this->insert_col_name<0>(); + this->insert_col_name(); this->body += " from " + this->table_name; } - template <std::size_t N> + template <std::size_t N=0> typename std::enable_if<N < sizeof...(T), void>::type insert_col_name() { @@ -71,7 +71,7 @@ struct SelectQuery: public Query this->insert_col_name<N+1>(); } - template <std::size_t N> + template <std::size_t N=0> typename std::enable_if<N == sizeof...(T), void>::type insert_col_name() {} diff --git a/src/database/table.hpp b/src/database/table.hpp index 163b97f..dc871c3 100644 --- a/src/database/table.hpp +++ b/src/database/table.hpp @@ -26,7 +26,7 @@ class Table std::string res{"CREATE TABLE IF NOT EXISTS "}; res += this->name; res += " (\n"; - this->add_column_create<0>(res); + this->add_column_create(res); res += ")"; log_debug(res); @@ -58,7 +58,7 @@ class Table } private: - template <std::size_t N> + template <std::size_t N=0> typename std::enable_if<N < sizeof...(T), void>::type add_column_create(std::string& str) { @@ -75,7 +75,7 @@ class Table add_column_create<N+1>(str); } - template <std::size_t N> + template <std::size_t N=0> typename std::enable_if<N == sizeof...(T), void>::type add_column_create(std::string&) { } |