Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:12

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 //class std::istream;
0026 
0027 //  Class LDOMParser
0028 //
0029 
0030 class LDOMParser
0031 {
0032  public:
0033   // ---------- PUBLIC METHODS ----------
0034 
0035   LDOMParser () : myReader (NULL), myCurrentData (16384) {}
0036   // Empty constructor
0037 
0038   virtual Standard_EXPORT ~LDOMParser  ();
0039   // Destructor
0040 
0041   Standard_EXPORT LDOM_Document
0042                         getDocument    ();
0043   // Get the LDOM_Document
0044 
0045   Standard_EXPORT Standard_Boolean
0046                         parse           (const char * const aFileName);
0047   // Parse a file
0048   // Returns True if error occurred, then GetError() can be called
0049 
0050   Standard_EXPORT Standard_Boolean
0051                         parse           (std::istream& anInput,
0052                                          const Standard_Boolean theTagPerStep  = Standard_False,
0053                                          const Standard_Boolean theWithoutRoot = Standard_False);
0054   // Parse a C++ stream
0055   // theTagPerStep - if true - extract characters from anInput until '>' 
0056   //                           extracted character and parse only these characters.
0057   //                 if false - extract until eof
0058   // theWithoutRoot - if true - create fictive "document" element before parsing
0059   //                            and consider that document start element has been already read
0060   //                - if false - parse a document as usual (parse header, document tag and etc)
0061   // Returns True if error occurred, then GetError() can be called
0062 
0063   Standard_EXPORT const TCollection_AsciiString&
0064                         GetError        (TCollection_AsciiString& aData) const;
0065   // Return text describing a parsing error, or Empty if no error occurred
0066 
0067   // Returns the byte order mask defined at the start of a stream
0068   Standard_EXPORT LDOM_OSStream::BOMType GetBOM() const;
0069 
0070  protected:
0071   // ---------- PROTECTED METHODS ----------
0072 
0073   Standard_EXPORT virtual Standard_Boolean
0074                         startElement    ();
0075   // virtual hook on 'StartElement' event for descendant classes
0076 
0077   Standard_EXPORT virtual Standard_Boolean
0078                         endElement      ();
0079   // virtual hook on 'EndElement' event for descendant classes
0080 
0081   Standard_EXPORT LDOM_Element
0082                         getCurrentElement () const;
0083   // to be called from startElement() and endElement()
0084 
0085  private:
0086   // ---------- PRIVATE METHODS ----------
0087   Standard_Boolean      ParseDocument   (Standard_IStream& theIStream, 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