当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlElement::NextSiblingElement方法代码示例

本文整理汇总了C++中TiXmlElement::NextSiblingElement方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::NextSiblingElement方法的具体用法?C++ TiXmlElement::NextSiblingElement怎么用?C++ TiXmlElement::NextSiblingElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlElement的用法示例。


在下文中一共展示了TiXmlElement::NextSiblingElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LERRORC

void NetworkConverter11to12::convertVolumeContainer(TiXmlElement* workspaceNode) {
    if (!workspaceNode) {
        LERRORC("voreen.NetworkConverter11to12", "no workspace node");
        return;
    }

    // construct map from Volume-refID to URL
    std::map<std::string, std::string> refToUrl;
    TiXmlElement* volumeContainerNode = workspaceNode->FirstChildElement("VolumeContainer");
    if (!volumeContainerNode)
        return;
    LWARNINGC("voreen.NetworkConverter11to12", "converting volume container ...");
    TiXmlElement* volumeHandlesNode = volumeContainerNode->FirstChildElement("VolumeHandles");
    if (!volumeHandlesNode)
        return;
    for (TiXmlElement* handleNode = volumeHandlesNode->FirstChildElement("VolumeHandle"); handleNode != 0; handleNode = handleNode->NextSiblingElement("VolumeHandle")) {
        const std::string* refID = handleNode->Attribute(std::string("id"));
        if (!refID)
            continue;
        TiXmlElement* originNode = handleNode->FirstChildElement("Origin");
        if (!originNode)
            continue;
        const std::string* url = originNode->Attribute(std::string("url"));
        if (!url)
            url = originNode->Attribute(std::string("filename"));
        if (!url)
            continue;

        tgtAssert(refID, "no refID");
        tgtAssert(url, "no url");
        refToUrl.insert(std::pair<std::string, std::string>(*refID, *url));
    }

    // look for VolumeSource processors and replace their VolumeHandleProperty (with specific refID)
    // with a VolumeURLProperty with the corresponding volume URL
    TiXmlElement* networkNode = workspaceNode->FirstChildElement("ProcessorNetwork");
    if (!networkNode)
        return;
    TiXmlElement* processorsNode = networkNode->FirstChildElement("Processors");
    if (!processorsNode)
        return;
    for (TiXmlElement* procNode = processorsNode->FirstChildElement("Processor"); procNode != 0; procNode = procNode->NextSiblingElement("Processor")) {
        const std::string* type = procNode->Attribute(std::string("type"));
        if (!type || *type != "VolumeSource")
            continue;

        // it's a VolumeSource => extract VolumeHandleProperty node
        TiXmlElement* propertiesNode = procNode->FirstChildElement("Properties");
        if (!propertiesNode)
            continue;
        TiXmlElement* handlePropNode = propertiesNode->FirstChildElement("Property");
        if (!handlePropNode)
            continue;
        const std::string* propName = handlePropNode->Attribute(std::string("name"));
        if (!propName || *propName != "volumeHandle")
            continue;

        // convert VolumeHandleProperty to VolumeURLProperty
        handlePropNode->SetAttribute("name", "volumeURL");

        // retrieve Volume reference
        TiXmlElement* valueNode = handlePropNode->FirstChildElement("value");
        if (!valueNode)
            continue;
        const std::string* refID = valueNode->Attribute(std::string("ref"));
        if (!refID)
            continue;

        // insert referenced URL into converted VolumeHandleProperty
        if (refToUrl.find(*refID) == refToUrl.end())
            LWARNINGC("voreen.NetworkConverter11to12", "convertVolumeContainer(): unknown refID: " << *refID);
        else
            handlePropNode->SetAttribute("url", refToUrl[*refID]);
    }


}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:77,代码来源:networkconverter.cpp

示例2: doc

/**
 * Create an Core object reading data from XML file
 *
 * @brief Core::loadFromFile
 * @param path
 * @return
 */
Core *
Core::loadFromFile(std::string basePath, std::string file)
{
    /* Create the core and run setup() */
    Core *it = new Core();

    if(!it->setup())
        return NULL;

    /* Load XML file */
    TiXmlDocument doc(basePath+file);

    std::cout << "Loading from file: "<< basePath+file << "... ";

    if(!doc.LoadFile())
    {
        std::cout << "Failed" << std::endl;;
        return NULL;
    }

    std::cout << "Ok" << std::endl;;
    TiXmlElement *root = doc.RootElement();

    // Terrain
    TiXmlElement *terrain = root->FirstChildElement("terrain");

    if(terrain)
    {
        std::string ttype = terrain->Attribute("type");
        std::string tpath = terrain->Attribute("path");

        // Set terrain
        std::cout << "\tSetting terrain (" << tpath << ")... ";
        if(it->setTerrain(basePath+tpath, ttype))
            std::cout << "Ok" << std::endl;
        else
            std::cout << "Failed" << std::endl;
    }

    // Layers
    TiXmlElement *layers = root->FirstChildElement("layers");

    if(layers)
    {
        TiXmlElement *layer = layers->FirstChildElement();

        while(layer)
        {
            std::string ltype = layer->Attribute("type");
            std::string lpath = layer->Attribute("path");
            std::string lname = layer->Attribute("name");
            std::string lmat = layer->Attribute("materials");

            // Add layer
            std::cout << "\tAdding layer (" << lpath << ")... ";
            if(it->addLayer(lname, basePath+lpath, lmat, ltype))
                    std::cout << "Ok" << std::endl;
                else
                    std::cout << "Failed" << std::endl;

            layer = layer->NextSiblingElement();
        }
    }

    return it;
}
开发者ID:dakk,项目名称:int-city,代码行数:73,代码来源:Core.cpp

示例3: parsXml

Module* XmlModLoader::parsXml(const char* szFile)
{
    module.clear();
    ErrorLogger* logger  = ErrorLogger::Instance();
    
    TiXmlDocument doc(szFile);
    if(!doc.LoadFile()) 
    {
        OSTRINGSTREAM err;
        err<<"Syntax error while loading "<<szFile<<" at line "\
           <<doc.ErrorRow()<<": ";
        err<<doc.ErrorDesc();
        logger->addError(err);
        return NULL;
    }
    
    /* retrieving root module */
    TiXmlElement *root = doc.RootElement();
    if(!root)    
    {
        OSTRINGSTREAM err;
        err<<"Syntax error while loading "<<szFile<<" . ";
        err<<"No root element.";
        logger->addError(err);
        return NULL;
    }
    
    if(!compareString(root->Value(), "module"))
    {
        /*
        OSTRINGSTREAM msg;
        msg<<szFile<<" is not a module descriptor file.";
        logger->addWarning(msg);
        */
        return NULL;
    }
    
    /* retrieving name */
    TiXmlElement* name = (TiXmlElement*) root->FirstChild("name");
    if(!name || !name->GetText())
    {
        OSTRINGSTREAM err;
        err<<"Module from "<<szFile<<" has no name.";
        logger->addError(err);      
        //return NULL;
    }

    module.setXmlFile(szFile);
    
    if(name)
        module.setName(name->GetText());

    /* retrieving description */
    TiXmlElement* desc;
    if((desc = (TiXmlElement*) root->FirstChild("description")))
        module.setDescription(desc->GetText());

    /* retrieving version */
    TiXmlElement* ver;
    if((ver = (TiXmlElement*) root->FirstChild("version")))
        module.setVersion(ver->GetText());


    /* retrieving parameter */
    TiXmlElement* arguments;
    if((arguments = (TiXmlElement*) root->FirstChild("arguments")))
        for(TiXmlElement* param = arguments->FirstChildElement(); param;
                param = param->NextSiblingElement())
        {
            if(compareString(param->Value(), "param"))
            {           
                if(param->GetText())
                {   
                    bool brequired = false;
                    if(compareString(param->Attribute("required"), "yes"))
                        brequired = true; 
                    Argument arg(param->GetText(), 
                                 brequired,
                                 param->Attribute("desc"));
                    arg.setDefault(param->Attribute("default"));
                    module.addArgument(arg);                 
                }
            }
            else
            if(compareString(param->Value(), "switch"))
            {           
                if(param->GetText())
                {   
                    bool brequired = false;
                    if(compareString(param->Attribute("required"), "yes"))
                        brequired = true; 
                    Argument arg(param->GetText(), 
                                 brequired,
                                 param->Attribute("desc"), true);
                    arg.setDefault(param->Attribute("default"));
                    module.addArgument(arg);                 
                }
            }                      
            else
            {
//.........这里部分代码省略.........
开发者ID:andreadelprete,项目名称:yarp,代码行数:101,代码来源:xmlmodloader.cpp

示例4: InternalFindMovie

int CIMDB::InternalFindMovie(const CStdString &strMovie, IMDB_MOVIELIST& movielist, bool& sortMovieList, const CStdString& strFunction, CScraperUrl* pUrl)
{
  movielist.clear();

  CScraperUrl scrURL;
  
  CStdString strName = strMovie;
  CStdString movieTitle, movieTitleAndYear, movieYear;
  CUtil::CleanString(strName, movieTitle, movieTitleAndYear, movieYear, true);

  movieTitle.ToLower();

  CLog::Log(LOGDEBUG, "%s: Searching for '%s' using %s scraper (file: '%s', content: '%s', language: '%s', date: '%s', framework: '%s')",
    __FUNCTION__, movieTitle.c_str(), m_info.strTitle.c_str(), m_info.strPath.c_str(), m_info.strContent.c_str(), m_info.strLanguage.c_str(), m_info.strDate.c_str(), m_info.strFramework.c_str());

  if (!pUrl)
  {
  if (m_parser.HasFunction("CreateSearchUrl"))
  {
      GetURL(strMovie, movieTitle, movieYear, scrURL);
  }
  else if (m_info.strContent.Equals("musicvideos"))
  {
    if (!m_parser.HasFunction("FileNameScrape"))
      return false;
    
    CScraperUrl scrURL("filenamescrape");
    scrURL.strTitle = strMovie;
    movielist.push_back(scrURL);
      return 1;
  }
    if (scrURL.m_xml.IsEmpty())
      return 0;
  }
  else
    scrURL = *pUrl;  

  vector<CStdString> strHTML;
  for (unsigned int i=0;i<scrURL.m_url.size();++i)
  {
    CStdString strCurrHTML;
    if (!CScraperUrl::Get(scrURL.m_url[i],strCurrHTML,m_http) || strCurrHTML.size() == 0)
      return 0;
    strHTML.push_back(strCurrHTML);
  }
  
  // now grab our details using the scraper
  for (unsigned int i=0;i<strHTML.size();++i)
    m_parser.m_param[i] = strHTML[i];
  m_parser.m_param[strHTML.size()] = scrURL.m_url[0].m_url;
  CStdString strXML = m_parser.Parse(strFunction,&m_info.settings);
  //CLog::Log(LOGDEBUG,"scraper: %s returned %s",strFunction.c_str(),strXML.c_str());
  if (strXML.IsEmpty())
  {
    CLog::Log(LOGERROR, "%s: Unable to parse web site",__FUNCTION__);
    return 0;
  }
  
  if (!XMLUtils::HasUTF8Declaration(strXML))
    g_charsetConverter.unknownToUTF8(strXML);

  // ok, now parse the xml file
  TiXmlDocument doc;
  doc.Parse(strXML.c_str(),0,TIXML_ENCODING_UTF8);
  if (!doc.RootElement())
  {
    CLog::Log(LOGERROR, "%s: Unable to parse xml",__FUNCTION__);
    return 0;
  }
  if (stricmp(doc.RootElement()->Value(),"error")==0)
  {
    TiXmlElement* title = doc.RootElement()->FirstChildElement("title");
    CStdString strTitle;
    if (title && title->FirstChild() && title->FirstChild()->Value())
      strTitle = title->FirstChild()->Value();
    TiXmlElement* message = doc.RootElement()->FirstChildElement("message");
    CStdString strMessage;
    if (message && message->FirstChild() && message->FirstChild()->Value())
      strMessage = message->FirstChild()->Value();
    CGUIDialogOK* dialog = (CGUIDialogOK*)g_windowManager.GetWindow(WINDOW_DIALOG_OK);
    dialog->SetHeading(strTitle);
    dialog->SetLine(0,strMessage);
    g_application.getApplicationMessenger().DoModal(dialog,WINDOW_DIALOG_OK);
    return -1;
  }
 
  TiXmlHandle docHandle( &doc );

  TiXmlElement* xurl = doc.RootElement()->FirstChildElement("url");
  while (xurl && xurl->FirstChild())
  {
    const char* szFunction = xurl->Attribute("function");
    if (szFunction)
    {
      CScraperUrl scrURL(xurl);
      InternalFindMovie(strMovie,movielist,sortMovieList,szFunction,&scrURL);
    }
    xurl = xurl->NextSiblingElement("url");
  }

//.........这里部分代码省略.........
开发者ID:flyingtime,项目名称:boxee,代码行数:101,代码来源:IMDB.cpp

示例5: OnXmlWrite

bool wxsCustomWidget::OnXmlWrite(TiXmlElement* Element,bool IsXRC,bool IsExtra)
{
    bool Ret = wxsItem::OnXmlWrite(Element,IsXRC,IsExtra);

    if ( IsXRC )
    {
        if ( !(GetPropertiesFlags() & flSource) )
        {
            Element->SetAttribute("class",cbU2C(GetUserClass()));
            Element->RemoveAttribute("subclass");
            Element->InsertEndChild(TiXmlElement("style"))->InsertEndChild(TiXmlText(cbU2C(m_Style)));

            for ( TiXmlElement* Child = m_XmlDataDoc.FirstChildElement(); Child; Child = Child->NextSiblingElement() )
            {
                // Skipping all standard elements
                wxString Name = cbC2U(Child->Value());
                if ( Name != _T("pos") &&
                     Name != _T("size") &&
                     Name != _T("style") &&
                     Name != _T("enabled") &&
                     Name != _T("focused") &&
                     Name != _T("hidden") &&
                     Name != _T("fg") &&
                     Name != _T("bg") &&
                     Name != _T("font") &&
                     Name != _T("handler") )
                {
                    Element->InsertEndChild(*Child);
                }
            }
        }
    }

    return Ret;
}
开发者ID:stahta01,项目名称:EmBlocks_old,代码行数:35,代码来源:wxscustomwidget.cpp

示例6: readXml


//.........这里部分代码省略.........
			if((objName = Xml::getAttrString(child, "name")) != "")
			{
				Rect* r = new Rect(objName, getOscRootAddress());
				r->loadXml(child);
				addObject(r);
				
				LOG_DEBUG << "Scene \"" << _name << "\": Loaded rect \"" << objName << "\" \""
						  << r->getOscRootAddress() << "\"" << std::endl;
			}
			else
			{
				LOG_WARN << "Scene \"" << _name << "\": cannot load rect without name, line "
						 << child->Row() << endl;
			}
		}

		else if(child->ValueStr() == "bitmap")
		{
			if((objName = Xml::getAttrString(child, "name")) != "")
			{
				Bitmap* b = new Bitmap(objName, getOscRootAddress());
				b->loadXml(child);
				addObject(b);
				
				LOG_DEBUG << "Scene \"" << _name << "\": Loaded bitmap \"" << objName << "\" \""
						  << b->getOscRootAddress() << "\"" << std::endl;
			}
			else
			{
				LOG_WARN << "Scene \"" << _name << "\": cannot load bitmap without name, line "
						 << child->Row() << endl;
			}
		}

		else if(child->ValueStr() == "sprite")
		{
			if((objName = Xml::getAttrString(child, "name")) != "")
			{
				Sprite* s = new Sprite(objName, getOscRootAddress());
				s->loadXml(child);
				addObject(s);
				
				LOG_DEBUG << "Scene \"" << _name << "\": Loaded sprite \"" << objName << "\" \""
						  << s->getOscRootAddress() << "\"" << std::endl;
			}
			else
			{
				LOG_WARN << "Scene \"" << _name << "\": cannot load sprite without name, line "
						 << child->Row() << endl;
			}
		}
		
		else if(child->ValueStr() == "image")
		{
			if((objName = Xml::getAttrString(child, "name")) != "")
			{
				Image* i = new Image(objName, getOscRootAddress());
				i->loadXml(child);
				addObject(i);
				
				LOG_DEBUG << "Scene \"" << _name << "\": Loaded image \"" << objName << "\" \""
						  << i->getOscRootAddress() << "\"" << std::endl;
			}
			else
			{
				LOG_WARN << "Scene \"" << _name << "\": cannot load image without name, line "
						 << child->Row() << endl;
			}
		}
		
		else if(child->ValueStr() == "text")
		{
			if((objName = Xml::getAttrString(child, "name")) != "")
			{
				Text* t = new Text(objName, getOscRootAddress());
				t->loadXml(child);
				addObject(t);
				
				LOG_DEBUG << "Scene \"" << _name << "\": Loaded text \"" << objName << "\" \""
						  << t->getOscRootAddress() << "\"" << std::endl;
			}
			else
			{
				LOG_WARN << "Scene \"" << _name << "\": cannot load text without name, line "
						 << child->Row() << endl;
			}
		}

		else if(child->ValueStr() != "background")
		{
			LOG_WARN << "Scene \"" << _name << "\": ignoring unknown element \""
					 << child->ValueStr() << "\"" << endl;
		}


		child = child->NextSiblingElement();
	}

	return true;
}
开发者ID:danomatika,项目名称:rc-visual,代码行数:101,代码来源:Scene.cpp

示例7: LoadPrefs

bool LoadPrefs()
{
    if (prefLoaded) // already attempted loading
        return true;

    char filepath[MAXPATHLEN];
    sprintf(filepath, "%s/%s", MPLAYER_DATADIR, PREF_FILE_NAME);

    TiXmlDocument doc;

    bool loadOkay = doc.LoadFile(filepath);
    if (loadOkay) {
        FixInvalidSettings();
        TiXmlHandle docu(&doc);
        TiXmlElement* settings = docu.FirstChildElement().Element();
        if (settings == NULL) {
            goto noheader;
        }
        TiXmlHandle handle(0);
        TiXmlElement* elem;
        handle = TiXmlHandle(settings);
        elem = handle.FirstChild("global").FirstChild().Element();
        for (elem; elem; elem = elem->NextSiblingElement()) {
            const char* elemName = elem->Value();
            if (strcmp(elemName, "exit") == 0) {
                XMPlayerCfg.exit_action = atoi(elem->Attribute("value"));
            } else if (strcmp(elemName, "language") == 0) {
                XMPlayerCfg.language = atoi(elem->Attribute("value"));
            }
        }
        elem = handle.FirstChild("filebrowser").FirstChild().Element();
        for (elem; elem; elem = elem->NextSiblingElement()) {
            const char* elemName = elem->Value();
            if (strcmp(elemName, "sort") == 0) {
                XMPlayerCfg.sort_order = atoi(elem->Attribute("value"));
            }
        }
        elem = handle.FirstChild("audio").FirstChild().Element();
        for (elem; elem; elem = elem->NextSiblingElement()) {
            const char* elemName = elem->Value();
            if (strcmp(elemName, "language") == 0) {
                sprintf(XMPlayerCfg.alang, elem->Attribute("value"));
                sprintf(XMPlayerCfg.alang_desc, elem->Attribute("desc"));
            } else if (strcmp(elemName, "volume") == 0) {
                XMPlayerCfg.volume = atoi(elem->Attribute("value"));
            } else if (strcmp(elemName, "softvol") == 0) {
                XMPlayerCfg.softvol = atoi(elem->Attribute("value"));
            }
        }
        elem = handle.FirstChild("video").FirstChild().Element();
        for (elem; elem; elem = elem->NextSiblingElement()) {
            const char* elemName = elem->Value();
            if (strcmp(elemName, "framedrop") == 0) {
                XMPlayerCfg.framedrop = atoi(elem->Attribute("value"));
            } else if (strcmp(elemName, "vsync") == 0) {
                XMPlayerCfg.vsync = atoi(elem->Attribute("value"));
            }
        }
        elem = handle.FirstChild("subtitles").FirstChild().Element();
        for (elem; elem; elem = elem->NextSiblingElement()) {
            const char* elemName = elem->Value();
            if (strcmp(elemName, "sub_color") == 0) {
                elem->Attribute("value", &XMPlayerCfg.subcolor);
            } else if (strcmp(elemName, "border_color") == 0) {
                elem->Attribute("value", &XMPlayerCfg.border_color);
            } else if (strcmp(elemName, "codepage") == 0) {
                sprintf(XMPlayerCfg.subcp, elem->Attribute("value"));
                sprintf(XMPlayerCfg.subcp_desc, elem->Attribute("desc"));
            } else if (strcmp(elemName, "language") == 0) {
                sprintf(XMPlayerCfg.sublang, elem->Attribute("value"));
                sprintf(XMPlayerCfg.sublang_desc, elem->Attribute("desc"));
            }
        }
        doc.Clear();
        prefLoaded = true;

        printf("[Preferences] Sucessfully loaded xmplayer.xml \n");
        return true;

    } else {
noheader:
        DefaultSettings();
        printf("[Preferences] Failed to load xmplayer.xml - Loading default settings \n");
        return false;
    }

}
开发者ID:,项目名称:,代码行数:87,代码来源:

示例8: parseObjectLayer

void LevelParser::parseObjectLayer(TiXmlElement* pObjectElement, std::vector<Layer*> *pLayers, Level* pLevel)
{
    // create an object layer
    ObjectLayer* pObjectLayer = new ObjectLayer();
    
    for(TiXmlElement* e = pObjectElement->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
    {
        if(e->Value() == std::string("object"))
        {
            int x, y, width, height, numFrames, callbackID = 0, animSpeed = 0;
            std::string textureID;
            std::string type;
            
            // get the initial node values type, x and y
            e->Attribute("x", &x);
            e->Attribute("y", &y);
            
            type = e->Attribute("type");
            GameObject* pGameObject = TheGameObjectFactory::Instance()->create(type);
            
            // get the property values
            for(TiXmlElement* properties = e->FirstChildElement(); properties != NULL; properties = properties->NextSiblingElement())
            {
                if(properties->Value() == std::string("properties"))
                {
                    for(TiXmlElement* property = properties->FirstChildElement(); property != NULL; property = property->NextSiblingElement())
                    {
                        if(property->Value() == std::string("property"))
                        {
                            if(property->Attribute("name") == std::string("numFrames"))
                            {
                                property->Attribute("value", &numFrames);
                            }
                            else if(property->Attribute("name") == std::string("textureHeight"))
                            {
                                property->Attribute("value", &height);
                            }
                            else if(property->Attribute("name") == std::string("textureID"))
                            {
                                textureID = property->Attribute("value");
                            }
                            else if(property->Attribute("name") == std::string("textureWidth"))
                            {
                                property->Attribute("value", &width);
                            }
                            else if(property->Attribute("name") == std::string("callbackID"))
                            {
                                property->Attribute("value", &callbackID);
                            }
                            else if(e->Attribute("name") == std::string("animSpeed"))
                            {
                                property->Attribute("value", &animSpeed);
                            }
                        }
                    }
                }
            }
            // load the object
            pGameObject->load(std::unique_ptr<LoaderParams>(new LoaderParams(x, y, width, height, textureID, numFrames,callbackID, animSpeed)));
            // set the collision layers
            pGameObject->setCollisionLayers(pLevel->getCollisionLayers());
            
            if(type == "Player")
            {
                pLevel->setPlayer(dynamic_cast<Player*>(pGameObject));
            }
            
            pObjectLayer->getGameObjects()->push_back(pGameObject);
        }
    }
    
    pLayers->push_back(pObjectLayer);
}
开发者ID:WillSams,项目名称:Conan-the-Caveman-Linux,代码行数:73,代码来源:LevelParser.cpp

示例9: parseTileLayer

void LevelParser::parseTileLayer(TiXmlElement* pTileElement, std::vector<Layer*> *pLayers, const std::vector<Tileset>* pTilesets, std::vector<TileLayer*> *pCollisionLayers)
{
    TileLayer* pTileLayer = new TileLayer(m_tileSize, m_width, m_height, *pTilesets);
    
    bool collidable = false;
    
    // tile data
    std::vector<std::vector<int>> data;
    
    std::string decodedIDs;
    TiXmlElement* pDataNode;
    
    for(TiXmlElement* e = pTileElement->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
    {
        if(e->Value() == std::string("properties"))
        {
            for(TiXmlElement* property = e->FirstChildElement(); property != NULL; property = property->NextSiblingElement())
            {
                if(property->Value() == std::string("property"))
                {
                    if(property->Attribute("name") == std::string("collidable"))
                    {
                        collidable = true;
                    }
                }
            }
        }
        
        if(e->Value() == std::string("data"))
        {
            pDataNode = e;
        }
    }
    
    for(TiXmlNode* e = pDataNode->FirstChild(); e != NULL; e = e->NextSibling())
    {
        TiXmlText* text = e->ToText();
        std::string t = text->Value();
        decodedIDs = base64_decode(t);
    }
    
    // uncompress zlib compression
    uLongf sizeofids = m_width * m_height * sizeof(int);
    std::vector<int> ids(m_width * m_height);
    uncompress((Bytef*)&ids[0], &sizeofids,(const Bytef*)decodedIDs.c_str(), decodedIDs.size());
    
    std::vector<int> layerRow(m_width);
    
    for(int j = 0; j < m_height; j++)
    {
        data.push_back(layerRow);
    }
    
    for(int rows = 0; rows < m_height; rows++)
    {
        for(int cols = 0; cols < m_width; cols++)
        {
            data[rows][cols] = ids[rows * m_width + cols];
        }
    }
    
    pTileLayer->setTileIDs(data);
    
    if(collidable)
    {
        pCollisionLayers->push_back(pTileLayer);
    }
    
    pLayers->push_back(pTileLayer);
}
开发者ID:WillSams,项目名称:Conan-the-Caveman-Linux,代码行数:70,代码来源:LevelParser.cpp

示例10: AddTexturesFromZip

//---------------------------------------------------------------------------
bool BitmapFont::AddTexturesFromZip( TiXmlDocument& metaDataDocument, ZipFile* zipFile, const std::string& metaDataFilePath )
{
	TiXmlElement* rootElement = metaDataDocument.RootElement();
	TiXmlElement* pageElement = rootElement->FirstChildElement( "pages" );
	const size_t lastSlashLocation = metaDataFilePath.rfind( '/' );
	for ( TiXmlElement* currentElement = pageElement->FirstChildElement( "page" ); currentElement != nullptr; currentElement = currentElement->NextSiblingElement( "page" ) )
	{
		Texture* texture = Texture::CreateOrGetTexture( zipFile, metaDataFilePath.substr( 0, lastSlashLocation + 1 ) + std::string( currentElement->Attribute( "file" ) ) );
		if ( !texture ) return false;
		m_glyphSheets.push_back( texture );
	}
	return true;
}
开发者ID:slajar,项目名称:BeatDetection,代码行数:14,代码来源:BitmapFont.cpp

示例11: parseXML

void IPXMLParser::parseXML() {
    if ( fileName.empty() )
        throw std::runtime_error( "Exception: fileName.empty()" );

    doc = TiXmlDocument( fileName );

    if ( !doc.LoadFile() )
        throw std::runtime_error( "Exception: XML file cannot be loaded!" );

    std::cout << fileName << " opened successfully!\n";

    TiXmlHandle hDoc( &doc );
    TiXmlHandle hRoot( NULL );

    el = hDoc.FirstChildElement( "Properties" ).ToElement();

    if ( !el )
        throw std::runtime_error(
                "Exception: XML file empty or 'Properties' missing!" );

    hRoot = TiXmlHandle( el );

    TiXmlElement * properties = hRoot.FirstChild( "Property" ).ToElement();

    if ( !properties )
        throw std::runtime_error( "Exception: 'Properties' is empty!" );

    for ( ; properties;
            properties = properties->NextSiblingElement( "Property" ) ) {
        const char * elName = properties->Attribute( "name" );

        if ( !properties )
            throw std::runtime_error( "Exception: no element named Property!" );

        if ( strcmp( elName, "hsvMin" ) != 0
                && std::strcmp( elName, "hsvMax" ) != 0 )
            throw std::runtime_error(
                    "Exception: hsvMin and hsvMax not available!" );

        if ( strcmp( elName, "hsvMin" ) == 0 ) {
            double hMin, sMin, vMin;

            properties->QueryDoubleAttribute( "hMin", &hMin );
            properties->QueryDoubleAttribute( "sMin", &sMin );
            properties->QueryDoubleAttribute( "vMin", &vMin );

            hsvMin = cv::Scalar( hMin, sMin, vMin );

            std::cout << "hsvMin: " << hsvMin( 0 ) << " " << hsvMin( 1 ) << " "
                    << hsvMin( 2 ) << " " << hsvMin( 3 ) << std::endl;
        }

        if ( strcmp( elName, "hsvMax" ) == 0 ) {
            double hMax, sMax, vMax;

            properties->QueryDoubleAttribute( "hMax", &hMax );
            properties->QueryDoubleAttribute( "sMax", &sMax );
            properties->QueryDoubleAttribute( "vMax", &vMax );

            hsvMax = cv::Scalar( hMax, sMax, vMax );

            std::cout << "hsvMax: " << hsvMax( 0 ) << " " << hsvMax( 1 ) << " "
                    << hsvMax( 2 ) << " " << hsvMax( 3 ) << std::endl;
        }
    }
}
开发者ID:frferrara,项目名称:ImageProcessingBla,代码行数:66,代码来源:IPXMLParser.cpp

示例12: ExtractMetaDataFromTinyXMLDocument

//---------------------------------------------------------------------------
void BitmapFont::ExtractMetaDataFromTinyXMLDocument( TiXmlDocument& metaDataDocument )
{
	Vec2f glyphPosition;
	Vec2f glyphDimensions;

	TiXmlElement* rootElement = metaDataDocument.RootElement();
	TiXmlElement* charElement = rootElement->FirstChildElement( "chars" );
	TiXmlElement* commonElement = rootElement->FirstChildElement( "common" );

	Vec2f glyphSheetDimensions( ( float ) atof( commonElement->Attribute( "scaleW" ) ), ( float ) atof( commonElement->Attribute( "scaleH" ) ) );
	Vec2f oneOverGlyphSheetDimensions( 1.f / glyphSheetDimensions.x, 1.f / glyphSheetDimensions.y );
	float oneOverGlyphCellHeight = 1.f / ( float ) atof( commonElement->Attribute( "lineHeight" ) );

	for ( TiXmlElement* currentElement = charElement->FirstChildElement( "char" ); currentElement != nullptr; currentElement = currentElement->NextSiblingElement( "char" ) )
	{
		GlyphMetaData& dataHolder = m_glyphData[ atoi( currentElement->Attribute( "id" ) ) ];
		// store page number
		dataHolder.m_glyphSheetIndex = ( char ) atoi( currentElement->Attribute( "page" ) );

		// find mins
		glyphPosition.x = ( float ) atof( currentElement->Attribute( "x" ) );
		glyphPosition.y = ( float ) atof( currentElement->Attribute( "y" ) );
		dataHolder.m_minTexCoords = Vec2f( glyphPosition.x * oneOverGlyphSheetDimensions.x, glyphPosition.y * oneOverGlyphSheetDimensions.y );

		// find maxes
		glyphDimensions.x = ( float ) atof( currentElement->Attribute( "width" ) ) * oneOverGlyphSheetDimensions.x;
		glyphDimensions.y = ( float ) atof( currentElement->Attribute( "height" ) ) * oneOverGlyphSheetDimensions.y;
		dataHolder.m_maxTexCoords = dataHolder.m_minTexCoords + glyphDimensions;

		// find a b c values
		dataHolder.m_ttfA = ( float ) atof( currentElement->Attribute( "xoffset" ) ) * oneOverGlyphCellHeight;
		dataHolder.m_ttfB = ( float ) atof( currentElement->Attribute( "width" ) ) * oneOverGlyphCellHeight; // width
		dataHolder.m_ttfC = ( float ) ( atoi( currentElement->Attribute( "xadvance" ) ) -
			( atoi( currentElement->Attribute( "width" ) ) + atoi( currentElement->Attribute( "xoffset" ) ) ) )
			* oneOverGlyphCellHeight; // xoffset - ( xadvance + width )
	}
}
开发者ID:slajar,项目名称:BeatDetection,代码行数:38,代码来源:BitmapFont.cpp

示例13: GetNewsItems

void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)
{
  HTML::CHTMLUtil html;

  TiXmlElement * itemNode = channelXmlNode->FirstChildElement("item");
  std::map<std::string, std::wstring> mTagElements;
  typedef std::pair<std::string, std::wstring> StrPair;
  std::list<std::string>::iterator i;

  // Add the title tag in if we didn't pass any tags in at all
  // Represents default behaviour before configurability

  if (m_tagSet.empty())
    AddTag("title");

  while (itemNode != nullptr)
  {
    TiXmlNode* childNode = itemNode->FirstChild();
    mTagElements.clear();
    while (childNode != nullptr)
    {
      std::string strName = childNode->ValueStr();

      for (i = m_tagSet.begin(); i != m_tagSet.end(); ++i)
      {
        if (!childNode->NoChildren() && *i == strName)
        {
          std::string htmlText = childNode->FirstChild()->ValueStr();

          // This usually happens in right-to-left languages where they want to
          // specify in the RSS body that the text should be RTL.
          // <title>
          //  <div dir="RTL">��� ����: ���� �� �����</div>
          // </title>
          if (htmlText == "div" || htmlText == "span")
            htmlText = childNode->FirstChild()->FirstChild()->ValueStr();

          std::wstring unicodeText, unicodeText2;

          g_charsetConverter.utf8ToW(htmlText, unicodeText2, m_rtlText);
          html.ConvertHTMLToW(unicodeText2, unicodeText);

          mTagElements.insert(StrPair(*i, unicodeText));
        }
      }
      childNode = childNode->NextSibling();
    }

    int rsscolour = RSS_COLOR_HEADLINE;
    for (i = m_tagSet.begin(); i != m_tagSet.end(); ++i)
    {
      std::map<std::string, std::wstring>::iterator j = mTagElements.find(*i);

      if (j == mTagElements.end())
        continue;

      std::wstring& text = j->second;
      AddString(text, rsscolour, iFeed);
      rsscolour = RSS_COLOR_BODY;
      text = L" - ";
      AddString(text, rsscolour, iFeed);
    }
    itemNode = itemNode->NextSiblingElement("item");
  }
}
开发者ID:FLyrfors,项目名称:xbmc,代码行数:65,代码来源:RssReader.cpp

示例14: changeProcessorType

void NetworkConverter::changeProcessorType(TiXmlElement* elem, const std::string& from, const std::string& to) {
    TiXmlElement* processorsNode = elem->FirstChildElement("Processors");
    for (TiXmlElement* node = processorsNode->FirstChildElement("Processor"); node != 0; node = node->NextSiblingElement("Processor")) {
        const std::string* type = node->Attribute(std::string("type"));
        if (type && *type == from) {
            node->SetAttribute("type", to);
            const std::string* name = node->Attribute(std::string("name"));
            if (name && *name == from)
                node->SetAttribute("name", to);
        }
    }
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:12,代码来源:networkconverter.cpp

示例15: ReadTexture

TextureMap* ReadTexture(TiXmlElement *element)
{
    const char* texName = element->Attribute("texture");
    if ( texName == NULL ) return NULL;
    
    Texture *tex = NULL;
    if ( COMPARE(texName,"checkerboard") ) {
        TextureChecker *ctex = new TextureChecker;
        tex = ctex;
        printf("      Texture: Checker Board\n");
        for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
            if ( COMPARE( child->Value(), "color1" ) ) {
                Color c(0,0,0);
                ReadColor( child, c );
                ctex->SetColor1(c);
                printf("         color1 %f %f %f\n",c.r,c.g,c.b);
            } else if ( COMPARE( child->Value(), "color2" ) ) {
                Color c(0,0,0);
                ReadColor( child, c );
                ctex->SetColor2(c);
                printf("         color2 %f %f %f\n",c.r,c.g,c.b);
            }
        }
        textureList.Append( tex, texName );
    } else {
        printf("      Texture: File \"%s\"",texName);
        tex = textureList.Find( texName );
        if ( tex == NULL ) {
            TextureFile *ftex = new TextureFile;
            tex = ftex;
            ftex->SetName(texName);
            if ( ! ftex->Load() ) {
                printf(" -- Error loading file!");
                delete tex;
                tex = NULL;
            } else {
                textureList.Append( tex, texName );
            }
        }
        printf("\n");
    }
    
    TextureMap *map = new TextureMap(tex);
    LoadTransform(map,element,1);
    return map;
}
开发者ID:varunk08,项目名称:raytracing,代码行数:46,代码来源:xmlload.cpp


注:本文中的TiXmlElement::NextSiblingElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。