GnuCash  5.6-150-g038405b370+
xml-helpers.h
1 /********************************************************************\
2  * This program is free software; you can redistribute it and/or *
3  * modify it under the terms of the GNU General Public License as *
4  * published by the Free Software Foundation; either version 2 of *
5  * the License, or (at your option) any later version. *
6  * *
7  * This program is distributed in the hope that it will be useful, *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10  * GNU General Public License for more details. *
11  * *
12  * You should have received a copy of the GNU General Public License*
13  * along with this program; if not, contact: *
14  * *
15  * Free Software Foundation Voice: +1-617-542-5942 *
16  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17  * Boston, MA 02110-1301, USA gnu@gnu.org *
18  * *
19 \********************************************************************/
20 
21 
22 /* xml-helpers.h
23  * Miscellaneous bogus helper routines.
24  */
25 
26 static inline void
27 maybe_add_int (xmlNodePtr ptr, const char* tag, gint val)
28 {
29  if (val)
30  xmlAddChild (ptr, int_to_dom_tree (tag, val));
31 }
32 
33 static inline void
34 maybe_add_numeric (xmlNodePtr ptr, const char* tag, gnc_numeric val)
35 {
36  if (!gnc_numeric_zero_p (val))
37  xmlAddChild (ptr, gnc_numeric_to_dom_tree (tag, &val));
38 }
39 
40 static inline void
41 maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
42 {
43  if (str && *str)
44  xmlAddChild (ptr, text_to_dom_tree (tag, str));
45 }
46 
47 static inline void
48 maybe_add_guid (xmlNodePtr ptr, const char* tag, QofInstance* inst)
49 {
50  if (inst)
51  xmlAddChild (ptr, guid_to_dom_tree (tag,
52  qof_instance_get_guid (inst)));
53 }
54 
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.