Commit Graph

13 Commits

Author SHA1 Message Date
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
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
8078c41a35 Make GncSqlRow a class and replace GValues with typed transfer functions. 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
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
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