From 2b7c1430e13465756df96ed0a38d21bf3410c901 Mon Sep 17 00:00:00 2001 From: Chris Shoemaker Date: Sat, 31 Dec 2005 22:28:42 +0000 Subject: [PATCH] Constify the AccountGroup variables where possible in Group.[ch] git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12228 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Group.c | 40 ++++++++++++++++++++-------------------- src/engine/Group.h | 30 +++++++++++++++--------------- src/engine/GroupP.h | 2 +- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/engine/Group.c b/src/engine/Group.c index a6309d557f..18fd21ff50 100644 --- a/src/engine/Group.c +++ b/src/engine/Group.c @@ -126,8 +126,8 @@ xaccSetAccountGroup (QofBook *book, AccountGroup *grp) \********************************************************************/ gboolean -xaccGroupEqual(AccountGroup *ga, - AccountGroup *gb, +xaccGroupEqual(const AccountGroup *ga, + const AccountGroup *gb, gboolean check_guids) { GList *na; @@ -250,7 +250,7 @@ xaccAccountGroupDestroy (AccountGroup *grp) \********************************************************************/ QofBook * -xaccGroupGetBook (AccountGroup *group) +xaccGroupGetBook (const AccountGroup *group) { if (!group) return NULL; return group->book; @@ -341,7 +341,7 @@ xaccGroupMarkNotSaved (AccountGroup *grp) \********************************************************************/ gboolean -xaccGroupNotSaved (AccountGroup *grp) +xaccGroupNotSaved (const AccountGroup *grp) { GList *node; @@ -365,7 +365,7 @@ xaccGroupNotSaved (AccountGroup *grp) \********************************************************************/ int -xaccGroupGetNumSubAccounts (AccountGroup *grp) +xaccGroupGetNumSubAccounts (const AccountGroup *grp) { GList *node; int num_acc; @@ -389,7 +389,7 @@ xaccGroupGetNumSubAccounts (AccountGroup *grp) \********************************************************************/ static void -xaccPrependAccounts (AccountGroup *grp, GList **accounts_p) +xaccPrependAccounts (const AccountGroup *grp, GList **accounts_p) { GList *node; @@ -406,7 +406,7 @@ xaccPrependAccounts (AccountGroup *grp, GList **accounts_p) } AccountList * -xaccGroupGetSubAccounts (AccountGroup *grp) +xaccGroupGetSubAccounts (const AccountGroup *grp) { GList *accounts = NULL; @@ -418,7 +418,7 @@ xaccGroupGetSubAccounts (AccountGroup *grp) } AccountList * -xaccGroupGetAccountList (AccountGroup *grp) +xaccGroupGetAccountList (const AccountGroup *grp) { if (!grp) return NULL; @@ -430,9 +430,9 @@ xaccGroupGetAccountList (AccountGroup *grp) \********************************************************************/ AccountGroup * -xaccGroupGetRoot (AccountGroup * grp) +xaccGroupGetRoot (const AccountGroup * grp) { - AccountGroup * root = NULL; + const AccountGroup * root = NULL; /* find the root of the account group structure */ while (grp) @@ -448,7 +448,7 @@ xaccGroupGetRoot (AccountGroup * grp) grp = NULL; } - return root; + return (AccountGroup*)root; } AccountGroup * @@ -462,7 +462,7 @@ xaccAccountGetRoot (const Account * acc) \********************************************************************/ Account * -xaccGetAccountFromName (AccountGroup *grp, const char * name) +xaccGetAccountFromName (const AccountGroup *grp, const char * name) { GList *node; @@ -499,7 +499,7 @@ xaccGetAccountFromName (AccountGroup *grp, const char * name) \********************************************************************/ Account * -xaccGetAccountFromFullName (AccountGroup *grp, +xaccGetAccountFromFullName (const AccountGroup *grp, const char *name, const char separator) { @@ -577,7 +577,7 @@ xaccGetAccountFromFullName (AccountGroup *grp, \********************************************************************/ Account * -xaccGetPeerAccountFromName (Account *acc, const char * name) +xaccGetPeerAccountFromName (const Account *acc, const char * name) { AccountGroup * root; Account *peer_acc; @@ -599,7 +599,7 @@ xaccGetPeerAccountFromName (Account *acc, const char * name) \********************************************************************/ Account * -xaccGetPeerAccountFromFullName (Account *acc, const char * name, +xaccGetPeerAccountFromFullName (const Account *acc, const char * name, const char separator) { AccountGroup * root; @@ -955,7 +955,7 @@ xaccGroupMergeAccounts (AccountGroup *grp) \********************************************************************/ int -xaccGroupGetNumAccounts (AccountGroup *grp) +xaccGroupGetNumAccounts (const AccountGroup *grp) { if (!grp) return 0; @@ -963,7 +963,7 @@ xaccGroupGetNumAccounts (AccountGroup *grp) } Account * -xaccGroupGetAccount (AccountGroup *grp, int i) +xaccGroupGetAccount (const AccountGroup *grp, int i) { if (!grp) return NULL; @@ -971,7 +971,7 @@ xaccGroupGetAccount (AccountGroup *grp, int i) } Account * -xaccGroupGetParentAccount (AccountGroup * grp) +xaccGroupGetParentAccount (const AccountGroup * grp) { if (!grp) return NULL; @@ -982,7 +982,7 @@ xaccGroupGetParentAccount (AccountGroup * grp) \********************************************************************/ int -xaccGroupGetDepth (AccountGroup *grp) +xaccGroupGetDepth (const AccountGroup *grp) { GList *node; int depth = 0; @@ -1217,7 +1217,7 @@ xaccGroupForEachAccount (AccountGroup *grp, /* ============================================================== */ QofBackend * -xaccGroupGetBackend (AccountGroup *grp) +xaccGroupGetBackend (const AccountGroup *grp) { grp = xaccGroupGetRoot (grp); if (!grp || !grp->book) return NULL; diff --git a/src/engine/Group.h b/src/engine/Group.h index 21bf5c6e24..02cdbcc5d6 100644 --- a/src/engine/Group.h +++ b/src/engine/Group.h @@ -73,7 +73,7 @@ void xaccAccountGroupDestroy (AccountGroup *grp); #define gnc_book_get_group xaccGetAccountGroup /** Return the book to which this account belongs */ -QofBook * xaccGroupGetBook (AccountGroup *group); +QofBook * xaccGroupGetBook (const AccountGroup *group); /** Compare two account groups @@ -82,7 +82,7 @@ groups have different numbers of accounts. @return TRUE if the two account groups are equal, FALSE otherwise. */ -gboolean xaccGroupEqual(AccountGroup *a, AccountGroup *b, +gboolean xaccGroupEqual(const AccountGroup *a, const AccountGroup *b, gboolean check_guids); /** @} */ @@ -105,7 +105,7 @@ void xaccAccountGroupCommitEdit (AccountGroup *grp); * hasn't been saved. XXX this should be moved to private header file, this is not a public routine! */ -gboolean xaccGroupNotSaved (AccountGroup *grp); +gboolean xaccGroupNotSaved (const AccountGroup *grp); /** The xaccGroupMarkSaved() subroutine will mark * the entire group as having been saved, including @@ -172,42 +172,42 @@ void xaccAccountInsertSubAccount (Account *parent, Account *child); /** The xaccGroupGetNumSubAccounts() subroutine returns the number * of accounts, including subaccounts, in the account group */ -int xaccGroupGetNumSubAccounts (AccountGroup *grp); +int xaccGroupGetNumSubAccounts (const AccountGroup *grp); /** The xaccGroupGetNumAccounts() subroutine returns the number * of accounts in the indicated group only (children not counted). */ -int xaccGroupGetNumAccounts (AccountGroup *grp); +int xaccGroupGetNumAccounts (const AccountGroup *grp); /** The xaccGroupGetDepth() subroutine returns the length of the * longest tree branch. Each link between an account and its * (non-null) children counts as one unit of length. */ -int xaccGroupGetDepth (AccountGroup *grp); +int xaccGroupGetDepth (const AccountGroup *grp); /** @} */ /** @name Getting Accounts and Subaccounts @{ */ /** DOCUMENT ME! is this routine deprecated? XXX using index is weird! */ -Account * xaccGroupGetAccount (AccountGroup *group, int index); +Account * xaccGroupGetAccount (const AccountGroup *group, int index); /** The xaccGroupGetSubAccounts() subroutine returns an list of the accounts, * including subaccounts, in the account group. The returned list * should be freed with g_list_free() when no longer needed. */ -AccountList * xaccGroupGetSubAccounts (AccountGroup *grp); +AccountList * xaccGroupGetSubAccounts (const AccountGroup *grp); /** The xaccGroupGetAccountList() subroutines returns only the immediate * children of the account group. The returned list should *not* * be freed by the caller. */ -AccountList * xaccGroupGetAccountList (AccountGroup *grp); +AccountList * xaccGroupGetAccountList (const AccountGroup *grp); /** The xaccGroupGetRoot() subroutine will find the topmost * (root) group to which this group belongs. */ -AccountGroup * xaccGroupGetRoot (AccountGroup *grp); +AccountGroup * xaccGroupGetRoot (const AccountGroup *grp); /** The xaccGetAccountRoot() subroutine will find the topmost * (root) group to which this account belongs. @@ -217,7 +217,7 @@ AccountGroup * xaccAccountGetRoot (const Account *account); /** The xaccGroupGetParentAccount() subroutine returns the parent * account of the group, or NULL. */ -Account * xaccGroupGetParentAccount (AccountGroup *group); +Account * xaccGroupGetParentAccount (const AccountGroup *group); /** @} */ @@ -229,13 +229,13 @@ Account * xaccGroupGetParentAccount (AccountGroup *group); * in the indicated AccountGroup group. It returns NULL if the * account was not found. */ -Account *xaccGetAccountFromName (AccountGroup *group, const char *name); +Account *xaccGetAccountFromName (const AccountGroup *group, const char *name); /** The xaccGetAccountFromFullName() subroutine works like * xaccGetAccountFromName, but uses fully-qualified names * using the given separator. */ -Account *xaccGetAccountFromFullName (AccountGroup *group, +Account *xaccGetAccountFromFullName (const AccountGroup *group, const char *name, const char separator); @@ -244,13 +244,13 @@ Account *xaccGetAccountFromFullName (AccountGroup *group, * in the same AccountGroup anchor group. It returns NULL if the * account was not found. */ -Account *xaccGetPeerAccountFromName (Account *account, const char *name); +Account *xaccGetPeerAccountFromName (const Account *account, const char *name); /** The xaccGetPeerAccountFromFullName() subroutine works like * xaccGetPeerAccountFromName, but uses fully-qualified * names using the given separator. */ -Account *xaccGetPeerAccountFromFullName (Account *acc, +Account *xaccGetPeerAccountFromFullName (const Account *acc, const char * name, const char separator); diff --git a/src/engine/GroupP.h b/src/engine/GroupP.h index f3c4e7dac7..4226c985e7 100644 --- a/src/engine/GroupP.h +++ b/src/engine/GroupP.h @@ -96,7 +96,7 @@ void xaccCollSetAccountGroup (QofCollection *col, AccountGroup *grp); * The xaccGroupGetBackend() subroutine will find the * persistent-data storage backend associated with this account group. */ -QofBackend * xaccGroupGetBackend (AccountGroup *group); +QofBackend * xaccGroupGetBackend (const AccountGroup *group); gboolean xaccGroupRegister (void);