X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FHEXABLOCK%2FHexXmlWriter.hxx;h=bdbc57b6b55249431206277c5f2f0ecc7a4a5de6;hb=b871c3e20e331915e4534dcaffc1f0eab8f809d5;hp=5afcbdbb187eed53d67263cfc37e2e09af0c11cb;hpb=3362101497b1bc0ded71b74c0806ac06c64d49d3;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCK/HexXmlWriter.hxx b/src/HEXABLOCK/HexXmlWriter.hxx index 5afcbdb..bdbc57b 100755 --- a/src/HEXABLOCK/HexXmlWriter.hxx +++ b/src/HEXABLOCK/HexXmlWriter.hxx @@ -1,3 +1,21 @@ +// Copyright (C) 2009-2016 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// // Class : Ecriture d'un fichier XML // @@ -10,15 +28,18 @@ BEGIN_NAMESPACE_HEXA -class XmlWriter +class HexaExport XmlWriter { public : XmlWriter (); ~XmlWriter () { closeXml () ; } - int openXml (string& nom) { return openXml (nom.c_str()); } - int openXml (cpchar nom); - void closeXml (); + int setFileName (cpchar filename); // Un seul xml par fichier + int setFile (pfile afile); // Plusieurs xml par fichier + int setStream (); // Sauvegarde par flux + int startXml (); + void closeXml (); + cpchar getXml () { return xml_buffer.c_str(); } void openMark (cpchar balise); // + eol @@ -35,12 +56,17 @@ private : void alaLigne (bool force=false); void ecrire (cpchar mot); void ecrire (string& mot) { ecrire (mot.c_str()) ; } + void addMot (cpchar mot); private : + enum {InaFile, InaStudy, InaStream} xml_mode; enum {xml_decal=3, xml_size=80}; + pfile xml_file; int xml_level; int xml_pos; + bool on_file; + std::string xml_buffer; std::stack > pile_mark; std::stack > pile_etat; }; @@ -63,6 +89,14 @@ inline void XmlWriter::addAttribute (cpchar attrib, string& valeur) { addAttribute (attrib, valeur.c_str()); } +// ====================================================== addMot +inline void XmlWriter::addMot (cpchar mot) +{ + if (on_file) + fprintf (xml_file, mot); + else + xml_buffer += mot; +} END_NAMESPACE_HEXA #endif