Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:28:31

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 //             AGV 130302: bug corr: was error if strlen(root_elem_name) < 7
0018 
0019 #ifndef LDOM_XmlReader_HeaderFile
0020 #define LDOM_XmlReader_HeaderFile
0021 
0022 // #define XML_BUFFER_SIZE 1000
0023 #define XML_BUFFER_SIZE 20480
0024 
0025 #include <LDOM_BasicElement.hxx>
0026 #include <LDOM_OSStream.hxx>
0027 
0028 class TCollection_AsciiString;
0029 
0030 //  Class LDOM_XmlReader
0031 //
0032 
0033 class LDOM_XmlReader
0034 {
0035 public:
0036   enum RecordType
0037   {
0038     XML_UNKNOWN,
0039     XML_HEADER,
0040     XML_DOCTYPE,
0041     XML_COMMENT,
0042     XML_START_ELEMENT,
0043     XML_END_ELEMENT,
0044     XML_FULL_ELEMENT,
0045     XML_TEXT,
0046     XML_CDATA,
0047     XML_EOF
0048   };
0049 
0050   // ---------- PUBLIC METHODS ----------
0051   LDOM_XmlReader(const occ::handle<LDOM_MemManager>& aDocument,
0052                  TCollection_AsciiString&            anErrorString,
0053                  const bool                          theTagPerStep = false);
0054   // Constructor - takes a file descriptor for input
0055   // Constructor - takes an std::istream for input
0056 
0057   RecordType ReadRecord(Standard_IStream& theIStream, LDOM_OSStream& theData, bool& theDocStart);
0058 
0059   // reading a markup or other element of XML format
0060 
0061   LDOM_BasicElement& GetElement() const { return *myElement; }
0062 
0063   // get the last element retrieved from the stream
0064 
0065   void CreateElement(const char* theName, const int theLen);
0066 
0067   static bool getInteger(LDOMBasicString& theValue, const char* theStart, const char* theEnd);
0068 
0069   // try convert string theStart to LDOM_AsciiInteger, return False on success
0070 
0071   // Returns the byte order mask defined at the start of a stream
0072   LDOM_OSStream::BOMType GetBOM() const { return myBOM; }
0073 
0074 private:
0075   // ---------- PRIVATE (PROHIBITED) METHODS ----------
0076   LDOM_XmlReader(const LDOM_XmlReader& theOther) = delete;
0077   // Copy constructor
0078 
0079   LDOM_XmlReader& operator=(const LDOM_XmlReader& theOther) = delete;
0080   // Assignment
0081 
0082 private:
0083   // ---------- PRIVATE FIELDS ----------
0084 
0085   bool                         myEOF;
0086   TCollection_AsciiString&     myError;
0087   occ::handle<LDOM_MemManager> myDocument;
0088   LDOM_BasicElement*           myElement;
0089   const LDOM_BasicNode*        myLastChild; // optim. reading attributes
0090   const char*                  myPtr;
0091   const char*                  myEndPtr;
0092   char                         myBuffer[XML_BUFFER_SIZE + 4];
0093   bool                         myTagPerStep;
0094   LDOM_OSStream::BOMType       myBOM;
0095 };
0096 
0097 #endif