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