[engine/*.cpp] NULL -> nullptr changes

It's the done thing
This commit is contained in:
Christopher Lam 2024-03-18 06:11:48 +08:00
parent 9a85eb4a2a
commit dab32807ef
18 changed files with 981 additions and 981 deletions

File diff suppressed because it is too large Load Diff

View File

@ -108,10 +108,10 @@ static void
gnc_split_init(Split* split) gnc_split_init(Split* split)
{ {
/* fill in some sane defaults */ /* fill in some sane defaults */
split->acc = NULL; split->acc = nullptr;
split->orig_acc = NULL; split->orig_acc = nullptr;
split->parent = NULL; split->parent = nullptr;
split->lot = NULL; split->lot = nullptr;
split->action = CACHE_INSERT(""); split->action = CACHE_INSERT("");
split->memo = CACHE_INSERT(""); split->memo = CACHE_INSERT("");
@ -127,7 +127,7 @@ gnc_split_init(Split* split)
split->noclosing_balance = gnc_numeric_zero(); split->noclosing_balance = gnc_numeric_zero();
split->gains = GAINS_STATUS_UNKNOWN; split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL; split->gains_split = nullptr;
} }
static void static void
@ -231,7 +231,7 @@ gnc_split_set_property(GObject *object,
g_return_if_fail(GNC_IS_SPLIT(object)); g_return_if_fail(GNC_IS_SPLIT(object));
split = GNC_SPLIT(object); split = GNC_SPLIT(object);
if (prop_id < PROP_RUNTIME_0 && split->parent != NULL) if (prop_id < PROP_RUNTIME_0 && split->parent != nullptr)
g_assert (qof_instance_get_editlevel(split->parent)); g_assert (qof_instance_get_editlevel(split->parent));
switch (prop_id) switch (prop_id)
@ -315,7 +315,7 @@ gnc_split_class_init(SplitClass* klass)
"by the user. It is intended to be a short " "by the user. It is intended to be a short "
"string that contains extra information about " "string that contains extra information about "
"this split.", "this split.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -327,7 +327,7 @@ gnc_split_class_init(SplitClass* klass)
"by the user. It is intended to be a short " "by the user. It is intended to be a short "
"string that describes the purpose of " "string that describes the purpose of "
"this split.", "this split.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -396,7 +396,7 @@ gnc_split_class_init(SplitClass* klass)
"The formula used to calculate the actual debit " "The formula used to calculate the actual debit "
"amount when a real split is generated from this " "amount when a real split is generated from this "
"SX split.", "SX split.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -417,7 +417,7 @@ gnc_split_class_init(SplitClass* klass)
"The formula used to calculate the actual credit " "The formula used to calculate the actual credit "
"amount when a real split is generated from this " "amount when a real split is generated from this "
"SX split.", "SX split.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -441,7 +441,7 @@ gnc_split_class_init(SplitClass* klass)
"Scheduled Transaction Shares", "Scheduled Transaction Shares",
"Numeric value of shares to insert in a new split when " "Numeric value of shares to insert in a new split when "
"it's generated from this SX split.", "it's generated from this SX split.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -460,7 +460,7 @@ gnc_split_class_init(SplitClass* klass)
"Online Account ID", "Online Account ID",
"The online account which corresponds to this " "The online account which corresponds to this "
"account for OFX/HCBI import", "account for OFX/HCBI import",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -500,10 +500,10 @@ void
xaccSplitReinit(Split * split) xaccSplitReinit(Split * split)
{ {
/* fill in some sane defaults */ /* fill in some sane defaults */
split->acc = NULL; split->acc = nullptr;
split->orig_acc = NULL; split->orig_acc = nullptr;
split->parent = NULL; split->parent = nullptr;
split->lot = NULL; split->lot = nullptr;
CACHE_REPLACE(split->action, ""); CACHE_REPLACE(split->action, "");
CACHE_REPLACE(split->memo, ""); CACHE_REPLACE(split->memo, "");
@ -521,7 +521,7 @@ xaccSplitReinit(Split * split)
qof_instance_set_idata(split, 0); qof_instance_set_idata(split, 0);
split->gains = GAINS_STATUS_UNKNOWN; split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL; split->gains_split = nullptr;
} }
/********************************************************************\ /********************************************************************\
@ -531,9 +531,9 @@ Split *
xaccMallocSplit(QofBook *book) xaccMallocSplit(QofBook *book)
{ {
Split *split; Split *split;
g_return_val_if_fail (book, NULL); g_return_val_if_fail (book, nullptr);
split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL)); split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, nullptr));
xaccInitSplit (split, book); xaccInitSplit (split, book);
return split; return split;
@ -551,13 +551,13 @@ xaccMallocSplit(QofBook *book)
Split * Split *
xaccDupeSplit (const Split *s) xaccDupeSplit (const Split *s)
{ {
Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL)); Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, nullptr));
/* Trash the entity table. We don't want to mistake the cloned /* Trash the entity table. We don't want to mistake the cloned
* splits as something official. If we ever use this split, we'll * splits as something official. If we ever use this split, we'll
* have to fix this up. * have to fix this up.
*/ */
split->inst.e_type = NULL; split->inst.e_type = nullptr;
qof_instance_copy_guid(split, s); qof_instance_copy_guid(split, s);
qof_instance_copy_book(split, s); qof_instance_copy_book(split, s);
@ -589,9 +589,9 @@ xaccDupeSplit (const Split *s)
Split * Split *
xaccSplitCloneNoKvp (const Split *s) xaccSplitCloneNoKvp (const Split *s)
{ {
Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL)); Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, nullptr));
split->parent = NULL; split->parent = nullptr;
split->memo = CACHE_INSERT(s->memo); split->memo = CACHE_INSERT(s->memo);
split->action = CACHE_INSERT(s->action); split->action = CACHE_INSERT(s->action);
split->reconciled = s->reconciled; split->reconciled = s->reconciled;
@ -604,7 +604,7 @@ xaccSplitCloneNoKvp (const Split *s)
split->noclosing_balance = s->noclosing_balance; split->noclosing_balance = s->noclosing_balance;
split->gains = GAINS_STATUS_UNKNOWN; split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL; split->gains_split = nullptr;
qof_instance_init_data(&split->inst, GNC_ID_SPLIT, qof_instance_init_data(&split->inst, GNC_ID_SPLIT,
qof_instance_get_book(s)); qof_instance_get_book(s));
@ -622,7 +622,7 @@ xaccSplitCopyKvp (const Split *from, Split *to)
{ {
qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from)); qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from));
/* But not the online-id */ /* But not the online-id */
qof_instance_set (QOF_INSTANCE (to), "online-id", NULL, NULL); qof_instance_set (QOF_INSTANCE (to), "online-id", nullptr, nullptr);
} }
/*################## Added for Reg2 #################*/ /*################## Added for Reg2 #################*/
@ -738,14 +738,14 @@ xaccFreeSplit (Split *split)
/* Just in case someone looks up freed memory ... */ /* Just in case someone looks up freed memory ... */
split->memo = (char *) 1; split->memo = (char *) 1;
split->action = NULL; split->action = nullptr;
split->reconciled = NREC; split->reconciled = NREC;
split->amount = gnc_numeric_zero(); split->amount = gnc_numeric_zero();
split->value = gnc_numeric_zero(); split->value = gnc_numeric_zero();
split->parent = NULL; split->parent = nullptr;
split->lot = NULL; split->lot = nullptr;
split->acc = NULL; split->acc = nullptr;
split->orig_acc = NULL; split->orig_acc = nullptr;
split->date_reconciled = 0; split->date_reconciled = 0;
G_OBJECT_CLASS (QOF_INSTANCE_GET_CLASS (&split->inst))->dispose(G_OBJECT (split)); G_OBJECT_CLASS (QOF_INSTANCE_GET_CLASS (&split->inst))->dispose(G_OBJECT (split));
@ -753,9 +753,9 @@ xaccFreeSplit (Split *split)
if (split->gains_split) if (split->gains_split)
{ {
Split *other = xaccSplitGetOtherSplit(split->gains_split); Split *other = xaccSplitGetOtherSplit(split->gains_split);
split->gains_split->gains_split = NULL; split->gains_split->gains_split = nullptr;
if (other) if (other)
other->gains_split = NULL; other->gains_split = nullptr;
} }
g_object_unref(split); g_object_unref(split);
@ -765,7 +765,7 @@ void mark_split (Split *s)
{ {
if (s->acc) if (s->acc)
{ {
g_object_set(s->acc, "sort-dirty", TRUE, "balance-dirty", TRUE, NULL); g_object_set(s->acc, "sort-dirty", TRUE, "balance-dirty", TRUE, nullptr);
} }
/* set dirty flag on lot too. */ /* set dirty flag on lot too. */
@ -809,7 +809,7 @@ xaccSplitEqual(const Split *sa, const Split *sb,
if (!sa || !sb) if (!sa || !sb)
{ {
PINFO ("one is NULL"); PINFO ("one is nullptr");
return FALSE; return FALSE;
} }
@ -933,8 +933,8 @@ xaccSplitEqual(const Split *sa, const Split *sb,
GList * GList *
xaccSplitListGetUniqueTransactionsReversed (const GList *splits) xaccSplitListGetUniqueTransactionsReversed (const GList *splits)
{ {
GHashTable *txn_hash = g_hash_table_new (NULL, NULL); GHashTable *txn_hash = g_hash_table_new (nullptr, nullptr);
GList *transList = NULL; GList *transList = nullptr;
const GList *snode; const GList *snode;
for (snode = splits; snode; snode = snode->next) for (snode = splits; snode; snode = snode->next)
@ -944,7 +944,7 @@ xaccSplitListGetUniqueTransactionsReversed (const GList *splits)
if (g_hash_table_contains (txn_hash, trans)) if (g_hash_table_contains (txn_hash, trans))
continue; continue;
g_hash_table_insert (txn_hash, trans, NULL); g_hash_table_insert (txn_hash, trans, nullptr);
transList = g_list_prepend (transList, trans); transList = g_list_prepend (transList, trans);
} }
g_hash_table_destroy (txn_hash); g_hash_table_destroy (txn_hash);
@ -967,7 +967,7 @@ xaccSplitListGetUniqueTransactions(const GList *splits)
Account * Account *
xaccSplitGetAccount (const Split *s) xaccSplitGetAccount (const Split *s)
{ {
return s ? s->acc : NULL; return s ? s->acc : nullptr;
} }
void void
@ -999,8 +999,8 @@ static void commit_err (QofInstance *inst, QofBackendError errcode)
void void
xaccSplitCommitEdit(Split *s) xaccSplitCommitEdit(Split *s)
{ {
Account *acc = NULL; Account *acc = nullptr;
Account *orig_acc = NULL; Account *orig_acc = nullptr;
g_return_if_fail(s); g_return_if_fail(s);
if (!qof_instance_is_dirty(QOF_INSTANCE(s))) if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
@ -1032,7 +1032,7 @@ xaccSplitCommitEdit(Split *s)
{ {
/* If the split's lot belonged to some other account, we /* If the split's lot belonged to some other account, we
leave it so. */ leave it so. */
if (s->lot && (NULL == gnc_lot_get_account(s->lot))) if (s->lot && (nullptr == gnc_lot_get_account(s->lot)))
xaccAccountInsertLot (acc, s->lot); xaccAccountInsertLot (acc, s->lot);
} }
else else
@ -1047,12 +1047,12 @@ xaccSplitCommitEdit(Split *s)
//FIXME: find better event //FIXME: find better event
if (s->orig_parent) if (s->orig_parent)
qof_event_gen(&s->orig_parent->inst, QOF_EVENT_MODIFY, qof_event_gen(&s->orig_parent->inst, QOF_EVENT_MODIFY,
NULL); nullptr);
} }
if (s->lot) if (s->lot)
{ {
/* A change of value/amnt affects gains display, etc. */ /* A change of value/amnt affects gains display, etc. */
qof_event_gen (QOF_INSTANCE(s->lot), QOF_EVENT_MODIFY, NULL); qof_event_gen (QOF_INSTANCE(s->lot), QOF_EVENT_MODIFY, nullptr);
} }
/* Important: we save off the original parent transaction and account /* Important: we save off the original parent transaction and account
@ -1060,12 +1060,12 @@ xaccSplitCommitEdit(Split *s)
original and new transactions, for the _next_ begin/commit cycle. */ original and new transactions, for the _next_ begin/commit cycle. */
s->orig_acc = s->acc; s->orig_acc = s->acc;
s->orig_parent = s->parent; s->orig_parent = s->parent;
if (!qof_commit_edit_part2(QOF_INSTANCE(s), commit_err, NULL, do_destroy)) if (!qof_commit_edit_part2(QOF_INSTANCE(s), commit_err, nullptr, do_destroy))
return; return;
if (acc) if (acc)
{ {
g_object_set(acc, "sort-dirty", TRUE, "balance-dirty", TRUE, NULL); g_object_set(acc, "sort-dirty", TRUE, "balance-dirty", TRUE, nullptr);
xaccAccountRecomputeBalance(acc); xaccAccountRecomputeBalance(acc);
} }
} }
@ -1075,7 +1075,7 @@ void
xaccSplitRollbackEdit(Split *s) xaccSplitRollbackEdit(Split *s)
{ {
/* Don't use setters because we want to allow NULL. This is legit /* Don't use setters because we want to allow nullptr. This is legit
only because we don't emit events for changing accounts until only because we don't emit events for changing accounts until
the final commit. */ the final commit. */
if (s->acc != s->orig_acc) if (s->acc != s->orig_acc)
@ -1103,7 +1103,7 @@ Split *
xaccSplitLookup (const GncGUID *guid, QofBook *book) xaccSplitLookup (const GncGUID *guid, QofBook *book)
{ {
QofCollection *col; QofCollection *col;
if (!guid || !book) return NULL; if (!guid || !book) return nullptr;
col = qof_book_get_collection (book, GNC_ID_SPLIT); col = qof_book_get_collection (book, GNC_ID_SPLIT);
return (Split *) qof_collection_lookup_entity (col, guid); return (Split *) qof_collection_lookup_entity (col, guid);
} }
@ -1123,7 +1123,7 @@ xaccSplitDetermineGainStatus (Split *split)
{ {
Split *other; Split *other;
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
GncGUID *guid = NULL; GncGUID *guid = nullptr;
if (GAINS_STATUS_UNKNOWN != split->gains) return; if (GAINS_STATUS_UNKNOWN != split->gains) return;
@ -1618,7 +1618,7 @@ xaccSplitOrderDateOnly (const Split *sa, const Split *sb)
static gboolean static gboolean
get_corr_account_split(const Split *sa, const Split **retval) get_corr_account_split(const Split *sa, const Split **retval)
{ {
*retval = NULL; *retval = nullptr;
g_return_val_if_fail(sa, FALSE); g_return_val_if_fail(sa, FALSE);
if (xaccTransCountSplits (sa->parent) > 2) if (xaccTransCountSplits (sa->parent) > 2)
@ -1635,7 +1635,7 @@ get_corr_account_split(const Split *sa, const Split **retval)
const char * const char *
xaccSplitGetCorrAccountName(const Split *sa) xaccSplitGetCorrAccountName(const Split *sa)
{ {
static const char *split_const = NULL; static const char *split_const = nullptr;
const Split *other_split; const Split *other_split;
if (!get_corr_account_split(sa, &other_split)) if (!get_corr_account_split(sa, &other_split))
@ -1652,7 +1652,7 @@ xaccSplitGetCorrAccountName(const Split *sa)
char * char *
xaccSplitGetCorrAccountFullName(const Split *sa) xaccSplitGetCorrAccountFullName(const Split *sa)
{ {
static const char *split_const = NULL; static const char *split_const = nullptr;
const Split *other_split; const Split *other_split;
if (!get_corr_account_split(sa, &other_split)) if (!get_corr_account_split(sa, &other_split))
@ -1668,7 +1668,7 @@ xaccSplitGetCorrAccountFullName(const Split *sa)
const char * const char *
xaccSplitGetCorrAccountCode(const Split *sa) xaccSplitGetCorrAccountCode(const Split *sa)
{ {
static const char *split_const = NULL; static const char *split_const = nullptr;
const Split *other_split; const Split *other_split;
if (!get_corr_account_split(sa, &other_split)) if (!get_corr_account_split(sa, &other_split))
@ -1864,7 +1864,7 @@ xaccSplitGetDateReconciled (const Split * split)
Transaction * Transaction *
xaccSplitGetParent (const Split *split) xaccSplitGetParent (const Split *split)
{ {
return split ? split->parent : NULL; return split ? split->parent : nullptr;
} }
void void
@ -1901,7 +1901,7 @@ xaccSplitSetParent(Split *s, Transaction *t)
xaccSplitSetValue(s, xaccSplitGetValue(s)); xaccSplitSetValue(s, xaccSplitGetValue(s));
/* add ourselves to the new transaction's list of pending splits. */ /* add ourselves to the new transaction's list of pending splits. */
if (NULL == g_list_find(t->splits, s)) if (nullptr == g_list_find(t->splits, s))
t->splits = g_list_append(t->splits, s); t->splits = g_list_append(t->splits, s);
ed.idx = -1; /* unused */ ed.idx = -1; /* unused */
@ -1914,7 +1914,7 @@ xaccSplitSetParent(Split *s, Transaction *t)
GNCLot * GNCLot *
xaccSplitGetLot (const Split *split) xaccSplitGetLot (const Split *split)
{ {
return split ? split->lot : NULL; return split ? split->lot : nullptr;
} }
void void
@ -1929,13 +1929,13 @@ xaccSplitSetLot(Split* split, GNCLot* lot)
const char * const char *
xaccSplitGetMemo (const Split *split) xaccSplitGetMemo (const Split *split)
{ {
return split ? split->memo : NULL; return split ? split->memo : nullptr;
} }
const char * const char *
xaccSplitGetAction (const Split *split) xaccSplitGetAction (const Split *split)
{ {
return split ? split->action : NULL; return split ? split->action : nullptr;
} }
char char
@ -2004,12 +2004,12 @@ xaccSplitGetBook (const Split *split)
const char * const char *
xaccSplitGetType(const Split *s) xaccSplitGetType(const Split *s)
{ {
if (!s) return NULL; if (!s) return nullptr;
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
const char* type; const char* type;
qof_instance_get_kvp (QOF_INSTANCE (s), &v, 1, "split-type"); qof_instance_get_kvp (QOF_INSTANCE (s), &v, 1, "split-type");
type = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; type = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
const char *rv; const char *rv;
if (!type || !g_strcmp0 (type, split_type_normal)) if (!type || !g_strcmp0 (type, split_type_normal))
rv = split_type_normal; rv = split_type_normal;
@ -2049,13 +2049,13 @@ xaccSplitAddPeerSplit (Split *split, const Split *other_split,
{ {
const GncGUID* guid; const GncGUID* guid;
g_return_if_fail (split != NULL); g_return_if_fail (split != nullptr);
g_return_if_fail (other_split != NULL); g_return_if_fail (other_split != nullptr);
guid = qof_instance_get_guid (QOF_INSTANCE (other_split)); guid = qof_instance_get_guid (QOF_INSTANCE (other_split));
xaccTransBeginEdit (split->parent); xaccTransBeginEdit (split->parent);
qof_instance_kvp_add_guid (QOF_INSTANCE (split), "lot-split", qof_instance_kvp_add_guid (QOF_INSTANCE (split), "lot-split",
gnc_time(NULL), "peer_guid", guid_copy(guid)); gnc_time(nullptr), "peer_guid", guid_copy(guid));
mark_split (split); mark_split (split);
qof_instance_set_dirty (QOF_INSTANCE (split)); qof_instance_set_dirty (QOF_INSTANCE (split));
xaccTransCommitEdit (split->parent); xaccTransCommitEdit (split->parent);
@ -2072,8 +2072,8 @@ xaccSplitIsPeerSplit (const Split *split, const Split *other_split)
{ {
const GncGUID* guid; const GncGUID* guid;
g_return_val_if_fail (split != NULL, FALSE); g_return_val_if_fail (split != nullptr, FALSE);
g_return_val_if_fail (other_split != NULL, FALSE); g_return_val_if_fail (other_split != nullptr, FALSE);
guid = qof_instance_get_guid (QOF_INSTANCE (other_split)); guid = qof_instance_get_guid (QOF_INSTANCE (other_split));
return qof_instance_kvp_has_guid (QOF_INSTANCE (split), "lot-split", return qof_instance_kvp_has_guid (QOF_INSTANCE (split), "lot-split",
@ -2085,8 +2085,8 @@ xaccSplitRemovePeerSplit (Split *split, const Split *other_split)
{ {
const GncGUID* guid; const GncGUID* guid;
g_return_if_fail (split != NULL); g_return_if_fail (split != nullptr);
g_return_if_fail (other_split != NULL); g_return_if_fail (other_split != nullptr);
guid = qof_instance_get_guid (QOF_INSTANCE (other_split)); guid = qof_instance_get_guid (QOF_INSTANCE (other_split));
xaccTransBeginEdit (split->parent); xaccTransBeginEdit (split->parent);
@ -2124,11 +2124,11 @@ Split *
xaccSplitGetOtherSplit (const Split *split) xaccSplitGetOtherSplit (const Split *split)
{ {
Transaction *trans; Transaction *trans;
Split *other = NULL; Split *other = nullptr;
if (!split) return NULL; if (!split) return nullptr;
trans = split->parent; trans = split->parent;
if (!trans) return NULL; if (!trans) return nullptr;
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next) for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{ {
@ -2140,7 +2140,7 @@ xaccSplitGetOtherSplit (const Split *split)
continue; continue;
if (other) if (other)
return NULL; return nullptr;
other = s; other = s;
} }
@ -2154,7 +2154,7 @@ gnc_numeric
xaccSplitVoidFormerAmount(const Split *split) xaccSplitVoidFormerAmount(const Split *split)
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
gnc_numeric *num = NULL; gnc_numeric *num = nullptr;
gnc_numeric retval; gnc_numeric retval;
g_return_val_if_fail(split, gnc_numeric_zero()); g_return_val_if_fail(split, gnc_numeric_zero());
qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str); qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_amt_str);
@ -2169,7 +2169,7 @@ gnc_numeric
xaccSplitVoidFormerValue(const Split *split) xaccSplitVoidFormerValue(const Split *split)
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
gnc_numeric *num = NULL; gnc_numeric *num = nullptr;
gnc_numeric retval; gnc_numeric retval;
g_return_val_if_fail(split, gnc_numeric_zero()); g_return_val_if_fail(split, gnc_numeric_zero());
qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str); qof_instance_get_kvp (QOF_INSTANCE (split), &v, 1, void_former_val_str);
@ -2208,8 +2208,8 @@ xaccSplitUnvoid(Split *split)
xaccSplitSetAmount (split, xaccSplitVoidFormerAmount(split)); xaccSplitSetAmount (split, xaccSplitVoidFormerAmount(split));
xaccSplitSetValue (split, xaccSplitVoidFormerValue(split)); xaccSplitSetValue (split, xaccSplitVoidFormerValue(split));
xaccSplitSetReconcile(split, NREC); xaccSplitSetReconcile(split, NREC);
qof_instance_set_kvp (QOF_INSTANCE (split), NULL, 1, void_former_amt_str); qof_instance_set_kvp (QOF_INSTANCE (split), nullptr, 1, void_former_amt_str);
qof_instance_set_kvp (QOF_INSTANCE (split), NULL, 1, void_former_val_str); qof_instance_set_kvp (QOF_INSTANCE (split), nullptr, 1, void_former_val_str);
qof_instance_set_dirty (QOF_INSTANCE (split)); qof_instance_set_dirty (QOF_INSTANCE (split));
} }
@ -2232,8 +2232,8 @@ static QofObject split_object_def =
DI(.e_type = ) GNC_ID_SPLIT, DI(.e_type = ) GNC_ID_SPLIT,
DI(.type_label = ) "Split", DI(.type_label = ) "Split",
DI(.create = ) (void* (*)(QofBook*))xaccMallocSplit, DI(.create = ) (void* (*)(QofBook*))xaccMallocSplit,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) NULL, DI(.book_end = ) nullptr,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) qof_collection_foreach, DI(.foreach = ) qof_collection_foreach,
@ -2247,9 +2247,9 @@ split_account_guid_getter (gpointer obj, const QofParam *p)
Split *s = GNC_SPLIT(obj); Split *s = GNC_SPLIT(obj);
Account *acc; Account *acc;
if (!s) return NULL; if (!s) return nullptr;
acc = xaccSplitGetAccount (s); acc = xaccSplitGetAccount (s);
if (!acc) return NULL; if (!acc) return nullptr;
return ((gpointer)xaccAccountGetGUID (acc)); return ((gpointer)xaccAccountGetGUID (acc));
} }
@ -2297,23 +2297,23 @@ gboolean xaccSplitRegister (void)
* queries, should be removed from old queries. */ * queries, should be removed from old queries. */
{ {
"d-share-amount", QOF_TYPE_DOUBLE, "d-share-amount", QOF_TYPE_DOUBLE,
(QofAccessFunc)DxaccSplitGetShareAmount, NULL (QofAccessFunc)DxaccSplitGetShareAmount, nullptr
}, },
{ {
"d-share-int64", QOF_TYPE_INT64, "d-share-int64", QOF_TYPE_INT64,
(QofAccessFunc)qof_entity_get_guid, NULL (QofAccessFunc)qof_entity_get_guid, nullptr
}, },
{ {
SPLIT_BALANCE, QOF_TYPE_NUMERIC, SPLIT_BALANCE, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccSplitGetBalance, NULL (QofAccessFunc)xaccSplitGetBalance, nullptr
}, },
{ {
SPLIT_CLEARED_BALANCE, QOF_TYPE_NUMERIC, SPLIT_CLEARED_BALANCE, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccSplitGetClearedBalance, NULL (QofAccessFunc)xaccSplitGetClearedBalance, nullptr
}, },
{ {
SPLIT_RECONCILED_BALANCE, QOF_TYPE_NUMERIC, SPLIT_RECONCILED_BALANCE, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccSplitGetReconciledBalance, NULL (QofAccessFunc)xaccSplitGetReconciledBalance, nullptr
}, },
{ {
SPLIT_MEMO, QOF_TYPE_STRING, SPLIT_MEMO, QOF_TYPE_STRING,
@ -2341,16 +2341,16 @@ gboolean xaccSplitRegister (void)
SPLIT_VALUE, QOF_TYPE_DEBCRED, SPLIT_VALUE, QOF_TYPE_DEBCRED,
(QofAccessFunc)xaccSplitGetValue, (QofSetterFunc)qofSplitSetValue (QofAccessFunc)xaccSplitGetValue, (QofSetterFunc)qofSplitSetValue
}, },
{ SPLIT_TYPE, QOF_TYPE_STRING, (QofAccessFunc)xaccSplitGetType, NULL }, { SPLIT_TYPE, QOF_TYPE_STRING, (QofAccessFunc)xaccSplitGetType, nullptr },
{ {
SPLIT_VOIDED_AMOUNT, QOF_TYPE_NUMERIC, SPLIT_VOIDED_AMOUNT, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccSplitVoidFormerAmount, NULL (QofAccessFunc)xaccSplitVoidFormerAmount, nullptr
}, },
{ {
SPLIT_VOIDED_VALUE, QOF_TYPE_NUMERIC, SPLIT_VOIDED_VALUE, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccSplitVoidFormerValue, NULL (QofAccessFunc)xaccSplitVoidFormerValue, nullptr
}, },
{ SPLIT_LOT, GNC_ID_LOT, (QofAccessFunc)xaccSplitGetLot, NULL }, { SPLIT_LOT, GNC_ID_LOT, (QofAccessFunc)xaccSplitGetLot, nullptr },
{ {
SPLIT_TRANS, GNC_ID_TRANS, SPLIT_TRANS, GNC_ID_TRANS,
(QofAccessFunc)xaccSplitGetParent, (QofAccessFunc)xaccSplitGetParent,
@ -2360,28 +2360,28 @@ gboolean xaccSplitRegister (void)
SPLIT_ACCOUNT, GNC_ID_ACCOUNT, SPLIT_ACCOUNT, GNC_ID_ACCOUNT,
(QofAccessFunc)xaccSplitGetAccount, (QofSetterFunc)qofSplitSetAccount (QofAccessFunc)xaccSplitGetAccount, (QofSetterFunc)qofSplitSetAccount
}, },
{ SPLIT_ACCOUNT_GUID, QOF_TYPE_GUID, split_account_guid_getter, NULL }, { SPLIT_ACCOUNT_GUID, QOF_TYPE_GUID, split_account_guid_getter, nullptr },
/* these are no-ops to register the parameter names (for sorting) but /* these are no-ops to register the parameter names (for sorting) but
they return an allocated object which getters cannot do. */ they return an allocated object which getters cannot do. */
{ SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op, NULL }, { SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op, nullptr },
{ SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op, NULL }, { SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op, nullptr },
{ SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op, NULL }, { SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op, nullptr },
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, NULL }, { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, nullptr },
{ {
QOF_PARAM_GUID, QOF_TYPE_GUID, QOF_PARAM_GUID, QOF_TYPE_GUID,
(QofAccessFunc)qof_entity_get_guid, NULL (QofAccessFunc)qof_entity_get_guid, nullptr
}, },
{ NULL }, { nullptr },
}; };
qof_class_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitOrder, params); qof_class_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitOrder, params);
qof_class_register (SPLIT_ACCT_FULLNAME, qof_class_register (SPLIT_ACCT_FULLNAME,
(QofSortFunc)xaccSplitCompareAccountFullNames, NULL); (QofSortFunc)xaccSplitCompareAccountFullNames, nullptr);
qof_class_register (SPLIT_CORR_ACCT_NAME, qof_class_register (SPLIT_CORR_ACCT_NAME,
(QofSortFunc)xaccSplitCompareOtherAccountFullNames, (QofSortFunc)xaccSplitCompareOtherAccountFullNames,
NULL); nullptr);
qof_class_register (SPLIT_CORR_ACCT_CODE, qof_class_register (SPLIT_CORR_ACCT_CODE,
(QofSortFunc)xaccSplitCompareOtherAccountCodes, NULL); (QofSortFunc)xaccSplitCompareOtherAccountCodes, nullptr);
return qof_object_register (&split_object_def); return qof_object_register (&split_object_def);
} }

View File

@ -251,7 +251,7 @@ void gen_event_trans (Transaction *trans)
if (lot) if (lot)
{ {
/* A change of transaction date might affect opening date of lot */ /* A change of transaction date might affect opening date of lot */
qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, NULL); qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, nullptr);
} }
} }
} }
@ -266,12 +266,12 @@ gnc_transaction_init(Transaction* trans)
/* Fill in some sane defaults */ /* Fill in some sane defaults */
trans->num = CACHE_INSERT(""); trans->num = CACHE_INSERT("");
trans->description = CACHE_INSERT(""); trans->description = CACHE_INSERT("");
trans->common_currency = NULL; trans->common_currency = nullptr;
trans->splits = NULL; trans->splits = nullptr;
trans->date_entered = 0; trans->date_entered = 0;
trans->date_posted = 0; trans->date_posted = 0;
trans->marker = 0; trans->marker = 0;
trans->orig = NULL; trans->orig = nullptr;
trans->txn_type = TXN_TYPE_UNCACHED; trans->txn_type = TXN_TYPE_UNCACHED;
LEAVE (" "); LEAVE (" ");
} }
@ -409,7 +409,7 @@ gnc_transaction_class_init(TransactionClass* klass)
"by the register. For checks, it is usually the " "by the register. For checks, it is usually the "
"check number. For other types of transactions, " "check number. For other types of transactions, "
"it can be any string.", "it can be any string.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -421,7 +421,7 @@ gnc_transaction_class_init(TransactionClass* klass)
"assigned by the user. It is usually the customer, " "assigned by the user. It is usually the customer, "
"vendor or other organization associated with the " "vendor or other organization associated with the "
"transaction.", "transaction.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -478,7 +478,7 @@ gnc_transaction_class_init(TransactionClass* klass)
"Online Account ID", "Online Account ID",
"The online account which corresponds to this " "The online account which corresponds to this "
"account for OFX/HCBI import", "account for OFX/HCBI import",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
} }
@ -503,11 +503,11 @@ xaccMallocTransaction (QofBook *book)
{ {
Transaction *trans; Transaction *trans;
g_return_val_if_fail (book, NULL); g_return_val_if_fail (book, nullptr);
trans = GNC_TRANSACTION(g_object_new(GNC_TYPE_TRANSACTION, NULL)); trans = GNC_TRANSACTION(g_object_new(GNC_TYPE_TRANSACTION, nullptr));
xaccInitTransaction (trans, book); xaccInitTransaction (trans, book);
qof_event_gen (&trans->inst, QOF_EVENT_CREATE, NULL); qof_event_gen (&trans->inst, QOF_EVENT_CREATE, nullptr);
return trans; return trans;
} }
@ -557,7 +557,7 @@ xaccTransDump (const Transaction *trans, const char *tag)
void void
xaccTransSortSplits (Transaction *trans) xaccTransSortSplits (Transaction *trans)
{ {
GList *node, *new_list = NULL; GList *node, *new_list = nullptr;
Split *split; Split *split;
/* first debits */ /* first debits */
@ -597,7 +597,7 @@ dupe_trans (const Transaction *from)
Transaction *to; Transaction *to;
GList *node; GList *node;
to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, NULL)); to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, nullptr));
CACHE_REPLACE (to->num, from->num); CACHE_REPLACE (to->num, from->num);
CACHE_REPLACE (to->description, from->description); CACHE_REPLACE (to->description, from->description);
@ -611,7 +611,7 @@ dupe_trans (const Transaction *from)
to->date_entered = from->date_entered; to->date_entered = from->date_entered;
to->date_posted = from->date_posted; to->date_posted = from->date_posted;
qof_instance_copy_version(to, from); qof_instance_copy_version(to, from);
to->orig = NULL; to->orig = nullptr;
to->common_currency = from->common_currency; to->common_currency = from->common_currency;
@ -619,7 +619,7 @@ dupe_trans (const Transaction *from)
* the cloned transaction as something official. If we ever * the cloned transaction as something official. If we ever
* use this transaction, we'll have to fix this up. * use this transaction, we'll have to fix this up.
*/ */
to->inst.e_type = NULL; to->inst.e_type = nullptr;
qof_instance_set_guid(to, guid_null()); qof_instance_set_guid(to, guid_null());
qof_instance_copy_book(to, from); qof_instance_copy_book(to, from);
qof_instance_copy_kvp (QOF_INSTANCE(to), QOF_INSTANCE(from)); qof_instance_copy_kvp (QOF_INSTANCE(to), QOF_INSTANCE(from));
@ -640,7 +640,7 @@ xaccTransCloneNoKvp (const Transaction *from)
GList *node; GList *node;
qof_event_suspend(); qof_event_suspend();
to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, NULL)); to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, nullptr));
to->date_entered = from->date_entered; to->date_entered = from->date_entered;
to->date_posted = from->date_posted; to->date_posted = from->date_posted;
@ -650,7 +650,7 @@ xaccTransCloneNoKvp (const Transaction *from)
qof_instance_copy_version(to, from); qof_instance_copy_version(to, from);
qof_instance_copy_version_check(to, from); qof_instance_copy_version_check(to, from);
to->orig = NULL; to->orig = nullptr;
qof_instance_init_data (&to->inst, GNC_ID_TRANS, qof_instance_init_data (&to->inst, GNC_ID_TRANS,
qof_instance_get_book(from)); qof_instance_get_book(from));
@ -678,14 +678,14 @@ xaccTransClone (const Transaction *from)
{ {
PERR ("Cloned transaction has different number of splits from original"); PERR ("Cloned transaction has different number of splits from original");
xaccTransDestroy (to); xaccTransDestroy (to);
return NULL; return nullptr;
} }
xaccTransBeginEdit (to); xaccTransBeginEdit (to);
qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from)); qof_instance_copy_kvp (QOF_INSTANCE (to), QOF_INSTANCE (from));
/* But not the online-id! */ /* But not the online-id! */
qof_instance_set (QOF_INSTANCE (to), "online-id", NULL, NULL); qof_instance_set (QOF_INSTANCE (to), "online-id", nullptr, nullptr);
for (GList* lfrom = from->splits, *lto = to->splits; lfrom && lto; for (GList* lfrom = from->splits, *lto = to->splits; lfrom && lto;
lfrom = g_list_next (lfrom), lto = g_list_next (lto)) lfrom = g_list_next (lfrom), lto = g_list_next (lto))
@ -707,7 +707,7 @@ Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans)
Transaction *to_trans; Transaction *to_trans;
if (!from_trans) if (!from_trans)
return NULL; return nullptr;
to_trans = dupe_trans(from_trans); to_trans = dupe_trans(from_trans);
return to_trans; return to_trans;
@ -720,7 +720,7 @@ Transaction * xaccTransCopyToClipBoard(const Transaction *from_trans)
void void
xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans) xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans)
{ {
xaccTransCopyFromClipBoard(from_trans, to_trans, NULL, NULL, TRUE); xaccTransCopyFromClipBoard(from_trans, to_trans, nullptr, nullptr, TRUE);
} }
/********************************************************************\ /********************************************************************\
@ -758,7 +758,7 @@ xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
xaccTransSetCurrency(to_trans, xaccTransGetCurrency(from_trans)); xaccTransSetCurrency(to_trans, xaccTransGetCurrency(from_trans));
xaccTransSetDescription(to_trans, xaccTransGetDescription(from_trans)); xaccTransSetDescription(to_trans, xaccTransGetDescription(from_trans));
if ((xaccTransGetNum(to_trans) == NULL) || (g_strcmp0 (xaccTransGetNum(to_trans), "") == 0)) if ((xaccTransGetNum(to_trans) == nullptr) || (g_strcmp0 (xaccTransGetNum(to_trans), "") == 0))
xaccTransSetNum(to_trans, xaccTransGetNum(from_trans)); xaccTransSetNum(to_trans, xaccTransGetNum(from_trans));
xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans)); xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
@ -800,7 +800,7 @@ xaccFreeTransaction (Transaction *trans)
/* free up the destination splits */ /* free up the destination splits */
g_list_free_full (trans->splits, (GDestroyNotify)xaccFreeSplit); g_list_free_full (trans->splits, (GDestroyNotify)xaccFreeSplit);
trans->splits = NULL; trans->splits = nullptr;
/* free up transaction strings */ /* free up transaction strings */
CACHE_REMOVE(trans->num); CACHE_REMOVE(trans->num);
@ -808,13 +808,13 @@ xaccFreeTransaction (Transaction *trans)
/* Just in case someone looks up freed memory ... */ /* Just in case someone looks up freed memory ... */
trans->num = (char *) 1; trans->num = (char *) 1;
trans->description = NULL; trans->description = nullptr;
trans->date_entered = 0; trans->date_entered = 0;
trans->date_posted = 0; trans->date_posted = 0;
if (trans->orig) if (trans->orig)
{ {
xaccFreeTransaction (trans->orig); xaccFreeTransaction (trans->orig);
trans->orig = NULL; trans->orig = nullptr;
} }
/* qof_instance_release (&trans->inst); */ /* qof_instance_release (&trans->inst); */
@ -859,7 +859,7 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
if (!ta || !tb) if (!ta || !tb)
{ {
PINFO ("one is NULL"); PINFO ("one is nullptr");
return FALSE; return FALSE;
} }
@ -1018,7 +1018,7 @@ Transaction *
xaccTransLookup (const GncGUID *guid, QofBook *book) xaccTransLookup (const GncGUID *guid, QofBook *book)
{ {
QofCollection *col; QofCollection *col;
if (!guid || !book) return NULL; if (!guid || !book) return nullptr;
col = qof_book_get_collection (book, GNC_ID_TRANS); col = qof_book_get_collection (book, GNC_ID_TRANS);
return (Transaction *) qof_collection_lookup_entity (col, guid); return (Transaction *) qof_collection_lookup_entity (col, guid);
} }
@ -1049,7 +1049,7 @@ xaccTransGetImbalance (const Transaction * trans)
split or (2) all the splits are in the same currency. If there are split or (2) all the splits are in the same currency. If there are
no non-currency splits and not all splits are in the same currency then no non-currency splits and not all splits are in the same currency then
imbal_list is used to compute the imbalance. */ imbal_list is used to compute the imbalance. */
MonetaryList *imbal_list = NULL; MonetaryList *imbal_list = nullptr;
gnc_numeric imbal_value = gnc_numeric_zero(); gnc_numeric imbal_value = gnc_numeric_zero();
gboolean trading_accts; gboolean trading_accts;
@ -1122,7 +1122,7 @@ xaccTransIsBalanced (const Transaction *trans)
gnc_numeric imbal = gnc_numeric_zero(); gnc_numeric imbal = gnc_numeric_zero();
gnc_numeric imbal_trading = gnc_numeric_zero(); gnc_numeric imbal_trading = gnc_numeric_zero();
if (trans == NULL) return FALSE; if (trans == nullptr) return FALSE;
if (xaccTransUseTradingAccounts(trans)) if (xaccTransUseTradingAccounts(trans))
{ {
@ -1155,7 +1155,7 @@ xaccTransIsBalanced (const Transaction *trans)
return TRUE; return TRUE;
imbal_list = xaccTransGetImbalance(trans); imbal_list = xaccTransGetImbalance(trans);
result = imbal_list == NULL; result = imbal_list == nullptr;
gnc_monetary_list_free(imbal_list); gnc_monetary_list_free(imbal_list);
return result; return result;
} }
@ -1199,7 +1199,7 @@ xaccTransGetRateForCommodity(const Transaction *trans,
GList *splits; GList *splits;
gnc_commodity *trans_curr; gnc_commodity *trans_curr;
if (trans == NULL || split_com == NULL || split == NULL) if (trans == nullptr || split_com == nullptr || split == nullptr)
return FALSE; return FALSE;
trans_curr = xaccTransGetCurrency (trans); trans_curr = xaccTransGetCurrency (trans);
@ -1305,7 +1305,7 @@ xaccTransGetAccountBalance (const Transaction *trans,
const Account *account) const Account *account)
{ {
GList *node; GList *node;
Split *last_split = NULL; Split *last_split = nullptr;
// Not really the appropriate error value. // Not really the appropriate error value.
g_return_val_if_fail(account && trans, gnc_numeric_error(GNC_ERROR_ARG)); g_return_val_if_fail(account && trans, gnc_numeric_error(GNC_ERROR_ARG));
@ -1341,7 +1341,7 @@ xaccTransGetAccountBalance (const Transaction *trans,
gnc_commodity * gnc_commodity *
xaccTransGetCurrency (const Transaction *trans) xaccTransGetCurrency (const Transaction *trans)
{ {
return trans ? trans->common_currency : NULL; return trans ? trans->common_currency : nullptr;
} }
/* Helper functions for xaccTransSetCurrency */ /* Helper functions for xaccTransSetCurrency */
@ -1350,7 +1350,7 @@ find_new_rate(Transaction *trans, gnc_commodity *curr)
{ {
GList *node; GList *node;
gnc_numeric rate = gnc_numeric_zero(); gnc_numeric rate = gnc_numeric_zero();
for (node = trans->splits; node != NULL; node = g_list_next (node)) for (node = trans->splits; node != nullptr; node = g_list_next (node))
{ {
Split *split = GNC_SPLIT(node->data); Split *split = GNC_SPLIT(node->data);
gnc_commodity *split_com = gnc_commodity *split_com =
@ -1405,7 +1405,7 @@ xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr)
xaccTransBeginEdit(trans); xaccTransBeginEdit(trans);
trans->common_currency = curr; trans->common_currency = curr;
if (old_curr != NULL && trans->splits != NULL) if (old_curr != nullptr && trans->splits != nullptr)
{ {
gnc_numeric rate = find_new_rate(trans, curr); gnc_numeric rate = find_new_rate(trans, curr);
if (!gnc_numeric_zero_p (rate)) if (!gnc_numeric_zero_p (rate))
@ -1477,7 +1477,7 @@ destroy_gains (Transaction *trans)
{ {
Transaction *t = s->gains_split->parent; Transaction *t = s->gains_split->parent;
xaccTransDestroy (t); xaccTransDestroy (t);
s->gains_split = NULL; s->gains_split = nullptr;
} }
} }
} }
@ -1498,7 +1498,7 @@ do_destroy (QofInstance* inst)
if (!shutting_down && !qof_book_is_readonly(qof_instance_get_book(trans))) if (!shutting_down && !qof_book_is_readonly(qof_instance_get_book(trans)))
xaccTransWriteLog (trans, 'D'); xaccTransWriteLog (trans, 'D');
qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, NULL); qof_event_gen (&trans->inst, QOF_EVENT_DESTROY, nullptr);
/* xaccFreeTransaction will also clean up the splits but without /* xaccFreeTransaction will also clean up the splits but without
* emitting GNC_EVENT_ITEM_REMOVED. * emitting GNC_EVENT_ITEM_REMOVED.
*/ */
@ -1578,8 +1578,8 @@ static void trans_cleanup_commit(QofInstance *inst)
{ {
/* Split was either added, destroyed or just changed */ /* Split was either added, destroyed or just changed */
if (qof_instance_get_destroying(s)) if (qof_instance_get_destroying(s))
qof_event_gen(&s->inst, QOF_EVENT_DESTROY, NULL); qof_event_gen(&s->inst, QOF_EVENT_DESTROY, nullptr);
else qof_event_gen(&s->inst, QOF_EVENT_MODIFY, NULL); else qof_event_gen(&s->inst, QOF_EVENT_MODIFY, nullptr);
xaccSplitCommitEdit(s); xaccSplitCommitEdit(s);
} }
} }
@ -1592,7 +1592,7 @@ static void trans_cleanup_commit(QofInstance *inst)
* so we don't need it any more. */ * so we don't need it any more. */
PINFO ("get rid of rollback trans=%p", trans->orig); PINFO ("get rid of rollback trans=%p", trans->orig);
xaccFreeTransaction (trans->orig); xaccFreeTransaction (trans->orig);
trans->orig = NULL; trans->orig = nullptr;
/* Sort the splits. Why do we need to do this ?? */ /* Sort the splits. Why do we need to do this ?? */
/* Good question. Who knows? */ /* Good question. Who knows? */
@ -1603,7 +1603,7 @@ static void trans_cleanup_commit(QofInstance *inst)
g_assert(qof_instance_get_editlevel(trans) == 0); g_assert(qof_instance_get_editlevel(trans) == 0);
gen_event_trans (trans); //TODO: could be conditional gen_event_trans (trans); //TODO: could be conditional
qof_event_gen (&trans->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen (&trans->inst, QOF_EVENT_MODIFY, nullptr);
} }
void void
@ -1644,12 +1644,12 @@ xaccTransCommitEdit (Transaction *trans)
* Call the trans scrub routine to fix it. Indirectly, this * Call the trans scrub routine to fix it. Indirectly, this
* routine also performs a number of other transaction fixes too. * routine also performs a number of other transaction fixes too.
*/ */
xaccTransScrubImbalance (trans, NULL, NULL); xaccTransScrubImbalance (trans, nullptr, nullptr);
/* Get the cap gains into a consistent state as well. */ /* Get the cap gains into a consistent state as well. */
/* Lot Scrubbing is temporarily disabled. */ /* Lot Scrubbing is temporarily disabled. */
if (g_getenv("GNC_AUTO_SCRUB_LOTS") != NULL) if (g_getenv("GNC_AUTO_SCRUB_LOTS") != nullptr)
xaccTransScrubGains (trans, NULL); xaccTransScrubGains (trans, nullptr);
/* Allow scrubbing in transaction commit again */ /* Allow scrubbing in transaction commit again */
scrub_data = 1; scrub_data = 1;
@ -1658,7 +1658,7 @@ xaccTransCommitEdit (Transaction *trans)
/* Record the time of last modification */ /* Record the time of last modification */
if (0 == trans->date_entered) if (0 == trans->date_entered)
{ {
trans->date_entered = gnc_time(NULL); trans->date_entered = gnc_time(nullptr);
qof_instance_set_dirty(QOF_INSTANCE(trans)); qof_instance_set_dirty(QOF_INSTANCE(trans));
} }
@ -1692,7 +1692,7 @@ xaccTransRollbackEdit (Transaction *trans)
* there should be a stack of transaction states that are popped off * there should be a stack of transaction states that are popped off
* and restored at each level -- but it does prevent restoring to the * and restored at each level -- but it does prevent restoring to the
* editlevel 0 state until one is returning to editlevel 0, and * editlevel 0 state until one is returning to editlevel 0, and
* thereby prevents a crash caused by trans->orig getting NULLed too * thereby prevents a crash caused by trans->orig getting nullptred too
* soon. * soon.
*/ */
if (!qof_instance_get_editlevel (QOF_INSTANCE (trans))) return; if (!qof_instance_get_editlevel (QOF_INSTANCE (trans))) return;
@ -1724,7 +1724,7 @@ xaccTransRollbackEdit (Transaction *trans)
num_preexist = g_list_length(orig->splits); num_preexist = g_list_length(orig->splits);
slist = g_list_copy(trans->splits); slist = g_list_copy(trans->splits);
for (i = 0, node = slist, onode = orig->splits; node; for (i = 0, node = slist, onode = orig->splits; node;
i++, node = node->next, onode = onode ? onode->next : NULL) i++, node = node->next, onode = onode ? onode->next : nullptr)
{ {
Split *s = GNC_SPLIT(node->data); Split *s = GNC_SPLIT(node->data);
@ -1766,7 +1766,7 @@ xaccTransRollbackEdit (Transaction *trans)
belongs to the engine. Specifically, it's freed by the belongs to the engine. Specifically, it's freed by the
transaction to which it was added. Don't add the Split to transaction to which it was added. Don't add the Split to
more than one transaction during the begin/commit block! */ more than one transaction during the begin/commit block! */
if (NULL == xaccSplitGetParent(s)) if (nullptr == xaccSplitGetParent(s))
{ {
xaccFreeSplit(s); // a newly malloc'd split xaccFreeSplit(s); // a newly malloc'd split
} }
@ -1776,7 +1776,7 @@ xaccTransRollbackEdit (Transaction *trans)
// orig->splits may still have duped splits so free them // orig->splits may still have duped splits so free them
g_list_free_full (orig->splits, (GDestroyNotify)xaccFreeSplit); g_list_free_full (orig->splits, (GDestroyNotify)xaccFreeSplit);
orig->splits = NULL; orig->splits = nullptr;
/* Now that the engine copy is back to its original version, /* Now that the engine copy is back to its original version,
* get the backend to fix it in the database */ * get the backend to fix it in the database */
@ -1825,7 +1825,7 @@ xaccTransRollbackEdit (Transaction *trans)
xaccFreeTransaction (trans->orig); xaccFreeTransaction (trans->orig);
trans->orig = NULL; trans->orig = nullptr;
qof_instance_set_destroying(trans, FALSE); qof_instance_set_destroying(trans, FALSE);
/* Put back to zero. */ /* Put back to zero. */
@ -1849,7 +1849,7 @@ xaccTransIsOpen (const Transaction *trans)
int int
xaccTransOrder (const Transaction *ta, const Transaction *tb) xaccTransOrder (const Transaction *ta, const Transaction *tb)
{ {
return xaccTransOrder_num_action (ta, NULL, tb, NULL); return xaccTransOrder_num_action (ta, nullptr, tb, nullptr);
} }
/* Order a pair of potentially numeric string as numbers if both /* Order a pair of potentially numeric string as numbers if both
@ -1865,7 +1865,7 @@ xaccTransOrder (const Transaction *ta, const Transaction *tb)
static int static int
order_by_int64_or_string (const char* a, const char* b) order_by_int64_or_string (const char* a, const char* b)
{ {
char *end_a = NULL, *end_b = NULL; char *end_a = nullptr, *end_b = nullptr;
int cmp = 0; int cmp = 0;
uint64_t na = strtoull(a, &end_a, 10); uint64_t na = strtoull(a, &end_a, 10);
uint64_t nb = strtoull(b, &end_b, 10); uint64_t nb = strtoull(b, &end_b, 10);
@ -1905,7 +1905,7 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
} }
/* otherwise, sort on number string */ /* otherwise, sort on number string */
if (actna && actnb) /* split action string, if not NULL */ if (actna && actnb) /* split action string, if not nullptr */
{ {
retval = order_by_int64_or_string (actna, actnb); retval = order_by_int64_or_string (actna, actnb);
} }
@ -2067,7 +2067,7 @@ void xaccTransClearReadOnly (Transaction *trans)
if (trans) if (trans)
{ {
xaccTransBeginEdit(trans); xaccTransBeginEdit(trans);
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, TRANS_READ_ONLY_REASON); qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, TRANS_READ_ONLY_REASON);
qof_instance_set_dirty(QOF_INSTANCE(trans)); qof_instance_set_dirty(QOF_INSTANCE(trans));
xaccTransCommitEdit(trans); xaccTransCommitEdit(trans);
} }
@ -2141,7 +2141,7 @@ xaccTransSetDocLink (Transaction *trans, const char *doclink)
xaccTransBeginEdit(trans); xaccTransBeginEdit(trans);
if (doclink[0] == '\0') if (doclink[0] == '\0')
{ {
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, doclink_uri_str); qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, doclink_uri_str);
} }
else else
{ {
@ -2193,7 +2193,7 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
} }
else else
{ {
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, trans_is_closing_str); qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, trans_is_closing_str);
} }
qof_instance_set_dirty(QOF_INSTANCE(trans)); qof_instance_set_dirty(QOF_INSTANCE(trans));
xaccTransCommitEdit(trans); xaccTransCommitEdit(trans);
@ -2239,10 +2239,10 @@ Split *
xaccTransGetSplit (const Transaction *trans, int i) xaccTransGetSplit (const Transaction *trans, int i)
{ {
int j = 0; int j = 0;
if (!trans || i < 0) return NULL; if (!trans || i < 0) return nullptr;
FOR_EACH_SPLIT(trans, { if (i == j) return s; j++; }); FOR_EACH_SPLIT(trans, { if (i == j) return s; j++; });
return NULL; return nullptr;
} }
int int
@ -2258,13 +2258,13 @@ xaccTransGetSplitIndex(const Transaction *trans, const Split *split)
SplitList * SplitList *
xaccTransGetSplitList (const Transaction *trans) xaccTransGetSplitList (const Transaction *trans)
{ {
return trans ? trans->splits : NULL; return trans ? trans->splits : nullptr;
} }
SplitList * SplitList *
xaccTransGetPaymentAcctSplitList (const Transaction *trans) xaccTransGetPaymentAcctSplitList (const Transaction *trans)
{ {
GList *pay_splits = NULL; GList *pay_splits = nullptr;
FOR_EACH_SPLIT (trans, FOR_EACH_SPLIT (trans,
const Account *account = xaccSplitGetAccount(s); const Account *account = xaccSplitGetAccount(s);
if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account))) if (account && gncBusinessIsPaymentAcctType(xaccAccountGetType(account)))
@ -2278,8 +2278,8 @@ xaccTransGetPaymentAcctSplitList (const Transaction *trans)
SplitList * SplitList *
xaccTransGetAPARAcctSplitList (const Transaction *trans, gboolean strict) xaccTransGetAPARAcctSplitList (const Transaction *trans, gboolean strict)
{ {
GList *apar_splits = NULL; GList *apar_splits = nullptr;
if (!trans) return NULL; if (!trans) return nullptr;
FOR_EACH_SPLIT (trans, FOR_EACH_SPLIT (trans,
const Account *account = xaccSplitGetAccount(s); const Account *account = xaccSplitGetAccount(s);
@ -2312,7 +2312,7 @@ Split *xaccTransGetFirstPaymentAcctSplit(const Transaction *trans)
return s; return s;
); );
return NULL; return nullptr;
} }
Split *xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict) Split *xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict)
@ -2335,14 +2335,14 @@ Split *xaccTransGetFirstAPARAcctSplit (const Transaction *trans, gboolean strict
} }
); );
return NULL; return nullptr;
} }
int int
xaccTransCountSplits (const Transaction *trans) xaccTransCountSplits (const Transaction *trans)
{ {
gint i = 0; gint i = 0;
g_return_val_if_fail (trans != NULL, 0); g_return_val_if_fail (trans != nullptr, 0);
FOR_EACH_SPLIT(trans, i++); FOR_EACH_SPLIT(trans, i++);
return i; return i;
} }
@ -2350,23 +2350,23 @@ xaccTransCountSplits (const Transaction *trans)
const char * const char *
xaccTransGetNum (const Transaction *trans) xaccTransGetNum (const Transaction *trans)
{ {
return trans ? trans->num : NULL; return trans ? trans->num : nullptr;
} }
const char * const char *
xaccTransGetDescription (const Transaction *trans) xaccTransGetDescription (const Transaction *trans)
{ {
return trans ? trans->description : NULL; return trans ? trans->description : nullptr;
} }
const char * const char *
xaccTransGetDocLink (const Transaction *trans) xaccTransGetDocLink (const Transaction *trans)
{ {
g_return_val_if_fail (trans, NULL); g_return_val_if_fail (trans, nullptr);
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, doclink_uri_str); qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, doclink_uri_str);
const char* doclink = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; const char* doclink = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return doclink; return doclink;
@ -2375,11 +2375,11 @@ xaccTransGetDocLink (const Transaction *trans)
const char * const char *
xaccTransGetNotes (const Transaction *trans) xaccTransGetNotes (const Transaction *trans)
{ {
g_return_val_if_fail (trans, NULL); g_return_val_if_fail (trans, nullptr);
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str); qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
const char *notes = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; const char *notes = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return notes; return notes;
@ -2526,12 +2526,12 @@ const char *
xaccTransGetReadOnly (Transaction *trans) xaccTransGetReadOnly (Transaction *trans)
{ {
if (!trans) if (!trans)
return NULL; return nullptr;
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_READ_ONLY_REASON); qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_READ_ONLY_REASON);
const char *readonly_reason = G_VALUE_HOLDS_STRING (&v) ? const char *readonly_reason = G_VALUE_HOLDS_STRING (&v) ?
g_value_get_string (&v) : NULL; g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return readonly_reason; return readonly_reason;
} }
@ -2540,17 +2540,17 @@ static gboolean
xaccTransIsSXTemplate (const Transaction * trans) xaccTransIsSXTemplate (const Transaction * trans)
{ {
Split *split0 = xaccTransGetSplit (trans, 0); Split *split0 = xaccTransGetSplit (trans, 0);
if (split0 != NULL) if (split0 != nullptr)
{ {
char* formula = NULL; char* formula = nullptr;
g_object_get (split0, "sx-debit-formula", &formula, NULL); g_object_get (split0, "sx-debit-formula", &formula, nullptr);
if (formula != NULL) if (formula != nullptr)
{ {
g_free (formula); g_free (formula);
return TRUE; return TRUE;
} }
g_object_get (split0, "sx-credit-formula", &formula, NULL); g_object_get (split0, "sx-credit-formula", &formula, nullptr);
if (formula != NULL) if (formula != nullptr)
{ {
g_free (formula); g_free (formula);
return TRUE; return TRUE;
@ -2649,7 +2649,7 @@ xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
gboolean gboolean
xaccTransHasReconciledSplits (const Transaction *trans) xaccTransHasReconciledSplits (const Transaction *trans)
{ {
return xaccTransHasReconciledSplitsByAccount (trans, NULL); return xaccTransHasReconciledSplitsByAccount (trans, nullptr);
} }
@ -2679,7 +2679,7 @@ xaccTransHasSplitsInStateByAccount (const Transaction *trans,
gboolean gboolean
xaccTransHasSplitsInState (const Transaction *trans, const char state) xaccTransHasSplitsInState (const Transaction *trans, const char state)
{ {
return xaccTransHasSplitsInStateByAccount (trans, state, NULL); return xaccTransHasSplitsInStateByAccount (trans, state, nullptr);
} }
@ -2736,7 +2736,7 @@ xaccTransVoid(Transaction *trans, const char *reason)
g_value_set_static_string (&v, reason); g_value_set_static_string (&v, reason);
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str); qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
gnc_time64_to_iso8601_buff (gnc_time(NULL), iso8601_str); gnc_time64_to_iso8601_buff (gnc_time(nullptr), iso8601_str);
g_value_set_static_string (&v, iso8601_str); g_value_set_static_string (&v, iso8601_str);
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_time_str); qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_time_str);
g_value_unset (&v); g_value_unset (&v);
@ -2758,11 +2758,11 @@ xaccTransGetVoidStatus(const Transaction *trans)
const char * const char *
xaccTransGetVoidReason(const Transaction *trans) xaccTransGetVoidReason(const Transaction *trans)
{ {
g_return_val_if_fail (trans, NULL); g_return_val_if_fail (trans, nullptr);
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str); qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
const char *void_reason = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; const char *void_reason = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return void_reason; return void_reason;
@ -2772,7 +2772,7 @@ time64
xaccTransGetVoidTime(const Transaction *tr) xaccTransGetVoidTime(const Transaction *tr)
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
const char *s = NULL; const char *s = nullptr;
time64 void_time = 0; time64 void_time = 0;
g_return_val_if_fail(tr, void_time); g_return_val_if_fail(tr, void_time);
@ -2791,19 +2791,19 @@ void
xaccTransUnvoid (Transaction *trans) xaccTransUnvoid (Transaction *trans)
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
const char *s = NULL; const char *s = nullptr;
g_return_if_fail(trans); g_return_if_fail(trans);
s = xaccTransGetVoidReason (trans); s = xaccTransGetVoidReason (trans);
if (s == NULL) return; /* Transaction isn't voided. Bail. */ if (s == nullptr) return; /* Transaction isn't voided. Bail. */
xaccTransBeginEdit(trans); xaccTransBeginEdit(trans);
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_former_notes_str); qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, void_former_notes_str);
if (G_VALUE_HOLDS_STRING (&v)) if (G_VALUE_HOLDS_STRING (&v))
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str); qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, trans_notes_str);
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_former_notes_str); qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, void_former_notes_str);
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_reason_str); qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, void_reason_str);
qof_instance_set_kvp (QOF_INSTANCE (trans), NULL, 1, void_time_str); qof_instance_set_kvp (QOF_INSTANCE (trans), nullptr, 1, void_time_str);
g_value_unset (&v); g_value_unset (&v);
FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s)); FOR_EACH_SPLIT(trans, xaccSplitUnvoid(s));
@ -2818,7 +2818,7 @@ xaccTransReverse (Transaction *orig)
{ {
Transaction *trans; Transaction *trans;
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
g_return_val_if_fail(orig, NULL); g_return_val_if_fail(orig, nullptr);
/* First edit, dirty, and commit orig to ensure that any trading /* First edit, dirty, and commit orig to ensure that any trading
* splits are correctly balanced. * splits are correctly balanced.
@ -2828,7 +2828,7 @@ xaccTransReverse (Transaction *orig)
xaccTransCommitEdit (orig); xaccTransCommitEdit (orig);
trans = xaccTransClone(orig); trans = xaccTransClone(orig);
g_return_val_if_fail (trans, NULL); g_return_val_if_fail (trans, nullptr);
xaccTransBeginEdit(trans); xaccTransBeginEdit(trans);
/* Reverse the values on each split. Clear per-split info. */ /* Reverse the values on each split. Clear per-split info. */
@ -2857,8 +2857,8 @@ Transaction *
xaccTransGetReversedBy(const Transaction *trans) xaccTransGetReversedBy(const Transaction *trans)
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
Transaction *retval = NULL; Transaction *retval = nullptr;
g_return_val_if_fail(trans, NULL); g_return_val_if_fail(trans, nullptr);
qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_REVERSED_BY); qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_REVERSED_BY);
if (G_VALUE_HOLDS_BOXED (&v)) if (G_VALUE_HOLDS_BOXED (&v))
{ {
@ -2956,9 +2956,9 @@ restart:
Split * Split *
xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc) xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc)
{ {
if (!trans || !acc) return NULL; if (!trans || !acc) return nullptr;
FOR_EACH_SPLIT(trans, if (xaccSplitGetAccount(s) == acc) return s); FOR_EACH_SPLIT(trans, if (xaccSplitGetAccount(s) == acc) return s);
return NULL; return nullptr;
} }
static void static void
@ -3080,7 +3080,7 @@ gnc_transaction_book_end(QofBook* book)
QofCollection *col; QofCollection *col;
col = qof_book_get_collection(book, GNC_ID_TRANS); col = qof_book_get_collection(book, GNC_ID_TRANS);
qof_collection_foreach(col, destroy_tx_on_book_close, NULL); qof_collection_foreach(col, destroy_tx_on_book_close, nullptr);
} }
#ifdef _MSC_VER #ifdef _MSC_VER
@ -3098,7 +3098,7 @@ static QofObject trans_object_def =
DI(.e_type = ) GNC_ID_TRANS, DI(.e_type = ) GNC_ID_TRANS,
DI(.type_label = ) "Transaction", DI(.type_label = ) "Transaction",
DI(.create = ) (void* (*)(QofBook*))xaccMallocTransaction, DI(.create = ) (void* (*)(QofBook*))xaccMallocTransaction,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) gnc_transaction_book_end, DI(.book_end = ) gnc_transaction_book_end,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
@ -3140,11 +3140,11 @@ gboolean xaccTransRegister (void)
}, },
{ {
TRANS_DATE_DUE, QOF_TYPE_DATE, TRANS_DATE_DUE, QOF_TYPE_DATE,
(QofAccessFunc)xaccTransRetDateDue, NULL (QofAccessFunc)xaccTransRetDateDue, nullptr
}, },
{ {
TRANS_IMBALANCE, QOF_TYPE_NUMERIC, TRANS_IMBALANCE, QOF_TYPE_NUMERIC,
(QofAccessFunc)xaccTransGetImbalanceValue, NULL (QofAccessFunc)xaccTransGetImbalanceValue, nullptr
}, },
{ {
TRANS_NOTES, QOF_TYPE_STRING, TRANS_NOTES, QOF_TYPE_STRING,
@ -3158,11 +3158,11 @@ gboolean xaccTransRegister (void)
}, },
{ {
TRANS_IS_CLOSING, QOF_TYPE_BOOLEAN, TRANS_IS_CLOSING, QOF_TYPE_BOOLEAN,
(QofAccessFunc)xaccTransGetIsClosingTxn, NULL (QofAccessFunc)xaccTransGetIsClosingTxn, nullptr
}, },
{ {
TRANS_IS_BALANCED, QOF_TYPE_BOOLEAN, TRANS_IS_BALANCED, QOF_TYPE_BOOLEAN,
(QofAccessFunc)trans_is_balanced_p, NULL (QofAccessFunc)trans_is_balanced_p, nullptr
}, },
{ {
TRANS_TYPE, QOF_TYPE_CHAR, TRANS_TYPE, QOF_TYPE_CHAR,
@ -3171,29 +3171,29 @@ gboolean xaccTransRegister (void)
}, },
{ {
TRANS_VOID_STATUS, QOF_TYPE_BOOLEAN, TRANS_VOID_STATUS, QOF_TYPE_BOOLEAN,
(QofAccessFunc)xaccTransGetVoidStatus, NULL (QofAccessFunc)xaccTransGetVoidStatus, nullptr
}, },
{ {
TRANS_VOID_REASON, QOF_TYPE_STRING, TRANS_VOID_REASON, QOF_TYPE_STRING,
(QofAccessFunc)xaccTransGetVoidReason, NULL (QofAccessFunc)xaccTransGetVoidReason, nullptr
}, },
{ {
TRANS_VOID_TIME, QOF_TYPE_DATE, TRANS_VOID_TIME, QOF_TYPE_DATE,
(QofAccessFunc)xaccTransGetVoidTime, NULL (QofAccessFunc)xaccTransGetVoidTime, nullptr
}, },
{ {
TRANS_SPLITLIST, GNC_ID_SPLIT, TRANS_SPLITLIST, GNC_ID_SPLIT,
(QofAccessFunc)xaccTransGetSplitList, NULL (QofAccessFunc)xaccTransGetSplitList, nullptr
}, },
{ {
QOF_PARAM_BOOK, QOF_ID_BOOK, QOF_PARAM_BOOK, QOF_ID_BOOK,
(QofAccessFunc)qof_instance_get_book, NULL (QofAccessFunc)qof_instance_get_book, nullptr
}, },
{ {
QOF_PARAM_GUID, QOF_TYPE_GUID, QOF_PARAM_GUID, QOF_TYPE_GUID,
(QofAccessFunc)qof_entity_get_guid, NULL (QofAccessFunc)qof_entity_get_guid, nullptr
}, },
{ NULL }, { nullptr },
}; };
qof_class_register (GNC_ID_TRANS, (QofSortFunc)xaccTransOrder, params); qof_class_register (GNC_ID_TRANS, (QofSortFunc)xaccTransOrder, params);

View File

@ -219,7 +219,7 @@ gnc_budget_class_init(GncBudgetClass* klass)
"to be a short, 5 to 30 character long string " "to be a short, 5 to 30 character long string "
"that is displayed by the GUI as the " "that is displayed by the GUI as the "
"budget mnemonic", "budget mnemonic",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property( g_object_class_install_property(
@ -231,7 +231,7 @@ gnc_budget_class_init(GncBudgetClass* klass)
"assigned by the user. It is intended " "assigned by the user. It is intended "
"to be a longer, 1-5 sentence description of " "to be a longer, 1-5 sentence description of "
"what the budget is all about.", "what the budget is all about.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property( g_object_class_install_property(
@ -266,7 +266,7 @@ gnc_budget_free(QofInstance *inst)
GncBudget *budget; GncBudget *budget;
GncBudgetPrivate* priv; GncBudgetPrivate* priv;
if (inst == NULL) if (inst == nullptr)
return; return;
g_return_if_fail(GNC_IS_BUDGET(inst)); g_return_if_fail(GNC_IS_BUDGET(inst));
@ -276,7 +276,7 @@ gnc_budget_free(QofInstance *inst)
/* We first send the message that this object is about to be /* We first send the message that this object is about to be
* destroyed so that any GUI elements can remove it before it is * destroyed so that any GUI elements can remove it before it is
* actually gone. */ * actually gone. */
qof_event_gen( &budget->inst, QOF_EVENT_DESTROY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_DESTROY, nullptr);
CACHE_REMOVE(priv->name); CACHE_REMOVE(priv->name);
CACHE_REMOVE(priv->description); CACHE_REMOVE(priv->description);
@ -305,14 +305,14 @@ gnc_budget_commit_edit(GncBudget *bgt)
GncBudget* GncBudget*
gnc_budget_new(QofBook *book) gnc_budget_new(QofBook *book)
{ {
g_return_val_if_fail(book, NULL); g_return_val_if_fail(book, nullptr);
ENTER(" "); ENTER(" ");
auto budget { static_cast<GncBudget*>(g_object_new(GNC_TYPE_BUDGET, nullptr)) }; auto budget { static_cast<GncBudget*>(g_object_new(GNC_TYPE_BUDGET, nullptr)) };
qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book); qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book);
qof_event_gen( &budget->inst, QOF_EVENT_CREATE , NULL); qof_event_gen( &budget->inst, QOF_EVENT_CREATE , nullptr);
LEAVE(" "); LEAVE(" ");
return budget; return budget;
@ -359,7 +359,7 @@ gnc_budget_clone(const GncBudget* old_b)
Account* root; Account* root;
CloneBudgetData_t clone_data; CloneBudgetData_t clone_data;
g_return_val_if_fail(old_b != NULL, NULL); g_return_val_if_fail(old_b != nullptr, nullptr);
ENTER(" "); ENTER(" ");
@ -398,13 +398,13 @@ gnc_budget_set_name(GncBudget* budget, const gchar* name)
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
const gchar* const gchar*
gnc_budget_get_name(const GncBudget* budget) gnc_budget_get_name(const GncBudget* budget)
{ {
g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr);
return GET_PRIVATE(budget)->name; return GET_PRIVATE(budget)->name;
} }
@ -423,13 +423,13 @@ gnc_budget_set_description(GncBudget* budget, const gchar* description)
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
const gchar* const gchar*
gnc_budget_get_description(const GncBudget* budget) gnc_budget_get_description(const GncBudget* budget)
{ {
g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr);
return GET_PRIVATE(budget)->description; return GET_PRIVATE(budget)->description;
} }
@ -446,21 +446,21 @@ gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r)
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen(&budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen(&budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
const Recurrence * const Recurrence *
gnc_budget_get_recurrence(const GncBudget *budget) gnc_budget_get_recurrence(const GncBudget *budget)
{ {
g_return_val_if_fail(budget, NULL); g_return_val_if_fail(budget, nullptr);
return (&GET_PRIVATE(budget)->recurrence); return (&GET_PRIVATE(budget)->recurrence);
} }
const GncGUID* const GncGUID*
gnc_budget_get_guid(const GncBudget* budget) gnc_budget_get_guid(const GncBudget* budget)
{ {
g_return_val_if_fail(budget, NULL); g_return_val_if_fail(budget, nullptr);
g_return_val_if_fail(GNC_IS_BUDGET(budget), NULL); g_return_val_if_fail(GNC_IS_BUDGET(budget), nullptr);
return qof_instance_get_guid(QOF_INSTANCE(budget)); return qof_instance_get_guid(QOF_INSTANCE(budget));
} }
@ -486,7 +486,7 @@ gnc_budget_set_num_periods(GncBudget* budget, guint num_periods)
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
guint guint
@ -522,8 +522,8 @@ void
gnc_budget_unset_account_period_value(GncBudget *budget, const Account *account, gnc_budget_unset_account_period_value(GncBudget *budget, const Account *account,
guint period_num) guint period_num)
{ {
g_return_if_fail (budget != NULL); g_return_if_fail (budget != nullptr);
g_return_if_fail (account != NULL); g_return_if_fail (account != nullptr);
g_return_if_fail (period_num < GET_PRIVATE(budget)->num_periods); g_return_if_fail (period_num < GET_PRIVATE(budget)->num_periods);
auto& data = get_perioddata (budget, account, period_num); auto& data = get_perioddata (budget, account, period_num);
@ -536,7 +536,7 @@ gnc_budget_unset_account_period_value(GncBudget *budget, const Account *account,
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
@ -554,8 +554,8 @@ gnc_budget_set_account_period_value(GncBudget *budget, const Account *account,
return; return;
} }
g_return_if_fail (budget != NULL); g_return_if_fail (budget != nullptr);
g_return_if_fail (account != NULL); g_return_if_fail (account != nullptr);
auto& perioddata = get_perioddata (budget, account, period_num); auto& perioddata = get_perioddata (budget, account, period_num);
auto budget_kvp { QOF_INSTANCE (budget)->kvp_data }; auto budget_kvp { QOF_INSTANCE (budget)->kvp_data };
@ -576,7 +576,7 @@ gnc_budget_set_account_period_value(GncBudget *budget, const Account *account,
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
@ -613,15 +613,15 @@ gnc_budget_set_account_period_note(GncBudget *budget, const Account *account,
return; return;
} }
g_return_if_fail (budget != NULL); g_return_if_fail (budget != nullptr);
g_return_if_fail (account != NULL); g_return_if_fail (account != nullptr);
auto& perioddata = get_perioddata (budget, account, period_num); auto& perioddata = get_perioddata (budget, account, period_num);
auto budget_kvp { QOF_INSTANCE (budget)->kvp_data }; auto budget_kvp { QOF_INSTANCE (budget)->kvp_data };
auto path = make_period_note_path (account, period_num); auto path = make_period_note_path (account, period_num);
gnc_budget_begin_edit(budget); gnc_budget_begin_edit(budget);
if (note == NULL) if (note == nullptr)
{ {
delete budget_kvp->set_path (path, nullptr); delete budget_kvp->set_path (path, nullptr);
perioddata.note.clear (); perioddata.note.clear ();
@ -636,7 +636,7 @@ gnc_budget_set_account_period_note(GncBudget *budget, const Account *account,
qof_instance_set_dirty(&budget->inst); qof_instance_set_dirty(&budget->inst);
gnc_budget_commit_edit(budget); gnc_budget_commit_edit(budget);
qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen( &budget->inst, QOF_EVENT_MODIFY, nullptr);
} }
@ -710,8 +710,8 @@ gnc_budget_lookup (const GncGUID *guid, const QofBook *book)
{ {
QofCollection *col; QofCollection *col;
g_return_val_if_fail(guid, NULL); g_return_val_if_fail(guid, nullptr);
g_return_val_if_fail(book, NULL); g_return_val_if_fail(book, nullptr);
col = qof_book_get_collection (book, GNC_ID_BUDGET); col = qof_book_get_collection (book, GNC_ID_BUDGET);
return GNC_BUDGET(qof_collection_lookup_entity (col, guid)); return GNC_BUDGET(qof_collection_lookup_entity (col, guid));
} }
@ -726,14 +726,14 @@ GncBudget*
gnc_budget_get_default (QofBook *book) gnc_budget_get_default (QofBook *book)
{ {
QofCollection *col; QofCollection *col;
GncBudget *bgt = NULL; GncBudget *bgt = nullptr;
GncGUID *default_budget_guid = NULL; GncGUID *default_budget_guid = nullptr;
g_return_val_if_fail(book, NULL); g_return_val_if_fail(book, nullptr);
qof_instance_get (QOF_INSTANCE (book), qof_instance_get (QOF_INSTANCE (book),
"default-budget", &default_budget_guid, "default-budget", &default_budget_guid,
NULL); nullptr);
if (default_budget_guid) if (default_budget_guid)
{ {
col = qof_book_get_collection(book, GNC_ID_BUDGET); col = qof_book_get_collection(book, GNC_ID_BUDGET);
@ -743,7 +743,7 @@ gnc_budget_get_default (QofBook *book)
/* Revert to 2.2.x behavior if the book has no default budget. */ /* Revert to 2.2.x behavior if the book has no default budget. */
if ( bgt == NULL ) if ( bgt == nullptr )
{ {
col = qof_book_get_collection(book, GNC_ID_BUDGET); col = qof_book_get_collection(book, GNC_ID_BUDGET);
if (qof_collection_count(col) > 0) if (qof_collection_count(col) > 0)
@ -774,7 +774,7 @@ gnc_budget_book_end(QofBook* book)
QofCollection *col; QofCollection *col;
col = qof_book_get_collection(book, GNC_ID_BUDGET); col = qof_book_get_collection(book, GNC_ID_BUDGET);
qof_collection_foreach(col, destroy_budget_on_book_close, NULL); qof_collection_foreach(col, destroy_budget_on_book_close, nullptr);
} }
#ifdef _MSC_VER #ifdef _MSC_VER
@ -792,7 +792,7 @@ static QofObject budget_object_def =
DI(.e_type = ) GNC_ID_BUDGET, DI(.e_type = ) GNC_ID_BUDGET,
DI(.type_label = ) "Budget", DI(.type_label = ) "Budget",
DI(.create = ) (void*(*)(QofBook*)) gnc_budget_new, DI(.create = ) (void*(*)(QofBook*)) gnc_budget_new,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) gnc_budget_book_end, DI(.book_end = ) gnc_budget_book_end,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
@ -833,19 +833,19 @@ gboolean gnc_budget_register (void)
}, },
{ {
"recurrence_period_type", QOF_TYPE_INT32, "recurrence_period_type", QOF_TYPE_INT32,
(QofAccessFunc) gnc_budget_get_rec_pt, NULL (QofAccessFunc) gnc_budget_get_rec_pt, nullptr
}, },
/* Signedness problem: Should be unsigned. */ /* Signedness problem: Should be unsigned. */
{ {
"recurrence_multiplier", QOF_TYPE_INT32, "recurrence_multiplier", QOF_TYPE_INT32,
(QofAccessFunc) gnc_budget_get_rec_mult, NULL (QofAccessFunc) gnc_budget_get_rec_mult, nullptr
}, },
/* This is the same way that SchedXaction.c uses QOF_TYPE_DATE /* This is the same way that SchedXaction.c uses QOF_TYPE_DATE
but I don't think QOF actually supports a GDate, so I think but I don't think QOF actually supports a GDate, so I think
this is wrong. */ this is wrong. */
{ {
"recurrence_date", QOF_TYPE_DATE, "recurrence_date", QOF_TYPE_DATE,
(QofAccessFunc) gnc_budget_get_rec_time, NULL (QofAccessFunc) gnc_budget_get_rec_time, nullptr
}, },
/* Signedness problem: Should be unsigned. */ /* Signedness problem: Should be unsigned. */
{ {
@ -855,15 +855,15 @@ gboolean gnc_budget_register (void)
}, },
{ {
QOF_PARAM_BOOK, QOF_ID_BOOK, QOF_PARAM_BOOK, QOF_ID_BOOK,
(QofAccessFunc) qof_instance_get_book, NULL (QofAccessFunc) qof_instance_get_book, nullptr
}, },
{ {
QOF_PARAM_GUID, QOF_TYPE_GUID, QOF_PARAM_GUID, QOF_TYPE_GUID,
(QofAccessFunc) qof_instance_get_guid, NULL (QofAccessFunc) qof_instance_get_guid, nullptr
}, },
{ NULL }, { nullptr },
}; };
qof_class_register(GNC_ID_BUDGET, (QofSortFunc) NULL, params); qof_class_register(GNC_ID_BUDGET, (QofSortFunc) nullptr, params);
return qof_object_register(&budget_object_def); return qof_object_register(&budget_object_def);
} }

View File

@ -303,7 +303,7 @@ gnc_quote_source_fq_installed (void)
* gnc_quote_source_fq_version * gnc_quote_source_fq_version
* *
* This function the version of the Finance::Quote module installed * This function the version of the Finance::Quote module installed
* on a user's computer or NULL if no installation is found. * on a user's computer or nullptr if no installation is found.
********************************************************************/ ********************************************************************/
const char* const char*
gnc_quote_source_fq_version (void) gnc_quote_source_fq_version (void)
@ -553,7 +553,7 @@ static void
mark_commodity_dirty (gnc_commodity *cm) mark_commodity_dirty (gnc_commodity *cm)
{ {
qof_instance_set_dirty(&cm->inst); qof_instance_set_dirty(&cm->inst);
qof_event_gen (&cm->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen (&cm->inst, QOF_EVENT_MODIFY, nullptr);
} }
static void static void
@ -587,13 +587,13 @@ gnc_commodity_init(gnc_commodity* com)
priv = GET_PRIVATE(com); priv = GET_PRIVATE(com);
priv->name_space = NULL; priv->name_space = nullptr;
priv->fullname = CACHE_INSERT(""); priv->fullname = CACHE_INSERT("");
priv->mnemonic = CACHE_INSERT(""); priv->mnemonic = CACHE_INSERT("");
priv->cusip = CACHE_INSERT(""); priv->cusip = CACHE_INSERT("");
priv->fraction = 10000; priv->fraction = 10000;
priv->quote_flag = 0; priv->quote_flag = 0;
priv->quote_source = NULL; priv->quote_source = nullptr;
priv->quote_tz = CACHE_INSERT(""); priv->quote_tz = CACHE_INSERT("");
reset_printname(priv); reset_printname(priv);
@ -737,7 +737,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass)
"Full Commodity Name", "Full Commodity Name",
"The fullname is the official full name of" "The fullname is the official full name of"
"the currency.", "the currency.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, g_object_class_install_property(gobject_class,
PROP_MNEMONIC, PROP_MNEMONIC,
@ -745,21 +745,21 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass)
"Commodity Mnemonic", "Commodity Mnemonic",
"The mnemonic is the official abbreviated" "The mnemonic is the official abbreviated"
"designation for the currency.", "designation for the currency.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, g_object_class_install_property(gobject_class,
PROP_PRINTNAME, PROP_PRINTNAME,
g_param_spec_string ("printname", g_param_spec_string ("printname",
"Commodity Print Name", "Commodity Print Name",
"Printable form of the commodity name.", "Printable form of the commodity name.",
NULL, nullptr,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property(gobject_class, g_object_class_install_property(gobject_class,
PROP_CUSIP, PROP_CUSIP,
g_param_spec_string ("cusip", g_param_spec_string ("cusip",
"Commodity CUSIP Code", "Commodity CUSIP Code",
"?????", "?????",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, g_object_class_install_property(gobject_class,
PROP_FRACTION, PROP_FRACTION,
@ -777,7 +777,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass)
"Commodity Unique Name", "Commodity Unique Name",
"Unique form of the commodity name which combines " "Unique form of the commodity name which combines "
"the namespace name and the commodity name.", "the namespace name and the commodity name.",
NULL, nullptr,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property(gobject_class, g_object_class_install_property(gobject_class,
PROP_QUOTE_FLAG, PROP_QUOTE_FLAG,
@ -798,7 +798,7 @@ gnc_commodity_class_init(struct _GncCommodityClass* klass)
g_param_spec_string ("quote-tz", g_param_spec_string ("quote-tz",
"Commodity Quote Timezone", "Commodity Quote Timezone",
"?????", "?????",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
} }
@ -807,12 +807,12 @@ gnc_commodity_new(QofBook *book, const char * fullname,
const char * name_space, const char * mnemonic, const char * name_space, const char * mnemonic,
const char * cusip, int fraction) const char * cusip, int fraction)
{ {
auto retval = GNC_COMMODITY(g_object_new(GNC_TYPE_COMMODITY, NULL)); auto retval = GNC_COMMODITY(g_object_new(GNC_TYPE_COMMODITY, nullptr));
qof_instance_init_data (&retval->inst, GNC_ID_COMMODITY, book); qof_instance_init_data (&retval->inst, GNC_ID_COMMODITY, book);
gnc_commodity_begin_edit(retval); gnc_commodity_begin_edit(retval);
if ( name_space != NULL ) if ( name_space != nullptr )
{ {
/* Prevent setting anything except template in namespace template. */ /* Prevent setting anything except template in namespace template. */
if (g_strcmp0 (name_space, GNC_COMMODITY_NS_TEMPLATE) == 0 && if (g_strcmp0 (name_space, GNC_COMMODITY_NS_TEMPLATE) == 0 &&
@ -836,7 +836,7 @@ gnc_commodity_new(QofBook *book, const char * fullname,
mark_commodity_dirty (retval); mark_commodity_dirty (retval);
gnc_commodity_commit_edit(retval); gnc_commodity_commit_edit(retval);
qof_event_gen (&retval->inst, QOF_EVENT_CREATE, NULL); qof_event_gen (&retval->inst, QOF_EVENT_CREATE, nullptr);
return retval; return retval;
} }
@ -860,24 +860,24 @@ commodity_free(gnc_commodity * cm)
gnc_commodity_table_remove(table, cm); gnc_commodity_table_remove(table, cm);
priv = GET_PRIVATE(cm); priv = GET_PRIVATE(cm);
qof_event_gen (&cm->inst, QOF_EVENT_DESTROY, NULL); qof_event_gen (&cm->inst, QOF_EVENT_DESTROY, nullptr);
/* Set at creation */ /* Set at creation */
CACHE_REMOVE (priv->fullname); CACHE_REMOVE (priv->fullname);
CACHE_REMOVE (priv->cusip); CACHE_REMOVE (priv->cusip);
CACHE_REMOVE (priv->mnemonic); CACHE_REMOVE (priv->mnemonic);
CACHE_REMOVE (priv->quote_tz); CACHE_REMOVE (priv->quote_tz);
priv->name_space = NULL; priv->name_space = nullptr;
/* Set through accessor functions */ /* Set through accessor functions */
priv->quote_source = NULL; priv->quote_source = nullptr;
/* Automatically generated */ /* Automatically generated */
g_free(priv->printname); g_free(priv->printname);
priv->printname = NULL; priv->printname = nullptr;
g_free(priv->unique_name); g_free(priv->unique_name);
priv->unique_name = NULL; priv->unique_name = nullptr;
#ifdef ACCOUNTS_CLEANED_UP #ifdef ACCOUNTS_CLEANED_UP
/* Account objects are not actually cleaned up when a book is closed (in fact /* Account objects are not actually cleaned up when a book is closed (in fact
@ -926,7 +926,7 @@ gnc_commodity_clone(const gnc_commodity *src, QofBook *dest_book)
gnc_commodityPrivate* src_priv; gnc_commodityPrivate* src_priv;
gnc_commodityPrivate* dest_priv; gnc_commodityPrivate* dest_priv;
auto dest = GNC_COMMODITY (g_object_new(GNC_TYPE_COMMODITY, NULL)); auto dest = GNC_COMMODITY (g_object_new(GNC_TYPE_COMMODITY, nullptr));
qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book); qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book);
src_priv = GET_PRIVATE(src); src_priv = GET_PRIVATE(src);
dest_priv = GET_PRIVATE(dest); dest_priv = GET_PRIVATE(dest);
@ -958,7 +958,7 @@ gnc_commodity_clone(const gnc_commodity *src, QofBook *dest_book)
const char * const char *
gnc_commodity_get_mnemonic(const gnc_commodity * cm) gnc_commodity_get_mnemonic(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->mnemonic; return GET_PRIVATE(cm)->mnemonic;
} }
@ -969,7 +969,7 @@ gnc_commodity_get_mnemonic(const gnc_commodity * cm)
const char * const char *
gnc_commodity_get_printname(const gnc_commodity * cm) gnc_commodity_get_printname(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->printname; return GET_PRIVATE(cm)->printname;
} }
@ -981,14 +981,14 @@ gnc_commodity_get_printname(const gnc_commodity * cm)
const char * const char *
gnc_commodity_get_namespace(const gnc_commodity * cm) gnc_commodity_get_namespace(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return gnc_commodity_namespace_get_name(GET_PRIVATE(cm)->name_space); return gnc_commodity_namespace_get_name(GET_PRIVATE(cm)->name_space);
} }
gnc_commodity_namespace * gnc_commodity_namespace *
gnc_commodity_get_namespace_ds(const gnc_commodity * cm) gnc_commodity_get_namespace_ds(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->name_space; return GET_PRIVATE(cm)->name_space;
} }
@ -999,7 +999,7 @@ gnc_commodity_get_namespace_ds(const gnc_commodity * cm)
const char * const char *
gnc_commodity_get_fullname(const gnc_commodity * cm) gnc_commodity_get_fullname(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->fullname; return GET_PRIVATE(cm)->fullname;
} }
@ -1011,7 +1011,7 @@ gnc_commodity_get_fullname(const gnc_commodity * cm)
const char * const char *
gnc_commodity_get_unique_name(const gnc_commodity * cm) gnc_commodity_get_unique_name(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->unique_name; return GET_PRIVATE(cm)->unique_name;
} }
@ -1023,7 +1023,7 @@ gnc_commodity_get_unique_name(const gnc_commodity * cm)
const char * const char *
gnc_commodity_get_cusip(const gnc_commodity * cm) gnc_commodity_get_cusip(const gnc_commodity * cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->cusip; return GET_PRIVATE(cm)->cusip;
} }
@ -1077,7 +1077,7 @@ gnc_commodity_get_quote_source(const gnc_commodity *cm)
{ {
gnc_commodityPrivate* priv; gnc_commodityPrivate* priv;
if (!cm) return NULL; if (!cm) return nullptr;
priv = GET_PRIVATE(cm); priv = GET_PRIVATE(cm);
if (!priv->quote_source && gnc_commodity_is_iso(cm)) if (!priv->quote_source && gnc_commodity_is_iso(cm))
return &currency_quote_sources[0]; return &currency_quote_sources[0];
@ -1100,7 +1100,7 @@ gnc_commodity_get_default_quote_source(const gnc_commodity *cm)
const char* const char*
gnc_commodity_get_quote_tz(const gnc_commodity *cm) gnc_commodity_get_quote_tz(const gnc_commodity *cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->quote_tz; return GET_PRIVATE(cm)->quote_tz;
} }
@ -1110,11 +1110,11 @@ gnc_commodity_get_quote_tz(const gnc_commodity *cm)
const char* const char*
gnc_commodity_get_user_symbol(const gnc_commodity *cm) gnc_commodity_get_user_symbol(const gnc_commodity *cm)
{ {
g_return_val_if_fail (GNC_IS_COMMODITY (cm), NULL); g_return_val_if_fail (GNC_IS_COMMODITY (cm), nullptr);
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE(cm), &v, 1, "user_symbol"); qof_instance_get_kvp (QOF_INSTANCE(cm), &v, 1, "user_symbol");
const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return rv; return rv;
} }
@ -1125,7 +1125,7 @@ gnc_commodity_get_user_symbol(const gnc_commodity *cm)
const char* const char*
gnc_commodity_get_default_symbol(const gnc_commodity *cm) gnc_commodity_get_default_symbol(const gnc_commodity *cm)
{ {
if (!cm) return NULL; if (!cm) return nullptr;
return GET_PRIVATE(cm)->default_symbol; return GET_PRIVATE(cm)->default_symbol;
} }
@ -1137,7 +1137,7 @@ gnc_commodity_get_nice_symbol (const gnc_commodity *cm)
{ {
const char *nice_symbol; const char *nice_symbol;
struct lconv *lc; struct lconv *lc;
if (!cm) return NULL; if (!cm) return nullptr;
nice_symbol = gnc_commodity_get_user_symbol(cm); nice_symbol = gnc_commodity_get_user_symbol(cm);
if (nice_symbol && *nice_symbol) if (nice_symbol && *nice_symbol)
@ -1284,7 +1284,7 @@ gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm,
} }
gnc_commodity_begin_edit(cm); gnc_commodity_begin_edit(cm);
if (flag) if (flag)
qof_instance_set_kvp (QOF_INSTANCE (cm), NULL, 1, "auto_quote_control"); qof_instance_set_kvp (QOF_INSTANCE (cm), nullptr, 1, "auto_quote_control");
else else
{ {
g_value_init (&v, G_TYPE_STRING); g_value_init (&v, G_TYPE_STRING);
@ -1411,14 +1411,14 @@ gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol)
lc = gnc_localeconv(); lc = gnc_localeconv();
if (!user_symbol || !*user_symbol) if (!user_symbol || !*user_symbol)
user_symbol = NULL; user_symbol = nullptr;
else if (!g_strcmp0(lc->int_curr_symbol, gnc_commodity_get_mnemonic(cm)) && else if (!g_strcmp0(lc->int_curr_symbol, gnc_commodity_get_mnemonic(cm)) &&
!g_strcmp0(lc->currency_symbol, user_symbol)) !g_strcmp0(lc->currency_symbol, user_symbol))
/* if the user gives the ISO symbol for the locale currency or the /* if the user gives the ISO symbol for the locale currency or the
* default symbol, actually remove the user symbol */ * default symbol, actually remove the user symbol */
user_symbol = NULL; user_symbol = nullptr;
else if (!g_strcmp0(user_symbol, gnc_commodity_get_default_symbol(cm))) else if (!g_strcmp0(user_symbol, gnc_commodity_get_default_symbol(cm)))
user_symbol = NULL; user_symbol = nullptr;
gnc_commodity_begin_edit (cm); gnc_commodity_begin_edit (cm);
@ -1432,7 +1432,7 @@ gnc_commodity_set_user_symbol(gnc_commodity * cm, const char * user_symbol)
} }
else else
{ {
qof_instance_set_kvp (QOF_INSTANCE(cm), NULL, 1, "user_symbol"); qof_instance_set_kvp (QOF_INSTANCE(cm), nullptr, 1, "user_symbol");
} }
mark_commodity_dirty(cm); mark_commodity_dirty(cm);
@ -1581,16 +1581,16 @@ int gnc_commodity_compare_void(const void * a, const void * b)
const char * const char *
gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns) gnc_commodity_namespace_get_name (const gnc_commodity_namespace *ns)
{ {
if (ns == NULL) if (ns == nullptr)
return NULL; return nullptr;
return ns->name; return ns->name;
} }
const char * const char *
gnc_commodity_namespace_get_gui_name (const gnc_commodity_namespace *ns) gnc_commodity_namespace_get_gui_name (const gnc_commodity_namespace *ns)
{ {
if (ns == NULL) if (ns == nullptr)
return NULL; return nullptr;
if (g_strcmp0 (ns->name, GNC_COMMODITY_NS_CURRENCY) == 0) if (g_strcmp0 (ns->name, GNC_COMMODITY_NS_CURRENCY) == 0)
return GNC_COMMODITY_NS_ISO_GUI; return GNC_COMMODITY_NS_ISO_GUI;
return ns->name; return ns->name;
@ -1600,7 +1600,7 @@ GList *
gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space) gnc_commodity_namespace_get_commodity_list(const gnc_commodity_namespace *name_space)
{ {
if (!name_space) if (!name_space)
return NULL; return nullptr;
return name_space->cm_list; return name_space->cm_list;
} }
@ -1630,7 +1630,7 @@ gnc_commodity_table_new(void)
{ {
gnc_commodity_table * retval = g_new0(gnc_commodity_table, 1); gnc_commodity_table * retval = g_new0(gnc_commodity_table, 1);
retval->ns_table = g_hash_table_new(&g_str_hash, &g_str_equal); retval->ns_table = g_hash_table_new(&g_str_hash, &g_str_equal);
retval->ns_list = NULL; retval->ns_list = nullptr;
return retval; return retval;
} }
@ -1641,7 +1641,7 @@ gnc_commodity_table_new(void)
gnc_commodity_table * gnc_commodity_table *
gnc_commodity_table_get_table(QofBook *book) gnc_commodity_table_get_table(QofBook *book)
{ {
if (!book) return NULL; if (!book) return nullptr;
return static_cast<gnc_commodity_table*>(qof_book_get_data (book, GNC_COMMODITY_TABLE)); return static_cast<gnc_commodity_table*>(qof_book_get_data (book, GNC_COMMODITY_TABLE));
} }
@ -1652,9 +1652,9 @@ gnc_commodity_obtain_twin (const gnc_commodity *from, QofBook *book)
const char * ucom; const char * ucom;
gnc_commodity_table * comtbl; gnc_commodity_table * comtbl;
if (!from) return NULL; if (!from) return nullptr;
comtbl = gnc_commodity_table_get_table (book); comtbl = gnc_commodity_table_get_table (book);
if (!comtbl) return NULL; if (!comtbl) return nullptr;
ucom = gnc_commodity_get_unique_name (from); ucom = gnc_commodity_get_unique_name (from);
twin = gnc_commodity_table_lookup_unique (comtbl, ucom); twin = gnc_commodity_table_lookup_unique (comtbl, ucom);
@ -1709,9 +1709,9 @@ gnc_commodity *
gnc_commodity_table_lookup(const gnc_commodity_table * table, gnc_commodity_table_lookup(const gnc_commodity_table * table,
const char * name_space, const char * mnemonic) const char * name_space, const char * mnemonic)
{ {
gnc_commodity_namespace * nsp = NULL; gnc_commodity_namespace * nsp = nullptr;
if (!table || !name_space || !mnemonic) return NULL; if (!table || !name_space || !mnemonic) return nullptr;
nsp = gnc_commodity_table_find_namespace(table, name_space); nsp = gnc_commodity_table_find_namespace(table, name_space);
@ -1731,7 +1731,7 @@ gnc_commodity_table_lookup(const gnc_commodity_table * table,
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -1748,14 +1748,14 @@ gnc_commodity_table_lookup_unique(const gnc_commodity_table *table,
char *mnemonic; char *mnemonic;
gnc_commodity *commodity; gnc_commodity *commodity;
if (!table || !unique_name) return NULL; if (!table || !unique_name) return nullptr;
name_space = g_strdup (unique_name); name_space = g_strdup (unique_name);
mnemonic = strstr (name_space, "::"); mnemonic = strstr (name_space, "::");
if (!mnemonic) if (!mnemonic)
{ {
g_free (name_space); g_free (name_space);
return NULL; return nullptr;
} }
*mnemonic = '\0'; *mnemonic = '\0';
@ -1778,12 +1778,12 @@ gnc_commodity_table_find_full(const gnc_commodity_table * table,
const char * name_space, const char * name_space,
const char * fullname) const char * fullname)
{ {
gnc_commodity * retval = NULL; gnc_commodity * retval = nullptr;
GList * all; GList * all;
GList * iterator; GList * iterator;
if (!fullname || (fullname[0] == '\0')) if (!fullname || (fullname[0] == '\0'))
return NULL; return nullptr;
all = gnc_commodity_table_get_commodities(table, name_space); all = gnc_commodity_table_get_commodities(table, name_space);
@ -1813,20 +1813,20 @@ gnc_commodity *
gnc_commodity_table_insert(gnc_commodity_table * table, gnc_commodity_table_insert(gnc_commodity_table * table,
gnc_commodity * comm) gnc_commodity * comm)
{ {
gnc_commodity_namespace * nsp = NULL; gnc_commodity_namespace * nsp = nullptr;
gnc_commodity *c; gnc_commodity *c;
const char *ns_name; const char *ns_name;
gnc_commodityPrivate* priv; gnc_commodityPrivate* priv;
QofBook *book; QofBook *book;
if (!table) return NULL; if (!table) return nullptr;
if (!comm) return NULL; if (!comm) return nullptr;
priv = GET_PRIVATE(comm); priv = GET_PRIVATE(comm);
ENTER ("(table=%p, comm=%p) %s %s", table, comm, ENTER ("(table=%p, comm=%p) %s %s", table, comm,
(priv->mnemonic == NULL ? "(null)" : priv->mnemonic), (priv->mnemonic == nullptr ? "(null)" : priv->mnemonic),
(priv->fullname == NULL ? "(null)" : priv->fullname)); (priv->fullname == nullptr ? "(null)" : priv->fullname));
ns_name = gnc_commodity_namespace_get_name(priv->name_space); ns_name = gnc_commodity_namespace_get_name(priv->name_space);
c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic); c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic);
@ -1873,7 +1873,7 @@ gnc_commodity_table_insert(gnc_commodity_table * table,
(gpointer)comm); (gpointer)comm);
nsp->cm_list = g_list_append(nsp->cm_list, comm); nsp->cm_list = g_list_append(nsp->cm_list, comm);
qof_event_gen (&comm->inst, QOF_EVENT_ADD, NULL); qof_event_gen (&comm->inst, QOF_EVENT_ADD, nullptr);
LEAVE ("(table=%p, comm=%p)", table, comm); LEAVE ("(table=%p, comm=%p)", table, comm);
return comm; return comm;
} }
@ -1900,7 +1900,7 @@ gnc_commodity_table_remove(gnc_commodity_table * table,
c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic); c = gnc_commodity_table_lookup (table, ns_name, priv->mnemonic);
if (c != comm) return; if (c != comm) return;
qof_event_gen (&comm->inst, QOF_EVENT_REMOVE, NULL); qof_event_gen (&comm->inst, QOF_EVENT_REMOVE, nullptr);
nsp = gnc_commodity_table_find_namespace(table, ns_name); nsp = gnc_commodity_table_find_namespace(table, ns_name);
if (!nsp) return; if (!nsp) return;
@ -1919,7 +1919,7 @@ int
gnc_commodity_table_has_namespace(const gnc_commodity_table * table, gnc_commodity_table_has_namespace(const gnc_commodity_table * table,
const char * name_space) const char * name_space)
{ {
gnc_commodity_namespace * nsp = NULL; gnc_commodity_namespace * nsp = nullptr;
if (!table || !name_space) if (!table || !name_space)
{ {
@ -1947,7 +1947,7 @@ hash_keys_helper(gpointer key, gpointer value, gpointer data)
static GList * static GList *
g_hash_table_keys(GHashTable * table) g_hash_table_keys(GHashTable * table)
{ {
GList * l = NULL; GList * l = nullptr;
g_hash_table_foreach(table, &hash_keys_helper, (gpointer) &l); g_hash_table_foreach(table, &hash_keys_helper, (gpointer) &l);
return l; return l;
} }
@ -1962,7 +1962,7 @@ hash_values_helper(gpointer key, gpointer value, gpointer data)
static GList * static GList *
g_hash_table_values(GHashTable * table) g_hash_table_values(GHashTable * table)
{ {
GList * l = NULL; GList * l = nullptr;
g_hash_table_foreach(table, &hash_values_helper, (gpointer) &l); g_hash_table_foreach(table, &hash_values_helper, (gpointer) &l);
return l; return l;
} }
@ -1976,7 +1976,7 @@ GList *
gnc_commodity_table_get_namespaces(const gnc_commodity_table * table) gnc_commodity_table_get_namespaces(const gnc_commodity_table * table)
{ {
if (!table) if (!table)
return NULL; return nullptr;
return g_hash_table_keys(table->ns_table); return g_hash_table_keys(table->ns_table);
} }
@ -1985,7 +1985,7 @@ GList *
gnc_commodity_table_get_namespaces_list(const gnc_commodity_table * table) gnc_commodity_table_get_namespaces_list(const gnc_commodity_table * table)
{ {
if (!table) if (!table)
return NULL; return nullptr;
return table->ns_list; return table->ns_list;
} }
@ -2027,11 +2027,11 @@ gnc_commodity_is_currency(const gnc_commodity *cm)
static CommodityList* static CommodityList*
commodity_table_get_all_noncurrency_commodities(const gnc_commodity_table* table) commodity_table_get_all_noncurrency_commodities(const gnc_commodity_table* table)
{ {
GList *node = NULL, *nslist = gnc_commodity_table_get_namespaces(table); GList *node = nullptr, *nslist = gnc_commodity_table_get_namespaces(table);
CommodityList *retval = NULL; CommodityList *retval = nullptr;
for (node = nslist; node; node=g_list_next(node)) for (node = nslist; node; node=g_list_next(node))
{ {
gnc_commodity_namespace *ns = NULL; gnc_commodity_namespace *ns = nullptr;
if (g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_CURRENCY) == 0 if (g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_CURRENCY) == 0
|| g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_TEMPLATE) == 0) || g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_TEMPLATE) == 0)
continue; continue;
@ -2048,15 +2048,15 @@ CommodityList *
gnc_commodity_table_get_commodities(const gnc_commodity_table * table, gnc_commodity_table_get_commodities(const gnc_commodity_table * table,
const char * name_space) const char * name_space)
{ {
gnc_commodity_namespace * ns = NULL; gnc_commodity_namespace * ns = nullptr;
if (!table) if (!table)
return NULL; return nullptr;
if (g_strcmp0(name_space, GNC_COMMODITY_NS_NONISO_GUI) == 0) if (g_strcmp0(name_space, GNC_COMMODITY_NS_NONISO_GUI) == 0)
return commodity_table_get_all_noncurrency_commodities(table); return commodity_table_get_all_noncurrency_commodities(table);
ns = gnc_commodity_table_find_namespace(table, name_space); ns = gnc_commodity_table_find_namespace(table, name_space);
if (!ns) if (!ns)
return NULL; return nullptr;
return g_hash_table_values(ns->cm_table); return g_hash_table_values(ns->cm_table);
} }
@ -2093,30 +2093,30 @@ get_quotables_helper2 (gnc_commodity *comm, gpointer data)
CommodityList * CommodityList *
gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table) gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table)
{ {
gnc_commodity_namespace * ns = NULL; gnc_commodity_namespace * ns = nullptr;
const char *name_space; const char *name_space;
GList * nslist, * tmp; GList * nslist, * tmp;
GList * l = NULL; GList * l = nullptr;
regex_t pattern; regex_t pattern;
const char *expression = gnc_prefs_get_namespace_regexp(); const char *expression = gnc_prefs_get_namespace_regexp();
ENTER("table=%p, expression=%s", table, expression); ENTER("table=%p, expression=%s", table, expression);
if (!table) if (!table)
return NULL; return nullptr;
if (expression && *expression) if (expression && *expression)
{ {
if (regcomp(&pattern, expression, REG_EXTENDED | REG_ICASE) != 0) if (regcomp(&pattern, expression, REG_EXTENDED | REG_ICASE) != 0)
{ {
LEAVE("Cannot compile regex"); LEAVE("Cannot compile regex");
return NULL; return nullptr;
} }
nslist = gnc_commodity_table_get_namespaces(table); nslist = gnc_commodity_table_get_namespaces(table);
for (tmp = nslist; tmp; tmp = tmp->next) for (tmp = nslist; tmp; tmp = tmp->next)
{ {
name_space = static_cast<const char*>(tmp->data); name_space = static_cast<const char*>(tmp->data);
if (regexec(&pattern, name_space, 0, NULL, 0) == 0) if (regexec(&pattern, name_space, 0, nullptr, 0) == 0)
{ {
DEBUG("Running list of %s commodities", name_space); DEBUG("Running list of %s commodities", name_space);
ns = gnc_commodity_table_find_namespace(table, name_space); ns = gnc_commodity_table_find_namespace(table, name_space);
@ -2166,26 +2166,26 @@ gnc_commodity_table_add_namespace(gnc_commodity_table * table,
const char * name_space, const char * name_space,
QofBook *book) QofBook *book)
{ {
gnc_commodity_namespace * ns = NULL; gnc_commodity_namespace * ns = nullptr;
if (!table) return NULL; if (!table) return nullptr;
name_space = gnc_commodity_table_map_namespace(name_space); name_space = gnc_commodity_table_map_namespace(name_space);
ns = gnc_commodity_table_find_namespace(table, name_space); ns = gnc_commodity_table_find_namespace(table, name_space);
if (!ns) if (!ns)
{ {
ns = static_cast<gnc_commodity_namespace*>(g_object_new(GNC_TYPE_COMMODITY_NAMESPACE, NULL)); ns = static_cast<gnc_commodity_namespace*>(g_object_new(GNC_TYPE_COMMODITY_NAMESPACE, nullptr));
ns->cm_table = g_hash_table_new(g_str_hash, g_str_equal); ns->cm_table = g_hash_table_new(g_str_hash, g_str_equal);
ns->name = CACHE_INSERT(static_cast<const char*>(name_space)); ns->name = CACHE_INSERT(static_cast<const char*>(name_space));
ns->iso4217 = gnc_commodity_namespace_is_iso(name_space); ns->iso4217 = gnc_commodity_namespace_is_iso(name_space);
qof_instance_init_data (&ns->inst, GNC_ID_COMMODITY_NAMESPACE, book); qof_instance_init_data (&ns->inst, GNC_ID_COMMODITY_NAMESPACE, book);
qof_event_gen (&ns->inst, QOF_EVENT_CREATE, NULL); qof_event_gen (&ns->inst, QOF_EVENT_CREATE, nullptr);
g_hash_table_insert(table->ns_table, g_hash_table_insert(table->ns_table,
(gpointer) ns->name, (gpointer) ns->name,
(gpointer) ns); (gpointer) ns);
table->ns_list = g_list_append(table->ns_list, ns); table->ns_list = g_list_append(table->ns_list, ns);
qof_event_gen (&ns->inst, QOF_EVENT_ADD, NULL); qof_event_gen (&ns->inst, QOF_EVENT_ADD, nullptr);
} }
return ns; return ns;
} }
@ -2196,7 +2196,7 @@ gnc_commodity_table_find_namespace(const gnc_commodity_table * table,
const char * name_space) const char * name_space)
{ {
if (!table || !name_space) if (!table || !name_space)
return NULL; return nullptr;
name_space = gnc_commodity_table_map_namespace(name_space); name_space = gnc_commodity_table_map_namespace(name_space);
return static_cast<gnc_commodity_namespace*>(g_hash_table_lookup(table->ns_table, (gpointer)name_space)); return static_cast<gnc_commodity_namespace*>(g_hash_table_lookup(table->ns_table, (gpointer)name_space));
@ -2207,7 +2207,7 @@ gnc_commodity *
gnc_commodity_find_commodity_by_guid(const GncGUID *guid, QofBook *book) gnc_commodity_find_commodity_by_guid(const GncGUID *guid, QofBook *book)
{ {
QofCollection *col; QofCollection *col;
if (!guid || !book) return NULL; if (!guid || !book) return nullptr;
col = qof_book_get_collection (book, GNC_ID_COMMODITY); col = qof_book_get_collection (book, GNC_ID_COMMODITY);
return (gnc_commodity *) qof_collection_lookup_entity (col, guid); return (gnc_commodity *) qof_collection_lookup_entity (col, guid);
} }
@ -2238,18 +2238,18 @@ gnc_commodity_table_delete_namespace(gnc_commodity_table * table,
if (!ns) if (!ns)
return; return;
qof_event_gen (&ns->inst, QOF_EVENT_REMOVE, NULL); qof_event_gen (&ns->inst, QOF_EVENT_REMOVE, nullptr);
g_hash_table_remove(table->ns_table, name_space); g_hash_table_remove(table->ns_table, name_space);
table->ns_list = g_list_remove(table->ns_list, ns); table->ns_list = g_list_remove(table->ns_list, ns);
g_list_free(ns->cm_list); g_list_free(ns->cm_list);
ns->cm_list = NULL; ns->cm_list = nullptr;
g_hash_table_foreach_remove(ns->cm_table, ns_helper, NULL); g_hash_table_foreach_remove(ns->cm_table, ns_helper, nullptr);
g_hash_table_destroy(ns->cm_table); g_hash_table_destroy(ns->cm_table);
CACHE_REMOVE(ns->name); CACHE_REMOVE(ns->name);
qof_event_gen (&ns->inst, QOF_EVENT_DESTROY, NULL); qof_event_gen (&ns->inst, QOF_EVENT_DESTROY, nullptr);
/* qof_instance_release(&ns->inst); */ /* qof_instance_release(&ns->inst); */
g_object_unref(ns); g_object_unref(ns);
} }
@ -2326,9 +2326,9 @@ gnc_commodity_table_destroy(gnc_commodity_table * t)
} }
g_list_free(t->ns_list); g_list_free(t->ns_list);
t->ns_list = NULL; t->ns_list = nullptr;
g_hash_table_destroy(t->ns_table); g_hash_table_destroy(t->ns_table);
t->ns_table = NULL; t->ns_table = nullptr;
LEAVE ("table=%p", t); LEAVE ("table=%p", t);
g_free(t); g_free(t);
} }
@ -2382,9 +2382,9 @@ static QofObject commodity_object_def =
DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_COMMODITY, DI(.e_type = ) GNC_ID_COMMODITY,
DI(.type_label = ) "Commodity", DI(.type_label = ) "Commodity",
DI(.create = ) NULL, DI(.create = ) nullptr,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) NULL, DI(.book_end = ) nullptr,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) qof_collection_foreach, DI(.foreach = ) qof_collection_foreach,
@ -2396,13 +2396,13 @@ static QofObject namespace_object_def =
DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_COMMODITY_NAMESPACE, DI(.e_type = ) GNC_ID_COMMODITY_NAMESPACE,
DI(.type_label = ) "Namespace", DI(.type_label = ) "Namespace",
DI(.create = ) NULL, DI(.create = ) nullptr,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) NULL, DI(.book_end = ) nullptr,
DI(.is_dirty = ) NULL, DI(.is_dirty = ) nullptr,
DI(.mark_clean = ) NULL, DI(.mark_clean = ) nullptr,
DI(.foreach = ) NULL, DI(.foreach = ) nullptr,
DI(.printable = ) NULL, DI(.printable = ) nullptr,
}; };
static void static void
@ -2431,7 +2431,7 @@ commodity_table_book_end (QofBook *book)
gnc_commodity_table *ct; gnc_commodity_table *ct;
ct = gnc_commodity_table_get_table (book); ct = gnc_commodity_table_get_table (book);
qof_book_set_data (book, GNC_COMMODITY_TABLE, NULL); qof_book_set_data (book, GNC_COMMODITY_TABLE, nullptr);
gnc_commodity_table_destroy (ct); gnc_commodity_table_destroy (ct);
} }
@ -2440,14 +2440,14 @@ static QofObject commodity_table_object_def =
DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_COMMODITY_TABLE, DI(.e_type = ) GNC_ID_COMMODITY_TABLE,
DI(.type_label = ) "CommodityTable", DI(.type_label = ) "CommodityTable",
DI(.create = ) NULL, DI(.create = ) nullptr,
DI(.book_begin = ) commodity_table_book_begin, DI(.book_begin = ) commodity_table_book_begin,
DI(.book_end = ) commodity_table_book_end, DI(.book_end = ) commodity_table_book_end,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) NULL, DI(.foreach = ) nullptr,
DI(.printable = ) NULL, DI(.printable = ) nullptr,
DI(.version_cmp = ) NULL, DI(.version_cmp = ) nullptr,
}; };
gboolean gboolean
@ -2481,7 +2481,7 @@ gnc_monetary_list_add_monetary(MonetaryList *list, gnc_monetary add_mon)
} }
/* See if we found an entry, and add one if not */ /* See if we found an entry, and add one if not */
if (tmp == NULL) if (tmp == nullptr)
{ {
auto new_mon = static_cast<gnc_monetary*>(g_new0(gnc_monetary, 1)); auto new_mon = static_cast<gnc_monetary*>(g_new0(gnc_monetary, 1));
*new_mon = add_mon; *new_mon = add_mon;

View File

@ -102,10 +102,10 @@ struct tm*
gnc_localtime (const time64 *secs) gnc_localtime (const time64 *secs)
{ {
auto time = static_cast<struct tm*>(calloc(1, sizeof(struct tm))); auto time = static_cast<struct tm*>(calloc(1, sizeof(struct tm)));
if (gnc_localtime_r (secs, time) == NULL) if (gnc_localtime_r (secs, time) == nullptr)
{ {
gnc_tm_free (time); gnc_tm_free (time);
return NULL; return nullptr;
} }
return time; return time;
} }
@ -120,7 +120,7 @@ gnc_localtime_r (const time64 *secs, struct tm* time)
} }
catch(std::invalid_argument&) catch(std::invalid_argument&)
{ {
return NULL; return nullptr;
} }
} }
@ -185,7 +185,7 @@ gnc_gmtime (const time64 *secs)
} }
catch(std::invalid_argument&) catch(std::invalid_argument&)
{ {
return NULL; return nullptr;
} }
} }
@ -262,7 +262,7 @@ gnc_time (time64 *tbuf)
{ {
GncDateTime gncdt; GncDateTime gncdt;
auto time = static_cast<time64>(gncdt); auto time = static_cast<time64>(gncdt);
if (tbuf != NULL) if (tbuf != nullptr)
*tbuf = time; *tbuf = time;
return time; return time;
} }
@ -297,7 +297,7 @@ gnc_date_dateformat_to_string(QofDateFormat format)
case QOF_DATE_FORMAT_UNSET: case QOF_DATE_FORMAT_UNSET:
return "unset"; return "unset";
default: default:
return NULL; return nullptr;
} }
} }
@ -342,7 +342,7 @@ gnc_date_monthformat_to_string(GNCDateMonthFormat format)
case GNCDATE_MONTH_NAME: case GNCDATE_MONTH_NAME:
return "name"; return "name";
default: default:
return NULL; return nullptr;
} }
} }
@ -702,9 +702,9 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year,
dupe = g_strdup (buff); dupe = g_strdup (buff);
tmp = dupe; tmp = dupe;
first_field = NULL; first_field = nullptr;
second_field = NULL; second_field = nullptr;
third_field = NULL; third_field = nullptr;
/* Use strtok to find delimiters */ /* Use strtok to find delimiters */
if (tmp) if (tmp)
@ -714,10 +714,10 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year,
first_field = strtok (tmp, delims); first_field = strtok (tmp, delims);
if (first_field) if (first_field)
{ {
second_field = strtok (NULL, delims); second_field = strtok (nullptr, delims);
if (second_field) if (second_field)
{ {
third_field = strtok (NULL, delims); third_field = strtok (nullptr, delims);
} }
} }
} }
@ -948,7 +948,7 @@ char dateSeparator (void)
time64 secs; time64 secs;
gchar *s; gchar *s;
secs = gnc_time (NULL); secs = gnc_time (nullptr);
gnc_localtime_r(&secs, &tm); gnc_localtime_r(&secs, &tm);
auto normalized_fmt = auto normalized_fmt =
normalize_format(qof_date_format_get_string(dateFormat)); normalize_format(qof_date_format_get_string(dateFormat));
@ -969,9 +969,9 @@ gchar *
qof_time_format_from_utf8(const gchar *utf8_format) qof_time_format_from_utf8(const gchar *utf8_format)
{ {
gchar *retval; gchar *retval;
GError *error = NULL; GError *error = nullptr;
retval = g_locale_from_utf8(utf8_format, -1, NULL, NULL, &error); retval = g_locale_from_utf8(utf8_format, -1, nullptr, nullptr, &error);
if (!retval) if (!retval)
{ {
@ -986,9 +986,9 @@ gchar *
qof_formatted_time_to_utf8(const gchar *locale_string) qof_formatted_time_to_utf8(const gchar *locale_string)
{ {
gchar *retval; gchar *retval;
GError *error = NULL; GError *error = nullptr;
retval = g_locale_to_utf8(locale_string, -1, NULL, NULL, &error); retval = g_locale_to_utf8(locale_string, -1, nullptr, nullptr, &error);
if (!retval) if (!retval)
{ {
@ -1011,7 +1011,7 @@ qof_format_time(const gchar *format, const struct tm *tm)
locale_format = qof_time_format_from_utf8(format); locale_format = qof_time_format_from_utf8(format);
if (!locale_format) if (!locale_format)
return NULL; return nullptr;
tmpbufsize = MAX(128, strlen(locale_format) * 2); tmpbufsize = MAX(128, strlen(locale_format) * 2);
while (TRUE) while (TRUE)
@ -1035,7 +1035,7 @@ qof_format_time(const gchar *format, const struct tm *tm)
"exceeded: giving up"); "exceeded: giving up");
g_free(locale_format); g_free(locale_format);
return NULL; return nullptr;
} }
} }
else else
@ -1075,7 +1075,7 @@ qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm)
{ {
/* Ensure only whole characters are copied into the buffer. */ /* Ensure only whole characters are copied into the buffer. */
gchar *end = g_utf8_find_prev_char(convbuf, convbuf + max); gchar *end = g_utf8_find_prev_char(convbuf, convbuf + max);
g_assert(end != NULL); g_assert(end != nullptr);
convlen = end - convbuf; convlen = end - convbuf;
/* Return 0 because the buffer isn't large enough. */ /* Return 0 because the buffer isn't large enough. */
@ -1138,7 +1138,7 @@ gnc_iso8601_to_time64_gmt(const char *cstr)
char * char *
gnc_time64_to_iso8601_buff (time64 time, char * buff) gnc_time64_to_iso8601_buff (time64 time, char * buff)
{ {
if (! buff) return NULL; if (!buff) return nullptr;
try try
{ {
GncDateTime gncdt(time); GncDateTime gncdt(time);

View File

@ -115,9 +115,9 @@ gnc_lot_init(GNCLot* lot)
GNCLotPrivate* priv; GNCLotPrivate* priv;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
priv->account = NULL; priv->account = nullptr;
priv->splits = NULL; priv->splits = nullptr;
priv->cached_invoice = NULL; priv->cached_invoice = nullptr;
priv->is_closed = LOT_CLOSED_UNKNOWN; priv->is_closed = LOT_CLOSED_UNKNOWN;
priv->marker = 0; priv->marker = 0;
} }
@ -267,11 +267,11 @@ GNCLot *
gnc_lot_new (QofBook *book) gnc_lot_new (QofBook *book)
{ {
GNCLot *lot; GNCLot *lot;
g_return_val_if_fail (book, NULL); g_return_val_if_fail (book, nullptr);
lot = GNC_LOT(g_object_new (GNC_TYPE_LOT, NULL)); lot = GNC_LOT(g_object_new (GNC_TYPE_LOT, nullptr));
qof_instance_init_data(QOF_INSTANCE(lot), GNC_ID_LOT, book); qof_instance_init_data(QOF_INSTANCE(lot), GNC_ID_LOT, book);
qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_CREATE, NULL); qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_CREATE, nullptr);
return lot; return lot;
} }
@ -283,20 +283,20 @@ gnc_lot_free(GNCLot* lot)
if (!lot) return; if (!lot) return;
ENTER ("(lot=%p)", lot); ENTER ("(lot=%p)", lot);
qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_DESTROY, NULL); qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_DESTROY, nullptr);
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
for (node = priv->splits; node; node = node->next) for (node = priv->splits; node; node = node->next)
{ {
Split *s = GNC_SPLIT(node->data); Split *s = GNC_SPLIT(node->data);
s->lot = NULL; s->lot = nullptr;
} }
g_list_free (priv->splits); g_list_free (priv->splits);
if (priv->account && !qof_instance_get_destroying(priv->account)) if (priv->account && !qof_instance_get_destroying(priv->account))
xaccAccountRemoveLot (priv->account, lot); xaccAccountRemoveLot (priv->account, lot);
priv->account = NULL; priv->account = nullptr;
priv->is_closed = TRUE; priv->is_closed = TRUE;
/* qof_instance_release (&lot->inst); */ /* qof_instance_release (&lot->inst); */
g_object_unref (lot); g_object_unref (lot);
@ -350,7 +350,7 @@ GNCLot *
gnc_lot_lookup (const GncGUID *guid, QofBook *book) gnc_lot_lookup (const GncGUID *guid, QofBook *book)
{ {
QofCollection *col; QofCollection *col;
if (!guid || !book) return NULL; if (!guid || !book) return nullptr;
col = qof_book_get_collection (book, GNC_ID_LOT); col = qof_book_get_collection (book, GNC_ID_LOT);
return (GNCLot *) qof_collection_lookup_entity (col, guid); return (GNCLot *) qof_collection_lookup_entity (col, guid);
} }
@ -377,14 +377,14 @@ Account *
gnc_lot_get_account (const GNCLot *lot) gnc_lot_get_account (const GNCLot *lot)
{ {
GNCLotPrivate* priv; GNCLotPrivate* priv;
if (!lot) return NULL; if (!lot) return nullptr;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
return priv->account; return priv->account;
} }
GncInvoice * gnc_lot_get_cached_invoice (const GNCLot *lot) GncInvoice * gnc_lot_get_cached_invoice (const GNCLot *lot)
{ {
if (!lot) return NULL; if (!lot) return nullptr;
else else
{ {
GNCLotPrivate *priv = GET_PRIVATE(lot); GNCLotPrivate *priv = GET_PRIVATE(lot);
@ -402,7 +402,7 @@ gnc_lot_set_cached_invoice(GNCLot* lot, GncInvoice *invoice)
void void
gnc_lot_set_account(GNCLot* lot, Account* account) gnc_lot_set_account(GNCLot* lot, Account* account)
{ {
if (lot != NULL) if (lot != nullptr)
{ {
GNCLotPrivate* priv; GNCLotPrivate* priv;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
@ -414,7 +414,7 @@ void
gnc_lot_set_closed_unknown(GNCLot* lot) gnc_lot_set_closed_unknown(GNCLot* lot)
{ {
GNCLotPrivate* priv; GNCLotPrivate* priv;
if (lot != NULL) if (lot != nullptr)
{ {
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
priv->is_closed = LOT_CLOSED_UNKNOWN; priv->is_closed = LOT_CLOSED_UNKNOWN;
@ -425,7 +425,7 @@ SplitList *
gnc_lot_get_split_list (const GNCLot *lot) gnc_lot_get_split_list (const GNCLot *lot)
{ {
GNCLotPrivate* priv; GNCLotPrivate* priv;
if (!lot) return NULL; if (!lot) return nullptr;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
return priv->splits; return priv->splits;
} }
@ -444,11 +444,11 @@ gint gnc_lot_count_splits (const GNCLot *lot)
const char * const char *
gnc_lot_get_title (const GNCLot *lot) gnc_lot_get_title (const GNCLot *lot)
{ {
if (!lot) return NULL; if (!lot) return nullptr;
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "title"); qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "title");
const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return rv; return rv;
@ -457,11 +457,11 @@ gnc_lot_get_title (const GNCLot *lot)
const char * const char *
gnc_lot_get_notes (const GNCLot *lot) gnc_lot_get_notes (const GNCLot *lot)
{ {
if (!lot) return NULL; if (!lot) return nullptr;
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "notes"); qof_instance_get_kvp (QOF_INSTANCE (lot), &v, 1, "notes");
const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : NULL; const char *rv = G_VALUE_HOLDS_STRING (&v) ? g_value_get_string (&v) : nullptr;
g_value_unset (&v); g_value_unset (&v);
return rv; return rv;
} }
@ -552,7 +552,7 @@ gnc_lot_get_balance_before (const GNCLot *lot, const Split *split,
*amount = amt; *amount = amt;
*value = val; *value = val;
if (lot == NULL) return; if (lot == nullptr) return;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
if (priv->splits) if (priv->splits)
@ -563,14 +563,14 @@ gnc_lot_get_balance_before (const GNCLot *lot, const Split *split,
its transaction for the comparison. Gains splits are in separate its transaction for the comparison. Gains splits are in separate
transactions that may sort after non-gains transactions. */ transactions that may sort after non-gains transactions. */
target = xaccSplitGetGainsSourceSplit (split); target = xaccSplitGetGainsSourceSplit (split);
if (target == NULL) if (target == nullptr)
target = split; target = split;
tb = xaccSplitGetParent (target); tb = xaccSplitGetParent (target);
for (node = priv->splits; node; node = node->next) for (node = priv->splits; node; node = node->next)
{ {
Split *s = GNC_SPLIT(node->data); Split *s = GNC_SPLIT(node->data);
Split *source = xaccSplitGetGainsSourceSplit (s); Split *source = xaccSplitGetGainsSourceSplit (s);
if (source == NULL) if (source == nullptr)
source = s; source = s;
ta = xaccSplitGetParent (source); ta = xaccSplitGetParent (source);
if ((ta == tb && source != target) || if ((ta == tb && source != target) ||
@ -605,7 +605,7 @@ gnc_lot_add_split (GNCLot *lot, Split *split)
gnc_lot_begin_edit(lot); gnc_lot_begin_edit(lot);
acc = xaccSplitGetAccount (split); acc = xaccSplitGetAccount (split);
qof_instance_set_dirty(QOF_INSTANCE(lot)); qof_instance_set_dirty(QOF_INSTANCE(lot));
if (NULL == priv->account) if (nullptr == priv->account)
{ {
xaccAccountInsertLot (acc, lot); xaccAccountInsertLot (acc, lot);
} }
@ -638,7 +638,7 @@ gnc_lot_add_split (GNCLot *lot, Split *split)
priv->is_closed = LOT_CLOSED_UNKNOWN; priv->is_closed = LOT_CLOSED_UNKNOWN;
gnc_lot_commit_edit(lot); gnc_lot_commit_edit(lot);
qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, NULL); qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, nullptr);
LEAVE("added to lot"); LEAVE("added to lot");
} }
@ -653,16 +653,16 @@ gnc_lot_remove_split (GNCLot *lot, Split *split)
gnc_lot_begin_edit(lot); gnc_lot_begin_edit(lot);
qof_instance_set_dirty(QOF_INSTANCE(lot)); qof_instance_set_dirty(QOF_INSTANCE(lot));
priv->splits = g_list_remove (priv->splits, split); priv->splits = g_list_remove (priv->splits, split);
xaccSplitSetLot(split, NULL); xaccSplitSetLot(split, nullptr);
priv->is_closed = LOT_CLOSED_UNKNOWN; /* force an is-closed computation */ priv->is_closed = LOT_CLOSED_UNKNOWN; /* force an is-closed computation */
if (!priv->splits && priv->account) if (!priv->splits && priv->account)
{ {
xaccAccountRemoveLot (priv->account, lot); xaccAccountRemoveLot (priv->account, lot);
priv->account = NULL; priv->account = nullptr;
} }
gnc_lot_commit_edit(lot); gnc_lot_commit_edit(lot);
qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, NULL); qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_MODIFY, nullptr);
LEAVE("removed from lot"); LEAVE("removed from lot");
} }
@ -673,9 +673,9 @@ Split *
gnc_lot_get_earliest_split (GNCLot *lot) gnc_lot_get_earliest_split (GNCLot *lot)
{ {
GNCLotPrivate* priv; GNCLotPrivate* priv;
if (!lot) return NULL; if (!lot) return nullptr;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
if (! priv->splits) return NULL; if (! priv->splits) return nullptr;
priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly); priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly);
return GNC_SPLIT(priv->splits->data); return GNC_SPLIT(priv->splits->data);
} }
@ -687,9 +687,9 @@ gnc_lot_get_latest_split (GNCLot *lot)
GNCLotPrivate* priv; GNCLotPrivate* priv;
SplitList *node; SplitList *node;
if (!lot) return NULL; if (!lot) return nullptr;
priv = GET_PRIVATE(lot); priv = GET_PRIVATE(lot);
if (! priv->splits) return NULL; if (! priv->splits) return nullptr;
priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly); priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly);
for (node = priv->splits; node->next; node = node->next) for (node = priv->splits; node->next; node = node->next)
@ -714,7 +714,7 @@ gnc_lot_book_end(QofBook* book)
QofCollection *col; QofCollection *col;
col = qof_book_get_collection(book, GNC_ID_LOT); col = qof_book_get_collection(book, GNC_ID_LOT);
qof_collection_foreach(col, destroy_lot_on_book_close, NULL); qof_collection_foreach(col, destroy_lot_on_book_close, nullptr);
} }
#ifdef _MSC_VER #ifdef _MSC_VER
@ -730,12 +730,12 @@ static QofObject gncLotDesc =
DI(.e_type = ) GNC_ID_LOT, DI(.e_type = ) GNC_ID_LOT,
DI(.type_label = ) "Lot", DI(.type_label = ) "Lot",
DI(.create = ) (void* (*)(QofBook*))gnc_lot_new, DI(.create = ) (void* (*)(QofBook*))gnc_lot_new,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) gnc_lot_book_end, DI(.book_end = ) gnc_lot_book_end,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) qof_collection_foreach, DI(.foreach = ) qof_collection_foreach,
DI(.printable = ) NULL, DI(.printable = ) nullptr,
DI(.version_cmp = ) (int (*)(gpointer, gpointer))qof_instance_version_cmp, DI(.version_cmp = ) (int (*)(gpointer, gpointer))qof_instance_version_cmp,
}; };
@ -756,24 +756,24 @@ gboolean gnc_lot_register (void)
}, },
{ {
QOF_PARAM_GUID, QOF_TYPE_GUID, QOF_PARAM_GUID, QOF_TYPE_GUID,
(QofAccessFunc) qof_entity_get_guid, NULL (QofAccessFunc) qof_entity_get_guid, nullptr
}, },
{ {
QOF_PARAM_BOOK, QOF_ID_BOOK, QOF_PARAM_BOOK, QOF_ID_BOOK,
(QofAccessFunc) gnc_lot_get_book, NULL (QofAccessFunc) gnc_lot_get_book, nullptr
}, },
{ {
LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, LOT_IS_CLOSED, QOF_TYPE_BOOLEAN,
(QofAccessFunc) gnc_lot_is_closed, NULL (QofAccessFunc) gnc_lot_is_closed, nullptr
}, },
{ {
LOT_BALANCE, QOF_TYPE_NUMERIC, LOT_BALANCE, QOF_TYPE_NUMERIC,
(QofAccessFunc) gnc_lot_get_balance, NULL (QofAccessFunc) gnc_lot_get_balance, nullptr
}, },
{ NULL }, { nullptr },
}; };
qof_class_register (GNC_ID_LOT, NULL, params); qof_class_register (GNC_ID_LOT, nullptr, params);
return qof_object_register(&gncLotDesc); return qof_object_register(&gncLotDesc);
} }
@ -787,11 +787,11 @@ GNCLot * gnc_lot_make_default (Account *acc)
/* Provide a reasonable title for the new lot */ /* Provide a reasonable title for the new lot */
xaccAccountBeginEdit (acc); xaccAccountBeginEdit (acc);
qof_instance_get (QOF_INSTANCE (acc), "lot-next-id", &id, NULL); qof_instance_get (QOF_INSTANCE (acc), "lot-next-id", &id, nullptr);
buff = g_strdup_printf ("%s %" G_GINT64_FORMAT, _("Lot"), id); buff = g_strdup_printf ("%s %" G_GINT64_FORMAT, _("Lot"), id);
gnc_lot_set_title (lot, buff); gnc_lot_set_title (lot, buff);
id ++; id ++;
qof_instance_set (QOF_INSTANCE (acc), "lot-next-id", id, NULL); qof_instance_set (QOF_INSTANCE (acc), "lot-next-id", id, nullptr);
xaccAccountCommitEdit (acc); xaccAccountCommitEdit (acc);
g_free (buff); g_free (buff);
return lot; return lot;

View File

@ -89,7 +89,7 @@ gnc_price_init(GNCPrice* price)
{ {
price->refcount = 1; price->refcount = 1;
price->value = gnc_numeric_zero(); price->value = gnc_numeric_zero();
price->type = NULL; price->type = nullptr;
price->source = PRICE_SOURCE_INVALID; price->source = PRICE_SOURCE_INVALID;
} }
@ -250,7 +250,7 @@ gnc_price_class_init(GNCPriceClass *klass)
" the price was created. This property works on the" " the price was created. This property works on the"
" string values in source_names for SQL database" " string values in source_names for SQL database"
" compatibility.", " compatibility.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -262,7 +262,7 @@ gnc_price_class_init(GNCPriceClass *klass)
"type of a price quote. Types possible now " "type of a price quote. Types possible now "
"are 'bid', 'ask', 'last', 'nav', 'transaction', " "are 'bid', 'ask', 'last', 'nav', 'transaction', "
"and 'unknown'.", "and 'unknown'.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -294,13 +294,13 @@ gnc_price_create (QofBook *book)
{ {
GNCPrice *p; GNCPrice *p;
g_return_val_if_fail (book, NULL); g_return_val_if_fail (book, nullptr);
ENTER(" "); ENTER(" ");
p = static_cast<GNCPrice*>(g_object_new(GNC_TYPE_PRICE, NULL)); p = static_cast<GNCPrice*>(g_object_new(GNC_TYPE_PRICE, nullptr));
qof_instance_init_data (&p->inst, GNC_ID_PRICE, book); qof_instance_init_data (&p->inst, GNC_ID_PRICE, book);
qof_event_gen (&p->inst, QOF_EVENT_CREATE, NULL); qof_event_gen (&p->inst, QOF_EVENT_CREATE, nullptr);
LEAVE ("price created %p", p); LEAVE ("price created %p", p);
return p; return p;
} }
@ -309,7 +309,7 @@ static void
gnc_price_destroy (GNCPrice *p) gnc_price_destroy (GNCPrice *p)
{ {
ENTER("destroy price %p", p); ENTER("destroy price %p", p);
qof_event_gen (&p->inst, QOF_EVENT_DESTROY, NULL); qof_event_gen (&p->inst, QOF_EVENT_DESTROY, nullptr);
if (p->type) CACHE_REMOVE(p->type); if (p->type) CACHE_REMOVE(p->type);
@ -338,7 +338,7 @@ gnc_price_unref(GNCPrice *p)
if (p->refcount <= 0) if (p->refcount <= 0)
{ {
if (NULL != p->db) if (nullptr != p->db)
{ {
PERR("last unref while price in database"); PERR("last unref while price in database");
} }
@ -354,21 +354,21 @@ gnc_price_clone (GNCPrice* p, QofBook *book)
/* the clone doesn't belong to a PriceDB */ /* the clone doesn't belong to a PriceDB */
GNCPrice *new_p; GNCPrice *new_p;
g_return_val_if_fail (book, NULL); g_return_val_if_fail (book, nullptr);
ENTER ("pr=%p", p); ENTER ("pr=%p", p);
if (!p) if (!p)
{ {
LEAVE ("return NULL"); LEAVE ("return nullptr");
return NULL; return nullptr;
} }
new_p = gnc_price_create(book); new_p = gnc_price_create(book);
if (!new_p) if (!new_p)
{ {
LEAVE ("return NULL"); LEAVE ("return nullptr");
return NULL; return nullptr;
} }
qof_instance_copy_version(new_p, p); qof_instance_copy_version(new_p, p);
@ -448,7 +448,7 @@ static void
gnc_price_set_dirty (GNCPrice *p) gnc_price_set_dirty (GNCPrice *p)
{ {
qof_instance_set_dirty(&p->inst); qof_instance_set_dirty(&p->inst);
qof_event_gen(&p->inst, QOF_EVENT_MODIFY, NULL); qof_event_gen(&p->inst, QOF_EVENT_MODIFY, nullptr);
} }
void void
@ -572,7 +572,7 @@ gnc_price_lookup (const GncGUID *guid, QofBook *book)
{ {
QofCollection *col; QofCollection *col;
if (!guid || !book) return NULL; if (!guid || !book) return nullptr;
col = qof_book_get_collection (book, GNC_ID_PRICE); col = qof_book_get_collection (book, GNC_ID_PRICE);
return (GNCPrice *) qof_collection_lookup_entity (col, guid); return (GNCPrice *) qof_collection_lookup_entity (col, guid);
} }
@ -580,7 +580,7 @@ gnc_price_lookup (const GncGUID *guid, QofBook *book)
gnc_commodity * gnc_commodity *
gnc_price_get_commodity(const GNCPrice *p) gnc_price_get_commodity(const GNCPrice *p)
{ {
if (!p) return NULL; if (!p) return nullptr;
return p->commodity; return p->commodity;
} }
@ -600,14 +600,14 @@ gnc_price_get_source(const GNCPrice *p)
const char* const char*
gnc_price_get_source_string(const GNCPrice *p) gnc_price_get_source_string(const GNCPrice *p)
{ {
if (!p) return NULL; if (!p) return nullptr;
return source_names[p->source]; return source_names[p->source];
} }
const char * const char *
gnc_price_get_typestr(const GNCPrice *p) gnc_price_get_typestr(const GNCPrice *p)
{ {
if (!p) return NULL; if (!p) return nullptr;
return p->type; return p->type;
} }
@ -616,7 +616,7 @@ gnc_price_get_value(const GNCPrice *p)
{ {
if (!p) if (!p)
{ {
PERR("price NULL.\n"); PERR("price nullptr.\n");
return gnc_numeric_zero(); return gnc_numeric_zero();
} }
return p->value; return p->value;
@ -625,7 +625,7 @@ gnc_price_get_value(const GNCPrice *p)
gnc_commodity * gnc_commodity *
gnc_price_get_currency(const GNCPrice *p) gnc_price_get_currency(const GNCPrice *p)
{ {
if (!p) return NULL; if (!p) return nullptr;
return p->currency; return p->currency;
} }
@ -802,7 +802,7 @@ gnc_pricedb_create(QofBook * book)
GNCPriceDB * result; GNCPriceDB * result;
QofCollection *col; QofCollection *col;
g_return_val_if_fail (book, NULL); g_return_val_if_fail (book, nullptr);
/* There can only be one pricedb per book. So if one exits already, /* There can only be one pricedb per book. So if one exits already,
* then use that. Warn user, they shouldn't be creating two ... * then use that. Warn user, they shouldn't be creating two ...
@ -815,7 +815,7 @@ gnc_pricedb_create(QofBook * book)
return result; return result;
} }
result = static_cast<GNCPriceDB*>(g_object_new(GNC_TYPE_PRICEDB, NULL)); result = static_cast<GNCPriceDB*>(g_object_new(GNC_TYPE_PRICEDB, nullptr));
qof_instance_init_data (&result->inst, GNC_ID_PRICEDB, book); qof_instance_init_data (&result->inst, GNC_ID_PRICEDB, book);
qof_collection_mark_clean(col); qof_collection_mark_clean(col);
@ -824,8 +824,8 @@ gnc_pricedb_create(QofBook * book)
provide one here. */ provide one here. */
qof_collection_set_data (col, result); qof_collection_set_data (col, result);
result->commodity_hash = g_hash_table_new(NULL, NULL); result->commodity_hash = g_hash_table_new(nullptr, nullptr);
g_return_val_if_fail (result->commodity_hash, NULL); g_return_val_if_fail (result->commodity_hash, nullptr);
return result; return result;
} }
@ -842,7 +842,7 @@ destroy_pricedb_currency_hash_data(gpointer key,
{ {
p = static_cast<GNCPrice*>(node->data); p = static_cast<GNCPrice*>(node->data);
p->db = NULL; p->db = nullptr;
} }
gnc_price_list_destroy(price_list); gnc_price_list_destroy(price_list);
@ -857,7 +857,7 @@ destroy_pricedb_commodity_hash_data(gpointer key,
if (!currency_hash) return; if (!currency_hash) return;
g_hash_table_foreach (currency_hash, g_hash_table_foreach (currency_hash,
destroy_pricedb_currency_hash_data, destroy_pricedb_currency_hash_data,
NULL); nullptr);
g_hash_table_destroy(currency_hash); g_hash_table_destroy(currency_hash);
} }
@ -869,10 +869,10 @@ gnc_pricedb_destroy(GNCPriceDB *db)
{ {
g_hash_table_foreach (db->commodity_hash, g_hash_table_foreach (db->commodity_hash,
destroy_pricedb_commodity_hash_data, destroy_pricedb_commodity_hash_data,
NULL); nullptr);
} }
g_hash_table_destroy (db->commodity_hash); g_hash_table_destroy (db->commodity_hash);
db->commodity_hash = NULL; db->commodity_hash = nullptr;
/* qof_instance_release (&db->inst); */ /* qof_instance_release (&db->inst); */
g_object_unref(db); g_object_unref(db);
} }
@ -901,7 +901,7 @@ gnc_pricedb_set_bulk_update(GNCPriceDB *db, gboolean bulk_update)
GNCPriceDB * GNCPriceDB *
gnc_collection_get_pricedb(QofCollection *col) gnc_collection_get_pricedb(QofCollection *col)
{ {
if (!col) return NULL; if (!col) return nullptr;
return static_cast<GNCPriceDB*>(qof_collection_get_data (col)); return static_cast<GNCPriceDB*>(qof_collection_get_data (col));
} }
@ -910,7 +910,7 @@ gnc_pricedb_get_db(QofBook *book)
{ {
QofCollection *col; QofCollection *col;
if (!book) return NULL; if (!book) return nullptr;
col = qof_book_get_collection (book, GNC_ID_PRICEDB); col = qof_book_get_collection (book, GNC_ID_PRICEDB);
return gnc_collection_get_pricedb (col); return gnc_collection_get_pricedb (col);
} }
@ -989,7 +989,7 @@ gnc_pricedb_equal (GNCPriceDB *db1, GNCPriceDB *db2)
if (!db1 || !db2) if (!db1 || !db2)
{ {
PWARN ("one is NULL"); PWARN ("one is nullptr");
return FALSE; return FALSE;
} }
@ -1056,7 +1056,7 @@ add_price(GNCPriceDB *db, GNCPrice *p)
{ {
GNCPrice *old_price = gnc_pricedb_lookup_day_t64(db, p->commodity, GNCPrice *old_price = gnc_pricedb_lookup_day_t64(db, p->commodity,
p->currency, p->tmspec); p->currency, p->tmspec);
if (old_price != NULL) if (old_price != nullptr)
{ {
if (p->source > old_price->source) if (p->source > old_price->source)
{ {
@ -1071,7 +1071,7 @@ add_price(GNCPriceDB *db, GNCPrice *p)
currency_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity)); currency_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity));
if (!currency_hash) if (!currency_hash)
{ {
currency_hash = g_hash_table_new(NULL, NULL); currency_hash = g_hash_table_new(nullptr, nullptr);
g_hash_table_insert(db->commodity_hash, commodity, currency_hash); g_hash_table_insert(db->commodity_hash, commodity, currency_hash);
} }
@ -1091,7 +1091,7 @@ add_price(GNCPriceDB *db, GNCPrice *p)
g_hash_table_insert(currency_hash, currency, price_list); g_hash_table_insert(currency_hash, currency, price_list);
p->db = db; p->db = db;
qof_event_gen (&p->inst, QOF_EVENT_ADD, NULL); qof_event_gen (&p->inst, QOF_EVENT_ADD, nullptr);
LEAVE ("db=%p, pr=%p dirty=%d dextroying=%d commodity=%s/%s currency_hash=%p", LEAVE ("db=%p, pr=%p dirty=%d dextroying=%d commodity=%s/%s currency_hash=%p",
db, p, qof_instance_get_dirty_flag(p), db, p, qof_instance_get_dirty_flag(p),
@ -1174,7 +1174,7 @@ remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup)
return FALSE; return FALSE;
} }
qof_event_gen (&p->inst, QOF_EVENT_REMOVE, NULL); qof_event_gen (&p->inst, QOF_EVENT_REMOVE, nullptr);
price_list = static_cast<GList*>(g_hash_table_lookup(currency_hash, currency)); price_list = static_cast<GList*>(g_hash_table_lookup(currency_hash, currency));
gnc_price_ref(p); gnc_price_ref(p);
if (!gnc_price_list_remove(&price_list, p)) if (!gnc_price_list_remove(&price_list, p))
@ -1239,7 +1239,7 @@ gnc_pricedb_remove_price(GNCPriceDB *db, GNCPrice *p)
gnc_price_begin_edit (p); gnc_price_begin_edit (p);
qof_instance_set_destroying(p, TRUE); qof_instance_set_destroying(p, TRUE);
gnc_price_commit_edit (p); gnc_price_commit_edit (p);
p->db = NULL; p->db = nullptr;
gnc_price_unref(p); gnc_price_unref(p);
LEAVE ("db=%p, pr=%p", db, p); LEAVE ("db=%p, pr=%p", db, p);
return rc; return rc;
@ -1395,7 +1395,7 @@ clone_price (GNCPrice **price, GNCPrice *source_price)
QofBook *book; QofBook *book;
if (!source_price) return; if (!source_price) return;
if (price == NULL) return; if (price == nullptr) return;
book = qof_instance_get_book (QOF_INSTANCE(source_price)); book = qof_instance_get_book (QOF_INSTANCE(source_price));
@ -1440,7 +1440,7 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
GSList *item; GSList *item;
gboolean save_first_price = FALSE; gboolean save_first_price = FALSE;
gint saved_test_value = 0, next_test_value = 0; gint saved_test_value = 0, next_test_value = 0;
GNCPrice *cloned_price = NULL; GNCPrice *cloned_price = nullptr;
GDateMonth fiscal_month_start; GDateMonth fiscal_month_start;
GDate *tmp_date = g_date_new_dmy (g_date_get_day (fiscal_end_date), GDate *tmp_date = g_date_new_dmy (g_date_get_day (fiscal_end_date),
g_date_get_month (fiscal_end_date), g_date_get_month (fiscal_end_date),
@ -1556,7 +1556,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list,
data.db = db; data.db = db;
data.cutoff = cutoff; data.cutoff = cutoff;
data.list = NULL; data.list = nullptr;
data.delete_fq = FALSE; data.delete_fq = FALSE;
data.delete_user = FALSE; data.delete_user = FALSE;
data.delete_app = FALSE; data.delete_app = FALSE;
@ -1580,7 +1580,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list,
g_hash_table_foreach (currencies_hash, pricedb_remove_foreach_pricelist, &data); g_hash_table_foreach (currencies_hash, pricedb_remove_foreach_pricelist, &data);
} }
if (data.list == NULL) if (data.list == nullptr)
{ {
LEAVE("Empty price list"); LEAVE("Empty price list");
return FALSE; return FALSE;
@ -1590,7 +1590,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list,
g_slist_length (data.list), datebuff); g_slist_length (data.list), datebuff);
// Check for a valid fiscal end of year date // Check for a valid fiscal end of year date
if (fiscal_end_date == NULL) if (fiscal_end_date == nullptr)
{ {
GDateYear year_now = g_date_get_year (gnc_g_date_new_today ()); GDateYear year_now = g_date_get_year (gnc_g_date_new_today ());
fiscal_end_date = g_date_new (); fiscal_end_date = g_date_new ();
@ -1632,14 +1632,14 @@ hash_values_helper(gpointer key, gpointer value, gpointer data)
static PriceList * static PriceList *
price_list_from_hashtable (GHashTable *hash, const gnc_commodity *currency) price_list_from_hashtable (GHashTable *hash, const gnc_commodity *currency)
{ {
GList *price_list = NULL, *result = NULL ; GList *price_list = nullptr, *result = nullptr ;
if (currency) if (currency)
{ {
price_list = static_cast<GList*>(g_hash_table_lookup(hash, currency)); price_list = static_cast<GList*>(g_hash_table_lookup(hash, currency));
if (!price_list) if (!price_list)
{ {
LEAVE (" no price list"); LEAVE (" no price list");
return NULL; return nullptr;
} }
result = g_list_copy (price_list); result = g_list_copy (price_list);
} }
@ -1653,18 +1653,18 @@ price_list_from_hashtable (GHashTable *hash, const gnc_commodity *currency)
static PriceList * static PriceList *
pricedb_price_list_merge (PriceList *a, PriceList *b) pricedb_price_list_merge (PriceList *a, PriceList *b)
{ {
PriceList *merged_list = NULL; PriceList *merged_list = nullptr;
GList *next_a = a; GList *next_a = a;
GList *next_b = b; GList *next_b = b;
while (next_a || next_b) while (next_a || next_b)
{ {
if (next_a == NULL) if (next_a == nullptr)
{ {
merged_list = g_list_prepend (merged_list, next_b->data); merged_list = g_list_prepend (merged_list, next_b->data);
next_b = next_b->next; next_b = next_b->next;
} }
else if (next_b == NULL) else if (next_b == nullptr)
{ {
merged_list = g_list_prepend (merged_list, next_a->data); merged_list = g_list_prepend (merged_list, next_a->data);
next_a = next_a->next; next_a = next_a->next;
@ -1688,17 +1688,17 @@ static PriceList*
pricedb_get_prices_internal(GNCPriceDB *db, const gnc_commodity *commodity, pricedb_get_prices_internal(GNCPriceDB *db, const gnc_commodity *commodity,
const gnc_commodity *currency, gboolean bidi) const gnc_commodity *currency, gboolean bidi)
{ {
GHashTable *forward_hash = NULL, *reverse_hash = NULL; GHashTable *forward_hash = nullptr, *reverse_hash = nullptr;
PriceList *forward_list = NULL, *reverse_list = NULL; PriceList *forward_list = nullptr, *reverse_list = nullptr;
g_return_val_if_fail (db != NULL, NULL); g_return_val_if_fail (db != nullptr, nullptr);
g_return_val_if_fail (commodity != NULL, NULL); g_return_val_if_fail (commodity != nullptr, nullptr);
forward_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity)); forward_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity));
if (currency && bidi) if (currency && bidi)
reverse_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, currency)); reverse_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, currency));
if (!forward_hash && !reverse_hash) if (!forward_hash && !reverse_hash)
{ {
LEAVE (" no currency hash"); LEAVE (" no currency hash");
return NULL; return nullptr;
} }
if (forward_hash) if (forward_hash)
forward_list = price_list_from_hashtable (forward_hash, currency); forward_list = price_list_from_hashtable (forward_hash, currency);
@ -1737,11 +1737,11 @@ GNCPrice *gnc_pricedb_lookup_latest(GNCPriceDB *db,
GList *price_list; GList *price_list;
GNCPrice *result; GNCPrice *result;
if (!db || !commodity || !currency) return NULL; if (!db || !commodity || !currency) return nullptr;
ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency); ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency);
price_list = pricedb_get_prices_internal(db, commodity, currency, TRUE); price_list = pricedb_get_prices_internal(db, commodity, currency, TRUE);
if (!price_list) return NULL; if (!price_list) return nullptr;
/* This works magically because prices are inserted in date-sorted /* This works magically because prices are inserted in date-sorted
* order, and the latest date always comes first. So return the * order, and the latest date always comes first. So return the
* first in the list. */ * first in the list. */
@ -1810,7 +1810,7 @@ price_list_scan_any_currency(GList *price_list, gpointer data)
/* No point in looking further, they will all be older */ /* No point in looking further, they will all be older */
break; break;
} }
else if (node->next == NULL) else if (node->next == nullptr)
{ {
/* The last price is later than given time, add it */ /* The last price is later than given time, add it */
gnc_price_ref(price); gnc_price_ref(price);
@ -1827,8 +1827,8 @@ price_list_scan_any_currency(GList *price_list, gpointer data)
static PriceList* static PriceList*
latest_before (PriceList *prices, const gnc_commodity* target, time64 t) latest_before (PriceList *prices, const gnc_commodity* target, time64 t)
{ {
GList *node, *found_coms = NULL, *retval = NULL; GList *node, *found_coms = nullptr, *retval = nullptr;
for (node = prices; node != NULL; node = g_list_next(node)) for (node = prices; node != nullptr; node = g_list_next(node))
{ {
GNCPrice *price = (GNCPrice*)node->data; GNCPrice *price = (GNCPrice*)node->data;
gnc_commodity *com = gnc_price_get_commodity(price); gnc_commodity *com = gnc_price_get_commodity(price);
@ -1852,7 +1852,7 @@ static GNCPrice**
find_comtime(GPtrArray* array, gnc_commodity *com) find_comtime(GPtrArray* array, gnc_commodity *com)
{ {
unsigned int index = 0; unsigned int index = 0;
GNCPrice** retval = NULL; GNCPrice** retval = nullptr;
for (index = 0; index < array->len; ++index) for (index = 0; index < array->len; ++index)
{ {
auto price_p = static_cast<GNCPrice**>(g_ptr_array_index(array, index)); auto price_p = static_cast<GNCPrice**>(g_ptr_array_index(array, index));
@ -1873,7 +1873,7 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price,
gnc_commodity *other = com == target ? cur : com; gnc_commodity *other = com == target ? cur : com;
GNCPrice **com_price = find_comtime(price_array, other); GNCPrice **com_price = find_comtime(price_array, other);
time64 com_t; time64 com_t;
if (com_price == NULL) if (com_price == nullptr)
{ {
com_price = (GNCPrice**)g_slice_new(gpointer); com_price = (GNCPrice**)g_slice_new(gpointer);
*com_price = price; *com_price = price;
@ -1920,7 +1920,7 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price,
static PriceList * static PriceList *
nearest_to (PriceList *prices, const gnc_commodity* target, time64 t) nearest_to (PriceList *prices, const gnc_commodity* target, time64 t)
{ {
GList *node, *retval = NULL; GList *node, *retval = nullptr;
const guint prealloc_size = 5; /*More than 5 "other" is unlikely as long as const guint prealloc_size = 5; /*More than 5 "other" is unlikely as long as
* target isn't the book's default * target isn't the book's default
* currency. */ * currency. */
@ -1928,7 +1928,7 @@ nearest_to (PriceList *prices, const gnc_commodity* target, time64 t)
GPtrArray *price_array = g_ptr_array_sized_new(prealloc_size); GPtrArray *price_array = g_ptr_array_sized_new(prealloc_size);
guint index; guint index;
for (node = prices; node != NULL; node = g_list_next(node)) for (node = prices; node != nullptr; node = g_list_next(node))
{ {
GNCPrice *price = (GNCPrice*)node->data; GNCPrice *price = (GNCPrice*)node->data;
retval = add_nearest_price(retval, price_array, price, target, t); retval = add_nearest_price(retval, price_array, price, target, t);
@ -1958,7 +1958,7 @@ gnc_pricedb_lookup_latest_any_currency(GNCPriceDB *db,
const gnc_commodity *commodity) const gnc_commodity *commodity)
{ {
return gnc_pricedb_lookup_nearest_before_any_currency_t64(db, commodity, return gnc_pricedb_lookup_nearest_before_any_currency_t64(db, commodity,
gnc_time(NULL)); gnc_time(nullptr));
} }
PriceList * PriceList *
@ -1966,11 +1966,11 @@ gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
const gnc_commodity *commodity, const gnc_commodity *commodity,
time64 t) time64 t)
{ {
GList *prices = NULL, *result; GList *prices = nullptr, *result;
UsesCommodity helper = {&prices, commodity, t}; UsesCommodity helper = {&prices, commodity, t};
result = NULL; result = nullptr;
if (!db || !commodity) return NULL; if (!db || !commodity) return nullptr;
ENTER ("db=%p commodity=%p", db, commodity); ENTER ("db=%p commodity=%p", db, commodity);
pricedb_pricelist_traversal(db, price_list_scan_any_currency, &helper); pricedb_pricelist_traversal(db, price_list_scan_any_currency, &helper);
@ -1986,11 +1986,11 @@ gnc_pricedb_lookup_nearest_before_any_currency_t64(GNCPriceDB *db,
const gnc_commodity *commodity, const gnc_commodity *commodity,
time64 t) time64 t)
{ {
GList *prices = NULL, *result; GList *prices = nullptr, *result;
UsesCommodity helper = {&prices, commodity, t}; UsesCommodity helper = {&prices, commodity, t};
result = NULL; result = nullptr;
if (!db || !commodity) return NULL; if (!db || !commodity) return nullptr;
ENTER ("db=%p commodity=%p", db, commodity); ENTER ("db=%p commodity=%p", db, commodity);
pricedb_pricelist_traversal(db, price_list_scan_any_currency, pricedb_pricelist_traversal(db, price_list_scan_any_currency,
@ -2050,10 +2050,10 @@ gnc_pricedb_get_prices(GNCPriceDB *db,
const gnc_commodity *commodity, const gnc_commodity *commodity,
const gnc_commodity *currency) const gnc_commodity *currency)
{ {
if (!db || !commodity) return NULL; if (!db || !commodity) return nullptr;
ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency); ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency);
auto result = pricedb_get_prices_internal (db, commodity, currency, FALSE); auto result = pricedb_get_prices_internal (db, commodity, currency, FALSE);
if (!result) return NULL; if (!result) return nullptr;
g_list_foreach (result, (GFunc)gnc_price_ref, nullptr); g_list_foreach (result, (GFunc)gnc_price_ref, nullptr);
LEAVE (" "); LEAVE (" ");
return result; return result;
@ -2096,7 +2096,7 @@ list_combine (gpointer element, gpointer data)
{ {
GList *list = *(GList**)data; GList *list = *(GList**)data;
auto lst = static_cast<GList*>(element); auto lst = static_cast<GList*>(element);
if (list == NULL) if (list == nullptr)
*(GList**)data = g_list_copy (lst); *(GList**)data = g_list_copy (lst);
else else
{ {
@ -2122,14 +2122,14 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
const gnc_commodity *c, const gnc_commodity *c,
const int n) const int n)
{ {
static const gnc_commodity *last_c = NULL; static const gnc_commodity *last_c = nullptr;
static GList *prices = NULL; static GList *prices = nullptr;
GNCPrice *result = NULL; GNCPrice *result = nullptr;
GHashTable *currency_hash; GHashTable *currency_hash;
g_return_val_if_fail (GNC_IS_COMMODITY (c), NULL); g_return_val_if_fail (GNC_IS_COMMODITY (c), nullptr);
if (!db || !c || n < 0) return NULL; if (!db || !c || n < 0) return nullptr;
ENTER ("db=%p commodity=%s index=%d", db, gnc_commodity_get_mnemonic(c), n); ENTER ("db=%p commodity=%s index=%d", db, gnc_commodity_get_mnemonic(c), n);
if (last_c && prices && last_c == c && db->reset_nth_price_cache == FALSE) if (last_c && prices && last_c == c && db->reset_nth_price_cache == FALSE)
@ -2144,7 +2144,7 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
if (prices) if (prices)
{ {
g_list_free (prices); g_list_free (prices);
prices = NULL; prices = nullptr;
} }
db->reset_nth_price_cache = FALSE; db->reset_nth_price_cache = FALSE;
@ -2191,7 +2191,7 @@ gnc_pricedb_lookup_at_time64(GNCPriceDB *db,
time64 t) time64 t)
{ {
GNCPrice *rv = nullptr; GNCPrice *rv = nullptr;
if (!db || !c || !currency) return NULL; if (!db || !c || !currency) return nullptr;
ENTER ("db=%p commodity=%p currency=%p", db, c, currency); ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
auto price_list = pricedb_get_prices_internal (db, c, currency, TRUE); auto price_list = pricedb_get_prices_internal (db, c, currency, TRUE);
auto p = g_list_find_custom (price_list, &t, (GCompareFunc) price_same_time); auto p = g_list_find_custom (price_list, &t, (GCompareFunc) price_same_time);
@ -2213,15 +2213,15 @@ lookup_nearest_in_time(GNCPriceDB *db,
gboolean sameday) gboolean sameday)
{ {
GList *price_list; GList *price_list;
GNCPrice *current_price = NULL; GNCPrice *current_price = nullptr;
GNCPrice *next_price = NULL; GNCPrice *next_price = nullptr;
GNCPrice *result = NULL; GNCPrice *result = nullptr;
if (!db || !c || !currency) return NULL; if (!db || !c || !currency) return nullptr;
if (t == INT64_MAX) return NULL; if (t == INT64_MAX) return nullptr;
ENTER ("db=%p commodity=%p currency=%p", db, c, currency); ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
price_list = pricedb_get_prices_internal (db, c, currency, TRUE); price_list = pricedb_get_prices_internal (db, c, currency, TRUE);
if (!price_list) return NULL; if (!price_list) return nullptr;
/* default answer */ /* default answer */
current_price = static_cast<GNCPrice*>(price_list->data); current_price = static_cast<GNCPrice*>(price_list->data);
@ -2254,7 +2254,7 @@ lookup_nearest_in_time(GNCPriceDB *db,
price_day = time64CanonicalDayTime(gnc_price_get_time64(current_price)); price_day = time64CanonicalDayTime(gnc_price_get_time64(current_price));
t_day = time64CanonicalDayTime(t); t_day = time64CanonicalDayTime(t);
if (price_day != t_day) if (price_day != t_day)
result = NULL; result = nullptr;
} }
} }
else else
@ -2336,11 +2336,11 @@ gnc_pricedb_lookup_nearest_before_t64 (GNCPriceDB *db,
const gnc_commodity *currency, const gnc_commodity *currency,
time64 t) time64 t)
{ {
GNCPrice *current_price = NULL; GNCPrice *current_price = nullptr;
if (!db || !c || !currency) return NULL; if (!db || !c || !currency) return nullptr;
ENTER ("db=%p commodity=%p currency=%p", db, c, currency); ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
auto price_list = pricedb_get_prices_internal (db, c, currency, TRUE); auto price_list = pricedb_get_prices_internal (db, c, currency, TRUE);
if (!price_list) return NULL; if (!price_list) return nullptr;
auto p = g_list_find_custom (price_list, &t, (GCompareFunc)price_time64_less_or_equal); auto p = g_list_find_custom (price_list, &t, (GCompareFunc)price_time64_less_or_equal);
if (p) if (p)
{ {
@ -2363,14 +2363,14 @@ static PriceTuple
extract_common_prices (PriceList *from_prices, PriceList *to_prices, extract_common_prices (PriceList *from_prices, PriceList *to_prices,
const gnc_commodity *from, const gnc_commodity *to) const gnc_commodity *from, const gnc_commodity *to)
{ {
PriceTuple retval = {NULL, NULL}; PriceTuple retval = {nullptr, nullptr};
GList *from_node = NULL, *to_node = NULL; GList *from_node = nullptr, *to_node = nullptr;
GNCPrice *from_price = NULL, *to_price = NULL; GNCPrice *from_price = nullptr, *to_price = nullptr;
for (from_node = from_prices; from_node != NULL; for (from_node = from_prices; from_node != nullptr;
from_node = g_list_next(from_node)) from_node = g_list_next(from_node))
{ {
for (to_node = to_prices; to_node != NULL; for (to_node = to_prices; to_node != nullptr;
to_node = g_list_next(to_node)) to_node = g_list_next(to_node))
{ {
gnc_commodity *to_com, *to_cur; gnc_commodity *to_com, *to_cur;
@ -2386,13 +2386,13 @@ extract_common_prices (PriceList *from_prices, PriceList *to_prices,
((to_cur == from_com || to_cur == from_cur) && ((to_cur == from_com || to_cur == from_cur) &&
(to_cur != from && to_cur != to))) (to_cur != from && to_cur != to)))
break; break;
to_price = NULL; to_price = nullptr;
from_price = NULL; from_price = nullptr;
} }
if (to_price != NULL && from_price != NULL) if (to_price != nullptr && from_price != nullptr)
break; break;
} }
if (from_price == NULL || to_price == NULL) if (from_price == nullptr || to_price == nullptr)
return retval; return retval;
gnc_price_ref(from_price); gnc_price_ref(from_price);
gnc_price_ref(to_price); gnc_price_ref(to_price);
@ -2437,7 +2437,7 @@ static gnc_numeric
indirect_price_conversion (GNCPriceDB *db, const gnc_commodity *from, indirect_price_conversion (GNCPriceDB *db, const gnc_commodity *from,
const gnc_commodity *to, time64 t, gboolean before_date) const gnc_commodity *to, time64 t, gboolean before_date)
{ {
GList *from_prices = NULL, *to_prices = NULL; GList *from_prices = nullptr, *to_prices = nullptr;
PriceTuple tuple; PriceTuple tuple;
gnc_numeric zero = gnc_numeric_zero(); gnc_numeric zero = gnc_numeric_zero();
if (!from || !to) if (!from || !to)
@ -2653,7 +2653,7 @@ unstable_price_traversal(GNCPriceDB *db,
foreach_data.ok = TRUE; foreach_data.ok = TRUE;
foreach_data.func = f; foreach_data.func = f;
foreach_data.user_data = user_data; foreach_data.user_data = user_data;
if (db->commodity_hash == NULL) if (db->commodity_hash == nullptr)
{ {
return FALSE; return FALSE;
} }
@ -2701,7 +2701,7 @@ pricedb_pricelist_traversal(GNCPriceDB *db,
foreach_data.ok = TRUE; foreach_data.ok = TRUE;
foreach_data.func = f; foreach_data.func = f;
foreach_data.user_data = user_data; foreach_data.user_data = user_data;
if (db->commodity_hash == NULL) if (db->commodity_hash == nullptr)
{ {
return FALSE; return FALSE;
} }
@ -2817,7 +2817,7 @@ gnc_pricedb_substitute_commodity(GNCPriceDB *db,
gnc_commodity *new_c) gnc_commodity *new_c)
{ {
GNCPriceFixupData data; GNCPriceFixupData data;
GList *prices = NULL; GList *prices = nullptr;
if (!db || !old_c || !new_c) return; if (!db || !old_c || !new_c) return;
@ -2840,7 +2840,7 @@ gnc_price_print(GNCPrice *p, FILE *f, int indent)
{ {
gnc_commodity *commodity; gnc_commodity *commodity;
gnc_commodity *currency; gnc_commodity *currency;
gchar *istr = NULL; /* indent string */ gchar *istr = nullptr; /* indent string */
const char *str; const char *str;
if (!p) return; if (!p) return;
@ -2896,12 +2896,12 @@ gnc_pricedb_print_contents(GNCPriceDB *db, FILE *f)
{ {
if (!db) if (!db)
{ {
PERR("NULL PriceDB\n"); PERR("nullptr PriceDB\n");
return; return;
} }
if (!f) if (!f)
{ {
PERR("NULL FILE*\n"); PERR("nullptr FILE*\n");
return; return;
} }
@ -2928,7 +2928,7 @@ pricedb_book_end (QofBook *book)
return; return;
col = qof_book_get_collection(book, GNC_ID_PRICEDB); col = qof_book_get_collection(book, GNC_ID_PRICEDB);
auto db = static_cast<GNCPriceDB*>(qof_collection_get_data(col)); auto db = static_cast<GNCPriceDB*>(qof_collection_get_data(col));
qof_collection_set_data(col, NULL); qof_collection_set_data(col, nullptr);
gnc_pricedb_destroy(db); gnc_pricedb_destroy(db);
} }
@ -3013,7 +3013,7 @@ price_printable(gpointer obj)
/* Reference it so the compiler doesn't optimize it out. bit /* Reference it so the compiler doesn't optimize it out. bit
don't actually call it. */ don't actually call it. */
if (obj == buff) if (obj == buff)
price_list_dump(NULL, ""); price_list_dump(nullptr, "");
#endif #endif
val = gnc_numeric_to_string (pr->value); val = gnc_numeric_to_string (pr->value);
@ -3039,7 +3039,7 @@ price_list_dump(GList *price_list, const char *tag)
GNCPrice *price; GNCPrice *price;
GList *node; GList *node;
printf("Price list %s\n", tag); printf("Price list %s\n", tag);
for (node = price_list; node != NULL; node = node->next) for (node = price_list; node != nullptr; node = node->next)
{ {
printf("%s\n", price_printable(node->data)); printf("%s\n", price_printable(node->data));
} }
@ -3059,13 +3059,13 @@ static QofObject price_object_def =
DI(.e_type = ) GNC_ID_PRICE, DI(.e_type = ) GNC_ID_PRICE,
DI(.type_label = ) "Price", DI(.type_label = ) "Price",
DI(.create = ) price_create, DI(.create = ) price_create,
DI(.book_begin = ) NULL, DI(.book_begin = ) nullptr,
DI(.book_end = ) NULL, DI(.book_end = ) nullptr,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) price_foreach, DI(.foreach = ) price_foreach,
DI(.printable = ) price_printable, DI(.printable = ) price_printable,
DI(.version_cmp = ) NULL, DI(.version_cmp = ) nullptr,
}; };
static QofObject pricedb_object_def = static QofObject pricedb_object_def =
@ -3073,14 +3073,14 @@ static QofObject pricedb_object_def =
DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_PRICEDB, DI(.e_type = ) GNC_ID_PRICEDB,
DI(.type_label = ) "PriceDB", DI(.type_label = ) "PriceDB",
DI(.create = ) NULL, DI(.create = ) nullptr,
DI(.book_begin = ) pricedb_book_begin, DI(.book_begin = ) pricedb_book_begin,
DI(.book_end = ) pricedb_book_end, DI(.book_end = ) pricedb_book_end,
DI(.is_dirty = ) qof_collection_is_dirty, DI(.is_dirty = ) qof_collection_is_dirty,
DI(.mark_clean = ) qof_collection_mark_clean, DI(.mark_clean = ) qof_collection_mark_clean,
DI(.foreach = ) NULL, DI(.foreach = ) nullptr,
DI(.printable = ) NULL, DI(.printable = ) nullptr,
DI(.version_cmp = ) NULL, DI(.version_cmp = ) nullptr,
}; };
gboolean gboolean
@ -3094,10 +3094,10 @@ gnc_pricedb_register (void)
{ PRICE_SOURCE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_source, (QofSetterFunc)gnc_price_set_source }, { PRICE_SOURCE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_source, (QofSetterFunc)gnc_price_set_source },
{ PRICE_TYPE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_typestr, (QofSetterFunc)gnc_price_set_typestr }, { PRICE_TYPE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_typestr, (QofSetterFunc)gnc_price_set_typestr },
{ PRICE_VALUE, QOF_TYPE_NUMERIC, (QofAccessFunc)gnc_price_get_value, (QofSetterFunc)gnc_price_set_value }, { PRICE_VALUE, QOF_TYPE_NUMERIC, (QofAccessFunc)gnc_price_get_value, (QofSetterFunc)gnc_price_set_value },
{ NULL }, { nullptr },
}; };
qof_class_register (GNC_ID_PRICE, NULL, params); qof_class_register (GNC_ID_PRICE, nullptr, params);
if (!qof_object_register (&price_object_def)) if (!qof_object_register (&price_object_def))
return FALSE; return FALSE;

View File

@ -74,8 +74,8 @@ gnc_value_get_guid (const GValue *value)
if (!value) return nullptr; if (!value) return nullptr;
GncGUID *val; GncGUID *val;
g_return_val_if_fail (value && G_IS_VALUE (value), NULL); g_return_val_if_fail (value && G_IS_VALUE (value), nullptr);
g_return_val_if_fail (GNC_VALUE_HOLDS_GUID (value), NULL); g_return_val_if_fail (GNC_VALUE_HOLDS_GUID (value), nullptr);
val = (GncGUID*) g_value_get_boxed (value); val = (GncGUID*) g_value_get_boxed (value);
@ -172,7 +172,7 @@ guid_to_string (const GncGUID * guid)
gchar * gchar *
guid_to_string_buff (const GncGUID * guid, gchar *str) guid_to_string_buff (const GncGUID * guid, gchar *str)
{ {
if (!str || !guid) return NULL; if (!str || !guid) return nullptr;
gnc::GUID temp {*guid}; gnc::GUID temp {*guid};
auto val = temp.to_string (); auto val = temp.to_string ();
@ -229,7 +229,7 @@ guid_hash_to_guint (gconstpointer ptr)
{ {
if (!ptr) if (!ptr)
{ {
PERR ("received NULL guid pointer."); PERR ("received nullptr guid pointer.");
return 0; return 0;
} }
GncGUID const & guid = * reinterpret_cast <GncGUID const *> (ptr); GncGUID const & guid = * reinterpret_cast <GncGUID const *> (ptr);

View File

@ -114,7 +114,7 @@ qof_book_init (QofBook *book)
qof_instance_init_data (&book->inst, QOF_ID_BOOK, book); qof_instance_init_data (&book->inst, QOF_ID_BOOK, book);
book->data_tables = g_hash_table_new_full (g_str_hash, g_str_equal, book->data_tables = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)qof_string_cache_remove, NULL); (GDestroyNotify)qof_string_cache_remove, nullptr);
book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal); book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
book->book_open = 'y'; book->book_open = 'y';
@ -239,10 +239,10 @@ qof_book_class_init (QofBookClass *klass)
PROP_OPT_TRADING_ACCOUNTS, PROP_OPT_TRADING_ACCOUNTS,
g_param_spec_string("trading-accts", g_param_spec_string("trading-accts",
"Use Trading Accounts", "Use Trading Accounts",
"Scheme true ('t') or NULL. If 't', then the book " "Scheme true ('t') or nullptr. If 't', then the book "
"uses trading accounts for managing multiple-currency " "uses trading accounts for managing multiple-currency "
"transactions.", "transactions.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -250,9 +250,9 @@ qof_book_class_init (QofBookClass *klass)
PROP_OPT_NUM_FIELD_SOURCE, PROP_OPT_NUM_FIELD_SOURCE,
g_param_spec_string(PARAM_NAME_NUM_FIELD_SOURCE, g_param_spec_string(PARAM_NAME_NUM_FIELD_SOURCE,
"Use Split-Action in the Num Field", "Use Split-Action in the Num Field",
"Scheme true ('t') or NULL. If 't', then the book " "Scheme true ('t') or nullptr. If 't', then the book "
"will put the split action value in the Num field.", "will put the split action value in the Num field.",
NULL, nullptr,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property g_object_class_install_property
@ -292,10 +292,10 @@ qof_book_new (void)
QofBook *book; QofBook *book;
ENTER (" "); ENTER (" ");
book = static_cast<QofBook*>(g_object_new(QOF_TYPE_BOOK, NULL)); book = static_cast<QofBook*>(g_object_new(QOF_TYPE_BOOK, nullptr));
qof_object_book_begin (book); qof_object_book_begin (book);
qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL); qof_event_gen (&book->inst, QOF_EVENT_CREATE, nullptr);
LEAVE ("book=%p", book); LEAVE ("book=%p", book);
return book; return book;
} }
@ -336,7 +336,7 @@ qof_book_destroy (QofBook *book)
ENTER ("book=%p", book); ENTER ("book=%p", book);
book->shutting_down = TRUE; book->shutting_down = TRUE;
qof_event_force (&book->inst, QOF_EVENT_DESTROY, NULL); qof_event_force (&book->inst, QOF_EVENT_DESTROY, nullptr);
/* Call the list of finalizers, let them do their thing. /* Call the list of finalizers, let them do their thing.
* Do this before tearing into the rest of the book. * Do this before tearing into the rest of the book.
@ -351,9 +351,9 @@ qof_book_destroy (QofBook *book)
qof_object_book_end (book); qof_object_book_end (book);
g_hash_table_destroy (book->data_table_finalizers); g_hash_table_destroy (book->data_table_finalizers);
book->data_table_finalizers = NULL; book->data_table_finalizers = nullptr;
g_hash_table_destroy (book->data_tables); g_hash_table_destroy (book->data_tables);
book->data_tables = NULL; book->data_tables = nullptr;
/* qof_instance_release (&book->inst); */ /* qof_instance_release (&book->inst); */
@ -401,7 +401,7 @@ void qof_book_mark_session_dirty (QofBook *book)
{ {
/* Set the session dirty upfront, because the callback will check. */ /* Set the session dirty upfront, because the callback will check. */
book->session_dirty = TRUE; book->session_dirty = TRUE;
book->dirty_time = gnc_time (NULL); book->dirty_time = gnc_time (nullptr);
if (book->dirty_cb) if (book->dirty_cb)
book->dirty_cb(book, TRUE, book->dirty_data); book->dirty_cb(book, TRUE, book->dirty_data);
} }
@ -413,7 +413,7 @@ qof_book_print_dirty (const QofBook *book)
if (qof_book_session_not_saved(book)) if (qof_book_session_not_saved(book))
PINFO("book is dirty."); PINFO("book is dirty.");
qof_book_foreach_collection qof_book_foreach_collection
(book, (QofCollectionForeachCB)qof_collection_print_dirty, NULL); (book, (QofCollectionForeachCB)qof_collection_print_dirty, nullptr);
} }
time64 time64
@ -439,7 +439,7 @@ qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data)
QofBackend * QofBackend *
qof_book_get_backend (const QofBook *book) qof_book_get_backend (const QofBook *book)
{ {
if (!book) return NULL; if (!book) return nullptr;
return book->backend; return book->backend;
} }
@ -488,7 +488,7 @@ qof_book_set_data_fin (QofBook *book, const char *key, gpointer data, QofBookFin
gpointer gpointer
qof_book_get_data (const QofBook *book, const char *key) qof_book_get_data (const QofBook *book, const char *key)
{ {
if (!book || !key) return NULL; if (!book || !key) return nullptr;
return g_hash_table_lookup (book->data_tables, (gpointer)key); return g_hash_table_lookup (book->data_tables, (gpointer)key);
} }
@ -496,14 +496,14 @@ qof_book_get_data (const QofBook *book, const char *key)
gboolean gboolean
qof_book_is_readonly(const QofBook *book) qof_book_is_readonly(const QofBook *book)
{ {
g_return_val_if_fail( book != NULL, TRUE ); g_return_val_if_fail( book != nullptr, TRUE );
return book->read_only; return book->read_only;
} }
void void
qof_book_mark_readonly(QofBook *book) qof_book_mark_readonly(QofBook *book)
{ {
g_return_if_fail( book != NULL ); g_return_if_fail( book != nullptr );
book->read_only = TRUE; book->read_only = TRUE;
} }
@ -522,7 +522,7 @@ qof_book_get_collection (const QofBook *book, QofIdType entity_type)
{ {
QofCollection *col; QofCollection *col;
if (!book || !entity_type) return NULL; if (!book || !entity_type) return nullptr;
col = static_cast<QofCollection*>(g_hash_table_lookup (book->hash_of_collections, entity_type)); col = static_cast<QofCollection*>(g_hash_table_lookup (book->hash_of_collections, entity_type));
if (!col) if (!col)
@ -633,13 +633,13 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
if (!book) if (!book)
{ {
PWARN ("No book!!!"); PWARN ("No book!!!");
return NULL; return nullptr;
} }
if (!counter_name || *counter_name == '\0') if (!counter_name || *counter_name == '\0')
{ {
PWARN ("Invalid counter name."); PWARN ("Invalid counter name.");
return NULL; return nullptr;
} }
/* Get the current counter value from the KVP in the book. */ /* Get the current counter value from the KVP in the book. */
@ -647,7 +647,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
/* Check if an error occurred */ /* Check if an error occurred */
if (counter < 0) if (counter < 0)
return NULL; return nullptr;
/* Increment the counter */ /* Increment the counter */
counter++; counter++;
@ -658,7 +658,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
if (!kvp) if (!kvp)
{ {
PWARN ("Book has no KVP_Frame"); PWARN ("Book has no KVP_Frame");
return NULL; return nullptr;
} }
/* Save off the new counter */ /* Save off the new counter */
@ -673,7 +673,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
if (!format) if (!format)
{ {
PWARN("Cannot get format for counter"); PWARN("Cannot get format for counter");
return NULL; return nullptr;
} }
/* Generate a string version of the counter */ /* Generate a string version of the counter */
@ -686,21 +686,21 @@ char *
qof_book_get_counter_format(const QofBook *book, const char *counter_name) qof_book_get_counter_format(const QofBook *book, const char *counter_name)
{ {
KvpFrame *kvp; KvpFrame *kvp;
const char *user_format = NULL; const char *user_format = nullptr;
gchar *norm_format = NULL; gchar *norm_format = nullptr;
KvpValue *value; KvpValue *value;
gchar *error = NULL; gchar *error = nullptr;
if (!book) if (!book)
{ {
PWARN ("No book!!!"); PWARN ("No book!!!");
return NULL; return nullptr;
} }
if (!counter_name || *counter_name == '\0') if (!counter_name || *counter_name == '\0')
{ {
PWARN ("Invalid counter name."); PWARN ("Invalid counter name.");
return NULL; return nullptr;
} }
/* Get the KVP from the current book */ /* Get the KVP from the current book */
@ -709,7 +709,7 @@ qof_book_get_counter_format(const QofBook *book, const char *counter_name)
if (!kvp) if (!kvp)
{ {
PWARN ("Book has no KVP_Frame"); PWARN ("Book has no KVP_Frame");
return NULL; return nullptr;
} }
/* Get the format string */ /* Get the format string */
@ -722,7 +722,7 @@ qof_book_get_counter_format(const QofBook *book, const char *counter_name)
{ {
PWARN("Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", user_format, counter_name, error); PWARN("Invalid counter format string. Format string: '%s' Counter: '%s' Error: '%s')", user_format, counter_name, error);
/* Invalid format string */ /* Invalid format string */
user_format = NULL; user_format = nullptr;
g_free(error); g_free(error);
} }
} }
@ -746,10 +746,10 @@ qof_book_normalize_counter_format(const gchar *p, gchar **err_msg)
"I64i", "I64i",
PRIi64, PRIi64,
"li", "li",
NULL, nullptr,
}; };
int i = 0; int i = 0;
gchar *normalized_spec = NULL; gchar *normalized_spec = nullptr;
while (valid_formats[i]) while (valid_formats[i])
{ {
@ -757,7 +757,7 @@ qof_book_normalize_counter_format(const gchar *p, gchar **err_msg)
if (err_msg && *err_msg) if (err_msg && *err_msg)
{ {
g_free (*err_msg); g_free (*err_msg);
*err_msg = NULL; *err_msg = nullptr;
} }
normalized_spec = qof_book_normalize_counter_format_internal(p, valid_formats[i], err_msg); normalized_spec = qof_book_normalize_counter_format_internal(p, valid_formats[i], err_msg);
@ -766,15 +766,15 @@ qof_book_normalize_counter_format(const gchar *p, gchar **err_msg)
i++; i++;
} }
return NULL; return nullptr;
} }
gchar * gchar *
qof_book_normalize_counter_format_internal(const gchar *p, qof_book_normalize_counter_format_internal(const gchar *p,
const gchar *gint64_format, gchar **err_msg) const gchar *gint64_format, gchar **err_msg)
{ {
const gchar *conv_start, *base, *tmp = NULL; const gchar *conv_start, *base, *tmp = nullptr;
gchar *normalized_str = NULL, *aux_str = NULL; gchar *normalized_str = nullptr, *aux_str = nullptr;
/* Validate a counter format. This is a very simple "parser" that /* Validate a counter format. This is a very simple "parser" that
* simply checks for a single gint64 conversion specification, * simply checks for a single gint64 conversion specification,
@ -804,7 +804,7 @@ qof_book_normalize_counter_format_internal(const gchar *p,
{ {
if (err_msg) if (err_msg)
*err_msg = g_strdup("Format string ended without any conversion specification"); *err_msg = g_strdup("Format string ended without any conversion specification");
return NULL; return nullptr;
} }
/* Store the start of the conversion for error messages */ /* Store the start of the conversion for error messages */
@ -821,7 +821,7 @@ qof_book_normalize_counter_format_internal(const gchar *p,
{ {
if (err_msg) if (err_msg)
*err_msg = g_strdup_printf("Format string doesn't contain requested format specifier: %s", gint64_format); *err_msg = g_strdup_printf("Format string doesn't contain requested format specifier: %s", gint64_format);
return NULL; return nullptr;
} }
/* Skip any number of flag characters */ /* Skip any number of flag characters */
@ -843,23 +843,23 @@ qof_book_normalize_counter_format_internal(const gchar *p,
{ {
if (err_msg) if (err_msg)
*err_msg = g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start); *err_msg = g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start);
return NULL; return nullptr;
} }
/* See if the format string starts with the correct format /* See if the format string starts with the correct format
* specification. */ * specification. */
tmp = strstr(p, gint64_format); tmp = strstr(p, gint64_format);
if (tmp == NULL) if (tmp == nullptr)
{ {
if (err_msg) if (err_msg)
*err_msg = g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format); *err_msg = g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format);
return NULL; return nullptr;
} }
else if (tmp != p) else if (tmp != p)
{ {
if (err_msg) if (err_msg)
*err_msg = g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p); *err_msg = g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
return NULL; return nullptr;
} }
/* Copy the string we have so far and add normalized format specifier for long int */ /* Copy the string we have so far and add normalized format specifier for long int */
@ -888,7 +888,7 @@ qof_book_normalize_counter_format_internal(const gchar *p,
if (err_msg) if (err_msg)
*err_msg = g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p); *err_msg = g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p);
g_free (normalized_str); g_free (normalized_str);
return NULL; return nullptr;
} }
/* Skip all other characters */ /* Skip all other characters */
p++; p++;
@ -925,10 +925,10 @@ qof_book_use_split_action_for_num_field (const QofBook *book)
{ {
// No cached value? Then do the expensive KVP lookup // No cached value? Then do the expensive KVP lookup
gboolean result; gboolean result;
char *opt = NULL; char *opt = nullptr;
qof_instance_get (QOF_INSTANCE (book), qof_instance_get (QOF_INSTANCE (book),
PARAM_NAME_NUM_FIELD_SOURCE, &opt, PARAM_NAME_NUM_FIELD_SOURCE, &opt,
NULL); nullptr);
if (opt && opt[0] == 't' && opt[1] == 0) if (opt && opt[0] == 't' && opt[1] == 0)
result = TRUE; result = TRUE;
@ -976,7 +976,7 @@ gint qof_book_get_num_days_autoreadonly (const QofBook *book)
// No cached value? Then do the expensive KVP lookup // No cached value? Then do the expensive KVP lookup
qof_instance_get (QOF_INSTANCE (book), qof_instance_get (QOF_INSTANCE (book),
PARAM_NAME_NUM_AUTOREAD_ONLY, &tmp, PARAM_NAME_NUM_AUTOREAD_ONLY, &tmp,
NULL); nullptr);
const_cast<QofBook*>(book)->cached_num_days_autoreadonly = tmp; const_cast<QofBook*>(book)->cached_num_days_autoreadonly = tmp;
const_cast<QofBook*>(book)->cached_num_days_autoreadonly_isvalid = TRUE; const_cast<QofBook*>(book)->cached_num_days_autoreadonly_isvalid = TRUE;
@ -988,7 +988,7 @@ gint qof_book_get_num_days_autoreadonly (const QofBook *book)
GDate* qof_book_get_autoreadonly_gdate (const QofBook *book) GDate* qof_book_get_autoreadonly_gdate (const QofBook *book)
{ {
gint num_days; gint num_days;
GDate* result = NULL; GDate* result = nullptr;
g_assert(book); g_assert(book);
num_days = qof_book_get_num_days_autoreadonly(book); num_days = qof_book_get_num_days_autoreadonly(book);
@ -1237,7 +1237,7 @@ qof_book_get_features (QofBook *book)
{ {
KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book)); KvpFrame *frame = qof_instance_get_slots (QOF_INSTANCE (book));
GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal, GHashTable *features = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL, g_free); nullptr, g_free);
PWARN ("qof_book_get_features is now deprecated."); PWARN ("qof_book_get_features is now deprecated.");
@ -1398,12 +1398,12 @@ gboolean qof_book_register (void)
{ {
static QofParam params[] = static QofParam params[] =
{ {
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL }, { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, nullptr },
{ QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL }, { QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, nullptr },
{ NULL }, { nullptr },
}; };
qof_class_register (QOF_ID_BOOK, NULL, params); qof_class_register (QOF_ID_BOOK, nullptr, params);
return TRUE; return TRUE;
} }

View File

@ -133,9 +133,9 @@ static void qof_instance_class_init(QofInstanceClass *klass)
object_class->set_property = qof_instance_set_property; object_class->set_property = qof_instance_set_property;
object_class->get_property = qof_instance_get_property; object_class->get_property = qof_instance_get_property;
klass->get_display_name = NULL; klass->get_display_name = nullptr;
klass->refers_to_object = NULL; klass->refers_to_object = nullptr;
klass->get_typed_referring_object_list = NULL; klass->get_typed_referring_object_list = nullptr;
g_object_class_install_property g_object_class_install_property
(object_class, (object_class,
@ -257,7 +257,7 @@ qof_instance_init (QofInstance *inst)
QofInstancePrivate *priv; QofInstancePrivate *priv;
priv = GET_PRIVATE(inst); priv = GET_PRIVATE(inst);
priv->book = NULL; priv->book = nullptr;
inst->kvp_data = new KvpFrame; inst->kvp_data = new KvpFrame;
priv->last_update = 0; priv->last_update = 0;
priv->editlevel = 0; priv->editlevel = 0;
@ -279,7 +279,7 @@ qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book)
priv->book = book; priv->book = book;
col = qof_book_get_collection (book, type); col = qof_book_get_collection (book, type);
g_return_if_fail(col != NULL); g_return_if_fail(col != nullptr);
/* XXX We passed redundant info to this routine ... but I think that's /* XXX We passed redundant info to this routine ... but I think that's
* OK, it might eliminate programming errors. */ * OK, it might eliminate programming errors. */
@ -297,7 +297,7 @@ qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book)
{ {
guid_replace(&priv->guid); guid_replace(&priv->guid);
if (NULL == qof_collection_lookup_entity (col, &priv->guid)) if (nullptr == qof_collection_lookup_entity (col, &priv->guid))
break; break;
PWARN("duplicate id created, trying again"); PWARN("duplicate id created, trying again");
@ -320,7 +320,7 @@ qof_instance_dispose (GObject *instp)
qof_collection_remove_entity(inst); qof_collection_remove_entity(inst);
CACHE_REMOVE(inst->e_type); CACHE_REMOVE(inst->e_type);
inst->e_type = NULL; inst->e_type = nullptr;
G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp); G_OBJECT_CLASS(qof_instance_parent_class)->dispose(instp);
} }
@ -457,7 +457,7 @@ qof_instance_get_guid (gconstpointer inst)
{ {
QofInstancePrivate *priv; QofInstancePrivate *priv;
if (!inst) return NULL; if (!inst) return nullptr;
g_return_val_if_fail(QOF_IS_INSTANCE(inst), guid_null()); g_return_val_if_fail(QOF_IS_INSTANCE(inst), guid_null());
priv = GET_PRIVATE(inst); priv = GET_PRIVATE(inst);
return &(priv->guid); return &(priv->guid);
@ -516,7 +516,7 @@ QofCollection *
qof_instance_get_collection (gconstpointer ptr) qof_instance_get_collection (gconstpointer ptr)
{ {
g_return_val_if_fail(QOF_IS_INSTANCE(ptr), NULL); g_return_val_if_fail(QOF_IS_INSTANCE(ptr), nullptr);
return GET_PRIVATE(ptr)->collection; return GET_PRIVATE(ptr)->collection;
} }
@ -530,8 +530,8 @@ qof_instance_set_collection (gconstpointer ptr, QofCollection *col)
QofBook * QofBook *
qof_instance_get_book (gconstpointer inst) qof_instance_get_book (gconstpointer inst)
{ {
if (!inst) return NULL; if (!inst) return nullptr;
g_return_val_if_fail(QOF_IS_INSTANCE(inst), NULL); g_return_val_if_fail(QOF_IS_INSTANCE(inst), nullptr);
return GET_PRIVATE(inst)->book; return GET_PRIVATE(inst)->book;
} }
@ -569,7 +569,7 @@ qof_instance_books_equal (gconstpointer ptr1, gconstpointer ptr2)
KvpFrame* KvpFrame*
qof_instance_get_slots (const QofInstance *inst) qof_instance_get_slots (const QofInstance *inst)
{ {
if (!inst) return NULL; if (!inst) return nullptr;
return inst->kvp_data; return inst->kvp_data;
} }
@ -785,9 +785,9 @@ void qof_instance_set_idata(gpointer inst, guint32 idata)
/* Returns a displayable name to represent this object */ /* Returns a displayable name to represent this object */
gchar* qof_instance_get_display_name(const QofInstance* inst) gchar* qof_instance_get_display_name(const QofInstance* inst)
{ {
g_return_val_if_fail( inst != NULL, NULL ); g_return_val_if_fail( inst != nullptr, nullptr );
if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name != NULL ) if ( QOF_INSTANCE_GET_CLASS(inst)->get_display_name != nullptr )
{ {
return QOF_INSTANCE_GET_CLASS(inst)->get_display_name(inst); return QOF_INSTANCE_GET_CLASS(inst)->get_display_name(inst);
} }
@ -811,7 +811,7 @@ get_referring_object_instance_helper(QofInstance* inst, gpointer user_data)
{ {
QofInstance** pInst = (QofInstance**)user_data; QofInstance** pInst = (QofInstance**)user_data;
if (*pInst == NULL) if (*pInst == nullptr)
{ {
*pInst = inst; *pInst = inst;
} }
@ -820,12 +820,12 @@ get_referring_object_instance_helper(QofInstance* inst, gpointer user_data)
static void static void
get_referring_object_helper(QofCollection* coll, gpointer user_data) get_referring_object_helper(QofCollection* coll, gpointer user_data)
{ {
QofInstance* first_instance = NULL; QofInstance* first_instance = nullptr;
GetReferringObjectHelperData* data = (GetReferringObjectHelperData*)user_data; GetReferringObjectHelperData* data = (GetReferringObjectHelperData*)user_data;
qof_collection_foreach(coll, get_referring_object_instance_helper, &first_instance); qof_collection_foreach(coll, get_referring_object_instance_helper, &first_instance);
if (first_instance != NULL) if (first_instance != nullptr)
{ {
GList* new_list = qof_instance_get_typed_referring_object_list(first_instance, data->inst); GList* new_list = qof_instance_get_typed_referring_object_list(first_instance, data->inst);
data->list = g_list_concat(data->list, new_list); data->list = g_list_concat(data->list, new_list);
@ -837,11 +837,11 @@ GList* qof_instance_get_referring_object_list(const QofInstance* inst)
{ {
GetReferringObjectHelperData data; GetReferringObjectHelperData data;
g_return_val_if_fail( inst != NULL, NULL ); g_return_val_if_fail( inst != nullptr, nullptr );
/* scan all collections */ /* scan all collections */
data.inst = inst; data.inst = inst;
data.list = NULL; data.list = nullptr;
qof_book_foreach_collection(qof_instance_get_book(inst), qof_book_foreach_collection(qof_instance_get_book(inst),
get_referring_object_helper, get_referring_object_helper,
@ -865,11 +865,11 @@ qof_instance_get_referring_object_list_from_collection(const QofCollection* coll
{ {
GetReferringObjectHelperData data; GetReferringObjectHelperData data;
g_return_val_if_fail( coll != NULL, NULL ); g_return_val_if_fail( coll != nullptr, nullptr );
g_return_val_if_fail( ref != NULL, NULL ); g_return_val_if_fail( ref != nullptr, nullptr );
data.inst = ref; data.inst = ref;
data.list = NULL; data.list = nullptr;
qof_collection_foreach(coll, get_typed_referring_object_instance_helper, &data); qof_collection_foreach(coll, get_typed_referring_object_instance_helper, &data);
return data.list; return data.list;
@ -878,10 +878,10 @@ qof_instance_get_referring_object_list_from_collection(const QofCollection* coll
GList* GList*
qof_instance_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref) qof_instance_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref)
{ {
g_return_val_if_fail( inst != NULL, NULL ); g_return_val_if_fail( inst != nullptr, nullptr );
g_return_val_if_fail( ref != NULL, NULL ); g_return_val_if_fail( ref != nullptr, nullptr );
if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list != NULL ) if ( QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list != nullptr )
{ {
return QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list(inst, ref); return QOF_INSTANCE_GET_CLASS(inst)->get_typed_referring_object_list(inst, ref);
} }
@ -899,10 +899,10 @@ qof_instance_get_typed_referring_object_list(const QofInstance* inst, const QofI
/* Check if this object refers to a specific object */ /* Check if this object refers to a specific object */
gboolean qof_instance_refers_to_object(const QofInstance* inst, const QofInstance* ref) gboolean qof_instance_refers_to_object(const QofInstance* inst, const QofInstance* ref)
{ {
g_return_val_if_fail( inst != NULL, FALSE ); g_return_val_if_fail( inst != nullptr, FALSE );
g_return_val_if_fail( ref != NULL, FALSE ); g_return_val_if_fail( ref != nullptr, FALSE );
if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object != NULL ) if ( QOF_INSTANCE_GET_CLASS(inst)->refers_to_object != nullptr )
{ {
return QOF_INSTANCE_GET_CLASS(inst)->refers_to_object(inst, ref); return QOF_INSTANCE_GET_CLASS(inst)->refers_to_object(inst, ref);
} }
@ -1043,7 +1043,7 @@ qof_commit_edit_part2(QofInstance *inst,
gboolean gboolean
qof_instance_has_kvp (QofInstance *inst) qof_instance_has_kvp (QofInstance *inst)
{ {
return (inst->kvp_data != NULL && !inst->kvp_data->empty()); return (inst->kvp_data != nullptr && !inst->kvp_data->empty());
} }
void qof_instance_set_path_kvp (QofInstance * inst, GValue const * value, std::vector<std::string> const & path) void qof_instance_set_path_kvp (QofInstance * inst, GValue const * value, std::vector<std::string> const & path)
@ -1111,7 +1111,7 @@ qof_instance_kvp_add_guid (const QofInstance *inst, const char* path,
time64 time, const char *key, time64 time, const char *key,
const GncGUID *guid) const GncGUID *guid)
{ {
g_return_if_fail (inst->kvp_data != NULL); g_return_if_fail (inst->kvp_data != nullptr);
auto container = new KvpFrame; auto container = new KvpFrame;
Time64 t{time}; Time64 t{time};
@ -1138,8 +1138,8 @@ gboolean
qof_instance_kvp_has_guid (const QofInstance *inst, const char *path, qof_instance_kvp_has_guid (const QofInstance *inst, const char *path,
const char* key, const GncGUID *guid) const char* key, const GncGUID *guid)
{ {
g_return_val_if_fail (inst->kvp_data != NULL, FALSE); g_return_val_if_fail (inst->kvp_data != nullptr, FALSE);
g_return_val_if_fail (guid != NULL, FALSE); g_return_val_if_fail (guid != nullptr, FALSE);
auto v = inst->kvp_data->get_slot({path}); auto v = inst->kvp_data->get_slot({path});
if (v == nullptr) return FALSE; if (v == nullptr) return FALSE;
@ -1152,7 +1152,7 @@ qof_instance_kvp_has_guid (const QofInstance *inst, const char *path,
case KvpValue::Type::GLIST: case KvpValue::Type::GLIST:
{ {
auto list = v->get<GList*>(); auto list = v->get<GList*>();
for (auto node = list; node != NULL; node = node->next) for (auto node = list; node != nullptr; node = node->next)
{ {
auto val = static_cast<KvpValue*>(node->data); auto val = static_cast<KvpValue*>(node->data);
if (kvp_match_guid (val, {key}, guid)) if (kvp_match_guid (val, {key}, guid))
@ -1173,11 +1173,11 @@ void
qof_instance_kvp_remove_guid (const QofInstance *inst, const char *path, qof_instance_kvp_remove_guid (const QofInstance *inst, const char *path,
const char *key, const GncGUID *guid) const char *key, const GncGUID *guid)
{ {
g_return_if_fail (inst->kvp_data != NULL); g_return_if_fail (inst->kvp_data != nullptr);
g_return_if_fail (guid != NULL); g_return_if_fail (guid != nullptr);
auto v = inst->kvp_data->get_slot({path}); auto v = inst->kvp_data->get_slot({path});
if (v == NULL) return; if (v == nullptr) return;
switch (v->get_type()) switch (v->get_type())
{ {
@ -1215,12 +1215,12 @@ void
qof_instance_kvp_merge_guids (const QofInstance *target, qof_instance_kvp_merge_guids (const QofInstance *target,
const QofInstance *donor, const char *path) const QofInstance *donor, const char *path)
{ {
g_return_if_fail (target != NULL); g_return_if_fail (target != nullptr);
g_return_if_fail (donor != NULL); g_return_if_fail (donor != nullptr);
if (! qof_instance_has_slot (donor, path)) return; if (! qof_instance_has_slot (donor, path)) return;
auto v = donor->kvp_data->get_slot({path}); auto v = donor->kvp_data->get_slot({path});
if (v == NULL) return; if (v == nullptr) return;
auto target_val = target->kvp_data->get_slot({path}); auto target_val = target->kvp_data->get_slot({path});
switch (v->get_type()) switch (v->get_type())
@ -1257,7 +1257,7 @@ bool qof_instance_has_path_slot (QofInstance const * inst, std::vector<std::stri
gboolean gboolean
qof_instance_has_slot (const QofInstance *inst, const char *path) qof_instance_has_slot (const QofInstance *inst, const char *path)
{ {
return inst->kvp_data->get_slot({path}) != NULL; return inst->kvp_data->get_slot({path}) != nullptr;
} }
void qof_instance_slot_path_delete (QofInstance const * inst, std::vector<std::string> const & path) void qof_instance_slot_path_delete (QofInstance const * inst, std::vector<std::string> const & path)

View File

@ -61,11 +61,11 @@
#define QOF_LOG_INDENT_WIDTH 4 #define QOF_LOG_INDENT_WIDTH 4
#define NUM_CLOCKS 10 #define NUM_CLOCKS 10
static FILE *fout = NULL; static FILE *fout = nullptr;
static gchar* function_buffer = NULL; static gchar* function_buffer = nullptr;
static gint qof_log_num_spaces = 0; static gint qof_log_num_spaces = 0;
static GLogFunc previous_handler = NULL; static GLogFunc previous_handler = nullptr;
static gchar* qof_logger_format = NULL; static gchar* qof_logger_format = nullptr;
static QofLogModule log_module = "qof"; static QofLogModule log_module = "qof";
using StrVec = std::vector<std::string>; using StrVec = std::vector<std::string>;
@ -90,7 +90,7 @@ struct ModuleEntry
MEVec m_children; MEVec m_children;
}; };
static ModuleEntryPtr _modules = NULL; static ModuleEntryPtr _modules = nullptr;
static ModuleEntry* static ModuleEntry*
get_modules() get_modules()
@ -155,7 +155,7 @@ qof_log_set_file(FILE *outfile)
void void
qof_log_init(void) qof_log_init(void)
{ {
qof_log_init_filename(NULL); qof_log_init_filename(nullptr);
} }
static void static void
@ -180,14 +180,14 @@ log4glib_handler(const gchar *log_domain,
#endif #endif
; ;
const char *level_str = qof_log_level_to_string(level); const char *level_str = qof_log_level_to_string(level);
now = gnc_time (NULL); now = gnc_time (nullptr);
gnc_localtime_r (&now, &now_tm); gnc_localtime_r (&now, &now_tm);
qof_strftime(timestamp_buf, 9, format_24hour, &now_tm); qof_strftime(timestamp_buf, 9, format_24hour, &now_tm);
fprintf(fout, qof_logger_format, fprintf(fout, qof_logger_format,
timestamp_buf, timestamp_buf,
5, level_str, 5, level_str,
(log_domain == NULL ? "" : log_domain), (log_domain == nullptr ? "" : log_domain),
qof_log_num_spaces, "", qof_log_num_spaces, "",
message, message,
(g_str_has_suffix(message, "\n") ? "" : "\n")); (g_str_has_suffix(message, "\n") ? "" : "\n"));
@ -198,7 +198,7 @@ log4glib_handler(const gchar *log_domain,
else else
{ {
// chain // chain
previous_handler(log_domain, log_level, message, NULL); previous_handler(log_domain, log_level, message, nullptr);
} }
*/ */
} }
@ -217,7 +217,7 @@ qof_log_init_filename(const gchar* log_filename)
int fd; int fd;
gchar *fname; gchar *fname;
if (fout != NULL && fout != stderr && fout != stdout) if (fout != nullptr && fout != stderr && fout != stdout)
fclose(fout); fclose(fout);
fname = g_strconcat(log_filename, ".XXXXXX.log", nullptr); fname = g_strconcat(log_filename, ".XXXXXX.log", nullptr);
@ -251,7 +251,7 @@ qof_log_init_filename(const gchar* log_filename)
if (!fout) if (!fout)
fout = stderr; fout = stderr;
if (previous_handler == NULL) if (previous_handler == nullptr)
previous_handler = g_log_set_default_handler(log4glib_handler, modules); previous_handler = g_log_set_default_handler(log4glib_handler, modules);
if (warn_about_missing_permission) if (warn_about_missing_permission)
@ -266,24 +266,24 @@ qof_log_shutdown (void)
if (fout && fout != stderr && fout != stdout) if (fout && fout != stderr && fout != stdout)
{ {
fclose(fout); fclose(fout);
fout = NULL; fout = nullptr;
} }
if (function_buffer) if (function_buffer)
{ {
g_free(function_buffer); g_free(function_buffer);
function_buffer = NULL; function_buffer = nullptr;
} }
if (_modules != NULL) if (_modules != nullptr)
{ {
_modules = nullptr; _modules = nullptr;
} }
if (previous_handler != NULL) if (previous_handler != nullptr)
{ {
g_log_set_default_handler(previous_handler, NULL); g_log_set_default_handler(previous_handler, nullptr);
previous_handler = NULL; previous_handler = nullptr;
} }
} }
@ -376,11 +376,11 @@ qof_log_prettify (const char *name)
p = g_strstr_len (buffer, length, "("); p = g_strstr_len (buffer, length, "(");
if (p) *p = '\0'; if (p) *p = '\0';
begin = g_strrstr (buffer, "*"); begin = g_strrstr (buffer, "*");
if (begin == NULL) if (begin == nullptr)
begin = g_strrstr (buffer, " "); begin = g_strrstr (buffer, " ");
else if (* (begin + 1) == ' ') else if (* (begin + 1) == ' ')
++ begin; ++ begin;
if (begin != NULL) if (begin != nullptr)
p = begin + 1; p = begin + 1;
else else
p = buffer; p = buffer;
@ -415,7 +415,7 @@ void
qof_log_parse_log_config(const char *filename) qof_log_parse_log_config(const char *filename)
{ {
const gchar *levels_group = "levels", *output_group = "output"; const gchar *levels_group = "levels", *output_group = "output";
GError *err = NULL; GError *err = nullptr;
GKeyFile *conf = g_key_file_new(); GKeyFile *conf = g_key_file_new();
if (!g_key_file_load_from_file(conf, filename, G_KEY_FILE_NONE, &err)) if (!g_key_file_load_from_file(conf, filename, G_KEY_FILE_NONE, &err))
@ -432,18 +432,18 @@ qof_log_parse_log_config(const char *filename)
unsigned int key_idx; unsigned int key_idx;
gchar **levels; gchar **levels;
gint logger_max_name_length = 12; gint logger_max_name_length = 12;
gchar *str = NULL; gchar *str = nullptr;
levels = g_key_file_get_keys(conf, levels_group, &num_levels, NULL); levels = g_key_file_get_keys(conf, levels_group, &num_levels, nullptr);
for (key_idx = 0; key_idx < num_levels && levels[key_idx] != NULL; key_idx++) for (key_idx = 0; key_idx < num_levels && levels[key_idx] != nullptr; key_idx++)
{ {
QofLogLevel level; QofLogLevel level;
gchar *logger_name = NULL, *level_str = NULL; gchar *logger_name = nullptr, *level_str = nullptr;
logger_name = g_strdup(levels[key_idx]); logger_name = g_strdup(levels[key_idx]);
logger_max_name_length = MAX (logger_max_name_length, (gint) strlen (logger_name)); logger_max_name_length = MAX (logger_max_name_length, (gint) strlen (logger_name));
level_str = g_key_file_get_string(conf, levels_group, logger_name, NULL); level_str = g_key_file_get_string(conf, levels_group, logger_name, nullptr);
level = qof_log_level_from_string(level_str); level = qof_log_level_from_string(level_str);
DEBUG("setting log [%s] to level [%s=%d]", logger_name, level_str, level); DEBUG("setting log [%s] to level [%s=%d]", logger_name, level_str, level);
@ -468,8 +468,8 @@ qof_log_parse_log_config(const char *filename)
unsigned int output_idx; unsigned int output_idx;
gchar **outputs; gchar **outputs;
outputs = g_key_file_get_keys(conf, output_group, &num_outputs, NULL); outputs = g_key_file_get_keys(conf, output_group, &num_outputs, nullptr);
for (output_idx = 0; output_idx < num_outputs && outputs[output_idx] != NULL; output_idx++) for (output_idx = 0; output_idx < num_outputs && outputs[output_idx] != nullptr; output_idx++)
{ {
gchar *key = outputs[output_idx]; gchar *key = outputs[output_idx];
gchar *value; gchar *value;
@ -480,7 +480,7 @@ qof_log_parse_log_config(const char *filename)
continue; continue;
} }
value = g_key_file_get_string(conf, output_group, key, NULL); value = g_key_file_get_string(conf, output_group, key, nullptr);
DEBUG("setting [output].to=[%s]", value); DEBUG("setting [output].to=[%s]", value);
qof_log_init_filename_special(value); qof_log_init_filename_special(value);
g_free(value); g_free(value);

View File

@ -32,8 +32,8 @@
static QofLogModule log_module = QOF_MOD_OBJECT; static QofLogModule log_module = QOF_MOD_OBJECT;
static gboolean object_is_initialized = FALSE; static gboolean object_is_initialized = FALSE;
static GList *object_modules = NULL; static GList *object_modules = nullptr;
static GList *book_list = NULL; static GList *book_list = nullptr;
/* /*
* These getters are used in tests to reach static vars from outside * These getters are used in tests to reach static vars from outside
@ -66,15 +66,15 @@ qof_object_new_instance (QofIdTypeConst type_name, QofBook *book)
{ {
const QofObject *obj; const QofObject *obj;
if (!type_name) return NULL; if (!type_name) return nullptr;
obj = qof_object_lookup (type_name); obj = qof_object_lookup (type_name);
if (!obj) return NULL; if (!obj) return nullptr;
if (obj->create) if (obj->create)
return (obj->create (book)); return (obj->create (book));
return NULL; return nullptr;
} }
void qof_object_book_begin (QofBook *book) void qof_object_book_begin (QofBook *book)
@ -169,7 +169,7 @@ qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
const QofObject *obj; const QofObject *obj;
obj = qof_object_lookup(type_name); obj = qof_object_lookup(type_name);
if ((obj->create == NULL) || (obj->foreach == NULL)) if ((obj->create == nullptr) || (obj->foreach == nullptr))
{ {
if (warn) if (warn)
{ {
@ -222,7 +222,7 @@ do_prepend (QofInstance *qof_p, gpointer list_p)
void void
qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data) qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
{ {
GList *list = NULL; GList *list = nullptr;
GList *iter; GList *iter;
qof_object_foreach(type_name, book, do_prepend, &list); qof_object_foreach(type_name, book, do_prepend, &list);
@ -249,25 +249,25 @@ qof_object_printable (QofIdTypeConst type_name, gpointer obj)
{ {
const QofObject *b_obj; const QofObject *b_obj;
if (!type_name || !obj) return NULL; if (!type_name || !obj) return nullptr;
b_obj = qof_object_lookup (type_name); b_obj = qof_object_lookup (type_name);
if (!b_obj) return NULL; if (!b_obj) return nullptr;
if (b_obj->printable) if (b_obj->printable)
return (b_obj->printable (obj)); return (b_obj->printable (obj));
return NULL; return nullptr;
} }
const char * qof_object_get_type_label (QofIdTypeConst type_name) const char * qof_object_get_type_label (QofIdTypeConst type_name)
{ {
const QofObject *obj; const QofObject *obj;
if (!type_name) return NULL; if (!type_name) return nullptr;
obj = qof_object_lookup (type_name); obj = qof_object_lookup (type_name);
if (!obj) return NULL; if (!obj) return nullptr;
return (obj->type_label); return (obj->type_label);
} }
@ -285,9 +285,9 @@ void qof_object_shutdown (void)
g_return_if_fail (object_is_initialized == TRUE); g_return_if_fail (object_is_initialized == TRUE);
g_list_free (object_modules); g_list_free (object_modules);
object_modules = NULL; object_modules = nullptr;
g_list_free (book_list); g_list_free (book_list);
book_list = NULL; book_list = nullptr;
object_is_initialized = FALSE; object_is_initialized = FALSE;
} }
@ -324,9 +324,9 @@ const QofObject * qof_object_lookup (QofIdTypeConst name)
GList *iter; GList *iter;
const QofObject *obj; const QofObject *obj;
g_return_val_if_fail (object_is_initialized, NULL); g_return_val_if_fail (object_is_initialized, nullptr);
if (!name) return NULL; if (!name) return nullptr;
for (iter = object_modules; iter; iter = iter->next) for (iter = object_modules; iter; iter = iter->next)
{ {
@ -334,7 +334,7 @@ const QofObject * qof_object_lookup (QofIdTypeConst name)
if (!g_strcmp0 (obj->e_type, name)) if (!g_strcmp0 (obj->e_type, name))
return obj; return obj;
} }
return NULL; return nullptr;
} }
/* ========================= END OF FILE =================== */ /* ========================= END OF FILE =================== */

View File

@ -46,7 +46,7 @@ struct _QofQueryTerm
/* These values are filled in during "compilation" of the query /* These values are filled in during "compilation" of the query
* term, based upon the obj_name, param_name, and searched-for * term, based upon the obj_name, param_name, and searched-for
* object type. If conv_fcn is NULL, then we don't know how to * object type. If conv_fcn is nullptr, then we don't know how to
* convert types. * convert types.
*/ */
GSList * param_fcns; GSList * param_fcns;
@ -61,7 +61,7 @@ struct _QofQuerySort
/* These values are filled in during "compilation" of the query /* These values are filled in during "compilation" of the query
* term, based upon the obj_name, param_name, and searched-for * term, based upon the obj_name, param_name, and searched-for
* object type. If conv_fcn is NULL, then we don't know how to * object type. If conv_fcn is nullptr, then we don't know how to
* convert types. * convert types.
*/ */
gboolean use_default; gboolean use_default;
@ -113,8 +113,8 @@ typedef struct _QofQueryCB
/* initial_term will be owned by the new Query */ /* initial_term will be owned by the new Query */
static void query_init (QofQuery *q, QofQueryTerm *initial_term) static void query_init (QofQuery *q, QofQueryTerm *initial_term)
{ {
GList * _or_ = NULL; GList * _or_ = nullptr;
GList *_and_ = NULL; GList *_and_ = nullptr;
GHashTable *ht; GHashTable *ht;
if (initial_term) if (initial_term)
@ -147,7 +147,7 @@ static void query_init (QofQuery *q, QofQueryTerm *initial_term)
q->changed = 1; q->changed = 1;
q->max_results = -1; q->max_results = -1;
q->primary_sort.param_list = g_slist_prepend (static_cast<GSList*>(NULL), q->primary_sort.param_list = g_slist_prepend (static_cast<GSList*>(nullptr),
static_cast<void*>(const_cast<char*>(QUERY_DEFAULT_SORT))); static_cast<void*>(const_cast<char*>(QUERY_DEFAULT_SORT)));
q->primary_sort.increasing = TRUE; q->primary_sort.increasing = TRUE;
q->secondary_sort.increasing = TRUE; q->secondary_sort.increasing = TRUE;
@ -185,7 +185,7 @@ static void free_query_term (QofQueryTerm *qt)
static QofQueryTerm * copy_query_term (const QofQueryTerm *qt) static QofQueryTerm * copy_query_term (const QofQueryTerm *qt)
{ {
QofQueryTerm *new_qt; QofQueryTerm *new_qt;
if (!qt) return NULL; if (!qt) return nullptr;
new_qt = g_new0 (QofQueryTerm, 1); new_qt = g_new0 (QofQueryTerm, 1);
*new_qt = *qt; *new_qt = *qt;
@ -197,7 +197,7 @@ static QofQueryTerm * copy_query_term (const QofQueryTerm *qt)
static GList * copy_and_terms (const GList *and_terms) static GList * copy_and_terms (const GList *and_terms)
{ {
GList *_and_ = NULL; GList *_and_ = nullptr;
const GList *cur_and; const GList *cur_and;
for (cur_and = and_terms; cur_and; cur_and = cur_and->next) for (cur_and = and_terms; cur_and; cur_and = cur_and->next)
@ -211,7 +211,7 @@ static GList * copy_and_terms (const GList *and_terms)
static GList * static GList *
copy_or_terms(const GList * or_terms) copy_or_terms(const GList * or_terms)
{ {
GList * _or_ = NULL; GList * _or_ = nullptr;
const GList * cur_or; const GList * cur_or;
for (cur_or = or_terms; cur_or; cur_or = cur_or->next) for (cur_or = or_terms; cur_or; cur_or = cur_or->next)
@ -232,17 +232,17 @@ static void copy_sort (QofQuerySort *dst, const QofQuerySort *src)
static void free_sort (QofQuerySort *s) static void free_sort (QofQuerySort *s)
{ {
g_slist_free (s->param_list); g_slist_free (s->param_list);
s->param_list = NULL; s->param_list = nullptr;
g_slist_free (s->param_fcns); g_slist_free (s->param_fcns);
s->param_fcns = NULL; s->param_fcns = nullptr;
} }
static void free_members (QofQuery *q) static void free_members (QofQuery *q)
{ {
GList * cur_or; GList * cur_or;
if (q == NULL) return; if (q == nullptr) return;
for (cur_or = q->terms; cur_or; cur_or = cur_or->next) for (cur_or = q->terms; cur_or; cur_or = cur_or->next)
{ {
@ -252,11 +252,11 @@ static void free_members (QofQuery *q)
cur_and = static_cast<GList*>(cur_and->next)) cur_and = static_cast<GList*>(cur_and->next))
{ {
free_query_term(static_cast<QofQueryTerm*>(cur_and->data)); free_query_term(static_cast<QofQueryTerm*>(cur_and->data));
cur_and->data = NULL; cur_and->data = nullptr;
} }
g_list_free(static_cast<GList*>(cur_or->data)); g_list_free(static_cast<GList*>(cur_or->data));
cur_or->data = NULL; cur_or->data = nullptr;
} }
free_sort (&(q->primary_sort)); free_sort (&(q->primary_sort));
@ -264,19 +264,19 @@ static void free_members (QofQuery *q)
free_sort (&(q->tertiary_sort)); free_sort (&(q->tertiary_sort));
g_list_free(q->terms); g_list_free(q->terms);
q->terms = NULL; q->terms = nullptr;
g_list_free(q->books); g_list_free(q->books);
q->books = NULL; q->books = nullptr;
g_list_free(q->results); g_list_free(q->results);
q->results = NULL; q->results = nullptr;
} }
static int cmp_func (const QofQuerySort *sort, QofSortFunc default_sort, static int cmp_func (const QofQuerySort *sort, QofSortFunc default_sort,
const gconstpointer a, const gconstpointer b) const gconstpointer a, const gconstpointer b)
{ {
QofParam *param = NULL; QofParam *param = nullptr;
GSList *node; GSList *node;
gpointer conva, convb; gpointer conva, convb;
@ -377,7 +377,7 @@ check_object (const QofQuery *q, gpointer object)
if (qt->param_fcns && qt->pred_fcn) if (qt->param_fcns && qt->pred_fcn)
{ {
const GSList *node; const GSList *node;
QofParam *param = NULL; QofParam *param = nullptr;
gpointer conv_obj = object; gpointer conv_obj = object;
/* iterate through the conversions */ /* iterate through the conversions */
@ -413,7 +413,7 @@ check_object (const QofQuery *q, gpointer object)
* may want to get all objects, but in a particular sorted * may want to get all objects, but in a particular sorted
* order. * order.
*/ */
if (NULL == q->terms) return 1; if (nullptr == q->terms) return 1;
return 0; return 0;
} }
@ -421,19 +421,19 @@ check_object (const QofQuery *q, gpointer object)
* compile the list of parameter get-functions. Save the last valid * compile the list of parameter get-functions. Save the last valid
* parameter definition in "final" and return the list of functions. * parameter definition in "final" and return the list of functions.
* *
* returns NULL if the first parameter is bad (and final is unchanged). * returns nullptr if the first parameter is bad (and final is unchanged).
*/ */
static GSList * static GSList *
compile_params (QofQueryParamList *param_list, QofIdType start_obj, compile_params (QofQueryParamList *param_list, QofIdType start_obj,
QofParam const **final) QofParam const **final)
{ {
const QofParam *objDef = NULL; const QofParam *objDef = nullptr;
GSList *fcns = NULL; GSList *fcns = nullptr;
ENTER ("param_list=%p id=%s", param_list, start_obj); ENTER ("param_list=%p id=%s", param_list, start_obj);
g_return_val_if_fail (param_list, NULL); g_return_val_if_fail (param_list, nullptr);
g_return_val_if_fail (start_obj, NULL); g_return_val_if_fail (start_obj, nullptr);
g_return_val_if_fail (final, NULL); g_return_val_if_fail (final, nullptr);
for (; param_list; param_list = param_list->next) for (; param_list; param_list = param_list->next)
{ {
@ -460,15 +460,15 @@ compile_params (QofQueryParamList *param_list, QofIdType start_obj,
static void static void
compile_sort (QofQuerySort *sort, QofIdType obj) compile_sort (QofQuerySort *sort, QofIdType obj)
{ {
const QofParam *resObj = NULL; const QofParam *resObj = nullptr;
ENTER ("sort=%p id=%s params=%p", sort, obj, sort->param_list); ENTER ("sort=%p id=%s params=%p", sort, obj, sort->param_list);
sort->use_default = FALSE; sort->use_default = FALSE;
g_slist_free (sort->param_fcns); g_slist_free (sort->param_fcns);
sort->param_fcns = NULL; sort->param_fcns = nullptr;
sort->comp_fcn = NULL; sort->comp_fcn = nullptr;
sort->obj_cmp = NULL; sort->obj_cmp = nullptr;
/* An empty param_list implies "no sort" */ /* An empty param_list implies "no sort" */
if (!sort->param_list) if (!sort->param_list)
@ -494,7 +494,7 @@ compile_sort (QofQuerySort *sort, QofIdType obj)
sort->comp_fcn = qof_query_core_get_compare (resObj->param_type); sort->comp_fcn = qof_query_core_get_compare (resObj->param_type);
/* Next, perhaps this is an object compare, not a core type compare? */ /* Next, perhaps this is an object compare, not a core type compare? */
if (sort->comp_fcn == NULL) if (sort->comp_fcn == nullptr)
sort->obj_cmp = qof_class_get_default_sort (resObj->param_type); sort->obj_cmp = qof_class_get_default_sort (resObj->param_type);
} }
else if (!g_strcmp0 (static_cast<char*>(sort->param_list->data), else if (!g_strcmp0 (static_cast<char*>(sort->param_list->data),
@ -519,10 +519,10 @@ static void compile_terms (QofQuery *q)
and_ptr = static_cast<GList*>(and_ptr->next)) and_ptr = static_cast<GList*>(and_ptr->next))
{ {
QofQueryTerm* qt = static_cast<QofQueryTerm*>(and_ptr->data); QofQueryTerm* qt = static_cast<QofQueryTerm*>(and_ptr->data);
const QofParam* resObj = NULL; const QofParam* resObj = nullptr;
g_slist_free (qt->param_fcns); g_slist_free (qt->param_fcns);
qt->param_fcns = NULL; qt->param_fcns = nullptr;
/* Walk the parameter list of obtain the parameter functions */ /* Walk the parameter list of obtain the parameter functions */
qt->param_fcns = compile_params (qt->param_list, q->search_for, qt->param_fcns = compile_params (qt->param_list, q->search_for,
@ -535,7 +535,7 @@ static void compile_terms (QofQuery *q)
if (qt->param_fcns && resObj) if (qt->param_fcns && resObj)
qt->pred_fcn = qof_query_core_get_predicate (resObj->param_type); qt->pred_fcn = qof_query_core_get_predicate (resObj->param_type);
else else
qt->pred_fcn = NULL; qt->pred_fcn = nullptr;
} }
} }
@ -603,7 +603,7 @@ static int param_list_cmp (const QofQueryParamList *l1, const QofQueryParamList
static GList * merge_books (GList *l1, GList *l2) static GList * merge_books (GList *l1, GList *l2)
{ {
GList *res = NULL; GList *res = nullptr;
GList *node; GList *node;
res = g_list_copy (l1); res = g_list_copy (l1);
@ -633,7 +633,7 @@ query_free_compiled (gpointer key, gpointer value, gpointer not_used)
/* clear out any cached query_compilations */ /* clear out any cached query_compilations */
static void query_clear_compiles (QofQuery *q) static void query_clear_compiles (QofQuery *q)
{ {
g_hash_table_foreach_remove (q->be_compiled, query_free_compiled, NULL); g_hash_table_foreach_remove (q->be_compiled, query_free_compiled, nullptr);
} }
/********************************************************************/ /********************************************************************/
@ -642,12 +642,12 @@ static void query_clear_compiles (QofQuery *q)
QofQueryParamList * QofQueryParamList *
qof_query_build_param_list (char const *param, ...) qof_query_build_param_list (char const *param, ...)
{ {
QofQueryParamList *param_list = NULL; QofQueryParamList *param_list = nullptr;
char const *this_param; char const *this_param;
va_list ap; va_list ap;
if (!param) if (!param)
return NULL; return nullptr;
va_start (ap, param); va_start (ap, param);
@ -673,7 +673,7 @@ void qof_query_add_term (QofQuery *q, QofQueryParamList *param_list,
qs = qof_query_create (); qs = qof_query_create ();
query_init (qs, qt); query_init (qs, qt);
if (q->terms != NULL) if (q->terms != nullptr)
qr = qof_query_merge (q, qs, op); qr = qof_query_merge (q, qs, op);
else else
qr = qof_query_merge (q, qs, QOF_QUERY_OR); qr = qof_query_merge (q, qs, QOF_QUERY_OR);
@ -725,13 +725,13 @@ static GList * qof_query_run_internal (QofQuery *q,
void(*run_cb)(QofQueryCB*, gpointer), void(*run_cb)(QofQueryCB*, gpointer),
gpointer cb_arg) gpointer cb_arg)
{ {
GList *matching_objects = NULL; GList *matching_objects = nullptr;
int object_count = 0; int object_count = 0;
if (!q) return NULL; if (!q) return nullptr;
g_return_val_if_fail (q->search_for, NULL); g_return_val_if_fail (q->search_for, nullptr);
g_return_val_if_fail (q->books, NULL); g_return_val_if_fail (q->books, nullptr);
g_return_val_if_fail (run_cb, NULL); g_return_val_if_fail (run_cb, nullptr);
ENTER (" q=%p", q); ENTER (" q=%p", q);
/* XXX: Prioritize the query terms? */ /* XXX: Prioritize the query terms? */
@ -786,11 +786,11 @@ static GList * qof_query_run_internal (QofQuery *q,
/* mptr is set to the first node of what will be the new list */ /* mptr is set to the first node of what will be the new list */
mptr = g_list_nth(matching_objects, object_count - q->max_results); mptr = g_list_nth(matching_objects, object_count - q->max_results);
/* mptr should not be NULL, but let's be safe */ /* mptr should not be nullptr, but let's be safe */
if (mptr != NULL) if (mptr != nullptr)
{ {
if (mptr->prev != NULL) mptr->prev->next = NULL; if (mptr->prev != nullptr) mptr->prev->next = nullptr;
mptr->prev = NULL; mptr->prev = nullptr;
} }
g_list_free(matching_objects); g_list_free(matching_objects);
matching_objects = mptr; matching_objects = mptr;
@ -799,7 +799,7 @@ static GList * qof_query_run_internal (QofQuery *q,
{ {
/* q->max_results == 0 */ /* q->max_results == 0 */
g_list_free(matching_objects); g_list_free(matching_objects);
matching_objects = NULL; matching_objects = nullptr;
} }
} }
@ -846,7 +846,7 @@ static void qof_query_run_cb(QofQueryCB* qcb, gpointer cb_arg)
GList * qof_query_run (QofQuery *q) GList * qof_query_run (QofQuery *q)
{ {
/* Just a wrapper */ /* Just a wrapper */
return qof_query_run_internal(q, qof_query_run_cb, NULL); return qof_query_run_internal(q, qof_query_run_cb, nullptr);
} }
static void qof_query_run_subq_cb(QofQueryCB* qcb, gpointer cb_arg) static void qof_query_run_subq_cb(QofQueryCB* qcb, gpointer cb_arg)
@ -860,14 +860,14 @@ static void qof_query_run_subq_cb(QofQueryCB* qcb, gpointer cb_arg)
GList * GList *
qof_query_run_subquery (QofQuery *subq, const QofQuery* primaryq) qof_query_run_subquery (QofQuery *subq, const QofQuery* primaryq)
{ {
if (!subq) return NULL; if (!subq) return nullptr;
if (!primaryq) return NULL; if (!primaryq) return nullptr;
/* Make sure we're searching for the same thing */ /* Make sure we're searching for the same thing */
g_return_val_if_fail (subq->search_for, NULL); g_return_val_if_fail (subq->search_for, nullptr);
g_return_val_if_fail (primaryq->search_for, NULL); g_return_val_if_fail (primaryq->search_for, nullptr);
g_return_val_if_fail(!g_strcmp0(subq->search_for, primaryq->search_for), g_return_val_if_fail(!g_strcmp0(subq->search_for, primaryq->search_for),
NULL); nullptr);
/* Perform the subquery */ /* Perform the subquery */
return qof_query_run_internal(subq, qof_query_run_subq_cb, return qof_query_run_internal(subq, qof_query_run_subq_cb,
@ -878,7 +878,7 @@ GList *
qof_query_last_run (QofQuery *query) qof_query_last_run (QofQuery *query)
{ {
if (!query) if (!query)
return NULL; return nullptr;
return query->results; return query->results;
} }
@ -890,9 +890,9 @@ void qof_query_clear (QofQuery *query)
qof_query_destroy (q2); qof_query_destroy (q2);
g_list_free (query->books); g_list_free (query->books);
query->books = NULL; query->books = nullptr;
g_list_free (query->results); g_list_free (query->results);
query->results = NULL; query->results = nullptr;
query->changed = 1; query->changed = 1;
} }
@ -900,7 +900,7 @@ QofQuery * qof_query_create (void)
{ {
QofQuery *qp = g_new0 (QofQuery, 1); QofQuery *qp = g_new0 (QofQuery, 1);
qp->be_compiled = g_hash_table_new (g_direct_hash, g_direct_equal); qp->be_compiled = g_hash_table_new (g_direct_hash, g_direct_equal);
query_init (qp, NULL); query_init (qp, nullptr);
return qp; return qp;
} }
@ -920,7 +920,7 @@ QofQuery * qof_query_create_for (QofIdTypeConst obj_type)
{ {
QofQuery *q; QofQuery *q;
if (!obj_type) if (!obj_type)
return NULL; return nullptr;
q = qof_query_create (); q = qof_query_create ();
qof_query_search_for (q, obj_type); qof_query_search_for (q, obj_type);
return q; return q;
@ -968,7 +968,7 @@ GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param)
{ {
GList *_or_; GList *_or_;
GList *_and_; GList *_and_;
GSList *results = NULL; GSList *results = nullptr;
if (!q || !term_param) if (!q || !term_param)
return FALSE; return FALSE;
@ -1001,7 +1001,7 @@ QofQuery * qof_query_copy (QofQuery *q)
QofQuery *copy; QofQuery *copy;
GHashTable *ht; GHashTable *ht;
if (!q) return NULL; if (!q) return nullptr;
copy = qof_query_create (); copy = qof_query_create ();
ht = copy->be_compiled; ht = copy->be_compiled;
free_members (copy); free_members (copy);
@ -1039,7 +1039,7 @@ QofQuery * qof_query_invert (QofQuery *q)
int num_or_terms; int num_or_terms;
if (!q) if (!q)
return NULL; return nullptr;
num_or_terms = g_list_length(q->terms); num_or_terms = g_list_length(q->terms);
@ -1060,12 +1060,12 @@ QofQuery * qof_query_invert (QofQuery *q)
retval->changed = 1; retval->changed = 1;
aterms = static_cast<GList*>(g_list_nth_data(q->terms, 0)); aterms = static_cast<GList*>(g_list_nth_data(q->terms, 0));
new_oterm = NULL; new_oterm = nullptr;
for (cur = aterms; cur; cur = cur->next) for (cur = aterms; cur; cur = cur->next)
{ {
qt = copy_query_term(static_cast<QofQueryTerm*>(cur->data)); qt = copy_query_term(static_cast<QofQueryTerm*>(cur->data));
qt->invert = !(qt->invert); qt->invert = !(qt->invert);
new_oterm = g_list_append(NULL, qt); new_oterm = g_list_append(nullptr, qt);
retval->terms = g_list_prepend(retval->terms, new_oterm); retval->terms = g_list_prepend(retval->terms, new_oterm);
} }
retval->terms = g_list_reverse(retval->terms); retval->terms = g_list_reverse(retval->terms);
@ -1079,7 +1079,7 @@ QofQuery * qof_query_invert (QofQuery *q)
right->terms = copy_or_terms(g_list_nth(q->terms, 1)); right->terms = copy_or_terms(g_list_nth(q->terms, 1));
left = qof_query_create(); left = qof_query_create();
left->terms = g_list_append(NULL, left->terms = g_list_append(nullptr,
copy_and_terms(static_cast<GList*>(g_list_nth_data(q->terms, 0)))); copy_and_terms(static_cast<GList*>(g_list_nth_data(q->terms, 0))));
iright = qof_query_invert(right); iright = qof_query_invert(right);
@ -1110,7 +1110,7 @@ QofQuery *
qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op) qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
{ {
QofQuery * retval = NULL; QofQuery * retval = nullptr;
QofQuery * i1, * i2; QofQuery * i1, * i2;
QofQuery * t1, * t2; QofQuery * t1, * t2;
GList * i, * j; GList * i, * j;
@ -1121,7 +1121,7 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
if (q1->search_for && q2->search_for) if (q1->search_for && q2->search_for)
g_return_val_if_fail (g_strcmp0 (q1->search_for, q2->search_for) == 0, g_return_val_if_fail (g_strcmp0 (q1->search_for, q2->search_for) == 0,
NULL); nullptr);
search_for = (q1->search_for ? q1->search_for : q2->search_for); search_for = (q1->search_for ? q1->search_for : q2->search_for);
@ -1135,7 +1135,7 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
* so that the first term added to an empty query doesn't screw up. * so that the first term added to an empty query doesn't screw up.
*/ */
if ((QOF_QUERY_AND == op) && if ((QOF_QUERY_AND == op) &&
(q1->terms == NULL || q2->terms == NULL)) (q1->terms == nullptr || q2->terms == nullptr))
{ {
op = QOF_QUERY_OR; op = QOF_QUERY_OR;
} }
@ -1291,7 +1291,7 @@ void qof_query_add_guid_list_match (QofQuery *q, QofQueryParamList *param_list,
void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list, void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list,
const GncGUID *guid, QofQueryOp op) const GncGUID *guid, QofQueryOp op)
{ {
GList *g = NULL; GList *g = nullptr;
if (!q || !param_list) return; if (!q || !param_list) return;
@ -1306,7 +1306,7 @@ void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list,
void qof_query_set_book (QofQuery *q, QofBook *book) void qof_query_set_book (QofQuery *q, QofBook *book)
{ {
QofQueryParamList *slist = NULL; QofQueryParamList *slist = nullptr;
if (!q || !book) return; if (!q || !book) return;
/* Make sure this book is only in the list once */ /* Make sure this book is only in the list once */
@ -1321,7 +1321,7 @@ void qof_query_set_book (QofQuery *q, QofBook *book)
GList * qof_query_get_books (QofQuery *q) GList * qof_query_get_books (QofQuery *q)
{ {
if (!q) return NULL; if (!q) return nullptr;
return q->books; return q->books;
} }
@ -1360,27 +1360,27 @@ int qof_query_get_max_results (const QofQuery *q)
QofIdType qof_query_get_search_for (const QofQuery *q) QofIdType qof_query_get_search_for (const QofQuery *q)
{ {
if (!q) return NULL; if (!q) return nullptr;
return q->search_for; return q->search_for;
} }
GList * qof_query_get_terms (const QofQuery *q) GList * qof_query_get_terms (const QofQuery *q)
{ {
if (!q) return NULL; if (!q) return nullptr;
return q->terms; return q->terms;
} }
QofQueryParamList * qof_query_term_get_param_path (const QofQueryTerm *qt) QofQueryParamList * qof_query_term_get_param_path (const QofQueryTerm *qt)
{ {
if (!qt) if (!qt)
return NULL; return nullptr;
return qt->param_list; return qt->param_list;
} }
QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *qt) QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *qt)
{ {
if (!qt) if (!qt)
return NULL; return nullptr;
return qt->pdata; return qt->pdata;
} }
@ -1407,7 +1407,7 @@ void qof_query_get_sorts (QofQuery *q, QofQuerySort **primary,
QofQueryParamList * qof_query_sort_get_param_path (const QofQuerySort *qs) QofQueryParamList * qof_query_sort_get_param_path (const QofQuerySort *qs)
{ {
if (!qs) if (!qs)
return NULL; return nullptr;
return qs->param_list; return qs->param_list;
} }
@ -1533,8 +1533,8 @@ qof_query_print (QofQuery * query)
return; return;
} }
output = NULL; output = nullptr;
str = NULL; str = nullptr;
maxResults = qof_query_get_max_results (query); maxResults = qof_query_get_max_results (query);
output = qof_query_printSearchFor (query, output); output = qof_query_printSearchFor (query, output);
@ -1566,7 +1566,7 @@ qof_query_printOutput (GList * output)
DEBUG (" %s", line->str); DEBUG (" %s", line->str);
g_string_free (line, TRUE); g_string_free (line, TRUE);
line = NULL; line = nullptr;
} }
} }
@ -1582,7 +1582,7 @@ qof_query_printSearchFor (QofQuery * query, GList * output)
searchFor = qof_query_get_search_for (query); searchFor = qof_query_get_search_for (query);
gs = g_string_new ("Query Object Type: "); gs = g_string_new ("Query Object Type: ");
g_string_append (gs, (NULL == searchFor) ? "(null)" : searchFor); g_string_append (gs, (nullptr == searchFor) ? "(null)" : searchFor);
output = g_list_append (output, gs); output = g_list_append (output, gs);
return output; return output;
@ -1628,7 +1628,7 @@ qof_query_printTerms (QofQuery * query, GList * output)
static GList * static GList *
qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output) qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output)
{ {
QofQueryParamList *gsl, *n = NULL; QofQueryParamList *gsl, *n = nullptr;
gint curSort; gint curSort;
GString *gs = g_string_new ("Sort Parameters: "); GString *gs = g_string_new ("Sort Parameters: ");
@ -1699,7 +1699,7 @@ qof_query_printAndTerms (GList * terms, GList * output)
static GString * static GString *
qof_query_printParamPath (QofQueryParamList * parmList) qof_query_printParamPath (QofQueryParamList * parmList)
{ {
QofQueryParamList *list = NULL; QofQueryParamList *list = nullptr;
GString *gs = g_string_new ("Param List: "); GString *gs = g_string_new ("Param List: ");
g_string_append (gs, " "); g_string_append (gs, " ");
for (list = parmList; list; list = list->next) for (list = parmList; list; list = list->next)

View File

@ -90,31 +90,31 @@ static const char * query_choice_type = QOF_TYPE_CHOICE;
/* Tables for predicate storage and lookup */ /* Tables for predicate storage and lookup */
static gboolean initialized = FALSE; static gboolean initialized = FALSE;
static GHashTable *predTable = NULL; static GHashTable *predTable = nullptr;
static GHashTable *cmpTable = NULL; static GHashTable *cmpTable = nullptr;
static GHashTable *copyTable = NULL; static GHashTable *copyTable = nullptr;
static GHashTable *freeTable = NULL; static GHashTable *freeTable = nullptr;
static GHashTable *toStringTable = NULL; static GHashTable *toStringTable = nullptr;
static GHashTable *predEqualTable = NULL; static GHashTable *predEqualTable = nullptr;
#define COMPARE_ERROR -3 #define COMPARE_ERROR -3
#define PREDICATE_ERROR -2 #define PREDICATE_ERROR -2
#define VERIFY_PDATA(str) { \ #define VERIFY_PDATA(str) { \
g_return_if_fail (pd != NULL); \ g_return_if_fail (pd != nullptr); \
g_return_if_fail (pd->type_name == str || \ g_return_if_fail (pd->type_name == str || \
!g_strcmp0 (str, pd->type_name)); \ !g_strcmp0 (str, pd->type_name)); \
} }
#define VERIFY_PDATA_R(str) { \ #define VERIFY_PDATA_R(str) { \
g_return_val_if_fail (pd != NULL, NULL); \ g_return_val_if_fail (pd != nullptr, nullptr); \
g_return_val_if_fail (pd->type_name == str || \ g_return_val_if_fail (pd->type_name == str || \
!g_strcmp0 (str, pd->type_name), \ !g_strcmp0 (str, pd->type_name), \
NULL); \ nullptr); \
} }
#define VERIFY_PREDICATE(str) { \ #define VERIFY_PREDICATE(str) { \
g_return_val_if_fail (getter != NULL, PREDICATE_ERROR); \ g_return_val_if_fail (getter != nullptr, PREDICATE_ERROR); \
g_return_val_if_fail (getter->param_getfcn != NULL, PREDICATE_ERROR); \ g_return_val_if_fail (getter->param_getfcn != nullptr, PREDICATE_ERROR); \
g_return_val_if_fail (pd != NULL, PREDICATE_ERROR); \ g_return_val_if_fail (pd != nullptr, PREDICATE_ERROR); \
g_return_val_if_fail (pd->type_name == str || \ g_return_val_if_fail (pd->type_name == str || \
!g_strcmp0 (str, pd->type_name), \ !g_strcmp0 (str, pd->type_name), \
PREDICATE_ERROR); \ PREDICATE_ERROR); \
@ -220,7 +220,7 @@ qof_string_number_compare_func (gpointer a, gpointer b, gint options,
s1 = ((query_string_getter)getter->param_getfcn) (a, getter); s1 = ((query_string_getter)getter->param_getfcn) (a, getter);
s2 = ((query_string_getter)getter->param_getfcn) (b, getter); s2 = ((query_string_getter)getter->param_getfcn) (b, getter);
// Deal with NULL strings // Deal with nullptr strings
if (s1 == s2) return 0; if (s1 == s2) return 0;
if (!s1 && s2) return -1; if (!s1 && s2) return -1;
if (s1 && !s2) return 1; if (s1 && !s2) return 1;
@ -282,10 +282,10 @@ qof_query_string_predicate (QofQueryCompare how,
{ {
query_string_t pdata; query_string_t pdata;
g_return_val_if_fail (str, NULL); g_return_val_if_fail (str, nullptr);
// g_return_val_if_fail (*str != '\0', NULL); // g_return_val_if_fail (*str != '\0', nullptr);
g_return_val_if_fail (how == QOF_COMPARE_CONTAINS || how == QOF_COMPARE_NCONTAINS || g_return_val_if_fail (how == QOF_COMPARE_CONTAINS || how == QOF_COMPARE_NCONTAINS ||
how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, NULL); how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, nullptr);
pdata = g_new0 (query_string_def, 1); pdata = g_new0 (query_string_def, 1);
pdata->pd.type_name = query_string_type; pdata->pd.type_name = query_string_type;
@ -305,7 +305,7 @@ qof_query_string_predicate (QofQueryCompare how,
{ {
g_free(pdata->matchstring); g_free(pdata->matchstring);
g_free(pdata); g_free(pdata);
return NULL; return nullptr;
} }
pdata->is_regex = TRUE; pdata->is_regex = TRUE;
} }
@ -320,7 +320,7 @@ string_to_string (gpointer object, QofParam *getter)
res = ((query_string_getter)getter->param_getfcn)(object, getter); res = ((query_string_getter)getter->param_getfcn)(object, getter);
if (res) if (res)
return g_strdup (res); return g_strdup (res);
return NULL; return nullptr;
} }
/* QOF_TYPE_DATE =================================================== */ /* QOF_TYPE_DATE =================================================== */
@ -452,7 +452,7 @@ date_to_string (gpointer object, QofParam *getter)
if (tt != INT64_MAX) if (tt != INT64_MAX)
return qof_print_date (tt); return qof_print_date (tt);
return NULL; return nullptr;
} }
/* QOF_TYPE_NUMERIC ================================================= */ /* QOF_TYPE_NUMERIC ================================================= */
@ -595,7 +595,7 @@ guid_match_predicate (gpointer object, QofParam *getter,
{ {
query_guid_t pdata = (query_guid_t)pd; query_guid_t pdata = (query_guid_t)pd;
GList *node, *o_list; GList *node, *o_list;
const GncGUID *guid = NULL; const GncGUID *guid = nullptr;
VERIFY_PREDICATE (query_guid_type); VERIFY_PREDICATE (query_guid_type);
@ -620,15 +620,15 @@ guid_match_predicate (gpointer object, QofParam *getter,
} }
/* /*
* If o_list is NULL, we've walked the whole list without finding * If o_list is nullptr, we've walked the whole list without finding
* a match. Therefore break out now, the match has failed. * a match. Therefore break out now, the match has failed.
*/ */
if (o_list == NULL) if (o_list == nullptr)
break; break;
} }
/* /*
* The match is complete. If node == NULL then we've successfully * The match is complete. If node == nullptr then we've successfully
* found a match for all the guids in the predicate. Return * found a match for all the guids in the predicate. Return
* appropriately below. * appropriately below.
*/ */
@ -657,14 +657,14 @@ guid_match_predicate (gpointer object, QofParam *getter,
} }
/* Check to see if we found a match. If so, break now */ /* Check to see if we found a match. If so, break now */
if (node2 != NULL) if (node2 != nullptr)
break; break;
} }
g_list_free(o_list); g_list_free(o_list);
/* yea, node may point to an invalid location, but that's ok. /* yea, node may point to an invalid location, but that's ok.
* we're not _USING_ the value, just checking that it's non-NULL * we're not _USING_ the value, just checking that it's non-nullptr
*/ */
break; break;
@ -687,14 +687,14 @@ guid_match_predicate (gpointer object, QofParam *getter,
{ {
case QOF_GUID_MATCH_ANY: case QOF_GUID_MATCH_ANY:
case QOF_GUID_MATCH_LIST_ANY: case QOF_GUID_MATCH_LIST_ANY:
return (node != NULL); return (node != nullptr);
break; break;
case QOF_GUID_MATCH_NONE: case QOF_GUID_MATCH_NONE:
case QOF_GUID_MATCH_ALL: case QOF_GUID_MATCH_ALL:
return (node == NULL); return (node == nullptr);
break; break;
case QOF_GUID_MATCH_NULL: case QOF_GUID_MATCH_NULL:
return ((guid == NULL) || guid_equal(guid, guid_null())); return ((guid == nullptr) || guid_equal(guid, guid_null()));
break; break;
default: default:
PWARN ("bad match type"); PWARN ("bad match type");
@ -751,7 +751,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guid_list)
/* An empty list of guids is only valid when testing for a null GUID value */ /* An empty list of guids is only valid when testing for a null GUID value */
if (!guid_list) if (!guid_list)
g_return_val_if_fail (options == QOF_GUID_MATCH_NULL, NULL); g_return_val_if_fail (options == QOF_GUID_MATCH_NULL, nullptr);
pdata = g_new0 (query_guid_def, 1); pdata = g_new0 (query_guid_def, 1);
pdata->pd.how = QOF_COMPARE_EQUAL; pdata->pd.how = QOF_COMPARE_EQUAL;
@ -1111,7 +1111,7 @@ QofQueryPredData *
qof_query_boolean_predicate (QofQueryCompare how, gboolean val) qof_query_boolean_predicate (QofQueryCompare how, gboolean val)
{ {
query_boolean_t pdata; query_boolean_t pdata;
g_return_val_if_fail (how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, NULL); g_return_val_if_fail (how == QOF_COMPARE_EQUAL || how == QOF_COMPARE_NEQ, nullptr);
pdata = g_new0 (query_boolean_def, 1); pdata = g_new0 (query_boolean_def, 1);
pdata->pd.type_name = query_boolean_type; pdata->pd.type_name = query_boolean_type;
@ -1196,7 +1196,7 @@ QofQueryPredData *
qof_query_char_predicate (QofCharMatch options, const char *chars) qof_query_char_predicate (QofCharMatch options, const char *chars)
{ {
query_char_t pdata; query_char_t pdata;
g_return_val_if_fail (chars, NULL); g_return_val_if_fail (chars, nullptr);
pdata = g_new0 (query_char_def, 1); pdata = g_new0 (query_char_def, 1);
pdata->pd.type_name = query_char_type; pdata->pd.type_name = query_char_type;
pdata->pd.how = QOF_COMPARE_EQUAL; pdata->pd.how = QOF_COMPARE_EQUAL;
@ -1225,7 +1225,7 @@ collect_match_predicate (gpointer object, QofParam *getter,
pdata = (query_coll_t)pd; pdata = (query_coll_t)pd;
VERIFY_PREDICATE (query_collect_type); VERIFY_PREDICATE (query_collect_type);
guid = NULL; guid = nullptr;
switch (pdata->options) switch (pdata->options)
{ {
case QOF_GUID_MATCH_ALL : case QOF_GUID_MATCH_ALL :
@ -1242,7 +1242,7 @@ collect_match_predicate (gpointer object, QofParam *getter,
break; break;
} }
} }
if (o_list == NULL) if (o_list == nullptr)
{ {
break; break;
} }
@ -1262,7 +1262,7 @@ collect_match_predicate (gpointer object, QofParam *getter,
break; break;
} }
} }
if (node2 != NULL) if (node2 != nullptr)
{ {
break; break;
} }
@ -1286,18 +1286,18 @@ collect_match_predicate (gpointer object, QofParam *getter,
case QOF_GUID_MATCH_ANY : case QOF_GUID_MATCH_ANY :
case QOF_GUID_MATCH_LIST_ANY : case QOF_GUID_MATCH_LIST_ANY :
{ {
return (node != NULL); return (node != nullptr);
break; break;
} }
case QOF_GUID_MATCH_NONE : case QOF_GUID_MATCH_NONE :
case QOF_GUID_MATCH_ALL : case QOF_GUID_MATCH_ALL :
{ {
return (node == NULL); return (node == nullptr);
break; break;
} }
case QOF_GUID_MATCH_NULL : case QOF_GUID_MATCH_NULL :
{ {
return ((guid == NULL) || guid_equal(guid, guid_null())); return ((guid == nullptr) || guid_equal(guid, guid_null()));
break; break;
} }
default : default :
@ -1328,7 +1328,7 @@ collect_free_pdata (QofQueryPredData *pd)
query_coll_t pdata; query_coll_t pdata;
GList *node; GList *node;
node = NULL; node = nullptr;
pdata = (query_coll_t) pd; pdata = (query_coll_t) pd;
VERIFY_PDATA (query_collect_type); VERIFY_PDATA (query_collect_type);
for (node = pdata->guids; node; node = node->next) for (node = pdata->guids; node; node = node->next)
@ -1380,14 +1380,14 @@ qof_query_collect_predicate (QofGuidMatch options, QofCollection *coll)
{ {
query_coll_t pdata; query_coll_t pdata;
g_return_val_if_fail (coll, NULL); g_return_val_if_fail (coll, nullptr);
pdata = g_new0 (query_coll_def, 1); pdata = g_new0 (query_coll_def, 1);
pdata->pd.type_name = query_collect_type; pdata->pd.type_name = query_collect_type;
pdata->options = options; pdata->options = options;
qof_collection_foreach(coll, query_collect_cb, pdata); qof_collection_foreach(coll, query_collect_cb, pdata);
if (NULL == pdata->guids) if (nullptr == pdata->guids)
{ {
return NULL; return nullptr;
} }
return ((QofQueryPredData*)pdata); return ((QofQueryPredData*)pdata);
} }
@ -1400,7 +1400,7 @@ choice_match_predicate (gpointer object, QofParam *getter,
{ {
query_choice_t pdata = (query_choice_t)pd; query_choice_t pdata = (query_choice_t)pd;
GList *node, *o_list; GList *node, *o_list;
const GncGUID *guid = NULL; const GncGUID *guid = nullptr;
VERIFY_PREDICATE (query_choice_type); VERIFY_PREDICATE (query_choice_type);
@ -1425,15 +1425,15 @@ choice_match_predicate (gpointer object, QofParam *getter,
} }
/* /*
* If o_list is NULL, we've walked the whole list without finding * If o_list is nullptr, we've walked the whole list without finding
* a match. Therefore break out now, the match has failed. * a match. Therefore break out now, the match has failed.
*/ */
if (o_list == NULL) if (o_list == nullptr)
break; break;
} }
/* /*
* The match is complete. If node == NULL then we've successfully * The match is complete. If node == nullptr then we've successfully
* found a match for all the guids in the predicate. Return * found a match for all the guids in the predicate. Return
* appropriately below. * appropriately below.
*/ */
@ -1455,7 +1455,7 @@ choice_match_predicate (gpointer object, QofParam *getter,
break; break;
} }
if (node2 != NULL) if (node2 != nullptr)
break; break;
} }
@ -1481,14 +1481,14 @@ choice_match_predicate (gpointer object, QofParam *getter,
{ {
case QOF_GUID_MATCH_ANY: case QOF_GUID_MATCH_ANY:
case QOF_GUID_MATCH_LIST_ANY: case QOF_GUID_MATCH_LIST_ANY:
return (node != NULL); return (node != nullptr);
break; break;
case QOF_GUID_MATCH_NONE: case QOF_GUID_MATCH_NONE:
case QOF_GUID_MATCH_ALL: case QOF_GUID_MATCH_ALL:
return (node == NULL); return (node == nullptr);
break; break;
case QOF_GUID_MATCH_NULL: case QOF_GUID_MATCH_NULL:
return ((guid == NULL) || guid_equal(guid, guid_null())); return ((guid == nullptr) || guid_equal(guid, guid_null()));
break; break;
default: default:
PWARN ("bad match type"); PWARN ("bad match type");
@ -1543,7 +1543,7 @@ qof_query_choice_predicate (QofGuidMatch options, GList *guid_list)
query_choice_t pdata; query_choice_t pdata;
GList *node; GList *node;
if (NULL == guid_list) return NULL; if (nullptr == guid_list) return nullptr;
pdata = g_new0 (query_choice_def, 1); pdata = g_new0 (query_choice_def, 1);
pdata->pd.how = QOF_COMPARE_EQUAL; pdata->pd.how = QOF_COMPARE_EQUAL;
@ -1645,8 +1645,8 @@ static void init_tables (void)
numeric_predicate_equal numeric_predicate_equal
}, },
{ {
QOF_TYPE_GUID, guid_match_predicate, NULL, QOF_TYPE_GUID, guid_match_predicate, nullptr,
guid_copy_predicate, guid_free_pdata, NULL, guid_copy_predicate, guid_free_pdata, nullptr,
guid_predicate_equal guid_predicate_equal
}, },
{ {
@ -1676,12 +1676,12 @@ static void init_tables (void)
}, },
{ {
QOF_TYPE_COLLECT, collect_match_predicate, collect_compare_func, QOF_TYPE_COLLECT, collect_match_predicate, collect_compare_func,
collect_copy_predicate, collect_free_pdata, NULL, collect_copy_predicate, collect_free_pdata, nullptr,
collect_predicate_equal collect_predicate_equal
}, },
{ {
QOF_TYPE_CHOICE, choice_match_predicate, NULL, QOF_TYPE_CHOICE, choice_match_predicate, nullptr,
choice_copy_predicate, choice_free_pdata, NULL, choice_predicate_equal choice_copy_predicate, choice_free_pdata, nullptr, choice_predicate_equal
}, },
}; };
@ -1702,7 +1702,7 @@ static QueryPredicateCopyFunc
qof_query_copy_predicate (QofType type) qof_query_copy_predicate (QofType type)
{ {
QueryPredicateCopyFunc rc; QueryPredicateCopyFunc rc;
g_return_val_if_fail (type, NULL); g_return_val_if_fail (type, nullptr);
rc = reinterpret_cast<QueryPredicateCopyFunc>(g_hash_table_lookup (copyTable, type)); rc = reinterpret_cast<QueryPredicateCopyFunc>(g_hash_table_lookup (copyTable, type));
return rc; return rc;
} }
@ -1710,7 +1710,7 @@ qof_query_copy_predicate (QofType type)
static QueryPredDataFree static QueryPredDataFree
qof_query_predicate_free (QofType type) qof_query_predicate_free (QofType type)
{ {
g_return_val_if_fail (type, NULL); g_return_val_if_fail (type, nullptr);
return reinterpret_cast<QueryPredDataFree>(g_hash_table_lookup (freeTable, type)); return reinterpret_cast<QueryPredDataFree>(g_hash_table_lookup (freeTable, type));
} }
@ -1750,14 +1750,14 @@ void qof_query_core_shutdown (void)
QofQueryPredicateFunc QofQueryPredicateFunc
qof_query_core_get_predicate (QofType type) qof_query_core_get_predicate (QofType type)
{ {
g_return_val_if_fail (type, NULL); g_return_val_if_fail (type, nullptr);
return reinterpret_cast<QofQueryPredicateFunc>(g_hash_table_lookup (predTable, type)); return reinterpret_cast<QofQueryPredicateFunc>(g_hash_table_lookup (predTable, type));
} }
QofCompareFunc QofCompareFunc
qof_query_core_get_compare (QofType type) qof_query_core_get_compare (QofType type)
{ {
g_return_val_if_fail (type, NULL); g_return_val_if_fail (type, nullptr);
return reinterpret_cast<QofCompareFunc>(g_hash_table_lookup (cmpTable, type)); return reinterpret_cast<QofCompareFunc>(g_hash_table_lookup (cmpTable, type));
} }
@ -1778,8 +1778,8 @@ qof_query_core_predicate_copy (const QofQueryPredData *pdata)
{ {
QueryPredicateCopyFunc copy; QueryPredicateCopyFunc copy;
g_return_val_if_fail (pdata, NULL); g_return_val_if_fail (pdata, nullptr);
g_return_val_if_fail (pdata->type_name, NULL); g_return_val_if_fail (pdata->type_name, nullptr);
copy = qof_query_copy_predicate (pdata->type_name); copy = qof_query_copy_predicate (pdata->type_name);
return (copy (pdata)); return (copy (pdata));
@ -1791,12 +1791,12 @@ qof_query_core_to_string (QofType type, gpointer object,
{ {
QueryToString toString; QueryToString toString;
g_return_val_if_fail (type, NULL); g_return_val_if_fail (type, nullptr);
g_return_val_if_fail (object, NULL); g_return_val_if_fail (object, nullptr);
g_return_val_if_fail (getter, NULL); g_return_val_if_fail (getter, nullptr);
toString = reinterpret_cast<QueryToString>(g_hash_table_lookup (toStringTable, type)); toString = reinterpret_cast<QueryToString>(g_hash_table_lookup (toStringTable, type));
g_return_val_if_fail (toString, NULL); g_return_val_if_fail (toString, nullptr);
return toString (object, getter); return toString (object, getter);
} }

View File

@ -471,7 +471,7 @@ test_gnc_account_list_name_violations (Fixture *fixture, gconstpointer pData)
{ {
auto log_level = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL); auto log_level = static_cast<GLogLevelFlags>(G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL);
auto log_domain = "gnc.engine"; auto log_domain = "gnc.engine";
auto msg = ": assertion 'separator != NULL' failed"; auto msg = ": assertion 'separator != nullptr' failed";
auto check = test_error_struct_new(log_domain, log_level, msg); auto check = test_error_struct_new(log_domain, log_level, msg);
GList *results, *res_iter; GList *results, *res_iter;
auto sep = ":"; auto sep = ":";

View File

@ -414,7 +414,7 @@ test_xaccSplitEqual (Fixture *fixture, gconstpointer pData)
{ {
Split *split1 = xaccSplitCloneNoKvp (fixture->split); Split *split1 = xaccSplitCloneNoKvp (fixture->split);
Split *split2 = xaccDupeSplit (fixture->split); Split *split2 = xaccDupeSplit (fixture->split);
gchar *msg01 = "[xaccSplitEqual] one is NULL"; gchar *msg01 = "[xaccSplitEqual] one is nullptr";
gchar *msg02 = "[xaccSplitEqual] GUIDs differ"; gchar *msg02 = "[xaccSplitEqual] GUIDs differ";
gchar *msg03; gchar *msg03;
gchar *msg04 = "[xaccSplitEqual] actions differ: foo vs bar"; gchar *msg04 = "[xaccSplitEqual] actions differ: foo vs bar";
@ -423,7 +423,7 @@ test_xaccSplitEqual (Fixture *fixture, gconstpointer pData)
G_GNUC_UNUSED gchar *msg07 = "[xaccSplitEqual] reconciled date differs"; G_GNUC_UNUSED gchar *msg07 = "[xaccSplitEqual] reconciled date differs";
G_GNUC_UNUSED gchar *msg08 = "[xaccSplitEqual] amounts differ: foo vs bar"; G_GNUC_UNUSED gchar *msg08 = "[xaccSplitEqual] amounts differ: foo vs bar";
gchar *msg10 = "[xaccSplitEqual] transactions differ"; gchar *msg10 = "[xaccSplitEqual] transactions differ";
gchar *msg11 = "[xaccTransEqual] one is NULL"; gchar *msg11 = "[xaccTransEqual] one is nullptr";
gchar *msg12 = "[xaccSplitEqualCheckBal] balances differ: 321/1000 vs 0/1"; gchar *msg12 = "[xaccSplitEqualCheckBal] balances differ: 321/1000 vs 0/1";
gchar *msg13 = "[xaccSplitEqualCheckBal] cleared balances differ: 321/1000 vs 0/1"; gchar *msg13 = "[xaccSplitEqualCheckBal] cleared balances differ: 321/1000 vs 0/1";
gchar *msg14 = "[xaccSplitEqualCheckBal] reconciled balances differ: 321/1000 vs 0/1"; gchar *msg14 = "[xaccSplitEqualCheckBal] reconciled balances differ: 321/1000 vs 0/1";

View File

@ -753,7 +753,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
Transaction *txn1 = xaccTransClone (txn0); Transaction *txn1 = xaccTransClone (txn0);
const GncGUID *guid_f_txn = qof_instance_get_guid (txn0); const GncGUID *guid_f_txn = qof_instance_get_guid (txn0);
gchar entered[DATE_BUF_SIZE], posted[DATE_BUF_SIZE]; gchar entered[DATE_BUF_SIZE], posted[DATE_BUF_SIZE];
auto msg1 = "[xaccTransEqual] one is NULL"; auto msg1 = "[xaccTransEqual] one is nullptr";
gchar *msg2 = NULL; gchar *msg2 = NULL;
auto cleanup_fmt = "[trans_cleanup_commit] get rid of rollback trans=%p"; auto cleanup_fmt = "[trans_cleanup_commit] get rid of rollback trans=%p";
gchar split_guid0[GUID_ENCODING_LENGTH + 1]; gchar split_guid0[GUID_ENCODING_LENGTH + 1];