From e01b217c43d7b4d2bf1e4fe3e1947dcaddb1fd63 Mon Sep 17 00:00:00 2001 From: James LewisMoss Date: Thu, 10 May 2001 16:12:02 +0000 Subject: [PATCH] * src/engine/Account.c (xaccCloneAccountSimple): new func. (xaccAccountEnumAsString): change arg to GNCAccountType. * src/engine/Account.c (xaccAccountGetChildren): Add children group if ->children == NULL. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4151 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 25 ++++++++++++++++++++++++- src/engine/Account.h | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/engine/Account.c b/src/engine/Account.c index 52b198cc7d..dc86395066 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -135,6 +135,27 @@ xaccMallocAccount (void) return acc; } +Account * +xaccCloneAccountSimple(const Account *from) +{ + Account *ret; + + ret = xaccMallocAccount(); + xaccInitAccount(ret); + + ret->type = from->type; + + ret->accountName = g_strdup(from->accountName); + ret->accountCode = g_strdup(from->accountCode); + ret->description = g_strdup(from->description); + + ret->kvp_data = kvp_frame_copy(from->kvp_data); + + ret->currency = from->currency; + + return ret; +} + /********************************************************************\ \********************************************************************/ @@ -1273,6 +1294,8 @@ AccountGroup * xaccAccountGetChildren (Account *acc) { if (!acc) return NULL; + if (acc->children == NULL) + acc->children = xaccMallocAccountGroup (); return (acc->children); } @@ -1755,7 +1778,7 @@ xaccAccountHasAncestor (Account *account, Account * ancestor) #define GNC_RETURN_ENUM_AS_STRING(x) case (x): return #x; char * -xaccAccountTypeEnumAsString(int type) { +xaccAccountTypeEnumAsString(GNCAccountType type) { switch(type) { GNC_RETURN_ENUM_AS_STRING(NO_TYPE); GNC_RETURN_ENUM_AS_STRING(BANK); diff --git a/src/engine/Account.h b/src/engine/Account.h index a0b6d78216..277917c02f 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -110,7 +110,7 @@ char * xaccAccountGetTypeStr (int type); /* GUI names */ /* Conversion routines for the account types to/from strings. Critical for the text communication mechanisms. i.e. INCOME -> "INCOME". */ -char * xaccAccountTypeEnumAsString (int type); +char * xaccAccountTypeEnumAsString (GNCAccountType type); gboolean xaccAccountStringToType (const char* str, int *type); GNCAccountType xaccAccountStringToEnum (const char* str); @@ -129,6 +129,7 @@ gboolean xaccAccountEqual(Account *a, Account* b, gboolean check_guids); * (by calling xaccAccountBeginEdit()) before calling this routine. */ Account *xaccMallocAccount (void); +Account * xaccCloneAccountSimple(const Account *from); void xaccAccountBeginEdit (Account *account); void xaccAccountCommitEdit (Account *account); void xaccAccountDestroy (Account *account);