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 
29 class SelectionRules;
30 
31 namespace cling {
32  class Interpreter;
33 }
34 
35 class XMLReader {
36 public:
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 
46 private:
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 
99 public:
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
XMLReader::GetNameOfTag
static ETagNames GetNameOfTag(const std::string &tag, std::string &name)
Definition: XMLReader.cxx:296
XMLReader::IsClosingTag
static bool IsClosingTag(const std::string &tag)
Definition: XMLReader.cxx:285
XMLReader::kVariable
@ kVariable
Definition: XMLReader.h:58
XMLReader::kEndIoread
@ kEndIoread
Definition: XMLReader.h:76
XMLReader::kMethod
@ kMethod
Definition: XMLReader.h:60
XMLReader::kTypedef
@ kTypedef
Definition: XMLReader.h:81
XMLReader::fCount
long fCount
Definition: XMLReader.h:47
XMLReader::kVersion
@ kVersion
Definition: XMLReader.h:65
XMLReader::kEndClass
@ kEndClass
Definition: XMLReader.h:70
XMLReader::kFunction
@ kFunction
Definition: XMLReader.h:57
XMLReader::fgMapTagNames
static std::map< std::string, ETagNames > fgMapTagNames
Definition: XMLReader.h:85
XMLReader::kNumTagNames
@ kNumTagNames
Definition: XMLReader.h:80
XMLReader::kInvalid
@ kInvalid
Definition: XMLReader.h:79
XMLReader::kClass
@ kClass
Definition: XMLReader.h:56
XMLReader::ETagNames
ETagNames
Definition: XMLReader.h:55
XMLReader::kEndStruct
@ kEndStruct
Definition: XMLReader.h:71
XMLReader::kBeginIoread
@ kBeginIoread
Definition: XMLReader.h:75
XMLReader::kEndExclusion
@ kEndExclusion
Definition: XMLReader.h:73
XMLReader::kBeginIoreadRaw
@ kBeginIoreadRaw
Definition: XMLReader.h:77
XMLReader::GetAttributes
static bool GetAttributes(const std::string &tag, std::vector< Attributes > &out, const char *lineNum)
Definition: XMLReader.cxx:321
XMLReader::kEndField
@ kEndField
Definition: XMLReader.h:63
XMLReader::kLcgdict
@ kLcgdict
Definition: XMLReader.h:67
XMLReader
Definition: XMLReader.h:35
XMLReader::Attributes::fName
std::string fName
Definition: XMLReader.h:40
XMLReader::Attributes::fValue
std::string fValue
Definition: XMLReader.h:41
XMLReader::Attributes::Attributes
Attributes()
Definition: XMLReader.h:42
XMLReader::kStartIgnore
@ kStartIgnore
Definition: XMLReader.h:66
XMLReader::kEnum
@ kEnum
Definition: XMLReader.h:59
XMLReader::kExclusion
@ kExclusion
Definition: XMLReader.h:69
XMLReader::PopulateMap
static void PopulateMap()
Definition: XMLReader.cxx:29
XMLReader::kEndLcgdict
@ kEndLcgdict
Definition: XMLReader.h:74
XMLReader::XMLReader
XMLReader(cling::Interpreter &interp)
Definition: XMLReader.h:101
XMLReader::fInterp
cling::Interpreter & fInterp
Definition: XMLReader.h:48
XMLReader::kSelection
@ kSelection
Definition: XMLReader.h:68
XMLReader::kField
@ kField
Definition: XMLReader.h:62
XMLReader::GetNextTag
static bool GetNextTag(std::ifstream &file, std::string &out, int &lineCount)
Definition: XMLReader.cxx:72
file
Definition: file.py:1
XMLReader::Attributes
Definition: XMLReader.h:38
XMLReader::CheckIsTagOK
static bool CheckIsTagOK(const std::string &tag)
Definition: XMLReader.cxx:209
XMLReader::IsStandaloneTag
static bool IsStandaloneTag(const std::string &tag)
Definition: XMLReader.cxx:275
XMLReader::kEndSelection
@ kEndSelection
Definition: XMLReader.h:72
name
char name[80]
Definition: TGX11.cxx:110
XMLReader::IsTagComment
static bool IsTagComment(const std::string &tag)
XMLReader::Parse
bool Parse(const std::string &fileName, SelectionRules &out)
Definition: XMLReader.cxx:453
XMLReader::kEndMethod
@ kEndMethod
Definition: XMLReader.h:61
XMLReader::Attributes::Attributes
Attributes(const std::string &nName, const std::string &nValue)
Definition: XMLReader.h:43
XMLReader::kProperties
@ kProperties
Definition: XMLReader.h:64
SelectionRules
Definition: SelectionRules.h:92
XMLReader::kEndIoreadRaw
@ kEndIoreadRaw
Definition: XMLReader.h:78