38 #include "qofbook-p.h" 40 #include "kvp-frame.hpp" 41 #include "qofinstance-p.h" 42 #include "qof-backend.hpp" 44 static QofLogModule log_module = QOF_MOD_ENGINE;
104 guint32 version_check;
111 #define GET_PRIVATE(o) \ 112 ((QofInstancePrivate*)qof_instance_get_instance_private((QofInstance*)o)) 114 G_DEFINE_TYPE_WITH_PRIVATE(
QofInstance, qof_instance, G_TYPE_OBJECT)
115 QOF_GOBJECT_FINALIZE(qof_instance);
116 #undef G_PARAM_READWRITE 117 #define G_PARAM_READWRITE static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE) 119 static void qof_instance_get_property (GObject *
object,
123 static void qof_instance_set_property (GObject *
object,
127 static void qof_instance_dispose(GObject*);
128 static void qof_instance_class_init(QofInstanceClass *klass)
130 GObjectClass *object_class = G_OBJECT_CLASS(klass);
131 object_class->finalize = qof_instance_finalize;
132 object_class->dispose = qof_instance_dispose;
133 object_class->set_property = qof_instance_set_property;
134 object_class->get_property = qof_instance_get_property;
136 klass->get_display_name =
nullptr;
137 klass->refers_to_object =
nullptr;
138 klass->get_typed_referring_object_list =
nullptr;
140 g_object_class_install_property
143 g_param_spec_boxed (
"guid",
145 "The object Globally Unique ID.",
149 g_object_class_install_property
152 g_param_spec_pointer (
"collection",
154 "A collection of like objects of which this " 155 "particular object is amember. E.g.. A " 156 "collection of accounts, or a collection of " 160 g_object_class_install_property
163 g_param_spec_object (
"book",
165 "The book that contains this object.",
169 g_object_class_install_property
172 g_param_spec_pointer (
"last-update",
173 "Object Last Update",
174 "A pointer to the last time this object was " 175 "updated. This value is present for use by " 176 "backends and shouldn't be written by other " 180 g_object_class_install_property
183 g_param_spec_int (
"editlevel",
185 "The object edit level.",
189 g_object_class_install_property
192 g_param_spec_boolean (
"destroying",
194 "This flag is set to TRUE if the object is " 195 "about to be destroyed.",
199 g_object_class_install_property
202 g_param_spec_boolean (
"dirty",
204 "This flag is set to TRUE if the object has " 209 g_object_class_install_property
212 g_param_spec_boolean (
"infant",
214 "This flag is set to TRUE if the object has " 215 "never been added to a book. This implies " 216 "that its destruction does not affect the " 217 "state of the book, and therefore the saved " 218 "state of the data file.",
222 g_object_class_install_property
225 g_param_spec_int (
"version",
227 "The version number of the current instance state.",
233 g_object_class_install_property
236 g_param_spec_uint (
"version-check",
238 "The version check number of the current instance state.",
244 g_object_class_install_property
247 g_param_spec_uint (
"idata",
249 "Per instance backend private data.",
259 priv = GET_PRIVATE(inst);
260 priv->book =
nullptr;
261 inst->kvp_data =
new KvpFrame;
262 priv->last_update = 0;
264 priv->do_free = FALSE;
276 g_return_if_fail(QOF_IS_INSTANCE(inst));
277 priv = GET_PRIVATE(inst);
278 g_return_if_fail(!priv->book);
282 g_return_if_fail(col !=
nullptr);
288 if (g_strcmp0(col_type, type))
290 PERR (
"attempt to insert \"%s\" into \"%s\"", type, col_type);
293 priv = GET_PRIVATE(inst);
303 PWARN(
"duplicate id created, trying again");
313 qof_instance_dispose (GObject *instp)
318 priv = GET_PRIVATE(instp);
320 qof_collection_remove_entity(inst);
322 CACHE_REMOVE(inst->
e_type);
325 G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp);
329 qof_instance_finalize_real (GObject *instp)
334 delete inst->kvp_data;
335 inst->kvp_data =
nullptr;
337 priv = GET_PRIVATE(inst);
339 priv->do_free = FALSE;
350 qof_instance_get_property (GObject *
object,
358 g_return_if_fail(QOF_IS_INSTANCE(
object));
360 inst = QOF_INSTANCE(
object);
361 priv = GET_PRIVATE(inst);
366 g_value_set_boxed(value, &priv->
guid);
368 case PROP_COLLECTION:
372 g_value_take_object(value, priv->book);
374 case PROP_LAST_UPDATE:
375 g_value_set_pointer(value, &priv->last_update);
378 g_value_set_int(value, priv->editlevel);
380 case PROP_DESTROYING:
381 g_value_set_boolean(value, priv->do_free);
384 g_value_set_boolean(value, qof_instance_get_dirty(inst));
387 g_value_set_boolean(value, priv->infant);
390 g_value_set_int(value, priv->version);
392 case PROP_VERSION_CHECK:
393 g_value_set_uint(value, priv->version_check);
396 g_value_set_uint(value, priv->idata);
399 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
405 qof_instance_set_property (GObject *
object,
413 g_return_if_fail(QOF_IS_INSTANCE(
object));
415 inst = QOF_INSTANCE(
object);
420 qof_instance_set_guid(inst,
421 static_cast<GncGUID*>(g_value_get_boxed(value)));
423 case PROP_COLLECTION:
424 qof_instance_set_collection(inst, static_cast<QofCollection*>(g_value_get_pointer(value)));
428 static_cast<QofBook*>(g_value_get_object(value)));
430 case PROP_LAST_UPDATE:
431 t = *(
static_cast<Time64*
>(g_value_get_pointer(value)));
432 qof_instance_set_last_update(inst, t.t);
434 case PROP_DESTROYING:
435 qof_instance_set_destroying(inst, g_value_get_boolean(value));
438 qof_instance_set_dirty(inst);
441 qof_instance_set_version(inst, g_value_get_int(value));
443 case PROP_VERSION_CHECK:
444 qof_instance_set_version_check(inst, g_value_get_uint(value));
447 qof_instance_set_idata(inst, g_value_get_uint(value));
450 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
460 if (!inst)
return nullptr;
461 g_return_val_if_fail(QOF_IS_INSTANCE(inst),
guid_null());
462 priv = GET_PRIVATE(inst);
463 return &(priv->
guid);
473 qof_instance_set_guid (gpointer ptr,
const GncGUID *guid)
479 g_return_if_fail(QOF_IS_INSTANCE(ptr));
481 inst = QOF_INSTANCE(ptr);
482 priv = GET_PRIVATE(inst);
487 qof_collection_remove_entity(inst);
493 qof_instance_copy_guid (gpointer to, gconstpointer from)
495 g_return_if_fail(QOF_IS_INSTANCE(to));
496 g_return_if_fail(QOF_IS_INSTANCE(from));
498 GET_PRIVATE(to)->guid = GET_PRIVATE(from)->guid;
506 g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), -1);
507 g_return_val_if_fail(QOF_IS_INSTANCE(ptr2), 1);
509 priv1 = GET_PRIVATE(ptr1);
510 priv2 = GET_PRIVATE(ptr2);
512 return guid_compare(&priv1->
guid, &priv2->
guid);
519 g_return_val_if_fail(QOF_IS_INSTANCE(ptr),
nullptr);
520 return GET_PRIVATE(ptr)->collection;
524 qof_instance_set_collection (gconstpointer ptr, QofCollection *col)
526 g_return_if_fail(QOF_IS_INSTANCE(ptr));
527 GET_PRIVATE(ptr)->collection = col;
533 if (!inst)
return nullptr;
534 g_return_val_if_fail(QOF_IS_INSTANCE(inst),
nullptr);
535 return GET_PRIVATE(inst)->book;
541 g_return_if_fail(QOF_IS_INSTANCE(inst));
542 GET_PRIVATE(inst)->book = book;
548 g_return_if_fail(QOF_IS_INSTANCE(ptr1));
549 g_return_if_fail(QOF_IS_INSTANCE(ptr2));
551 GET_PRIVATE(ptr1)->book = GET_PRIVATE(ptr2)->book;
559 g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), FALSE);
560 g_return_val_if_fail(QOF_IS_INSTANCE(ptr2), FALSE);
562 priv1 = GET_PRIVATE(ptr1);
563 priv2 = GET_PRIVATE(ptr2);
565 return (priv1->book == priv2->book);
572 if (!inst)
return nullptr;
573 return inst->kvp_data;
577 qof_instance_set_slots (
QofInstance *inst, KvpFrame *frm)
583 priv = GET_PRIVATE(inst);
584 if (inst->kvp_data && (inst->kvp_data != frm))
586 delete inst->kvp_data;
590 inst->kvp_data = frm;
597 GET_PRIVATE(inst)->last_update = t;
601 qof_instance_get_editlevel (gconstpointer ptr)
603 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), 0);
604 return GET_PRIVATE(ptr)->editlevel;
607 void qof_instance_increase_editlevel (gpointer ptr)
609 g_return_if_fail(QOF_IS_INSTANCE(ptr));
610 GET_PRIVATE(ptr)->editlevel++;
613 void qof_instance_decrease_editlevel (gpointer ptr)
615 g_return_if_fail(QOF_IS_INSTANCE(ptr));
616 GET_PRIVATE(ptr)->editlevel--;
619 void qof_instance_reset_editlevel (gpointer ptr)
621 g_return_if_fail(QOF_IS_INSTANCE(ptr));
622 GET_PRIVATE(ptr)->editlevel = 0;
630 if (!left && !right)
return 0;
631 if (!left)
return -1;
632 if (!right)
return +1;
634 lpriv = GET_PRIVATE(left);
635 rpriv = GET_PRIVATE(right);
636 return lpriv->last_update < rpriv->last_update ? -1 :
637 lpriv->last_update > rpriv->last_update ? 1 : 0;
643 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
644 return GET_PRIVATE(ptr)->do_free;
648 qof_instance_set_destroying (gpointer ptr, gboolean value)
650 g_return_if_fail(QOF_IS_INSTANCE(ptr));
651 GET_PRIVATE(ptr)->do_free = value;
657 g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
658 return GET_PRIVATE(ptr)->dirty;
662 qof_instance_set_dirty_flag (gconstpointer inst, gboolean flag)
664 g_return_if_fail(QOF_IS_INSTANCE(inst));
665 GET_PRIVATE(inst)->dirty = flag;
672 GET_PRIVATE(inst)->dirty = FALSE;
676 qof_instance_print_dirty (
const QofInstance *inst, gpointer dummy)
680 priv = GET_PRIVATE(inst);
685 printf(
"%s instance %s is dirty.\n", inst->
e_type, guidstr);
699 priv = GET_PRIVATE(inst);
708 priv = GET_PRIVATE(inst);
715 g_return_val_if_fail(QOF_IS_INSTANCE(inst), FALSE);
716 return GET_PRIVATE(inst)->infant;
720 qof_instance_get_version (gconstpointer inst)
722 g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
723 return GET_PRIVATE(inst)->version;
727 qof_instance_set_version (gpointer inst, gint32 vers)
729 g_return_if_fail(QOF_IS_INSTANCE(inst));
730 GET_PRIVATE(inst)->version = vers;
734 qof_instance_copy_version (gpointer to, gconstpointer from)
736 g_return_if_fail(QOF_IS_INSTANCE(to));
737 g_return_if_fail(QOF_IS_INSTANCE(from));
738 GET_PRIVATE(to)->version = GET_PRIVATE(from)->version;
742 qof_instance_get_version_check (gconstpointer inst)
744 g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
745 return GET_PRIVATE(inst)->version_check;
749 qof_instance_set_version_check (gpointer inst, guint32 value)
751 g_return_if_fail(QOF_IS_INSTANCE(inst));
752 GET_PRIVATE(inst)->version_check = value;
756 qof_instance_copy_version_check (gpointer to, gconstpointer from)
758 g_return_if_fail(QOF_IS_INSTANCE(to));
759 g_return_if_fail(QOF_IS_INSTANCE(from));
760 GET_PRIVATE(to)->version_check = GET_PRIVATE(from)->version_check;
769 g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
770 return GET_PRIVATE(inst)->idata;
773 void qof_instance_set_idata(gpointer inst, guint32 idata)
779 g_return_if_fail(QOF_IS_INSTANCE(inst));
780 GET_PRIVATE(inst)->idata = idata;
788 g_return_val_if_fail( inst !=
nullptr,
nullptr );
790 if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name !=
nullptr )
792 return QOF_INSTANCE_GET_CLASS(inst)->get_display_name(inst);
797 return g_strdup_printf(
"Object %s %p",
810 get_referring_object_instance_helper(
QofInstance* inst, gpointer user_data)
814 if (*pInst ==
nullptr)
821 get_referring_object_helper(QofCollection* coll, gpointer user_data)
828 if (first_instance !=
nullptr)
831 data->list = g_list_concat(data->list, new_list);
840 g_return_val_if_fail( inst !=
nullptr,
nullptr );
847 get_referring_object_helper,
853 get_typed_referring_object_instance_helper(
QofInstance* inst, gpointer user_data)
859 data->list = g_list_prepend(data->list, inst);
868 g_return_val_if_fail( coll !=
nullptr,
nullptr );
869 g_return_val_if_fail( ref !=
nullptr,
nullptr );
881 g_return_val_if_fail( inst !=
nullptr,
nullptr );
882 g_return_val_if_fail( ref !=
nullptr,
nullptr );
884 if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list !=
nullptr )
886 return QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list(inst, ref);
902 g_return_val_if_fail( inst !=
nullptr, FALSE );
903 g_return_val_if_fail( ref !=
nullptr, FALSE );
905 if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object !=
nullptr )
907 return QOF_INSTANCE_GET_CLASS(inst)->refers_to_object(inst, ref);
921 g_return_if_fail (QOF_IS_INSTANCE (inst));
923 va_start (ap, first_prop);
924 g_object_get_valist (G_OBJECT (inst), first_prop, ap);
932 g_return_if_fail (QOF_IS_INSTANCE (inst));
934 qof_instance_set_dirty (inst);
935 va_start (ap, first_prop);
936 g_object_set_valist (G_OBJECT (inst), first_prop, ap);
950 if (!inst)
return FALSE;
952 priv = GET_PRIVATE(inst);
954 if (1 < priv->editlevel)
return FALSE;
955 if (0 >= priv->editlevel)
971 if (!inst)
return FALSE;
973 priv = GET_PRIVATE(inst);
975 if (0 < priv->editlevel)
return FALSE;
977 if (0 > priv->editlevel)
979 PERR (
"unbalanced call - resetting (was %d)", priv->editlevel);
993 priv = GET_PRIVATE(inst);
996 !(priv->infant && priv->do_free)) {
1010 errcode = be->get_error();
1012 while (errcode != ERR_BACKEND_NO_ERR);
1015 errcode = be->get_error();
1016 if (errcode != ERR_BACKEND_NO_ERR)
1019 priv->do_free = FALSE;
1022 be->set_error (errcode);
1024 on_error(inst, errcode);
1028 priv->infant = FALSE;
1046 return (inst->kvp_data !=
nullptr && !inst->kvp_data->empty());
1049 void qof_instance_set_path_kvp (
QofInstance * inst, GValue
const * value, std::vector<std::string>
const & path)
1057 std::vector<std::string> path;
1059 va_start (args, count);
1060 for (
unsigned i{0}; i < count; ++i)
1061 path.push_back (va_arg (args,
char const *));
1066 void qof_instance_get_path_kvp (
QofInstance * inst, GValue * value, std::vector<std::string>
const & path)
1074 std::vector<std::string> path;
1076 va_start (args, count);
1077 for (
unsigned i{0}; i < count; ++i)
1078 path.push_back (va_arg (args,
char const *));
1086 delete to->kvp_data;
1087 to->kvp_data =
new KvpFrame(*from->kvp_data);
1093 std::swap(a->kvp_data, b->kvp_data);
1099 return compare(a->kvp_data, b->kvp_data);
1103 qof_instance_kvp_as_string (
const QofInstance *inst)
1105 auto str{inst->kvp_data->to_string()};
1106 return g_strdup(str.c_str());
1110 qof_instance_kvp_add_guid (
const QofInstance *inst,
const char* path,
1111 time64 time,
const char *key,
1114 g_return_if_fail (inst->kvp_data !=
nullptr);
1116 auto container =
new KvpFrame;
1118 container->set({key},
new KvpValue(const_cast<GncGUID*>(guid)));
1119 container->set({
"date"},
new KvpValue(t));
1120 delete inst->kvp_data->set_path({path},
new KvpValue(container));
1123 inline static gboolean
1124 kvp_match_guid (KvpValue *v, std::vector<std::string>
const & path,
const GncGUID *guid)
1126 if (v->get_type() != KvpValue::Type::FRAME)
1128 auto frame = v->get<KvpFrame*>();
1129 auto val = frame->get_slot(path);
1130 if (val ==
nullptr || val->get_type() != KvpValue::Type::GUID)
1132 auto this_guid = val->get<
GncGUID*>();
1138 qof_instance_kvp_has_guid (
const QofInstance *inst,
const char *path,
1139 const char* key,
const GncGUID *guid)
1141 g_return_val_if_fail (inst->kvp_data !=
nullptr, FALSE);
1142 g_return_val_if_fail (guid !=
nullptr, FALSE);
1144 auto v = inst->kvp_data->get_slot({path});
1145 if (v ==
nullptr)
return FALSE;
1147 switch (v->get_type())
1149 case KvpValue::Type::FRAME:
1150 return kvp_match_guid (v, {key}, guid);
1152 case KvpValue::Type::GLIST:
1154 auto list = v->get<GList*>();
1155 for (
auto node = list; node !=
nullptr; node = node->next)
1157 auto val =
static_cast<KvpValue*
>(node->data);
1158 if (kvp_match_guid (val, {key}, guid))
1166 PWARN (
"Instance KVP on path %s contains the wrong type.", path);
1173 qof_instance_kvp_remove_guid (
const QofInstance *inst,
const char *path,
1174 const char *key,
const GncGUID *guid)
1176 g_return_if_fail (inst->kvp_data !=
nullptr);
1177 g_return_if_fail (guid !=
nullptr);
1179 auto v = inst->kvp_data->get_slot({path});
1180 if (v ==
nullptr)
return;
1182 switch (v->get_type())
1184 case KvpValue::Type::FRAME:
1185 if (kvp_match_guid (v, {key}, guid))
1187 delete inst->kvp_data->set_path({path},
nullptr);
1191 case KvpValue::Type::GLIST:
1193 auto list = v->get<GList*>();
1194 for (
auto node = list; node !=
nullptr; node = node->next)
1196 auto val =
static_cast<KvpValue*
>(node->data);
1197 if (kvp_match_guid (val, {key}, guid))
1199 list = g_list_delete_link (list, node);
1208 PWARN (
"Instance KVP on path %s contains the wrong type.", path);
1215 qof_instance_kvp_merge_guids (
const QofInstance *target,
1218 g_return_if_fail (target !=
nullptr);
1219 g_return_if_fail (donor !=
nullptr);
1221 if (! qof_instance_has_slot (donor, path))
return;
1222 auto v = donor->kvp_data->get_slot({path});
1223 if (v ==
nullptr)
return;
1225 auto target_val = target->kvp_data->get_slot({path});
1226 switch (v->get_type())
1228 case KvpValue::Type::FRAME:
1232 target->kvp_data->set_path({path}, v);
1233 donor->kvp_data->set({path},
nullptr);
1235 case KvpValue::Type::GLIST:
1238 auto list = target_val->get<GList*>();
1239 list = g_list_concat(list, v->get<GList*>());
1240 target_val->set(list);
1243 target->kvp_data->set({path}, v);
1244 donor->kvp_data->set({path},
nullptr);
1247 PWARN (
"Instance KVP on path %s contains the wrong type.", path);
1252 bool qof_instance_has_path_slot (
QofInstance const * inst, std::vector<std::string>
const & path)
1254 return inst->kvp_data->get_slot (path) !=
nullptr;
1258 qof_instance_has_slot (
const QofInstance *inst,
const char *path)
1260 return inst->kvp_data->get_slot({path}) !=
nullptr;
1263 void qof_instance_slot_path_delete (
QofInstance const * inst, std::vector<std::string>
const & path)
1265 delete inst->kvp_data->set (path,
nullptr);
1269 qof_instance_slot_delete (
QofInstance const *inst,
char const * path)
1271 delete inst->kvp_data->set ({path},
nullptr);
1274 void qof_instance_slot_path_delete_if_empty (
QofInstance const * inst, std::vector<std::string>
const & path)
1276 auto slot = inst->kvp_data->get_slot (path);
1279 auto frame = slot->get <KvpFrame*> ();
1280 if (frame && frame->empty())
1281 delete inst->kvp_data->set (path,
nullptr);
1286 qof_instance_slot_delete_if_empty (
QofInstance const *inst,
char const * path)
1288 auto slot = inst->kvp_data->get_slot ({path});
1291 auto frame = slot->get <KvpFrame*> ();
1292 if (frame && frame->empty ())
1293 delete inst->kvp_data->set ({path},
nullptr);
1297 std::vector <std::pair <std::string, KvpValue*>>
1298 qof_instance_get_slots_prefix (
QofInstance const * inst, std::string
const & prefix)
1300 std::vector <std::pair <std::string, KvpValue*>> ret;
1301 inst->kvp_data->for_each_slot_temp ([&prefix, &ret] (std::string
const & key, KvpValue * val) {
1302 if (key.find (prefix) == 0)
1303 ret.emplace_back (key, val);
1311 void (*proc)(
const char*,
const GValue*,
void*);
1317 wrap_gvalue_function (
const char* key, KvpValue *val, wrap_param & param)
1320 if (val->get_type() != KvpValue::Type::FRAME)
1324 gv = g_slice_new0 (GValue);
1325 g_value_init (gv, G_TYPE_STRING);
1326 g_value_set_string (gv,
nullptr);
1328 param.proc(key, gv, param.user_data);
1329 g_slice_free (GValue, gv);
1333 qof_instance_foreach_slot (
const QofInstance *inst,
const char* head,
const char* category,
1334 void (*proc)(
const char*,
const GValue*,
void*),
void* data)
1336 std::vector<std::string> path {head};
1338 path.emplace_back (category);
1340 auto slot = inst->kvp_data->get_slot(path);
1341 if (slot ==
nullptr || slot->get_type() != KvpValue::Type::FRAME)
1343 auto frame = slot->get<KvpFrame*>();
1344 wrap_param new_data {proc, data};
1345 frame->for_each_slot_temp(&wrap_gvalue_function, new_data);
int qof_instance_version_cmp(const QofInstance *left, const QofInstance *right)
Compare two instances, based on their last update times.
void guid_replace(GncGUID *guid)
Generate a new guid.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
void qof_instance_set_kvp(QofInstance *, GValue const *value, unsigned count,...)
Sets a KVP slot to a value from a GValue.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
GncGUID guid
GncGUID for the entity.
GList * qof_instance_get_referring_object_list_from_collection(const QofCollection *coll, const QofInstance *ref)
Returns a list of objects from the collection which refer to the specific object. ...
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
KvpValue * kvp_value_from_gvalue(const GValue *gval)
Convert a gvalue into a kvpvalue.
QofCollection * qof_instance_get_collection(gconstpointer ptr)
Return the collection this instance belongs to.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
#define PERR(format, args...)
Log a serious error.
void qof_collection_foreach(const QofCollection *col, QofInstanceForeachCB cb_func, gpointer user_data)
Call the callback for each entity in the collection.
void qof_instance_get_kvp(QofInstance *, GValue *value, unsigned count,...)
Retrieves the contents of a KVP slot into a provided GValue.
#define PWARN(format, args...)
Log a warning.
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
guint32 qof_instance_get_idata(gconstpointer inst)
get the instance tag number used for kvp management in sql backends.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
gboolean qof_instance_get_dirty_flag(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object has been modified.
void qof_instance_copy_book(gpointer ptr1, gconstpointer ptr2)
Copy the book from one QofInstances to another.
GList * qof_instance_get_typed_referring_object_list(const QofInstance *inst, const QofInstance *ref)
Returns a list of my type of object which refers to an object.
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
void qof_collection_insert_entity(QofCollection *, QofInstance *)
Take entity, remove it from whatever collection its currently in, and place it in a new collection...
const GncGUID * qof_entity_get_guid(gconstpointer ent)
gboolean qof_instance_books_equal(gconstpointer ptr1, gconstpointer ptr2)
See if two QofInstances share the same book.
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
GList * qof_instance_get_referring_object_list(const QofInstance *inst)
Returns a list of objects which refer to a specific object.
QofIdType qof_collection_get_type(const QofCollection *col)
return the type that the collection stores
GValue * gvalue_from_kvp_value(const KvpValue *kval, GValue *val)
Convert a kvp_value into a GValue.
QofIdType e_type
Entity type.
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
void qof_instance_set_book(gconstpointer inst, QofBook *book)
Set the book pointer.
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
gboolean qof_instance_refers_to_object(const QofInstance *inst, const QofInstance *ref)
Does this object refer to a specific object.
gboolean qof_instance_has_kvp(QofInstance *inst)
Report whether a QofInstance has anything stored in KVP.
QofBackend * qof_book_get_backend(const QofBook *book)
Retrieve the backend used by this book.
The type used to store guids in C.
QofCollection * collection
Entity collection.
gchar * qof_instance_get_display_name(const QofInstance *inst)
Returns a displayable name for this object.