Logo ROOT   6.18/05
Reference Guide
XMLReader.h
Go to the documentation of this file.
1// @(#)root/core/utils:$Id: XMLReader.h 35213 2010-09-08 16:39:04Z axel $
2// Author: Velislava Spasova, 2010-09-16
3
4/*************************************************************************
5 * Copyright (C) 1995-2011, 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//////////////////////////////////////////////////////////////////////////
13// //
14// XML parsing class //
15// //
16//////////////////////////////////////////////////////////////////////////
17
18
19#ifndef ROOT__XMLREADER_H__
20#define ROOT__XMLREADER_H__
21
22#include <iostream>
23#include <fstream>
24#include <sstream>
25#include <vector>
26#include <map>
27
28class SelectionRules;
29
30namespace cling {
31 class Interpreter;
32}
33
34class XMLReader {
35public:
36 // class to temporarily store the arguments of a tag (if such are present)
37 class Attributes {
38 public:
39 std::string fName;
40 std::string fValue;
42 Attributes(const std::string& nName, const std::string& nValue) : fName(nName), fValue(nValue) {}
43 };
44
45private:
46 long fCount;
47 cling::Interpreter &fInterp;
48
49 //SelectionRules& fSelectionRules;
50 //std::string fXMLFileName;
51 //std::ifstream fXMLInStream;
52
53 // enumeration - lists the posible tag elements in the selection file
54 enum ETagNames {
81 };
82
83 // used to create string to tag kind association to use in switch constructions
84 static std::map<std::string, ETagNames> fgMapTagNames;
85 static void PopulateMap();
86
87 static bool GetNextTag(std::ifstream &file, std::string& out, int& lineCount); // gets the next tag out of the in stream
88 static bool IsStandaloneTag(const std::string& tag); // returns true if the tag is standalone - i.e. <class name = "x" />
89 static bool IsClosingTag(const std::string& tag); // eturns true if the tag is closing tag, i.e. </class>
90 static ETagNames GetNameOfTag(const std::string& tag, std::string& name); // gets name of the tag, i.e. class, function ..
91 //static bool HasTagArguments(const std::string& tag);
92 static bool GetAttributes(const std::string& tag, std::vector<Attributes>& out, const char* lineNum); //writes the attr. names in values in the
93 // vector of Attribute objects passed as a second parameter
94 static bool CheckIsTagOK(const std::string& tag); // for a given tag checks if the tag is the correct format, i.e
95 // < class name="x"> will return false but <class name="x"> will return true
96 static bool IsTagComment(const std::string& tag); // Check that this is not an XML comment: <!-- comment -->
97
98public:
99 // Constructors
100 XMLReader(cling::Interpreter &interp) : fCount(0), fInterp(interp) {}
101 /* XMLReader(const std::string& fileName):
102 fXMLFileName(fileName) {}*/
103
104 //const std::string& getXMLFileName();
105 //std::ifstream& getXMLInStream();
106 //std::ifstream& openXMLInStream(const std::string& fileName);
107
108 // main parsing function - should be called over an open input file stream
109 bool Parse(const std::string &fileName, SelectionRules& out);
110// bool Parse(std::ifstream &file, SelectionRules& out);
111
112};
113
114#endif
char name[80]
Definition: TGX11.cxx:109
The class representing the collection of selection rules.
std::string fValue
Definition: XMLReader.h:40
std::string fName
Definition: XMLReader.h:39
Attributes(const std::string &nName, const std::string &nValue)
Definition: XMLReader.h:42
cling::Interpreter & fInterp
Definition: XMLReader.h:47
static bool IsClosingTag(const std::string &tag)
Definition: XMLReader.cxx:285
@ kNumTagNames
Definition: XMLReader.h:79
@ kLcgdict
Definition: XMLReader.h:66
@ kEndField
Definition: XMLReader.h:62
@ kEndMethod
Definition: XMLReader.h:60
@ kBeginIoreadRaw
Definition: XMLReader.h:76
@ kStartIgnore
Definition: XMLReader.h:65
@ kEndIoreadRaw
Definition: XMLReader.h:77
@ kExclusion
Definition: XMLReader.h:68
@ kVariable
Definition: XMLReader.h:57
@ kEndSelection
Definition: XMLReader.h:71
@ kEndIoread
Definition: XMLReader.h:75
@ kEndLcgdict
Definition: XMLReader.h:73
@ kTypedef
Definition: XMLReader.h:80
@ kBeginIoread
Definition: XMLReader.h:74
@ kInvalid
Definition: XMLReader.h:78
@ kEndClass
Definition: XMLReader.h:69
@ kEndExclusion
Definition: XMLReader.h:72
@ kProperties
Definition: XMLReader.h:63
@ kEndStruct
Definition: XMLReader.h:70
@ kFunction
Definition: XMLReader.h:56
@ kSelection
Definition: XMLReader.h:67
@ kVersion
Definition: XMLReader.h:64
static void PopulateMap()
Definition: XMLReader.cxx:29
XMLReader(cling::Interpreter &interp)
Definition: XMLReader.h:100
long fCount
Definition: XMLReader.h:46
static std::map< std::string, ETagNames > fgMapTagNames
Definition: XMLReader.h:84
static bool CheckIsTagOK(const std::string &tag)
Definition: XMLReader.cxx:209
static bool IsTagComment(const std::string &tag)
bool Parse(const std::string &fileName, SelectionRules &out)
Definition: XMLReader.cxx:453
static bool GetNextTag(std::ifstream &file, std::string &out, int &lineCount)
Definition: XMLReader.cxx:72
static bool GetAttributes(const std::string &tag, std::vector< Attributes > &out, const char *lineNum)
Definition: XMLReader.cxx:321
static ETagNames GetNameOfTag(const std::string &tag, std::string &name)
Definition: XMLReader.cxx:296
static bool IsStandaloneTag(const std::string &tag)
Definition: XMLReader.cxx:275
Definition: file.py:1