rspec_parser_helper.h 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2010 University of Utah and the Flux Group.
 * All rights reserved.
 */

/*
 * Helper class for the rspec parser
 */
 
#ifdef WITH_XML 
 
#ifndef __RSPEC_PARSER_HELPER_H__
#define __RSPEC_PARSER_HELPER_H__

#include "xstr.h"

#include <sstream>
#include <string>
20
#include <vector>
21 22 23 24
#include <xercesc/dom/DOM.hpp>

class rspec_parser_helper
{
25 26 27 28 29 30 31 32 33
 public:
  std::string getAttribute (const xercesc::DOMElement*, 
			    const std::string,
			    bool&);
  std::string getAttribute(const xercesc::DOMElement*, const std::string);
  bool hasAttribute (const xercesc::DOMElement*, const std::string);
  std::string readChild (const xercesc::DOMElement*, const char*, bool&);
  std::string readChild (const xercesc::DOMElement*, const char*);
  bool hasChild (const xercesc::DOMElement*, const char*);
34 35
  std::vector<xercesc::DOMElement*> 
    getChildrenByName(const xercesc::DOMElement* parent, const char* name);
36 37 38 39 40 41 42 43
  
  // Methods to convert between strings and other data types
  static std::string numToString (int num);
  static std::string numToString (double num);
  static float stringToNum (std::string str);
  
  // To determine the rspec version from the root element
  static int getRspecVersion (xercesc::DOMElement* root);
44 45 46 47 48 49 50 51 52

  // Converts the (hardwareType/sliverType) pair of rspec v2 to a single type
  // for assign's consumption
  static std::string convertType (std::string hwType, std::string slType);

  // Converts a single type name of the old format into a 
  // (hardwareType/sliverType) pair and then converts it into a single type
  // for assign's consumption
  static std::string convertType (std::string type);
53 54 55 56 57
};

#endif // __RSPEC_PARSER_HELPER_H__

#endif // WITH_XML