Пример #1
0
    void SetXMLValueForKey(const char* pKey, const char* value, rapidxml::xml_document<>& doc, rapidxml::xml_node<>* parentNode)
    {
        // check the params
        if (!pKey || !value || !parentNode)
        {
            return;
        }

        // find the node
        rapidxml::xml_node<>* node = parentNode->first_node(pKey);

        if (node)
        {
            if (node->first_node())
            {
                node->first_node()->value(doc.allocate_string(value));
            }
            else
            {
                node->value(doc.allocate_string(value));
            }
        }
        else
        {
            parentNode->append_node(doc.allocate_node(rapidxml::node_element, doc.allocate_string(pKey), doc.allocate_string(value)));
        }
    }
Пример #2
0
void XmlParse::InitXml(rapidxml::xml_document<> &doc)
{
    xml_node<> *node = doc.allocate_node(node_declaration, "", "");
    doc.append_node(node);
    xml_attribute<> *attr1 = doc.allocate_attribute("version", "1.0");
    xml_attribute<> *attr2 = doc.allocate_attribute("encoding", "UTF-8");
    node->append_attribute(attr1);
    node->append_attribute(attr2);
}
Пример #3
0
void TacheUnitaire::xml_ajouterAttributs(rapidxml::xml_document<> & doc, rapidxml::xml_node<> & node_tache)
{
   using namespace rapidxml;
   xml_attribute<> * attribute = doc.allocate_attribute("type", "u");
   node_tache.append_attribute(attribute);
   if(getPreempte() == true) {
      attribute = doc.allocate_attribute("pre", "true");
      node_tache.append_attribute(attribute);
   }
   char * node_name = doc.allocate_string( duree.toChar() );
   attribute = doc.allocate_attribute( "duree", node_name );
   node_tache.append_attribute(attribute);
}
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;
}
Пример #5
0
void Genome::FillGenes(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* chromosomeNode, Encoding& encoding){
	for (rapidxml::xml_node<>* geneNode = chromosomeNode->first_node("Gene"); geneNode; geneNode = geneNode->next_sibling("Gene"))
	{
		char* pchRandomData = doc.allocate_string(encoding.RandomData(chromosomeNode).c_str());
		geneNode->value(pchRandomData);

	}


}
Пример #6
0
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;
}
Пример #7
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;
	}
Пример #8
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;
}
Пример #9
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();
  }   
}
Пример #10
0
bool struct_xml(rapidxml::xml_node<> * & node, const ReqDeviceInfo & in, rapidxml::xml_document<> & doc)
{
node = doc.allocate_node(rapidxml::node_element, doc.allocate_string("ReqDeviceInfo"));
/* @generate [ userId:int ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, "userId", doc.allocate_string(get_string(in.userId).c_str()));
node->append_node(node1);
}
/* @generate [ userId:int ] end @ */

/* @generate [ deviceId:int ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, "deviceId", doc.allocate_string(get_string(in.deviceId).c_str()));
node->append_node(node1);
}
/* @generate [ deviceId:int ] end @ */

return true;
}
Пример #11
0
void Genome::GeneMutations(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* geneNode, Mutation& mutation, MutationChance mutationChance){

		char* pchMutatedData;

		int nLow = 0;
		int nHigh = RAND_MAX;

		double dRandom;


		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dBitString){
			pchMutatedData = doc.allocate_string(mutation.BitString().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dFlipBits){
			pchMutatedData = doc.allocate_string(mutation.FlipBits().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dBoundary){
			pchMutatedData = doc.allocate_string(mutation.Boundary().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dUniform){
			pchMutatedData = doc.allocate_string(mutation.Uniform().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dGaussian){
			pchMutatedData = doc.allocate_string(mutation.Gaussian(mutationChance.dGaussianSigma).c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dDuplication){
			pchMutatedData = doc.allocate_string(mutation.Duplication().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dDeletion){
			pchMutatedData = doc.allocate_string(mutation.Deletion().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dInsertion){
			pchMutatedData = doc.allocate_string(mutation.Insertion().c_str());
			geneNode->value(pchMutatedData);
		}

		dRandom = (double)((rand() % (nHigh - nLow + 1)) + nLow)/nHigh;
		dRandom = dRandom * 100;
		if(dRandom <=  mutationChance.dSwap){
			pchMutatedData = doc.allocate_string(mutation.Swap().c_str());
			geneNode->value(pchMutatedData);
		}

}
Пример #12
0
void XmlTree::appendRapidXmlNode( rapidxml::xml_document<char> &doc, rapidxml::xml_node<char> *parent ) const
{
	rapidxml::node_type type;
	switch( getNodeType() ) {
		case XmlTree::NODE_ELEMENT: type = rapidxml::node_element; break;
		case XmlTree::NODE_COMMENT: type = rapidxml::node_comment; break;
		case XmlTree::NODE_CDATA: type = rapidxml::node_cdata; break;
		case XmlTree::NODE_DATA: type = rapidxml::node_data; break;
		
		default: throw ExcUnknownNodeType();
	}
	rapidxml::xml_node<char> *node = 0;
	if( type == rapidxml::node_data ) {
		node = doc.allocate_node( type, NULL, doc.allocate_string( getValue().c_str() ) );
	}
	else if( type == rapidxml::node_comment ) {
		node = doc.allocate_node( type, doc.allocate_string( getTag().c_str() ), doc.allocate_string( getValue().c_str() ) );
	}
	else {
		node = doc.allocate_node( type, doc.allocate_string( getTag().c_str() ), NULL );
		if( ! getValue().empty() )
			node->append_node( doc.allocate_node( rapidxml::node_data, NULL, doc.allocate_string( getValue().c_str() ) ) );
	}
	parent->append_node( node );

	for( list<Attr>::const_iterator attrIt = mAttributes.begin(); attrIt != mAttributes.end(); ++attrIt )
		node->append_attribute( doc.allocate_attribute( doc.allocate_string( attrIt->getName().c_str() ), doc.allocate_string( attrIt->getValue().c_str() ) ) );
		
	for( Container::const_iterator childIt = mChildren.begin(); childIt != mChildren.end(); ++childIt )
		(*childIt)->appendRapidXmlNode( doc, node );
}
Пример #13
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();
 }
Пример #14
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();
	}

}
Пример #15
0
void CTest::AddXMLAttributeValue( rapidxml::xml_document<>& pDoc, rapidxml::xml_node<>* pNode, const std::wstring& strwKey, const std::wstring& strwValue )
{
	std::string straValue = wstr2str(strwValue, CP_UTF8);
	std::string strakey = wstr2str(strwKey, CP_UTF8);
	pNode->append_attribute(pDoc.allocate_attribute(pDoc.allocate_string(strakey.c_str()), pDoc.allocate_string(straValue.c_str()) ) );
}
Пример #16
0
bool struct_xml(rapidxml::xml_node<> * & node, const RetDeviceInfo & in, rapidxml::xml_document<> & doc)
{
node = doc.allocate_node(rapidxml::node_element, doc.allocate_string("RetDeviceInfo"));
/* @generate [ userId:int ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, "userId", doc.allocate_string(get_string(in.userId).c_str()));
node->append_node(node1);
}
/* @generate [ userId:int ] end @ */

/* @generate [ deviceId:int ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, "deviceId", doc.allocate_string(get_string(in.deviceId).c_str()));
node->append_node(node1);
}
/* @generate [ deviceId:int ] end @ */

/* @generate [ deviceInfos:std::vector< ReqDeviceInfo > ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, doc.allocate_string("deviceInfos"));
node->append_node(node1);
auto node2 = doc.allocate_node(rapidxml::node_element, doc.allocate_string("Vector"));
node1->append_node(node2);
for(auto i = in.deviceInfos.begin(); i != in.deviceInfos.end(); ++i)
{
rapidxml::xml_node<> * tmp = 0;
if(!struct_xml(tmp, *i, doc))
return false;
node2->append_node(tmp);
}
}
/* @generate [ deviceInfos:std::vector< ReqDeviceInfo > ] end @ */

/* @generate [ deviceInfos2:std::vector< int > ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, doc.allocate_string("deviceInfos2"));
node->append_node(node1);
auto node2 = doc.allocate_node(rapidxml::node_element, doc.allocate_string("Vector"));
node1->append_node(node2);
for(auto i = in.deviceInfos2.begin(); i != in.deviceInfos2.end(); ++i)
{
rapidxml::xml_node<> * tmp = 0;
if(!struct_xml(tmp, *i, doc))
return false;
node2->append_node(tmp);
}
}
/* @generate [ deviceInfos2:std::vector< int > ] end @ */

/* @generate [ deviceInfo:ReqDeviceInfo ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, "deviceInfo");
node->append_node(node1);
rapidxml::xml_node<> * node2 = 0;
if(!struct_xml(node2, in.deviceInfo, doc))
return false;
node1->append_node(node2);
}
/* @generate [ deviceInfo:ReqDeviceInfo ] end @ */

/* @generate [ time:int ] begin @ */

{
auto node1 = doc.allocate_node(rapidxml::node_element, "time", doc.allocate_string(get_string(in.time).c_str()));
node->append_node(node1);
}
/* @generate [ time:int ] end @ */

return true;
}
Пример #17
0
	sdn_fact_rapidxml_element(rapidxml::xml_document<>& doc)
	 : node(doc.first_node())
	{
	}