Logo ROOT  
Reference Guide
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
21struct _xmlParserCtxt;
22
23
24class TXMLParser : public TObject, public TQObject {
25
26private:
27 TXMLParser(const TXMLParser&) = delete;
28 TXMLParser& operator=(const TXMLParser&) = delete;
29
30protected:
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
45public:
46 TXMLParser();
47 virtual ~TXMLParser();
48
49 void SetValidate(Bool_t val = kTRUE);
50 Bool_t GetValidate() const { return fValidate; }
51
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
int Int_t
Definition: RtypesCore.h:45
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassDef(name, id)
Definition: Rtypes.h:325
Mother of all ROOT objects.
Definition: TObject.h:37
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
Basic string class.
Definition: TString.h:136
TXMLParser is an abstract class which interfaces with Libxml2.
Definition: TXMLParser.h:24
TString fValidateWarning
Parse warning.
Definition: TXMLParser.h:36
virtual void InitializeContext()
Initialize parser parameters, such as, disactivate non-standards libxml1 features,...
Definition: TXMLParser.cxx:152
TXMLParser()
Initializes parser variables.
Definition: TXMLParser.cxx:59
virtual Int_t ParseBuffer(const char *contents, Int_t len)=0
virtual Int_t ParseFile(const char *filename)=0
virtual void SetParseCode(Int_t code)
Set the parse code:
Definition: TXMLParser.cxx:181
Bool_t GetStopOnError() const
Definition: TXMLParser.h:64
const char * GetValidateWarning() const
Definition: TXMLParser.h:67
Int_t GetParseCode() const
Definition: TXMLParser.h:59
const char * GetValidateError() const
Definition: TXMLParser.h:66
_xmlParserCtxt * fContext
Parse the xml file.
Definition: TXMLParser.h:31
Int_t fParseCode
To keep track of the errorcodes.
Definition: TXMLParser.h:37
void SetValidate(Bool_t val=kTRUE)
The parser will validate the xml file if val = true.
Definition: TXMLParser.cxx:76
TString fValidateError
Parse error.
Definition: TXMLParser.h:35
void SetReplaceEntities(Bool_t val=kTRUE)
The parser will replace/expand entities.
Definition: TXMLParser.cxx:84
virtual void ReleaseUnderlying()
To release any existing document.
Definition: TXMLParser.cxx:92
Bool_t GetValidate() const
Definition: TXMLParser.h:50
Bool_t fValidate
To validate the parse context.
Definition: TXMLParser.h:32
Bool_t GetReplaceEntities() const
Definition: TXMLParser.h:53
virtual ~TXMLParser()
Cleanup.
Definition: TXMLParser.cxx:67
TXMLParser & operator=(const TXMLParser &)=delete
const char * GetParseCodeMessage(Int_t parseCode) const
Returns the parse code message.
Definition: TXMLParser.cxx:122
virtual void OnValidateWarning(const TString &message)
This function is called when a warning from the parser has occured.
Definition: TXMLParser.cxx:114
void SetStopOnError(Bool_t stop=kTRUE)
Set parser stops in case of error:
Definition: TXMLParser.cxx:191
Bool_t fReplaceEntities
Replace entities.
Definition: TXMLParser.h:33
virtual void StopParser()
Stops parsing.
Definition: TXMLParser.cxx:166
virtual void OnValidateError(const TString &message)
This function is called when an error from the parser has occured.
Definition: TXMLParser.cxx:105
TXMLParser(const TXMLParser &)=delete
Bool_t fStopError
Stop when parse error occurs.
Definition: TXMLParser.h:34