GnuCash  5.6-150-g038405b370+
Public Member Functions
GncSqlJobBackend Class Reference
Inheritance diagram for GncSqlJobBackend:
GncSqlObjectBackend

Public Member Functions

void load_all (GncSqlBackend *) override
 Load all objects of m_type in the database into memory. More...
 
bool write (GncSqlBackend *) override
 Write all objects of m_type_name to the database. More...
 
- Public Member Functions inherited from GncSqlObjectBackend
 GncSqlObjectBackend (int version, const std::string &type, const std::string &table, const EntryVec &vec)
 
virtual void create_tables (GncSqlBackend *sql_be)
 Conditionally create or update a database table from m_col_table. More...
 
virtual bool commit (GncSqlBackend *sql_be, QofInstance *inst)
 UPDATE/INSERT a single instance of m_type_name into the database. More...
 
const char * type () const noexcept
 Return the m_type_name for the class. More...
 
const bool is_version (int version) const noexcept
 Compare a version with the compiled version (m_version). More...
 
bool instance_in_db (const GncSqlBackend *sql_be, QofInstance *inst) const noexcept
 Check the presence of an object in the backend's database. More...
 

Additional Inherited Members

- Protected Attributes inherited from GncSqlObjectBackend
const std::string m_table_name
 
const int m_version
 
const std::string m_type_name
 
const EntryVec & m_col_table
 The front-end QofIdType.
 

Detailed Description

Definition at line 35 of file gnc-job-sql.h.

Member Function Documentation

◆ load_all()

void GncSqlJobBackend::load_all ( GncSqlBackend sql_be)
overridevirtual

Load all objects of m_type in the database into memory.

Parameters
sql_beThe GncSqlBackend containing the database connection.

Implements GncSqlObjectBackend.

Definition at line 105 of file gnc-job-sql.cpp.

106 {
107  g_return_if_fail (sql_be != NULL);
108 
109  std::string sql("SELECT * FROM " TABLE_NAME);
110  auto stmt = sql_be->create_statement_from_sql(sql);
111  auto result = sql_be->execute_select_statement(stmt);
112 
113  for (auto row : *result)
114  load_single_job (sql_be, row);
115 
116  std::string pkey(col_table[0]->name());
117  sql = "SELECT DISTINCT ";
118  sql += pkey + " FROM " TABLE_NAME;
120  (BookLookupFn)gnc_job_lookup);
121 }
GncSqlResultPtr execute_select_statement(const GncSqlStatementPtr &stmt) const noexcept
Executes an SQL SELECT statement and returns the result rows.
void gnc_sql_slots_load_for_sql_subquery(GncSqlBackend *sql_be, const std::string subquery, BookLookupFn lookup_fn)
gnc_sql_slots_load_for_sql_subquery - Loads slots for all objects whose guid is supplied by a subquer...

◆ write()

bool GncSqlJobBackend::write ( GncSqlBackend sql_be)
overridevirtual

Write all objects of m_type_name to the database.

Parameters
sql_beThe GncSqlBackend containing the database.
Returns
true if the objects were successfully written, false otherwise.

Reimplemented from GncSqlObjectBackend.

Definition at line 157 of file gnc-job-sql.cpp.

158 {
159  g_return_val_if_fail (sql_be != NULL, FALSE);
160  write_objects_t data{sql_be, true, this};
161 
162  qof_object_foreach (GNC_ID_JOB, sql_be->book(), write_single_job, &data);
163 
164  return data.is_ok;
165 }
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke the callback 'cb' on every instance ov a particular object type.
Definition: qofobject.cpp:185
Data-passing struct for callbacks to qof_object_foreach() used in GncSqlObjectBackend::write().

The documentation for this class was generated from the following files: