39 #include "qofbook-p.h"    41 #include "kvp-frame.hpp"    42 #include "qofinstance-p.h"    43 #include "qof-backend.hpp"    45 static QofLogModule log_module = QOF_MOD_ENGINE;
   105     guint32 version_check;  
   112 #define GET_PRIVATE(o)  \   113     ((QofInstancePrivate*)qof_instance_get_instance_private((QofInstance*)o))   115 G_DEFINE_TYPE_WITH_PRIVATE(
QofInstance, qof_instance, G_TYPE_OBJECT)
   116 QOF_GOBJECT_FINALIZE(qof_instance);
   117 #undef G_PARAM_READWRITE   118 #define G_PARAM_READWRITE static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)   120 static void qof_instance_get_property (GObject         *
object,
   124 static void qof_instance_set_property (GObject         *
object,
   128 static void qof_instance_dispose(GObject*);
   129 static void qof_instance_class_init(QofInstanceClass *klass)
   131     GObjectClass *object_class = G_OBJECT_CLASS(klass);
   132     object_class->finalize = qof_instance_finalize;
   133     object_class->dispose = qof_instance_dispose;
   134     object_class->set_property = qof_instance_set_property;
   135     object_class->get_property = qof_instance_get_property;
   137     klass->get_display_name = 
nullptr;
   138     klass->refers_to_object = 
nullptr;
   139     klass->get_typed_referring_object_list = 
nullptr;
   141     g_object_class_install_property
   144      g_param_spec_boxed (
"guid",
   146                          "The object Globally Unique ID.",
   150     g_object_class_install_property
   153      g_param_spec_pointer (
"collection",
   155                            "A collection of like objects of which this "   156                            "particular object is amember.  E.g.. A "   157                            "collection of accounts, or a collection of "   161     g_object_class_install_property
   164      g_param_spec_object (
"book",
   166                           "The book that contains this object.",
   170     g_object_class_install_property
   173      g_param_spec_pointer (
"last-update",
   174                            "Object Last Update",
   175                            "A pointer to the last time this object was "   176                            "updated.  This value is present for use by "   177                            "backends and shouldn't be written by other "   181     g_object_class_install_property
   184      g_param_spec_int (
"editlevel",
   186                        "The object edit level.",
   190     g_object_class_install_property
   193      g_param_spec_boolean (
"destroying",
   195                            "This flag is set to TRUE if the object is "   196                            "about to be destroyed.",
   200     g_object_class_install_property
   203      g_param_spec_boolean (
"dirty",
   205                            "This flag is set to TRUE if the object has "   210     g_object_class_install_property
   213      g_param_spec_boolean (
"infant",
   215                            "This flag is set to TRUE if the object has "   216                            "never been added to a book.  This implies "   217                            "that its destruction does not affect the "   218                            "state of the book, and therefore the saved "   219                            "state of the data file.",
   223     g_object_class_install_property
   226      g_param_spec_int (
"version",
   228                        "The version number of the current instance state.",
   234     g_object_class_install_property
   237      g_param_spec_uint (
"version-check",
   239                         "The version check number of the current instance state.",
   245     g_object_class_install_property
   248      g_param_spec_uint (
"idata",
   250                         "Per instance backend private data.",
   260     priv = GET_PRIVATE(inst);
   261     priv->book = 
nullptr;
   262     inst->kvp_data = 
new KvpFrame;
   263     priv->last_update = 0;
   265     priv->do_free = FALSE;
   277     g_return_if_fail(QOF_IS_INSTANCE(inst));
   278     priv = GET_PRIVATE(inst);
   279     g_return_if_fail(!priv->book);
   283     g_return_if_fail(col != 
nullptr);
   289     if (g_strcmp0(col_type, type))
   291         PERR (
"attempt to insert \"%s\" into \"%s\"", type, col_type);
   294     priv = GET_PRIVATE(inst);
   304         PWARN(
"duplicate id created, trying again");
   314 qof_instance_dispose (GObject *instp)
   319     priv = GET_PRIVATE(instp);
   321         qof_collection_remove_entity(inst);
   323     CACHE_REMOVE(inst->
e_type);
   326     G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp);
   330 qof_instance_finalize_real (GObject *instp)
   335     delete inst->kvp_data;
   336     inst->kvp_data = 
nullptr;
   338     priv = GET_PRIVATE(inst);
   340     priv->do_free = FALSE;
   351 qof_instance_get_property (GObject         *
object,
   359     g_return_if_fail(QOF_IS_INSTANCE(
object));
   361     inst = QOF_INSTANCE(
object);
   362     priv = GET_PRIVATE(inst);
   367         g_value_set_boxed(value, &priv->
guid);
   369     case PROP_COLLECTION:
   373         g_value_take_object(value, priv->book);
   375     case PROP_LAST_UPDATE:
   376         g_value_set_pointer(value, &priv->last_update);
   379         g_value_set_int(value, priv->editlevel);
   381     case PROP_DESTROYING:
   382         g_value_set_boolean(value, priv->do_free);
   385         g_value_set_boolean(value, qof_instance_get_dirty(inst));
   388         g_value_set_boolean(value, priv->infant);
   391         g_value_set_int(value, priv->version);
   393     case PROP_VERSION_CHECK:
   394         g_value_set_uint(value, priv->version_check);
   397         g_value_set_uint(value, priv->idata);
   400         G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
   406 qof_instance_set_property (GObject         *
object,
   414     g_return_if_fail(QOF_IS_INSTANCE(
object));
   416     inst = QOF_INSTANCE(
object);
   421         qof_instance_set_guid(inst,
   422                   static_cast<GncGUID*>(g_value_get_boxed(value)));
   424     case PROP_COLLECTION:
   425         qof_instance_set_collection(inst, static_cast<QofCollection*>(g_value_get_pointer(value)));
   429                   static_cast<QofBook*>(g_value_get_object(value)));
   431     case PROP_LAST_UPDATE:
   432         t = *(
static_cast<Time64*
>(g_value_get_pointer(value)));
   433         qof_instance_set_last_update(inst, t.t);
   435     case PROP_DESTROYING:
   436         qof_instance_set_destroying(inst, g_value_get_boolean(value));
   439         qof_instance_set_dirty(inst);
   442         qof_instance_set_version(inst, g_value_get_int(value));
   444     case PROP_VERSION_CHECK:
   445         qof_instance_set_version_check(inst, g_value_get_uint(value));
   448         qof_instance_set_idata(inst, g_value_get_uint(value));
   451         G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
   461     if (!inst) 
return nullptr;
   462     g_return_val_if_fail(QOF_IS_INSTANCE(inst), 
guid_null());
   463     priv = GET_PRIVATE(inst);
   464     return &(priv->
guid);
   474 qof_instance_set_guid (gpointer ptr, 
const GncGUID *guid)
   480     g_return_if_fail(QOF_IS_INSTANCE(ptr));
   482     inst = QOF_INSTANCE(ptr);
   483     priv = GET_PRIVATE(inst);
   488     qof_collection_remove_entity(inst);
   494 qof_instance_copy_guid (gpointer to, gconstpointer from)
   496     g_return_if_fail(QOF_IS_INSTANCE(to));
   497     g_return_if_fail(QOF_IS_INSTANCE(from));
   499     GET_PRIVATE(to)->guid = GET_PRIVATE(from)->guid;
   507     g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), -1);
   508     g_return_val_if_fail(QOF_IS_INSTANCE(ptr2),  1);
   510     priv1 = GET_PRIVATE(ptr1);
   511     priv2 = GET_PRIVATE(ptr2);
   513     return guid_compare(&priv1->
guid, &priv2->
guid);
   520     g_return_val_if_fail(QOF_IS_INSTANCE(ptr), 
nullptr);
   521     return GET_PRIVATE(ptr)->collection;
   525 qof_instance_set_collection (gconstpointer ptr, QofCollection *col)
   527     g_return_if_fail(QOF_IS_INSTANCE(ptr));
   528     GET_PRIVATE(ptr)->collection = col;
   534     if (!inst) 
return nullptr;
   535     g_return_val_if_fail(QOF_IS_INSTANCE(inst), 
nullptr);
   536     return GET_PRIVATE(inst)->book;
   542     g_return_if_fail(QOF_IS_INSTANCE(inst));
   543     GET_PRIVATE(inst)->book = book;
   549     g_return_if_fail(QOF_IS_INSTANCE(ptr1));
   550     g_return_if_fail(QOF_IS_INSTANCE(ptr2));
   552     GET_PRIVATE(ptr1)->book = GET_PRIVATE(ptr2)->book;
   560     g_return_val_if_fail(QOF_IS_INSTANCE(ptr1), FALSE);
   561     g_return_val_if_fail(QOF_IS_INSTANCE(ptr2), FALSE);
   563     priv1 = GET_PRIVATE(ptr1);
   564     priv2 = GET_PRIVATE(ptr2);
   566     return (priv1->book == priv2->book);
   573     if (!inst) 
return nullptr;
   574     return inst->kvp_data;
   578 qof_instance_set_slots (
QofInstance *inst, KvpFrame *frm)
   584     priv = GET_PRIVATE(inst);
   585     if (inst->kvp_data && (inst->kvp_data != frm))
   587         delete inst->kvp_data;
   591     inst->kvp_data = frm;
   598     GET_PRIVATE(inst)->last_update = t;
   602 qof_instance_get_editlevel (gconstpointer ptr)
   604     g_return_val_if_fail(QOF_IS_INSTANCE(ptr), 0);
   605     return GET_PRIVATE(ptr)->editlevel;
   608 void qof_instance_increase_editlevel (gpointer ptr)
   610     g_return_if_fail(QOF_IS_INSTANCE(ptr));
   611     GET_PRIVATE(ptr)->editlevel++;
   614 void qof_instance_decrease_editlevel (gpointer ptr)
   616     g_return_if_fail(QOF_IS_INSTANCE(ptr));
   617     GET_PRIVATE(ptr)->editlevel--;
   620 void qof_instance_reset_editlevel (gpointer ptr)
   622     g_return_if_fail(QOF_IS_INSTANCE(ptr));
   623     GET_PRIVATE(ptr)->editlevel = 0;
   631     if (!left && !right) 
return 0;
   632     if (!left) 
return -1;
   633     if (!right) 
return +1;
   635     lpriv = GET_PRIVATE(left);
   636     rpriv = GET_PRIVATE(right);
   637     return lpriv->last_update < rpriv->last_update ? -1 :
   638         lpriv->last_update > rpriv->last_update ? 1 : 0;
   644     g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
   645     return GET_PRIVATE(ptr)->do_free;
   649 qof_instance_set_destroying (gpointer ptr, gboolean value)
   651     g_return_if_fail(QOF_IS_INSTANCE(ptr));
   652     GET_PRIVATE(ptr)->do_free = value;
   658     g_return_val_if_fail(QOF_IS_INSTANCE(ptr), FALSE);
   659     return GET_PRIVATE(ptr)->dirty;
   663 qof_instance_set_dirty_flag (gconstpointer inst, gboolean flag)
   665     g_return_if_fail(QOF_IS_INSTANCE(inst));
   666     GET_PRIVATE(inst)->dirty = flag;
   673     GET_PRIVATE(inst)->dirty = FALSE;
   677 qof_instance_print_dirty (
const QofInstance *inst, gpointer dummy)
   681     priv = GET_PRIVATE(inst);
   686         printf(
"%s instance %s is dirty.\n", inst->
e_type, guidstr);
   700     priv = GET_PRIVATE(inst);
   709     priv = GET_PRIVATE(inst);
   716     g_return_val_if_fail(QOF_IS_INSTANCE(inst), FALSE);
   717     return GET_PRIVATE(inst)->infant;
   721 qof_instance_get_version (gconstpointer inst)
   723     g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
   724     return GET_PRIVATE(inst)->version;
   728 qof_instance_set_version (gpointer inst, gint32 vers)
   730     g_return_if_fail(QOF_IS_INSTANCE(inst));
   731     GET_PRIVATE(inst)->version = vers;
   735 qof_instance_copy_version (gpointer to, gconstpointer from)
   737     g_return_if_fail(QOF_IS_INSTANCE(to));
   738     g_return_if_fail(QOF_IS_INSTANCE(from));
   739     GET_PRIVATE(to)->version = GET_PRIVATE(from)->version;
   743 qof_instance_get_version_check (gconstpointer inst)
   745     g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
   746     return GET_PRIVATE(inst)->version_check;
   750 qof_instance_set_version_check (gpointer inst, guint32 value)
   752     g_return_if_fail(QOF_IS_INSTANCE(inst));
   753     GET_PRIVATE(inst)->version_check = value;
   757 qof_instance_copy_version_check (gpointer to, gconstpointer from)
   759     g_return_if_fail(QOF_IS_INSTANCE(to));
   760     g_return_if_fail(QOF_IS_INSTANCE(from));
   761     GET_PRIVATE(to)->version_check = GET_PRIVATE(from)->version_check;
   770     g_return_val_if_fail(QOF_IS_INSTANCE(inst), 0);
   771     return GET_PRIVATE(inst)->idata;
   774 void qof_instance_set_idata(gpointer inst, guint32 idata)
   780     g_return_if_fail(QOF_IS_INSTANCE(inst));
   781     GET_PRIVATE(inst)->idata = idata;
   789     g_return_val_if_fail( inst != 
nullptr, 
nullptr );
   791     if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name != 
nullptr )
   793         return QOF_INSTANCE_GET_CLASS(inst)->get_display_name(inst);
   798         return g_strdup_printf(
"Object %s %p",
   811 get_referring_object_instance_helper(
QofInstance* inst, gpointer user_data)
   815     if (*pInst == 
nullptr)
   822 get_referring_object_helper(QofCollection* coll, gpointer user_data)
   827     qof_collection_foreach(coll, get_referring_object_instance_helper, &first_instance);
   829     if (first_instance != 
nullptr)
   832         data->list = g_list_concat(data->list, new_list);
   841     g_return_val_if_fail( inst != 
nullptr, 
nullptr );
   848                                 get_referring_object_helper,
   854 get_typed_referring_object_instance_helper(
QofInstance* inst, gpointer user_data)
   860         data->list = g_list_prepend(data->list, inst);
   869     g_return_val_if_fail( coll != 
nullptr, 
nullptr );
   870     g_return_val_if_fail( ref != 
nullptr, 
nullptr );
   875     qof_collection_foreach(coll, get_typed_referring_object_instance_helper, &data);
   882     g_return_val_if_fail( inst != 
nullptr, 
nullptr );
   883     g_return_val_if_fail( ref != 
nullptr, 
nullptr );
   885     if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list != 
nullptr )
   887         return QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list(inst, ref);
   903     g_return_val_if_fail( inst != 
nullptr, FALSE );
   904     g_return_val_if_fail( ref != 
nullptr, FALSE );
   906     if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object != 
nullptr )
   908         return QOF_INSTANCE_GET_CLASS(inst)->refers_to_object(inst, ref);
   922     g_return_if_fail (QOF_IS_INSTANCE (inst));
   924     va_start (ap, first_prop);
   925     g_object_get_valist (G_OBJECT (inst), first_prop, ap);
   933     g_return_if_fail (QOF_IS_INSTANCE (inst));
   935     qof_instance_set_dirty (inst);
   936     va_start (ap, first_prop);
   937     g_object_set_valist (G_OBJECT (inst), first_prop, ap);
   951     if (!inst) 
return FALSE;
   953     priv = GET_PRIVATE(inst);
   955     if (1 < priv->editlevel) 
return FALSE;
   956     if (0 >= priv->editlevel)
   972     if (!inst) 
return FALSE;
   974     priv = GET_PRIVATE(inst);
   976     if (0 < priv->editlevel) 
return FALSE;
   978     if (0 > priv->editlevel)
   980         PERR (
"unbalanced call - resetting (was %d)", priv->editlevel);
   994     priv = GET_PRIVATE(inst);
   997         !(priv->infant && priv->do_free)) {
  1011             errcode = be->get_error();
  1013         while (errcode != ERR_BACKEND_NO_ERR);
  1016         errcode = be->get_error();
  1017         if (errcode != ERR_BACKEND_NO_ERR)
  1020             priv->do_free = FALSE;
  1023             be->set_error (errcode);
  1025                 on_error(inst, errcode);
  1029             priv->infant = FALSE;
  1047     return (inst->kvp_data != 
nullptr && !inst->kvp_data->empty());
  1050 void qof_instance_set_path_kvp (
QofInstance * inst, GValue 
const * value, std::vector<std::string> 
const & path)
  1058     std::vector<std::string> path;
  1060     va_start (args, count);
  1061     for (
unsigned i{0}; i < count; ++i)
  1062         path.push_back (va_arg (args, 
char const *));
  1067 template <
typename T> std::optional<T>
  1068 qof_instance_get_path_kvp (
QofInstance* inst, 
const Path& path)
  1070     g_return_val_if_fail (QOF_IS_INSTANCE(inst), std::nullopt);
  1071     auto kvp_value{inst->kvp_data->get_slot(path)};
  1072     return kvp_value ? std::make_optional<T>(kvp_value->get<T>()) : 
std::nullopt;
  1075 template <
typename T> 
void  1076 qof_instance_set_path_kvp (
QofInstance* inst, std::optional<T> value, 
const Path& path)
  1078     g_return_if_fail (QOF_IS_INSTANCE(inst));
  1079     delete inst->kvp_data->set_path(path, value ? 
new KvpValue(*value) : 
nullptr);
  1080     qof_instance_set_dirty (inst);
  1083 template std::optional<Time64> qof_instance_get_path_kvp <Time64> (
QofInstance*, 
const Path&);
  1084 template std::optional<GDate> qof_instance_get_path_kvp <GDate> (
QofInstance*, 
const Path&);
  1085 template std::optional<const char*> qof_instance_get_path_kvp <const char*> (
QofInstance*, 
const Path&);
  1086 template std::optional<gnc_numeric> qof_instance_get_path_kvp <gnc_numeric> (
QofInstance*, 
const Path&);
  1087 template std::optional<GncGUID*> qof_instance_get_path_kvp <GncGUID*> (
QofInstance*, 
const Path&);
  1088 template std::optional<int64_t> qof_instance_get_path_kvp <int64_t> (
QofInstance*, 
const Path&);
  1090 template void qof_instance_set_path_kvp <Time64> (
QofInstance*, std::optional<Time64>, 
const Path& path);
  1091 template void qof_instance_set_path_kvp <GDate> (
QofInstance*, std::optional<GDate>, 
const Path& path);
  1092 template void qof_instance_set_path_kvp <const char*> (
QofInstance*, std::optional<const char*>, 
const Path& path);
  1093 template void qof_instance_set_path_kvp <gnc_numeric> (
QofInstance*, std::optional<gnc_numeric>, 
const Path& path);
  1094 template void qof_instance_set_path_kvp <GncGUID*> (
QofInstance*, std::optional<GncGUID*>, 
const Path& path);
  1095 template void qof_instance_set_path_kvp <int64_t> (
QofInstance*, std::optional<int64_t>, 
const Path& path);
  1097 void qof_instance_get_path_kvp (
QofInstance * inst, GValue * value, std::vector<std::string> 
const & path)
  1105     std::vector<std::string> path;
  1107     va_start (args, count);
  1108     for (
unsigned i{0}; i < count; ++i)
  1109         path.push_back (va_arg (args, 
char const *));
  1117     delete to->kvp_data;
  1118     to->kvp_data = 
new KvpFrame(*from->kvp_data);
  1124     std::swap(a->kvp_data, b->kvp_data);
  1130     return compare(a->kvp_data, b->kvp_data);
  1134 qof_instance_kvp_as_string (
const QofInstance *inst)
  1136     auto str{inst->kvp_data->to_string()};
  1137     return g_strdup(str.c_str());
  1141 qof_instance_kvp_add_guid (
const QofInstance *inst, 
const char* path,
  1142                            time64 time, 
const char *key,
  1145     g_return_if_fail (inst->kvp_data != 
nullptr);
  1147     auto container = 
new KvpFrame;
  1149     container->set({key}, 
new KvpValue(const_cast<GncGUID*>(guid)));
  1150     container->set({
"date"}, 
new KvpValue(t));
  1151     delete inst->kvp_data->set_path({path}, 
new KvpValue(container));
  1154 inline static gboolean
  1155 kvp_match_guid (KvpValue *v, std::vector<std::string> 
const & path, 
const GncGUID *guid)
  1157     if (v->get_type() != KvpValue::Type::FRAME)
  1159     auto frame = v->get<KvpFrame*>();
  1160     auto val = frame->get_slot(path);
  1161     if (val == 
nullptr || val->get_type() != KvpValue::Type::GUID)
  1163     auto this_guid = val->get<
GncGUID*>();
  1169 qof_instance_kvp_has_guid (
const QofInstance *inst, 
const char *path,
  1170                            const char* key, 
const GncGUID *guid)
  1172     g_return_val_if_fail (inst->kvp_data != 
nullptr, FALSE);
  1173     g_return_val_if_fail (guid != 
nullptr, FALSE);
  1175     auto v = inst->kvp_data->get_slot({path});
  1176     if (v == 
nullptr) 
return FALSE;
  1178     switch (v->get_type())
  1180     case KvpValue::Type::FRAME:
  1181         return kvp_match_guid (v, {key}, guid);
  1183     case KvpValue::Type::GLIST:
  1185         auto list = v->get<GList*>();
  1186         for (
auto node = list; node != 
nullptr; node = node->next)
  1188             auto val = 
static_cast<KvpValue*
>(node->data);
  1189             if (kvp_match_guid (val, {key}, guid))
  1197         PWARN (
"Instance KVP on path %s contains the wrong type.", path);
  1204 qof_instance_kvp_remove_guid (
const QofInstance *inst, 
const char *path,
  1205                           const char *key, 
const GncGUID *guid)
  1207     g_return_if_fail (inst->kvp_data != 
nullptr);
  1208     g_return_if_fail (guid != 
nullptr);
  1210     auto v = inst->kvp_data->get_slot({path});
  1211     if (v == 
nullptr) 
return;
  1213     switch (v->get_type())
  1215     case KvpValue::Type::FRAME:
  1216         if (kvp_match_guid (v, {key}, guid))
  1218             delete inst->kvp_data->set_path({path}, 
nullptr);
  1222     case KvpValue::Type::GLIST:
  1224         auto list = v->get<GList*>();
  1225         for (
auto node = list; node != 
nullptr; node = node->next)
  1227             auto val = 
static_cast<KvpValue*
>(node->data);
  1228             if (kvp_match_guid (val, {key}, guid))
  1230                 list = g_list_delete_link (list, node);
  1239         PWARN (
"Instance KVP on path %s contains the wrong type.", path);
  1246 qof_instance_kvp_merge_guids (
const QofInstance *target,
  1249     g_return_if_fail (target != 
nullptr);
  1250     g_return_if_fail (donor != 
nullptr);
  1252     if (! qof_instance_has_slot (donor, path)) 
return;
  1253     auto v = donor->kvp_data->get_slot({path});
  1254     if (v == 
nullptr) 
return;
  1256     auto target_val = target->kvp_data->get_slot({path});
  1257     switch (v->get_type())
  1259     case KvpValue::Type::FRAME:
  1263             target->kvp_data->set_path({path}, v);
  1264         donor->kvp_data->set({path}, 
nullptr); 
  1266     case KvpValue::Type::GLIST:
  1269             auto list = target_val->get<GList*>();
  1270             list = g_list_concat(list, v->get<GList*>());
  1271             target_val->set(list);
  1274             target->kvp_data->set({path}, v);
  1275         donor->kvp_data->set({path}, 
nullptr); 
  1278         PWARN (
"Instance KVP on path %s contains the wrong type.", path);
  1283 bool qof_instance_has_path_slot (
QofInstance const * inst, std::vector<std::string> 
const & path)
  1285     return inst->kvp_data->get_slot (path) != 
nullptr;
  1289 qof_instance_has_slot (
const QofInstance *inst, 
const char *path)
  1291     return inst->kvp_data->get_slot({path}) != 
nullptr;
  1294 void qof_instance_slot_path_delete (
QofInstance const * inst, std::vector<std::string> 
const & path)
  1296     delete inst->kvp_data->set (path, 
nullptr);
  1300 qof_instance_slot_delete (
QofInstance const *inst, 
char const * path)
  1302     delete inst->kvp_data->set ({path}, 
nullptr);
  1305 void qof_instance_slot_path_delete_if_empty (
QofInstance const * inst, std::vector<std::string> 
const & path)
  1307     auto slot = inst->kvp_data->get_slot (path);
  1310         auto frame = slot->get <KvpFrame*> ();
  1311         if (frame && frame->empty())
  1312             delete inst->kvp_data->set (path, 
nullptr);
  1317 qof_instance_slot_delete_if_empty (
QofInstance const *inst, 
char const * path)
  1319     auto slot = inst->kvp_data->get_slot ({path});
  1322         auto frame = slot->get <KvpFrame*> ();
  1323         if (frame && frame->empty ())
  1324             delete inst->kvp_data->set ({path}, 
nullptr);
  1328 std::vector <std::pair <std::string, KvpValue*>>
  1329 qof_instance_get_slots_prefix (
QofInstance const * inst, std::string 
const & prefix)
  1331     std::vector <std::pair <std::string, KvpValue*>> ret;
  1332     inst->kvp_data->for_each_slot_temp ([&prefix, &ret] (std::string 
const & key, KvpValue * val) {
  1333         if (key.find (prefix) == 0)
  1334             ret.emplace_back (key, val);
  1342     void (*proc)(
const char*, 
const GValue*, 
void*);
  1348 wrap_gvalue_function (
const char* key, KvpValue *val, wrap_param & param)
  1350     GValue gv = G_VALUE_INIT;
  1351     if (val->get_type() != KvpValue::Type::FRAME)
  1355         g_value_init (&gv, G_TYPE_STRING);
  1356         g_value_set_string (&gv, 
nullptr);
  1358     param.proc(key, &gv, param.user_data);
  1359     g_value_unset (&gv);
  1363 qof_instance_foreach_slot (
const QofInstance *inst, 
const char* head, 
const char* category,
  1364                            void (*proc)(
const char*, 
const GValue*, 
void*), 
void* data)
  1366     std::vector<std::string> path {head};
  1368         path.emplace_back (category);
  1370     auto slot = inst->kvp_data->get_slot(path);
  1371     if (slot == 
nullptr || slot->get_type() != KvpValue::Type::FRAME)
  1373     auto frame = slot->get<KvpFrame*>();
  1374     wrap_param new_data {proc, data};
  1375     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. ...
 
void gvalue_from_kvp_value(const KvpValue *kval, GValue *val)
Convert a kvp_value into a GValue. 
 
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_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 
 
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.