GnuCash c935c2f+
Loading...
Searching...
No Matches
qofbook.h
Go to the documentation of this file.
1/********************************************************************\
2 * qofbook.h -- Encapsulate all the information about a dataset. *
3 * This program is free software; you can redistribute it and/or *
4 * modify it under the terms of the GNU General Public License as *
5 * published by the Free Software Foundation; either version 2 of *
6 * the License, or (at your option) any later version. *
7 * *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU General Public License*
14 * along with this program; if not, contact: *
15 * *
16 * Free Software Foundation Voice: +1-617-542-5942 *
17 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
18 * Boston, MA 02110-1301, USA gnu@gnu.org *
19 * *
20\********************************************************************/
40#ifndef QOF_BOOK_H
41#define QOF_BOOK_H
42
43#include <glib.h>
44#ifdef __cplusplus
45class GncOptionDB;
46#else
47typedef struct GncOptionDB GncOptionDB;
48#endif
49/* We only want a few things exported to Guile */
50#ifndef SWIG
51
52typedef struct _QofBookClass QofBookClass;
53#ifndef __KVP_VALUE
54typedef struct KvpValueImpl KvpValue;
55#define __KVP_VALUE
56#endif
57
58#include "qofid.h"
59#include "qofinstance.h"
60#include "qofbackend.h"
61
62#ifdef __cplusplus
63extern "C"
64{
65#endif
66
67/* --- type macros --- */
68#define QOF_TYPE_BOOK (qof_book_get_type ())
69#define QOF_BOOK(o) \
70 (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
71#define QOF_BOOK_CLASS(k) \
72 (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
73#define QOF_IS_BOOK(o) \
74 (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
75#define QOF_IS_BOOK_CLASS(k) \
76 (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
77#define QOF_BOOK_GET_CLASS(o) \
78 (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
79
80typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
81
82typedef void (*GncOptionSave) (GncOptionDB*, QofBook*, gboolean);
83typedef void (*GncOptionLoad) (GncOptionDB*, QofBook*);
84
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
API for data storage Backend.
QOF entity type identification system.
Object instance holds common fields that most gnucash objects use.
The type used to store guids in C.
Definition guid.h:75
Implements KvpValue using boost::variant.
Definition kvp-value.hpp:53
QofBook reference.
Definition qofbook-p.hpp:47