45 #ifdef GNC_PLATFORM_WINDOWS 47 #define __STDC_FORMAT_MACROS = 1 54 #include "qofevent-p.h" 56 #include "qofbook-p.h" 59 #include "qofbookslots.h" 60 #include "kvp-frame.hpp" 64 static QofLogModule log_module = QOF_MOD_ENGINE;
66 #define AB_TEMPLATES "template-list" 73 PROP_OPT_TRADING_ACCOUNTS,
74 PROP_OPT_AUTO_READONLY_DAYS,
75 PROP_OPT_NUM_FIELD_SOURCE,
76 PROP_OPT_DEFAULT_BUDGET,
83 qof_book_option_num_field_source_changed_cb (GObject *gobject,
87 qof_book_option_num_autoreadonly_changed_cb (GObject *gobject,
92 #define PARAM_NAME_NUM_FIELD_SOURCE "split-action-num-field" 93 #define PARAM_NAME_NUM_AUTOREAD_ONLY "autoreadonly-days" 95 G_DEFINE_TYPE(QofBook, qof_book, QOF_TYPE_INSTANCE);
96 QOF_GOBJECT_DISPOSE(qof_book);
97 QOF_GOBJECT_FINALIZE(qof_book);
99 static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
100 #undef G_PARAM_READWRITE 101 #define G_PARAM_READWRITE static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE) 105 static void coll_destroy(gpointer col)
111 qof_book_init (QofBook *book)
115 book->hash_of_collections = g_hash_table_new_full(
116 g_str_hash, g_str_equal,
122 book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
123 book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
125 book->book_open =
'y';
126 book->read_only = FALSE;
127 book->session_dirty = FALSE;
129 book->cached_num_field_source_isvalid = FALSE;
130 book->cached_num_days_autoreadonly_isvalid = FALSE;
135 g_signal_connect (G_OBJECT(book),
136 "notify::" PARAM_NAME_NUM_FIELD_SOURCE,
137 G_CALLBACK (qof_book_option_num_field_source_changed_cb),
143 g_signal_connect (G_OBJECT(book),
144 "notify::" PARAM_NAME_NUM_AUTOREAD_ONLY,
145 G_CALLBACK (qof_book_option_num_autoreadonly_changed_cb),
149 static const std::string str_KVP_OPTION_PATH(KVP_OPTION_PATH);
150 static const std::string str_OPTION_SECTION_ACCOUNTS(OPTION_SECTION_ACCOUNTS);
151 static const std::string str_OPTION_SECTION_BUDGETING(OPTION_SECTION_BUDGETING);
152 static const std::string str_OPTION_NAME_DEFAULT_BUDGET(OPTION_NAME_DEFAULT_BUDGET);
153 static const std::string str_OPTION_NAME_TRADING_ACCOUNTS(OPTION_NAME_TRADING_ACCOUNTS);
154 static const std::string str_OPTION_NAME_AUTO_READONLY_DAYS(OPTION_NAME_AUTO_READONLY_DAYS);
155 static const std::string str_OPTION_NAME_NUM_FIELD_SOURCE(OPTION_NAME_NUM_FIELD_SOURCE);
158 qof_book_get_property (GObject*
object,
166 g_return_if_fail (QOF_IS_BOOK (
object));
167 book = QOF_BOOK (
object);
170 case PROP_OPT_TRADING_ACCOUNTS:
171 qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
172 str_OPTION_SECTION_ACCOUNTS, str_OPTION_NAME_TRADING_ACCOUNTS});
174 case PROP_OPT_AUTO_READONLY_DAYS:
175 qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
176 str_OPTION_SECTION_ACCOUNTS, str_OPTION_NAME_AUTO_READONLY_DAYS});
178 case PROP_OPT_NUM_FIELD_SOURCE:
179 qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
180 str_OPTION_SECTION_ACCOUNTS, str_OPTION_NAME_NUM_FIELD_SOURCE});
182 case PROP_OPT_DEFAULT_BUDGET:
183 qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
184 str_OPTION_SECTION_BUDGETING, str_OPTION_NAME_DEFAULT_BUDGET});
186 case PROP_OPT_FY_END:
187 qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {
"fy_end"});
189 case PROP_AB_TEMPLATES:
190 qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {
"AB_KEY",
"AB_TEMPLATES"});
193 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
199 qof_book_set_property (GObject *
object,
207 g_return_if_fail (QOF_IS_BOOK (
object));
208 book = QOF_BOOK (
object);
209 g_assert (qof_instance_get_editlevel(book));
213 case PROP_OPT_TRADING_ACCOUNTS:
214 qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
215 str_OPTION_SECTION_ACCOUNTS, str_OPTION_NAME_TRADING_ACCOUNTS});
217 case PROP_OPT_AUTO_READONLY_DAYS:
218 qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
219 str_OPTION_SECTION_ACCOUNTS, str_OPTION_NAME_AUTO_READONLY_DAYS});
221 case PROP_OPT_NUM_FIELD_SOURCE:
222 qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
223 str_OPTION_SECTION_ACCOUNTS, str_OPTION_NAME_NUM_FIELD_SOURCE});
225 case PROP_OPT_DEFAULT_BUDGET:
226 qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
227 str_OPTION_SECTION_BUDGETING, OPTION_NAME_DEFAULT_BUDGET});
229 case PROP_OPT_FY_END:
230 qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {
"fy_end"});
232 case PROP_AB_TEMPLATES:
233 qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {AB_KEY, AB_TEMPLATES});
236 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
242 qof_book_class_init (QofBookClass *klass)
244 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
245 gobject_class->dispose = qof_book_dispose;
246 gobject_class->finalize = qof_book_finalize;
247 gobject_class->get_property = qof_book_get_property;
248 gobject_class->set_property = qof_book_set_property;
250 g_object_class_install_property
252 PROP_OPT_TRADING_ACCOUNTS,
253 g_param_spec_string(
"trading-accts",
254 "Use Trading Accounts",
255 "Scheme true ('t') or NULL. If 't', then the book " 256 "uses trading accounts for managing multiple-currency " 261 g_object_class_install_property
263 PROP_OPT_NUM_FIELD_SOURCE,
264 g_param_spec_string(PARAM_NAME_NUM_FIELD_SOURCE,
265 "Use Split-Action in the Num Field",
266 "Scheme true ('t') or NULL. If 't', then the book " 267 "will put the split action value in the Num field.",
271 g_object_class_install_property
273 PROP_OPT_AUTO_READONLY_DAYS,
274 g_param_spec_double(
"autoreadonly-days",
275 "Transaction Auto-read-only Days",
276 "Prevent editing of transactions posted more than " 277 "this many days ago.",
283 g_object_class_install_property
285 PROP_OPT_DEFAULT_BUDGET,
286 g_param_spec_boxed(
"default-budget",
287 "Book Default Budget",
288 "The default Budget for this book.",
291 g_object_class_install_property
294 g_param_spec_boxed(
"fy-end",
295 "Book Fiscal Year End",
296 "A GDate with a bogus year having the last Month and " 297 "Day of the Fiscal year for the book.",
300 g_object_class_install_property
303 g_param_spec_boxed(
"ab-templates",
304 "AQBanking Template List",
305 "A GList of AQBanking Templates",
316 book =
static_cast<QofBook*
>(g_object_new(QOF_TYPE_BOOK, NULL));
320 LEAVE (
"book=%p", book);
325 book_final (gpointer key, gpointer value, gpointer booq)
327 QofBookFinalCB cb =
reinterpret_cast<QofBookFinalCB
>(value);
328 QofBook *book =
static_cast<QofBook*
>(booq);
330 gpointer user_data = g_hash_table_lookup (book->data_tables, key);
331 (*cb) (book, key, user_data);
335 qof_book_dispose_real (G_GNUC_UNUSED GObject *bookp)
340 qof_book_finalize_real (G_GNUC_UNUSED GObject *bookp)
350 ENTER (
"book=%p", book);
352 book->shutting_down = TRUE;
353 qof_event_force (&book->inst, QOF_EVENT_DESTROY, NULL);
358 g_hash_table_foreach (book->data_table_finalizers, book_final, book);
360 qof_object_book_end (book);
362 g_hash_table_destroy (book->data_table_finalizers);
363 book->data_table_finalizers = NULL;
364 g_hash_table_destroy (book->data_tables);
365 book->data_tables = NULL;
374 cols = book->hash_of_collections;
375 g_object_unref (book);
376 g_hash_table_destroy (cols);
379 LEAVE (
"book=%p", book);
387 if (!book)
return FALSE;
397 book->dirty_time = 0;
398 if (book->session_dirty)
401 book->session_dirty = FALSE;
403 book->dirty_cb(book, FALSE, book->dirty_data);
410 if (!book->session_dirty)
413 book->session_dirty = TRUE;
416 book->dirty_cb(book, TRUE, book->dirty_data);
424 PINFO(
"book is dirty.");
425 qof_book_foreach_collection
432 return book->dirty_time;
438 g_return_if_fail(book);
440 PWARN(
"Already existing callback %p, will be overwritten by %p\n",
442 book->dirty_data = user_data;
452 if (!book)
return NULL;
453 return book->backend;
459 if (!book)
return FALSE;
460 return book->shutting_down;
467 qof_book_set_backend (QofBook *book,
QofBackend *be)
470 ENTER (
"book=%p be=%p", book, be);
482 if (!book || !key)
return;
483 g_hash_table_insert (book->data_tables, (gpointer)key, data);
489 if (!book || !key)
return;
490 g_hash_table_insert (book->data_tables, (gpointer)key, data);
493 g_hash_table_insert (book->data_table_finalizers, (gpointer)key,
494 reinterpret_cast<void*>(cb));
500 if (!book || !key)
return NULL;
501 return g_hash_table_lookup (book->data_tables, (gpointer)key);
508 g_return_val_if_fail( book != NULL, TRUE );
509 return book->read_only;
515 g_return_if_fail( book != NULL );
516 book->read_only = TRUE;
522 if (!book)
return TRUE;
534 if (!book || !entity_type)
return NULL;
536 col =
static_cast<QofCollection*
>(g_hash_table_lookup (book->hash_of_collections, entity_type));
541 book->hash_of_collections,
554 foreach_cb (G_GNUC_UNUSED gpointer key, gpointer item, gpointer arg)
557 QofCollection *col =
static_cast<QofCollection*
>(item);
559 iter->fn (col, iter->data);
563 qof_book_foreach_collection (
const QofBook *book,
568 g_return_if_fail (book);
569 g_return_if_fail (cb);
572 iter.data = user_data;
574 g_hash_table_foreach (book->hash_of_collections, foreach_cb, &iter);
585 book->book_open =
'n';
596 PWARN (
"No book!!!");
600 if (!counter_name || *counter_name ==
'\0')
602 PWARN (
"Invalid counter name.");
607 kvp = qof_instance_get_slots (QOF_INSTANCE (book));
611 PWARN (
"Book has no KVP_Frame");
615 value = kvp->get_slot({
"counters", counter_name});
619 return value->get<int64_t>();
639 PWARN (
"No book!!!");
643 if (!counter_name || *counter_name ==
'\0')
645 PWARN (
"Invalid counter name.");
660 kvp = qof_instance_get_slots (QOF_INSTANCE (book));
664 PWARN (
"Book has no KVP_Frame");
669 qof_book_begin_edit(book);
670 value =
new KvpValue(counter);
671 delete kvp->set_path({
"counters", counter_name}, value);
672 qof_instance_set_dirty (QOF_INSTANCE (book));
673 qof_book_commit_edit(book);
679 PWARN(
"Cannot get format for counter");
684 result = g_strdup_printf(format, counter);
693 const char *user_format = NULL;
694 gchar *norm_format = NULL;
700 PWARN (
"No book!!!");
704 if (!counter_name || *counter_name ==
'\0')
706 PWARN (
"Invalid counter name.");
711 kvp = qof_instance_get_slots (QOF_INSTANCE (book));
715 PWARN (
"Book has no KVP_Frame");
720 value = kvp->get_slot({
"counter_formats", counter_name});
723 user_format = value->get<
const char*>();
727 PWARN(
"Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", user_format, counter_name, error);
739 norm_format = g_strdup (
"%.6" PRIi64);
747 const gchar *valid_formats [] = {
756 gchar *normalized_spec = NULL;
758 while (valid_formats[i])
761 if (err_msg && *err_msg)
769 return normalized_spec;
778 const gchar *gint64_format, gchar **err_msg)
780 const gchar *conv_start, *base, *tmp = NULL;
781 gchar *normalized_str = NULL, *aux_str = NULL;
794 if (p[0] ==
'%' && p[1] ==
'%')
810 *err_msg = g_strdup(
"Format string ended without any conversion specification");
822 tmp = strstr(p, gint64_format);
827 *err_msg = g_strdup_printf(
"Format string doesn't contain requested format specifier: %s", gint64_format);
832 while (*p && (tmp != p) && strchr(
"#0- +'I", *p))
835 tmp = strstr(p, gint64_format);
840 while (*p && (tmp != p) && strchr(
"0123456789.", *p))
843 tmp = strstr(p, gint64_format);
849 *err_msg = g_strdup_printf(
"Format string ended during the conversion specification. Conversion seen so far: %s", conv_start);
855 tmp = strstr(p, gint64_format);
859 *err_msg = g_strdup_printf(
"Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format);
865 *err_msg = g_strdup_printf(
"Garbage before length modifier and/or conversion specifier: '%*s'", (
int)(tmp - p), p);
870 aux_str = g_strndup (base, p - base);
871 normalized_str = g_strconcat (aux_str, PRIi64,
nullptr);
875 p += strlen(gint64_format);
883 if (p[0] ==
'%' && p[1] ==
'%')
893 *err_msg = g_strdup_printf(
"Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p);
894 g_free (normalized_str);
902 aux_str = normalized_str;
903 normalized_str = g_strconcat (aux_str, tmp,
nullptr);
908 return normalized_str;
917 auto retval = (opt && opt[0] ==
't' && opt[1] == 0);
927 g_return_val_if_fail (book, FALSE);
928 if (!book->cached_num_field_source_isvalid)
934 PARAM_NAME_NUM_FIELD_SOURCE, &opt,
937 if (opt && opt[0] ==
't' && opt[1] == 0)
946 const_cast<QofBook*
>(book)->cached_num_field_source = result;
947 const_cast<QofBook*
>(book)->cached_num_field_source_isvalid = TRUE;
950 return book->cached_num_field_source;
957 qof_book_option_num_field_source_changed_cb (GObject *gobject,
961 QofBook *book =
reinterpret_cast<QofBook*
>(user_data);
962 g_return_if_fail(QOF_IS_BOOK(book));
963 book->cached_num_field_source_isvalid = FALSE;
976 if (!book->cached_num_days_autoreadonly_isvalid)
982 PARAM_NAME_NUM_AUTOREAD_ONLY, &tmp,
985 const_cast<QofBook*
>(book)->cached_num_days_autoreadonly = tmp;
986 const_cast<QofBook*
>(book)->cached_num_days_autoreadonly_isvalid = TRUE;
989 return (gint) book->cached_num_days_autoreadonly;
995 GDate* result = NULL;
1002 g_date_subtract_days(result, num_days);
1011 qof_book_option_num_autoreadonly_changed_cb (GObject *gobject,
1015 QofBook *book =
reinterpret_cast<QofBook*
>(user_data);
1016 g_return_if_fail(QOF_IS_BOOK(book));
1017 book->cached_num_days_autoreadonly_isvalid = FALSE;
1022 static Path opt_name_to_path (
const char* opt_name)
1025 g_return_val_if_fail (opt_name, result);
1026 auto opt_name_list = g_strsplit(opt_name,
"/", -1);
1027 for (
int i=0; opt_name_list[i]; i++)
1028 result.push_back (opt_name_list[i]);
1029 g_strfreev (opt_name_list);
1034 qof_book_get_string_option(
const QofBook* book,
const char* opt_name)
1036 auto slot = qof_instance_get_slots(QOF_INSTANCE (book))->get_slot(opt_name_to_path(opt_name));
1037 if (slot ==
nullptr)
1039 return slot->get<
const char*>();
1043 qof_book_set_string_option(QofBook* book,
const char* opt_name,
const char* opt_val)
1045 qof_book_begin_edit(book);
1046 auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
1047 auto opt_path = opt_name_to_path(opt_name);
1048 if (opt_val && (*opt_val !=
'\0'))
1049 delete frame->set_path(opt_path,
new KvpValue(g_strdup(opt_val)));
1051 delete frame->set_path(opt_path,
nullptr);
1052 qof_instance_set_dirty (QOF_INSTANCE (book));
1053 qof_book_commit_edit(book);
1057 qof_book_get_guid_option(QofBook* book, GSList* path)
1059 g_return_val_if_fail(book !=
nullptr,
nullptr);
1060 g_return_val_if_fail(path !=
nullptr,
nullptr);
1065 return table_value->get<
GncGUID*>();
1069 qof_book_option_frame_delete (QofBook *book,
const char* opt_name)
1071 if (opt_name && (*opt_name !=
'\0'))
1073 qof_book_begin_edit(book);
1074 auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
1075 auto opt_path = opt_name_to_path(opt_name);
1076 delete frame->set_path(opt_path,
nullptr);
1077 qof_instance_set_dirty (QOF_INSTANCE (book));
1078 qof_book_commit_edit(book);
1083 qof_book_begin_edit (QofBook *book)
1090 PERR (
"Failed to commit: %d", errcode);
1094 #define GNC_FEATURES "features" 1096 add_feature_to_hash (
const gchar *key, KvpValue *value, GHashTable * user_data)
1098 gchar *descr = g_strdup(value->get<
const char*>());
1099 g_hash_table_insert (user_data, (gchar*)key, descr);
1105 KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
1106 GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal,
1109 auto slot = frame->get_slot({GNC_FEATURES});
1110 if (slot !=
nullptr)
1112 frame = slot->get<KvpFrame*>();
1113 frame->for_each_slot_temp(&add_feature_to_hash, features);
1119 qof_book_set_feature (QofBook *book,
const gchar *key,
const gchar *descr)
1121 KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
1122 KvpValue* feature =
nullptr;
1123 auto feature_slot = frame->get_slot({GNC_FEATURES});
1126 auto feature_frame = feature_slot->get<KvpFrame*>();
1127 feature = feature_frame->get_slot({key});
1129 if (feature ==
nullptr || g_strcmp0 (feature->get<
const char*>(), descr))
1131 qof_book_begin_edit (book);
1132 delete frame->set_path({GNC_FEATURES, key},
new KvpValue(g_strdup (descr)));
1133 qof_instance_set_dirty (QOF_INSTANCE (book));
1134 qof_book_commit_edit (book);
1140 qof_book_unset_feature (QofBook *book,
const gchar *key,
const gchar *descr)
1142 KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
1143 KvpValue* feature =
nullptr;
1144 auto feature_slot = frame->get_slot({GNC_FEATURES});
1147 auto feature_frame = feature_slot->get<KvpFrame*>();
1148 feature = feature_frame->get_slot({key});
1150 if (feature ==
nullptr || g_strcmp0 (feature->get<
const char*>(), descr))
1152 qof_book_begin_edit (book);
1153 delete frame->set_path({GNC_FEATURES, key},
nullptr);
1154 qof_instance_set_dirty (QOF_INSTANCE (book));
1155 qof_book_commit_edit (book);
1162 load_cb (odb, book);
1173 qof_book_begin_edit (book);
1174 save_cb (odb, book, clear);
1175 qof_book_commit_edit (book);
1181 qof_book_commit_edit(QofBook *book)
1189 static Path gslist_to_option_path (GSList *gspath)
1192 if (!gspath)
return tmp_path;
1194 Path path_v {str_KVP_OPTION_PATH};
1195 for (
auto item = gspath; item !=
nullptr; item = g_slist_next(item))
1196 tmp_path.push_back(static_cast<const char*>(item->data));
1197 if ((tmp_path.front() ==
"counters") || (tmp_path.front() ==
"counter_formats"))
1200 path_v.insert(path_v.end(), tmp_path.begin(), tmp_path.end());
1207 KvpFrame *root = qof_instance_get_slots (QOF_INSTANCE (book));
1208 qof_book_begin_edit (book);
1209 delete root->set_path(gslist_to_option_path(path), value);
1210 qof_instance_set_dirty (QOF_INSTANCE (book));
1211 qof_book_commit_edit (book);
1214 book->cached_num_field_source_isvalid = FALSE;
1220 KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
1221 return root->get_slot(gslist_to_option_path(path));
1227 KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
1228 if (path !=
nullptr)
1230 Path path_v {str_KVP_OPTION_PATH};
1232 for (
auto item = path; item !=
nullptr; item = g_slist_next(item))
1233 tmp_path.push_back(static_cast<const char*>(item->data));
1234 delete root->set_path(gslist_to_option_path(path),
nullptr);
1237 delete root->set_path({str_KVP_OPTION_PATH},
nullptr);
1243 static QofParam params[] =
Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections.
API for data storage Backend.
void qof_book_load_options(QofBook *book, GncOptionLoad load_cb, GncOptionDB *odb)
Load a GncOptionsDB from KVP data.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
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.
KvpValue * qof_book_get_option(QofBook *book, GSList *path)
Read a single option value.
void(* QofCollectionForeachCB)(QofCollection *, gpointer user_data)
Invoke the indicated callback on each collection in the book.
gboolean qof_book_register(void)
Register the book object with the QOF object system.
#define PINFO(format, args...)
Print an informational note.
void qof_object_book_begin(QofBook *book)
To be called from within the book.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
time64 qof_book_get_session_dirty_time(const QofBook *book)
Retrieve the earliest modification time on the 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.
gint qof_book_get_num_days_autoreadonly(const QofBook *book)
Returns the number of days for auto-read-only transactions.
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_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
This function registers a new object class with the Qof subsystem.
QofBook * qof_book_new(void)
Allocate, initialise and return a new QofBook.
void qof_book_mark_closed(QofBook *book)
Close a book to editing.
char * qof_book_get_counter_format(const QofBook *book, const char *counter_name)
Get the format string to use for the named counter.
void qof_book_mark_readonly(QofBook *book)
Mark the book as read only.
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
GHashTable * qof_book_get_features(QofBook *book)
Access functions for reading and setting the used-features on this book.
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 ...
the Core Object Registration/Lookup Private Interface
#define PWARN(format, args...)
Log a warning.
gint64 qof_book_get_counter(QofBook *book, const char *counter_name)
This will get the named counter for this book.
gboolean qof_book_empty(const QofBook *book)
Check if the book has had anything loaded into it.
const gchar * QofIdType
QofIdType declaration.
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.
gboolean qof_begin_edit(QofInstance *inst)
begin_edit
void qof_book_save_options(QofBook *book, GncOptionSave save_cb, GncOptionDB *odb, gboolean clear)
Save a GncOptionsDB back to the book's KVP.
GDate * qof_book_get_autoreadonly_gdate(const QofBook *book)
Returns the GDate that is the threshold for auto-read-only.
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_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...
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_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
gchar * qof_book_normalize_counter_format(const gchar *p, gchar **err_msg)
Validate a counter format string.
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.
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...
const GncGUID * qof_entity_get_guid(gconstpointer ent)
#define QOF_PARAM_KVP
"Known" Object Parameters – some objects might support these
void qof_collection_destroy(QofCollection *col)
destroy the collection
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
This is the private header for the account structure.
void qof_book_print_dirty(const QofBook *book)
This debugging function can be used to traverse the book structure and all subsidiary structures...
#define LEAVE(format, args...)
Print a function exit debugging message.
time64 gnc_time(time64 *tbuf)
get the current local time
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
gpointer qof_collection_get_data(const QofCollection *col)
Store and retrieve arbitrary object-defined data.
void qof_book_set_option(QofBook *book, KvpValue *value, GSList *path)
Save a single option value.
gboolean qof_book_uses_autoreadonly(const QofBook *book)
Returns TRUE if the auto-read-only feature should be used, otherwise FALSE.
QofBackend * qof_book_get_backend(const QofBook *book)
Retrieve the backend used by this book.
gboolean qof_book_shutting_down(const QofBook *book)
Is the book shutting down?
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
void qof_book_options_delete(QofBook *book, GSList *path)
Delete the options.
The type used to store guids in C.
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_use_trading_accounts(const QofBook *book)
Returns flag indicating whether this book uses trading accounts.
void qof_string_cache_remove(const char *key)
You can use this function as a destroy notifier for a GHashTable that uses common strings as keys (or...
void qof_book_destroy(QofBook *book)
End any editing sessions associated with book, and free all memory associated with it...
QofCollection * qof_collection_new(QofIdType type)
create a new collection of entities of type
GDate * gnc_g_date_new_today()
Returns a newly allocated date of the current clock time, taken from time(2).