Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-24 08:18:02

0001 // Created on: 2001-07-20
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2001-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 // AGV 060302: Input from std::istream
0017 
0018 #ifndef LDOMParser_HeaderFile
0019 #define LDOMParser_HeaderFile
0020 
0021 #include <LDOM_Document.hxx>
0022 #include <LDOM_OSStream.hxx>
0023 
0024 class LDOM_XmlReader;
0025 
0026 // class std::istream;
0027 
0028 //  Class LDOMParser
0029 //
0030 
0031 class LDOMParser
0032 {
0033 public:
0034   // ---------- PUBLIC METHODS ----------
0035 
0036   LDOMParser()
0037       : myReader(NULL),
0038         myCurrentData(16384)
0039   {
0040   }
0041 
0042   // Empty constructor
0043 
0044   virtual Standard_EXPORT ~LDOMParser();
0045   // Destructor
0046 
0047   Standard_EXPORT LDOM_Document getDocument();
0048   // Get the LDOM_Document
0049 
0050   Standard_EXPORT Standard_Boolean parse(const char* const aFileName);
0051   // Parse a file
0052   // Returns True if error occurred, then GetError() can be called
0053 
0054   Standard_EXPORT Standard_Boolean parse(std::istream&          anInput,
0055                                          const Standard_Boolean theTagPerStep  = Standard_False,
0056                                          const Standard_Boolean theWithoutRoot = Standard_False);
0057   // Parse a C++ stream
0058   // theTagPerStep - if true - extract characters from anInput until '>'
0059   //                           extracted character and parse only these characters.
0060   //                 if false - extract until eof
0061   // theWithoutRoot - if true - create fictive "document" element before parsing
0062   //                            and consider that document start element has been already read
0063   //                - if false - parse a document as usual (parse header, document tag and etc)
0064   // Returns True if error occurred, then GetError() can be called
0065 
0066   Standard_EXPORT const TCollection_AsciiString& GetError(TCollection_AsciiString& aData) const;
0067   // Return text describing a parsing error, or Empty if no error occurred
0068 
0069   // Returns the byte order mask defined at the start of a stream
0070   Standard_EXPORT LDOM_OSStream::BOMType GetBOM() const;
0071 
0072 protected:
0073   // ---------- PROTECTED METHODS ----------
0074 
0075   Standard_EXPORT virtual Standard_Boolean startElement();
0076   // virtual hook on 'StartElement' event for descendant classes
0077 
0078   Standard_EXPORT virtual Standard_Boolean endElement();
0079   // virtual hook on 'EndElement' event for descendant classes
0080 
0081   Standard_EXPORT LDOM_Element getCurrentElement() const;
0082   // to be called from startElement() and endElement()
0083 
0084 private:
0085   // ---------- PRIVATE METHODS ----------
0086   Standard_Boolean ParseDocument(Standard_IStream&      theIStream,
0087                                  const Standard_Boolean theWithoutRoot = Standard_False);
0088 
0089   Standard_Boolean ParseElement(Standard_IStream& theIStream, Standard_Boolean& theDocStart);
0090 
0091   // ---------- PRIVATE (PROHIBITED) METHODS ----------
0092 
0093   LDOMParser(const LDOMParser& theOther);
0094   // Copy constructor
0095 
0096   LDOMParser& operator=(const LDOMParser& theOther);
0097   // Assignment
0098 
0099 private:
0100   // ---------- PRIVATE FIELDS ----------
0101 
0102   LDOM_XmlReader*         myReader;
0103   Handle(LDOM_MemManager) myDocument;
0104   LDOM_OSStream           myCurrentData;
0105   TCollection_AsciiString myError;
0106 };
0107 
0108 #endif