sqlite_wrapper - pbujak/Sqlite-AddOns GitHub Wiki

The intermediate library between Sqlite3 and C++ applications.

The library can use code generated by the sqlite_stub_maker utility. It has references to the SQLite3 itself, so clients are freed from the dependency. Some features like transactions are not supported yet, but can be implemented in future (it is even recommended).

In Linux it is compiled to the shared library libsqlite_wrapper.so, in Windows it is intended to become a DLL sqlite_wrapper.dll. So the export policy is designed to be as portable as possible. By default all the symbols are hidden using g++ switch "-fvisibility=hidden" - it is the only Windows behaviour. To make the symbols visible, the attribute "__attribute__( ( __visibility__( "default" ) ) )" is used - it is the equivalent of the "__declpec(dllexport/dllimport)" modifiers. So the macro DLL_EXPORT has been defined to make symbol exportable in the OS independent way, see file dll_interface.hpp.

Utility classes and functions

  • open_database.hpp - The openDatabase opens a database using a database template as optional. In the most situations the template would be a database stub generated by the sqlite_stub_maker tool.
  • db_exception.cpp - Exception thrown in case of an error.

Interfaces

The interfaces could be located in the following file:

  • i_database.hpp - The handle to the open database.
  • i_database_template.hpp - The wrapper of the database template. Is should be provided by the client calling the openDatabase function.
  • i_table_accessor.hpp - The handle to the open table. It should not be used directly but by template class template DbTable< RecordClass >.
  • i_query.hpp - The handle to the open query. It should not be used directly but by template class template DbQuery< RecordClass >.
  • i_record_wrapper.hpp - The interface passed to appropriate functions related to record. It is implicitely implemented by appropriate templates.
  • i_record_iterator.hpp - The record iterator associated with table or query. Is should not be used directly but by class template DbRecordIterator< RecordClass >

Templates

The following templates are related to record classes generated by the sqlite_stub_maker tool. See example db_unit_record.hpp.

  • db_table.hpp - The class template DbTable< RecordClass > related to an appropriate table. The RecordClass is a class generated by sqlite_stub_maker. Its structure can be digested by DbTable.
  • db_query.hpp - The class template DbQuery< RecordClass > associated with an SQL query related to an appropriate table. The RecordClass is a class generated by sqlite_stub_maker. Its structure can be digested by DbQuery.
  • db_record_iterator.hpp - The record iterator related to an appropriate record class. It is not constructed explicitely, but returned by the getAll method of DbTable< RecordClass > and DbQuery< RecordClass > .

Implementations

The implementation files are located in the private subdirectory. They are not intended to be used by clients.