[Gnucash-changes] r12228 - gnucash/trunk/src/engine - Constify the AccountGroup variables where possible in Group.[ch]

Chris Shoemaker chris at cvs.gnucash.org
Sat Dec 31 17:28:42 EST 2005


Author: chris
Date: 2005-12-31 17:28:42 -0500 (Sat, 31 Dec 2005)
New Revision: 12228
Trac: http://svn.gnucash.org/trac/changeset/12228

Modified:
   gnucash/trunk/src/engine/Group.c
   gnucash/trunk/src/engine/Group.h
   gnucash/trunk/src/engine/GroupP.h
Log:
Constify the AccountGroup variables where possible in Group.[ch]


Modified: gnucash/trunk/src/engine/Group.c
===================================================================
--- gnucash/trunk/src/engine/Group.c	2005-12-31 21:17:32 UTC (rev 12227)
+++ gnucash/trunk/src/engine/Group.c	2005-12-31 22:28:42 UTC (rev 12228)
@@ -126,8 +126,8 @@
 \********************************************************************/
 
 gboolean
-xaccGroupEqual(AccountGroup *ga,
-               AccountGroup *gb,
+xaccGroupEqual(const AccountGroup *ga,
+               const AccountGroup *gb,
                gboolean check_guids)
 {
   GList *na;
@@ -250,7 +250,7 @@
 \********************************************************************/
 
 QofBook *
-xaccGroupGetBook (AccountGroup *group)
+xaccGroupGetBook (const AccountGroup *group)
 {
   if (!group) return NULL;
   return group->book;
@@ -341,7 +341,7 @@
 \********************************************************************/
 
 gboolean
-xaccGroupNotSaved (AccountGroup *grp)
+xaccGroupNotSaved (const AccountGroup *grp)
 {
   GList *node;
 
@@ -365,7 +365,7 @@
 \********************************************************************/
 
 int
-xaccGroupGetNumSubAccounts (AccountGroup *grp)
+xaccGroupGetNumSubAccounts (const AccountGroup *grp)
 {
   GList *node;
   int num_acc;
@@ -389,7 +389,7 @@
 \********************************************************************/
 
 static void
-xaccPrependAccounts (AccountGroup *grp, GList **accounts_p)
+xaccPrependAccounts (const AccountGroup *grp, GList **accounts_p)
 {
   GList *node;
 
@@ -406,7 +406,7 @@
 }
 
 AccountList *
-xaccGroupGetSubAccounts (AccountGroup *grp)
+xaccGroupGetSubAccounts (const AccountGroup *grp)
 {
   GList *accounts = NULL;
 
@@ -418,7 +418,7 @@
 }
 
 AccountList *
-xaccGroupGetAccountList (AccountGroup *grp)
+xaccGroupGetAccountList (const AccountGroup *grp)
 {
   if (!grp) return NULL;
 
@@ -430,9 +430,9 @@
 \********************************************************************/
 
 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 @@
       grp = NULL;
   }
 
-  return root;
+  return (AccountGroup*)root;
 }
 
 AccountGroup *
@@ -462,7 +462,7 @@
 \********************************************************************/
 
 Account *
-xaccGetAccountFromName (AccountGroup *grp, const char * name)
+xaccGetAccountFromName (const AccountGroup *grp, const char * name)
 {
   GList *node;
 
@@ -499,7 +499,7 @@
 \********************************************************************/
 
 Account *
-xaccGetAccountFromFullName (AccountGroup *grp,
+xaccGetAccountFromFullName (const AccountGroup *grp,
                             const char *name,
                             const char separator)
 {
@@ -577,7 +577,7 @@
 \********************************************************************/
 
 Account *
-xaccGetPeerAccountFromName (Account *acc, const char * name)
+xaccGetPeerAccountFromName (const Account *acc, const char * name)
 {
   AccountGroup * root;
   Account *peer_acc;
@@ -599,7 +599,7 @@
 \********************************************************************/
 
 Account *
-xaccGetPeerAccountFromFullName (Account *acc, const char * name,
+xaccGetPeerAccountFromFullName (const Account *acc, const char * name,
                                 const char separator)
 {
   AccountGroup * root;
@@ -955,7 +955,7 @@
 \********************************************************************/
 
 int     
-xaccGroupGetNumAccounts (AccountGroup *grp)
+xaccGroupGetNumAccounts (const AccountGroup *grp)
 {
    if (!grp) return 0;
 
@@ -963,7 +963,7 @@
 }
 
 Account *
-xaccGroupGetAccount (AccountGroup *grp, int i)
+xaccGroupGetAccount (const AccountGroup *grp, int i)
 {
    if (!grp) return NULL;
 
@@ -971,7 +971,7 @@
 }
 
 Account *
-xaccGroupGetParentAccount (AccountGroup * grp)
+xaccGroupGetParentAccount (const AccountGroup * grp)
 {
   if (!grp) return NULL;
 
@@ -982,7 +982,7 @@
 \********************************************************************/
 
 int     
-xaccGroupGetDepth (AccountGroup *grp)
+xaccGroupGetDepth (const AccountGroup *grp)
 {
   GList *node;
   int depth = 0;
@@ -1217,7 +1217,7 @@
 /* ============================================================== */
 
 QofBackend *
-xaccGroupGetBackend (AccountGroup *grp)
+xaccGroupGetBackend (const AccountGroup *grp)
 {
   grp = xaccGroupGetRoot (grp);
   if (!grp || !grp->book) return NULL;

Modified: gnucash/trunk/src/engine/Group.h
===================================================================
--- gnucash/trunk/src/engine/Group.h	2005-12-31 21:17:32 UTC (rev 12227)
+++ gnucash/trunk/src/engine/Group.h	2005-12-31 22:28:42 UTC (rev 12228)
@@ -73,7 +73,7 @@
 #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 @@
 
 @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 @@
  *    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 @@
 /** 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 @@
 /** 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 @@
  *    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 @@
  *    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);
 

Modified: gnucash/trunk/src/engine/GroupP.h
===================================================================
--- gnucash/trunk/src/engine/GroupP.h	2005-12-31 21:17:32 UTC (rev 12227)
+++ gnucash/trunk/src/engine/GroupP.h	2005-12-31 22:28:42 UTC (rev 12228)
@@ -96,7 +96,7 @@
  * 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);
 



More information about the gnucash-changes mailing list