mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
James LewisMoss's patch.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3661 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
a24407162c
commit
a1a95e9cdd
25
ChangeLog
25
ChangeLog
@ -1,3 +1,28 @@
|
||||
2001-02-15 James LewisMoss <jimdres@mindspring.com>
|
||||
|
||||
* src/engine/Account.h: Add prototype for SetSlots.
|
||||
|
||||
* src/engine/Account.c (xaccAccountSetSlots): add func.
|
||||
|
||||
* src/test/test-dom-converters1.c (main): Add return_value
|
||||
handling to better be a "check"able program.
|
||||
|
||||
* src/test/test-date-converting.c (main): Add return_value
|
||||
handling to better be a "check"able program.
|
||||
|
||||
* src/engine/kvp_frame.c (kvp_frame_get_frame): refactor to use
|
||||
glist func.
|
||||
(kvp_frame_parse_slash_path): extract from slashpath func
|
||||
(kvp_frame_get_frame_slash): refactor to use gslist func
|
||||
|
||||
* src/test/test-dom-converters1.c
|
||||
(test_dom_tree_to_commodity_ref): Use no_engine version.
|
||||
|
||||
* src/engine/sixtp-dom-parsers.c
|
||||
(dom_tree_to_commodity_ref_no_engine): rename func.
|
||||
(dom_tree_to_commodity_ref): Add func to do complete commodity
|
||||
creation including adding to engine cache.
|
||||
|
||||
2001-02-14 James LewisMoss <jimdres@mindspring.com>
|
||||
|
||||
* src/test/test-dom-converters1.c (Repository): fix mem leak.
|
||||
|
@ -442,6 +442,17 @@ xaccAccountGetSlots(Account * account) {
|
||||
return(account->kvp_data);
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetSlots(Account *account, kvp_frame *frame)
|
||||
{
|
||||
if(account->kvp_data)
|
||||
{
|
||||
kvp_frame_delete (account->kvp_data);
|
||||
}
|
||||
account->kvp_data = frame;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
@ -134,6 +134,7 @@ void xaccAccountCommitEdit (Account *account);
|
||||
void xaccAccountDestroy (Account *account);
|
||||
|
||||
kvp_frame * xaccAccountGetSlots (Account *account);
|
||||
void xaccAccountSetSlots(Account *account, kvp_frame *frame);
|
||||
|
||||
/*
|
||||
* The xaccAccountGetGUID() subroutine will return the
|
||||
|
@ -293,49 +293,6 @@ kvp_frame_set_slot_path_gslist (kvp_frame *frame,
|
||||
|
||||
/* ============================================================ */
|
||||
|
||||
kvp_frame *
|
||||
kvp_frame_get_frame (kvp_frame *frame, const char *first_key, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *key;
|
||||
|
||||
if (!frame || !first_key)
|
||||
return frame;
|
||||
|
||||
va_start (ap, first_key);
|
||||
|
||||
key = first_key;
|
||||
|
||||
while (TRUE) {
|
||||
kvp_value *value;
|
||||
|
||||
/* get the frame assoc with key, or create it if needed */
|
||||
value = kvp_frame_get_slot (frame, key);
|
||||
if (!value) {
|
||||
kvp_frame *new_frame = kvp_frame_new ();
|
||||
kvp_value *frame_value = kvp_value_new_frame (new_frame);
|
||||
|
||||
kvp_frame_set_slot_nc (frame, key, frame_value);
|
||||
|
||||
value = kvp_frame_get_slot (frame, key);
|
||||
if (!value)
|
||||
break; /* error, should never occur */
|
||||
}
|
||||
|
||||
frame = kvp_value_get_frame (value);
|
||||
if (!frame)
|
||||
break; /* error, should never occur */
|
||||
|
||||
key = va_arg (ap, const char *);
|
||||
if (!key) {
|
||||
break; /* the normal exit to this routine. */
|
||||
}
|
||||
}
|
||||
|
||||
va_end (ap);
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
kvp_frame *
|
||||
kvp_frame_get_frame_gslist (kvp_frame *frame, GSList *key_path)
|
||||
@ -375,42 +332,93 @@ kvp_frame_get_frame_gslist (kvp_frame *frame, GSList *key_path)
|
||||
}
|
||||
|
||||
kvp_frame *
|
||||
kvp_frame_get_frame_slash (kvp_frame *frame, const char *key_path)
|
||||
kvp_frame_get_frame (kvp_frame *frame, const char *first_key, ...)
|
||||
{
|
||||
char *root, *key, *next;
|
||||
if (!frame || !key_path)
|
||||
va_list ap;
|
||||
const char *key;
|
||||
GSList *lst;
|
||||
kvp_frame *ret;
|
||||
|
||||
if (!frame || !first_key)
|
||||
return frame;
|
||||
|
||||
va_start (ap, first_key);
|
||||
|
||||
key = first_key;
|
||||
|
||||
lst = g_slist_alloc();
|
||||
|
||||
while (TRUE) {
|
||||
g_slist_append(lst, key);
|
||||
|
||||
key = va_arg (ap, const char *);
|
||||
if (!key) {
|
||||
break; /* the normal exit to this routine. */
|
||||
}
|
||||
}
|
||||
va_end (ap);
|
||||
|
||||
ret = kvp_frame_get_frame_gslist(frame, lst);
|
||||
g_slist_free(lst);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GSList*
|
||||
kvp_frame_parse_slash_path(const char *key_path)
|
||||
{
|
||||
char *root, *key, *next;
|
||||
GSList *ret;
|
||||
|
||||
ret = g_slist_alloc();
|
||||
|
||||
root = g_strdup (key_path);
|
||||
key = root;
|
||||
key --;
|
||||
|
||||
while (key) {
|
||||
kvp_value *value;
|
||||
|
||||
key ++;
|
||||
while ('/' == *key) { key++; }
|
||||
if (0x0 == *key) break; /* trailing slash */
|
||||
next = strchr (key, '/');
|
||||
if (next) *next = 0x0;
|
||||
|
||||
value = kvp_frame_get_slot (frame, key);
|
||||
if (!value) {
|
||||
kvp_frame *new_frame = kvp_frame_new ();
|
||||
kvp_value *frame_value = kvp_value_new_frame (new_frame);
|
||||
|
||||
kvp_frame_set_slot_nc (frame, key, frame_value);
|
||||
value = kvp_frame_get_slot (frame, key);
|
||||
if (!value) break; /* error - should never happen */
|
||||
}
|
||||
|
||||
frame = kvp_value_get_frame (value);
|
||||
if (!frame) break; /* error - should never happen */
|
||||
|
||||
g_slist_append(ret, g_strdup(key));
|
||||
|
||||
key = next;
|
||||
}
|
||||
g_free(root);
|
||||
return frame;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
kvp_frame_sp_free_string(gpointer *data, gpointer *ignored)
|
||||
{
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static void
|
||||
kvp_frame_delete_slash_path_gslist(GSList *lst)
|
||||
{
|
||||
g_slist_foreach(lst, kvp_frame_sp_free_string, NULL);
|
||||
g_slist_free(lst);
|
||||
}
|
||||
|
||||
kvp_frame *
|
||||
kvp_frame_get_frame_slash (kvp_frame *frame, const char *key_path)
|
||||
{
|
||||
char *root, *key, *next;
|
||||
GSList *lst;
|
||||
kvp_frame *ret;
|
||||
|
||||
if (!frame || !key_path)
|
||||
return frame;
|
||||
|
||||
lst = kvp_frame_parse_slash_path(key_path);
|
||||
ret = kvp_frame_get_frame_gslist(frame, lst);
|
||||
kvp_frame_delete_slash_path_gslist(lst);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ============================================================ */
|
||||
|
@ -221,7 +221,7 @@ dom_tree_to_timespec(xmlNodePtr node)
|
||||
}
|
||||
|
||||
gnc_commodity *
|
||||
dom_tree_to_commodity_ref(xmlNodePtr node)
|
||||
dom_tree_to_commodity_ref_no_engine(xmlNodePtr node)
|
||||
{
|
||||
/* Turn something like this
|
||||
|
||||
@ -283,6 +283,20 @@ dom_tree_to_commodity_ref(xmlNodePtr node)
|
||||
return c;
|
||||
}
|
||||
|
||||
gnc_commodity*
|
||||
dom_tree_to_commodity_ref(xmlNodePtr node)
|
||||
{
|
||||
gnc_commodity* daref;
|
||||
gnc_commodity *ret;
|
||||
|
||||
daref = dom_tree_to_commodity_ref_no_engine(node);
|
||||
ret = associate_commodity_ref_with_engine_commodity(daref);
|
||||
|
||||
g_free(daref);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gnc_commodity *
|
||||
associate_commodity_ref_with_engine_commodity(gnc_commodity *com)
|
||||
{
|
||||
|
@ -19,6 +19,7 @@ GUID* dom_tree_to_guid(xmlNodePtr node);
|
||||
gnc_commodity* dom_tree_to_commodity_ref(xmlNodePtr node);
|
||||
gnc_commodity* associate_commodity_ref_with_engine_commodity(
|
||||
gnc_commodity *com);
|
||||
gnc_commodity *dom_tree_to_commodity_ref_no_engine(xmlNodePtr node);
|
||||
|
||||
Timespec* dom_tree_to_timespec(xmlNodePtr node);
|
||||
gnc_numeric* dom_tree_to_gnc_numeric(xmlNodePtr node);
|
||||
|
Loading…
Reference in New Issue
Block a user