Commit Graph

17948 Commits

Author SHA1 Message Date
John Ralls
c2082bea99 Convert upgrade_table to member, remove some convenience functions.
To wit, gnc_sql_execute_select_sql, gnc_sql_execute_nonselect_sql,
gnc_sql_create_temp_table, and gnc_sql_create_select_statement.
2016-10-28 10:33:52 -07:00
John Ralls
54acef27c2 Remove a bunch of free functions already implemented as GncSqlBackend members. 2016-10-28 10:33:52 -07:00
John Ralls
a303ae688a Remove some GList and GSList uses from tests. 2016-10-28 10:33:52 -07:00
John Ralls
4b62deee42 Rework gnc_sql_append_guid_list_to_sql to eliminate GString and GList.
Which in turn forced rework of its users since the GString and GList were
passed-in parameters.
2016-10-28 10:33:52 -07:00
John Ralls
cb464da599 Replace GHashTable in GncSqlConnection with a std::vector. 2016-10-28 10:33:52 -07:00
John Ralls
885470b3e7 Replace std::vector<std::string> with StrVec. 2016-10-28 10:33:52 -07:00
John Ralls
d1fd223f9f Make conn_table_operation and add_columns_ddl members of GncDbiSqlConnection.
So they don't need to be friends.
2016-10-28 10:33:51 -07:00
John Ralls
6f67e2dd1a Convert GncSqlBackend and GncDbiBackend into a class hierarchy.
This is a rather complex change, because it also begins to separate the
responsibilities of the backends and GncSqlConnection.
2016-10-28 10:33:51 -07:00
John Ralls
d106346316 Minimally document GncDbiResult. 2016-10-28 10:33:51 -07:00
John Ralls
97b6e3a6c6 Pass ownership of the dbi_conn to GncDbiSqlConnection. 2016-10-28 10:33:51 -07:00
John Ralls
e0d5cc5b0b New function GncSqlConnection::dberror().
GncDbiSqlResult::dberror() just calls it instead of retrieving the dbi_conn
to call dbi_conn_error() itself.
2016-10-28 10:33:51 -07:00
John Ralls
583c951adc Use the right include delineators, it's not in the current source dir. 2016-10-28 10:33:51 -07:00
John Ralls
5823bf0d9a Move GncDbiSqlConnection into a separate file.
The declaration stays in gnc-backend-dbi.h because the dependencies are
still a little too tangled to be able to separate it.
2016-10-28 10:33:51 -07:00
John Ralls
ccbfb69cf1 Delete unused or duplicated member variables from GncSqlBackend & GncDbiBackend. 2016-10-28 10:33:51 -07:00
John Ralls
c0a193c593 Remove unused/never implemented QofBackend functions.
Note that the QofQuery functions that sort-of used them are ifdefed out
instead of deleted to serve as place-holders since we'll be bringing
back backend querying later.
2016-10-28 10:33:51 -07:00
John Ralls
eed4a012c3 Remove no-longer-needed gnc_table_slist_free. 2016-10-28 10:33:51 -07:00
John Ralls
1f52839271 Templatize QofDbiBackendProvider. 2016-10-28 10:33:50 -07:00
John Ralls
3894a2e8b7 Convert struct provider_functions_t into virtual class GncDbiProvider.
Implementation templated as template <DbType> GncDbiProviderImpl.
Converted GSLists to std::vectors and GStrings to std::strings.
2016-10-28 10:33:50 -07:00
John Ralls
faf59964e4 Rename gnc-backend-dbi-priv.h to gnc-backend-dbi.hpp.
Also remove "#ifdef __cplusplus" from both gnc-backend-dbi.hpp and
gnc-backend-dbi.h, these files are always C++.
2016-10-28 10:33:50 -07:00
John Ralls
7fe404808a Delete some no-longer (or in some cases never) used functions. 2016-10-28 10:33:50 -07:00
John Ralls
cfa3ab24f6 Convert GncSqlConnection to a C++ class. 2016-10-28 10:33:50 -07:00
John Ralls
12e763884e Use a std::unique_ptr for GncSqlStatement for better memory management. 2016-10-28 10:33:50 -07:00
John Ralls
64c1fda6ec gnc-backend-dbi.cpp: NULL -> nullptr. 2016-10-28 10:33:50 -07:00
John Ralls
92f2f2765e Replace the ptr-to-func GncSqlObjectBackend struct with a class hierarchy.
Can't template them because we need to iterate on the collection when loading.
2016-10-28 10:33:50 -07:00
John Ralls
6e84ccac75 Move GncSqlColumnTypeHandler functions into GncSqlColumnTableEntry.
Unfortunately a rather massive change. Gets rid of GncSqlColumnTypeHandler
and its hideous run-time registry by making the handler functions members
of GncSqlColumnTableEntry. GncSqlColumnTableEntry becomes an abstract super-
class with a templatized subclass GncSqlColumnTableEntryImpl whose template
parameter is the GncSqlObjectType that's also the GncSqlColumnTableEntryImpl's
m_col_type member. That member is a candidate for future removal as it's not
necessary. An explicit specialization is provided for each GncSqlObjectType and
that's a candidate for future code-shrinkage as there's still a fair amount
of duplication in spite of adding several helper template functions to absorb
most of the meat. The abstract GncSqlColumnTableEntry class is motivated by
the need to have an iterable container which in turn requires runtime
polymorphism. This can probably be replaced with a variadic-template
pseudo-container.

The two major benefits of this change are that it gets rid of one more set
of macro functions and provides vtable dispatch that has only one level
of indirection instead of the cumbersome string-hash-table-lookup to
find the handler followed by invoking the handler's function.

The two header files are removed because they exposed only the initialization
function which in turn only registered the respective GncSqlColumnTypeHandler.
2016-10-28 10:33:50 -07:00
John Ralls
e20c17b642 Change the object type string defines to an enum.
Because doing unnecessary string compares is dumb.
2016-10-28 10:33:49 -07:00
John Ralls
a716636e00 Convert GncSqlStatement to a virtual class.
Implemented by GncDbiSqlStatement. Use class function semantics.
2016-10-28 10:33:49 -07:00
John Ralls
0d548da223 Create a new set_parameter template function to reduce repetition. 2016-10-28 10:33:49 -07:00
John Ralls
a0ae59a96a Reimplement row retrieval as an iterator on GncSqlResults.
Replaces a much-copied and longish while loop with a simple range-for loop
that's guaranteed not to iterate if the result-set is empty.
2016-10-28 10:33:49 -07:00
John Ralls
576bc8ae7d Don't override an already-set QofBackend error. 2016-10-28 10:33:49 -07:00
John Ralls
8078c41a35 Make GncSqlRow a class and replace GValues with typed transfer functions. 2016-10-28 10:33:49 -07:00
John Ralls
2f0b5ec8fe Remove tabs from gnc-backend-sql*. 2016-10-28 10:33:49 -07:00
John Ralls
7e3ba421d7 Fix potential dereference error.
Thanks Geert Janssens.
2016-10-28 10:33:49 -07:00
John Ralls
7d4ca43fd0 Combine add_colname_to_list and add_gvalue_to_slist into single function add_value_to_vec.
The two lists were always used together so replace them with a single
vector of std::pair<std::string, std::string>; this also gets rid of the
intermediate GValue which was used to convert the returned value to a string.
operator<<() can do that for us more transparently.

Also template most of the add_value_to_vec functions.
2016-10-28 10:33:49 -07:00
John Ralls
96a8a7b99f Make GncSqlColumnTableEntry arrays into std::vectors.
Allows use of range for.
2016-10-28 10:33:48 -07:00
John Ralls
be1a5f56d6 Replace heap-allocate GncSqlColumnInfo GList with on-stack std::vector.
Faster, more concise, can't leak.
2016-10-28 10:33:48 -07:00
John Ralls
72ac25d755 Change GncSqlColumnInfo::m_null_allowed to m_not_null and invert logic.
The COL_NNUL flag is "not null", the SQL table column qualifier is NOT NULL,
and bitwise AND is clearer code than bitwise XOR.
2016-10-28 10:33:48 -07:00
John Ralls
611f210a07 Provide constructors for GncSqlColumnInfo, change variable names to m_ prefix. 2016-10-28 10:33:48 -07:00
John Ralls
049b905d86 Replace qof_object_foo_backend with c++ native containers.
Since C++ provides find and for_each on native containers there's no need
for a hand-rolled version in libqof.
2016-10-28 10:33:48 -07:00
John Ralls
a808525d05 Fix free of non-malloced memory crash in SQL save slots. 2016-10-27 16:25:56 -07:00
John Ralls
1e5f245900 Merge convert GUID from inheriting boost::guid to composition. 2016-10-25 11:49:48 -07:00
lmat
85770afb8e Replaced inheritance from boost uuid with composition
Rather than extending boost::uuids::uuid, we add a boost::uuids::uuid
member to handle the implementation of equality checking, uuid
generation, etc.
2016-10-25 12:36:53 -04:00
John Ralls
5fcdfba69c Bug 769124 - Australian (GMT-10) OFX transactions imported have previous
day's date. Previous efforts didn't work on Windows and shouldn't have
elsewhere because gnc_localtime and gnc_mktime are inverse functions;
in particular gnc_mktime doesn't adjust the time based on the value
of tm_isdst, though some implementations of STDC mktime do.

Rather than being too clever about trying to find the DST offset this
implementation just uses 1 hour.
2016-10-24 11:21:12 +11:00
lmat
0a5a0ab7ab Separate C guid from C++ guid 2016-10-21 17:19:58 -04:00
John Ralls
6695ef9585 Bug 769124 - Australian (GMT-10) OFX transactions imported have previous days date.
Fix on Windows, where the test failed to build.
2016-10-20 10:40:18 -07:00
lmat
e1e85cee16 Added forward declaration for struct GncGUID
I also removed the guid.hpp include where I could.
2016-10-19 17:05:48 -04:00
Rob.Gowin
c68452a497 Remove configuration of HAVE_PUTENV.
The Python includes files for Windows define HAVE_PUTENV to be
empty. GnuCash under MINGW (only) defines it to be 1. This causes
redefinition errors when building the Python bindings on Windows.
HAVE_PUTENV is not used in the GnuCash code base, so the best
solution seems to be to just get rid of it.
2016-10-14 14:17:04 -05:00
Geert Janssens
3877c03ee7 Merge branch 'maint' 2016-10-10 13:55:35 +02:00
Geert Janssens
38e6d7f7ce Bug 771617 - Build fails because test test-report-utilities is sensitive to time of day/timezone
Previous commit was working with years and monts potentially outside the supported range.
2016-10-10 12:28:49 +02:00
Geert Janssens
c5414e336a Merge branch 'maint' 2016-10-10 11:57:03 +02:00