int CharmLoader::countCharms(rapidxml::xml_document<>& doc) {
	int num = 0;

	rapidxml::xml_node<>* ptr = doc.first_node()->first_node();
	while (ptr != nullptr) {
		num++;
		ptr = ptr->next_sibling();
	}
	return num;
}
示例#2
0
文件: image.cpp 项目: metiscus/meow
std::shared_ptr<Resource> Image::Load(rapidxml::xml_document<> &doc)
{
    std::shared_ptr<Resource> ret;
    rapidxml::xml_node<> *node = doc.first_node("resource");
    assert(node);

    ResourceId resId = Resource::StringToResourceId(node->first_attribute("uuid")->value());
    ret.reset(new Image(resId));

    //TODO: Actually perform the loading of the image file here
    return ret;
}
示例#3
0
	XmlNodeRef XmlParserImp::parse(char* buffer, int bufLen, const char* rootNodeName, behaviac::string& errorString, bool isFinal)
	{
		BEHAVIAC_UNUSED_VAR(bufLen);
		BEHAVIAC_UNUSED_VAR(errorString);
		BEHAVIAC_UNUSED_VAR(isFinal);

		m_parser.parse<0>(buffer);

		rapidxml::xml_node<>* xmlnode = m_parser.first_node(rootNodeName);

		XmlNodeRef node = cloneXmlNodeFrom(xmlnode);

		return node;
	}
示例#4
0
// TODO consider creating dove::xml and moving all of my 
// helper functions into that namespace to keep it clean
std::vector<rapidxml::xml_node<char>*> dove::get_all_hosts(
    rapidxml::xml_document<char> &system) {
  xdebug("Getting all hosts from system.xml");
  rapidxml::xml_node<>* nodes = system.first_node("system")->
    first_node("nodes");
  
  std::vector<rapidxml::xml_node<char>*> result;
  for (rapidxml::xml_node<char> *child = nodes->first_node();
      child;
      child = child->next_sibling()) {
    if (strcmp(child->name(), "node")==0)
      result.push_back(child);
  }
  
  return result;
}
示例#5
0
// TODO make this set type on hardware component
void dove::parse_pids(rapidxml::xml_document<char> &system, 
  std::string logical_id,
  int &node_pid, 
  int &proc_pid, 
  int &core_pid, 
  int &hwth_pid, 
  std::string &hostname, 
  std::string &ip) {

rapidxml::xml_node<>* nodes = system.first_node("system")->
  first_node("nodes");
rapidxml::xml_node<>* node = get_child_with_attribute(nodes, "id", 
    logical_id);

// While we have not returned to the root
while (strcmp(node->name(), "nodes") != 0) {
  std::string name = node->name();
  int pindex = atoi( node->first_attribute("pindex")->value() );
  if (name.compare("pu") == 0) {
    hwth_pid = pindex;
  }
  else if (name.compare("core") == 0)
    core_pid = pindex;
  else if (name.compare("socket") == 0) 
    proc_pid = pindex;
  else if (name.compare("node") == 0) {
    node_pid = pindex;
      ip = node->first_attribute("ip")->value();
      hostname = node->first_attribute("hostname")->value();
    }
    else
      throw "Unknown tag in XML. Valid values underneath 'nodes' are node,socket,core,pu";
    
    node = node->parent();
  }   
}
示例#6
0
void InfoDTVFileProcesser::ProcessInfoDTVIBLObject(InfoDTVObjectPtr aObject, rapidxml::xml_document<> &aXmlDocument)
{

	aXmlDocument.clear();

	//						boost::shared_array<char> Content(new char[aObject->IBLFileContent.size() + 1]);
	boost::shared_ptr<char> Content((char *)std::malloc(aObject->IBLFileContent.size() + 1),&free);//new char[aObject->IBLFileContent.size() + 1]);
	strcpy(Content.get(), aObject->IBLFileContent.c_str());
	//aXmlDocument->Parse(aObject->IBLFileContent.c_str());
	aXmlDocument.parse<0> (Content.get());

	rapidxml::xml_node<> *node = aXmlDocument.first_node();

	while (node)
	{
		//								cout << "Name of  node is: " << node->name() << "\n";
		//								cout << "Node  has value " << node->value() << "\n";
		string TagName = node->name();

		TagName = toUpper(TagName);
		if (TagName == "IMG")
		{
			IBLProcessImageLink(aObject, node, 0);
			IBLProcessAction(aObject, node, "laction", "lasrc");
			IBLProcessAction(aObject, node, "faction", "fasrc");
			IBLProcessAction(aObject, node, "action", "asrc");
			//								attr = node->first_attribute("laction", 7, false);
			//								attr = node->first_attribute("lasrc", 5, false);
			//								attr = node->first_attribute("faction", 7, false);
			//								attr = node->first_attribute("fasrc", 5, false);
			//								for (xml_attribute<> *attr = node->first_attribute(); attr; attr
			//								        = attr->next_attribute())
			//								{
			//								    cout << "Node has attribute " << attr->name() << " ";
			//								    cout << "with value " << attr->value() << "\n";
			//								}

		}
		else if (TagName == "STBAD")
		{
			IBLProcessImageLink(aObject, node, 0);
		}
		else if (TagName == "TEXTLINK")
		{
			IBLProcessAction(aObject, node, "laction", "lasrc");
			IBLProcessAction(aObject, node, "faction", "fasrc");
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "REGION")
		{
			IBLProcessImageLink(aObject, node, 1);
		}
		else if (TagName == "GROUPACTION")
		{
			//xml_attribute<> *attr = node->first_attribute("bkimg", 6, false);
			string Value = node->value();
			IBLProcessGroupAction(aObject, Value);
		}
		else if(TagName=="KEYACTION")
		{
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "FORCEACTION")
		{
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "CARDID")
		{
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "BOUQUETID")
		{
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "STBID")
		{
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "NUMINPUT")
		{
			//								string Value = node->value();
			//								IBLProcessGroupAction(aObject, Value);
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		else if (TagName == "VCHANNEL")
		{
			string Value = node->value();
			IBLProcessGroupAction(aObject, Value);
		}
		else if (TagName == "CODEINPUT")
		{
			IBLProcessAction(aObject, node, "laction", "lasrc");
			IBLProcessAction(aObject, node, "faction", "fasrc");
			string Value = node->value();
			IBLProcessGroupAction(aObject, Value);
		}
		else if (TagName == "SLOT")
		{
			string Value = node->value();
			IBLProcessGroupAction(aObject, Value);
		}
		else if (TagName == "LINKRESOURCEINFO")
		{
			IBLProcessLinkResourceInfo(aObject,node);
			//								string Value = node->value();
			//								IBLProcessGroupAction(Value);
		}
		else if(TagName=="SELECTFILE")
		{
			IBLProcessAction(aObject, node, "action", "asrc");
		}
		node = node->next_sibling();
	}

}
示例#7
0
	sdn_fact_rapidxml_element(rapidxml::xml_document<>& doc)
	 : node(doc.first_node())
	{
	}
示例#8
0
 rapidxml::xml_node<char>* parsed_config()
 {
   ctext = doc.allocate_string(xml_config.c_str());
   doc.parse< rapidxml::parse_no_data_nodes >(ctext);
   return doc.first_node();
 }