The Gnome Chemistry Utils  0.14.0
xml-utils.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * xml-utils.h
6  *
7  * Copyright (C) 2002-2009 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 
26 #ifndef GCU_XML_UTILS_H
27 #define GCU_XML_UTILS_H
28 
29 #include <libxml/parser.h>
30 #include "chemistry.h"
31 #include <goffice/goffice.h>
32 
33 namespace gcu {
34 
50 xmlNodePtr FindNodeByNameAndId (xmlNodePtr node, const char* name, const char* id = NULL);
51 
65 bool ReadPosition (xmlNodePtr node, const char* id, double* x, double* y, double* z = NULL);
79 bool WritePosition (xmlDocPtr xml, xmlNodePtr node, const char* id, double x, double y, double z = 0.0);
80 
94 bool ReadColor (xmlNodePtr node, const char* id, float* red, float* green, float* blue, float* alpha = NULL);
109 bool WriteColor (xmlDocPtr xml, xmlNodePtr node, const char* id, double red, double green, double blue, double alpha = 1.0);
110 
117 GOColor ReadColor (xmlNodePtr node);
118 
124 void WriteColor (xmlNodePtr node, GOColor color);
125 
135 bool ReadRadius (xmlNodePtr node, GcuAtomicRadius& radius);
136 
146 bool WriteRadius (xmlDocPtr xml, xmlNodePtr node, const GcuAtomicRadius& radius);
147 
157 char const *GetStaticScale (char *buf);
158 
167  void WriteFloat (xmlNodePtr node, char const *name, double value);
168 
179 bool ReadFloat (xmlNodePtr node, char const *name, double &value, double default_value = 0.);
180 
188 void WriteInt (xmlNodePtr node, char const *name, int value);
189 
200 bool ReadInt (xmlNodePtr node, char const *name, int &value, int default_value = 0);
201 
210 void WriteDate (xmlNodePtr node, char const *name, GDate const *date);
211 
222 bool ReadDate (xmlNodePtr node, char const *name, GDate *date);
223 
224 
225 } // namespace gcu
226 
227 #endif // GCU_XML_UTILS_H