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
18 #ifndef LDOMParser_HeaderFile
19 #define LDOMParser_HeaderFile
21 #include <LDOM_Document.hxx>
22 #include <LDOM_OSStream.hxx>
33 // ---------- PUBLIC METHODS ----------
35 LDOMParser () : myReader (NULL), myCurrentData (16384) {}
38 virtual Standard_EXPORT ~LDOMParser ();
41 Standard_EXPORT LDOM_Document
43 // Get the LDOM_Document
45 Standard_EXPORT Standard_Boolean
46 parse (const char * const aFileName);
48 // Returns True if error occurred, then GetError() can be called
50 Standard_EXPORT Standard_Boolean
51 parse (std::istream& anInput,
52 const Standard_Boolean theTagPerStep = Standard_False,
53 const Standard_Boolean theWithoutRoot = Standard_False);
55 // theTagPerStep - if true - extract characters from anInput until '>'
56 // extracted character and parse only these characters.
57 // if false - extract until eof
58 // theWithoutRoot - if true - create fictive "document" element before parsing
59 // and consider that document start element has been already read
60 // - if false - parse a document as usual (parse header, document tag and etc)
61 // Returns True if error occurred, then GetError() can be called
63 Standard_EXPORT const TCollection_AsciiString&
64 GetError (TCollection_AsciiString& aData) const;
65 // Return text describing a parsing error, or Empty if no error occurred
68 // ---------- PROTECTED METHODS ----------
70 Standard_EXPORT virtual Standard_Boolean
72 // virtual hook on 'StartElement' event for descendant classes
74 Standard_EXPORT virtual Standard_Boolean
76 // virtual hook on 'EndElement' event for descendant classes
78 Standard_EXPORT LDOM_Element
79 getCurrentElement () const;
80 // to be called from startElement() and endElement()
83 // ---------- PRIVATE METHODS ----------
84 Standard_Boolean ParseDocument (Standard_IStream& theIStream, const Standard_Boolean theWithoutRoot = Standard_False);
86 Standard_Boolean ParseElement (Standard_IStream& theIStream);
88 // ---------- PRIVATE (PROHIBITED) METHODS ----------
90 LDOMParser (const LDOMParser& theOther);
93 LDOMParser& operator = (const LDOMParser& theOther);
97 // ---------- PRIVATE FIELDS ----------
99 LDOM_XmlReader * myReader;
100 Handle(LDOM_MemManager) myDocument;
101 LDOM_OSStream myCurrentData;
102 TCollection_AsciiString myError;