ROOT  6.06/09
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 
28 class SelectionRules;
29 
30 namespace cling {
31  class Interpreter;
32 }
33 
34 class XMLReader {
35 public:
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 
45 private:
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 
98 public:
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
Attributes(const std::string &nName, const std::string &nValue)
Definition: XMLReader.h:42
long fCount
Definition: XMLReader.h:46
static bool GetAttributes(const std::string &tag, std::vector< Attributes > &out, const char *lineNum)
Definition: XMLReader.cxx:321
static bool GetNextTag(std::ifstream &file, std::string &out, int &lineCount)
Definition: XMLReader.cxx:72
static std::map< std::string, ETagNames > fgMapTagNames
Definition: XMLReader.h:84
static bool IsStandaloneTag(const std::string &tag)
Definition: XMLReader.cxx:275
std::string fName
Definition: XMLReader.h:39
static void PopulateMap()
Definition: XMLReader.cxx:29
The class representing the collection of selection rules.
char * out
Definition: TBase64.cxx:29
std::string fValue
Definition: XMLReader.h:40
static bool IsClosingTag(const std::string &tag)
Definition: XMLReader.cxx:285
static bool IsTagComment(const std::string &tag)
Definition: TDatime.h:114
#define name(a, b)
Definition: linkTestLib0.cpp:5
static bool CheckIsTagOK(const std::string &tag)
Definition: XMLReader.cxx:209
static ETagNames GetNameOfTag(const std::string &tag, std::string &name)
Definition: XMLReader.cxx:296
XMLReader(cling::Interpreter &interp)
Definition: XMLReader.h:100
bool Parse(const std::string &fileName, SelectionRules &out)
Definition: XMLReader.cxx:453
cling::Interpreter & fInterp
Definition: XMLReader.h:47