1 // Copyright (C) 2009-2022 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, or (at your option) any later version.
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
25 #include "hexa_base.hxx"
31 enum EnumItem { M_NONE, M_BEGIN, M_END, M_BEGIN_CLOSE, M_CLOSE,
32 M_IDENT, M_EQUALS, M_STRING,
33 M_COMMENT, M_END_COMMENT, M_PROLOG, M_END_PROLOG,
35 class HexaExport XmlTree
38 XmlTree (const std::string& name, XmlTree* dad=NULL);
41 int parseFile (const std::string& name);
42 int parseStream (cpchar flux, int& posit);
44 cpchar getName () { return item_name.c_str() ; }
45 int getNbrAttributs () { return nbr_attributs ; }
46 int getNbrChildren () { return nbr_items ; }
48 int findAttribute (const std::string& nom);
49 const std::string& findValue (const std::string& nom);
50 int findInteger (const std::string& nom);
52 cpchar getAttribute (int nro) { return tab_attributs [nro].c_str(); }
53 cpchar getValue (int nro) { return tab_values [nro].c_str(); }
55 XmlTree* findChild (const std::string& nom);
56 XmlTree* getChild (int nro) { return tab_items [nro]; }
57 XmlTree* getParent () { return xml_parent; }
59 // ------------------------- Modifications
61 XmlTree* addChild (const std::string& nom);
62 void addAttribut (const std::string& nom, const std::string& valeur);
63 void setName (const std::string& nom) { item_name = nom; }
64 void dump (int niveau=0);
66 int goTo (cpchar ouca);
71 EnumItem readItem (std::string& item);
72 EnumItem getItem (std::string& item, EnumItem waited=M_NONE);
73 int getString (std::string& item);
74 int getIdent (std::string& item);
76 void putError (cpchar why);
79 std::string item_name;
80 std::string item_vide;
85 std::vector <std::string> tab_attributs;
86 std::vector <std::string> tab_values;
87 std::vector <XmlTree*> tab_items;
89 std::string fic_buffer;