mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 18:30:23 -06:00
Removed qof_instance_set_kvp, qof_instance_get_kvp
And replaced them with versions that take lists of key path elements. This is in an effort to eliminate the parsing of kvp keys.
This commit is contained in:
parent
eb6dad86e3
commit
9d7ec35ce5
@ -406,34 +406,27 @@ gnc_account_get_property (GObject *object,
|
||||
case PROP_SORT_REVERSED:
|
||||
g_value_set_boolean(value, xaccAccountGetSortReversed(account));
|
||||
case PROP_LOT_NEXT_ID:
|
||||
key = "lot-mgmt/next-id";
|
||||
/* Pre-set the value in case the frame is empty */
|
||||
g_value_set_int64 (value, 0);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {"lot-mgmt", "next-id"});
|
||||
break;
|
||||
case PROP_ONLINE_ACCOUNT:
|
||||
key = "online_id";
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {"online_id"});
|
||||
break;
|
||||
case PROP_OFX_INCOME_ACCOUNT:
|
||||
key = KEY_ASSOC_INCOME_ACCOUNT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {KEY_ASSOC_INCOME_ACCOUNT});
|
||||
break;
|
||||
case PROP_AB_ACCOUNT_ID:
|
||||
key = AB_KEY "/" AB_ACCOUNT_ID;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_ID});
|
||||
break;
|
||||
case PROP_AB_ACCOUNT_UID:
|
||||
key = AB_KEY "/" AB_ACCOUNT_UID;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_UID});
|
||||
break;
|
||||
case PROP_AB_BANK_CODE:
|
||||
key = AB_KEY "/" AB_BANK_CODE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_BANK_CODE});
|
||||
break;
|
||||
case PROP_AB_TRANS_RETRIEVAL:
|
||||
key = AB_KEY "/" AB_TRANS_RETRIEVAL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_TRANS_RETRIEVAL});
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -449,10 +442,7 @@ gnc_account_set_property (GObject *object,
|
||||
{
|
||||
Account *account;
|
||||
gnc_numeric *number;
|
||||
const gchar *key = NULL;
|
||||
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(object));
|
||||
|
||||
account = GNC_ACCOUNT(object);
|
||||
if (prop_id < PROP_RUNTIME_0)
|
||||
g_assert (qof_instance_get_editlevel(account));
|
||||
@ -540,32 +530,25 @@ gnc_account_set_property (GObject *object,
|
||||
case PROP_SORT_REVERSED:
|
||||
xaccAccountSetSortReversed(account, g_value_get_boolean(value));
|
||||
case PROP_LOT_NEXT_ID:
|
||||
key = "lot-mgmt/next-id";
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {"lot-mgmt", "next-id"});
|
||||
break;
|
||||
case PROP_ONLINE_ACCOUNT:
|
||||
key = "online_id";
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {"online_id"});
|
||||
break;
|
||||
case PROP_OFX_INCOME_ACCOUNT:
|
||||
key = KEY_ASSOC_INCOME_ACCOUNT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {KEY_ASSOC_INCOME_ACCOUNT});
|
||||
break;
|
||||
case PROP_AB_ACCOUNT_ID:
|
||||
key = AB_KEY "/" AB_ACCOUNT_ID;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_ID});
|
||||
break;
|
||||
case PROP_AB_ACCOUNT_UID:
|
||||
key = AB_KEY "/" AB_ACCOUNT_UID;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_ACCOUNT_UID});
|
||||
break;
|
||||
case PROP_AB_BANK_CODE:
|
||||
key = AB_KEY "/" AB_BANK_CODE;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_BANK_CODE});
|
||||
break;
|
||||
case PROP_AB_TRANS_RETRIEVAL:
|
||||
key = AB_KEY "/" AB_TRANS_RETRIEVAL;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), key, value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (account), value, {AB_KEY, AB_TRANS_RETRIEVAL});
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -2310,20 +2293,20 @@ set_kvp_string_tag (Account *acc, const char *tag, const char *value)
|
||||
if (value)
|
||||
{
|
||||
gchar *tmp = g_strstrip(g_strdup(value));
|
||||
if (strlen (tmp))
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, tmp);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), tag , &v);
|
||||
}
|
||||
else
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), tag, NULL);
|
||||
if (strlen (tmp))
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, tmp);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {tag});
|
||||
}
|
||||
else
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, {tag});
|
||||
g_free(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), tag, NULL);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), NULL, {tag});
|
||||
}
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit(acc);
|
||||
@ -2334,7 +2317,7 @@ get_kvp_string_tag (const Account *acc, const char *tag)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (acc == NULL || tag == NULL) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (acc), tag, &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, {tag});
|
||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
||||
}
|
||||
|
||||
@ -2359,7 +2342,7 @@ xaccAccountSetSortOrder (Account *acc, const char *str)
|
||||
void
|
||||
xaccAccountSetSortReversed (Account *acc, gboolean sortreversed)
|
||||
{
|
||||
set_kvp_string_tag (acc, "sort-reversed", sortreversed ? "true" : NULL);
|
||||
set_kvp_string_tag (acc, "sort-reversed", sortreversed ? "true" : NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2507,7 +2490,7 @@ DxaccAccountSetCurrency (Account * acc, gnc_commodity * currency)
|
||||
if ((!acc) || (!currency)) return;
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, s);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "old-currency", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"old-currency"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit(acc);
|
||||
|
||||
@ -3142,7 +3125,7 @@ DxaccAccountGetCurrency (const Account *acc)
|
||||
gnc_commodity_table *table;
|
||||
|
||||
if (!acc) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), "old-currency", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"old-currency"});
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
if (!s) return NULL;
|
||||
@ -3809,7 +3792,7 @@ xaccAccountForEachLot(const Account *acc,
|
||||
}
|
||||
|
||||
static void
|
||||
set_boolean_key (Account *acc, const char* key, gboolean option)
|
||||
set_boolean_key (Account *acc, std::vector<std::string> const & path, gboolean option)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
||||
@ -3817,17 +3800,17 @@ set_boolean_key (Account *acc, const char* key, gboolean option)
|
||||
g_value_init (&v, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (&v, option);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc),key , &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, path);
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
boolean_from_key (const Account *acc, const char *key)
|
||||
boolean_from_key (const Account *acc, std::vector<std::string> const & path)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), key, &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, path);
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
return g_value_get_int64 (&v) != 0;
|
||||
if (G_VALUE_HOLDS_BOOLEAN (&v))
|
||||
@ -3844,13 +3827,13 @@ boolean_from_key (const Account *acc, const char *key)
|
||||
gboolean
|
||||
xaccAccountGetTaxRelated (const Account *acc)
|
||||
{
|
||||
return boolean_from_key(acc, "tax-related");
|
||||
return boolean_from_key(acc, {"tax-related"});
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetTaxRelated (Account *acc, gboolean tax_related)
|
||||
{
|
||||
set_boolean_key(acc, "tax-related", tax_related);
|
||||
set_boolean_key(acc, {"tax-related"}, tax_related);
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -3858,7 +3841,7 @@ xaccAccountGetTaxUSCode (const Account *acc)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), "/tax-US/code", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "code"});
|
||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
||||
}
|
||||
|
||||
@ -3871,7 +3854,7 @@ xaccAccountSetTaxUSCode (Account *acc, const char *code)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, code);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "/tax-US/code", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "code"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -3881,8 +3864,7 @@ xaccAccountGetTaxUSPayerNameSource (const Account *acc)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc),
|
||||
"/tax-US/payer-name-source", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "payer-name-source"});
|
||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
||||
}
|
||||
|
||||
@ -3895,7 +3877,7 @@ xaccAccountSetTaxUSPayerNameSource (Account *acc, const char *source)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, source);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "/tax-US/payer-name-source", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "payer-name-source"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -3906,7 +3888,7 @@ xaccAccountGetTaxUSCopyNumber (const Account *acc)
|
||||
gint64 copy_number = 0;
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), "/tax-US/copy-number", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"tax-US", "copy-number"});
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
copy_number = g_value_get_int64 (&v);
|
||||
|
||||
@ -3923,11 +3905,11 @@ xaccAccountSetTaxUSCopyNumber (Account *acc, gint64 copy_number)
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, copy_number);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "/tax-US/copy-number", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"tax-US", "copy-number"});
|
||||
}
|
||||
else
|
||||
{
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "/tax-US/copy-number", NULL);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), nullptr, {"tax-US", "copy-number"});
|
||||
}
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
@ -3939,13 +3921,13 @@ xaccAccountSetTaxUSCopyNumber (Account *acc, gint64 copy_number)
|
||||
gboolean
|
||||
xaccAccountGetPlaceholder (const Account *acc)
|
||||
{
|
||||
return boolean_from_key(acc, "placeholder");
|
||||
return boolean_from_key(acc, {"placeholder"});
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetPlaceholder (Account *acc, gboolean val)
|
||||
{
|
||||
set_boolean_key(acc, "placeholder", val);
|
||||
set_boolean_key(acc, {"placeholder"}, val);
|
||||
}
|
||||
|
||||
GNCPlaceholderType
|
||||
@ -3975,13 +3957,13 @@ xaccAccountGetDescendantPlaceholder (const Account *acc)
|
||||
gboolean
|
||||
xaccAccountGetHidden (const Account *acc)
|
||||
{
|
||||
return boolean_from_key (acc, "hidden");
|
||||
return boolean_from_key (acc, {"hidden"});
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetHidden (Account *acc, gboolean val)
|
||||
{
|
||||
set_boolean_key (acc, "hidden", val);
|
||||
set_boolean_key (acc, {"hidden"}, val);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -4312,7 +4294,7 @@ xaccAccountGetReconcileLastDate (const Account *acc, time64 *last_date)
|
||||
gint64 date = 0;
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), "reconcile-info/last-date", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"reconcile-info", "last-date"});
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
date = g_value_get_int64 (&v);
|
||||
|
||||
@ -4337,7 +4319,7 @@ xaccAccountSetReconcileLastDate (Account *acc, time64 last_date)
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, last_date);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "/reconcile-info/last-date", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"reconcile-info", "last-date"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4354,10 +4336,10 @@ xaccAccountGetReconcileLastInterval (const Account *acc,
|
||||
|
||||
if (!acc) return FALSE;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc),
|
||||
"reconcile-info/last-interval/months", &v1);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc),
|
||||
"reconcile-info/last-interval/days", &v2);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v1,
|
||||
{"reconcile-info", "last-interval", "months"});
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v2,
|
||||
{"reconcile-info", "last-interval", "days"});
|
||||
if (G_VALUE_HOLDS_INT64 (&v1))
|
||||
m = g_value_get_int64 (&v1);
|
||||
if (G_VALUE_HOLDS_INT64 (&v2))
|
||||
@ -4387,10 +4369,10 @@ xaccAccountSetReconcileLastInterval (Account *acc, int months, int days)
|
||||
g_value_init (&v2, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v2, days);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc),
|
||||
"reconcile-info/last-interval/months", &v1);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc),
|
||||
"reconcile-info/last-interval/days", &v2);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v1,
|
||||
{"reconcile-info", "last-interval", "months"});
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v2,
|
||||
{"reconcile-info", "last-interval", "days"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4404,8 +4386,8 @@ xaccAccountGetReconcilePostponeDate (const Account *acc, time64 *postpone_date)
|
||||
gint64 date = 0;
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc),
|
||||
"reconcile-info/postpone/date", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v,
|
||||
{"reconcile-info", "postpone", "date"});
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
date = g_value_get_int64 (&v);
|
||||
|
||||
@ -4430,8 +4412,8 @@ xaccAccountSetReconcilePostponeDate (Account *acc, time64 postpone_date)
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, postpone_date);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc),
|
||||
"/reconcile-info/postpone/date", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v,
|
||||
{"reconcile-info", "postpone", "date"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4446,8 +4428,8 @@ xaccAccountGetReconcilePostponeBalance (const Account *acc,
|
||||
gnc_numeric bal = gnc_numeric_zero ();
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc),
|
||||
"reconcile-info/postpone/balance", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v,
|
||||
{"reconcile-info", "postpone", "balance"});
|
||||
if (!G_VALUE_HOLDS_INT64 (&v))
|
||||
return FALSE;
|
||||
|
||||
@ -4473,8 +4455,8 @@ xaccAccountSetReconcilePostponeBalance (Account *acc, gnc_numeric balance)
|
||||
g_value_init (&v, GNC_TYPE_NUMERIC);
|
||||
g_value_set_boxed (&v, &balance);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc),
|
||||
"/reconcile-info/postpone/balance", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v,
|
||||
{"reconcile-info", "postpone", "balance"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4489,7 +4471,7 @@ xaccAccountClearReconcilePostpone (Account *acc)
|
||||
if (!acc) return;
|
||||
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(acc), "reconcile-info/postpone", NULL);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE(acc), nullptr, {"reconcile-info", "postpone"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4504,7 +4486,7 @@ xaccAccountClearReconcilePostpone (Account *acc)
|
||||
gboolean
|
||||
xaccAccountGetAutoInterestXfer (const Account *acc, gboolean default_value)
|
||||
{
|
||||
return boolean_from_key (acc, "reconcile-info/auto-interest-transfer");
|
||||
return boolean_from_key (acc, {"reconcile-info", "auto-interest-transfer"});
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4513,7 +4495,7 @@ xaccAccountGetAutoInterestXfer (const Account *acc, gboolean default_value)
|
||||
void
|
||||
xaccAccountSetAutoInterestXfer (Account *acc, gboolean option)
|
||||
{
|
||||
set_boolean_key (acc, "reconcile-info/auto-interest-transfer", option);
|
||||
set_boolean_key (acc, {"reconcile-info", "auto-interest-transfer"}, option);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -4524,7 +4506,7 @@ xaccAccountGetLastNum (const Account *acc)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), "last-num", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"last-num"});
|
||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
||||
}
|
||||
|
||||
@ -4540,7 +4522,7 @@ xaccAccountSetLastNum (Account *acc, const char *num)
|
||||
|
||||
g_value_set_string (&v, num);
|
||||
xaccAccountBeginEdit (acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "last-num", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"last-num"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4594,13 +4576,13 @@ Account *
|
||||
xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gchar *curr_name = g_strdup_printf ("/lot-mgmt/gains-act/%s",
|
||||
gnc_commodity_get_unique_name (curr));
|
||||
std::vector<std::string> path {"lot-mgmt", "gains-acct",
|
||||
gnc_commodity_get_unique_name (curr)};
|
||||
GncGUID *guid = NULL;
|
||||
Account *gains_account;
|
||||
|
||||
g_return_val_if_fail (acc != NULL, NULL);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), curr_name, &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, path);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
guid = (GncGUID*)g_value_get_boxed (&v);
|
||||
if (guid == NULL) /* No gains account for this currency */
|
||||
@ -4613,7 +4595,7 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
|
||||
GValue vr = G_VALUE_INIT;
|
||||
g_value_init (&vr, GNC_TYPE_GUID);
|
||||
g_value_set_boxed (&vr, guid);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), curr_name, &vr);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &vr, path);
|
||||
qof_instance_set_dirty (QOF_INSTANCE (acc));
|
||||
}
|
||||
xaccAccountCommitEdit (acc);
|
||||
@ -4622,7 +4604,6 @@ xaccAccountGainsAccount (Account *acc, gnc_commodity *curr)
|
||||
gains_account = xaccAccountLookup (guid,
|
||||
qof_instance_get_book(acc));
|
||||
|
||||
g_free (curr_name);
|
||||
return gains_account;
|
||||
}
|
||||
|
||||
@ -4642,11 +4623,10 @@ dxaccAccountSetPriceSrc(Account *acc, const char *src)
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, src);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(acc),
|
||||
"old-price-source", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE(acc), &v, {"old-price-source"});
|
||||
}
|
||||
else
|
||||
qof_instance_set_kvp (QOF_INSTANCE(acc), "old-price-source", NULL);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE(acc), nullptr, {"old-price-source"});
|
||||
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit(acc);
|
||||
@ -4664,7 +4644,7 @@ dxaccAccountGetPriceSrc(const Account *acc)
|
||||
|
||||
if (!xaccAccountIsPriced(acc)) return NULL;
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), "old-price-source", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v, {"old-price-source"});
|
||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
||||
}
|
||||
|
||||
@ -4680,7 +4660,7 @@ dxaccAccountSetQuoteTZ(Account *acc, const char *tz)
|
||||
xaccAccountBeginEdit(acc);
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, tz);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc), "old-quote-tz", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v, {"old-quote-tz"});
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit(acc);
|
||||
}
|
||||
@ -4694,7 +4674,7 @@ dxaccAccountGetQuoteTZ(const Account *acc)
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!acc) return NULL;
|
||||
if (!xaccAccountIsPriced(acc)) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (acc), "old-quote-tz", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, {"old-quote-tz"});
|
||||
return G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL;
|
||||
}
|
||||
|
||||
@ -4714,8 +4694,8 @@ xaccAccountSetReconcileChildrenStatus(Account *acc, gboolean status)
|
||||
*/
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, status);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (acc),
|
||||
"/reconcile-info/include-children", &v);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (acc), &v,
|
||||
{"reconcile-info", "include-children"});
|
||||
mark_account(acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -4732,8 +4712,8 @@ xaccAccountGetReconcileChildrenStatus(const Account *acc)
|
||||
*/
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!acc) return FALSE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (acc),
|
||||
"reconcile-info/include-children", &v);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v,
|
||||
{"reconcile-info", "include-children"});
|
||||
return G_VALUE_HOLDS_INT64 (&v) ? g_value_get_int64 (&v) : FALSE;
|
||||
}
|
||||
|
||||
@ -5107,17 +5087,14 @@ gnc_account_imap_find_account (GncImportMatchMap *imap,
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
GncGUID * guid = NULL;
|
||||
char *kvp_path;
|
||||
|
||||
if (!imap || !key) return NULL;
|
||||
if (!category)
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s", key);
|
||||
else
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s/%s", category, key);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (imap->acc), kvp_path, &v);
|
||||
std::vector<std::string> path {IMAP_FRAME};
|
||||
if (category)
|
||||
path.push_back (category);
|
||||
path.push_back (key);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (imap->acc), &v, path);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
guid = (GncGUID*)g_value_get_boxed (&v);
|
||||
g_free (kvp_path);
|
||||
return xaccAccountLookup (guid, imap->book);
|
||||
}
|
||||
|
||||
@ -5129,19 +5106,15 @@ gnc_account_imap_add_account (GncImportMatchMap *imap,
|
||||
Account *acc)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
char *kvp_path;
|
||||
|
||||
if (!imap || !key || !acc || (strlen (key) == 0)) return;
|
||||
if (!category)
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s", key);
|
||||
else
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s/%s", category, key);
|
||||
|
||||
std::vector<std::string> path {IMAP_FRAME};
|
||||
if (category)
|
||||
path.emplace_back (category);
|
||||
path.emplace_back (key);
|
||||
g_value_init (&v, GNC_TYPE_GUID);
|
||||
g_value_set_boxed (&v, xaccAccountGetGUID (acc));
|
||||
xaccAccountBeginEdit (imap->acc);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (imap->acc), kvp_path, &v);
|
||||
g_free (kvp_path);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (imap->acc), &v, path);
|
||||
qof_instance_set_dirty (QOF_INSTANCE (imap->acc));
|
||||
xaccAccountCommitEdit (imap->acc);
|
||||
}
|
||||
@ -5152,28 +5125,18 @@ gnc_account_imap_delete_account (GncImportMatchMap *imap,
|
||||
const char *category,
|
||||
const char *key)
|
||||
{
|
||||
char *kvp_path;
|
||||
|
||||
if (!imap || !key) return;
|
||||
if (!category)
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s", key);
|
||||
else
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s/%s", category, key);
|
||||
|
||||
std::vector<std::string> path {IMAP_FRAME};
|
||||
if (category)
|
||||
path.emplace_back (category);
|
||||
path.emplace_back (key);
|
||||
xaccAccountBeginEdit (imap->acc);
|
||||
|
||||
if (qof_instance_has_slot (QOF_INSTANCE (imap->acc), kvp_path))
|
||||
if (qof_instance_has_path_slot (QOF_INSTANCE (imap->acc), path))
|
||||
{
|
||||
qof_instance_slot_delete (QOF_INSTANCE (imap->acc), kvp_path);
|
||||
g_free (kvp_path);
|
||||
|
||||
qof_instance_slot_path_delete (QOF_INSTANCE (imap->acc), path);
|
||||
if (category)
|
||||
{
|
||||
kvp_path = g_strdup_printf (IMAP_FRAME "/%s", category);
|
||||
qof_instance_slot_delete_if_empty (QOF_INSTANCE (imap->acc), kvp_path);
|
||||
g_free (kvp_path);
|
||||
}
|
||||
qof_instance_slot_delete_if_empty (QOF_INSTANCE (imap->acc), IMAP_FRAME);
|
||||
qof_instance_slot_path_delete_if_empty (QOF_INSTANCE (imap->acc), {IMAP_FRAME, category});
|
||||
qof_instance_slot_path_delete_if_empty (QOF_INSTANCE (imap->acc), {IMAP_FRAME});
|
||||
}
|
||||
qof_instance_set_dirty (QOF_INSTANCE (imap->acc));
|
||||
xaccAccountCommitEdit (imap->acc);
|
||||
@ -5333,20 +5296,20 @@ gnc_account_imap_find_account_bayes (GncImportMatchMap *imap, GList *tokens)
|
||||
}
|
||||
|
||||
static void
|
||||
change_imap_entry (GncImportMatchMap *imap, gchar const * kvp_path, int64_t token_count)
|
||||
change_imap_entry (GncImportMatchMap *imap, std::string const & path, int64_t token_count)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
PINFO("Source Account is '%s', kvp_path is '%s', Count is '%" G_GINT64_FORMAT "'",
|
||||
xaccAccountGetName (imap->acc), kvp_path, token_count);
|
||||
PINFO("Source Account is '%s', Count is '%" G_GINT64_FORMAT "'",
|
||||
xaccAccountGetName (imap->acc), token_count);
|
||||
|
||||
// check for existing guid entry
|
||||
if (qof_instance_has_slot (QOF_INSTANCE(imap->acc), kvp_path))
|
||||
if (qof_instance_has_slot (QOF_INSTANCE(imap->acc), path.c_str ()))
|
||||
{
|
||||
int64_t existing_token_count = 0;
|
||||
|
||||
// get the existing_token_count value
|
||||
qof_instance_get_kvp (QOF_INSTANCE (imap->acc), kvp_path, &value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (imap->acc), &value, {path});
|
||||
|
||||
if (G_VALUE_HOLDS_INT64 (&value))
|
||||
existing_token_count = g_value_get_int64 (&value);
|
||||
@ -5362,7 +5325,7 @@ change_imap_entry (GncImportMatchMap *imap, gchar const * kvp_path, int64_t toke
|
||||
g_value_set_int64 (&value, token_count);
|
||||
|
||||
// Add or Update the entry based on guid
|
||||
qof_instance_set_kvp (QOF_INSTANCE (imap->acc), kvp_path, &value);
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (imap->acc), &value, {path});
|
||||
|
||||
/* Set a feature flag in the book for the change to use guid.
|
||||
* This will prevent older GnuCash versions that don't support this feature
|
||||
@ -5410,11 +5373,11 @@ gnc_account_imap_add_account_bayes (GncImportMatchMap *imap,
|
||||
/* start off with one token for this account */
|
||||
token_count = 1;
|
||||
PINFO("adding token '%s'", (char*)current_token->data);
|
||||
std::string translated_token {static_cast <char*> (current_token->data)};
|
||||
std::replace (translated_token.begin (), translated_token.end (), '/', '-');
|
||||
std::string translated_token {static_cast<char*>(current_token->data)};
|
||||
std::replace(translated_token.begin(), translated_token.end(), '/', '-');
|
||||
auto path = std::string {IMAP_FRAME_BAYES} + '-' + translated_token + '-' + guid_string;
|
||||
/* change the imap entry for the account */
|
||||
change_imap_entry (imap, path.c_str (), token_count);
|
||||
change_imap_entry (imap, path, token_count);
|
||||
}
|
||||
/* free up the account fullname and guid string */
|
||||
qof_instance_set_dirty (QOF_INSTANCE (imap->acc));
|
||||
@ -5566,12 +5529,10 @@ gnc_account_get_map_entry (Account *acc, const char *full_category)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gchar *text = NULL;
|
||||
gchar *kvp_path = g_strdup (full_category);
|
||||
|
||||
if (qof_instance_has_slot (QOF_INSTANCE(acc), kvp_path))
|
||||
std::vector<std::string> path {full_category};
|
||||
if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
|
||||
{
|
||||
qof_instance_get_kvp (QOF_INSTANCE(acc), kvp_path, &v);
|
||||
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, path);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
{
|
||||
gchar const *string;
|
||||
@ -5579,7 +5540,6 @@ gnc_account_get_map_entry (Account *acc, const char *full_category)
|
||||
text = g_strdup (string);
|
||||
}
|
||||
}
|
||||
g_free (kvp_path);
|
||||
return text;
|
||||
}
|
||||
|
||||
@ -5729,7 +5689,7 @@ static bool
|
||||
run_once_key_set (char const * key, QofBook * book)
|
||||
{
|
||||
GValue value G_VALUE_INIT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE(book), key, &value);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE(book), &value, {key});
|
||||
return G_VALUE_HOLDS_STRING(&value) && strcmp(g_value_get_string(&value), "true");
|
||||
}
|
||||
|
||||
@ -5739,7 +5699,7 @@ set_run_once_key (char const * key, QofBook * book)
|
||||
GValue value G_VALUE_INIT;
|
||||
g_value_init(&value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean(&value, TRUE);
|
||||
qof_instance_set_kvp(QOF_INSTANCE (book), key, &value);
|
||||
qof_instance_set_path_kvp(QOF_INSTANCE (book), &value, {key});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1228,10 +1228,10 @@ xaccAccountDeleteOldData (Account *account)
|
||||
{
|
||||
if (!account) return;
|
||||
xaccAccountBeginEdit (account);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), "old-currency", NULL);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), "old-security", NULL);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), "old-currency-scu", NULL);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (account), "old-security-scu", NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (account), NULL, 1, "old-currency");
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (account), NULL, 1, "old-security");
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (account), NULL, 1, "old-currency-scu");
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (account), NULL, 1, "old-security-scu");
|
||||
qof_instance_set_dirty (QOF_INSTANCE (account));
|
||||
xaccAccountCommitEdit (account);
|
||||
}
|
||||
@ -1337,22 +1337,22 @@ xaccAccountScrubKvp (Account *account)
|
||||
|
||||
if (!account) return;
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), "notes", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (account), &v, 1, "notes");
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
{
|
||||
str2 = g_strstrip(g_value_dup_string(&v));
|
||||
if (strlen(str2) == 0)
|
||||
qof_instance_slot_delete (QOF_INSTANCE (account), "notes");
|
||||
qof_instance_slot_var_delete (QOF_INSTANCE (account), 1, "notes");
|
||||
g_free(str2);
|
||||
}
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (account), "placeholder", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (account), &v, 1, "placeholder");
|
||||
if ((G_VALUE_HOLDS_STRING (&v) &&
|
||||
strcmp(g_value_get_string (&v), "false") == 0) ||
|
||||
(G_VALUE_HOLDS_BOOLEAN (&v) && ! g_value_get_boolean (&v)))
|
||||
qof_instance_slot_delete (QOF_INSTANCE (account), "placeholder");
|
||||
qof_instance_slot_var_delete (QOF_INSTANCE (account), 1, "placeholder");
|
||||
|
||||
qof_instance_slot_delete_if_empty (QOF_INSTANCE (account), "hbci");
|
||||
qof_instance_slot_var_delete_if_empty (QOF_INSTANCE (account), 1, "hbci");
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
|
@ -184,40 +184,31 @@ gnc_split_get_property(GObject *object,
|
||||
g_value_take_object(value, split->lot);
|
||||
break;
|
||||
case PROP_SX_CREDIT_FORMULA:
|
||||
key = GNC_SX_ID "/" GNC_SX_CREDIT_FORMULA;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_CREDIT_FORMULA);
|
||||
break;
|
||||
case PROP_SX_CREDIT_NUMERIC:
|
||||
key = GNC_SX_ID "/" GNC_SX_CREDIT_NUMERIC;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_CREDIT_NUMERIC);
|
||||
break;
|
||||
case PROP_SX_DEBIT_FORMULA:
|
||||
key = GNC_SX_ID "/" GNC_SX_DEBIT_FORMULA;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_DEBIT_FORMULA);
|
||||
break;
|
||||
case PROP_SX_DEBIT_NUMERIC:
|
||||
key = GNC_SX_ID "/" GNC_SX_DEBIT_NUMERIC;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_DEBIT_NUMERIC);
|
||||
break;
|
||||
case PROP_SX_ACCOUNT:
|
||||
key = GNC_SX_ID "/" GNC_SX_ACCOUNT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_ACCOUNT);
|
||||
break;
|
||||
case PROP_SX_SHARES:
|
||||
key = GNC_SX_ID "/" GNC_SX_SHARES;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_SHARES);
|
||||
break;
|
||||
case PROP_ONLINE_ACCOUNT:
|
||||
key = "online_id";
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 1, "online_id");
|
||||
break;
|
||||
case PROP_GAINS_SPLIT:
|
||||
key = "gains-split";
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 1, "gains-split");
|
||||
break;
|
||||
case PROP_GAINS_SOURCE:
|
||||
key = "gains-source";
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), value, 1, "gains-source");
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -270,40 +261,31 @@ gnc_split_set_property(GObject *object,
|
||||
xaccSplitSetLot(split, g_value_get_object(value));
|
||||
break;
|
||||
case PROP_SX_CREDIT_FORMULA:
|
||||
key = GNC_SX_ID "/" GNC_SX_CREDIT_FORMULA;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_CREDIT_FORMULA);
|
||||
break;
|
||||
case PROP_SX_CREDIT_NUMERIC:
|
||||
key = GNC_SX_ID "/" GNC_SX_CREDIT_NUMERIC;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_CREDIT_NUMERIC);
|
||||
break;
|
||||
case PROP_SX_DEBIT_FORMULA:
|
||||
key = GNC_SX_ID "/" GNC_SX_DEBIT_FORMULA;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_DEBIT_FORMULA);
|
||||
break;
|
||||
case PROP_SX_DEBIT_NUMERIC:
|
||||
key = GNC_SX_ID "/" GNC_SX_DEBIT_NUMERIC;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_DEBIT_NUMERIC);
|
||||
break;
|
||||
case PROP_SX_ACCOUNT:
|
||||
key = GNC_SX_ID "/" GNC_SX_ACCOUNT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_ACCOUNT);
|
||||
break;
|
||||
case PROP_SX_SHARES:
|
||||
key = GNC_SX_ID "/" GNC_SX_SHARES;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_SHARES);
|
||||
break;
|
||||
case PROP_ONLINE_ACCOUNT:
|
||||
key = "online_id";
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 1, "online_id");
|
||||
break;
|
||||
case PROP_GAINS_SPLIT:
|
||||
key = "gains-split";
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 1, "gains-split");
|
||||
break;
|
||||
case PROP_GAINS_SOURCE:
|
||||
key = "gains-source";
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), value, 1, "gains-source");
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -1097,7 +1079,7 @@ xaccSplitDetermineGainStatus (Split *split)
|
||||
return;
|
||||
}
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), "gains-source", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), &v, 1, "gains-source");
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
guid = (GncGUID*)g_value_get_boxed (&v);
|
||||
if (!guid)
|
||||
@ -1990,7 +1972,7 @@ xaccSplitGetType(const Split *s)
|
||||
const char *split_type = NULL;
|
||||
|
||||
if (!s) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (s), "split-type", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (s), &v, 1, "split-type");
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
split_type = g_value_get_string (&v);
|
||||
return split_type ? split_type : "normal";
|
||||
@ -2007,7 +1989,7 @@ xaccSplitMakeStockSplit(Split *s)
|
||||
s->value = gnc_numeric_zero();
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, "stock-split");
|
||||
qof_instance_set_kvp (QOF_INSTANCE (s), "split-type", &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (s), &v, 1, "split-type");
|
||||
SET_GAINS_VDIRTY(s);
|
||||
mark_split(s);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(s));
|
||||
@ -2144,7 +2126,7 @@ xaccSplitVoidFormerAmount(const Split *split)
|
||||
GValue v = G_VALUE_INIT;
|
||||
gnc_numeric *num = NULL;
|
||||
g_return_val_if_fail(split, gnc_numeric_zero());
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), void_former_amt_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
num = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
return num ? *num : gnc_numeric_zero();
|
||||
@ -2156,7 +2138,7 @@ xaccSplitVoidFormerValue(const Split *split)
|
||||
GValue v = G_VALUE_INIT;
|
||||
gnc_numeric *num = NULL;
|
||||
g_return_val_if_fail(split, gnc_numeric_zero());
|
||||
qof_instance_get_kvp (QOF_INSTANCE (split), void_former_val_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
num = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
return num ? *num : gnc_numeric_zero();
|
||||
@ -2171,10 +2153,10 @@ xaccSplitVoid(Split *split)
|
||||
g_value_init (&v, GNC_TYPE_NUMERIC);
|
||||
num = xaccSplitGetAmount(split);
|
||||
g_value_set_boxed (&v, &num);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), void_former_amt_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str);
|
||||
num = xaccSplitGetValue(split);
|
||||
g_value_set_boxed (&v, &num);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), void_former_val_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str);
|
||||
|
||||
/* Marking dirty handled by SetAmount etc. */
|
||||
xaccSplitSetAmount (split, zero);
|
||||
@ -2188,8 +2170,8 @@ xaccSplitUnvoid(Split *split)
|
||||
xaccSplitSetAmount (split, xaccSplitVoidFormerAmount(split));
|
||||
xaccSplitSetValue (split, xaccSplitVoidFormerValue(split));
|
||||
xaccSplitSetReconcile(split, NREC);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), void_former_amt_str, NULL);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (split), void_former_val_str, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), NULL, 1, void_former_amt_str);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (split), NULL, 1, void_former_val_str);
|
||||
qof_instance_set_dirty (QOF_INSTANCE (split));
|
||||
}
|
||||
|
||||
|
@ -338,17 +338,14 @@ gnc_transaction_get_property(GObject* object,
|
||||
g_value_set_boxed(value, &tx->date_entered);
|
||||
break;
|
||||
case PROP_INVOICE:
|
||||
key = GNC_INVOICE_ID "/" GNC_INVOICE_GUID;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (tx), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||
break;
|
||||
case PROP_SX_TXN:
|
||||
key = GNC_SX_FROM;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (tx), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (tx), value, 1, GNC_SX_FROM);
|
||||
break;
|
||||
case PROP_ONLINE_ACCOUNT:
|
||||
key = "online_id";
|
||||
qof_instance_get_kvp (QOF_INSTANCE (tx), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (tx), value, 1, "online_id");
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -387,17 +384,14 @@ gnc_transaction_set_property(GObject* object,
|
||||
xaccTransSetDateEnteredTS(tx, g_value_get_boxed(value));
|
||||
break;
|
||||
case PROP_INVOICE:
|
||||
key = GNC_INVOICE_ID "/" GNC_INVOICE_GUID;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (tx), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||
break;
|
||||
case PROP_SX_TXN:
|
||||
key = GNC_SX_FROM;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (tx), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (tx), value, 1, GNC_SX_FROM);
|
||||
break;
|
||||
case PROP_ONLINE_ACCOUNT:
|
||||
key = "online_id";
|
||||
qof_instance_set_kvp (QOF_INSTANCE (tx), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (tx), value, 1, "online_id");
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -1993,7 +1987,7 @@ xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
|
||||
* clearly be distinguished from the Timespec. */
|
||||
g_value_init (&v, G_TYPE_DATE);
|
||||
g_value_set_boxed (&v, &date);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(trans), TRANS_DATE_POSTED, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_DATE_POSTED);
|
||||
/* mark dirty and commit handled by SetDateInternal */
|
||||
xaccTransSetDateInternal(trans, &trans->date_posted,
|
||||
gdate_to_timespec(date));
|
||||
@ -2069,7 +2063,7 @@ xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts)
|
||||
g_value_init (&v, GNC_TYPE_TIMESPEC);
|
||||
g_value_set_boxed (&v, ts);
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), TRANS_DATE_DUE_KVP, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2083,7 +2077,7 @@ xaccTransSetTxnType (Transaction *trans, char type)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, s);
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), TRANS_TXN_TYPE_KVP, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_TXN_TYPE_KVP);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2093,8 +2087,7 @@ void xaccTransClearReadOnly (Transaction *trans)
|
||||
if (trans)
|
||||
{
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans),
|
||||
TRANS_READ_ONLY_REASON, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), NULL, 1, TRANS_READ_ONLY_REASON);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2105,11 +2098,11 @@ xaccTransSetReadOnly (Transaction *trans, const char *reason)
|
||||
{
|
||||
if (trans && reason)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, reason);
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, reason);
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), TRANS_READ_ONLY_REASON, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_READ_ONLY_REASON);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2167,7 +2160,7 @@ xaccTransSetAssociation (Transaction *trans, const char *assoc)
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, assoc);
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), assoc_uri_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, assoc_uri_str);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2189,7 +2182,7 @@ xaccTransSetNotes (Transaction *trans, const char *notes)
|
||||
g_value_set_string (&v, notes);
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), trans_notes_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2202,13 +2195,13 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
|
||||
|
||||
if (is_closing)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, 1);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), trans_is_closing_str, &v);
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64 (&v, 1);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_is_closing_str);
|
||||
}
|
||||
else
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), trans_is_closing_str, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), NULL, 1, trans_is_closing_str);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
@ -2343,7 +2336,7 @@ xaccTransGetAssociation (const Transaction *trans)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!trans) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), assoc_uri_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, assoc_uri_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return g_value_get_string (&v);
|
||||
return NULL;
|
||||
@ -2354,7 +2347,7 @@ xaccTransGetNotes (const Transaction *trans)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!trans) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), trans_notes_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return g_value_get_string (&v);
|
||||
return NULL;
|
||||
@ -2365,7 +2358,7 @@ xaccTransGetIsClosingTxn (const Transaction *trans)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!trans) return FALSE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), trans_is_closing_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_is_closing_str);
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
return g_value_get_int64 (&v);
|
||||
return FALSE;
|
||||
@ -2419,11 +2412,11 @@ xaccTransGetDatePostedGDate (const Transaction *trans)
|
||||
/* Can we look up this value in the kvp slot? If yes, use it
|
||||
* from there because it doesn't suffer from time zone
|
||||
* shifts. */
|
||||
GValue v = G_VALUE_INIT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), TRANS_DATE_POSTED, &v);
|
||||
GValue v = G_VALUE_INIT;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_POSTED);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
result = *(GDate*)g_value_get_boxed (&v);
|
||||
if (! g_date_valid (&result))
|
||||
if (! g_date_valid (&result))
|
||||
{
|
||||
/* Well, this txn doesn't have a GDate saved in a
|
||||
* slot. Avoid getting the date in the local TZ by
|
||||
@ -2455,7 +2448,7 @@ xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts)
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!trans || !ts) return;
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), TRANS_DATE_DUE_KVP, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
*ts = *(Timespec*)g_value_get_boxed (&v);
|
||||
if (ts->tv_sec == 0)
|
||||
@ -2477,11 +2470,11 @@ xaccTransGetTxnType (const Transaction *trans)
|
||||
GValue v = G_VALUE_INIT;
|
||||
|
||||
if (!trans) return TXN_TYPE_NONE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), TRANS_TXN_TYPE_KVP, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_TXN_TYPE_KVP);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
if (s && strlen (s) == 1)
|
||||
return *s;
|
||||
return *s;
|
||||
|
||||
return TXN_TYPE_NONE;
|
||||
}
|
||||
@ -2495,11 +2488,11 @@ xaccTransGetReadOnly (const Transaction *trans)
|
||||
GValue v = G_VALUE_INIT;
|
||||
const char *s = NULL;
|
||||
if (trans == NULL) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE(trans), TRANS_READ_ONLY_REASON, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_READ_ONLY_REASON);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
if (s && strlen (s))
|
||||
return s;
|
||||
return s;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -2693,20 +2686,20 @@ xaccTransVoid(Transaction *trans, const char *reason)
|
||||
return;
|
||||
}
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), trans_notes_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), void_former_notes_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, void_former_notes_str);
|
||||
else
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (&v, _("Voided transaction"));
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), trans_notes_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
|
||||
g_value_set_string (&v, reason);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), void_reason_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
|
||||
gnc_timespec_to_iso8601_buff (timespec_now (), iso8601_str);
|
||||
g_value_set_string (&v, iso8601_str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), void_time_str, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, void_time_str);
|
||||
|
||||
FOR_EACH_SPLIT(trans, xaccSplitVoid(s));
|
||||
|
||||
@ -2722,7 +2715,7 @@ xaccTransGetVoidStatus(const Transaction *trans)
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(trans, FALSE);
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), void_reason_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
return s && strlen(s);
|
||||
@ -2734,7 +2727,7 @@ xaccTransGetVoidReason(const Transaction *trans)
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(trans, FALSE);
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), void_reason_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return g_value_get_string (&v);
|
||||
return NULL;
|
||||
@ -2748,11 +2741,11 @@ xaccTransGetVoidTime(const Transaction *tr)
|
||||
Timespec void_time = {0, 0};
|
||||
|
||||
g_return_val_if_fail(tr, void_time);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (tr), void_time_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (tr), &v, 1, void_time_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
if (s)
|
||||
return gnc_iso8601_to_timespec_gmt (s);
|
||||
return gnc_iso8601_to_timespec_gmt (s);
|
||||
return void_time;
|
||||
}
|
||||
|
||||
@ -2763,18 +2756,18 @@ xaccTransUnvoid (Transaction *trans)
|
||||
const char *s = NULL;
|
||||
g_return_if_fail(trans);
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), void_reason_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
s = g_value_get_string (&v);
|
||||
if (s == NULL) return; /* Transaction isn't voided. Bail. */
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), void_former_notes_str, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (trans), &v, 1, void_former_notes_str);
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), trans_notes_str, &v);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), void_former_notes_str, NULL);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), void_reason_str, NULL);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), void_time_str, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), NULL, 1, void_former_notes_str);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), NULL, 1, void_reason_str);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (trans), NULL, 1, void_time_str);
|
||||
|
||||
FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s));
|
||||
|
||||
@ -2804,7 +2797,7 @@ xaccTransReverse (Transaction *orig)
|
||||
/* Now update the original with a pointer to the new one */
|
||||
g_value_init (&v, GNC_TYPE_GUID);
|
||||
g_value_set_boxed (&v, xaccTransGetGUID(trans));
|
||||
qof_instance_set_kvp (QOF_INSTANCE (orig), TRANS_REVERSED_BY, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (orig), &v, 1, TRANS_REVERSED_BY);
|
||||
|
||||
/* Make sure the reverse transaction is not read-only */
|
||||
xaccTransClearReadOnly(trans);
|
||||
@ -2819,7 +2812,7 @@ xaccTransGetReversedBy(const Transaction *trans)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_return_val_if_fail(trans, NULL);
|
||||
qof_instance_get_kvp (QOF_INSTANCE(trans), TRANS_REVERSED_BY, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_REVERSED_BY);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
return xaccTransLookup((GncGUID*)g_value_get_boxed (&v),
|
||||
qof_instance_get_book(trans));
|
||||
|
@ -473,32 +473,31 @@ gnc_budget_get_num_periods(const GncBudget* budget)
|
||||
return GET_PRIVATE(budget)->num_periods;
|
||||
}
|
||||
|
||||
#define BUF_SIZE (10 + GUID_ENCODING_LENGTH + \
|
||||
GNC_BUDGET_MAX_NUM_PERIODS_DIGITS)
|
||||
|
||||
static inline void
|
||||
make_period_path (const Account *account, guint period_num, char *path)
|
||||
make_period_path (const Account *account, guint period_num, char *path1, char *path2)
|
||||
{
|
||||
const GncGUID *guid;
|
||||
gchar *bufend;
|
||||
guid = xaccAccountGetGUID(account);
|
||||
bufend = guid_to_string_buff(guid, path);
|
||||
g_sprintf(bufend, "/%d", period_num);
|
||||
guid = xaccAccountGetGUID (account);
|
||||
guid_to_string_buff (guid, path1);
|
||||
g_sprintf (path2, "%d", period_num);
|
||||
}
|
||||
|
||||
/* period_num is zero-based */
|
||||
/* What happens when account is deleted, after we have an entry for it? */
|
||||
void
|
||||
gnc_budget_unset_account_period_value(GncBudget *budget, const Account *account,
|
||||
guint period_num)
|
||||
{
|
||||
gchar path[BUF_SIZE];
|
||||
gchar path_part_one [GUID_ENCODING_LENGTH];
|
||||
gchar path_part_two [GNC_BUDGET_MAX_NUM_PERIODS_DIGITS];
|
||||
|
||||
g_return_if_fail (budget != NULL);
|
||||
g_return_if_fail (account != NULL);
|
||||
make_period_path (account, period_num, path);
|
||||
make_period_path (account, period_num, path_part_one, path_part_two);
|
||||
|
||||
gnc_budget_begin_edit(budget);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (budget), path, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (budget), NULL, 2, path_part_one, path_part_two);
|
||||
qof_instance_set_dirty(&budget->inst);
|
||||
gnc_budget_commit_edit(budget);
|
||||
|
||||
@ -512,7 +511,8 @@ void
|
||||
gnc_budget_set_account_period_value(GncBudget *budget, const Account *account,
|
||||
guint period_num, gnc_numeric val)
|
||||
{
|
||||
gchar path[BUF_SIZE];
|
||||
gchar path_part_one [GUID_ENCODING_LENGTH];
|
||||
gchar path_part_two [GNC_BUDGET_MAX_NUM_PERIODS_DIGITS];
|
||||
|
||||
/* Watch out for an off-by-one error here:
|
||||
* period_num starts from 0 while num_periods starts from 1 */
|
||||
@ -525,17 +525,17 @@ gnc_budget_set_account_period_value(GncBudget *budget, const Account *account,
|
||||
g_return_if_fail (budget != NULL);
|
||||
g_return_if_fail (account != NULL);
|
||||
|
||||
make_period_path (account, period_num, path);
|
||||
make_period_path (account, period_num, path_part_one, path_part_two);
|
||||
|
||||
gnc_budget_begin_edit(budget);
|
||||
if (gnc_numeric_check(val))
|
||||
qof_instance_set_kvp (QOF_INSTANCE (budget), path, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (budget), NULL, 2, path_part_one, path_part_two);
|
||||
else
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GNC_TYPE_NUMERIC);
|
||||
g_value_set_boxed (&v, &val);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (budget), path, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (budget), &v, 2, path_part_one, path_part_two);
|
||||
}
|
||||
qof_instance_set_dirty(&budget->inst);
|
||||
gnc_budget_commit_edit(budget);
|
||||
@ -553,14 +553,15 @@ gnc_budget_is_account_period_value_set(const GncBudget *budget,
|
||||
guint period_num)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
gchar path[BUF_SIZE];
|
||||
gchar path_part_one [GUID_ENCODING_LENGTH];
|
||||
gchar path_part_two [GNC_BUDGET_MAX_NUM_PERIODS_DIGITS];
|
||||
gconstpointer ptr = NULL;
|
||||
|
||||
g_return_val_if_fail(GNC_IS_BUDGET(budget), FALSE);
|
||||
g_return_val_if_fail(account, FALSE);
|
||||
|
||||
make_period_path (account, period_num, path);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (budget), path, &v);
|
||||
make_period_path (account, period_num, path_part_one, path_part_two);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (budget), &v, 2, path_part_one, path_part_two);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
ptr = g_value_get_boxed (&v);
|
||||
return (ptr != NULL);
|
||||
@ -572,14 +573,15 @@ gnc_budget_get_account_period_value(const GncBudget *budget,
|
||||
guint period_num)
|
||||
{
|
||||
gnc_numeric *numeric = NULL;
|
||||
gchar path[BUF_SIZE];
|
||||
gchar path_part_one [GUID_ENCODING_LENGTH];
|
||||
gchar path_part_two [GNC_BUDGET_MAX_NUM_PERIODS_DIGITS];
|
||||
GValue v = G_VALUE_INIT;
|
||||
|
||||
g_return_val_if_fail(GNC_IS_BUDGET(budget), gnc_numeric_zero());
|
||||
g_return_val_if_fail(account, gnc_numeric_zero());
|
||||
|
||||
make_period_path (account, period_num, path);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (budget), path, &v);
|
||||
make_period_path (account, period_num, path_part_one, path_part_two);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (budget), &v, 2, path_part_one, path_part_two);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
numeric = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ gnc_commodity_get_auto_quote_control_flag(const gnc_commodity *cm)
|
||||
GValue v = G_VALUE_INIT;
|
||||
|
||||
if (!cm) return FALSE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (cm), "auto_quote_control", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (cm), &v, 1, "auto_quote_control");
|
||||
if (G_VALUE_HOLDS_STRING (&v) &&
|
||||
strcmp(g_value_get_string (&v), "false") == 0)
|
||||
return FALSE;
|
||||
@ -1145,7 +1145,7 @@ gnc_commodity_get_user_symbol(const gnc_commodity *cm)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!cm) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE(cm), "user_symbol", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE(cm), &v, 1, "user_symbol");
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return g_value_get_string (&v);
|
||||
return NULL;
|
||||
@ -1316,12 +1316,12 @@ gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm,
|
||||
}
|
||||
gnc_commodity_begin_edit(cm);
|
||||
if (flag)
|
||||
qof_instance_set_kvp (QOF_INSTANCE (cm), "auto_quote_control", NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (cm), NULL, 1, "auto_quote_control");
|
||||
else
|
||||
{
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, "false");
|
||||
qof_instance_set_kvp (QOF_INSTANCE (cm), "auto_quote_control", &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (cm), &v, 1, "auto_quote_control");
|
||||
}
|
||||
mark_commodity_dirty(cm);
|
||||
gnc_commodity_commit_edit(cm);
|
||||
@ -1456,10 +1456,10 @@ gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol)
|
||||
{
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, user_symbol);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(cm), "user_symbol", &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE(cm), &v, 1, "user_symbol");
|
||||
}
|
||||
else
|
||||
qof_instance_set_kvp (QOF_INSTANCE(cm), "user_symbol", NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE(cm), NULL, 1, "user_symbol");
|
||||
|
||||
mark_commodity_dirty(cm);
|
||||
gnc_commodity_commit_edit(cm);
|
||||
|
@ -148,16 +148,13 @@ gnc_lot_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec*
|
||||
g_value_set_int(value, priv->marker);
|
||||
break;
|
||||
case PROP_INVOICE:
|
||||
key = GNC_INVOICE_ID "/" GNC_INVOICE_GUID;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (lot), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (lot), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||
break;
|
||||
case PROP_OWNER_TYPE:
|
||||
key = GNC_OWNER_ID"/" GNC_OWNER_TYPE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (lot), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (lot), value, 2, GNC_OWNER_ID, GNC_OWNER_TYPE);
|
||||
break;
|
||||
case PROP_OWNER_GUID:
|
||||
key = GNC_OWNER_ID "/" GNC_OWNER_GUID;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (lot), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (lot), value, 2, GNC_OWNER_ID, GNC_OWNER_GUID);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -191,16 +188,13 @@ gnc_lot_set_property (GObject* object,
|
||||
priv->marker = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_INVOICE:
|
||||
key = GNC_INVOICE_ID"/" GNC_INVOICE_GUID;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (lot), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||
break;
|
||||
case PROP_OWNER_TYPE:
|
||||
key = GNC_OWNER_ID "/" GNC_OWNER_TYPE;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (lot), value, 2, GNC_OWNER_ID, GNC_OWNER_TYPE);
|
||||
break;
|
||||
case PROP_OWNER_GUID:
|
||||
key = GNC_OWNER_ID "/" GNC_OWNER_GUID;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (lot), value, 2, GNC_OWNER_ID, GNC_OWNER_GUID);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -433,7 +427,7 @@ gnc_lot_get_title (const GNCLot *lot)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!lot) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (lot), "/title", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (lot), &v, 1, "title");
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return g_value_get_string (&v);
|
||||
return NULL;
|
||||
@ -444,7 +438,7 @@ gnc_lot_get_notes (const GNCLot *lot)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!lot) return NULL;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (lot), "/notes", &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (lot), &v, 1, "notes");
|
||||
if (G_VALUE_HOLDS_STRING (&v))
|
||||
return g_value_get_string (&v);
|
||||
return NULL;
|
||||
@ -458,7 +452,7 @@ gnc_lot_set_title (GNCLot *lot, const char *str)
|
||||
qof_begin_edit(QOF_INSTANCE(lot));
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), "/title", &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (lot), &v, 1, "title");
|
||||
qof_instance_set_dirty(QOF_INSTANCE(lot));
|
||||
gnc_lot_commit_edit(lot);
|
||||
}
|
||||
@ -471,7 +465,7 @@ gnc_lot_set_notes (GNCLot *lot, const char *str)
|
||||
qof_begin_edit(QOF_INSTANCE(lot));
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_set_string (&v, str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (lot), "/notes", &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (lot), &v, 1, "notes");
|
||||
qof_instance_set_dirty(QOF_INSTANCE(lot));
|
||||
gnc_lot_commit_edit(lot);
|
||||
}
|
||||
|
@ -140,17 +140,14 @@ gnc_customer_get_property (GObject *object,
|
||||
g_value_set_string(value, cust->name);
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (cust), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (cust), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
case PROP_LAST_POSTED:
|
||||
key = LAST_POSTED_TO_ACCT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (cust), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (cust), value, 1, LAST_POSTED_TO_ACCT);
|
||||
break;
|
||||
case PROP_PAYMENT_LAST_ACCT:
|
||||
key = GNC_PAYMENT "/" GNC_LAST_ACCOUNT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (cust), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (cust), value, 2, GNC_PAYMENT, GNC_LAST_ACCOUNT);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -177,17 +174,14 @@ gnc_customer_set_property (GObject *object,
|
||||
gncCustomerSetName(cust, g_value_get_string(value));
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (cust), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (cust), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
case PROP_LAST_POSTED:
|
||||
key = LAST_POSTED_TO_ACCT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (cust), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (cust), value, 1, LAST_POSTED_TO_ACCT);
|
||||
break;
|
||||
case PROP_PAYMENT_LAST_ACCT:
|
||||
key = GNC_PAYMENT "/" GNC_LAST_ACCOUNT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (cust), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (cust), value, 2, GNC_PAYMENT, GNC_LAST_ACCOUNT);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -128,10 +128,7 @@ gnc_employee_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GncEmployee *emp;
|
||||
gchar *key;
|
||||
|
||||
g_return_if_fail(GNC_IS_EMPLOYEE(object));
|
||||
|
||||
emp = GNC_EMPLOYEE(object);
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -166,17 +163,14 @@ gnc_employee_get_property (GObject *object,
|
||||
g_value_take_object(value, emp->ccard_acc);
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (emp), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (emp), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
case PROP_LAST_POSTED:
|
||||
key = LAST_POSTED_TO_ACCT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (emp), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (emp), value, 1, LAST_POSTED_TO_ACCT);
|
||||
break;
|
||||
case PROP_PAYMENT_LAST_ACCT:
|
||||
key = GNC_PAYMENT "/" GNC_LAST_ACCOUNT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (emp), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (emp), value, 2, GNC_PAYMENT, GNC_LAST_ACCOUNT);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -190,13 +184,9 @@ gnc_employee_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GncEmployee *emp;
|
||||
gchar *key;
|
||||
|
||||
g_return_if_fail(GNC_IS_EMPLOYEE(object));
|
||||
|
||||
emp = GNC_EMPLOYEE(object);
|
||||
g_assert (qof_instance_get_editlevel(emp));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_USERNAME:
|
||||
@ -230,17 +220,14 @@ gnc_employee_set_property (GObject *object,
|
||||
gncEmployeeSetCCard(emp, g_value_get_object(value));
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (emp), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (emp), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
case PROP_LAST_POSTED:
|
||||
key = LAST_POSTED_TO_ACCT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (emp), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (emp), value, 1, LAST_POSTED_TO_ACCT);
|
||||
break;
|
||||
case PROP_PAYMENT_LAST_ACCT:
|
||||
key = GNC_PAYMENT "/" GNC_LAST_ACCOUNT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (emp), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (emp), value, 2, GNC_PAYMENT, GNC_LAST_ACCOUNT);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -354,9 +354,9 @@ GncInvoice *gncInvoiceCopy (const GncInvoice *from)
|
||||
invoice->billing_id = CACHE_INSERT (from->billing_id);
|
||||
invoice->active = from->active;
|
||||
|
||||
qof_instance_get_kvp (QOF_INSTANCE (from), GNC_INVOICE_IS_CN, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (from), &v, 1, GNC_INVOICE_IS_CN);
|
||||
if (G_VALUE_HOLDS_INT64 (&v))
|
||||
qof_instance_set_kvp (QOF_INSTANCE (invoice), GNC_INVOICE_IS_CN, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (invoice), &v, 1, GNC_INVOICE_IS_CN);
|
||||
|
||||
invoice->terms = from->terms;
|
||||
gncBillTermIncRef (invoice->terms);
|
||||
@ -551,7 +551,7 @@ void gncInvoiceSetIsCreditNote (GncInvoice *invoice, gboolean credit_note)
|
||||
gncInvoiceBeginEdit (invoice);
|
||||
g_value_init (&v, G_TYPE_INT64);
|
||||
g_value_set_int64(&v, credit_note ? 1 : 0);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (invoice), GNC_INVOICE_IS_CN, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (invoice), &v, 1, GNC_INVOICE_IS_CN);
|
||||
mark_invoice (invoice);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
|
||||
@ -1040,7 +1040,7 @@ gboolean gncInvoiceGetIsCreditNote (const GncInvoice *invoice)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
if (!invoice) return FALSE;
|
||||
qof_instance_get_kvp (QOF_INSTANCE(invoice), GNC_INVOICE_IS_CN, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE(invoice), &v, 1, GNC_INVOICE_IS_CN);
|
||||
if (G_VALUE_HOLDS_INT64(&v) && g_value_get_int64(&v))
|
||||
return TRUE;
|
||||
else
|
||||
|
@ -120,8 +120,7 @@ gnc_job_get_property (GObject *object,
|
||||
g_value_set_string(value, job->name);
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (job), key, value);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (job), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -149,8 +148,7 @@ gnc_job_set_property (GObject *object,
|
||||
gncJobSetName(job, g_value_get_string(value));
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (job), key, value);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (job), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -318,11 +316,11 @@ void gncJobSetRate (GncJob *job, gnc_numeric rate)
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GNC_TYPE_NUMERIC);
|
||||
g_value_set_boxed (&v, &rate);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (job), GNC_JOB_RATE, &v);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (job), &v, 1, GNC_JOB_RATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
qof_instance_set_kvp (QOF_INSTANCE (job), GNC_JOB_RATE, NULL);
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (job), NULL, 1, GNC_JOB_RATE);
|
||||
}
|
||||
mark_job (job);
|
||||
gncJobCommitEdit (job);
|
||||
@ -456,7 +454,7 @@ gnc_numeric gncJobGetRate (const GncJob *job)
|
||||
GValue v = G_VALUE_INIT;
|
||||
gnc_numeric *rate = NULL;
|
||||
if (!job) return gnc_numeric_zero ();
|
||||
qof_instance_get_kvp (QOF_INSTANCE (job), GNC_JOB_RATE, &v);
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (job), &v, 1, GNC_JOB_RATE);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
rate = (gnc_numeric*)g_value_get_boxed (&v);
|
||||
if (rate)
|
||||
|
@ -179,17 +179,14 @@ gnc_vendor_get_property (GObject *object,
|
||||
g_value_set_string(value, qofVendorGetTaxIncluded(vendor));
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (vendor), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (vendor), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
case PROP_LAST_POSTED:
|
||||
key = LAST_POSTED_TO_ACCT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (vendor), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (vendor), value, 1, LAST_POSTED_TO_ACCT);
|
||||
break;
|
||||
case PROP_PAYMENT_LAST_ACCT:
|
||||
key = GNC_PAYMENT "/" GNC_LAST_ACCOUNT;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (vendor), key, value);
|
||||
break;
|
||||
qof_instance_get_var_kvp (QOF_INSTANCE (vendor), value, 2, GNC_PAYMENT, GNC_LAST_ACCOUNT);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -246,17 +243,14 @@ gnc_vendor_set_property (GObject *object,
|
||||
qofVendorSetTaxIncluded(vendor, g_value_get_string(value));
|
||||
break;
|
||||
case PROP_PDF_DIRNAME:
|
||||
key = OWNER_EXPORT_PDF_DIRNAME;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (vendor), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (vendor), value, 1, OWNER_EXPORT_PDF_DIRNAME);
|
||||
break;
|
||||
case PROP_LAST_POSTED:
|
||||
key = LAST_POSTED_TO_ACCT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (vendor), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (vendor), value, 1, LAST_POSTED_TO_ACCT);
|
||||
break;
|
||||
case PROP_PAYMENT_LAST_ACCT:
|
||||
key = GNC_PAYMENT "/" GNC_LAST_ACCOUNT;
|
||||
qof_instance_set_kvp (QOF_INSTANCE (vendor), key, value);
|
||||
break;
|
||||
qof_instance_set_var_kvp (QOF_INSTANCE (vendor), value, 2, GNC_PAYMENT, GNC_LAST_ACCOUNT);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -84,6 +84,11 @@ make_vector(std::string key)
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the key is delimited, calls set(path) with the parsed result
|
||||
* otherwise, inserts the key and value locally and returns the
|
||||
* old value if there was one.
|
||||
*/
|
||||
KvpValue*
|
||||
KvpFrameImpl::set(const char* key, KvpValue* value) noexcept
|
||||
{
|
||||
@ -123,6 +128,10 @@ walk_path_or_nullptr(const KvpFrameImpl* frame, Path& path)
|
||||
return cur_frame;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the last path parameter has a delimiter, the path before that point is ignored,
|
||||
* and set is called with only the last parameter with the delimiter as the key.
|
||||
*/
|
||||
KvpValue*
|
||||
KvpFrameImpl::set(Path path, KvpValue* value) noexcept
|
||||
{
|
||||
|
@ -44,12 +44,8 @@
|
||||
* KVP modifications are written to the database. Two generic abstractions are
|
||||
* provided:
|
||||
*
|
||||
* * @ref qof_instance_set_kvp and @ref qof_instance_get_kvp provide single-item
|
||||
access via GValues to support object properties.
|
||||
|
||||
* * @ref qof_book_set_option and @ref qof_book_get_option provide similar
|
||||
access for book options.
|
||||
|
||||
* access for book options.
|
||||
*
|
||||
* @ref kvpvalues provides a catolog of KVP entries including what objects
|
||||
* they're part of and how they're used.
|
||||
|
@ -142,62 +142,40 @@ qof_book_get_property (GObject* object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OPT_TRADING_ACCOUNTS:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_TRADING_ACCOUNTS);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_TRADING_ACCOUNTS});
|
||||
break;
|
||||
case PROP_OPT_BOOK_CURRENCY:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_BOOK_CURRENCY);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_BOOK_CURRENCY});
|
||||
break;
|
||||
case PROP_OPT_DEFAULT_GAINS_POLICY:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_DEFAULT_GAINS_POLICY);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_GAINS_POLICY});
|
||||
break;
|
||||
case PROP_OPT_DEFAULT_GAINS_ACCOUNT_GUID:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_DEFAULT_GAINS_LOSS_ACCT_GUID);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_GAINS_LOSS_ACCT_GUID});
|
||||
break;
|
||||
case PROP_OPT_AUTO_READONLY_DAYS:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_AUTO_READONLY_DAYS);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_AUTO_READONLY_DAYS});
|
||||
break;
|
||||
case PROP_OPT_NUM_FIELD_SOURCE:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_NUM_FIELD_SOURCE);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_NUM_FIELD_SOURCE});
|
||||
break;
|
||||
case PROP_OPT_DEFAULT_BUDGET:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_DEFAULT_BUDGET);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_BUDGET});
|
||||
break;
|
||||
case PROP_OPT_FY_END:
|
||||
key = const_cast<char*>("fy_end");
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
break;
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});
|
||||
break;
|
||||
case PROP_AB_TEMPLATES:
|
||||
key = const_cast<char*>(AB_KEY "/" AB_TEMPLATES);
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), key, value);
|
||||
break;
|
||||
key = const_cast<char*>(AB_KEY "/" AB_TEMPLATES);
|
||||
qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"AB_KEY", "AB_TEMPLATES"});
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
@ -220,62 +198,39 @@ qof_book_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OPT_TRADING_ACCOUNTS:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_TRADING_ACCOUNTS);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_TRADING_ACCOUNTS});
|
||||
break;
|
||||
case PROP_OPT_BOOK_CURRENCY:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_BOOK_CURRENCY);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_BOOK_CURRENCY});
|
||||
break;
|
||||
case PROP_OPT_DEFAULT_GAINS_POLICY:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_DEFAULT_GAINS_POLICY);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_GAINS_POLICY});
|
||||
break;
|
||||
case PROP_OPT_DEFAULT_GAINS_ACCOUNT_GUID:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_DEFAULT_GAINS_LOSS_ACCT_GUID);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_GAINS_LOSS_ACCT_GUID});
|
||||
break;
|
||||
case PROP_OPT_AUTO_READONLY_DAYS:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_AUTO_READONLY_DAYS);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_AUTO_READONLY_DAYS});
|
||||
break;
|
||||
case PROP_OPT_NUM_FIELD_SOURCE:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_NUM_FIELD_SOURCE);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_NUM_FIELD_SOURCE});
|
||||
break;
|
||||
case PROP_OPT_DEFAULT_BUDGET:
|
||||
key = g_strdup_printf ("%s/%s/%s", KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS,
|
||||
OPTION_NAME_DEFAULT_BUDGET);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
g_free (key);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {KVP_OPTION_PATH,
|
||||
OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_BUDGET});
|
||||
break;
|
||||
case PROP_OPT_FY_END:
|
||||
key = const_cast<char*>("fy_end");
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});
|
||||
break;
|
||||
case PROP_AB_TEMPLATES:
|
||||
key = const_cast<char*>(AB_KEY "/" AB_TEMPLATES);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), key, value);
|
||||
break;
|
||||
qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {AB_KEY, AB_TEMPLATES});
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*
|
||||
* Copyright (C) 2003 Linas Vepstas <linas@linas.org>
|
||||
* Copyright (c) 2007 David Hampton <hampton@employees.org>
|
||||
* Copyright 2017 Aaron Laws <dartme18@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef QOF_INSTANCE_P_H
|
||||
@ -115,23 +116,24 @@ void qof_instance_set_idata(gpointer inst, guint32 idata);
|
||||
* @return TRUE if Kvp isn't empty.
|
||||
*/
|
||||
gboolean qof_instance_has_kvp (QofInstance *inst);
|
||||
/** Sets a KVP slot to a value from a GValue. The key can be a '/'-delimited
|
||||
* path, and intermediate container frames will be created if necessary.
|
||||
* Commits the change to the QofInstance.
|
||||
|
||||
/** Sets a KVP slot to a value from a GValue. Intermediate container
|
||||
* frames will be created if necessary. Commits the change to the QofInstance.
|
||||
* @param inst: The QofInstance on which to set the value.
|
||||
* @param key: The key for the slot or '/'-delimited path
|
||||
* @param key: The path to the slot.
|
||||
* @param value: A GValue containing an item of a type which KvpValue knows
|
||||
* how to store.
|
||||
* how to store.
|
||||
*/
|
||||
void qof_instance_set_kvp (QofInstance *inst, const gchar *key, const GValue *value);
|
||||
void qof_instance_set_var_kvp (QofInstance *, GValue const * value, unsigned count, ...);
|
||||
|
||||
/** Retrieves the contents of a KVP slot into a provided GValue.
|
||||
* @param inst: The QofInstance
|
||||
* @param key: The key of or '/'-delimited path to the slot.
|
||||
* @param key: The path to the slot.
|
||||
* @param value: A GValue into which to store the value of the slot. It will be
|
||||
* set to the correct type.
|
||||
*/
|
||||
void qof_instance_get_kvp (const QofInstance *inst, const gchar *key, GValue
|
||||
*value);
|
||||
void qof_instance_get_var_kvp (QofInstance *, GValue * value, unsigned count, ...);
|
||||
|
||||
/** @} Close out the DOxygen ingroup */
|
||||
/* Functions to isolate the KVP mechanism inside QOF for cases where
|
||||
GValue * operations won't work.
|
||||
@ -151,7 +153,9 @@ gboolean qof_instance_kvp_has_guid (const QofInstance *inst, const char *path,
|
||||
void qof_instance_kvp_merge_guids (const QofInstance *target,
|
||||
const QofInstance *donor, const char* path);
|
||||
gboolean qof_instance_has_slot (const QofInstance *inst, const char *path);
|
||||
void qof_instance_slot_var_delete (const QofInstance *, unsigned count, ...);
|
||||
void qof_instance_slot_delete (const QofInstance *inst, const char *path);
|
||||
void qof_instance_slot_var_delete_if_empty (const QofInstance *, unsigned count, ...);
|
||||
void qof_instance_slot_delete_if_empty (const QofInstance *inst,
|
||||
const char *path);
|
||||
void qof_instance_foreach_slot (const QofInstance *inst, const char *path,
|
||||
@ -160,6 +164,15 @@ void qof_instance_foreach_slot (const QofInstance *inst, const char *path,
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
void qof_instance_get_path_kvp (QofInstance *, GValue *, std::vector<std::string> const &);
|
||||
|
||||
void qof_instance_set_path_kvp (QofInstance *, GValue const *, std::vector<std::string> const &);
|
||||
|
||||
bool qof_instance_has_path_slot (QofInstance const *, std::vector<std::string> const &);
|
||||
|
||||
void qof_instance_slot_path_delete (QofInstance const *, std::vector<std::string> const &);
|
||||
|
||||
void qof_instance_slot_path_delete_if_empty (QofInstance const *, std::vector<std::string> const &);
|
||||
/** Returns all keys that match the given prefix and their corresponding values.*/
|
||||
std::map<std::string, KvpValue*>
|
||||
qof_instance_get_slots_prefix (QofInstance const *, std::string const & prefix);
|
||||
|
@ -26,6 +26,7 @@
|
||||
*
|
||||
* Copyright (C) 2003 Linas Vepstas <linas@linas.org>
|
||||
* Copyright (c) 2007 David Hampton <hampton@employees.org>
|
||||
* Copyright 2017 Aaron Laws <dartme18@gmail.com>
|
||||
*/
|
||||
|
||||
#include "guid.hpp"
|
||||
@ -1059,23 +1060,53 @@ qof_instance_has_kvp (QofInstance *inst)
|
||||
return (inst->kvp_data != NULL && !inst->kvp_data->empty());
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_set_kvp (QofInstance *inst, const gchar *key, const GValue *value)
|
||||
void qof_instance_set_path_kvp (QofInstance * inst, GValue const * value, std::vector<std::string> const & path)
|
||||
{
|
||||
delete inst->kvp_data->set_path(key, kvp_value_from_gvalue(value));
|
||||
delete inst->kvp_data->set_path (path, kvp_value_from_gvalue (value));
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_get_kvp (const QofInstance *inst, const gchar *key, GValue *value)
|
||||
qof_instance_set_var_kvp (QofInstance * inst, GValue const * value, unsigned count, ...)
|
||||
{
|
||||
auto temp = gvalue_from_kvp_value (inst->kvp_data->get_slot(key));
|
||||
std::vector<std::string> path;
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
for (unsigned i{0}; i < count; ++i)
|
||||
path.push_back (va_arg (args, char const *));
|
||||
va_end (args);
|
||||
delete inst->kvp_data->set_path (path, kvp_value_from_gvalue (value));
|
||||
}
|
||||
|
||||
void qof_instance_get_path_kvp (QofInstance * inst, GValue * value, std::vector<std::string> const & path)
|
||||
{
|
||||
auto temp = gvalue_from_kvp_value (inst->kvp_data->get_slot (path));
|
||||
if (G_IS_VALUE (temp))
|
||||
{
|
||||
if (G_IS_VALUE (value))
|
||||
g_value_unset (value);
|
||||
g_value_init (value, G_VALUE_TYPE (temp));
|
||||
g_value_copy (temp, value);
|
||||
gnc_gvalue_free (temp);
|
||||
g_value_copy (temp, value);
|
||||
gnc_gvalue_free (temp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_get_var_kvp (QofInstance * inst, GValue * value, unsigned count, ...)
|
||||
{
|
||||
std::vector<std::string> path;
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
for (unsigned i{0}; i < count; ++i)
|
||||
path.push_back (va_arg (args, char const *));
|
||||
va_end (args);
|
||||
auto temp = gvalue_from_kvp_value (inst->kvp_data->get_slot (path));
|
||||
if (G_IS_VALUE (temp))
|
||||
{
|
||||
if (G_IS_VALUE (value))
|
||||
g_value_unset (value);
|
||||
g_value_init (value, G_VALUE_TYPE (temp));
|
||||
g_value_copy (temp, value);
|
||||
gnc_gvalue_free (temp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1115,16 +1146,16 @@ qof_instance_kvp_add_guid (const QofInstance *inst, const char* path,
|
||||
auto container = new KvpFrame;
|
||||
container->set(key, new KvpValue(const_cast<GncGUID*>(guid)));
|
||||
container->set("date", new KvpValue(time));
|
||||
delete inst->kvp_data->set_path(path, new KvpValue(container));
|
||||
delete inst->kvp_data->set_path({path}, new KvpValue(container));
|
||||
}
|
||||
|
||||
inline static gboolean
|
||||
kvp_match_guid (KvpValue *v, const char *key, const GncGUID *guid)
|
||||
kvp_match_guid (KvpValue *v, std::vector<std::string> const & path, const GncGUID *guid)
|
||||
{
|
||||
if (v->get_type() != KvpValue::Type::FRAME)
|
||||
return FALSE;
|
||||
auto frame = v->get<KvpFrame*>();
|
||||
auto val = frame->get_slot(key);
|
||||
auto val = frame->get_slot(path);
|
||||
if (val == nullptr || val->get_type() != KvpValue::Type::GUID)
|
||||
return FALSE;
|
||||
auto this_guid = val->get<GncGUID*>();
|
||||
@ -1139,13 +1170,13 @@ qof_instance_kvp_has_guid (const QofInstance *inst, const char *path,
|
||||
g_return_val_if_fail (inst->kvp_data != NULL, FALSE);
|
||||
g_return_val_if_fail (guid != NULL, FALSE);
|
||||
|
||||
auto v = inst->kvp_data->get_slot(path);
|
||||
auto v = inst->kvp_data->get_slot({path});
|
||||
if (v == nullptr) return FALSE;
|
||||
|
||||
switch (v->get_type())
|
||||
{
|
||||
case KvpValue::Type::FRAME:
|
||||
return kvp_match_guid (v, key, guid);
|
||||
return kvp_match_guid (v, {key}, guid);
|
||||
break;
|
||||
case KvpValue::Type::GLIST:
|
||||
{
|
||||
@ -1153,7 +1184,7 @@ qof_instance_kvp_has_guid (const QofInstance *inst, const char *path,
|
||||
for (auto node = list; node != NULL; node = node->next)
|
||||
{
|
||||
auto val = static_cast<KvpValue*>(node->data);
|
||||
if (kvp_match_guid (val, key, guid))
|
||||
if (kvp_match_guid (val, {key}, guid))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -1174,15 +1205,15 @@ qof_instance_kvp_remove_guid (const QofInstance *inst, const char *path,
|
||||
g_return_if_fail (inst->kvp_data != NULL);
|
||||
g_return_if_fail (guid != NULL);
|
||||
|
||||
auto v = inst->kvp_data->get_slot(path);
|
||||
auto v = inst->kvp_data->get_slot({path});
|
||||
if (v == NULL) return;
|
||||
|
||||
switch (v->get_type())
|
||||
{
|
||||
case KvpValue::Type::FRAME:
|
||||
if (kvp_match_guid (v, key, guid))
|
||||
if (kvp_match_guid (v, {key}, guid))
|
||||
{
|
||||
delete inst->kvp_data->set_path(path, nullptr);
|
||||
delete inst->kvp_data->set_path({path}, nullptr);
|
||||
delete v;
|
||||
}
|
||||
break;
|
||||
@ -1192,7 +1223,7 @@ qof_instance_kvp_remove_guid (const QofInstance *inst, const char *path,
|
||||
for (auto node = list; node != nullptr; node = node->next)
|
||||
{
|
||||
auto val = static_cast<KvpValue*>(node->data);
|
||||
if (kvp_match_guid (val, key, guid))
|
||||
if (kvp_match_guid (val, {key}, guid))
|
||||
{
|
||||
list = g_list_delete_link (list, node);
|
||||
v->set(list);
|
||||
@ -1216,19 +1247,19 @@ qof_instance_kvp_merge_guids (const QofInstance *target,
|
||||
g_return_if_fail (target != NULL);
|
||||
g_return_if_fail (donor != NULL);
|
||||
|
||||
if (! qof_instance_has_slot (donor, path)) return;
|
||||
auto v = donor->kvp_data->get_slot(path);
|
||||
if (! qof_instance_has_slot (donor, {path})) return;
|
||||
auto v = donor->kvp_data->get_slot({path});
|
||||
if (v == NULL) return;
|
||||
|
||||
auto target_val = target->kvp_data->get_slot(path);
|
||||
auto target_val = target->kvp_data->get_slot({path});
|
||||
switch (v->get_type())
|
||||
{
|
||||
case KvpValue::Type::FRAME:
|
||||
if (target_val)
|
||||
target_val->add(v);
|
||||
else
|
||||
target->kvp_data->set_path(path, v);
|
||||
donor->kvp_data->set(path, nullptr); //Contents moved, Don't delete!
|
||||
target->kvp_data->set_path({path}, v);
|
||||
donor->kvp_data->set({path}, nullptr); //Contents moved, Don't delete!
|
||||
break;
|
||||
case KvpValue::Type::GLIST:
|
||||
if (target_val)
|
||||
@ -1238,8 +1269,8 @@ qof_instance_kvp_merge_guids (const QofInstance *target,
|
||||
target_val->set(list);
|
||||
}
|
||||
else
|
||||
target->kvp_data->set(path, v);
|
||||
donor->kvp_data->set(path, nullptr); //Contents moved, Don't delete!
|
||||
target->kvp_data->set({path}, v);
|
||||
donor->kvp_data->set({path}, nullptr); //Contents moved, Don't delete!
|
||||
break;
|
||||
default:
|
||||
PWARN ("Instance KVP on path %s contains the wrong type.", path);
|
||||
@ -1247,16 +1278,67 @@ qof_instance_kvp_merge_guids (const QofInstance *target,
|
||||
}
|
||||
}
|
||||
|
||||
bool qof_instance_has_path_slot (QofInstance const * inst, std::vector<std::string> const & path)
|
||||
{
|
||||
return inst->kvp_data->get_slot (path) != nullptr;
|
||||
}
|
||||
|
||||
gboolean
|
||||
qof_instance_has_slot (const QofInstance *inst, const char *path)
|
||||
{
|
||||
return inst->kvp_data->get_slot(path) != NULL;
|
||||
}
|
||||
|
||||
void qof_instance_slot_path_delete (QofInstance const * inst, std::vector<std::string> const & path)
|
||||
{
|
||||
delete inst->kvp_data->set (path, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_slot_var_delete (QofInstance const *inst, unsigned count, ...)
|
||||
{
|
||||
std::vector<std::string> path;
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
for (unsigned i{0}; i < count; ++i)
|
||||
path.push_back (va_arg (args, char const *));
|
||||
va_end (args);
|
||||
delete inst->kvp_data->set (path, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_slot_delete (const QofInstance *inst, const char *path)
|
||||
{
|
||||
inst->kvp_data->set(path, nullptr);
|
||||
delete inst->kvp_data->set(path, nullptr);
|
||||
}
|
||||
|
||||
void qof_instance_slot_path_delete_if_empty (QofInstance const * inst, std::vector<std::string> const & path)
|
||||
{
|
||||
auto slot = inst->kvp_data->get_slot (path);
|
||||
if (slot)
|
||||
{
|
||||
auto frame = slot->get <KvpFrame*> ();
|
||||
if (frame && frame->empty())
|
||||
delete inst->kvp_data->set (path, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_slot_var_delete_if_empty (QofInstance const *inst, unsigned count, ...)
|
||||
{
|
||||
std::vector<std::string> path;
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
for (unsigned i{0}; i < count; ++i)
|
||||
path.push_back (va_arg (args, char const *));
|
||||
va_end (args);
|
||||
auto slot = inst->kvp_data->get_slot (path);
|
||||
if (slot)
|
||||
{
|
||||
auto frame = slot->get <KvpFrame*> ();
|
||||
if (frame && frame->empty ())
|
||||
delete inst->kvp_data->set (path, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -1267,9 +1349,10 @@ qof_instance_slot_delete_if_empty (const QofInstance *inst, const char *path)
|
||||
{
|
||||
auto frame = slot->get<KvpFrame*>();
|
||||
if (frame && frame->empty())
|
||||
inst->kvp_data->set(path, nullptr);
|
||||
delete inst->kvp_data->set(path, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct wrap_param
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user