Line data Source code
1 : /********************************************************************
2 : * gnc-dbiprovider.cpp: Encapsulate differences among Dbi backends. *
3 : * *
4 : * Copyright 2016 John Ralls <jralls@ceridwen.us> *
5 : * *
6 : * This program is free software; you can redistribute it and/or *
7 : * modify it under the terms of the GNU General Public License as *
8 : * published by the Free Software Foundation; either version 2 of *
9 : * the License, or (at your option) any later version. *
10 : * *
11 : * This program is distributed in the hope that it will be useful, *
12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 : * GNU General Public License for more details. *
15 : * *
16 : * You should have received a copy of the GNU General Public License*
17 : * along with this program; if not, contact: *
18 : * *
19 : * Free Software Foundation Voice: +1-617-542-5942 *
20 : * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21 : * Boston, MA 02110-1301, USA gnu@gnu.org *
22 : \********************************************************************/
23 :
24 : #ifndef __GNC_DBIPROVIDER_HPP__
25 : #define __GNC_DBIPROVIDER_HPP__
26 :
27 : #include <dbi/dbi.h>
28 : #include <string>
29 : #include <vector>
30 :
31 : /**
32 : * Provides the primary abstraction for different DBI backends.
33 : */
34 : class GncSqlConnection;
35 : struct GncSqlColumnInfo;
36 : using ColVec = std::vector<GncSqlColumnInfo>;
37 : using StrVec = std::vector<std::string>;
38 : class GncDbiProvider
39 : {
40 : public:
41 0 : virtual ~GncDbiProvider() = default;
42 : virtual StrVec get_table_list(dbi_conn conn, const std::string& table) = 0;
43 : virtual void append_col_def(std::string& ddl,
44 : const GncSqlColumnInfo& info) = 0;
45 : virtual StrVec get_index_list (dbi_conn conn) = 0;
46 : virtual void drop_index(dbi_conn conn, const std::string& index) = 0;
47 : };
48 :
49 : using GncDbiProviderPtr = std::unique_ptr<GncDbiProvider>;
50 :
51 : #endif //__GNC_DBIPROVIDER_HPP__
|