summaryrefslogtreecommitdiff
path: root/inc/LDOMParser.hxx
blob: 80a8370a85043b206c0b9b418ba7f53220b6c2c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// File:      LDOMParser.hxx
// Created:   20.07.01 12:52:47
// Author:    Alexander GRIGORIEV
// Copyright: OpenCascade 2001
// History:   AGV 060302: Input from istream

#ifndef LDOMParser_HeaderFile
#define LDOMParser_HeaderFile

#include <LDOM_Document.hxx>
#include <LDOM_OSStream.hxx>

class LDOM_XmlReader;
//class istream;

//  Class LDOMParser
//

class LDOMParser
{
 public:
  // ---------- PUBLIC METHODS ----------

  LDOMParser () : myReader (NULL), myCurrentData (16384) {}
  // Empty constructor

  virtual Standard_EXPORT ~LDOMParser  ();
  // Destructor

  Standard_EXPORT LDOM_Document
                        getDocument    ();
  // Get the LDOM_Document

  Standard_EXPORT Standard_Boolean
                        parse           (const char * const aFileName);
  // Parse a file
  // Returns True if error occurred, then GetError() can be called

  Standard_EXPORT Standard_Boolean
                        parse           (istream& anInput);
  // Parse a C++ stream
  // Returns True if error occurred, then GetError() can be called

  Standard_EXPORT const TCollection_AsciiString&
                        GetError        (TCollection_AsciiString& aData) const;
  // Return text describing a parsing error, or Empty if no error occurred

 protected:
  // ---------- PROTECTED METHODS ----------

  Standard_EXPORT virtual Standard_Boolean
                        startElement    ();
  // virtual hook on 'StartElement' event for descendant classes

  Standard_EXPORT virtual Standard_Boolean
                        endElement      ();
  // virtual hook on 'EndElement' event for descendant classes

  Standard_EXPORT LDOM_Element
                        getCurrentElement () const;
  // to be called from startElement() and endElement()

 private:
  // ---------- PRIVATE METHODS ----------
  Standard_Boolean      ParseDocument   ();

  Standard_Boolean      ParseElement    ();

  // ---------- PRIVATE (PROHIBITED) METHODS ----------

  LDOMParser (const LDOMParser& theOther);
  // Copy constructor

  LDOMParser& operator = (const LDOMParser& theOther);
  // Assignment

 private:
  // ---------- PRIVATE FIELDS ----------

  LDOM_XmlReader                * myReader;
  Handle(LDOM_MemManager)       myDocument;
  LDOM_OSStream                 myCurrentData;
  TCollection_AsciiString       myError;
};

#endif