StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StlXmlTree.h
1 #ifndef NoXmlTreeReader
2 #ifndef __CINT__
3 #include <libxml/xmlreader.h>
4 #endif
5 
228 #ifndef StlXmlTree_h
229 #define StlXmlTree_h
230 #ifdef __ROOT__
231 #include "Rtypes.h"
232 #endif
233 #include <vector>
234 #include <map>
235 #include <string>
236 
237 namespace stl_xml_tree {
238  const std::string sep = ">"; // will be parsed out of XML or cause an error -- safe to use here
239  enum
240  {
241  NO_ERROR,
242  NO_XML_BASE, // no file to be parsed
243  BAD_XML // parsing error, the structure may be incomplete
244  };
245 }
246 
248 {
249  private:
250  StlXmlTree* Filter = 0;
251 #ifndef __CINT__
252  xmlTextReaderPtr reader;
253 #endif
254  std::multimap<std::string,std::string> XmlTree;
255  char* xmlfilename = 0;
256  std::multimap<std::string,std::string>::const_iterator OnTheTree;
257  int Depth = 0;
258  int PreviousDepth = 0;
259  int MaxDepthWanted = 0;
260  std::string XmlTreeNodeName;
261  std::string NodeName;
262  std::string IdString;
263  short MyStatus = 0;
264 
265  void ProcessNode();
266 #ifdef DEBUG
267  void ProcessNodeDebug();
268 #endif
269  void ProcessAttribute();
270  bool SkipBasedOnValue(const std::string key, const std::string value);
271  void UpdateDepth();
272 
273 
274 public:
275  StlXmlTree();
276  StlXmlTree(const std::string xmlfilename, StlXmlTree* filter=0);
277  virtual ~StlXmlTree(){;}
278  void ShowTree();
279  static std::map<std::string,std::string> ParseAttributeString(const std::string);
280  static std::string MakeKey(const std::string FullyQualifiedParent, const std::string Child);
281  static std::string QualifyParent(const std::string Parent, const std::string Attributes);
282  std::vector<std::string> LookUpValueByKey(const std::string key);
283  std::vector<std::string> LookUpValueByKey
284  (std::string& Parent, const std::string ParentAttributes, const std::string Child);
285 //--------------^ enables recursion, returns the look-up key good for the next step
286  void InsertKeyValuePair(std::string key, std::string value);
287  static bool AttributesContain(std::string attributeString, std::string attributeName, std::string attributeValue);
288  inline short GetStatus() {return MyStatus;};
289 #ifdef __ROOT__
290  ClassDef(StlXmlTree,0);
291 #endif
292 };
293 #endif
294 #endif
Definition: Filter.h:17