Commit Graph

13 Commits

Author SHA1 Message Date
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
12e763884e Use a std::unique_ptr for GncSqlStatement for better memory management. 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
a716636e00 Convert GncSqlStatement to a virtual class.
Implemented by GncDbiSqlStatement. Use class function semantics.
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
96a8a7b99f Make GncSqlColumnTableEntry arrays into std::vectors.
Allows use of range for.
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
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
lmat
293a286693 Add C++ header for guid.cpp and tests. 2016-06-09 15:07:54 -07:00
John Ralls
34e34334c7 Backends: astyle -xd -k1 -m0 -M60 -xL -xC79 -OHpUcZns4 --brackets=break
More extensive than usual, but these files had a lot of format issues.
2016-05-23 13:12:24 -07:00
John Ralls
a2863ab370 Remove old static analysis markup from backend. 2016-05-23 13:12:23 -07:00
John Ralls
0178492663 Convert SQL & DBI backends to compile as C++. 2015-11-29 17:23:43 -08:00