GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Typedefs | Functions

A QOF Book is a dataset. More...

Files

file  qofbook.h
 Encapsulate all the information about a dataset.
 

Data Structures

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.
 
#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.
 

Functions

GType qof_book_get_type (void)
 
gboolean qof_book_register (void)
 Register the book object with the QOF object system.
 
QofBookqof_book_new (void)
 Allocate, initialise and return a new QofBook.
 
void qof_book_destroy (QofBook *book)
 End any editing sessions associated with book, and free all memory associated with it.
 
void qof_book_mark_closed (QofBook *book)
 Close a book to editing.
 
gboolean qof_book_is_open (const QofBook *book)
 
void qof_book_swap_books_readonly (QofBook *book, QofBook *other)
 
QofCollection * qof_book_get_collection (const QofBook *, QofIdType)
 Return The table of entities of the given type.
 
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.
 
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.
 
gpointer qof_book_get_data (const QofBook *book, const gchar *key)
 Retrieves arbitrary pointers to structs stored by qof_book_set_data.
 
gboolean qof_book_is_readonly (const QofBook *book)
 Return whether the book is read only.
 
void qof_book_mark_readonly (QofBook *book)
 Mark the book as read only.
 
gboolean qof_book_empty (const QofBook *book)
 Check if the book has had anything loaded into it.
 
gboolean qof_book_use_trading_accounts (const QofBook *book)
 Returns flag indicating whether this book uses trading accounts.
 
void qof_book_reset_num_days_autoreadonly_cache (QofBook *book)
 
gboolean qof_book_uses_autoreadonly (const QofBook *book)
 Returns TRUE if the auto-read-only feature should be used, otherwise FALSE.
 
gint qof_book_get_num_days_autoreadonly (const QofBook *book)
 Returns the number of days for auto-read-only transactions.
 
GDate * qof_book_get_autoreadonly_gdate (const QofBook *book)
 Returns the GDate that is the threshold for auto-read-only.
 
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.
 
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).
 
void qof_book_mark_session_dirty (QofBook *book)
 The qof_book_mark_dirty() routine marks the book as having been modified.
 
time64 qof_book_get_session_dirty_time (const QofBook *book)
 Retrieve the earliest modification time on the book.
 
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.
 
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.
 
gchar * qof_book_normalize_counter_format (const gchar *format, gchar **err_msg)
 Validate a counter format string.
 
char * qof_book_get_counter_format (const QofBook *book, const char *counter_name)
 Get the format string to use for the named counter.
 
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 GncGUIDqof_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.
 
void qof_book_set_option (QofBook *book, KvpValue *value, GSList *path)
 Save a single option value.
 
KvpValue * qof_book_get_option (QofBook *book, GSList *path)
 Read a single option value.
 
void qof_book_options_delete (QofBook *book, GSList *path)
 Delete the options.
 

Detailed Description

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.

Macro Definition Documentation

◆ __KVP_VALUE

#define __KVP_VALUE

Definition at line 55 of file qofbook.h.

◆ QOF_BOOK

#define QOF_BOOK (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))

Definition at line 69 of file qofbook.h.

86{
87 QofInstanceClass parent_class;
88};
89
90GType qof_book_get_type(void);
91
101#define QOF_BOOK_RETURN_ENTITY(book,guid,e_type,c_type) { \
102 QofInstance *val = NULL; \
103 if ((guid != NULL) && (book != NULL)) { \
104 const QofCollection *col; \
105 col = qof_book_get_collection (book, e_type); \
106 val = qof_collection_lookup_entity (col, guid); \
107 } \
108 return (c_type *) val; \
109}
110
111
112
114typedef GList QofBookList;
115
116typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
117
119gboolean qof_book_register (void);
120
123QofBook * qof_book_new (void);
124
127void qof_book_destroy (QofBook *book);
128
134void qof_book_mark_closed (QofBook *book);
135
136gboolean qof_book_is_open (const QofBook *book);
137
138void qof_book_swap_books_readonly (QofBook *book, QofBook *other);
139
153/*@ dependent @*/
154QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
155
157typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
158void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
159
166void qof_book_set_data (QofBook *book, const gchar *key, gpointer data);
167
172void qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data,
173 QofBookFinalCB);
174
176gpointer qof_book_get_data (const QofBook *book, const gchar *key);
177
179gboolean qof_book_is_readonly(const QofBook *book);
180
183
185gboolean qof_book_empty(const QofBook *book);
186
187#endif /* SWIG */
188
190gboolean qof_book_use_trading_accounts (const QofBook *book);
191
192void qof_book_reset_num_days_autoreadonly_cache (QofBook *book);
193
196gboolean qof_book_uses_autoreadonly (const QofBook *book);
197
202
211GDate* qof_book_get_autoreadonly_gdate (const QofBook *book);
212
216void qof_book_set_default_invoice_report (QofBook *book, const gchar *guid,
217 const gchar *name);
218
223
228
233
237
239gboolean qof_book_shutting_down (const QofBook *book);
240
248gboolean qof_book_session_not_saved (const QofBook *book);
249
250/* The following functions are not useful in scripting languages */
251#ifndef SWIG
252
259
265
268
272void qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data);
273
277gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
278
283gchar *qof_book_increment_and_format_counter (QofBook *book, const char *counter_name);
284
292gchar * qof_book_normalize_counter_format(const gchar *format, gchar **err_msg);
293
298char *qof_book_get_counter_format (const QofBook *book,
299 const char *counter_name);
300
301const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
302void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
303const GncGUID* qof_book_get_guid_option(QofBook* book, GSList* path);
304void qof_book_option_frame_delete (QofBook *book, const char* opt_name);
305
308GHashTable *qof_book_get_features (QofBook *book);
309void qof_book_unset_feature (QofBook *book, const gchar *key);
310void qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr);
311
312void qof_book_begin_edit(QofBook *book);
313void qof_book_commit_edit(QofBook *book);
314
315/* Access functions for options. */
324void qof_book_load_options (QofBook *book, GncOptionLoad load_cb,
325 GncOptionDB *odb);
332void qof_book_save_options (QofBook *book, GncOptionSave save_cb,
333 GncOptionDB* odb, gboolean clear);
342void qof_book_set_option (QofBook *book, KvpValue *value, GSList *path);
343
351KvpValue* qof_book_get_option (QofBook *book, GSList *path);
352
359void qof_book_options_delete (QofBook *book, GSList *path);
362#define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))
363
364#ifdef __cplusplus
365}
366#endif
367
368#endif /* SWIG */
369#endif /* QOF_BOOK_H */
Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections.
gpointer qof_book_get_data(const QofBook *book, const gchar *key)
Retrieves arbitrary pointers to structs stored by qof_book_set_data.
void qof_book_destroy(QofBook *book)
End any editing sessions associated with book, and free all memory associated with it.
Definition qofbook.cpp:331
gint64 qof_book_get_counter(QofBook *book, const char *counter_name)
This will get the named counter for this book.
Definition qofbook.cpp:592
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.
Definition qofbook.cpp:1090
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
Return The table of entities of the given type.
Definition qofbook.cpp:521
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.
Definition qofbook.cpp:1119
void qof_book_mark_readonly(QofBook *book)
Mark the book as read only.
Definition qofbook.cpp:504
GHashTable * qof_book_get_features(QofBook *book)
Access functions for reading and setting the used-features on this book.
Definition qofbook.cpp:1254
gboolean qof_book_shutting_down(const QofBook *book)
Is the book shutting down?
Definition qofbook.cpp:447
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
Definition qofbook.cpp:397
gchar * qof_book_normalize_counter_format(const gchar *format, gchar **err_msg)
Validate a counter format string.
Definition qofbook.cpp:753
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.
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 t...
Definition qofbook.cpp:375
char * qof_book_get_counter_format(const QofBook *book, const char *counter_name)
Get the format string to use for the named counter.
Definition qofbook.cpp:698
gint qof_book_get_num_days_autoreadonly(const QofBook *book)
Returns the number of days for auto-read-only transactions.
Definition qofbook.cpp:986
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.
Definition qofbook.cpp:426
QofBook * qof_book_new(void)
Allocate, initialise and return a new QofBook.
Definition qofbook.cpp:290
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.
Definition qofbook.cpp:1150
GDate * qof_book_get_autoreadonly_gdate(const QofBook *book)
Returns the GDate that is the threshold for auto-read-only.
Definition qofbook.cpp:1006
void qof_book_mark_closed(QofBook *book)
Close a book to editing.
Definition qofbook.cpp:570
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
Definition qofbook.cpp:497
void(* QofCollectionForeachCB)(QofCollection *, gpointer user_data)
Invoke the indicated callback on each collection in the book.
Definition qofbook.h:157
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.
Definition qofbook.cpp:1044
gboolean qof_book_uses_autoreadonly(const QofBook *book)
Returns TRUE if the auto-read-only feature should be used, otherwise FALSE.
Definition qofbook.cpp:974
gboolean qof_book_register(void)
Register the book object with the QOF object system.
Definition qofbook.cpp:1415
gboolean qof_book_use_trading_accounts(const QofBook *book)
Returns flag indicating whether this book uses trading accounts.
Definition qofbook.cpp:921
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).
Definition qofbook.cpp:383
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 nu...
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.
gboolean qof_book_empty(const QofBook *book)
Check if the book has had anything loaded into it.
Definition qofbook.cpp:511
GList QofBookList
GList of QofBook.
Definition qofbook.h:114
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.
Definition qofbook.cpp:637
time64 qof_book_get_session_dirty_time(const QofBook *book)
Retrieve the earliest modification time on the book.
Definition qofbook.cpp:420
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
const gchar * QofIdType
QofIdType declaration.
Definition qofid.h:80
void qof_book_set_option(QofBook *book, KvpValue *value, GSList *path)
Save a single option value.
Definition qofbook.cpp:1379
KvpValue * qof_book_get_option(QofBook *book, GSList *path)
Read a single option value.
Definition qofbook.cpp:1392
void qof_book_save_options(QofBook *book, GncOptionSave save_cb, GncOptionDB *odb, gboolean clear)
Save a GncOptionsDB back to the book's KVP.
Definition qofbook.cpp:1340
void qof_book_options_delete(QofBook *book, GSList *path)
Delete the options.
Definition qofbook.cpp:1399
void qof_book_load_options(QofBook *book, GncOptionLoad load_cb, GncOptionDB *odb)
Load a GncOptionsDB from KVP data.
Definition qofbook.cpp:1334
The type used to store guids in C.
Definition guid.h:75
QofBook reference.
Definition qofbook-p.hpp:47

◆ QOF_BOOK_CLASS

#define QOF_BOOK_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))

Definition at line 71 of file qofbook.h.

◆ QOF_BOOK_GET_CLASS

#define QOF_BOOK_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))

Definition at line 77 of file qofbook.h.

◆ qof_book_get_guid

#define qof_book_get_guid (   X)    qof_entity_get_guid (QOF_INSTANCE(X))

deprecated

Definition at line 362 of file qofbook.h.

◆ QOF_BOOK_RETURN_ENTITY

#define QOF_BOOK_RETURN_ENTITY (   book,
  guid,
  e_type,
  c_type 
)
Value:
{ \
QofInstance *val = NULL; \
if ((guid != NULL) && (book != NULL)) { \
const QofCollection *col; \
col = qof_book_get_collection (book, e_type); \
val = qof_collection_lookup_entity (col, guid); \
} \
return (c_type *) val; \
}
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
Definition qofid.cpp:209

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.

Definition at line 101 of file qofbook.h.

101 { \
102 QofInstance *val = NULL; \
103 if ((guid != NULL) && (book != NULL)) { \
104 const QofCollection *col; \
105 col = qof_book_get_collection (book, e_type); \
106 val = qof_collection_lookup_entity (col, guid); \
107 } \
108 return (c_type *) val; \
109}

◆ QOF_IS_BOOK

#define QOF_IS_BOOK (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))

Definition at line 73 of file qofbook.h.

◆ QOF_IS_BOOK_CLASS

#define QOF_IS_BOOK_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))

Definition at line 75 of file qofbook.h.

◆ QOF_TYPE_BOOK

#define QOF_TYPE_BOOK   (qof_book_get_type ())

Definition at line 68 of file qofbook.h.

Typedef Documentation

◆ GncOptionLoad

typedef void(* GncOptionLoad) (GncOptionDB *, QofBook *)

Definition at line 83 of file qofbook.h.

◆ GncOptionSave

typedef void(* GncOptionSave) (GncOptionDB *, QofBook *, gboolean)

Definition at line 82 of file qofbook.h.

◆ QofBookDirtyCB

typedef void(* QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data)

Definition at line 80 of file qofbook.h.

◆ QofBookFinalCB

typedef void(* QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data)

Definition at line 116 of file qofbook.h.

◆ QofBookList

typedef GList QofBookList

GList of QofBook.

Definition at line 114 of file qofbook.h.

◆ QofCollectionForeachCB

typedef void(* QofCollectionForeachCB) (QofCollection *, gpointer user_data)

Invoke the indicated callback on each collection in the book.

Definition at line 157 of file qofbook.h.

Function Documentation

◆ qof_book_begin_edit()

void qof_book_begin_edit ( QofBook book)

Definition at line 1234 of file qofbook.cpp.

1235{
1236 qof_begin_edit(&book->inst);
1237}
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ qof_book_commit_edit()

void qof_book_commit_edit ( QofBook book)

Definition at line 1355 of file qofbook.cpp.

1356{
1357 if (!qof_commit_edit (QOF_INSTANCE(book))) return;
1358 qof_commit_edit_part2 (&book->inst, commit_err, noop, noop/*lot_free*/);
1359}
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers

◆ qof_book_destroy()

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.

332{
333 GHashTable* cols;
334
335 if (!book || !book->hash_of_collections) return;
336 ENTER ("book=%p", book);
337
338 book->shutting_down = TRUE;
339 qof_event_force (&book->inst, QOF_EVENT_DESTROY, nullptr);
340
341 /* Call the list of finalizers, let them do their thing.
342 * Do this before tearing into the rest of the book.
343 */
344 g_hash_table_foreach (book->data_table_finalizers, book_final, book);
345
346 /* Lots hold a variety of pointers that need to still exist while
347 * cleaning them up so run its book_end before the rest.
348 */
349 auto lots{qof_book_get_collection(book, GNC_ID_LOT)};
350 qof_collection_foreach(lots, destroy_lot, nullptr);
351 qof_object_book_end (book);
352
353 g_hash_table_destroy (book->data_table_finalizers);
354 book->data_table_finalizers = nullptr;
355 g_hash_table_destroy (book->data_tables);
356 book->data_tables = nullptr;
357
358 /* qof_instance_release (&book->inst); */
359
360 /* Note: we need to save this hashtable until after we remove ourself
361 * from it, otherwise we'll crash in our dispose() function when we
362 * DO remove ourself from the collection but the collection had already
363 * been destroyed.
364 */
365 cols = book->hash_of_collections;
366 g_object_unref (book);
367 g_hash_table_destroy (cols);
368
369 LEAVE ("book=%p", book);
370}
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272

◆ qof_book_empty()

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.

512{
513 if (!book) return TRUE;
514 auto root_acct_col = qof_book_get_collection (book, GNC_ID_ROOT_ACCOUNT);
515 return qof_collection_get_data(root_acct_col) == nullptr;
516}
gpointer qof_collection_get_data(const QofCollection *col)
Store and retrieve arbitrary object-defined data.
Definition qofid.cpp:266

◆ qof_book_foreach_collection()

void qof_book_foreach_collection ( const QofBook book,
QofCollectionForeachCB  cb,
gpointer  user_data 
)

Definition at line 554 of file qofbook.cpp.

556{
557 struct _iterate iter;
558
559 g_return_if_fail (book);
560 g_return_if_fail (cb);
561
562 iter.fn = cb;
563 iter.data = user_data;
564
565 g_hash_table_foreach (book->hash_of_collections, foreach_cb, &iter);
566}

◆ qof_book_get_autoreadonly_gdate()

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 1006 of file qofbook.cpp.

1007{
1008 gint num_days;
1009 GDate* result = nullptr;
1010
1011 g_assert(book);
1012 num_days = qof_book_get_num_days_autoreadonly(book);
1013 if (num_days > 0)
1014 {
1015 result = gnc_g_date_new_today();
1016 g_date_subtract_days(result, num_days);
1017 }
1018 return result;
1019}
GDate * gnc_g_date_new_today()
Returns a newly allocated date of the current clock time, taken from time(2).

◆ qof_book_get_collection()

QofCollection * qof_book_get_collection ( const QofBook book,
QofIdType  entity_type 
)

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.

522{
523 QofCollection *col;
524
525 if (!book || !entity_type) return nullptr;
526
527 col = static_cast<QofCollection*>(g_hash_table_lookup (book->hash_of_collections, entity_type));
528 if (!col)
529 {
530 col = qof_collection_new (entity_type);
531 g_hash_table_insert(
532 book->hash_of_collections,
533 (gpointer)qof_string_cache_insert(entity_type), col);
534 }
535 return col;
536}
QofCollection * qof_collection_new(QofIdType type)
create a new collection of entities of type
Definition qofid.cpp:58
const char * qof_string_cache_insert(const char *key)
You can use this function with g_hash_table_insert(), for the key (or value), as long as you use the ...

◆ qof_book_get_counter()

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 592 of file qofbook.cpp.

593{
594 KvpFrame *kvp;
595 KvpValue *value;
596
597 if (!book)
598 {
599 PWARN ("No book!!!");
600 return -1;
601 }
602
603 if (!counter_name || *counter_name == '\0')
604 {
605 PWARN ("Invalid counter name.");
606 return -1;
607 }
608
609 /* Use the KVP in the book */
610 kvp = qof_instance_get_slots (QOF_INSTANCE (book));
611
612 if (!kvp)
613 {
614 PWARN ("Book has no KVP_Frame");
615 return -1;
616 }
617
618 value = kvp->get_slot({"counters", counter_name});
619 if (value)
620 {
621 auto int_value{value->get<int64_t>()};
622 /* Might be a double because of
623 * https://bugs.gnucash.org/show_bug.cgi?id=798930
624 */
625 if (!int_value)
626 int_value = static_cast<int64_t>(value->get<double>());
627 return int_value;
628 }
629 else
630 {
631 /* New counter */
632 return 0;
633 }
634}
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250

◆ qof_book_get_counter_format()

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 698 of file qofbook.cpp.

699{
700 KvpFrame *kvp;
701 const char *user_format = nullptr;
702 gchar *norm_format = nullptr;
703 KvpValue *value;
704 gchar *error = nullptr;
705
706 if (!book)
707 {
708 PWARN ("No book!!!");
709 return nullptr;
710 }
711
712 if (!counter_name || *counter_name == '\0')
713 {
714 PWARN ("Invalid counter name.");
715 return nullptr;
716 }
717
718 /* Get the KVP from the current book */
719 kvp = qof_instance_get_slots (QOF_INSTANCE (book));
720
721 if (!kvp)
722 {
723 PWARN ("Book has no KVP_Frame");
724 return nullptr;
725 }
726
727 /* Get the format string */
728 value = kvp->get_slot({"counter_formats", counter_name});
729 if (value)
730 {
731 user_format = value->get<const char*>();
732 norm_format = qof_book_normalize_counter_format(user_format, &error);
733 if (!norm_format)
734 {
735 PWARN("Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", user_format, counter_name, error);
736 /* Invalid format string */
737 user_format = nullptr;
738 g_free(error);
739 }
740 }
741
742 /* If no (valid) format string was found, use the default format
743 * string */
744 if (!norm_format)
745 {
746 /* Use the default format */
747 norm_format = g_strdup ("%.6" PRIi64);
748 }
749 return norm_format;
750}

◆ qof_book_get_default_invoice_report_guid()

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.

Definition at line 1090 of file qofbook.cpp.

1091{
1092 gchar *report_guid = nullptr;
1093
1094 if (!book)
1095 {
1096 PWARN ("No book!!!");
1097 return report_guid;
1098 }
1099
1100 KvpValue *value = get_option_default_invoice_report_value (const_cast<QofBook*>(book));
1101
1102 if (value)
1103 {
1104 auto str {value->get<const char*>()};
1105 auto ptr = strchr (str, '/');
1106 if (ptr)
1107 {
1108 if (ptr - str == GUID_ENCODING_LENGTH)
1109 {
1110 if (strlen (str) > GUID_ENCODING_LENGTH)
1111 report_guid = g_strndup (&str[0], GUID_ENCODING_LENGTH);
1112 }
1113 }
1114 }
1115 return report_guid;
1116}
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition guid.h:84

◆ qof_book_get_default_invoice_report_name()

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.

Definition at line 1119 of file qofbook.cpp.

1120{
1121 gchar *report_name = nullptr;
1122
1123 if (!book)
1124 {
1125 PWARN ("No book!!!");
1126 return report_name;
1127 }
1128
1129 KvpValue *value = get_option_default_invoice_report_value (const_cast<QofBook*>(book));
1130
1131 if (value)
1132 {
1133 auto str {value->get<const char*>()};
1134 auto ptr = strchr (str, '/');
1135 if (ptr)
1136 {
1137 if (ptr - str == GUID_ENCODING_LENGTH)
1138 {
1139 if (strlen (str) > GUID_ENCODING_LENGTH + 1)
1140 report_name = g_strdup (&str[GUID_ENCODING_LENGTH + 1]);
1141 else
1142 report_name = g_strdup ("");
1143 }
1144 }
1145 }
1146 return report_name;
1147}

◆ qof_book_get_default_invoice_report_timeout()

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.

Definition at line 1150 of file qofbook.cpp.

1151{
1152 double ret = 0;
1153
1154 if (!book)
1155 {
1156 PWARN ("No book!!!");
1157 return ret;
1158 }
1159
1160 KvpFrame *root = qof_instance_get_slots (QOF_INSTANCE(book));
1161 KvpValue *value = root->get_slot ({KVP_OPTION_PATH,
1162 OPTION_SECTION_BUSINESS,
1163 OPTION_NAME_DEFAULT_INVOICE_REPORT_TIMEOUT});
1164
1165 if (value)
1166 ret = {value->get<double>()};
1167
1168 return ret;
1169}

◆ qof_book_get_features()

GHashTable * qof_book_get_features ( QofBook book)

Access functions for reading and setting the used-features on this book.

Definition at line 1254 of file qofbook.cpp.

1255{
1256 KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
1257 GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal,
1258 nullptr, g_free);
1259
1260 PWARN ("qof_book_get_features is now deprecated.");
1261
1262 auto slot = frame->get_slot({GNC_FEATURES});
1263 if (slot != nullptr)
1264 {
1265 frame = slot->get<KvpFrame*>();
1266 frame->for_each_slot_temp(&add_feature_to_hash, features);
1267 }
1268 return features;
1269}

◆ qof_book_get_guid_option()

const GncGUID * qof_book_get_guid_option ( QofBook book,
GSList *  path 
)

Definition at line 1208 of file qofbook.cpp.

1209{
1210 g_return_val_if_fail(book != nullptr, nullptr);
1211 g_return_val_if_fail(path != nullptr, nullptr);
1212
1213 auto table_value = qof_book_get_option(book, path);
1214 if (!table_value)
1215 return nullptr;
1216 return table_value->get<GncGUID*>();
1217}
KvpValue * qof_book_get_option(QofBook *book, GSList *path)
Read a single option value.
Definition qofbook.cpp:1392

◆ qof_book_get_num_days_autoreadonly()

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 986 of file qofbook.cpp.

987{
988 g_assert(book);
989
990 if (!book->cached_num_days_autoreadonly_isvalid)
991 {
992 double tmp;
993
994 // No cached value? Then do the expensive KVP lookup
995 qof_instance_get (QOF_INSTANCE (book),
996 PARAM_NAME_NUM_AUTOREAD_ONLY, &tmp,
997 nullptr);
998
999 const_cast<QofBook*>(book)->cached_num_days_autoreadonly = tmp;
1000 const_cast<QofBook*>(book)->cached_num_days_autoreadonly_isvalid = TRUE;
1001 }
1002 // Value is cached now. Use the cheap variable returning.
1003 return (gint) book->cached_num_days_autoreadonly;
1004}
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.

◆ qof_book_get_option()

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.

Parameters
bookThe book.
pathA GSList of keys which form a path under KVP_OPTION_PATH.

Definition at line 1392 of file qofbook.cpp.

1393{
1394 KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
1395 return root->get_slot(gslist_to_option_path(path));
1396}

◆ qof_book_get_session_dirty_time()

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.

421{
422 return book->dirty_time;
423}

◆ qof_book_get_string_option()

const char * qof_book_get_string_option ( const QofBook book,
const char *  opt_name 
)

Definition at line 1185 of file qofbook.cpp.

1186{
1187 auto slot = qof_instance_get_slots(QOF_INSTANCE (book))->get_slot(opt_name_to_path(opt_name));
1188 if (slot == nullptr)
1189 return nullptr;
1190 return slot->get<const char*>();
1191}

◆ qof_book_get_type()

GType qof_book_get_type ( void  )

Definition at line 24 of file gmock-qofbook.cpp.

25{
26 return qof_mockbook_get_type();
27}

◆ qof_book_increment_and_format_counter()

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 637 of file qofbook.cpp.

638{
639 KvpFrame *kvp;
640 KvpValue *value;
641 gint64 counter;
642 gchar* format;
643 gchar* result;
644
645 if (!book)
646 {
647 PWARN ("No book!!!");
648 return nullptr;
649 }
650
651 if (!counter_name || *counter_name == '\0')
652 {
653 PWARN ("Invalid counter name.");
654 return nullptr;
655 }
656
657 /* Get the current counter value from the KVP in the book. */
658 counter = qof_book_get_counter(book, counter_name);
659
660 /* Check if an error occurred */
661 if (counter < 0)
662 return nullptr;
663
664 /* Increment the counter */
665 counter++;
666
667 /* Get the KVP from the current book */
668 kvp = qof_instance_get_slots (QOF_INSTANCE (book));
669
670 if (!kvp)
671 {
672 PWARN ("Book has no KVP_Frame");
673 return nullptr;
674 }
675
676 /* Save off the new counter */
677 qof_book_begin_edit(book);
678 value = new KvpValue(counter);
679 delete kvp->set_path({"counters", counter_name}, value);
680 qof_instance_set_dirty (QOF_INSTANCE (book));
681 qof_book_commit_edit(book);
682
683 format = qof_book_get_counter_format(book, counter_name);
684
685 if (!format)
686 {
687 PWARN("Cannot get format for counter");
688 return nullptr;
689 }
690
691 /* Generate a string version of the counter */
692 result = g_strdup_printf(format, counter);
693 g_free (format);
694 return result;
695}

◆ qof_book_is_open()

gboolean qof_book_is_open ( const QofBook book)

Definition at line 579 of file qofbook.cpp.

580{
581 g_return_val_if_fail (book, FALSE);
582 return book->book_open == 'y';
583}

◆ qof_book_is_readonly()

gboolean qof_book_is_readonly ( const QofBook book)

Return whether the book is read only.

Definition at line 497 of file qofbook.cpp.

498{
499 g_return_val_if_fail( book != nullptr, TRUE );
500 return book->read_only;
501}

◆ qof_book_mark_closed()

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.

571{
572 if (!book)
573 {
574 return;
575 }
576 book->book_open = 'n';
577}

◆ qof_book_mark_readonly()

void qof_book_mark_readonly ( QofBook book)

Mark the book as read only.

Definition at line 504 of file qofbook.cpp.

505{
506 g_return_if_fail( book != nullptr );
507 book->read_only = TRUE;
508}

◆ qof_book_mark_session_dirty()

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.

398{
399 if (!book) return;
400 if (!book->session_dirty)
401 {
402 /* Set the session dirty upfront, because the callback will check. */
403 book->session_dirty = TRUE;
404 book->dirty_time = gnc_time (nullptr);
405 if (book->dirty_cb)
406 book->dirty_cb(book, TRUE, book->dirty_data);
407 }
408}
time64 gnc_time(time64 *tbuf)
get the current time
Definition gnc-date.cpp:262

◆ qof_book_mark_session_saved()

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.

384{
385 if (!book) return;
386
387 book->dirty_time = 0;
388 if (book->session_dirty)
389 {
390 /* Set the session clean upfront, because the callback will check. */
391 book->session_dirty = FALSE;
392 if (book->dirty_cb)
393 book->dirty_cb(book, FALSE, book->dirty_data);
394 }
395}

◆ qof_book_new()

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.

291{
292 QofBook *book;
293
294 ENTER (" ");
295 book = static_cast<QofBook*>(g_object_new(QOF_TYPE_BOOK, nullptr));
297
298 qof_event_gen (&book->inst, QOF_EVENT_CREATE, nullptr);
299 LEAVE ("book=%p", book);
300 return book;
301}
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition qofevent.cpp:231
void qof_object_book_begin(QofBook *book)
To be called from within the book.
Definition qofobject.cpp:80

◆ qof_book_normalize_counter_format()

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 753 of file qofbook.cpp.

754{
755 const gchar *valid_formats [] = {
756 G_GINT64_FORMAT,
757 "lli",
758 "I64i",
759 PRIi64,
760 "li",
761 nullptr,
762 };
763 int i = 0;
764 gchar *normalized_spec = nullptr;
765
766 while (valid_formats[i])
767 {
768
769 if (err_msg && *err_msg)
770 {
771 g_free (*err_msg);
772 *err_msg = nullptr;
773 }
774
775 normalized_spec = qof_book_normalize_counter_format_internal(p, valid_formats[i], err_msg);
776 if (normalized_spec)
777 return normalized_spec; /* Found a valid format specifier, return */
778 i++;
779 }
780
781 return nullptr;
782}
gchar * qof_book_normalize_counter_format_internal(const gchar *p, const gchar *gint64_format, gchar **err_msg)
Validate a counter format string with a given format specifier.
Definition qofbook.cpp:785

◆ qof_book_option_frame_delete()

void qof_book_option_frame_delete ( QofBook book,
const char *  opt_name 
)

Definition at line 1220 of file qofbook.cpp.

1221{
1222 if (opt_name && (*opt_name != '\0'))
1223 {
1224 qof_book_begin_edit(book);
1225 auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
1226 auto opt_path = opt_name_to_path(opt_name);
1227 delete frame->set_path(opt_path, nullptr);
1228 qof_instance_set_dirty (QOF_INSTANCE (book));
1229 qof_book_commit_edit(book);
1230 }
1231}

◆ qof_book_options_delete()

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.

Parameters
bookThe book.
listA GList of keys which from a path under KVP_OPTION_PATH. If GList is Null, the whole option is deleted.

Definition at line 1399 of file qofbook.cpp.

1400{
1401 KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
1402 if (path != nullptr)
1403 {
1404 Path path_v {str_KVP_OPTION_PATH};
1405 Path tmp_path;
1406 for (auto item = path; item != nullptr; item = g_slist_next(item))
1407 tmp_path.push_back(static_cast<const char*>(item->data));
1408 delete root->set_path(gslist_to_option_path(path), nullptr);
1409 }
1410 else
1411 delete root->set_path({str_KVP_OPTION_PATH}, nullptr);
1412}

◆ qof_book_register()

gboolean qof_book_register ( void  )

Register the book object with the QOF object system.

Definition at line 1415 of file qofbook.cpp.

1416{
1417 static QofParam params[] =
1418 {
1419 { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, nullptr },
1420 { QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, nullptr },
1421 { nullptr },
1422 };
1423
1424 qof_class_register (QOF_ID_BOOK, nullptr, params);
1425
1426 return TRUE;
1427}
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
Definition qofclass.h:123
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
This function registers a new object class with the Qof subsystem.
Definition qofclass.cpp:86
const GncGUID * qof_entity_get_guid(gconstpointer ent)
#define QOF_PARAM_KVP
"Known" Object Parameters – some objects might support these
Definition qofquery.h:112

◆ qof_book_reset_num_days_autoreadonly_cache()

void qof_book_reset_num_days_autoreadonly_cache ( QofBook book)

Definition at line 980 of file qofbook.cpp.

981{
982 g_return_if_fail (book);
983 book->cached_num_days_autoreadonly_isvalid = FALSE;
984}

◆ qof_book_save_options()

void qof_book_save_options ( QofBook book,
GncOptionSave  save_cb,
GncOptionDB odb,
gboolean  clear 
)

Save a GncOptionsDB back to the book's KVP.

Parameters
bookThe book.
save_cbA callback function that does the saving.
odbThe GncOptionsDB to save from.
clearShould the GncOptionsDB be emptied after the save?

Definition at line 1340 of file qofbook.cpp.

1342{
1343 /* Wrap this in begin/commit so that it commits only once instead of doing
1344 * so for every option. Qof_book_set_option will take care of dirtying the
1345 * book.
1346 */
1347 qof_book_begin_edit (book);
1348 save_cb (odb, book, clear);
1349 qof_book_commit_edit (book);
1350}

◆ qof_book_session_not_saved()

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.

376{
377 if (!book) return FALSE;
378 return !qof_book_empty(book) && book->session_dirty;
379
380}

◆ qof_book_set_data()

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.

◆ qof_book_set_data_fin()

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.

◆ qof_book_set_default_invoice_report()

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.

Definition at line 1044 of file qofbook.cpp.

1046{
1047 const gchar *existing_guid_name = nullptr;
1048 gchar *new_guid_name;
1049
1050 if (!book)
1051 {
1052 PWARN ("No book!!!");
1053 return;
1054 }
1055
1056 if (!guid)
1057 {
1058 PWARN ("No guid!!!");
1059 return;
1060 }
1061
1062 if (!name)
1063 {
1064 PWARN ("No name!!!");
1065 return;
1066 }
1067
1068 KvpValue *value = get_option_default_invoice_report_value (book);
1069
1070 if (value)
1071 existing_guid_name = {value->get<const char*>()};
1072
1073 new_guid_name = g_strconcat (guid, "/", name, nullptr);
1074
1075 if (g_strcmp0 (existing_guid_name, new_guid_name) != 0)
1076 {
1077 auto value = new KvpValue {g_strdup(new_guid_name)};
1078 KvpFrame *root = qof_instance_get_slots (QOF_INSTANCE(book));
1079 qof_book_begin_edit (book);
1080 delete root->set_path ({KVP_OPTION_PATH,
1081 OPTION_SECTION_BUSINESS,
1082 OPTION_NAME_DEFAULT_INVOICE_REPORT}, value);
1083 qof_instance_set_dirty (QOF_INSTANCE(book));
1084 qof_book_commit_edit (book);
1085 }
1086 g_free (new_guid_name);
1087}

◆ qof_book_set_dirty_cb()

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.

Definition at line 426 of file qofbook.cpp.

427{
428 g_return_if_fail(book);
429 if (book->dirty_cb)
430 PWARN("Already existing callback %p, will be overwritten by %p\n",
431 book->dirty_cb, cb);
432 book->dirty_data = user_data;
433 book->dirty_cb = cb;
434}

◆ qof_book_set_feature()

void qof_book_set_feature ( QofBook book,
const gchar *  key,
const gchar *  descr 
)

Definition at line 1272 of file qofbook.cpp.

1273{
1274 KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
1275 KvpValue* feature = nullptr;
1276 auto feature_slot = frame->get_slot({GNC_FEATURES});
1277 if (feature_slot)
1278 {
1279 auto feature_frame = feature_slot->get<KvpFrame*>();
1280 feature = feature_frame->get_slot({key});
1281 }
1282 if (feature == nullptr || g_strcmp0 (feature->get<const char*>(), descr))
1283 {
1284 qof_book_begin_edit (book);
1285 delete frame->set_path({GNC_FEATURES, key}, new KvpValue(g_strdup (descr)));
1286 qof_instance_set_dirty (QOF_INSTANCE (book));
1287 qof_book_commit_edit (book);
1288 }
1289}

◆ qof_book_set_option()

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.

Parameters
bookThe book.
valueThe KvpValue to store.
pathA GSList of keys which form a path under KVP_OPTION_PATH.

Definition at line 1379 of file qofbook.cpp.

1380{
1381 KvpFrame *root = qof_instance_get_slots (QOF_INSTANCE (book));
1382 qof_book_begin_edit (book);
1383 delete root->set_path(gslist_to_option_path(path), value);
1384 qof_instance_set_dirty (QOF_INSTANCE (book));
1385 qof_book_commit_edit (book);
1386
1387 // Also, mark any cached value as invalid
1388 book->cached_num_field_source_isvalid = FALSE;
1389}

◆ qof_book_set_string_option()

void qof_book_set_string_option ( QofBook book,
const char *  opt_name,
const char *  opt_val 
)

Definition at line 1194 of file qofbook.cpp.

1195{
1196 qof_book_begin_edit(book);
1197 auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
1198 auto opt_path = opt_name_to_path(opt_name);
1199 if (opt_val && (*opt_val != '\0'))
1200 delete frame->set_path(opt_path, new KvpValue(g_strdup(opt_val)));
1201 else
1202 delete frame->set_path(opt_path, nullptr);
1203 qof_instance_set_dirty (QOF_INSTANCE (book));
1204 qof_book_commit_edit(book);
1205}

◆ qof_book_shutting_down()

gboolean qof_book_shutting_down ( const QofBook book)

Is the book shutting down?

Definition at line 447 of file qofbook.cpp.

448{
449 if (!book) return FALSE;
450 return book->shutting_down;
451}

◆ qof_book_swap_books_readonly()

void qof_book_swap_books_readonly ( QofBook book,
QofBook other 
)

Definition at line 585 of file qofbook.cpp.

586{
587 g_return_if_fail (book && other);
588 std::swap (book->read_only, other->read_only);
589}

◆ qof_book_unset_feature()

void qof_book_unset_feature ( QofBook book,
const gchar *  key 
)

Definition at line 1318 of file qofbook.cpp.

1319{
1320 KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
1321 auto feature_slot = frame->get_slot({GNC_FEATURES, key});
1322 if (!feature_slot)
1323 {
1324 PWARN ("no feature %s. bail out.", key);
1325 return;
1326 }
1327 qof_book_begin_edit (book);
1328 delete frame->set_path({GNC_FEATURES, key}, nullptr);
1329 qof_instance_set_dirty (QOF_INSTANCE (book));
1330 qof_book_commit_edit (book);
1331}

◆ qof_book_use_split_action_for_num_field()

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.

Definition at line 30 of file gmock-qofbook.cpp.

31{
32 SCOPED_TRACE("");
33 auto mockbook = qof_mockbook(book);
34 return mockbook ? mockbook->use_split_action_for_num_field() : FALSE;
35}

◆ qof_book_use_trading_accounts()

gboolean qof_book_use_trading_accounts ( const QofBook book)

Returns flag indicating whether this book uses trading accounts.

Definition at line 921 of file qofbook.cpp.

922{
923 char *opt = nullptr;
924 qof_instance_get (QOF_INSTANCE (book), "trading-accts", &opt, nullptr);
925 auto retval = (opt && opt[0] == 't' && opt[1] == 0);
926 g_free (opt);
927 return retval;
928}

◆ qof_book_uses_autoreadonly()

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 974 of file qofbook.cpp.

975{
976 g_assert(book);
977 return (qof_book_get_num_days_autoreadonly(book) != 0);
978}