1 // Created on: 2001-07-20
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //AGV 060302: Input from std::istream
17 // AGV 130302: bug corr: was error if strlen(root_elem_name) < 7
19 #ifndef LDOM_XmlReader_HeaderFile
20 #define LDOM_XmlReader_HeaderFile
22 //#define XML_BUFFER_SIZE 1000
23 #define XML_BUFFER_SIZE 20480
25 #include <LDOM_BasicElement.hxx>
26 #include <LDOM_OSStream.hxx>
28 class TCollection_AsciiString;
30 // Class LDOM_XmlReader
49 // ---------- PUBLIC METHODS ----------
50 LDOM_XmlReader (const Handle(LDOM_MemManager)& aDocument,
51 TCollection_AsciiString& anErrorString,
52 const Standard_Boolean theTagPerStep = Standard_False);
53 // Constructor - takes a file descriptor for input
54 // Constructor - takes an std::istream for input
56 RecordType ReadRecord (Standard_IStream& theIStream, LDOM_OSStream& theData);
57 // reading a markup or other element of XML format
59 LDOM_BasicElement& GetElement () const { return * myElement; }
60 // get the last element retrieved from the stream
62 void CreateElement (const char *theName, const Standard_Integer theLen);
64 static Standard_Boolean getInteger (LDOMBasicString& theValue,
65 const char * theStart,
67 // try convert string theStart to LDOM_AsciiInteger, return False on success
69 // Returns the byte order mask defined at the start of a stream
70 LDOM_OSStream::BOMType GetBOM() const { return myBOM; }
73 // ---------- PRIVATE (PROHIBITED) METHODS ----------
74 LDOM_XmlReader (const LDOM_XmlReader& theOther);
77 LDOM_XmlReader& operator = (const LDOM_XmlReader& theOther);
81 // ---------- PRIVATE FIELDS ----------
83 Standard_Boolean myEOF;
84 TCollection_AsciiString & myError;
85 Handle(LDOM_MemManager) myDocument;
86 LDOM_BasicElement * myElement;
87 const LDOM_BasicNode * myLastChild; // optim. reading attributes
89 const char * myEndPtr;
90 char myBuffer [XML_BUFFER_SIZE+4];
91 Standard_Boolean myTagPerStep;
92 LDOM_OSStream::BOMType myBOM;