GnuCash
5.6-150-g038405b370+
|
A QOF Book is a dataset. More...
Files | |
file | qofbook.h |
Encapsulate all the information about a dataset. | |
Data Structures | |
struct | QofBook |
QofBook reference. More... | |
struct | QofBookClass |
Macros | |
#define | __KVP_VALUE |
#define | QOF_TYPE_BOOK (qof_book_get_type ()) |
#define | QOF_BOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook)) |
#define | QOF_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass)) |
#define | QOF_IS_BOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK)) |
#define | QOF_IS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK)) |
#define | QOF_BOOK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass)) |
#define | QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type) |
Encapsulates all the information about a dataset manipulated by QOF. More... | |
#define | qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X)) |
deprecated | |
Typedefs | |
typedef void(* | QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data) |
typedef void(* | GncOptionSave) (GncOptionDB *, QofBook *, gboolean) |
typedef void(* | GncOptionLoad) (GncOptionDB *, QofBook *) |
typedef GList | QofBookList |
GList of QofBook. | |
typedef void(* | QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data) |
typedef void(* | QofCollectionForeachCB) (QofCollection *, gpointer user_data) |
Invoke the indicated callback on each collection in the book. More... | |
Functions | |
GType | qof_book_get_type (void) |
gboolean | qof_book_register (void) |
Register the book object with the QOF object system. More... | |
QofBook * | qof_book_new (void) |
Allocate, initialise and return a new QofBook. More... | |
void | qof_book_destroy (QofBook *book) |
End any editing sessions associated with book, and free all memory associated with it. More... | |
void | qof_book_mark_closed (QofBook *book) |
Close a book to editing. More... | |
QofCollection * | qof_book_get_collection (const QofBook *, QofIdType) |
Return The table of entities of the given type. More... | |
void | qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer) |
void | qof_book_set_data (QofBook *book, const gchar *key, gpointer data) |
The qof_book_set_data() allows arbitrary pointers to structs to be stored in QofBook. More... | |
void | qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data, QofBookFinalCB) |
Same as qof_book_set_data(), except that the callback will be called when the book is destroyed. More... | |
gpointer | qof_book_get_data (const QofBook *book, const gchar *key) |
Retrieves arbitrary pointers to structs stored by qof_book_set_data. More... | |
gboolean | qof_book_is_readonly (const QofBook *book) |
Return whether the book is read only. More... | |
void | qof_book_mark_readonly (QofBook *book) |
Mark the book as read only. More... | |
gboolean | qof_book_empty (const QofBook *book) |
Check if the book has had anything loaded into it. More... | |
gboolean | qof_book_use_trading_accounts (const QofBook *book) |
Returns flag indicating whether this book uses trading accounts. | |
gboolean | qof_book_uses_autoreadonly (const QofBook *book) |
Returns TRUE if the auto-read-only feature should be used, otherwise FALSE. More... | |
gint | qof_book_get_num_days_autoreadonly (const QofBook *book) |
Returns the number of days for auto-read-only transactions. More... | |
GDate * | qof_book_get_autoreadonly_gdate (const QofBook *book) |
Returns the GDate that is the threshold for auto-read-only. More... | |
void | qof_book_set_default_invoice_report (QofBook *book, const gchar *guid, const gchar *name) |
Save the Invoice Report name / guid to be used as the default for printing Invoices. | |
gchar * | qof_book_get_default_invoice_report_guid (const QofBook *book) |
Get the guid of the Invoice Report to be used as the default for printing Invoices. | |
gchar * | qof_book_get_default_invoice_report_name (const QofBook *book) |
Get the name of the Invoice Report to be used as the default for printing Invoices. | |
gdouble | qof_book_get_default_invoice_report_timeout (const QofBook *book) |
Get the length of time available to change the used Invoice Report when printing Invoices. | |
gboolean | qof_book_use_split_action_for_num_field (const QofBook *book) |
Returns TRUE if this book uses split action field as the 'Num' field, FALSE if it uses transaction number field. | |
gboolean | qof_book_shutting_down (const QofBook *book) |
Is the book shutting down? | |
gboolean | qof_book_session_not_saved (const QofBook *book) |
qof_book_not_saved() returns the value of the session_dirty flag, set when changes to any object in the book are committed (qof_backend->commit_edit has been called) and the backend hasn't yet written out the changes. More... | |
void | qof_book_mark_session_saved (QofBook *book) |
The qof_book_mark_saved() routine marks the book as having been saved (to a file, to a database). More... | |
void | qof_book_mark_session_dirty (QofBook *book) |
The qof_book_mark_dirty() routine marks the book as having been modified. More... | |
time64 | qof_book_get_session_dirty_time (const QofBook *book) |
Retrieve the earliest modification time on the book. More... | |
void | qof_book_set_dirty_cb (QofBook *book, QofBookDirtyCB cb, gpointer user_data) |
Set the function to call when a book transitions from clean to dirty, or vice versa. | |
gint64 | qof_book_get_counter (QofBook *book, const char *counter_name) |
This will get the named counter for this book. More... | |
gchar * | qof_book_increment_and_format_counter (QofBook *book, const char *counter_name) |
This will increment the named counter for this book and format it. More... | |
gchar * | qof_book_normalize_counter_format (const gchar *format, gchar **err_msg) |
Validate a counter format string. More... | |
char * | qof_book_get_counter_format (const QofBook *book, const char *counter_name) |
Get the format string to use for the named counter. More... | |
const char * | qof_book_get_string_option (const QofBook *book, const char *opt_name) |
void | qof_book_set_string_option (QofBook *book, const char *opt_name, const char *opt_val) |
const GncGUID * | qof_book_get_guid_option (QofBook *book, GSList *path) |
void | qof_book_option_frame_delete (QofBook *book, const char *opt_name) |
GHashTable * | qof_book_get_features (QofBook *book) |
Access functions for reading and setting the used-features on this book. | |
void | qof_book_unset_feature (QofBook *book, const gchar *key) |
void | qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr) |
void | qof_book_begin_edit (QofBook *book) |
void | qof_book_commit_edit (QofBook *book) |
void | qof_book_save_options (QofBook *book, GncOptionSave save_cb, GncOptionDB *odb, gboolean clear) |
Save a GncOptionsDB back to the book's KVP. More... | |
void | qof_book_set_option (QofBook *book, KvpValue *value, GSList *path) |
Save a single option value. More... | |
KvpValue * | qof_book_get_option (QofBook *book, GSList *path) |
Read a single option value. More... | |
void | qof_book_options_delete (QofBook *book, GSList *path) |
Delete the options. More... | |
A QOF Book is a dataset.
It provides a single handle through which all the various collections of entities can be found. In particular, given only the type of the entity, the collection can be found.
Books also provide the 'natural' place to working with a storage backend, as a book can encapsulate everything held in storage.
#define QOF_BOOK_RETURN_ENTITY | ( | book, | |
guid, | |||
e_type, | |||
c_type | |||
) |
Encapsulates all the information about a dataset manipulated by QOF.
This is the top-most structure used for anchoring data. This macro looks up an entity by GncGUID and returns a pointer to the entity by ending with a "return" statement. Hence, this macro can only be used as the last statement in the definition of a function, but not somewhere inline in the code.
typedef void(* QofCollectionForeachCB) (QofCollection *, gpointer user_data) |
void qof_book_destroy | ( | QofBook * | book | ) |
End any editing sessions associated with book, and free all memory associated with it.
Definition at line 331 of file qofbook.cpp.
gboolean qof_book_empty | ( | const QofBook * | book | ) |
Check if the book has had anything loaded into it.
Definition at line 511 of file qofbook.cpp.
GDate* qof_book_get_autoreadonly_gdate | ( | const QofBook * | book | ) |
Returns the GDate that is the threshold for auto-read-only.
Any txn with posted-date lesser than this date should be considered read-only.
If the auto-read-only feature is not used (qof_book_uses_autoreadonly() returns FALSE), NULL is returned here.
The returned object was allocated newly; the caller must g_date_free() the object afterwards.
Definition at line 988 of file qofbook.cpp.
QofCollection* qof_book_get_collection | ( | const QofBook * | , |
QofIdType | |||
) |
Return The table of entities of the given type.
When an object's constructor calls qof_instance_init(), a reference to the object is stored in the book. The book stores all the references to initialized instances, sorted by type. This function returns a collection of the references for the specified type.
If the collection doesn't yet exist for the indicated type, it is created. Thus, this routine is guaranteed to return a non-NULL value. (Unless the system malloc failed (out of memory) in which case what happens??).
Definition at line 521 of file qofbook.cpp.
gint64 qof_book_get_counter | ( | QofBook * | book, |
const char * | counter_name | ||
) |
This will get the named counter for this book.
The return value is -1 on error or the current value of the counter.
Definition at line 580 of file qofbook.cpp.
char* qof_book_get_counter_format | ( | const QofBook * | book, |
const char * | counter_name | ||
) |
Get the format string to use for the named counter.
The return value is NULL on error or the format string of the counter. The returned string should be freed by the caller.
Definition at line 686 of file qofbook.cpp.
gpointer qof_book_get_data | ( | const QofBook * | book, |
const gchar * | key | ||
) |
Retrieves arbitrary pointers to structs stored by qof_book_set_data.
gint qof_book_get_num_days_autoreadonly | ( | const QofBook * | book | ) |
Returns the number of days for auto-read-only transactions.
If zero, the auto-read-only feature should be disabled (and qof_book_uses_autoreadonly() returns FALSE).
Definition at line 968 of file qofbook.cpp.
KvpValue* qof_book_get_option | ( | QofBook * | book, |
GSList * | path | ||
) |
Read a single option value.
Used from Scheme, the KvpValue<–>SCM translation is handled by the functions in kvp-scm.c and automated by SWIG. The starting element is set as KVP_OPTION_PATH in qofbookslots.h.
book | The book. |
path | A GSList of keys which form a path under KVP_OPTION_PATH. |
Definition at line 1374 of file qofbook.cpp.
time64 qof_book_get_session_dirty_time | ( | const QofBook * | book | ) |
Retrieve the earliest modification time on the book.
Definition at line 420 of file qofbook.cpp.
gchar* qof_book_increment_and_format_counter | ( | QofBook * | book, |
const char * | counter_name | ||
) |
This will increment the named counter for this book and format it.
The return value is NULL on error or the formatted (new) value of the counter. The caller should free the result with g_gree.
Definition at line 625 of file qofbook.cpp.
gboolean qof_book_is_readonly | ( | const QofBook * | book | ) |
Return whether the book is read only.
Definition at line 497 of file qofbook.cpp.
void qof_book_mark_closed | ( | QofBook * | book | ) |
Close a book to editing.
It is up to the application to check this flag, and once marked closed, books cannot be marked as open.
Definition at line 570 of file qofbook.cpp.
void qof_book_mark_readonly | ( | QofBook * | book | ) |
Mark the book as read only.
Definition at line 504 of file qofbook.cpp.
void qof_book_mark_session_dirty | ( | QofBook * | book | ) |
The qof_book_mark_dirty() routine marks the book as having been modified.
It can be used by frontend when the used has made a change at the book level.
Definition at line 397 of file qofbook.cpp.
void qof_book_mark_session_saved | ( | QofBook * | book | ) |
The qof_book_mark_saved() routine marks the book as having been saved (to a file, to a database).
Used by backends to mark the notsaved flag as FALSE just after loading. Can also be used by the frontend when the used has said to abandon any changes.
Definition at line 383 of file qofbook.cpp.
QofBook* qof_book_new | ( | void | ) |
Allocate, initialise and return a new QofBook.
Books contain references to all of the top-level object containers.
Definition at line 290 of file qofbook.cpp.
gchar* qof_book_normalize_counter_format | ( | const gchar * | format, |
gchar ** | err_msg | ||
) |
Validate a counter format string.
If valid, returns a normalized format string, that is whatever long int specifier was used will be replaced with the value of the posix "PRIx64" macro. If not valid returns NULL and optionally set an error message is a non-null err_msg parameter was passed. The caller should free the returned format string and error message with g_free.
Definition at line 741 of file qofbook.cpp.
void qof_book_options_delete | ( | QofBook * | book, |
GSList * | path | ||
) |
Delete the options.
Primarily used from Scheme to clear out the options before saving a new set.
book | The book. |
list | A GList of keys which from a path under KVP_OPTION_PATH. If GList is Null, the whole option is deleted. |
Definition at line 1381 of file qofbook.cpp.
gboolean qof_book_register | ( | void | ) |
Register the book object with the QOF object system.
Definition at line 1397 of file qofbook.cpp.
void qof_book_save_options | ( | QofBook * | book, |
GncOptionSave | save_cb, | ||
GncOptionDB * | odb, | ||
gboolean | clear | ||
) |
Save a GncOptionsDB back to the book's KVP.
book | The book. |
save_cb | A callback function that does the saving. |
odb | The GncOptionsDB to save from. |
clear | Should the GncOptionsDB be emptied after the save? |
Definition at line 1322 of file qofbook.cpp.
gboolean qof_book_session_not_saved | ( | const QofBook * | book | ) |
qof_book_not_saved() returns the value of the session_dirty flag, set when changes to any object in the book are committed (qof_backend->commit_edit has been called) and the backend hasn't yet written out the changes.
(Note that SQL backends write commits out immediately; file backends don't, and use the flag to control an autosave timer.)
Definition at line 375 of file qofbook.cpp.
void qof_book_set_data | ( | QofBook * | book, |
const gchar * | key, | ||
gpointer | data | ||
) |
The qof_book_set_data() allows arbitrary pointers to structs to be stored in QofBook.
This is the "preferred" method for extending QofBook to hold new data types. This is also the ideal location to store other arbitrary runtime data that the application may need.
void qof_book_set_data_fin | ( | QofBook * | book, |
const gchar * | key, | ||
gpointer | data, | ||
QofBookFinalCB | |||
) |
Same as qof_book_set_data(), except that the callback will be called when the book is destroyed.
The argument to the callback will be the book followed by the data pointer.
void qof_book_set_option | ( | QofBook * | book, |
KvpValue * | value, | ||
GSList * | path | ||
) |
Save a single option value.
Used from Scheme, the KvpValue<–>SCM translation is handled by the functions in kvp-scm.c and automated by SWIG. The starting element is set as KVP_OPTION_PATH in qofbookslots.h.
book | The book. |
value | The KvpValue to store. |
path | A GSList of keys which form a path under KVP_OPTION_PATH. |
Definition at line 1361 of file qofbook.cpp.
gboolean qof_book_uses_autoreadonly | ( | const QofBook * | book | ) |
Returns TRUE if the auto-read-only feature should be used, otherwise FALSE.
This is just a wrapper on qof_book_get_num_days_autoreadonly() == 0.
Definition at line 962 of file qofbook.cpp.