コード例 #1
0
ファイル: Config.cpp プロジェクト: snosscire/Block-World
	void Config::loadFile(const string& path)
	{
		XMLDocument document;
		if (document.LoadFile(path.c_str()) == XML_NO_ERROR) {
			XMLElement* file = document.FirstChildElement("file");
			if (file) {
				XMLElement* config = file->FirstChildElement("config");
				
				while (config) {
					const char* name = config->Attribute("name");
					if (name) {
						     if (strcmp(name, "DefaultGravity") == 0)       config->QueryDoubleAttribute("value", &Config::DefaultGravity);
						else if (strcmp(name, "PlayerMoveSpeed") == 0)      config->QueryDoubleAttribute("value", &Config::PlayerMoveSpeed);
						else if (strcmp(name, "PlayerJumpSpeed") == 0)      config->QueryDoubleAttribute("value", &Config::PlayerJumpSpeed);
						else if (strcmp(name, "MaxCrosshairDistance") == 0) config->QueryDoubleAttribute("value", &Config::MaxCrosshairDistance);
						else if (strcmp(name, "MaxGibsOnScreen") == 0)      config->QueryUnsignedAttribute("value", &Config::MaxGibsOnScreen);
						else if (strcmp(name, "GibsMin") == 0)              config->QueryIntAttribute("value", &Config::GibsMin);
						else if (strcmp(name, "GibsMax") == 0)              config->QueryIntAttribute("value", &Config::GibsMax);
						else if (strcmp(name, "BloodParticles") == 0)       config->QueryIntAttribute("value", &Config::BloodParticles);
						else if (strcmp(name, "GibMaxSpeedX") == 0)         config->QueryIntAttribute("value", &Config::GibMaxSpeedX);
						else if (strcmp(name, "GibMaxSpeedY") == 0)         config->QueryIntAttribute("value", &Config::GibMaxSpeedY);
						else if (strcmp(name, "BloodMaxSpeedX") == 0)       config->QueryIntAttribute("value", &Config::BloodMaxSpeedX);
						else if (strcmp(name, "BloodMaxSpeedY") == 0)       config->QueryIntAttribute("value", &Config::BloodMaxSpeedY);
					}
					
					config = config->NextSiblingElement("config");
				}
			}
		} else {
			cout << document.GetErrorStr1() << endl;
			cout << document.GetErrorStr2() << endl;
		}
	}
コード例 #2
0
ファイル: TracksXml.cpp プロジェクト: HaohaoLau/stuntrally
bool UserXml::LoadXml(std::string file)
{
	XMLDocument doc;
	XMLError e = doc.LoadFile(file.c_str());
	if (e != XML_SUCCESS)  return false;
		
	XMLElement* root = doc.RootElement();
	if (!root)  return false;

	//  clear
	trks.clear();  trkmap.clear();

	//  tracks
	const char* a;  //int i=1;  //0 = none
	XMLElement* eTrk = root->FirstChildElement("track");
	while (eTrk)
	{
		UserTrkInfo t;
		a = eTrk->Attribute("n");		if (a)  t.name = string(a);

		a = eTrk->Attribute("date");	if (a)  t.last = s2dt(a);
		a = eTrk->Attribute("rate");	if (a)  t.rating = s2i(a);
		a = eTrk->Attribute("laps");	if (a)  t.laps = s2i(a);
		a = eTrk->Attribute("time");	if (a)  t.time = s2r(a);

		trks.push_back(t);
		trkmap[t.name] = trks.size();  //i++;
		eTrk = eTrk->NextSiblingElement("track");
	}
	return true;
}
コード例 #3
0
ファイル: tilemap.cpp プロジェクト: zkl/Gear
bool TileMap::load(const char * file)
{
	this->clear();

	XMLDocument document;
	document.LoadFile(file);
	XMLElement * root = document.FirstChildElement("map");
	if(root != 0)
	{
		// base path
		strcpy(_basePath, file);
		char* p = &_basePath[strlen(file)-1];
		while(p != _basePath && *p != '/')
			p--;

		if(*p == '/')
			*p = 0;

		analyzeMapInfo(root);
		for(XMLElement* e = root->FirstChildElement(); e != 0; e = e->NextSiblingElement())
		{
			if(e->Value() == std::string("tileset"))
				this->analyzeTileset(e);
			else if(e->Value() == std::string("layer"))
				this->anylyzeLayers(e);
			else if(e->Value() == std::string("imagelayer"))
				this->anylyzeImageLayer(e);
		}
		return true;
	}
	return false;
}
コード例 #4
0
void SerializeStruct(FSsPart& Value, SsXmlIArchiver* ar)
{
	SSAR_DECLARE("name", Value.PartName);
	SSAR_DECLARE("arrayIndex", Value.ArrayIndex);
	SSAR_DECLARE("parentIndex", Value.ParentIndex);

	SSAR_DECLARE_ENUM("type", Value.Type);
	SSAR_DECLARE_ENUM("boundsType", Value.BoundsType);
	SSAR_DECLARE_ENUM("inheritType", Value.InheritType);
	SSAR_DECLARE_ENUM("alphaBlendType", Value.AlphaBlendType);
	SSAR_DECLARE("show", Value.Show);
	SSAR_DECLARE("locked", Value.Locked);
	SSAR_DECLARE("refAnimePack", Value.RefAnimePack);
	SSAR_DECLARE("refAnime", Value.RefAnime);

	//継承率後に改良を実施
	if (ar->getType() == EnumSsArchiver::in)
	{
		XMLElement* e = ar->getxml()->FirstChildElement("ineheritRates");
		if (e)
		{
			XMLElement* ec = e->FirstChildElement();
			while(ec)
			{
				const char* tag = ec->Value();
				TEnumAsByte<SsAttributeKind::Type> enumattr;

				__StringToEnum_( tag , enumattr );
				Value.InheritRates[(int)enumattr] = (float)atof(ec->GetText());
				ec = ec->NextSiblingElement();
			}
		}
	}
}
コード例 #5
0
ファイル: LogoScene.cpp プロジェクト: LiZhengyan/mycocos
void LogoScene::loadXmlElement(XMLElement* rootElement)
{
    XMLElement *dicEle = rootElement->FirstChildElement();
    while (dicEle!=NULL) {
        if (dicEle->GetText()!=NULL) {
            log("dicEle Text= %s", dicEle->GetText());
            string name=dicEle->GetText();
            string png=".png";
            //判断是否是图片
            if (name.find(png)<100) {
                log("%lu 是图片",name.find(png));
                //加入缓存
                Director::getInstance()->getTextureCache()->addImageAsync(dicEle->GetText(),CC_CALLBACK_1(LogoScene::menuCloseCallback, this));
                Texture2D* texture=TextureCache::sharedTextureCache()->textureForKey(dicEle->GetText());
                if (texture) {
                    texture->setAntiAliasTexParameters();
            }
            
            
            }
            
            
        }else if (dicEle->FirstChildElement()!=NULL)
        {
            loadXmlElement(dicEle);
        }
        dicEle=dicEle->NextSiblingElement();
    }
}
コード例 #6
0
ファイル: lector.cpp プロジェクト: fernandohv3279/SDSM
/**
 * metodo para obtener el dato deseado
 * recibe un char* con el nombre de los nodos que se deben recorrer
 * separados por un "/" y finalizando tambien con este símbolo
 */
const char* lector::obtener(char* camino){ // siempre debe terminar con "/"
	XMLElement* elemento; //se crea un elemento temporal
	int tam=strlen(camino); //se obtiene el tamaño de la cadena de caracteres
	int inicio=0; //variable que maneja el inicio de una palabra en la cadena
	bool PrimeraPalabra=true;//bandera que sirve para identificar la primera palabra
	for(int i=0;i<tam;i++){ //ciclo para ir entranado en los nodos del XML
		if (camino[i]=='/'){ //identifica donde termina una palabra
			char dato[i-inicio]; //crea un arreglo de char del tamaño necesario para la palabra
			strncpy (dato, camino+inicio,i-inicio); // copia en dato la palabra leida de camino
			dato[i-inicio]='\0'; //agrega el caracter de escape
			if(PrimeraPalabra){ //exepcion que debe hacerse en la primera palabra
				elemento=this->doc->FirstChildElement(dato);
				if(elemento==0){
					std::cout<<"estamos en la papa"<<std::endl;
					return 0;
				}
				PrimeraPalabra=false;//indica que ya se realizo el primer caso
			}
			else{
				elemento=elemento->FirstChildElement(dato); // accede a los nodos del XML
				if(elemento==0){
					std::cout << "estamos en la segunda papa" << std::endl;
					return 0;
				}
			}
			inicio=i+1;//se mueve a la siguiente posicion del arreglo
		}
	}
	return elemento->GetText();//devulve el texto del archivo XML
}
コード例 #7
0
ファイル: Scenario.cpp プロジェクト: smarmy/DungeonCrawler
Scenario::Scenario()
  : m_useCharGen(false),
    m_name("DPOC")
{
  XMLDocument doc;
  if (doc.LoadFile("Scenario.xml") != 0)
  {
    throw std::runtime_error{"Fatal error: no Scenario.xml file found!"};
  }

  TRACE("Loaded scenario file");

  XMLElement* root = doc.FirstChildElement("scenario");
  for (XMLElement* element = root->FirstChildElement(); element; element = element->NextSiblingElement())
  {
    std::string tagName = element->Name();

    if (tagName == "createParty")
    {
      m_useCharGen = std::string(element->GetText()) == "true";
    }
    else if (tagName == "name")
    {
      m_name = element->GetText();
    }
  }

  TRACE(" - m_gameName   = %s", m_name.c_str());
  TRACE(" - m_useCharGen = %s", m_useCharGen ? "true" : "false");
}
コード例 #8
0
ファイル: xmlloader.cpp プロジェクト: skogler/storyofanerd2
void LoadedMap::loadTerrains(XMLElement *element, TileSet *target)
{
    Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadTerrains start\n");

    assert(element);
    assert(target);

    XMLElement *terrain = element->FirstChildElement(XML_TERRAIN.c_str());

    Logger.logMessage(LOG_DEBUG, LOG_MAP, "LoadedMap::loadTerrains: Found first terrain\n");
    while(terrain)
    {
        TerrainType parsed_terrain;
        parsed_terrain.name = getAttributeString(terrain, XML_TERRAIN_NAME);

        stringstream tile (terrain->Attribute(XML_TERRAIN_TILE.c_str()));
        tile >> parsed_terrain.tile;

        XMLElement *properties = terrain->FirstChildElement(XML_TERRAIN_PROPS.c_str());
        if(properties)
        {
            loadTerrainProperties(properties, &parsed_terrain);
        }

        target->terraintypes.push_back(parsed_terrain);
        terrain = terrain->NextSiblingElement();
    }

    Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadTerrains end\n");
}
コード例 #9
0
void MapLoader::load(const std::string &xmlFilename, ResourceHandler &handler) {
	XMLFile doc(xmlFilename);

	XMLElement *areaElement = doc.FirstChildElement("maps").FirstChildElement("area").ToElement();
	while(areaElement) {
		u16 area = areaElement->IntAttribute("id");

		XMLElement *mapElement = areaElement->FirstChildElement("map");
		while(mapElement) {
			std::string name = mapElement->Attribute("name");
			std::string tilesetName = mapElement->Attribute("tileset");

			u16 x = mapElement->IntAttribute("x");
			u16 y = mapElement->IntAttribute("y");

			Tileset &tileset = handler.get<Tileset>(tilesetName);

			loadMap(name, area, x, y, tileset, handler);

			mapElement = mapElement->NextSiblingElement("map");
		}

		areaElement = areaElement->NextSiblingElement("area");
	}
}
コード例 #10
0
void MapLoader::loadMap(const std::string &name, u16 area, u16 x, u16 y, Tileset &tileset, ResourceHandler &handler) {
	XMLFile doc("data/maps/" + name + ".tmx");

	XMLElement *mapElement = doc.FirstChildElement("map").ToElement();

	u16 width = mapElement->IntAttribute("width");
	u16 height = mapElement->IntAttribute("height");

	std::vector<u16> data;
	XMLElement *tileElement = mapElement->FirstChildElement("layer")->FirstChildElement("data")->FirstChildElement("tile");
	while(tileElement) {
		s16 tileID = tileElement->IntAttribute("gid") - 1;

		data.push_back((tileID >= 0) ? tileID : 0);

		tileElement = tileElement->NextSiblingElement("tile");
	}

	Map &map = handler.add<Map>(makeName(area, x, y), area, x, y, width, height, tileset, data);

	for(u16 tileY = 0 ; tileY < height ; tileY++) {
		for(u16 tileX = 0 ; tileX < width ; tileX++) {
			u16 tileID = map.getTile(tileX, tileY);

			if(tileset.info()[tileID] == TilesInfos::TileType::GrassTile) {
				map.scene().addObject(GrassFactory::create(tileX, tileY));
			}
			else if(tileset.info()[tileID] == TilesInfos::TileType::LowGrassTile) {
				map.scene().addObject(GrassFactory::create(tileX, tileY, true));
			}
		}
	}

	SceneObjectLoader::load(name, map.scene());
}
コード例 #11
0
ファイル: Tiro.cpp プロジェクト: rbpimenta/CG-UFES-20152-TF
void Tiro::carregarInformacoes() {
	XMLDocument* doc = new XMLDocument();

	doc->LoadFile("tiro.svg");

	if (doc == NULL) {
		cout << "Problema ao abrir arquivo .svg\n";
		exit(1);
	}

	XMLElement* svg = doc->FirstChildElement("svg");
	if (svg == NULL) {
		cout
				<< "Erro na hora de encontrar Element 'svg'! Finalizando programa...\n";
		exit(1);
	}

	XMLElement* circleElem = svg->FirstChildElement("circle");
	if (circleElem == NULL) {
		cout
				<< "Erro na hora de encontrar Element 'circle'! Finalizando programa...\n";
		exit(1);
	}

	this->tiro->setValues(circleElem);
}
コード例 #12
0
bool
RenderComponent::deserialize(XMLElement &n)
{
	if (!ComponentBase::deserialize(n))
	    return(false);

	XMLElement *l_child = n.FirstChildElement("mesh");
	if (!l_child) {
		MMWARNING("Render component '" << id().str() << "' deserialized without a mesh!");
		return(false);
	}

	const char *l_mesh_type = l_child->Attribute("type");
	Graphics::SharedMesh l_mesh =
	    Game::FactoryBase::Instance()->createMesh(l_mesh_type);
	if (!l_mesh) {
		MMWARNING("Render component '" << id().str() << "' has an unknown mesh type");
		return(false);
	}

	if (!l_mesh->deserialize(*l_child)) {
		MMWARNING("Render component '" << id().str() << "' deserialization of mesh failed");
		return(false);
	}

	m_p->mesh = l_mesh;

	return(true);
}
コード例 #13
0
ファイル: ModelAttribute.cpp プロジェクト: joyfish/TowerTD
//解析xml,id为int类型,其它属性为string类型
void ModelAttribute::parseXML(){
	if (xmldocument)
	{
		log("parseXML");
		XMLElement* root = xmldocument->RootElement();
		log("xml get root child element");
		XMLElement* att_element = root->FirstChildElement("Model");
		log("xml get first child element");
		while (att_element)
		{
			//取id
			int id = att_element->IntAttribute("ID");

			//取属性
			//			tmp_attribute_map = new std::map<std::string,int>();

			std::string sprite = att_element->Attribute("Sprite");
			tmp_attribute_map["Sprite"] = sprite;
			std::string runanimate = att_element->Attribute("Runanimate");
			tmp_attribute_map["Runanimate"] = runanimate;
			std::string dieanimate = att_element->Attribute("Dieanimate");
			tmp_attribute_map["Dieanimate"] = dieanimate;
			//将一条记录加入map
			id_map->insert(std::pair <int,std::map<std::string,std::string> >(id,tmp_attribute_map));

			//取下一个节点
			att_element = att_element->NextSiblingElement();
		}
	}
}
コード例 #14
0
void Robot::loadSettings(XMLDocument* doc)
{
	printf("Robot::%s::%d: Loading Settings...\n",__INFO__);
	XMLElement* robot = doc->FirstChildElement("Robot");
	if(robot != NULL)
	{
		XMLElement* main_thread = robot->FirstChildElement("MainThread");
		if(main_thread != NULL)
		{
			double period = 0.0;
			int priority = 0;
			GET_XML_FLOAT(main_thread,Period,period,DEFUALT_MAIN_THREAD_PERIOD);
			setPeriod(period);
			GET_XML_FLOAT(main_thread,Priority,priority,DEFUALT_MAIN_THREAD_PRIORITY);
			setPriority(static_cast<gsi::Thread::ThreadPriority>(priority));
			//printf("Period is: %.3f\n",period);
			//printf("Values: %s\n",main_thread->FirstChildElement("Period")->GetText());
			//setPeriod()
		}
		else
		{
			setPeriod(DEFUALT_MAIN_THREAD_PERIOD);
			setPriority(static_cast<gsi::Thread::ThreadPriority>(DEFUALT_MAIN_THREAD_PRIORITY));
		}
	}
	else
	{
		printf("Robot::%s::%d: Error, no <Robot> element\n",__INFO__);
		printf("Robot::%s::%d: Assigning defualt settings\n",__INFO__);
		settings_file_exists = false;
	}
}
コード例 #15
0
bool
SceneBase::deserialize(XMLElement &n)
{
	XMLElement *l_child;
	for (l_child = n.FirstChildElement("layer") ;
	     l_child;
	     l_child = l_child->NextSiblingElement("layer")) {

		const char *l_id   = l_child->Attribute("id");
		const char *l_type = l_child->Attribute("type");

		SharedSceneLayer l_layer =
		    FactoryBase::Instance()->createSceneLayer(l_type, l_id, *this);

		if (!l_layer) {
			MMWARNING("SceneLayer '" << l_id << "' of type '" << l_type << "' creation failed");
			continue;
		}

		if (!l_layer->deserialize(*l_child)) {
			MMWARNING("SceneLayer '" << l_id << "' of type '" << l_type << "' failed deserialization");
			continue;
		}

		pushLayer(l_layer);
	}
	
	return(true);
}
コード例 #16
0
ファイル: xmltest.cpp プロジェクト: Redee/RdEngine
bool example_4()
{
	static const char* xml =
		"<information>"
		"	<attributeApproach v='2' />"
		"	<textApproach>"
		"		<v>2</v>"
		"	</textApproach>"
		"</information>";

	XMLDocument doc;
	doc.Parse( xml );

	int v0 = 0;
	int v1 = 0;

	XMLElement* attributeApproachElement = doc.FirstChildElement()->FirstChildElement( "attributeApproach" );
	attributeApproachElement->QueryIntAttribute( "v", &v0 );

	XMLElement* textApproachElement = doc.FirstChildElement()->FirstChildElement( "textApproach" );
	textApproachElement->FirstChildElement( "v" )->QueryIntText( &v1 );

	printf( "Both values are the same: %d and %d\n", v0, v1 );

	return !doc.Error() && ( v0 == v1 );
}
コード例 #17
0
ファイル: environment.cpp プロジェクト: mccagigal/mufco
void CEnvironment::_configureSinusoidal ( void ){ 	
	/* Read components from XML file */
	XMLDocument conf;
    	conf.LoadFile( m_sSourceFile.c_str() );
	XMLElement* root = conf.FirstChildElement();
	string   elemName, attr;
	SFreqCmp tmp_FC;
	for( XMLElement* elem = root->FirstChildElement() ; elem != NULL ; elem = elem->NextSiblingElement() ){
		elemName = elem->Value();
		if ( elemName == "Cmp" ){
			attr          = elem->Attribute("period");
			tmp_FC.period = atof( attr.c_str() ) / float ( m_nSampling );
			attr          = elem->Attribute("phase");
			tmp_FC.phs    = atof( attr.c_str() );
			attr          = elem->Attribute("amplitude");
			tmp_FC.amp    = m_fAmplitude * atof( attr.c_str() );
			if ( tmp_FC.period > 0.0 ){
				m_vInputSignal [ int ( float( m_nFFTsize  ) / tmp_FC.period ) ] = tmp_FC;
				m_vNCAmp       [ int ( float( m_nFFTsize  ) / tmp_FC.period ) ] = tmp_FC.amp;
			}
			else{
				m_vInputSignal [ 0 ] = tmp_FC;
				m_vNCAmp       [ 0 ] = tmp_FC.amp;

			}
		}
	}
	return;
};
コード例 #18
0
void readVisualSceneInstanceGeometries(XMLDocument& doc, btHashMap<btHashString, int>& name2Shape, btAlignedObjectArray<ColladaGraphicsInstance>& visualShapeInstances)
{
	btHashMap<btHashString, XMLElement*> allVisualScenes;

	XMLElement* libVisualScenes = doc.RootElement()->FirstChildElement("library_visual_scenes");
	if (libVisualScenes == 0)
		return;

	{
		for (XMLElement* scene = libVisualScenes->FirstChildElement("visual_scene");
			 scene != NULL; scene = scene->NextSiblingElement("visual_scene"))
		{
			const char* sceneName = scene->Attribute("id");
			allVisualScenes.insert(sceneName, scene);
		}
	}

	XMLElement* scene = 0;
	{
		XMLElement* scenes = doc.RootElement()->FirstChildElement("scene");
		if (scenes)
		{
			XMLElement* instanceSceneReference = scenes->FirstChildElement("instance_visual_scene");
			if (instanceSceneReference)
			{
				const char* instanceSceneUrl = instanceSceneReference->Attribute("url");
				XMLElement** sceneInstancePtr = allVisualScenes[instanceSceneUrl + 1];  //skip #
				if (sceneInstancePtr)
				{
					scene = *sceneInstancePtr;
				}
			}
		}
	}

	if (scene)
	{
		for (XMLElement* node = scene->FirstChildElement("node");
			 node != NULL; node = node->NextSiblingElement("node"))
		{
			btMatrix4x4 identity;
			identity.setIdentity();
			btVector3 identScaling(1, 1, 1);
			readNodeHierarchy(node, name2Shape, visualShapeInstances, identity);
		}
	}
}
コード例 #19
0
ファイル: XMLReader.cpp プロジェクト: wardh/ZeldaClone
void XMLReader::DebugFirstChild(XMLElement aParent, const std::string& aChildName) const
{
	if (aParent->FirstChildElement(aChildName.c_str()) == nullptr)
	{
		DL_DEBUG("Failed to [ForceFindFirstChild]. Parent: [ %s ], Child: [ %s ], File: [ %s ]", aParent->Name(), aChildName.c_str(), myFilePath.c_str());
		DL_ASSERT("Failed to [ForceFindFirstChild], check DebugLog for more info");
	}
}
コード例 #20
0
ファイル: XMLReader.cpp プロジェクト: wardh/ZeldaClone
XMLElement XMLReader::FindFirstChild(XMLElement aParent, const std::string& aChildName) const
{
	if (myHasOpenedDoc == false)
		DL_ASSERT("[XMLReader]: Tried to [FindFirstChild] before Opening the document");


	return aParent->FirstChildElement(aChildName.c_str());
}
コード例 #21
0
ファイル: main.cpp プロジェクト: mccagigal/mufco
void parallelSetUp       ( void ){
	XMLDocument conf;
    	conf.LoadFile( g_sMainFilename.c_str() );
	XMLElement* root = conf.FirstChildElement();
	string elemName , attr;	

	for( XMLElement* elem = root->FirstChildElement() ; elem != NULL ; elem = elem->NextSiblingElement() ){
		elemName = elem->Value();

		if ( elemName == "output" ){
			attr          = elem->Attribute("file");
			g_sOutputFile = attr;
		}
		else if ( elemName == "exp_conf"  ){
			attr       = elem->Attribute("file");
			g_sExpConf = attr;
		}
		else if ( elemName == "seed"){
			attr       = elem->Attribute("number");
			g_nSeeds   = atoi( attr.c_str() );
		}
		else if ( elemName == "prm"){
			SParamConf tmp_param;
			attr             = elem->Attribute("length");
			tmp_param.length = atoi( attr.c_str() );
			attr             = elem->Attribute("offset");	
			tmp_param.offset = atof( attr.c_str() );
			attr             = elem->Attribute("step");
			tmp_param.step   = atof( attr.c_str() );
			g_vParams.push_back( tmp_param );			
		}
		else if ( elemName == "env"){
			SParamConf tmp_envir;
			attr             = elem->Attribute("length");
			tmp_envir.length = atoi( attr.c_str() );
			attr             = elem->Attribute("offset");	
			tmp_envir.offset = atof( attr.c_str() );
			attr             = elem->Attribute("step");
			tmp_envir.step   = atof( attr.c_str() );
			g_vEnvirs.push_back( tmp_envir );			
		}
		else if ( elemName == "result"){
			attr       = elem->Attribute("length");
			g_nResltN  = atoi( attr.c_str() );	
			attr       = elem->Attribute("type");
			g_nResltT  = atoi( attr.c_str() );
		}
	}
	g_nParamN = g_vParams.size();
	g_nEnvirN = g_vEnvirs.size(); 
	for ( int i = 0 ; i < g_nParamN ; i++ )
		g_nExpSize *= g_vParams[i].length;
	for ( int i = 0 ; i < g_nEnvirN ; i++ )
		g_nExpSize *= g_vEnvirs[i].length;
	conf.Clear();	

	return;
};
コード例 #22
0
Config readConfigFile(char* configFile) {
	Config config;
	XMLDocument doc;
	doc.LoadFile(configFile);
	XMLElement* configElement = doc.FirstChildElement("config");
	XMLElement* imageElement = getChild("image", configElement);
	config.imageFileExtension = getChildText("fileExtension", imageElement);
	config.imageDirectory = getChildText("directory", imageElement);
	XMLElement* directoryFilterFile = imageElement->FirstChildElement("directoryFilterFile");
	if (directoryFilterFile != NULL) {
		config.imageDirectoryFilterFile = directoryFilterFile->GetText();
	}
	XMLElement* annotationsElement = getChild("annotations", configElement);
	config.annotationsDirectory = getChildText("directory", annotationsElement);
	config.annotationsFileExtension = getChildText("fileExtension", annotationsElement);
	config.annotationsFileFormat = getChildText("fileFormat", annotationsElement);

	XMLElement* detectionElement = getChild("detection", configElement);
	XMLElement* outputImagesElement = detectionElement->FirstChildElement("outputImages");
	if (outputImagesElement != NULL){
		config.detectionOutputImages=true;
		config.detectionOutputImagesDirectory=getChildText("directory", outputImagesElement);
	}

	XMLElement* detectors = getChild("detectors", configElement);
	XMLElement* detectorElement = detectors->FirstChildElement("detector");

	while (detectorElement != NULL) {
		string type = getChildText("type", detectorElement);
		if (utils::equals(type, "HOGObjectDetector")) {
			config.objectDetectors.push_back(new HOGObjectDetector());
		} else if (utils::equals(type, "LatentSVMObjectDetector")) {
			string model = getChildText("model", detectorElement);
			double overlapThreshold = utils::stringToDouble(getChildText("overlapThreshold", detectorElement));
			int numberOfThreads = utils::stringToInt(getChildText("numberOfThreads", detectorElement));
			config.objectDetectors.push_back(new LatentSVMObjectDetector(model, overlapThreshold, numberOfThreads));
		} else if (utils::equals(type, "CascadeObjectDetector")) {
			string model = getChildText("model", detectorElement);
			config.objectDetectors.push_back(new CascadeObjectDetector(model));
		}
		detectorElement = detectorElement->NextSiblingElement("detector");
	}

	return config;
}
コード例 #23
0
ファイル: xmlReader.cpp プロジェクト: github188/msm
void XmlReader::xmlReadSelfInfo(void)
{
    XMLDocument doc;
    doc.LoadFile(m_filename);
    if (doc.ErrorID() != 0) {
        printf("read xml error!\n");
        return;
    }
    XMLElement *root = doc.FirstChildElement("root");

    XMLElement *user = root->FirstChildElement("user");
    XMLElement *user_id = user->FirstChildElement("user_id");
    XMLElement *user1_account = user->FirstChildElement("user_acount");
    XMLElement *user_name = user->FirstChildElement("user_name");
    XMLElement *big_visit_num = user->FirstChildElement("big_visit_num");
    XMLElement *vsp_id = user->FirstChildElement("vsp_id");
    XMLElement *vsp_name = user->FirstChildElement("vsp_name");

    printf("user_id: %s\n", user_id->GetText());
    printf("user1_account: %s\n", user1_account->GetText());
    printf("user_name: %s\n", user_name->GetText());
    printf("big_visit_num: %s\n", big_visit_num->GetText());
    printf("vsp_id: %s\n", vsp_id->GetText());
    printf("vsp_name: %s\n", vsp_name->GetText());
    printf("================================================\n");
}
コード例 #24
0
ファイル: FastXMLVisitor.cpp プロジェクト: DaveInga/mFAST
bool FastXMLVisitor::is_mandatory_constant(const XMLElement & element)
{
  if (strcmp("mandatory", get_optional_attr(element, "presence", "mandatory")) == 0 ) {
    if (element.FirstChildElement("constant")) {
      return true;
    }
  }
  return false;
}
コード例 #25
0
ファイル: hnews.cpp プロジェクト: rohshall/hnews
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;
            }
        }
    }
}
コード例 #26
0
ファイル: XMLReader.cpp プロジェクト: wardh/ZeldaClone
XMLElement XMLReader::ForceFindFirstChild(XMLElement aParent) const
{
	if (myHasOpenedDoc == false)
		DL_ASSERT("[XMLReader]: Tried to [FindFirstChild] before Opening the document");

	DebugFirstChild(aParent);

	return aParent->FirstChildElement();
}
コード例 #27
0
void parseSDF(RigidBodySystem& sys, XMLDocument* xml_doc) {
  XMLElement* node = xml_doc->FirstChildElement("sdf");
  if (!node)
    throw std::runtime_error(
        "ERROR: This xml file does not contain an sdf tag");
  for (XMLElement* elnode = node->FirstChildElement("model"); elnode;
       elnode = node->NextSiblingElement("model"))
    parseSDFModel(sys, elnode);
}
コード例 #28
0
ファイル: Response.cpp プロジェクト: janbar/pvr.vbox
void Response::ParseStatus()
{
  int errorCode;
  std::string errorDescription;

  XMLNode *rootElement = m_document->RootElement();
  XMLElement *statusElement = rootElement->FirstChildElement(GetStatusElementName().c_str());

  // Not all response types always return the status element
  if (statusElement)
  {
    errorCode = xmltv::Utilities::QueryIntText(statusElement->FirstChildElement("ErrorCode"));
    errorDescription = statusElement->FirstChildElement("ErrorDescription")->GetText();

    m_error.code = static_cast<ErrorCode>(errorCode);
    m_error.description = errorDescription;
  }
}
コード例 #29
0
bool TiledMap::loadLayers(XMLDocument *map)
{
    XMLElement* layer;
    XMLElement* tile;
    if((layer = map->FirstChildElement("map")->FirstChildElement("layer")) != NULL)
    {
        TiledMapLayer* temp = new TiledMapLayer();
        temp->setName(layer->Attribute("name"));
        temp->setWidth(this->stringToInt(layer->Attribute("width")));
        temp->setHeight(this->stringToInt(layer->Attribute("height")));

        if((tile = layer->FirstChildElement("data")->FirstChildElement("tile")) != NULL)
        {
            temp->insertData(this->stringToInt(tile->Attribute("gid")));
        }

        while((tile = tile->NextSiblingElement("tile")) != NULL)
        {
            temp->insertData(this->stringToInt(tile->Attribute("gid")));
        }

        this->insertLayer(temp);
    }

    while(layer != NULL && (layer = layer->NextSiblingElement("layer")) != NULL)
    {
        TiledMapLayer* temp = new TiledMapLayer();
        temp->setName(layer->Attribute("name"));
        temp->setWidth(this->stringToInt(layer->Attribute("width")));
        temp->setHeight(this->stringToInt(layer->Attribute("height")));

        if((tile = layer->FirstChildElement("data")->FirstChildElement("tile")) != NULL)
        {
            temp->insertData(this->stringToInt(tile->Attribute("gid")));
        }

        while((tile = tile->NextSiblingElement("tile")) != NULL)
        {
            temp->insertData(this->stringToInt(tile->Attribute("gid")));
        }

        this->insertLayer(temp);
    }
}
コード例 #30
0
ファイル: tr_svt.cpp プロジェクト: BKNio/opencv_contrib
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());
        }
    }
}