Example #1
0
bool MProject::loadXML(const char * filename)
{
	char rep[256];

	if(! filename)
		return false;

	// get rep
	getRepertory(rep, filename);

	// read document
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
		return false;
	
	TiXmlHandle hDoc(&doc);
	TiXmlElement * rootNode;
	TiXmlHandle hRoot(0);

	// maratis
	rootNode = hDoc.FirstChildElement().Element();
	if(! rootNode)
		return false;

	if(strcmp(rootNode->Value(), "Maratis") != 0)
		return false;

	hRoot = TiXmlHandle(rootNode);

	// Project
	TiXmlElement * projectNode = rootNode->FirstChildElement("Project");
	if(! projectNode)
		return false;

	// renderer
	TiXmlElement * rendererNode = projectNode->FirstChildElement("renderer");
	if(rendererNode)
	{
		const char * name = rendererNode->Attribute("name");
		if(name)
		{
			renderer = name;
		}
	}
	
	// start
	TiXmlElement * startNode = projectNode->FirstChildElement("start");
	if(startNode)
	{
		const char * file = startNode->Attribute("file");
		if(file)
		{
			char levelFilename[256];
			getGlobalFilename(levelFilename, rep, file);
			startLevel = levelFilename;
		}
	}

	return true;
}
/**
 * Read the configuration XML file which contains the initial configuration
 * of the rules and the actions
 */
bool XMLConfigReader::readConfigFile(std::string configFile)
{
	TiXmlDocument doc( configFile );
	doc.LoadFile();

	TiXmlElement* root = doc.FirstChildElement( "root" );
	if ( root )
	{
		TiXmlElement* playerElm = root->FirstChildElement("player");
		if(playerElm != NULL){
			rpsGame->player1 = new Player();
			rpsGame->player1->setName(playerElm->Attribute("name"));
			getRuleEnginesFromXML(playerElm, rpsGame->player1);

			playerElm = playerElm->NextSiblingElement("player");
			if(playerElm != NULL){
				rpsGame->player2 = new Player();
				rpsGame->player2->setName(playerElm->Attribute("name"));
				getRuleEnginesFromXML(playerElm, rpsGame->player2);
			} else {
				std::cerr << "second player not found!!" << std::endl;
			}
		} else {
			std::cerr << "<player></player> not found!!" << std::endl;
		}
	} else {
		std::cerr << "Initial configuration file unformatted!!" << std::endl;
	}
	return true;
}
Example #3
0
xdl_int XdevLCudaImpl::readModuleInformation(TiXmlDocument* document) {
	TiXmlHandle docHandle(document);
	TiXmlElement* root = docHandle.FirstChild(XdevLCorePropertiesName.c_str()).FirstChildElement("XdevLOpenGL").ToElement();

	if (!root) {
		XDEVL_MODULE_INFO("<XdevLCuda> section not found, skipping proccess.\n");
		return ERR_OK;
	}

	if(root->Attribute("id")){
		XdevLModuleId id(root->Attribute("id"));
		if(*getId() != id){
			return ERR_OK;
		}		
	}else{
		XDEVL_MODULE_ERROR("No 'id' attribute specified.");
		return ERR_ERROR;
	}

//	if (root->Attribute("framebuffer_depth")){
//		m_ColorDepth = xstd::from_string<xdl_int>(root->Attribute("framebuffer_depth"));
//		XDEVL_MODULE_INFO("Framebuffer depth request: " << m_ColorDepth << std::endl);
//	}

	return ERR_OK;
}
Example #4
0
void SPDImplementation::parseUsesDevices(TiXmlElement *elem)
{
    DEBUG(4, SPDImplementation, "In parseUsesDevices.");

    TiXmlElement *uses = elem->FirstChildElement("usesdevice");

    for (; uses; uses = uses->NextSiblingElement("usesdevice")) {
        const char *id = uses->Attribute("id");
        const char *type = uses->Attribute("type");

        CF::Properties props;
        unsigned int i(0);

        TiXmlElement *prop = uses->FirstChildElement("propertyref");
        for (; prop; prop = prop->NextSiblingElement("propertyref")) {
            const char *refid = prop->Attribute("refid");
            const char *value = prop->Attribute("value");
            props.length(i+1);
            props[i].id = CORBA::string_dup (refid);
            props[i].value <<= value;
            i++;
        }

        usesDevice.push_back(new SPDUsesDevice (id, type, props));
    }
}
bool HeadPanTiltController::initXml(mechanism::RobotState * robot, TiXmlElement * config)
{
  robot_ = robot->model_;
  TiXmlElement *elt = config->FirstChildElement("controller");
  while (elt)
  {
    JointPositionController * jpc = new JointPositionController();
    std::cout<<elt->Attribute("type")<<elt->Attribute("name")<<std::endl;
    assert(static_cast<std::string>(elt->Attribute("type")) == std::string("JointPositionController"));
    joint_position_controllers_.push_back(jpc);

    if(!jpc->initXml(robot, elt))
      return false;

    elt = elt->NextSiblingElement("controller");
  }

  num_joints_ = joint_position_controllers_.size();

  fprintf(stderr,"HeadPanTiltController:: num_joints_: %d\n",num_joints_);

  set_pts_.resize(num_joints_);
  last_time_ = robot->hw_->current_time_;

  return true;
}
Example #6
0
bool CFanart::Unpack()
{
    TiXmlDocument doc;
    doc.Parse(m_xml.c_str());

    m_fanart.clear();
    m_url.Empty();

    TiXmlElement *fanart = doc.FirstChildElement("fanart");
    if (fanart)
    {
        m_url = fanart->Attribute("url");
        TiXmlElement *fanartThumb = fanart->FirstChildElement("thumb");
        while (fanartThumb)
        {
            SFanartData data;
            data.strImage = fanartThumb->GetText();
            data.strResolution = fanartThumb->Attribute("dim");
            data.strPreview = fanartThumb->Attribute("preview");
            if (data.strPreview.IsEmpty())
            {   // could be due to an old version in db - use old hardcoded method for now
                if (m_url.Equals("http://thetvdb.com/banners/"))
                    data.strPreview = "_cache/" + data.strImage;
            }
            ParseColors(fanartThumb->Attribute("colors"), data.strColors);
            m_fanart.push_back(data);
            fanartThumb = fanartThumb->NextSiblingElement("thumb");
        }
    }
    return true;
}
Example #7
0
void LoadMetadataV1(TiXmlElement *meta, Metadata *md)
{
  TiXmlElement *node = meta->FirstChildElement("description");

  if(node) {
    if(const char *rtf = node->GetText())
      md->setAbout(rtf);
  }

  node = meta->FirstChildElement("link");

  while(node) {
    const char *rel = node->Attribute("rel");
    const char *url = node->Attribute("href");
    const char *name = node->GetText();

    if(!rel) rel = "";
    if(!name) {
      if(!url) url = "";
      name = url;
    }
    else if(!url) url = name;

    md->addLink(Metadata::getLinkType(rel), {name, url});

    node = node->NextSiblingElement("link");
  }
}
Example #8
0
int ServerConf::ReadSendConfig(TiXmlElement *root)
{
	TiXmlElement *sendElement = root->FirstChildElement("sendcfg");
	if(!sendElement){
		AC_ERROR("read sendcfg error");
		return -1;	
	}
	const char* str;
	str = sendElement->Attribute("sendhour",&m_sendcfg.hour);
	if(!str)	
	{		
		AC_ERROR("read hour error");		
		return -1;	
	}	


	str = sendElement->Attribute("sendminute",&m_sendcfg.minute);
	if(!str)	
	{		
		AC_ERROR("read minute error");		
		return -1;	
	}	

	str = sendElement->Attribute("timeInteval",&m_sendcfg.timeInteval);
	if(!str)	
	{		
		AC_ERROR("read timeInteval error");		
		return -1;	
	}	
	AC_INFO("sendInteval is: %d",m_sendcfg.timeInteval);
	return 0;
}
bool MasterFile::LoadXML( TiXmlHandle hLoadedFiles )
{
    files.clear();
    TiXmlElement* pLoadedFiles = hLoadedFiles.ToElement();
    if( pLoadedFiles == nullptr )
    {
        return false;
    }

    TiXmlElement* pGirlsFiles = pLoadedFiles->FirstChildElement("Girls_Files");
    if( pGirlsFiles == nullptr )
    {
        return false;
    }

    for( TiXmlElement* pFile = pGirlsFiles->FirstChildElement("File");
        pFile != nullptr;
        pFile = pFile->NextSiblingElement("File") )
    {
        if( pFile->Attribute("Filename") )
        {
            add( pFile->Attribute("Filename") );
        }
    }

    return true;
}
Example #10
0
void YafFile::processLights(TiXmlElement* lights)
{
    float location[4], ambient[4], diffuse[4], specular[4];
    float angle = 0, exponent = 0, direction[3];
    bool enabled;
    string type;
    char* id;
    Light* light;
    TiXmlElement* element = lights->FirstChildElement();
    while(element!=NULL)
    {
        element->QueryBoolAttribute("enabled",&enabled);
        id = (char*)element->Attribute("id");
        read3Float("location", element, location[0], location[1], location[2]);
        read4Float("ambient", element, ambient[0], ambient[1], ambient[2],
                   ambient[3]);
        read4Float("diffuse", element, diffuse[0], diffuse[1], diffuse[2],
                   diffuse[3]);
        read4Float("specular", element, specular[0], specular[1], specular[2],
                   specular[3]);
        if(element->Attribute("angle")!=NULL)
        {
            type="spot";
            element->QueryFloatAttribute("angle", &angle);
            element->QueryFloatAttribute("exponent", &exponent);
            read3Float("direction", element, direction[0], direction[1],
                       direction[2]);
        }
        light = new Light(id,enabled,type,location,ambient,diffuse,specular,angle,exponent,direction);
        this->sceneLights.push_back(light);
        element=element->NextSiblingElement();
    }
}
//----------------------------------------------------------------------------
int CDotSceneSerializer::ReadSubEntity(TiXmlElement *element, CBaseEditor *parent, CBaseEditor **ret)
{
    OgitorsPropertyValueMap params;
    OgitorsPropertyValue propValue;
 
    propValue.propType = PROP_STRING;

    TiXmlElement* subs = 0;
    Ogre::String eType;
    subs = element->FirstChildElement();
    if(!subs) return SCF_OK;
    do
    {
        eType = subs->Value();
        if(eType == "subentity")
        {
            Ogre::String idx = ValidAttr(subs->Attribute("index"),"0");
            Ogre::String matname = ValidAttr(subs->Attribute("materialName"));
            propValue.val = Ogre::Any(matname);
            params["subentity" + idx + "::material"] = propValue;
        }
    } while(subs = subs->NextSiblingElement());

    parent->getProperties()->initValueMap(params);

    return SCF_OK;
}
bool wxsItemResData::LoadInFileMode()
{
    TiXmlDocument Doc;
    if ( !TinyXML::LoadDocument(m_XrcFileName,&Doc) ) return false;

    TiXmlElement* Resource = Doc.FirstChildElement("resource");
    if ( !Resource ) return false;

    TiXmlElement* Object = Resource->FirstChildElement("object");
    while ( Object )
    {
        if ( cbC2U(Object->Attribute("name")) == m_ClassName ) break;
        Object = Object->NextSiblingElement("object");
    }

    if ( !Object ) return false;
    if ( cbC2U(Object->Attribute("class")) != m_ClassType ) return false;

    RecreateRootItem();
    if ( !m_RootItem ) return false;
    m_RootItem->XmlRead(Object,true,false);
    LoadToolsReq(Object,true,false);

    return true;
}
void ModelLibrary::LoadAnimsFromXML(TiXmlElement* parent, vector<SAnimation*>* anims, vector<SSound*>* sounds)
{
	TiXmlElement* child;
	for(child = parent->FirstChildElement(); child; child = child->NextSiblingElement())
	{
		if (child->ValueStr() == "sound") 
		{
			SSound* s = new SSound();
			s->filename = child->Attribute(FILENAME);
			child->Attribute(SOUNDLOOP, &s->soundloop);
			sounds->push_back(s);

			Ogre::LogManager::getSingleton().logMessage("XML: SOUND: "+s->filename);
		}
		else if (child->ValueStr() == "animation")
		{
			SAnimation* a = new SAnimation();
			a->name = child->Attribute(ANIMNAME);
			child->Attribute(FRAMES, &a->frames);
			child->Attribute(LOOP, &a->loop);
			anims->push_back(a);

			Ogre::LogManager::getSingleton().logMessage("XML: ANIM: "+a->name);
		}
		else
		{
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : should never get here *giggles*");
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : culporate: "+child->ValueStr());
		};
	}
}
void EditorLexerLoader::DoSingleKeywordNode(HighlightLanguage language, TiXmlElement* node, const wxString& nodename)
{
    TiXmlElement* keywords = node->FirstChildElement(nodename.mb_str());
    while (keywords)
    {
    //    LOGSTREAM << "Found " << nodename << '\n';
        int keyidx = keywords->Attribute("index") ? atol(keywords->Attribute("index")) : -1;
    //    LOGSTREAM << "keyidx=" << keyidx << '\n';
        if (keyidx != -1)
        {
            // the lexer file contains keywords indented - remove the extra spacing and EOLs
            wxRegEx regex(_T("[[:space:]]+"));
            wxString value(keywords->Attribute("value"), wxConvUTF8);
            regex.Replace(&value, _T(" "));

            #if wxCHECK_VERSION(2, 9, 0)
            m_pTarget->SetKeywords(language, keyidx, value );
            #else
            m_pTarget->SetKeywords(language, keyidx, wxString ( value, wxConvUTF8 ) );
            #endif
        }

        keywords = keywords->NextSiblingElement(nodename.mb_str());
    }
}
Example #15
0
int ServerConf::ReadSpConfig(TiXmlElement *root)
{
	TiXmlElement *spElement = root->FirstChildElement("spcfg");
	if(!spElement){
		AC_ERROR("read dbcfg error");
		return -1;	
	}
	const char * str;

	str = spElement->Attribute("spname");
	if(!str)	
	{		
		AC_ERROR("read spname error");		
		return -1;	
	}	
	m_spcfg.spname = str;
	AC_INFO("read spname :%s ",str);

	str = spElement->Attribute("arg",&m_spcfg.numDay);
	if(!str)	
	{		
		AC_ERROR("read arg error");		
		return -1;	
	}	
	return 0;
}
Example #16
0
void ImageLoader::Load(TiXmlDocument& doc)
{
	TiXmlElement* root = doc.FirstChildElement("Body");
	root = root->FirstChildElement("Image");
	while (root)
	{
		TiXmlAttribute* attribute = root->FirstAttribute();
		std::string str = attribute->Name();
		if (str == "name")
		{
			std::string imageName = attribute->Value();
			std::string fileName;
			int x1 = -1, x2 = -1, y1 = -1, y2 = -1;
			TiXmlElement* element = root->FirstChildElement("a");
			if (element)
			{
				if (element->Attribute("file"))
				{
					fileName = element->Attribute("file");
				}
			}

			element = root->FirstChildElement("rect");

			while (element)
			{

				TiXmlAttribute* attrib = element->FirstAttribute();
				while (attrib)
				{
					std::string name = attrib->Name();
					if (name == "x1")
					{
						x1 = attrib->IntValue();
					}
					else if (name == "x2")
					{
						x2 = attrib->IntValue();
					}
					else if (name == "y1")
					{
						y1 = attrib->IntValue();
					}
					else if (name == "y2")
					{
						y2 = attrib->IntValue();
					}

					attrib = attrib->Next();
				}
				element = element->NextSiblingElement("rect");
			}

			internalCreate(imageName, fileName, x1, y1, x2, y2);
		}

		root = root->NextSiblingElement("Image");
	}
}
Example #17
0
bool CPeripherals::LoadMappings()
{
  CSingleLock lock(m_critSectionMappings);

  CXBMCTinyXML xmlDoc;
  if (!xmlDoc.LoadFile("special://xbmc/system/peripherals.xml"))
  {
    CLog::Log(LOGWARNING, "%s - peripherals.xml does not exist", __FUNCTION__);
    return true;
  }

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (!pRootElement || strcmpi(pRootElement->Value(), "peripherals") != 0)
  {
    CLog::Log(LOGERROR, "%s - peripherals.xml does not contain <peripherals>", __FUNCTION__);
    return false;
  }

  for (TiXmlElement *currentNode = pRootElement->FirstChildElement("peripheral"); currentNode; currentNode = currentNode->NextSiblingElement("peripheral"))
  {
    PeripheralID id;
    PeripheralDeviceMapping mapping;

    mapping.m_strDeviceName = XMLUtils::GetAttribute(currentNode, "name");

    // If there is no vendor_product attribute ignore this entry
    if (currentNode->Attribute("vendor_product"))
    {
      // The vendor_product attribute is a list of comma separated vendor:product pairs
      std::vector<std::string> vpArray = StringUtils::Split(currentNode->Attribute("vendor_product"), ",");
      for (const auto& i : vpArray)
      {
        std::vector<std::string> idArray = StringUtils::Split(i, ":");
        if (idArray.size() != 2)
        {
          CLog::Log(LOGERROR, "%s - ignoring node \"%s\" with invalid vendor_product attribute", __FUNCTION__, mapping.m_strDeviceName.c_str());
          continue;
        }

        id.m_iVendorId = PeripheralTypeTranslator::HexStringToInt(idArray[0].c_str());
        id.m_iProductId = PeripheralTypeTranslator::HexStringToInt(idArray[1].c_str());
        mapping.m_PeripheralID.push_back(id);
      }
    }

    mapping.m_busType       = PeripheralTypeTranslator::GetBusTypeFromString(XMLUtils::GetAttribute(currentNode, "bus"));
    mapping.m_class         = PeripheralTypeTranslator::GetTypeFromString(XMLUtils::GetAttribute(currentNode, "class"));
    mapping.m_mappedTo      = PeripheralTypeTranslator::GetTypeFromString(XMLUtils::GetAttribute(currentNode, "mapTo"));
    GetSettingsFromMappingsFile(currentNode, mapping.m_settings);

    m_mappings.push_back(mapping);
    CLog::Log(LOGDEBUG, "%s - loaded node \"%s\"", __FUNCTION__, mapping.m_strDeviceName.c_str());
  }

  return true;
}
Example #18
0
int ServerConf::ReadMailList(TiXmlElement *root)
{
	TiXmlElement *servercfg = root->FirstChildElement("clientconn");	
	if(!servercfg){
		AC_ERROR("read clientconn error");
		return -1;	
	}
	const char* str;
	str = servercfg->Attribute("beatthreadsleep", &m_Beatthreadsleep);	
	if(!str){	
		AC_ERROR("read beatthreadsleep error");
		return -1;	
	}	
	AC_INFO("client beatthreadsleep = %d",m_Beatthreadsleep);
	TiXmlElement *mailsvrcfg = servercfg->FirstChildElement("mailserver");
	while(mailsvrcfg)
	{
		s_SrvList tmps;
		str=mailsvrcfg->Attribute("servername");
		if(!str){
			AC_ERROR("read servername error");
			return -1;
		}
		AC_INFO("read servername :%s",str);
		tmps.srvname = str;
		str=mailsvrcfg->Attribute("sender");
		if(!str){
			AC_ERROR("read sender error");
			return -1;
		}
		AC_INFO("read sender :%s",str);
		tmps.sender = str;
		str=mailsvrcfg->Attribute("password");
		if(!str){
			AC_ERROR("read password error");
			return -1;
		}
		AC_INFO("read password :%s",str);
		tmps.password = str;
		TiXmlElement *mailcfg = mailsvrcfg->FirstChildElement("mail");	
		while(mailcfg){
			str = mailcfg->Attribute("mailname");		
			if(!str){
				AC_ERROR("read mailname error");
				return -1;
			}
			AC_INFO("read mailname :%s",str);
			string strtmp = str;
			tmps.ListOfMail.push_back(strtmp);
			mailcfg = mailcfg->NextSiblingElement("mail");
		}
		m_ListOfMail.push_back(tmps);
		mailsvrcfg = mailsvrcfg->NextSiblingElement("mailserver");
	}
	return 0;
}
Example #19
0
bool ServerConfig::LoadServerConf(const char* pFilePath)
{
	if (!m_xmlDoc.LoadFile(pFilePath))
	{
		return false;
	}

	TiXmlElement* pRoot = m_xmlDoc.RootElement();
	if (!pRoot)
	{
		return false;
	}

	TiXmlElement* pHostServer = pRoot->FirstChildElement("HostServer");
	if (!pHostServer)
	{
		cout << "cannot find host server" << endl;
		return false;
	}

	TiXmlElement* pServer = pHostServer->FirstChildElement("bind");
	if (!pServer)
	{
		return false;
	}
	const char* pServerIp = pServer->Attribute("ip");
	const char* pServerPort = pServer->Attribute("port");
	if (pServerIp)
	{
		memcpy(m_szBindIp, pServerIp, strlen(pServerIp));
	}
	if (pServerPort)
	{
		m_nListenPort = boost::lexical_cast<int>(pServerPort);
	}

	// listen client info
	TiXmlElement* pClient = pHostServer->FirstChildElement("client");
	if (!pClient)
	{
		return false;
	}
	const char* pClientListenIp = pClient->Attribute("ip");
	const char* pClientListenPort = pClient->Attribute("port");
	if (pClientListenIp)
	{
		memcpy(m_szBindClientIp, pClientListenIp, strlen(pClientListenIp));
	}
	if (pClientListenPort)
	{
		m_nListenClientPort = boost::lexical_cast<int>(pClientListenPort);
	}
	
	return true;
}
Example #20
0
bool parseMaterial(Material &material, TiXmlElement *config, bool only_name_is_ok)
{
  bool has_rgb = false;
  bool has_filename = false;

  material.clear();

  if (!config->Attribute("name"))
  {
    logError("Material must contain a name attribute");
    return false;
  }
  
  material.name = config->Attribute("name");

  // texture
  TiXmlElement *t = config->FirstChildElement("texture");
  if (t)
  {
    if (t->Attribute("filename"))
    {
      material.texture_filename = t->Attribute("filename");
      has_filename = true;
    }
  }

  // color
  TiXmlElement *c = config->FirstChildElement("color");
  if (c)
  {
    if (c->Attribute("rgba")) {

      try {
        material.color.init(c->Attribute("rgba"));
        has_rgb = true;
      }
      catch (ParseError &e) {  
        material.color.clear();
        logError(std::string("Material [" + material.name + "] has malformed color rgba values: " + e.what()).c_str());
      }
    }
  }

  if (!has_rgb && !has_filename) {
    if (!only_name_is_ok) // no need for an error if only name is ok
    {
      if (!has_rgb) logError(std::string("Material ["+material.name+"] color has no rgba").c_str());
      if (!has_filename) logError(std::string("Material ["+material.name+"] not defined in file").c_str());
    }
    return false;
  }
  return true;
}
Example #21
0
bool CLastFMDirectory::ParseTrackList(CStdString url, CFileItemList &items)
{
  if (!RetrieveList(url))
    return false;

  TiXmlElement* pRootElement = m_xmlDoc.RootElement();

  TiXmlElement* pEntry = pRootElement->FirstChildElement("track");

  while(pEntry)
  {
    TiXmlNode* name = pEntry->FirstChild("name");
    TiXmlNode* artist = pEntry->FirstChild("artist");
    TiXmlElement *date = pEntry->FirstChildElement("date");

    TiXmlNode* count;
    count = pEntry->FirstChild("count");
    if (!count) count = pEntry->FirstChild("playcount");
    if (!count) count = pEntry->FirstChild("match");

    if (name)
    {
      if (artist)
        AddListEntry(name->FirstChild()->Value(),
            artist->FirstChild()->Value(),
            (count) ? count->FirstChild()->Value() : ((date) ? date->FirstChild()->Value() : NULL),
            (date) ? date->Attribute("uts") : NULL,
            NULL, "lastfm://xbmc/artist/" + (CStdString)artist->FirstChild()->Value() + "/", items);
      else
        // no artist in xml, assuming we're retrieving track list for the artist in m_objname...
        AddListEntry(name->FirstChild()->Value(),
            m_objname.c_str(),
            (count) ? count->FirstChild()->Value() : NULL,
            NULL, NULL, "lastfm://xbmc/artist/" + m_objname + "/", items);
    }
    else
    {
      // no luck, try another way :)
      const char *name = pEntry->Attribute("name");
      const char *artist = pEntry->FirstChildElement("artist")->Attribute("name");
      const char *count = pEntry->Attribute("count");

      if (name)
        AddListEntry(name, artist, count, NULL, NULL,
            "lastfm://xbmc/artist/" + (CStdString)artist + "/", items);
    }

    pEntry = pEntry->NextSiblingElement("track");
  }

  m_xmlDoc.Clear();
  return true;
}
Example #22
0
void YafFile::processCameras(TiXmlElement* camerasElement)
{
    char* rootId = (char*)camerasElement->Attribute("initial");
    char* id;
    string testRoot=rootId;
    TiXmlElement* orthoElement = camerasElement->FirstChildElement("ortho");
    TiXmlElement* perspectiveElement = camerasElement->FirstChildElement("perspective");
    CGFcamera* cam;
    float near, far, left, right, top, bottom;
    unsigned int i = 0;
    while(orthoElement != NULL)
    {
        orthoElement->QueryFloatAttribute("near", &near);
        orthoElement->QueryFloatAttribute("far", &far);
        orthoElement->QueryFloatAttribute("left", &left);
        orthoElement->QueryFloatAttribute("right", &right);
        orthoElement->QueryFloatAttribute("top", &top);
        orthoElement->QueryFloatAttribute("bottom", &bottom);
        id=(char*)orthoElement->Attribute("id");
        cam = new OrthoCamera(near, far, left, right, top, bottom,id==rootId);
        sceneCameras.push_back(make_pair(id,cam));
        orthoElement = orthoElement->NextSiblingElement("ortho");
        string test = id;
        if(test==testRoot)
        {
            camera=i;
        }
        else
            i++;
    }

    while(perspectiveElement != NULL)
    {
        float position[3],target[3],angle;
        perspectiveElement->QueryFloatAttribute("near", &near);
        perspectiveElement->QueryFloatAttribute("far", &far);
        perspectiveElement->QueryFloatAttribute("angle", &angle);
        read3Float("pos", perspectiveElement, position[0], position[1], position[2]);
        read3Float("target", perspectiveElement, target[0], target[1], target[2]);
        id=(char*)perspectiveElement->Attribute("id");
        cam = new PerspectiveCamera(id==rootId,near, far, angle, position[0], position[1],
                                    position[2], target[0], target[1], target[2]);
        sceneCameras.push_back(make_pair(id,cam));
        string test = id;
        if(test==testRoot)
        {
            camera=i;
        }
        else
            i++;
        perspectiveElement = perspectiveElement->NextSiblingElement("perspective");
    }
}
Example #23
0
void VersionInfoFactory::ParseVTable(TiXmlElement* vtable, VersionInfo* mem)
{
    TiXmlElement* pClassEntry;
    TiXmlElement* pClassSubEntry;
    /*
    // check for rebase, do rebase if check positive
    const char * rebase = vtable->Attribute("rebase");
    if(rebase)
    {
        int32_t rebase_offset = strtol(rebase, NULL, 16);
        mem->RebaseVTable(rebase_offset);
    }
    */
    // parse vtable entries
    pClassEntry = vtable->FirstChildElement();
    for(;pClassEntry;pClassEntry=pClassEntry->NextSiblingElement())
    {
        string type = pClassEntry->Value();
        const char *cstr_name = pClassEntry->Attribute("name");
        const char *cstr_vtable = pClassEntry->Attribute("vtable");
        uint32_t vtable = 0;
        if(cstr_vtable)
            vtable = strtol(cstr_vtable, NULL, 16);
        // it's a simple class
        if(type== "class")
        {
            mem->setClass(cstr_name, vtable);
        }
        // it's a multi-type class
        else if (type == "multiclass")
        {
            // get offset of the type variable
            const char *cstr_typeoffset = pClassEntry->Attribute("typeoffset");
            uint32_t typeoffset = 0;
            if(cstr_typeoffset)
                typeoffset = strtol(cstr_typeoffset, NULL, 16);
            t_class * mclass = mem->setClass(cstr_name, vtable, typeoffset);
            // parse class sub-entries
            pClassSubEntry = pClassEntry->FirstChildElement();
            for(;pClassSubEntry;pClassSubEntry=pClassSubEntry->NextSiblingElement())
            {
                type = pClassSubEntry->Value();
                if(type== "class")
                {
                    // type is a value loaded from type offset
                    cstr_name = pClassSubEntry->Attribute("name");
                    const char *cstr_value = pClassSubEntry->Attribute("type");
                    mem->setClassChild(mclass,cstr_name,cstr_value);
                }
            }
        }
    }
}
static void DoLayers()
{
/* ---- */
/* Open */
/* ---- */

	XML_TKEM		xml( gArgs.GetXML(), flog );
	TiXmlElement*	layer	= xml.GetFirstLayer();

/* ------------------------- */
/* Kill layers outside range */
/* ------------------------- */

	TiXmlNode*		lyrset = layer->Parent();
	TiXmlElement*	next;

	for( ; layer; layer = next ) {

		// next layer0 before deleting anything
		next = layer->NextSiblingElement();

		int	z = atoi( layer->Attribute( "z" ) );

		if( z < gArgs.zmin || z > gArgs.zmax )
			lyrset->RemoveChild( layer );
	}

/* --------------------------- */
/* Copies for remaining layers */
/* --------------------------- */

	layer = lyrset->FirstChild( "t2_layer" )->ToElement();

	for( ; layer; layer = layer->NextSiblingElement() ) {

		int	z = atoi( layer->Attribute( "z" ) );

		gArgs.NewLayer( z );
		UpdateTiles( layer );
	}

/* ---- */
/* Save */
/* ---- */

	xml.Save( "xmltmp.txt", true );

/* ------------------ */
/* Rename version two */
/* ------------------ */

	gArgs.RenameXML();
}
Example #25
0
Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem)
{
  // is it a <separator>?
  if (strcmp(elem->Value(), "separator") == 0)
    return new Separator("", JI_HORIZONTAL);

  const char* command_name = elem->Attribute("command");
  Command* command =
    command_name ? CommandsModule::instance()->getCommandByName(command_name):
                   NULL;

  // load params
  Params params;
  if (command) {
    TiXmlElement* xmlParam = elem->FirstChildElement("param");
    while (xmlParam) {
      const char* param_name = xmlParam->Attribute("name");
      const char* param_value = xmlParam->Attribute("value");

      if (param_name && param_value)
        params.set(param_name, param_value);

      xmlParam = xmlParam->NextSiblingElement();
    }
  }

  // Create the item
  AppMenuItem* menuitem = new AppMenuItem(elem->Attribute("text"),
                                          command, command ? &params: NULL);
  if (!menuitem)
    return NULL;

  /* has it a ID? */
  const char* id = elem->Attribute("id");
  if (id) {
    /* recent list menu */
    if (strcmp(id, "recent_list") == 0) {
      m_recentListMenuitem = menuitem;
    }
  }

  // Has it a sub-menu (<menu>)?
  if (strcmp(elem->Value(), "menu") == 0) {
    // Create the sub-menu
    Menu* subMenu = convertXmlelemToMenu(elem);
    if (!subMenu)
      throw base::Exception("Error reading the sub-menu\n");

    menuitem->setSubmenu(subMenu);
  }

  return menuitem;
}
Example #26
0
bool CXmlOpeation::Parse_XML_define_File(char* pFileName, _Proc_Define_Info& obj_Proc_Define_Info)
{
	Close();
	m_pTiXmlDocument = new TiXmlDocument(pFileName);
	if(NULL == m_pTiXmlDocument)
	{
		return false;
	}

	if(false == m_pTiXmlDocument->LoadFile())
	{
		return false;
	}

	TiXmlNode* pMainNode     = NULL;

	//获得根元素
	m_pRootElement = m_pTiXmlDocument->RootElement();

	if(NULL == m_pRootElement)
	{
		return false;
	}

	//获得工程名称
	sprintf_safe(obj_Proc_Define_Info.m_szProcName, MAX_BUFF_50, "%s", (char* )m_pRootElement->Attribute("ProcName"));

	//循环获取预定义信息
	for(pMainNode = m_pRootElement->FirstChildElement();pMainNode;pMainNode = pMainNode->NextSiblingElement())
	{
		_Define_Info obj_Define_Info;

		//获得Lua文件信息
		int nMainType = pMainNode->Type();

		if(nMainType != TiXmlText::TINYXML_ELEMENT)
		{
			continue;
		}

		TiXmlElement* pMainElement = pMainNode->ToElement();
		sprintf_safe(obj_Define_Info.m_szSrcType, MAX_BUFF_50, "%s", pMainElement->Attribute("srcType"));
		sprintf_safe(obj_Define_Info.m_szTagType, MAX_BUFF_50, "%s", pMainElement->Attribute("tagType"));
		sprintf_safe(obj_Define_Info.m_szDesc, MAX_BUFF_100, "%s", pMainElement->Attribute("desc"));
		obj_Proc_Define_Info.obj_vec_Define_Info.push_back(obj_Define_Info);
	}

	delete m_pTiXmlDocument;
	m_pTiXmlDocument = NULL;

	return true;
}
Example #27
0
bool CTextureAtlas::Load()
{
    BEATS_ASSERT(!IsLoaded());

    TString fileext = CFilePathTool::GetInstance()->Extension(GetFilePath().c_str());
    if(fileext == _T(".xml"))
    {
        TiXmlDocument doc;
        CSerializer serializer;
        CFilePathTool::GetInstance()->LoadFile(&serializer, GetFilePath().c_str(), _T("rb"));
        if (serializer.GetWritePos() != serializer.GetReadPos())
        {
            doc.Parse((char*)serializer.GetReadPtr());
        }
        TiXmlElement *root = doc.RootElement();
        BEATS_ASSERT(root && strcmp(root->Value(), "Imageset") == 0, 
            _T("TextureAtlas file %s not found or incorrect!"), GetFilePath().c_str());

        const char *textureFile = root->Attribute("Imagefile");
        BEATS_ASSERT(textureFile);
        TCHAR szNameBuffer[MAX_PATH];
        CStringHelper::GetInstance()->ConvertToTCHAR(textureFile, szNameBuffer, MAX_PATH);
        m_texture = CResourceManager::GetInstance()->GetResource<CTexture>(szNameBuffer);
        kmVec2 size;
        kmVec2 point;
        TString strName;
        for(TiXmlElement *elemImage = root->FirstChildElement("Image");
            elemImage != nullptr; elemImage = elemImage->NextSiblingElement("Image"))
        {
            const char *name = elemImage->Attribute("Name");
            BEATS_ASSERT(name);
            kmVec2Fill(&point, 0.f, 0.f);
            kmVec2Fill(&size, 0.f, 0.f);
            elemImage->QueryFloatAttribute("XPos", &point.x);
            elemImage->QueryFloatAttribute("YPos", &point.y);
            elemImage->QueryFloatAttribute("Width", &size.x);
            elemImage->QueryFloatAttribute("Height", &size.y);

            CStringHelper::GetInstance()->ConvertToTCHAR(name, szNameBuffer, MAX_PATH);
            strName.assign(szNameBuffer);
            CreateTextureFrag(strName, point, size);
        }
    }
    else
    {
        m_texture = CResourceManager::GetInstance()->GetResource<CTexture>(GetFilePath());
    }

    m_name = CFilePathTool::GetInstance()->FileName(GetFilePath().c_str());
    super::Load();
    return true;
}
Example #28
0
static bool ReadDeviceCertificate(const CStdString& deviceCertificate, AppInfo* appInfo)
{
  TiXmlDocument xmlDoc;

  if(!xmlDoc.LoadFile(deviceCertificate))
  {
    CLog::Log(LOGERROR, "CAppSecurity::%s - Failed to load %s", __func__, deviceCertificate.c_str());
    return false;
  }

  TiXmlElement* root = xmlDoc.RootElement();
  if(!root)
  {
    CLog::Log(LOGERROR,"CAppSecurity::%s - Failed to get root from BXXMLDocument of %s", __func__, deviceCertificate.c_str());
    return false;
  }

  CStdString type, serial, mac;
  while (root)
  {
    if(strcmp(root->Value(),"device") == 0)
    {
      type = root->Attribute("type");
      serial = root->Attribute("sn");
      mac = root->Attribute("mac");

      root = root->FirstChildElement();
      continue;
    }
    else if(strcmp(root->Value(),"signature") == 0)
    {
      appInfo->signature = root->FirstChild()->Value();
    }

    root = root->NextSiblingElement();
  }  

  bool bVerified = false;
  do
  {
     if(appInfo->signature.IsEmpty())
     {
       CLog::Log(LOGERROR,"CAppSecurity::%s - Device signature is empty", __func__);
       break;
     }

    bVerified = true;

  } while(false);

  return bVerified;
}
Example #29
0
void DataModel::loadFish()
{
    TiXmlDocument* myDocument = new TiXmlDocument();
    unsigned char* pBuffer = NULL;
    ssize_t bufferSize = 0;
    pBuffer = FileUtils::getInstance()->getFileData("fish.xml", "r", &bufferSize);
    if (pBuffer) {
        myDocument->Parse((const char*)pBuffer);
        TiXmlElement* fishes = myDocument->RootElement();
        TiXmlElement* fish = fishes->FirstChildElement();
        while (fish) {
            const char * name = fish->Attribute("name");
            const char * color = fish->Attribute("color");
            const char * shape = fish->Attribute("shape");
            names.pushBack(__String::create(name));
            
            if (std::string(color) == std::string("red")) {
                red.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("blue")) {
                blue.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("purple")) {
                purple.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("green")) {
                green.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("pink")) {
                pink.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("yellow")) {
                yellow.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("olive-green")) {
                olive.pushBack(__String::create(name));
            } else if (std::string(color) == std::string("orange")) {
                orange.pushBack(__String::create(name));
            }
            
            if (std::string(shape) == std::string("solid")) {
                solid.pushBack(__String::create(name));
            } else if (std::string(shape) == std::string("dot")) {
                dot.pushBack(__String::create(name));
            } else if (std::string(shape) == std::string("dash")) {
                dash.pushBack(__String::create(name));
            } else if (std::string(shape) == std::string("stripe")) {
                stripe.pushBack(__String::create(name));
            } else if (std::string(shape) == std::string("ripple")) {
                ripple.pushBack(__String::create(name));
            } else if (std::string(shape) == std::string("line")) {
                line.pushBack(__String::create(name));
            }
            fish = fish->NextSiblingElement();
        }

    }
}
Example #30
0
std::string	ParsingXml::getPlayerScore(std::string &playerName)
{
  TiXmlElement *players = this->_doc.FirstChildElement("players");
  if (players)
    {
      for(TiXmlElement *player = players->FirstChildElement("player"); player; player = player->NextSiblingElement("player"))
	{
	  if (player->Attribute("name") == playerName)
	    return player->Attribute("score");
	}
    }
  return NULL;
}