b311480e |
1 | // Created on: 2001-07-20 |
2 | // Created by: Alexander GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2001-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //AGV 060302: Input from istream |
7fd59977 |
17 | // AGV 130302: bug corr: was error if strlen(root_elem_name) < 7 |
18 | |
19 | #ifndef LDOM_XmlReader_HeaderFile |
20 | #define LDOM_XmlReader_HeaderFile |
21 | |
22 | //#define XML_BUFFER_SIZE 1000 |
23 | #define XML_BUFFER_SIZE 20480 |
24 | |
25 | #include <LDOM_BasicElement.hxx> |
26 | |
27 | class TCollection_AsciiString; |
28 | class LDOM_OSStream; |
29 | |
30 | // Class LDOM_XmlReader |
31 | // |
32 | |
33 | class LDOM_XmlReader |
34 | { |
35 | public: |
36 | enum RecordType { |
37 | XML_UNKNOWN, |
38 | XML_HEADER, |
39 | XML_DOCTYPE, |
40 | XML_COMMENT, |
41 | XML_START_ELEMENT, |
42 | XML_END_ELEMENT, |
43 | XML_FULL_ELEMENT, |
44 | XML_TEXT, |
45 | XML_CDATA, |
46 | XML_EOF |
47 | }; |
48 | |
49 | // ---------- PUBLIC METHODS ---------- |
50 | LDOM_XmlReader (const int aFileDes, const Handle(LDOM_MemManager)& aDocument, |
51 | TCollection_AsciiString& anErrorString); |
52 | // Constructor - takes a file descriptor for input |
53 | |
54 | LDOM_XmlReader (istream& anInput, const Handle(LDOM_MemManager)& aDocument, |
55 | TCollection_AsciiString& anErrorString); |
56 | // Constructor - takes an istream for input |
57 | |
58 | RecordType ReadRecord (LDOM_OSStream& theData); |
59 | // reading a markup or other element of XML format |
60 | |
61 | LDOM_BasicElement& GetElement () const { return * myElement; } |
62 | // get the last element retrieved from the stream |
63 | |
64 | static Standard_Boolean getInteger (LDOMBasicString& theValue, |
65 | const char * theStart, |
66 | const char * theEnd); |
67 | // try convert string theStart to LDOM_AsciiInteger, return False on success |
68 | |
69 | private: |
70 | // ---------- PRIVATE (PROHIBITED) METHODS ---------- |
71 | LDOM_XmlReader (const LDOM_XmlReader& theOther); |
72 | // Copy constructor |
73 | |
74 | LDOM_XmlReader& operator = (const LDOM_XmlReader& theOther); |
75 | // Assignment |
76 | |
77 | private: |
78 | // ---------- PRIVATE FIELDS ---------- |
79 | |
80 | Standard_Boolean myEOF; |
81 | int myFileDes; // alternative 1: file descriptor |
82 | istream& myIStream; // alternative 2: istream |
83 | TCollection_AsciiString & myError; |
84 | Handle(LDOM_MemManager) myDocument; |
85 | LDOM_BasicElement * myElement; |
86 | const LDOM_BasicNode * myLastChild; // optim. reading attributes |
87 | const char * myPtr; |
88 | const char * myEndPtr; |
89 | char myBuffer [XML_BUFFER_SIZE+4]; |
90 | }; |
91 | |
92 | #endif |