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


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

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


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

示例1: LoadState

	void SphereCollider::LoadState(TiXmlElement* xmlElement)
	{
		TiXmlElement* centerEle = xmlElement->FirstChildElement("Center");

		if( centerEle != 0 )
		{
			TiXmlElement* xEle = centerEle->FirstChildElement("x");
			if( xEle != 0 &&
				xEle->GetText() != 0 &&
				strlen(xEle->GetText()) != 0 )
			{
				sphere.center.x = (float)atof(xEle->GetText());
			}

			TiXmlElement* yEle = centerEle->FirstChildElement("y");
			if( yEle != 0 &&
				yEle->GetText() != 0 &&
				strlen(yEle->GetText()) != 0 )
			{
				sphere.center.y = (float)atof(yEle->GetText());
			}

			TiXmlElement* zEle = centerEle->FirstChildElement("z");
			if( zEle != 0 &&
				zEle->GetText() != 0 &&
				strlen(zEle->GetText()) != 0 )
			{
				sphere.center.z = (float)atof(zEle->GetText());
			}
		}

		TiXmlElement* radiusEle = xmlElement->FirstChildElement("Radius");
		
		if( radiusEle != 0 &&
			radiusEle->GetText() != 0 &&
			strlen(radiusEle->GetText()) != 0 )
			sphere.radius = (float)atof(radiusEle->GetText());
	}
开发者ID:Burnsidious,项目名称:FSGDEngine,代码行数:38,代码来源:SphereCollider.cpp

示例2: MapJoystickActions

void CButtonTranslator::MapJoystickActions(int windowID, TiXmlNode *pJoystick)
{
  string joyname = "_xbmc_"; // default global map name
  vector<string> joynames;
  map<int, string> buttonMap;
  map<int, string> axisMap;
  map<int, string> hatMap;

  TiXmlElement *pJoy = pJoystick->ToElement();
  if (pJoy && pJoy->Attribute("name"))
    joyname = pJoy->Attribute("name");
  else
    CLog::Log(LOGNOTICE, "No Joystick name specified, loading default map");

  joynames.push_back(joyname);

  // parse map
  TiXmlElement *pButton = pJoystick->FirstChildElement();
  int id = 0;
  //char* szId;
  const char* szType;
  const char *szAction;
  while (pButton)
  {
    szType = pButton->Value();
    szAction = pButton->GetText();
    if (szAction == NULL)
      szAction = "";
    if (szType)
    {
      if ((pButton->QueryIntAttribute("id", &id) == TIXML_SUCCESS) && id>=0 && id<=256)
      {
        if (strcmpi(szType, "button")==0)
        {
          buttonMap[id] = string(szAction);
        }
        else if (strcmpi(szType, "axis")==0)
        {
          int limit = 0;
          if (pButton->QueryIntAttribute("limit", &limit) == TIXML_SUCCESS)
          {
            if (limit==-1)
              axisMap[-id] = string(szAction);
            else if (limit==1)
              axisMap[id] = string(szAction);
            else if (limit==0)
              axisMap[id|0xFFFF0000] = string(szAction);
            else
            {
              axisMap[id] = string(szAction);
              axisMap[-id] = string(szAction);
              CLog::Log(LOGERROR, "Error in joystick map, invalid limit specified %d for axis %d", limit, id);
            }
          }
          else
          {
            axisMap[id] = string(szAction);
            axisMap[-id] = string(szAction);
          }
        }
        else if (strcmpi(szType, "hat")==0)
        {
          string position;
          if (pButton->QueryValueAttribute("position", &position) == TIXML_SUCCESS)
          {
            uint32_t hatID = id|0xFFF00000;
            if (position.compare("up") == 0)
              hatMap[(JACTIVE_HAT_UP<<16)|hatID] = string(szAction);
            else if (position.compare("down") == 0)
              hatMap[(JACTIVE_HAT_DOWN<<16)|hatID] = string(szAction);
            else if (position.compare("right") == 0)
              hatMap[(JACTIVE_HAT_RIGHT<<16)|hatID] = string(szAction);
            else if (position.compare("left") == 0)
              hatMap[(JACTIVE_HAT_LEFT<<16)|hatID] = string(szAction);
            else
              CLog::Log(LOGERROR, "Error in joystick map, invalid position specified %s for axis %d", position.c_str(), id);
          }
        }
        else
          CLog::Log(LOGERROR, "Error reading joystick map element, unknown button type: %s", szType);
      }
      else if (strcmpi(szType, "altname")==0)
        joynames.push_back(string(szAction));
      else
        CLog::Log(LOGERROR, "Error reading joystick map element, Invalid id: %d", id);
    }
    else
      CLog::Log(LOGERROR, "Error reading joystick map element, skipping");

    pButton = pButton->NextSiblingElement();
  }
  vector<string>::iterator it = joynames.begin();
  while (it!=joynames.end())
  {
    m_joystickButtonMap[*it][windowID] = buttonMap;
    m_joystickAxisMap[*it][windowID] = axisMap;
    m_joystickHatMap[*it][windowID] = hatMap;
//    CLog::Log(LOGDEBUG, "Found Joystick map for window %d using %s", windowID, it->c_str());
    it++;
  }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: openFile

void MainWindow::openFile()
{
    if( !scene->items().isEmpty() )
    {
        QMessageBox::warning(this, tr("Warning"), tr("All unsaved data will be lost!"));
    }

    QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("XML Files (*.xml)"));
    if(fileName != "")
    {
        scene->clearAllItems();
        projectName.clear();
        commands.clear();

        TiXmlDocument doc;
        if(!doc.LoadFile(fileName.toStdString()))
        {
            QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
        }
        TiXmlElement * pProjectElement = doc.FirstChildElement("project");
        TiXmlElement * pNodeElement;
        if( pProjectElement == NULL )
        {
            QMessageBox::critical(this, tr("Error"), tr("Could not parse file: <project> not found"));
            return;
        }
        pNodeElement = pProjectElement->FirstChildElement("name");
        if( pNodeElement != NULL )
        {
            projectName = QString(pNodeElement->GetText());
			ui->projectEdit->setText(projectName);
        }
        std::map<QString, HEESGraphicsItem*> nameIndex;
        // First pass: add components
        for( pNodeElement = pProjectElement->FirstChildElement("comp"); pNodeElement != NULL; pNodeElement = pNodeElement->NextSiblingElement("comp"))
        {
            HEESGraphicsItem * item;
            QString type(pNodeElement->Attribute("type"));
            if( type == QString("cti") )
            {
                item = new HEESGraphicsItem(CTI);
            }
            else if( type == QString("bank"))
            {
                item = new HEESGraphicsItem(BANK);
            }
            else if( type == QString("load") )
            {
                item = new HEESGraphicsItem(LOAD);
            }
            else if( type == QString("source") )
            {
                item = new HEESGraphicsItem(SOURCE);
            }
            else if( type == QString("converter") )
            {
                // will be added in the second pass
                continue;
            }
            else if( type == QString("manager") )
            {
                item = new HEESGraphicsItem(MANAGER);
            }
            else
            {
                continue;
            }
            QString xpos(pNodeElement->Attribute("x_pos"));
            QString ypos(pNodeElement->Attribute("y_pos"));
            if( !xpos.isEmpty() && !ypos.isEmpty() )
            {
                item->setPos( xpos.toDouble(), ypos.toDouble() );
            }
            TiXmlElement * pNameElement = pNodeElement->FirstChildElement("name");
            if( pNameElement != NULL )
            {
                item->name = QString(pNameElement->GetText());
            }
            TiXmlElement * pDerivedElement = pNodeElement->FirstChildElement("derived");
            if( pDerivedElement == NULL )
            {
                QMessageBox::critical(this, tr("Error"), tr("Could not parse file: <derived> not found for component:")+item->name);
                scene->clearAllItems();
                projectName.clear();
                commands.clear();
                return;
            }
            if( type != QString("cti") )
            {
                item->derivedType = QString(pDerivedElement->Attribute("type"));
            }
            TiXmlElement * pElement;
            for( pElement = pDerivedElement->FirstChildElement(); pElement != NULL; pElement = pElement->NextSiblingElement() )
            {
                item->myAttributes()->insertBack( pElement->Value(), pElement->GetText() );
            }
            nameIndex[item->name] = item;
            scene->addItem(item);
        }
        // Second pass: add converters
//.........这里部分代码省略.........
开发者ID:siyuyue,项目名称:simes,代码行数:101,代码来源:mainwindow.cpp


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