data hiding for groups

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@680 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-03-20 08:52:07 +00:00
parent 24eaffd8fe
commit a621175a5b
3 changed files with 36 additions and 19 deletions

View File

@ -937,7 +937,7 @@ xaccResetWriteFlags (AccountGroup *grp)
int n=0; int n=0;
Account *acc; Account *acc;
Split *s; Split *s;
acc = getAccount (grp,i) ; acc = xaccGroupGetAccount (grp,i) ;
/* recursively do sub-accounts */ /* recursively do sub-accounts */
xaccResetWriteFlags (acc->children); xaccResetWriteFlags (acc->children);
@ -1033,7 +1033,7 @@ writeGroup (int fd, AccountGroup *grp )
for( i=0; i<grp->numAcc; i++ ) for( i=0; i<grp->numAcc; i++ )
{ {
err = writeAccount( fd, getAccount(grp,i) ); err = writeAccount( fd, xaccGroupGetAccount(grp,i) );
if( -1 == err ) if( -1 == err )
return err; return err;
} }

View File

@ -132,22 +132,6 @@ xaccAccountGroupNotSaved (AccountGroup *grp)
return 0; return 0;
} }
/********************************************************************\
\********************************************************************/
Account *
getAccount( AccountGroup *grp, int num )
{
if( grp != NULL )
{
if( (0 <= num) && (num < grp->numAcc) )
return grp->account[num];
else
return NULL;
}
else
return NULL;
}
/********************************************************************\ /********************************************************************\
* Get the number of accounts, including subaccounts * * Get the number of accounts, including subaccounts *
\********************************************************************/ \********************************************************************/
@ -589,4 +573,28 @@ xaccConsolidateGrpTransactions (AccountGroup *grp)
} }
} }
/********************************************************************\
\********************************************************************/
int
xaccGroupGetNumAccounts (AccountGroup *grp)
{
return (grp->numAcc);
}
Account *
xaccGroupGetAccount (AccountGroup *grp, int i)
{
if (!grp) return NULL;
if (!(grp->account)) return NULL;
if((0>i) || (i >= grp->numAcc)) return NULL;
return (grp->account[i]);
}
double
xaccGroupGetBalance (AccountGroup * grp)
{
return (grp->balance);
}
/****************** END OF FILE *************************************/ /****************** END OF FILE *************************************/

View File

@ -56,7 +56,6 @@ void xaccMergeAccounts (AccountGroup *grp);
int xaccAccountGroupNotSaved (AccountGroup *grp); int xaccAccountGroupNotSaved (AccountGroup *grp);
void xaccAccountGroupMarkSaved (AccountGroup *grp); void xaccAccountGroupMarkSaved (AccountGroup *grp);
Account *getAccount( AccountGroup *grp, int num );
Account *removeAccount( AccountGroup *grp, int num ); Account *removeAccount( AccountGroup *grp, int num );
int insertAccount( AccountGroup *grp, Account *acc ); int insertAccount( AccountGroup *grp, Account *acc );
@ -85,6 +84,12 @@ int xaccInsertSubAccount( Account *parent, Account *child );
*/ */
int xaccGetNumAccounts (AccountGroup *grp); int xaccGetNumAccounts (AccountGroup *grp);
/*
* The xaccGroupGetNumAccounts() subroutine returns the number
* of accounts in the indicated group only (children not counted).
*/
int xaccGroupGetNumAccounts (AccountGroup *grp);
/* /*
* The xaccGetAccountFromID() subroutine fetches the account * The xaccGetAccountFromID() subroutine fetches the account
* with the indicated account id from the collection of accounts * with the indicated account id from the collection of accounts
@ -136,6 +141,10 @@ AccountGroup * xaccGetAccountRoot (Account *);
void xaccConsolidateGrpTransactions (AccountGroup *); void xaccConsolidateGrpTransactions (AccountGroup *);
/* #define getAccount xaccGroupGetAccount */
Account * xaccGroupGetAccount (AccountGroup *, int);
double xaccGroupGetBalance (AccountGroup *);
/** GLOBALS *********************************************************/ /** GLOBALS *********************************************************/
extern AccountGroup *topgroup; extern AccountGroup *topgroup;