GnuCash  5.6-150-g038405b370+
Public Member Functions | Protected Member Functions | Friends
GncSqlColumnTableEntry Class Referenceabstract

Contains all of the information required to copy information between an object and the database for a specific object property. More...

#include <gnc-sql-column-table-entry.hpp>

Inheritance diagram for GncSqlColumnTableEntry:
GncSqlColumnTableEntryImpl< Type >

Public Member Functions

 GncSqlColumnTableEntry (const char *name, const GncSqlObjectType type, unsigned int s, int f, const char *gobj_name=nullptr, const char *qof_name=nullptr, QofAccessFunc get=nullptr, QofSetterFunc set=nullptr)
 
virtual void load (const GncSqlBackend *sql_be, GncSqlRow &row, QofIdTypeConst obj_name, void *pObject) const noexcept=0
 Load a value into an object from the database row.
 
virtual void add_to_table (ColVec &vec) const noexcept=0
 Add a GncSqlColumnInfo structure for the column type to a ColVec.
 
virtual void add_to_query (QofIdTypeConst obj_name, void *pObject, PairVec &vec) const noexcept=0
 Add a pair of the table column heading and object's value's string representation to a PairVec; used for constructing WHERE clauses and UPDATE statements.
 
QofAccessFunc get_getter (QofIdTypeConst obj_name) const noexcept
 Retrieve the getter function depending on whether it's an auto-increment field, a QofClass getter, or a function passed to the constructor.
 
QofSetterFunc get_setter (QofIdTypeConst obj_name) const noexcept
 Retrieve the setter function depending on whether it's an auto-increment field, a QofClass getter, or a function passed to the constructor.
 
const char * name () const noexcept
 Retrieve the field name so that we don't need to make create_single_col_select_statement and friend.
 
bool is_autoincr () const noexcept
 Report if the entry is an auto-increment field.
 
template<typename T >
void load_from_guid_ref (GncSqlRow &row, QofIdTypeConst obj_name, void *pObject, T get_ref) const noexcept
 

Protected Member Functions

template<typename T >
get_row_value_from_object (QofIdTypeConst obj_name, const void *pObject) const
 
template<typename T >
void add_value_to_vec (QofIdTypeConst obj_name, const void *pObject, PairVec &vec) const
 
void add_objectref_guid_to_query (QofIdTypeConst obj_name, const void *pObject, PairVec &vec) const noexcept
 Adds a name/guid std::pair to a PairVec for creating a query. More...
 
void add_objectref_guid_to_table (ColVec &vec) const noexcept
 Adds a column info structure for an object reference GncGUID to a ColVec. More...
 
template<>
void add_value_to_vec (QofIdTypeConst obj_name, const void *pObject, PairVec &vec, std::true_type) const
 
template<>
void add_value_to_vec (QofIdTypeConst obj_name, const void *pObject, PairVec &vec, std::false_type) const
 

Friends

template<GncSqlObjectType Otype>
class GncSqlColumnTableEntryImpl
 
struct GncSqlColumnInfo
 

Detailed Description

Contains all of the information required to copy information between an object and the database for a specific object property.

If an entry contains a gobj_param_name value, this string is used as the property name for a call to g_object_get() or g_object_set(). If the gobj_param_name value is NULL but qof_param_name is not NULL, this value is used as the parameter name for a call to qof_class_get_parameter_getter(). If both of these values are NULL, getter and setter are the addresses of routines to return or set the parameter value, respectively.

The database description for an object consists of an array of GncSqlColumnTableEntry objects, with a final member having col_name == NULL.

Definition at line 126 of file gnc-sql-column-table-entry.hpp.

Member Function Documentation

◆ add_objectref_guid_to_query()

void GncSqlColumnTableEntry::add_objectref_guid_to_query ( QofIdTypeConst  obj_name,
const void *  pObject,
PairVec &  vec 
) const
protectednoexcept

Adds a name/guid std::pair to a PairVec for creating a query.

Parameters
sql_beSQL backend struct
obj_nameQOF object type name
pObjectObject
pListList

Definition at line 95 of file gnc-sql-column-table-entry.cpp.

98 {
99  auto inst = get_row_value_from_object<QofInstance*>(obj_name, pObject);
100  if (inst == nullptr) return;
101  auto guid = qof_instance_get_guid (inst);
102  if (guid != nullptr) {
103  gchar *guid_s = guid_to_string(guid);
104  vec.emplace_back (std::make_pair (std::string{m_col_name}, quote_string(guid_s)));
105  g_free(guid_s);
106  }
107 }
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
gchar * guid_to_string(const GncGUID *guid)
The guid_to_string() routine returns a null-terminated string encoding of the id. ...
Definition: guid.cpp:164

◆ add_objectref_guid_to_table()

void GncSqlColumnTableEntry::add_objectref_guid_to_table ( ColVec &  vec) const
protectednoexcept

Adds a column info structure for an object reference GncGUID to a ColVec.

Parameters
sql_beSQL backend struct
pListList

Definition at line 110 of file gnc-sql-column-table-entry.cpp.

111 {
112  GncSqlColumnInfo info{*this, BCT_STRING, GUID_ENCODING_LENGTH, FALSE};
113  vec.emplace_back(std::move(info));
114 }
information required to create a column in a table.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition: guid.h:84

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