1 // Created on: 2001-06-28
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15 
16 #ifndef LDOM_XmlWriter_HeaderFile
17 #define LDOM_XmlWriter_HeaderFile
18 
19 #include <Standard_OStream.hxx>
20 #include <Standard_TypeDef.hxx>
21 #include <stdio.h>
22 
23 class LDOM_Document;
24 class LDOM_Node;
25 class LDOMBasicString;
26 
27 class LDOM_XmlWriter
28 {
29 public:
30 
31   Standard_EXPORT LDOM_XmlWriter (const char* theEncoding = NULL);
32 
33   Standard_EXPORT ~LDOM_XmlWriter ();
34 
35   // Set indentation for output (by default 0)
SetIndentation(const Standard_Integer theIndent)36   void SetIndentation (const Standard_Integer theIndent) { myIndent = theIndent; }
37 
38   Standard_EXPORT void Write (Standard_OStream& theOStream, const LDOM_Document& theDoc);
39 
40   //  Stream out a DOM node, and, recursively, all of its children. This
41   //  function is the heart of writing a DOM tree out as XML source. Give it
42   //  a document node and it will do the whole thing.
43   Standard_EXPORT void Write (Standard_OStream& theOStream, const LDOM_Node& theNode);
44 
45 private:
46 
47   LDOM_XmlWriter (const LDOM_XmlWriter& anOther);
48 
49   LDOM_XmlWriter& operator = (const LDOM_XmlWriter& anOther);
50 
51   void Write (Standard_OStream& theOStream, const LDOMBasicString& theString);
52   void Write (Standard_OStream& theOStream, const char* theString);
53   void Write (Standard_OStream& theOStream, const char theChar);
54 
55   void  WriteAttribute (Standard_OStream& theOStream, const LDOM_Node& theAtt);
56 
57  private:
58 
59   char*            myEncodingName;
60   Standard_Integer myIndent;
61   Standard_Integer myCurIndent;
62   char*            myABuffer;
63   Standard_Integer myABufferLen;
64 };
65 
66 #endif
67