// C++ : Ecriture en XML
-// Copyright (C) 2009-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2009-2013 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
xml_level = 0;
xml_pos = 0;
on_file = true;
+ xml_mode = InaStudy;
}
-// ========================================================= openXml
-int XmlWriter::openXml (cpchar nomfic)
+// ========================================================= setStream
+int XmlWriter::setStream ()
{
- xml_level = 0;
- xml_pos = 0;
- xml_buffer = "";
- xml_file = stdout;
- on_file = false;
+ xml_mode = InaStream;
+ xml_file = NULL;
+ on_file = false;
+
+ return HOK;
+}
+// ========================================================= setFile
+int XmlWriter::setFile (pfile afile)
+{
+ xml_mode = InaStudy;
+ xml_file = afile;
+ on_file = true;
- if (nomfic != NULL)
+ if (xml_file==NULL)
{
- on_file = true;
- bool suff = true;
- int pext = strlen (nomfic) - 4;
- if (pext > 0)
- {
- string sext = &nomfic[pext];
- set_minus (sext);
- suff = sext != ".xml";
- }
- string fname = nomfic;
- if (suff)
- fname += ".xml";
- xml_file = fopen (fname.c_str(), "w");
- if (xml_file==NULL)
- {
- xml_file = stdout;
- return HERR;
- }
+ xml_file = stdout;
+ xml_mode = InaStream;
+ return HERR;
}
+ return HOK;
+}
+// ========================================================= setFileName
+int XmlWriter::setFileName (cpchar nomfic)
+{
+ xml_mode = InaFile;
+ xml_file = stdout;
+ on_file = true;
+
+ bool suff = true;
+ int pext = strlen (nomfic) - 4;
+ if (pext > 0)
+ {
+ string sext = &nomfic[pext];
+ set_minus (sext);
+ suff = sext != ".xml";
+ }
+
+ string fname = nomfic;
+ if (suff)
+ fname += ".xml";
+
+ xml_file = fopen (fname.c_str(), "w");
+ if (xml_file==NULL)
+ {
+ xml_file = stdout;
+ return HERR;
+ }
+
+ return HOK;
+}
+// ========================================================= startXml
+int XmlWriter::startXml ()
+{
+ xml_level = 0;
+ xml_pos = 0;
+ xml_buffer = "";
+
ecrire ("<?xml version='1.0'?>");
return HOK;
}
while (NOT pile_mark.empty())
closeMark ();
- if (xml_file!=stdout)
+ if (xml_mode == InaFile && xml_file!=stdout)
+ {
fclose (xml_file);
-
- xml_file = stdout;
+ xml_file = stdout;
+ }
}
// ========================================================= addMark
void XmlWriter::addMark (cpchar balise, bool jump)