Exemplo n.º 1
0
bool Triggers::parse() {
  XMLDocument doc;
  if (doc.LoadFile(mXmlFile.c_str())) {
    doc.PrintError();
    return false;
  }

  const XMLElement* root = doc.FirstChildElement("triggers");
  if (! root)
    return false;

  const XMLElement* runs = root->FirstChildElement("runs");
  for (; runs; runs = runs->NextSiblingElement("runs")) {
    parseRunsElement(runs);
  }

  return true;
}
Exemplo n.º 2
0
void FileList::write() {
	XMLDocument doc;
	{
		XMLElement* filelist = doc.NewElement("filelist");
		filelist->SetAttribute("application", "video-organizer");
		filelist->SetAttribute("version", "1.0");
		for (unsigned i = 0; i < records.size(); i++) {
			XMLElement* record = doc.NewElement("record");
			record->SetAttribute("from", records[i].from.c_str());
			record->SetAttribute("to", records[i].to.c_str());
			record->SetAttribute("action", records[i].action);
			filelist->InsertEndChild(record);
		}
		doc.InsertEndChild(filelist);
	}
	XMLError ret = doc.SaveFile((dir + "filelist").c_str());
	if (ret) console.e("Error writing filelist: %s", ret);
}
Exemplo n.º 3
0
void rss_feed_parse(const std::string &feed)
{
    XMLDocument doc;
    doc.Parse(feed.c_str());
    XMLElement *rss = doc.FirstChildElement("rss");
    if (rss) {
        XMLElement *channel = rss->FirstChildElement("channel");
        if (channel) {
            for (XMLElement *article = channel->FirstChildElement("item"); article; article = article->NextSiblingElement("item")) {
                XMLElement *title = article->FirstChildElement("title"); 
                XMLElement *link = article->FirstChildElement("link"); 
                std::cout << title->GetText() << std::endl;
                std::cout << link->GetText() << std::endl;
                std::cout << std::endl;
            }
        }
    }
}
Exemplo n.º 4
0
bool MCTriggers::parse() {
  XMLDocument doc;
  if (doc.LoadFile(mXmlFile.c_str())) {
    doc.PrintError();
    return false;
  }

  const XMLElement* root = doc.FirstChildElement("triggers");
  if (! root)
    return false;

  const XMLElement* path = root->FirstChildElement("path");
  for (; path; path = path->NextSiblingElement("path")) {
    parsePathElement(path);
  }

  return true;
}
Exemplo n.º 5
0
int SPECAPIENTRY readSpecs(const char* xmlData, unsigned int bytes,
    Function** functions, unsigned int* functionCount,
    Constant** constants, unsigned int* constantsCount)
{
    XMLDocument document;
    if (document.Parse(xmlData, bytes) == XMLError::XML_NO_ERROR)
    {
        XMLElement* registry = document.FirstChildElement("registry");
        if (registry)
        {
            ObtainConstants(registry, constantsCount, constants);
            ObtainCommands(registry, functionCount, functions);
            ObtainFeatures(registry, functionCount, functions);
            ObtainExtensions(registry, functionCount, functions);
        }
    }
    return 0;
}
Exemplo n.º 6
0
void pluginManager::addPluginByXML(const char* name)
{
	//fprintf(stderr,"[DEBUG] addPluginByXML(%s)\n",name);
	XMLDocument doc;
	doc.LoadFile(name);

	// TODO add exception handle here
	const char* libName = doc.FirstChildElement("libname")->GetText();
	const char* funcName = doc.FirstChildElement("funcname")->GetText();
	const char* freqs = doc.FirstChildElement("freq")->GetText();

	int sleepInterval = atoi(freqs);

	struct arguments A;
	A.iv = sleepInterval;

	addPlugin(libName ,funcName ,A);
}
Exemplo n.º 7
0
 // Only public function of the module
 void apply_style(XMLDocument const & xml, XMLDocument const & xsl,
     std::ostream & out, std::ostream & err)
 {
   if (Validator(*xsl.root(), err)())
   {
     Document xsl_doc(xsl);
     xsl_doc.apply_style_to(xml, out);
   }
 }
Exemplo n.º 8
0
void TR_svtImp::xmlParse(const string &set, vector< Ptr<Object> > &out)
{
    XMLDocument doc;
    doc.LoadFile(set.c_str());
    XMLElement *root_ = doc.RootElement();
    string rootElem(root_->Name());
    if (rootElem == "tagset")
    {
        string strImage("image");
        XMLElement *child = root_->FirstChildElement(strImage.c_str());
        while (child)
        {
            string imageName = child->FirstChildElement("imageName")->GetText();
            string lex = child->FirstChildElement("lex")->GetText();

            Ptr<TR_svtObj> curr(new TR_svtObj);
            curr->fileName = imageName;
            split(lex, curr->lex, ',');

            XMLElement *childTaggeds = child->FirstChildElement("taggedRectangles");
            if (childTaggeds)
            {
                string strTagged("taggedRectangle");
                XMLElement *childTagged = childTaggeds->FirstChildElement(strTagged.c_str());
                while (childTagged)
                {
                    tag t;
                    t.value = childTagged->FirstChildElement("tag")->GetText();
                    t.height = atoi(childTagged->Attribute("height"));
                    t.width = atoi(childTagged->Attribute("width"));
                    t.x = atoi(childTagged->Attribute("x"));
                    t.y = atoi(childTagged->Attribute("y"));
                    curr->tags.push_back(t);

                    childTagged = childTagged->NextSiblingElement(strTagged.c_str());
                }
            }

            out.push_back(curr);

            child = child->NextSiblingElement(strImage.c_str());
        }
    }
}
Exemplo n.º 9
0
bool loadDatasetConfig(const string &filepath, ConfigXML &outConfigXML) {

	cout << "Carregando ConfigXML... ";
	
	// se houver problemas para abrir o arquivo, retorna false
	XMLDocument doc;
	XMLError error = doc.LoadFile(filepath.c_str());
	if (error != XML_NO_ERROR) {
		cout << "erro!" << endl;
		return false;
	}

	// pega as configs do m�todo
	XMLElement* configTag = doc.FirstChildElement("config");
	outConfigXML.verbose = (strcmp(configTag->FirstChildElement("verbose")->GetText(), "true") == 0);
	outConfigXML.display = (strcmp(configTag->FirstChildElement("display_images")->GetText(), "true") == 0);
	outConfigXML.numParticles = configTag->FirstChildElement("particle_filter")->IntAttribute("num");

	// pega as configs do dataset
	XMLElement* dataset = doc.FirstChildElement()->FirstChildElement("dataset");
	outConfigXML.dataset.id = dataset->Attribute("id");
	outConfigXML.dataset.name = dataset->Attribute("name");
	outConfigXML.dataset.path = dataset->Attribute("path");
	outConfigXML.dataset.FrameSequence.start = dataset->FirstChildElement("frame_sequence")->IntAttribute("start");
	outConfigXML.dataset.FrameSequence.end = dataset->FirstChildElement("frame_sequence")->IntAttribute("end");
	outConfigXML.dataset.FrameSize.width = dataset->FirstChildElement("frame_size")->IntAttribute("width");
	outConfigXML.dataset.FrameSize.height = dataset->FirstChildElement("frame_size")->IntAttribute("height");
	outConfigXML.dataset._ROI.x = dataset->FirstChildElement("region_of_interest")->IntAttribute("x");
	outConfigXML.dataset._ROI.y = dataset->FirstChildElement("region_of_interest")->IntAttribute("y");
	outConfigXML.dataset._ROI.width = dataset->FirstChildElement("region_of_interest")->IntAttribute("width");
	outConfigXML.dataset._ROI.height = dataset->FirstChildElement("region_of_interest")->IntAttribute("height");
	outConfigXML.dataset._IPM.tr = dataset->FirstChildElement("ipm_points")->IntAttribute("top_right");
	outConfigXML.dataset._IPM.tl = dataset->FirstChildElement("ipm_points")->IntAttribute("top_left");
	outConfigXML.dataset._IPM.br = dataset->FirstChildElement("ipm_points")->IntAttribute("bottom_right");
	outConfigXML.dataset._IPM.bl = dataset->FirstChildElement("ipm_points")->IntAttribute("bottom_left");

	// Constr�i o ipm e a roi
	setROI(outConfigXML);
	setIPM(outConfigXML);

	cout << "pronto!" << endl;

	return true;
}
model::describe_volumes_response::describe_volumes_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	const XMLNode *RootNode = doc.FirstChild();
  if (RootNode) {
    set_string_value(RootNode, "requestId", request_id);
    const XMLElement * Element = RootNode->FirstChildElement("volumeSet");
    const XMLElement * ListElement = NULL;
    if (Element)
      ListElement = Element->FirstChildElement("item");
    while(ListElement != NULL)
    {
      string status,volume_id, device, instance_id, snapshot_id,create_time;
      bool encrypted = false;
      string volume_type;
      float size;

      set_string_value(ListElement, "status", status);
      set_string_value(ListElement, "volumeId", volume_id);
      //Attachment set
      const XMLElement* attachment = ListElement->FirstChildElement("attachmentSet");
      if (attachment) {
        const XMLElement* items = attachment->FirstChildElement("item");
        if (items) {
          set_string_value(items, "device", device);
          set_string_value(items, "instanceId", instance_id);
        }
      }
      set_string_value(ListElement, "snapshotId", snapshot_id);
      set_string_value(ListElement, "createTime", create_time);
      set_float_value(ListElement, "size", size);
      set_bool_value(ListElement, "encrypted", encrypted);

      model::volume data(status, volume_id, device, instance_id, snapshot_id, create_time, size, encrypted, volume_type);
      volume_set.push_back(data);

      ListElement=ListElement->NextSiblingElement();

    }
  }
}
Exemplo n.º 11
0
bool TiledMap::loadMap(string source)
{
    XMLDocument map;
    map.LoadFile(source.data());

    XMLElement* map_info =  map.FirstChildElement("map");

    this->version = map_info->Attribute("version");
    this->orientation = map_info->Attribute("orientation");

    this->width = this->stringToInt(map_info->Attribute("width"));
    this->height = this->stringToInt(map_info->Attribute("height"));
    this->tilewidth = this->stringToInt(map_info->Attribute("tilewidth"));
    this->tileheight = this->stringToInt(map_info->Attribute("tileheight"));

    this->loadTilesets(&map);
    this->loadLayers(&map);
    this->loadObjectGroups(&map);
}
model::describe_instance_types_response::describe_instance_types_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	XMLNode *RootNode = doc.FirstChild();
	XMLElement *Element = RootNode->FirstChildElement("requestId");
	if(Element!=NULL)
	{
		if(Element->GetText()!=NULL) request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing request_id from XML describe_instance_types_response\n";
	
	XMLElement *InstanceTypeElement,*ListElement = Element->FirstChildElement("item");
	float vcpus,ram;
	string id;
	while(ListElement != NULL)
	{
		InstanceTypeElement = ListElement->FirstChildElement("vcpus");
		if(InstanceTypeElement!=NULL)
		{
			InstanceTypeElement->QueryFloatText(&vcpus);
			InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
		}
		else cout<<"Error Parsing VCPUS from XML describe_instance_types_response\n";
		if(InstanceTypeElement!=NULL)
		{	
			InstanceTypeElement->QueryFloatText(&ram);
			InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
		}
		else cout<<"Error Parsing RAM data from XML describe_instance_types_response\n";

		if(InstanceTypeElement!=NULL)
			{if(InstanceTypeElement->GetText() != NULL)id = InstanceTypeElement->GetText();}
		else cout<<"Error Parsing instance_id from XML describe_instance_types_response\n";
		//Add to map
		model::instance_type data(vcpus, ram, id);
		instance_type_set.push_back(data);

		ListElement=ListElement->NextSiblingElement();
	}
}
Exemplo n.º 13
0
/**
 * Parses an XML document, which should be one of the three Query Rewrite
 * descriptor types, and builds a hierarchy of classes representing the
 * elements of the document.
 *
 * @param xmlText Text of the descriptor to be parsed.
 * @param xmlLen  Length of the descriptor text.
 * @param[out] descriptor Pointer to class instance representing the document
 *                        element of the parsed document.
 * @return Status indicator.
 */
static QRRequestResult parseXML(char* xmlText, Int32 xmlLen,
                                XMLElementPtr &descriptor)
{
  try
    {
      QRElementMapper em;
      XMLDocument doc = XMLDocument(STMTHEAP, em);
      descriptor = doc.parse(xmlText, xmlLen, TRUE);

      if (!descriptor)
        {
          // LCOV_EXCL_START :rfi
          QRLogger::log(CAT_QR_HANDLER, LL_MVQR_FAIL,
            "XMLDocument.parse() returned NULL.");
          return XMLParseError;
          // LCOV_EXCL_STOP
        }
      else
        ;//debugMessage("Parsed XML document successfully.");
    }
  // LCOV_EXCL_START :rfi
  catch (XMLException& ex)
    {
      QRLogger::log(CAT_QR_HANDLER, LL_MVQR_FAIL,
        "An XMLException occurred: %s", ex.getMessage());
      return XMLParseError;
    }
  catch (QRDescriptorException& ex)
    {
      QRLogger::log(CAT_QR_HANDLER, LL_MVQR_FAIL,
        "A QRDescriptorException occurred: %s", ex.getMessage());
      return XMLParseError;
    }
  catch (...)
    {
      QRLogger::log(CAT_QR_HANDLER, LL_MVQR_FAIL,
        "An Unknown exception occurred");
      return InternalError;
    }
  // LCOV_EXCL_STOP

  return Success;
}
Exemplo n.º 14
0
void OccluderMap::loadFromXML(const XMLDocument &doc) {
	clear();

	for(int n = 0; n < m_grid.size(); n++)
		if(m_grid[n].ptr)
			ASSERT(m_grid[n].occluder_id == -1);

	XMLNode main_node = doc.child("occluders");

	if(main_node) {
		XMLNode occluder_node = main_node.child("occluder");
		vector<int> temp;
		temp.reserve(m_grid.size());

		while(occluder_node) {
			int occluder_id = size();
			m_occluders.push_back(Occluder());
			Occluder &occluder = m_occluders.back();
			
			int object_count = occluder_node.attrib<int>("object_count");
			ASSERT(object_count < m_grid.size() && object_count > 0);
			occluder.objects.resize(object_count, -1);

			XMLNode box_node = occluder_node.child("box");
			bool first = true;
			while(box_node) {
				FBox bbox(box_node.attrib<float3>("min"), box_node.attrib<float3>("max"));
				occluder.bbox = first? bbox : sum(occluder.bbox, bbox);
				first = false;

				temp.clear();
				m_grid.findAll(temp, bbox);
				for(int n = 0; n < (int)temp.size(); n++)
					m_grid[temp[n]].occluder_id = occluder_id;
				box_node = box_node.sibling("box");
			}
			
			occluder_node = occluder_node.sibling("occluder");
		}

		vector<int> counts(m_occluders.size(), 0);
		for(int n = 0; n < m_grid.size(); n++) {
			int occ_id = m_grid[n].occluder_id;
			if(occ_id != -1 && m_grid[n].ptr) {
				Occluder &occluder = m_occluders[occ_id];
				int count = counts[occ_id];
				ASSERT(count < (int)occluder.objects.size());
				occluder.objects[count++] = n;
				counts[occ_id] = count;
			}
		}
		for(int n = 0; n < (int)counts.size(); n++)
			ASSERT(counts[n] == (int)m_occluders[n].objects.size());
	}
}
Exemplo n.º 15
0
set<string> compareWithStorageFile(const string& path) {
  map<string, time_t> storage;
	
  XMLDocument doc;
  if (doc.LoadFile(gStorage.c_str())!=XML_NO_ERROR) {
    cerr << "Error reading XML!" << endl;
    doc.PrintError();
  }
  auto root  = doc.FirstChildElement();
  auto file = root->FirstChildElement();
  while (file) {
    string name = file->FirstAttribute()->Value();
    auto time = file->Attribute("last_modif");
    storage[name] = stoll(time);
    file = file->NextSiblingElement();
  }

  set<string> dst;
  fs::path current(path);
  fs::recursive_directory_iterator end;
  cout << "Go to directory iterator: " << current.string() << " -> " << endl;
  for (fs::recursive_directory_iterator item(current); item != end; ++item) {
    if (!fs::is_directory(item->status())) {
      fs::path filename = item->path();

      time_t time = fs::last_write_time(filename);
      auto sfile = filename.string().substr(current.string().size());
      if (storage.count(sfile)>0) {
	if (storage[sfile]!=time) {
          dst.insert(sfile);
	  cout << "[mod] " << sfile << endl;
	}
      }
      else {
	dst.insert(sfile);
	cout << "[new] " << sfile << endl; 
      }
    }
  }

  return dst;
}
Exemplo n.º 16
0
void XmlReader::xmlReadMeetingInfo(void)
{
    XMLDocument doc;
    doc.LoadFile(m_filename);
    if (doc.ErrorID() != 0) {
        printf("read xml error!\n");
        return;
    }
    XMLElement *root = doc.FirstChildElement("root");

    XMLElement *meetings = root->FirstChildElement("meetings");
    for (XMLElement *meeting = meetings->FirstChildElement("meeting");
         meeting;
         meeting = meeting->NextSiblingElement("meeting")) {
        XMLElement *meeting_id = meeting->FirstChildElement("meeting_id");
        XMLElement *meeting_name = meeting->FirstChildElement("meeting_name");
        XMLElement *start_time = meeting->FirstChildElement("start_time");
        XMLElement *end_time = meeting->FirstChildElement("end_time");
        XMLElement *meeting_conferrees = meeting->FirstChildElement("meeting_conferrees");

        printf("meeting_id: %s\n", meeting_id->GetText());
        printf("meeting_name: %s\n", meeting_name->GetText());
        printf("start_time: %s\n", start_time->GetText());
        printf("end_time: %s\n", end_time->GetText());
        printf("conferreess:\n");
        if (meeting_conferrees) {
            for (XMLElement *meeting_conferree = meeting_conferrees->FirstChildElement("meeting_conferree");
                 meeting_conferree;
                 meeting_conferree = meeting_conferree->NextSiblingElement("meeting_conferree")) {

                XMLElement *user2_id = meeting_conferree->FirstChildElement("user_id");
                XMLElement *user2_account = meeting_conferree->FirstChildElement("user_acount");
                XMLElement *user2_name = meeting_conferree->FirstChildElement("user_name");

                printf("user_id: %s\n", user2_id->GetText());
                printf("user_account: %s\n",  user2_account->GetText());
                printf("user_name: %s\n", user2_name->GetText());
            }
        }
        printf("\n");
    }
}
model::start_instances_response::start_instances_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	XMLNode *RootNode = doc.FirstChild();
	XMLElement *Element = RootNode->FirstChildElement("requestId");
	if(Element!= NULL)
	{
		if(Element->GetText() != NULL)request_id = Element->GetText();
		Element = Element->NextSiblingElement();
	}	
	
	XMLElement *ListElement = Element->FirstChildElement("item");
	XMLElement *InstanceSetElement;
	string instance_id, current_state, previous_state; 
	while(ListElement != NULL)
	{
		InstanceSetElement = ListElement->FirstChildElement("instanceId");
		if(InstanceSetElement!=NULL)
		{
			if(InstanceSetElement->GetText()!=NULL)instance_id = InstanceSetElement->GetText();
			InstanceSetElement=InstanceSetElement->NextSiblingElement();
		}
		else cout<<"Error Parsing instance_id from start_instances_response";
		if(InstanceSetElement!=NULL)
		{	
			current_state = InstanceSetElement->GetText();
			InstanceSetElement=InstanceSetElement->NextSiblingElement();
		}
		else cout<<"Error Parsing current_state from XMl start_instances_response";
		
		if(InstanceSetElement!=NULL)
			{if(InstanceSetElement->GetText()!=NULL)previous_state = InstanceSetElement->GetText();}
		else cout<<"Error Parsing previous_state from XML start_instances_response";
		//Add to the map;
		model::instance_set data(instance_id, current_state, previous_state);
		instances.push_back(data);
		
		ListElement=ListElement->NextSiblingElement();
	}
}
Exemplo n.º 18
0
bool CGBFile<GeomType, ValueType>::save(const std::string& directoryname, const std::string& fn, const Volume3d<GeomType, ValueType>& volume)
{	
	const std::string& filename = directoryname + "/" + fn;
	XMLDocument xml;
	XMLDeclaration* decl = xml.NewDeclaration();
	xml.InsertEndChild(decl);
	XMLNode* root = xml.NewElement("root");
	xml.InsertEndChild(root);

	{
		XMLElement* res = xml.NewElement(resStr.c_str());

		res->SetAttribute("x", volume.getResolutions()[0]);
		res->SetAttribute("y", volume.getResolutions()[1]);
		res->SetAttribute("z", volume.getResolutions()[2]);

		root->InsertEndChild(res);
	}

	root->InsertEndChild( create(xml, originStr, volume.getStart()) );
	root->InsertEndChild( create(xml, "length", volume.getSpace().getLengths()));

	imageFileNames.clear();
	{
		XMLElement* e = xml.NewElement("volume");

		e->SetAttribute("type", "unsigned char");
		e->SetAttribute("format", "png");

		VolumeFile vFile(directoryname);
		for (size_t i = 0; i < volume.getResolutions()[2]; ++i) {
			const auto iFile = vFile.toImageFile( "image", i, ImageFile::Type::PNG);
			XMLElement* elem = xml.NewElement("image");
			const auto& str = iFile.getFileNameIncludingPath();
			elem->SetAttribute("path", str.c_str());
			e->InsertEndChild(elem);
			imageFileNames.push_back(str);
		}

		root->InsertEndChild(e);
	}

	//for (size_t i = 0; i < )
	
	xml.SaveFile(filename.c_str());
	return true;
}
Exemplo n.º 19
0
bool XMLOperation::fixAttribute1(const char *filePath, const char *elementId, const char *name, const char *value,const char* defId,bool fullPath)
{
    std::string fullpath_str = filePath;
    
    if (!fullPath)
    {
        fullpath_str.clear();
        fullpath_str = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(filePath);
        
    }
    
    cout<<"修改文件读取的路径:"<<fullpath_str<<endl;
    
    XMLDocument *pDoc = new XMLDocument();
    pDoc->LoadFile(fullpath_str.c_str());
    
    XMLElement *rootElement = pDoc->FirstChildElement();
    XMLElement *xElement = rootElement->FirstChildElement();
    
    bool isFixed = false;
    
    while (xElement)//一条记录
    {
        if (strcmp(xElement->Attribute(defId),elementId) == 0)
        {
            xElement->SetAttribute(name, value);
//            cout<<"属性id 值:"<<xElement->Attribute(defId)<<"比较id "<<elementId<<" name "<<name<<" value:"<<value<<endl;
            
        if (pDoc->SaveFile(fullpath_str.c_str()) == XML_SUCCESS) {
                isFixed = true;
            }
            break;

        }
    
        xElement = xElement->NextSiblingElement();
    }
    
    delete pDoc;
    
    return isFixed;
}
Exemplo n.º 20
0
void XMLOperation::readXML(const char *filePath)
{
    XMLDocument *pDoc = new XMLDocument();
    pDoc->LoadFile(filePath);
    
    XMLElement *rootElement = pDoc->FirstChildElement();
    XMLElement *xElement = rootElement->FirstChildElement();
    
    while (xElement) {
        
        cout<<xElement->Name()<<endl;
        
        XMLOperation::readAttribute(xElement, _xmlDic);
        
        xElement = xElement->NextSiblingElement();
    }
    
    delete pDoc;
    
}
Exemplo n.º 21
0
int main (int argc, char const* argv[])
{
    XMLDocument doc;
    
    doc.LoadFile("resource/example4.xml");
    
    XMLElement* element = doc.FirstChildElement("MyApp");
    element = element->FirstChildElement("Messages")->FirstChildElement("value");

    if(element){
        float value;
        element->QueryFloatText(&value);

        cout<< value+2 << endl;
    }else{
        cout<<"not found"<<endl;
    }
    
    return 0;
}
Exemplo n.º 22
0
	void ImageMapWorldCreator::readXML(MapDirectory* mapDirectory, Engine* engine, SDL_Surface* surface, World* world)
	{
		XMLDocument document;
		if (document.LoadFile(mapDirectory->getXMLPath().c_str()) == XML_NO_ERROR) {
			XMLElement* mapElement = document.FirstChildElement("map");
			if (mapElement) {
				XMLElement* backgroundsElement = mapElement->FirstChildElement("backgrounds");
				XMLElement* texturesElement = mapElement->FirstChildElement("textures");
				if (texturesElement) {
					readTexturesElement(texturesElement, surface);
				}
				if (backgroundsElement) {
					readBackgroundsElement(backgroundsElement, engine, mapDirectory, world);
				}
			}
		} else {
			cout << document.GetErrorStr1() << endl;
			cout << document.GetErrorStr2() << endl;
		}
	}
Exemplo n.º 23
0
    // Static functions.
    void loadGeometriesFromFile(std::vector<MeshGeometry> &geos, const char* filename) {
        XMLDocument doc;
        XMLConstHandle node(NULL);

        doc.LoadFile(filename);

        node = XMLConstHandle(&doc)
            .FirstChildElement("COLLADA")
            .FirstChildElement("library_geometries")
            .FirstChildElement("geometry");

        while (node.ToElement() != NULL && node.FirstChildElement("mesh").ToElement() != NULL) {
            MeshGeometry mg = MeshGeometry();
            mg.id = node.ToElement()->Attribute("id");
            mg.name = node.ToElement()->Attribute("name");
            loadMeshGeometry(mg, node.FirstChildElement("mesh"));
            geos.push_back(mg);
            node = node.NextSiblingElement("geometry");
        }
    }
bool osmsMessageRegisterContentAssignIdentifierRequest::decode(char* xmlText)
{
	XMLDocument* pDoc = new XMLDocument();
	if (pDoc == NULL)
		return false;

	if (!pDoc->decode(xmlText, getName()))
	{
		delete pDoc;
		return false;
	}

	setMessageType(pDoc->getInteger("MessageType"));
	setMetadataType(pDoc->getString("MetadataType"));
	setMetadataXml(pDoc->getString("MetadataXml"));

	delete pDoc;

	return true;
}
bool osmsMessageRegisterDigitalItemInstanceResponseError::decode(char* xmlText)
{
	XMLDocument* pDoc = new XMLDocument();
	if (pDoc == NULL)
		return false;

	if (!pDoc->decode(xmlText, getName()))
	{
		delete pDoc;
		return false;
	}

	setMessageType(pDoc->getInteger("MessageType"));
	setErrorCode(pDoc->getInteger("ErrorCode"));
	setResponseString(pDoc->getString("ResponseString"));

	delete pDoc;

	return true;
}
Exemplo n.º 26
0
void highscore::reloadHighScore()
{
    string playerNameTMP;
    int scoreTMP;

    // Clear highscore list first
    this->highScoreData.clear();

    // Initialize XML reader
    XMLDocument xmlHighScore;
    XMLElement *nodeTransversal;
    xmlHighScore.LoadFile("score.xml");

    // Get first child
    nodeTransversal = xmlHighScore.FirstChildElement("hs");
    playerNameTMP = string(nodeTransversal->FirstChildElement("name")->GetText());
    scoreTMP = atoi(nodeTransversal->FirstChildElement("score")->GetText());
    this->addScore(playerNameTMP, scoreTMP);

    // Get all node
    while(true)
    {
        nodeTransversal = nodeTransversal->NextSiblingElement("hs");
        if(nodeTransversal)
        {
            playerNameTMP = string(nodeTransversal->FirstChildElement("name")->GetText());
            scoreTMP = atoi(nodeTransversal->FirstChildElement("score")->GetText());
            this->addScore(playerNameTMP, scoreTMP);
        }
        else
        {
            break;
        }
    }

    // Sort highscore depend on its score
    this->highScoreData.sort(hsComp);



}
Exemplo n.º 27
0
// TODO : error checking
memorymap_t* loadMemoryMap(char* path)
{
	if(!path)return NULL;

    XMLDocument doc;
    if(doc.LoadFile(path))return NULL;

	memorymap_t* ret = (memorymap_t*) malloc(sizeof(memorymap_t));
	if(!ret) return NULL;

    XMLElement* header_element = doc.FirstChildElement("header");
	if(header_element)
	{
		ret->num = getXmlUnsignedInt(header_element->FirstChildElement("num"));
		ret->processLinearOffset = getXmlUnsignedInt(header_element->FirstChildElement("processLinearOffset"));
	}else return NULL;

    XMLElement* map = doc.FirstChildElement("map");
    if(map)
    {
		int i = 0;

		for (tinyxml2::XMLElement* child = map->FirstChildElement(); child != NULL && i < ret->num; child = child->NextSiblingElement())
		{
			if(!strcmp(child->Name(), "entry"))
			{
				ret->map[i].src = getXmlInt(child->FirstChildElement("src"));
				ret->map[i].dst = getXmlInt(child->FirstChildElement("dst"));
				ret->map[i].size = getXmlInt(child->FirstChildElement("size"));

				i++;
			}
		}

		if(i == ret->num) return ret;
    }

    free(ret);

    return NULL;
}
Exemplo n.º 28
0
// TODO : error checking
Result loadShortcut(shortcut_s* s, char* path)
{
    if(!s || !path)return -1;

    XMLDocument doc;
    if(doc.LoadFile(path))return -2;

    XMLElement* shortcut = doc.FirstChildElement("shortcut");
    if(shortcut)
    {
        XMLElement* executable = shortcut->FirstChildElement("executable");
        if(executable)
        {
            const char* str = executable->GetText();
            if(str)
            {
                s->executable = (char*)malloc(strlen(str) + 1);
                if(s->executable) strcpy(s->executable, str);
            }
        }
        if(!s->executable) return -3;

        XMLElement* descriptor = shortcut->FirstChildElement("descriptor");
        const char* descriptor_path = path;
        if(descriptor) descriptor_path = descriptor->GetText();
        if(descriptor_path)
        {
            s->descriptor = (char*)malloc(strlen(descriptor_path) + 1);
            if(s->descriptor) strcpy(s->descriptor, descriptor_path);
        }

        loadXmlString(&s->icon, shortcut, "icon");
        loadXmlString(&s->arg, shortcut, "arg");
        loadXmlString(&s->name, shortcut, "name");
        loadXmlString(&s->description, shortcut, "description");
        loadXmlString(&s->author, shortcut, "author");

    } else return -4;

    return 0;
}
Exemplo n.º 29
0
void XmlReader::xmlReadMsmServerInfo(void)
{
    XMLDocument doc;
    doc.LoadFile(m_filename);
    if (doc.ErrorID() != 0) {
        printf("read xml error!\n");
        return;
    }
    XMLElement *root = doc.FirstChildElement("root");

    XMLElement *msms = root->FirstChildElement("msms");
    for (XMLElement *msm = msms->FirstChildElement("msm");
         msm;
         msm = msm->NextSiblingElement("msm")) {
        XMLElement *msm_ip = msm->FirstChildElement("msm_ip");
        XMLElement *msm_port = msm->FirstChildElement("msm_port");

        printf("msm_ip: %s\n", msm_ip->GetText());
        printf("msm_port: %s\n", msm_port->GetText());
    }
}
Exemplo n.º 30
-1
TEST(XML_READER, getFirstChild)
{
	XMLDocument * doc = XmlWrapper::loadDocument("UT/TestFiles/PDDB/test_pddb_1.xml");
	XmlReader * reader = new XmlReader(doc);
	XMLElement* doc_element;
	std::string tag = "";

	reader->goFirstChild();
	reader->goFirstChild();
	doc_element = doc->FirstChildElement();
	doc_element = doc_element->FirstChildElement();

	std::string a = XmlElementReader::getName(reader->getFirstChild(tag));
	std::string b = XmlElementReader::getName(doc_element).c_str();
	EXPECT_EQ(a, b);
	delete reader;
	delete doc;
}