1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Class : Ecriture d'un fichier XML
22 #ifndef __XML_WRITER_H
23 #define __XML_WRITER_H
25 #include "hexa_base.hxx"
35 ~XmlWriter () { closeXml () ; }
37 int openXml (string& nom) { return openXml (nom.c_str()); }
38 int openXml (cpchar nom=NULL);
40 cpchar getXml () { return xml_buffer.c_str(); }
42 void openMark (cpchar balise); // <Balise ..
43 void addMark (cpchar balise, bool jump=true); // <Balise> + eol
44 void closeMark (bool jump=false); // </Balise> ou />
47 void addAttribute (cpchar attrib, cpchar valeur); // attrib="valeur"
48 void addAttribute (cpchar attrib, int valeur);
49 void addAttribute (cpchar attrib, double valeur);
50 void addAttribute (cpchar attrib, string& valeur);
54 void alaLigne (bool force=false);
55 void ecrire (cpchar mot);
56 void ecrire (string& mot) { ecrire (mot.c_str()) ; }
57 void addMot (cpchar mot);
60 enum {xml_decal=3, xml_size=80};
65 std::string xml_buffer;
66 std::stack <std::string, std::vector <std::string> > pile_mark;
67 std::stack <int, std::vector <int> > pile_etat;
69 // ====================================================== addAttribute (I)
70 inline void XmlWriter::addAttribute (cpchar attrib, int valeur)
73 sprintf (buffer, "%d", valeur);
74 addAttribute (attrib, buffer);
76 // ====================================================== addAttribute (R)
77 inline void XmlWriter::addAttribute (cpchar attrib, double valeur)
80 sprintf (buffer, "%g", valeur);
81 addAttribute (attrib, buffer);
83 // ====================================================== addAttribute (stl)
84 inline void XmlWriter::addAttribute (cpchar attrib, string& valeur)
86 addAttribute (attrib, valeur.c_str());
88 // ====================================================== addMot
89 inline void XmlWriter::addMot (cpchar mot)
92 fprintf (xml_file, mot);