GnuCash c935c2f+
Loading...
Searching...
No Matches
io-utils.cpp
1/********************************************************************\
2 * io-utils.c -- implementation for gnucash file i/o utils *
3 * *
4 * Copyright (C) 2001 James LewisMoss <dres@debian.org> *
5 * *
6 * This program is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU General Public License as *
8 * published by the Free Software Foundation; either version 2 of *
9 * the License, or (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License*
17 * along with this program; if not, contact: *
18 * *
19 * Free Software Foundation Voice: +1-617-542-5942 *
20 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21 * Boston, MA 02110-1301, USA gnu@gnu.org *
22 * *
23\********************************************************************/
24#include <glib.h>
25
26#include <config.h>
27
28#include <stdio.h>
29
30#include "gnc-xml.h"
31#include "io-utils.h"
32#include "sixtp.h"
33
34static gboolean
35write_one_account (FILE* out,
36 Account* account,
37 sixtp_gdv2* gd,
38 gboolean allow_incompat)
39{
40 xmlNodePtr accnode;
41
42 accnode =
43 gnc_account_dom_tree_create (account, gd && gd->exporting, allow_incompat);
44
45 xmlElemDump (out, NULL, accnode);
46 xmlFreeNode (accnode);
47
48 g_return_val_if_fail(gd, FALSE);
49
50 if (ferror (out) || fprintf (out, "\n") < 0)
51 return FALSE;
52
53 gd->counter.accounts_loaded++;
54 sixtp_run_callback (gd, "account");
55 return TRUE;
56}
57
58gboolean
59write_account_tree (FILE* out, Account* root, sixtp_gdv2* gd)
60{
61 GList* descendants, *node;
62 gboolean allow_incompat = TRUE;
63 gboolean success = TRUE;
64
65 if (allow_incompat)
66 if (!write_one_account (out, root, gd, allow_incompat))
67 return FALSE;
68
69 descendants = gnc_account_get_descendants (root);
70 for (node = descendants; node; node = g_list_next (node))
71 {
72 if (!write_one_account (out, static_cast<Account*> (node->data),
73 gd, allow_incompat))
74 {
75 success = FALSE;
76 break;
77 }
78 }
79
80 g_list_free (descendants);
81 return success;
82}
83
84gboolean
85write_accounts (FILE* out, QofBook* book, sixtp_gdv2* gd)
86{
87 return write_account_tree (out, gnc_book_get_root_account (book), gd);
88}
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
Definition Account.cpp:3044
STRUCTS.
QofBook reference.
Definition qofbook-p.hpp:47