static gboolean order_guid_handler (xmlNodePtr node, gpointer order_pdata) { struct order_pdata *pdata = order_pdata; GncGUID *guid; GncOrder *order; guid = dom_tree_to_guid(node); g_return_val_if_fail (guid, FALSE); order = gncOrderLookup (pdata->book, guid); if (order) { gncOrderDestroy (pdata->order); pdata->order = order; gncOrderBeginEdit (order); } else { gncOrderSetGUID(pdata->order, guid); } g_free(guid); return TRUE; }
/* ================================================================= */ template<> void GncSqlColumnTableEntryImpl<CT_ORDERREF>::load (const GncSqlBackend* be, GncSqlRow& row, QofIdTypeConst obj_name, gpointer pObject) const noexcept { load_from_guid_ref(row, obj_name, pObject, [be](GncGUID* g){ return gncOrderLookup(be->book(), g); }); }
static GncOrder* load_single_order (GncSqlBackend* be, GncSqlRow& row) { const GncGUID* guid; GncOrder* pOrder; g_return_val_if_fail (be != NULL, NULL); guid = gnc_sql_load_guid (be, row); pOrder = gncOrderLookup (be->book(), guid); if (pOrder == NULL) { pOrder = gncOrderCreate (be->book()); } gnc_sql_load_object (be, row, GNC_ID_ORDER, pOrder, col_table); qof_instance_mark_clean (QOF_INSTANCE (pOrder)); return pOrder; }
/* ================================================================= */ static void load_order_guid (const GncSqlBackend* be, GncSqlRow* row, QofSetterFunc setter, gpointer pObject, const GncSqlColumnTableEntry* table_row) { const GValue* val; GncGUID guid; GncOrder* order = NULL; g_return_if_fail (be != NULL); g_return_if_fail (row != NULL); g_return_if_fail (pObject != NULL); g_return_if_fail (table_row != NULL); val = gnc_sql_row_get_value_at_col_name (row, table_row->col_name); if (val != NULL && G_VALUE_HOLDS_STRING (val) && g_value_get_string (val) != NULL) { string_to_guid (g_value_get_string (val), &guid); order = gncOrderLookup (be->book, &guid); if (order != NULL) { if (table_row->gobj_param_name != NULL) { qof_instance_increase_editlevel (pObject); g_object_set (pObject, table_row->gobj_param_name, order, NULL); qof_instance_decrease_editlevel (pObject); } else { (*setter) (pObject, (const gpointer)order); } } else { PWARN ("Order ref '%s' not found", g_value_get_string (val)); } } }
static gboolean entry_order_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata *pdata = entry_pdata; GncGUID *guid; GncOrder *order; guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); order = gncOrderLookup (pdata->book, guid); if (!order) { order = gncOrderCreate (pdata->book); gncOrderBeginEdit (order); gncOrderSetGUID (order, guid); gncOrderCommitEdit (order); } gncOrderBeginEdit (order); gncOrderAddEntry (order, pdata->entry); gncOrderCommitEdit (order); g_free(guid); return TRUE; }