Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TXMLParser.h
Go to the documentation of this file.
1 // @(#)root/xmlparser:$Id$
2 // Author: Jose Lo 12/4/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TXMLParser
13 #define ROOT_TXMLParser
14 
15 #include "TQObject.h"
16 
17 #include "TObject.h"
18 
19 #include "TString.h"
20 
21 struct _xmlParserCtxt;
22 
23 
24 class TXMLParser : public TObject, public TQObject {
25 
26 private:
27  TXMLParser(const TXMLParser&); // Not implemented
28  TXMLParser& operator=(const TXMLParser&); // Not implemented
29 
30 protected:
31  _xmlParserCtxt *fContext; ///< Parse the xml file
32  Bool_t fValidate; ///< To validate the parse context
33  Bool_t fReplaceEntities; ///< Replace entities
34  Bool_t fStopError; ///< Stop when parse error occurs
35  TString fValidateError; ///< Parse error
36  TString fValidateWarning; ///< Parse warning
37  Int_t fParseCode; ///< To keep track of the errorcodes
38 
39  virtual void InitializeContext();
40  virtual void ReleaseUnderlying();
41  virtual void OnValidateError(const TString& message);
42  virtual void OnValidateWarning(const TString& message);
43  virtual void SetParseCode(Int_t code);
44 
45 public:
46  TXMLParser();
47  virtual ~TXMLParser();
48 
49  void SetValidate(Bool_t val = kTRUE);
50  Bool_t GetValidate() const { return fValidate; }
51 
52  void SetReplaceEntities(Bool_t val = kTRUE);
53  Bool_t GetReplaceEntities() const { return fReplaceEntities; }
54 
55  virtual Int_t ParseFile(const char *filename) = 0;
56  virtual Int_t ParseBuffer(const char *contents, Int_t len) = 0;
57  virtual void StopParser();
58 
59  Int_t GetParseCode() const { return fParseCode; }
60 
61  const char *GetParseCodeMessage(Int_t parseCode) const;
62 
63  void SetStopOnError(Bool_t stop = kTRUE);
64  Bool_t GetStopOnError() const { return fStopError; }
65 
66  const char *GetValidateError() const { return fValidateError; }
67  const char *GetValidateWarning() const { return fValidateWarning; }
68 
69  ClassDef(TXMLParser,0); // XML SAX parser
70 };
71 
72 #endif