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


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

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


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

示例1: RequestRadioTracks

bool CLastFmManager::RequestRadioTracks()
{
  unsigned int start = CTimeUtils::GetTimeMS();
  CStdString url;
  CStdString html;
  url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/xspf.php?sk=%s&discovery=0&desktop=", m_RadioSession);
  {
    CFileCurl http;
    if (!http.Get(url, html))
    {
      m_RadioSession.empty();
      CLog::Log(LOGERROR, "LastFmManager: Connect to Last.fm to request tracks failed.");
      return false;
    }
  }
  //CLog::DebugLog("RequestRadioTracks: %s", html.c_str());

  //parse playlist
  TiXmlDocument xmlDoc;

  xmlDoc.Parse(html);
  if (xmlDoc.Error())
  {
    m_RadioSession.empty();
    CLog::Log(LOGERROR, "LastFmManager: Unable to parse tracklist Error: %s", xmlDoc.ErrorDesc());
    return false;
  }

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement )
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received");
    m_RadioSession.empty();
    return false;
  }

  TiXmlElement* pBodyElement = pRootElement->FirstChildElement("trackList");
  if (!pBodyElement )
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, no tracklist");
    m_RadioSession.empty();
    return false;
  }

  TiXmlElement* pTrackElement = pBodyElement->FirstChildElement("track");

  if (!pTrackElement)
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, empty tracklist");
    m_RadioSession.empty();
    return false;
  }
  while (pTrackElement)
  {
    CFileItemPtr newItem(new CFileItem);

    TiXmlElement* pElement = pTrackElement->FirstChildElement("location");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        CStdString url = child->Value();
        url.Replace("http:", "lastfm:");
        newItem->m_strPath = url;
      }
    }
    pElement = pTrackElement->FirstChildElement("title");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->SetLabel(child->Value());
        newItem->GetMusicInfoTag()->SetTitle(child->Value());
      }
    }
    pElement = pTrackElement->FirstChildElement("creator");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->GetMusicInfoTag()->SetArtist(child->Value());
      }
    }
    pElement = pTrackElement->FirstChildElement("album");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->GetMusicInfoTag()->SetAlbum(child->Value());
      }
    }

    pElement = pTrackElement->FirstChildElement("duration");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
//.........这里部分代码省略.........
开发者ID:mbolhuis,项目名称:xbmc,代码行数:101,代码来源:LastFmManager.cpp

示例2: parseGeometry

bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger* logger)
{
	btAssert(g);
		
	TiXmlElement *shape = g->FirstChildElement();
	if (!shape)
	{
		logger->reportError("Geometry tag contains no child element.");
		return false;
	}
		
	const std::string type_name = shape->ValueTStr().c_str();
	if (type_name == "sphere")
	{
		geom.m_type = URDF_GEOM_SPHERE;
		if (!shape->Attribute("radius"))
		{
			logger->reportError("Sphere shape must have a radius attribute");
			return false;
		} else
		{
			geom.m_sphereRadius = urdfLexicalCast<double>(shape->Attribute("radius"));
		}
	}	
	else if (type_name == "box")
	{
		geom.m_type = URDF_GEOM_BOX;
        if (m_parseSDF)
        {
            TiXmlElement* size = shape->FirstChildElement("size");
            if (0==size)
            {
                logger->reportError("box requires a size child element");
                return false;
            }
            parseVector3(geom.m_boxSize,size->GetText(),logger);
        }
        else
        {
              if (!shape->Attribute("size"))
              {
                  logger->reportError("box requires a size attribute");
                  return false;
              } else
              {
                  parseVector3(geom.m_boxSize,shape->Attribute("size"),logger);
              }
        }
	}
	else if (type_name == "cylinder")
	{
		geom.m_type = URDF_GEOM_CYLINDER;
		if (!shape->Attribute("length") ||
			!shape->Attribute("radius"))
	  {
		  logger->reportError("Cylinder shape must have both length and radius attributes");
		  return false;
	  }
		geom.m_cylinderRadius = urdfLexicalCast<double>(shape->Attribute("radius"));
		geom.m_cylinderLength = urdfLexicalCast<double>(shape->Attribute("length"));
		
	}
	
  else if (type_name == "mesh")
  {
	  geom.m_type = URDF_GEOM_MESH;
      if (m_parseSDF)
      {
          TiXmlElement* scale = shape->FirstChildElement("scale");
          if (0==scale)
          {
              geom.m_meshScale.setValue(1,1,1);
          }
          else
          {
              parseVector3(geom.m_meshScale,scale->GetText(),logger);
          }
          
          TiXmlElement* filename = shape->FirstChildElement("uri");
          geom.m_meshFileName = filename->GetText();
      }
      else
      {
          if (!shape->Attribute("filename")) {
              logger->reportError("Mesh must contain a filename attribute");
              return false;
          }
          
          geom.m_meshFileName = shape->Attribute("filename");
		  geom.m_meshScale.setValue(1,1,1);

		  if (shape->Attribute("scale"))
          {
              if (!parseVector3(geom.m_meshScale,shape->Attribute("scale"),logger))
			  {
				  logger->reportWarning("scale should be a vector3, not single scalar. Workaround activated.\n");
				  std::string scalar_str = shape->Attribute("scale");
				  double scaleFactor = urdfLexicalCast<double>(scalar_str.c_str());
				  if (scaleFactor)
				  {
//.........这里部分代码省略.........
开发者ID:yushuiqiang,项目名称:bullet3,代码行数:101,代码来源:UrdfParser.cpp

示例3: parseLink

bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *config, ErrorLogger* logger)
{
	const char* linkName  = config->Attribute("name");
	if (!linkName)
	{
		logger->reportError("Link with no name");
		return false;
	}
	link.m_name = linkName;
    
    if (m_parseSDF) {


        TiXmlElement* pose = config->FirstChildElement("pose");
        if (0==pose)
        {
            link.m_linkTransformInWorld.setIdentity();
        }
        else
        {
            parseTransform(link.m_linkTransformInWorld, pose,logger,m_parseSDF);
        }
    }

	{
		//optional 'contact' parameters
	 TiXmlElement* ci = config->FirstChildElement("contact");
	  if (ci)
	  {
		TiXmlElement *friction_xml = ci->FirstChildElement("lateral_friction");
		if (friction_xml)
		{
			if (m_parseSDF)
			{
				link.m_contactInfo.m_lateralFriction = urdfLexicalCast<double>(friction_xml->GetText());
			} else
			{
				if (!friction_xml->Attribute("value"))
				{
				  logger->reportError("Link/contact: lateral_friction element must have value attribute");
				  return false;
				}

				link.m_contactInfo.m_lateralFriction = urdfLexicalCast<double>(friction_xml->Attribute("value"));
			}
		}
	  }
	}

  // Inertial (optional)
  TiXmlElement *i = config->FirstChildElement("inertial");
  if (i)
  {
	  if (!parseInertia(link.m_inertia, i,logger))
	  {
		  logger->reportError("Could not parse inertial element for Link:");
		  logger->reportError(link.m_name.c_str());
		  return false;
	  }
  } else
  {
      
      if ((strlen(linkName)==5) && (strncmp(linkName, "world", 5))==0)
      {
          link.m_inertia.m_mass = 0.f;
          link.m_inertia.m_linkLocalFrame.setIdentity();
          link.m_inertia.m_ixx = 0.f;
          link.m_inertia.m_iyy = 0.f;
          link.m_inertia.m_izz= 0.f;
      } else
      {
          
          logger->reportWarning("No inertial data for link, using mass=1, localinertiadiagonal = 1,1,1, identity local inertial frame");
          link.m_inertia.m_mass = 1.f;
          link.m_inertia.m_linkLocalFrame.setIdentity();
          link.m_inertia.m_ixx = 1.f;
          link.m_inertia.m_iyy = 1.f;
          link.m_inertia.m_izz= 1.f;
          logger->reportWarning(link.m_name.c_str());
      }
  }

  // Multiple Visuals (optional)
  for (TiXmlElement* vis_xml = config->FirstChildElement("visual"); vis_xml; vis_xml = vis_xml->NextSiblingElement("visual"))
  {
	  UrdfVisual visual;
	  
	  if (parseVisual(model, visual, vis_xml,logger))
	  {
		  link.m_visualArray.push_back(visual);
	  }
	  else
	  {
		  logger->reportError("Could not parse visual element for Link:");
		  logger->reportError(link.m_name.c_str());
		  return false;
	  }
	  
  }
		
//.........这里部分代码省略.........
开发者ID:yushuiqiang,项目名称:bullet3,代码行数:101,代码来源:UrdfParser.cpp

示例4: initFromXML

void MCVolume::initFromXML(const char *xml_filepath) throw (iom::exception)
{
	#if VM_VERBOSE > 3
	printf("\t\t\t\tin MCVolume::initFromXML(char *xml_filename = %s)\n", xml_filename);
		#endif

	TiXmlDocument xml;
	if(!xml.LoadFile(xml_filepath))
	{
		char errMsg[2000];
		sprintf(errMsg,"in MCVolume::initFromXML(xml_filepath = \"%s\") : unable to load xml", xml_filepath);
		throw iom::exception(errMsg);
	}

	//setting ROOT element (that is the first child, i.e. <TeraStitcher> node)
	TiXmlHandle hRoot(xml.FirstChildElement("TeraStitcher"));

	// 2014-09-10. Alessandro. @ADDED 'volume_format' attribute to <TeraStitcher> XML node
	const char *volformat = hRoot.ToElement()->Attribute("volume_format");
	if(volformat && strcmp(volformat, id.c_str()) != 0)
		throw iom::exception(vm::strprintf("in MCVolume::initFromXML(): unsupported volume_format = \"%s\" (current format is \"%s\")", volformat, id.c_str()).c_str());

	// 2017-04-27. Giulio. ADDED 'input_plugin' attribute to <TeraStitcher> XML node
	const char *inplugin = hRoot.ToElement()->Attribute("input_plugin"); 
	if(inplugin)
		iom::IMIN_PLUGIN = inplugin;
	
	//reading fields
	TiXmlElement * pelem = hRoot.FirstChildElement("stacks_dir").Element();
	// 2014-11-06. Giulio. @ADDED saved reference system into XML file
	if ( (pelem = hRoot.FirstChildElement("ref_sys").Element()) != 0 ) { // skip if not present (for compatibility with previous versions)
		pelem->QueryIntAttribute("ref1", (int *) &reference_system.first);
		pelem->QueryIntAttribute("ref2", (int *) &reference_system.second);
		pelem->QueryIntAttribute("ref3", (int *) &reference_system.third);
	}
	else {
		// 2014-11-06. Giulio. @MOVED in case XML is old
		// 2014-09-09. Alessandro. @FIXED. Added default reference system if volume is imported from xml.
		reference_system = vm::ref_sys(vm::vertical,vm::horizontal,vm::depth);
	}
	pelem = hRoot.FirstChildElement("voxel_dims").Element();
	pelem->QueryFloatAttribute("V", &VXL_V);
	pelem->QueryFloatAttribute("H", &VXL_H);
	pelem->QueryFloatAttribute("D", &VXL_D);
	pelem = hRoot.FirstChildElement("origin").Element();
	pelem->QueryFloatAttribute("V", &ORG_V);
	pelem->QueryFloatAttribute("H", &ORG_H);
	pelem->QueryFloatAttribute("D", &ORG_D);

	//// 2016-10-27. Giulio. New field in the xml import file to select a subimage (resolution, timepoint, series_no)
	//if ( (pelem = hRoot.FirstChildElement("subimage").Element()) != 0 ) { // skip if not present (for compatibility with previous versions)
	//	int value;
	//	std::stringstream str;
	//	if ( pelem->QueryIntAttribute("resolution", &value) == TIXML_SUCCESS ) {
	//		if ( value ) {// additional parameters are not needed if resolution is zero
	//			additionalIOPluginParams = true;
	//			str << value;
	//			active_res = str.str();
	//		}
	//	}
	//	if ( pelem->QueryIntAttribute("timepoint", &value) == TIXML_SUCCESS ) {
	//		if ( value ) { // additional parameters are not needed if resolution is zero
	//			additionalIOPluginParams = true;
	//			str.str("");
	//			str << value;
	//			active_tp = str.str();
	//		}
	//	}
	//	const char *series_no_flag=pelem->Attribute("series_no");
	//	if ( series_no_flag ) {
	//		if ( strcmp(series_no_flag,"true") == 0 ) 
	//			series_no = additionalIOPluginParams = true;
	//	}
	//}

	pelem = hRoot.FirstChildElement("mechanical_displacements").Element();
	pelem->QueryFloatAttribute("V", &MEC_V);
	pelem->QueryFloatAttribute("H", &MEC_H);
	pelem = hRoot.FirstChildElement("dimensions").Element();
	int nrows, ncols, nslices;
	pelem->QueryIntAttribute("stack_rows", &nrows);
	pelem->QueryIntAttribute("stack_columns", &ncols);
	N_ROWS = nrows;
	N_COLS = ncols;
	pelem->QueryIntAttribute("stack_slices", &nslices);
	N_SLICES = nslices;

	pelem = hRoot.FirstChildElement("SUBVOLUMES").Element();
	pelem->QueryIntAttribute("N_SUBVOLUMES", &N_SUBVOLS);
	pelem->QueryIntAttribute("ENABLED_SUBVOLUME", &enabledSV);

	const char *strvalue = pelem->Attribute("ALIGNED");
	if ( strcmp(strvalue,"true") == 0 )
		aligned = true;
	else
		aligned = false;

	subvolumes = new vm::VirtualVolume *[N_SUBVOLS];
	sv_format = new string[N_SUBVOLS];
	xml_file_names = new string[N_SUBVOLS];
//.........这里部分代码省略.........
开发者ID:abria,项目名称:TeraStitcher,代码行数:101,代码来源:vmMCVolume.cpp

示例5: ReadDBFromFile

void MainWindow::ReadDBFromFile()
{
    //读入数据
    QString filename = QFileDialog::getOpenFileName(this,"open database","","database (db.xml)");
    
    string filenameStr = filename.toStdString();
    
    if("" == filenameStr) return;

    cout<<"filename = "<<filenameStr<<endl;

    TiXmlDocument doc;
    
    if(!doc.LoadFile(filenameStr))
    {
        ShowError("读取指定数据库失败。");
        return;
    }
    
    
    //清空已有的数据
    dataBase.clear();
    Reset();
    
    TiXmlElement* firstElem = doc.FirstChildElement()->FirstChildElement();
    while (NULL!=firstElem) {
        
        TiXmlElement* pathElem = firstElem->FirstChildElement();
        TiXmlElement* segPathElem = pathElem->NextSiblingElement();
        TiXmlElement* phaseElem = segPathElem->NextSiblingElement();
        TiXmlElement* qualityElem = phaseElem->NextSiblingElement();
        TiXmlElement* tumorQualityElem = qualityElem->NextSiblingElement();
        TiXmlElement* layerElem = tumorQualityElem->NextSiblingElement();
        TiXmlElement* isSegErrorElem = layerElem->NextSiblingElement();
        TiXmlElement* descriptionElem = isSegErrorElem->NextSiblingElement();
        
        //cout<<"description = "<<(string)descriptionElem->Value()<<endl;
        
        dbAtom newAtom;
        newAtom.path = pathElem->GetText();
        newAtom.segPath = segPathElem->GetText();
        newAtom.phase = atoi(phaseElem->GetText());
        newAtom.quality = atoi(qualityElem->GetText());
        newAtom.tumorQuality = atoi(tumorQualityElem->GetText());
        
        int currLayer = atoi(layerElem->GetText());
        
        //newAtom.layer = (currLayer>100)+(currLayer>200)+(currLayer>400);
        
        newAtom.layer = currLayer;
        
        if(0 == strcmp("TRUE", isSegErrorElem->GetText()))
        {
            newAtom.isError = 0;//有错是0,没错是1
        }else{
            newAtom.isError = 1;
        }
        
        if(NULL != descriptionElem->FirstChild())
            newAtom.description = descriptionElem->GetText();
        else
            newAtom.description = "无描述";
        
        //newAtom.PrintSelf(std::cout);
        
        this->dataBase.push_back(newAtom);
        
        firstElem = firstElem->NextSiblingElement();
    }
    
    
    UpdateFilters(0);
    //SetupDB();
}
开发者ID:yzxyzh,项目名称:dbAccessor,代码行数:74,代码来源:mainwindow.cpp

示例6: deserialize

void CVar::deserialize(TiXmlNode* rootNode)
{
    int oldFlags = m_flags;
    unlock();
    if (rootNode == NULL)
        return;
    TiXmlElement* cvarNode = NULL;
    if (type() != Bind)
        cvarNode = rootNode->FirstChildElement("CVar");
    else
        cvarNode = rootNode->FirstChildElement("Bind");

    while (cvarNode != nullptr)
    {
        if (type() != Bind)
        {
            if (!std::string(cvarNode->Attribute("name")).compare(name()))
                break;

            cvarNode = cvarNode->NextSiblingElement("CVar");
        }
        else
        {
            if (!std::string(cvarNode->Attribute("action")).compare(name()))
                break;

            cvarNode = cvarNode->NextSiblingElement("Bind");
        }
    }

    if (!cvarNode)
        return;

    switch(type())
    {
        case Bind:
        {
            std::string tmp;
            if (cvarNode->Attribute("key"))
            {
                tmp = cvarNode->Attribute("key");
                Athena::utility::tolower(tmp);
                for (int k = 0; k < (int)Key::KEYCOUNT; k++)
                {
                    std::string keyName = enumToStdString((Key)k);
                    Athena::utility::tolower(keyName);
                    if (!keyName.compare(tmp))
                        m_binding.KeyVal = (Key)k;
                }
            }

            if (cvarNode->Attribute("mouseButton"))
            {
                tmp = cvarNode->Attribute("mouseButton");
                for (int m = 0; m < (int)MouseButton::COUNT; m++)
                {
                    std::string name = enumToStdString((MouseButton)m);
                    Athena::utility::tolower(name);
                    if (!name.compare(tmp))
                        m_binding.MouseButtonVal = (MouseButton)m;
                }
            }

            for (int j = 0; j < IJoystickManager::MaxJoysticks; j++)
            {
                std::stringstream ss;
                ss << j;
                TiXmlElement* joyNode = cvarNode->FirstChildElement("Joy");
                while (joyNode != NULL)
                {
                    if (!std::string(joyNode->Attribute("id")).compare(ss.str()))
                        break;
                    joyNode = joyNode->NextSiblingElement("Joy");
                }

                if (!joyNode)
                    continue;

                bool set = false;
                if (joyNode->Attribute("button"))
                {
                    int button;
                    joyNode->Attribute("button", &button);
                    m_binding.Joysticks[j].Button = button;
                    set = true;
                }
                if (joyNode->Attribute("axis"))
                {
                    int axis;
                    joyNode->Attribute("axis", &axis);
                    m_binding.Joysticks[j].Axis = axis;
                    set = true;
                }

                if (joyNode->Attribute("isAxisNegative"))
                {
                    tmp = joyNode->Attribute("isAxisNegative");
                    m_binding.Joysticks[j].NegativeAxis = Athena::utility::parseBool(tmp);
                    set = true;
                }
//.........这里部分代码省略.........
开发者ID:Antidote,项目名称:Orion,代码行数:101,代码来源:CVar.cpp

示例7: ParseSettingsFile

void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
{
  CXBMCTinyXML advancedXML;
  if (!CFile::Exists(file))
  {
    CLog::Log(LOGNOTICE, "No settings file to load (%s)", file.c_str());
    return;
  }

  if (!advancedXML.LoadFile(file))
  {
    CLog::Log(LOGERROR, "Error loading %s, Line %d\n%s", file.c_str(), advancedXML.ErrorRow(), advancedXML.ErrorDesc());
    return;
  }

  TiXmlElement *pRootElement = advancedXML.RootElement();
  if (!pRootElement || strcmpi(pRootElement->Value(),"advancedsettings") != 0)
  {
    CLog::Log(LOGERROR, "Error loading %s, no <advancedsettings> node", file.c_str());
    return;
  }

  // succeeded - tell the user it worked
  CLog::Log(LOGNOTICE, "Loaded settings file from %s", file.c_str());

  // Dump contents of AS.xml to debug log
  TiXmlPrinter printer;
  printer.SetLineBreak("\n");
  printer.SetIndent("  ");
  advancedXML.Accept(&printer);
  CLog::Log(LOGNOTICE, "Contents of %s are...\n%s", file.c_str(), printer.CStr());

  TiXmlElement *pElement = pRootElement->FirstChildElement("audio");
  if (pElement)
  {
    XMLUtils::GetFloat(pElement, "ac3downmixgain", m_ac3Gain, -96.0f, 96.0f);
    XMLUtils::GetInt(pElement, "headroom", m_audioHeadRoom, 0, 12);
    XMLUtils::GetString(pElement, "defaultplayer", m_audioDefaultPlayer);
    // 101 on purpose - can be used to never automark as watched
    XMLUtils::GetFloat(pElement, "playcountminimumpercent", m_audioPlayCountMinimumPercent, 0.0f, 101.0f);

    XMLUtils::GetBoolean(pElement, "usetimeseeking", m_musicUseTimeSeeking);
    XMLUtils::GetInt(pElement, "timeseekforward", m_musicTimeSeekForward, 0, 6000);
    XMLUtils::GetInt(pElement, "timeseekbackward", m_musicTimeSeekBackward, -6000, 0);
    XMLUtils::GetInt(pElement, "timeseekforwardbig", m_musicTimeSeekForwardBig, 0, 6000);
    XMLUtils::GetInt(pElement, "timeseekbackwardbig", m_musicTimeSeekBackwardBig, -6000, 0);

    XMLUtils::GetInt(pElement, "percentseekforward", m_musicPercentSeekForward, 0, 100);
    XMLUtils::GetInt(pElement, "percentseekbackward", m_musicPercentSeekBackward, -100, 0);
    XMLUtils::GetInt(pElement, "percentseekforwardbig", m_musicPercentSeekForwardBig, 0, 100);
    XMLUtils::GetInt(pElement, "percentseekbackwardbig", m_musicPercentSeekBackwardBig, -100, 0);

    XMLUtils::GetInt(pElement, "resample", m_audioResample, 0, 192000);
    XMLUtils::GetBoolean(pElement, "allowtranscode44100", m_allowTranscode44100);
    XMLUtils::GetBoolean(pElement, "forceDirectSound", m_audioForceDirectSound);
    XMLUtils::GetBoolean(pElement, "audiophile", m_audioAudiophile);
    XMLUtils::GetBoolean(pElement, "allchannelstereo", m_allChannelStereo);
    XMLUtils::GetBoolean(pElement, "streamsilence", m_streamSilence);
    XMLUtils::GetString(pElement, "transcodeto", m_audioTranscodeTo);
    XMLUtils::GetInt(pElement, "audiosinkbufferdurationmsec", m_audioSinkBufferDurationMsec);

    TiXmlElement* pAudioExcludes = pElement->FirstChildElement("excludefromlisting");
    if (pAudioExcludes)
      GetCustomRegexps(pAudioExcludes, m_audioExcludeFromListingRegExps);

    pAudioExcludes = pElement->FirstChildElement("excludefromscan");
    if (pAudioExcludes)
      GetCustomRegexps(pAudioExcludes, m_audioExcludeFromScanRegExps);

    XMLUtils::GetString(pElement, "audiohost", m_audioHost);
    XMLUtils::GetBoolean(pElement, "applydrc", m_audioApplyDrc);
    XMLUtils::GetBoolean(pElement, "dvdplayerignoredtsinwav", m_dvdplayerIgnoreDTSinWAV);

    XMLUtils::GetFloat(pElement, "limiterhold", m_limiterHold, 0.0f, 100.0f);
    XMLUtils::GetFloat(pElement, "limiterrelease", m_limiterRelease, 0.001f, 100.0f);
  }

  pElement = pRootElement->FirstChildElement("omx");
  if (pElement)
  {
    XMLUtils::GetBoolean(pElement, "omxhwaudiodecode", m_omxHWAudioDecode);
    XMLUtils::GetBoolean(pElement, "omxdecodestartwithvalidframe", m_omxDecodeStartWithValidFrame);
  }

  pElement = pRootElement->FirstChildElement("karaoke");
  if (pElement)
  {
    XMLUtils::GetFloat(pElement, "syncdelaycdg", m_karaokeSyncDelayCDG, -3.0f, 3.0f); // keep the old name for comp
    XMLUtils::GetFloat(pElement, "syncdelaylrc", m_karaokeSyncDelayLRC, -3.0f, 3.0f);
    XMLUtils::GetBoolean(pElement, "alwaysreplacegenre", m_karaokeChangeGenreForKaraokeSongs );
    XMLUtils::GetBoolean(pElement, "storedelay", m_karaokeKeepDelay );
    XMLUtils::GetInt(pElement, "autoassignstartfrom", m_karaokeStartIndex, 1, 2000000000);
    XMLUtils::GetBoolean(pElement, "nocdgbackground", m_karaokeAlwaysEmptyOnCdgs );
    XMLUtils::GetBoolean(pElement, "lookupsongbackground", m_karaokeUseSongSpecificBackground );

    TiXmlElement* pKaraokeBackground = pElement->FirstChildElement("defaultbackground");
    if (pKaraokeBackground)
    {
      const char* attr = pKaraokeBackground->Attribute("type");
      if ( attr )
//.........这里部分代码省略.........
开发者ID:fldc,项目名称:spotyxbmc2,代码行数:101,代码来源:AdvancedSettings.cpp

示例8: LoadXmlByFileName

int CDBServiceConfig::LoadXmlByFileName(const string& sFileName)
{
	SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());

	TiXmlDocument m_xmlDoc;
    TiXmlElement *pService;
	
	if(!m_xmlDoc.LoadFile(sFileName.c_str()))
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Load File Error,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1;
	}
		
	if((pService=m_xmlDoc.RootElement())==NULL)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,No RootElement,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1;
	}

	SServiceDesc serviceDesc;
	
	char szName[64] = {0};
	int nRet = pService->QueryValueAttribute("name", &szName);
	if(nRet != TIXML_SUCCESS)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,No Service Name,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1;
	}
	serviceDesc.sServiceName = szName;
	boost::to_lower(serviceDesc.sServiceName);
	
	serviceDesc.bReadOnly = false;
	
	char szReadOnly[64]={0};
	nRet = pService->QueryValueAttribute("queryonly", &szReadOnly);
	if(nRet == TIXML_SUCCESS)
	{
		if (strncmp(szReadOnly,"true",4)==0)
		{
			serviceDesc.bReadOnly = true;
		}		
	}
	
	int nServiceId = 0;
	nRet = pService->QueryIntAttribute("id", (int *)&nServiceId);
	if(nRet != TIXML_SUCCESS)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Get ServiceId Error\n",__FUNCTION__);
    	return -1;
	}
	serviceDesc.nServiceId = nServiceId;

	/* get types */
	TiXmlElement * pConfigType = NULL;
	if((pConfigType=pService->FirstChildElement("type"))==NULL)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,No Type,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1; 
	}
	else
	{	
		SServiceType serviceType;
		if(LoadServiceTypes(pConfigType,serviceType)<0)
		{
			return -1;
		}

		serviceDesc.mapServiceType.insert(make_pair(serviceType.sTypeName,serviceType));
	}
	while((pConfigType=pConfigType->NextSiblingElement("type"))!=NULL)
	{
		SServiceType serviceType;
		if(LoadServiceTypes(pConfigType,serviceType)<0)
		{
			return -1;
		}
		serviceDesc.mapServiceType.insert(make_pair(serviceType.sTypeName,serviceType));
	}

	PostProcessServiceTypes(serviceDesc.mapServiceType);

	//get message attribute
	TiXmlElement * pMsgAttri = NULL;
	if((pMsgAttri=pService->FirstChildElement("message"))==NULL)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,No Message,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1;
	}
	else
	{
		SMsgAttri sMsgAttri;
		if(LoadServiceMessage(pMsgAttri,sMsgAttri)<0)
		{
			return -1;
		}
		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s,OperType=[%d]\n",__FUNCTION__,sMsgAttri.eOperType);
		serviceDesc.mapMsgAttri.insert(make_pair(sMsgAttri.nMsgId,sMsgAttri));
	}

	while((pMsgAttri=pMsgAttri->NextSiblingElement("message"))!=NULL)
//.........这里部分代码省略.........
开发者ID:victorzjl,项目名称:BPE,代码行数:101,代码来源:dbserviceconfig.cpp

示例9: parseResourceFile

bool ResourceManager::parseResourceFile(const std::string &fileName, unsigned char *key)
{
	// if we've already loaded the fonts:
	if (find(mParsedResourceFiles.begin(),mParsedResourceFiles.end(),fileName) != mParsedResourceFiles.end())
	{
		// ignore this call:
		return true;
	}

	TiXmlDocument doc;

	if (key==NULL)
	{
		bool success = doc.LoadFile(fileName.c_str());
		if (!success)
		{
			return false;
		}
	}
	else
	{
		// adjust the filename to point to the encrypted version:
		std::string encFileName = fileName;
		if (key!=NULL)
		{
			encFileName.append(".bin");
		}

		// load and decrypt the resource file
		char *data;
		int dataSize;
		bool success = Boy::loadDecrypt(key, encFileName.c_str(), &data, &dataSize);
		if (!success)
		{
			return false;
		}

		// parse it:
		doc.Parse(data);
		mParsedResourceFiles.push_back(fileName);

		// deallocate the mem:
		delete[] data;
		data = NULL;
	}
	
	TiXmlElement *root = doc.RootElement();

	for (TiXmlElement *e = root->FirstChildElement() ; e!=NULL ; e = e->NextSiblingElement())
	{
		if (Boy::Environment::instance()->stricmp(e->Value(),"resources")==0)
		{
			parseResourceGroup(e);
		}
		else
		{
			assert(false);
		}
	}

	doc.Clear();

	return true;
}
开发者ID:kmiron,项目名称:BattleBoy,代码行数:64,代码来源:ResourceManager.cpp

示例10: LoadXMLDBConnConfig

int CDBServiceConfig::LoadXMLDBConnConfig(const string& sFileName)
{
	SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());

	TiXmlDocument m_xmlDoc;
    TiXmlElement *pRoot;
	
	if(!m_xmlDoc.LoadFile(sFileName.c_str()))
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Load File Error,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1;
	}
		
	if((pRoot=m_xmlDoc.RootElement())==NULL)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Have No RootElement,FileName=[%s]\n",__FUNCTION__,sFileName.c_str());
		return -1;
	}
	m_nBPEThreadNum=8;
	TiXmlElement* pBPEThreadNum;
	if((pBPEThreadNum=pRoot->FirstChildElement("ThreadNum"))!=NULL)
	{
		string sTmp = pBPEThreadNum->GetText();
		m_nBPEThreadNum = atoi(sTmp.c_str());
	}
	else
	{
		SC_XLOG(XLOG_WARNING, "CDBServiceConfig::%s,No BPEThreadNum Use Default[8]\n",__FUNCTION__);
	}
	if (m_nBPEThreadNum<=0)
	{
		m_nBPEThreadNum=8;
	}	
	m_nDBThreadNum = 8;
	TiXmlElement* pDBThreadNum;
	if((pDBThreadNum=pRoot->FirstChildElement("dbthreadnum"))!=NULL)
	{
		string sTmp = pDBThreadNum->GetText();
		m_nDBThreadNum = atoi(sTmp.c_str());
	}
	else
	{
		SC_XLOG(XLOG_WARNING, "CDBServiceConfig::%s,No DBThreadNum Use Default[8]\n",__FUNCTION__);
	}
		
	m_nDBBigQueueNum = 500000; //50万
	TiXmlElement* pDBBigQueueNum;
	if((pDBBigQueueNum=pRoot->FirstChildElement("dbbigqueuenum"))!=NULL)
	{
		string sTmp = pDBBigQueueNum->GetText();
		m_nDBBigQueueNum = atoi(sTmp.c_str());
	}
	else
	{
		SC_XLOG(XLOG_WARNING, "CDBServiceConfig::%s,No DBBigQueueNum Use Default[5000000]\n",__FUNCTION__);
	}
	
	m_nDBDelayQueueNum = 3000; //3000
	TiXmlElement* pDBDelayQueueNum;
	if((pDBDelayQueueNum=pRoot->FirstChildElement("dbdelayqueuenum"))!=NULL)
	{
		string sTmp = pDBDelayQueueNum->GetText();
		m_nDBDelayQueueNum = atoi(sTmp.c_str());
	}
	else
	{
		SC_XLOG(XLOG_WARNING, "CDBServiceConfig::%s,No DBDelayQueueNum Use Default[3000]\n",__FUNCTION__);
	}
	
	TiXmlElement* pDBSosList;
	if((pDBSosList=pRoot->FirstChildElement("dbsoslist"))==NULL)
	{
		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s no dbsoslist\n",__FUNCTION__);
		return -1; 
	}
	else
	{	
		SConnDesc connDesc;
		if(LoadDBConnDesc(pDBSosList,connDesc)<0)
		{
			return -1;
		}
		vecDBConnConfig.push_back(connDesc);
	}
	while((pDBSosList=pDBSosList->NextSiblingElement("dbsoslist"))!=NULL)
	{
		SConnDesc connDesc;
		if(LoadDBConnDesc(pDBSosList,connDesc)<0)
		{
			return -1;
		}
		vecDBConnConfig.push_back(connDesc);
	}
	return 0;

}
开发者ID:victorzjl,项目名称:BPE,代码行数:96,代码来源:dbserviceconfig.cpp

示例11: SubLoadDBConnDesc

int CDBServiceConfig::SubLoadDBConnDesc(TiXmlElement* pDBDesc,SConnItem& connItem)
{
	SC_XLOG(XLOG_DEBUG, "CDBServiceConfigX::%s\n",__FUNCTION__);

	try{
	int nRet = 0;
	int nConnNum = 0;
	nRet = pDBDesc->QueryIntAttribute("conns", (int *)&nConnNum);
	if(nRet != TIXML_SUCCESS)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Get Master ConnNum Error\n",__FUNCTION__);
	}
	else
	{
		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s nConnNum[%d]\n",__FUNCTION__,nConnNum);
	}
	connItem.nConnNum = nConnNum;

	int nDBFactor = 1;
	nRet = pDBDesc->QueryIntAttribute("dbfactor", (int *)&nDBFactor);
	if(nRet == TIXML_SUCCESS)
	{
		connItem.nDBFactor = nDBFactor;
		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s nDBFactor[%d]\n",__FUNCTION__,nDBFactor);
	}

	int nTBFactor = 1;
	nRet = pDBDesc->QueryIntAttribute("tbfactor", (int *)&nTBFactor);
	if(nRet == TIXML_SUCCESS)
	{
		connItem.nTBFactor = nTBFactor;
		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s nTBFactor[%d]\n",__FUNCTION__,nTBFactor);
	}

	char szFactorType[64] = {0};
	nRet = pDBDesc->QueryValueAttribute("factortype", &szFactorType);
	if(nRet == TIXML_SUCCESS)
	{
		connItem.sFactorType= szFactorType;
		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s szFactorType[%s]\n",__FUNCTION__,szFactorType);
	}

	TiXmlElement* pDivideConns;
	if((pDivideConns=pDBDesc->FirstChildElement("divideconns"))!=NULL)
	{
		TiXmlElement* pConnStr;
		if((pConnStr=pDivideConns->FirstChildElement("conn"))!=NULL)
		{
			string strConn = pConnStr->GetText();
			string out1,out2;	
			out1= strConn;
			if (DecodePassword(out1,out2)<0)
			{
				SC_XLOG(XLOG_ERROR, "divide connectstr[%s] config error\n",strConn.c_str());
				return -1;
			}
			strConn = out2;
			//SC_XLOG(XLOG_DEBUG, ".............out2[%s]\n",out2.c_str());
			connItem.vecDivideConn.push_back(strConn);
		}

		while((pConnStr=pConnStr->NextSiblingElement("conn"))!=NULL)
		{
			string strConn = pConnStr->GetText();
			string out1,out2;	
			out1= strConn;
			if (DecodePassword(out1,out2)<0)
			{
				SC_XLOG(XLOG_ERROR, "divide connectstr[%s] config error\n",strConn.c_str());
				return -1;
			}
			strConn = out2;
			//SC_XLOG(XLOG_DEBUG, ".............out2[%s]\n",out2.c_str());
			connItem.vecDivideConn.push_back(strConn);
		}

	}
	
	SC_XLOG(XLOG_DEBUG, "CDBServiceConfigY::%s\n",__FUNCTION__);
	TiXmlElement* pDefaultConn;
	if((pDefaultConn=pDBDesc->FirstChildElement("defaultconn"))!=NULL)
	{
		string strConn = pDefaultConn->GetText();
		
		string out1,out2;	
		out1= strConn;
		if (DecodePassword(out1,out2)<0)
		{
			SC_XLOG(XLOG_ERROR, "default contstr[%s] config error\n",strConn.c_str());
			return -1;
		}
		strConn = out2;
		//SC_XLOG(XLOG_DEBUG, ".............out2[%s]\n",out2.c_str());
		connItem.sDefaultConn = strConn;
	}
	}catch(std::exception const &e)
	{
		SC_XLOG(XLOG_ERROR, "Load SubConnect Exception e:%s\n",e.what());
		SC_XLOG(XLOG_ERROR, "Load SubConnect FAILED !!!!!!!!!!!!!\n");
		return -1;
//.........这里部分代码省略.........
开发者ID:victorzjl,项目名称:BPE,代码行数:101,代码来源:dbserviceconfig.cpp

示例12: LoadServiceMessage

int CDBServiceConfig::LoadServiceMessage(TiXmlElement* pMessage, SMsgAttri& sMsgAtrri)
{
	SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s Start\n",__FUNCTION__);
	char szName[64] = {0};
	int nRet = pMessage->QueryValueAttribute("name", &szName);
	if(nRet != TIXML_SUCCESS)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Get Message Name Error\n",__FUNCTION__);
		return -1;
	}
	sMsgAtrri.sMsgName = szName;
	boost::to_lower(sMsgAtrri.sMsgName);

	//
	int nMsgId;
	nRet = pMessage->QueryIntAttribute("id", (int *)&nMsgId);
	if(nRet != TIXML_SUCCESS)
	{
		SC_XLOG(XLOG_ERROR, "CDBServiceConfig::%s,Get MessageID Error,MsgName=[%s] Error\n",__FUNCTION__,szName);
    	return -1;
	}
	sMsgAtrri.nMsgId = nMsgId;
	
	char szMultiArray[64] = {0};
	nRet = pMessage->QueryValueAttribute("multiarrayasone", &szMultiArray);
	if(nRet == TIXML_SUCCESS)
	{
		if (strcmp(szMultiArray,"true")==0)
		{
			sMsgAtrri.bMultArray = true;
		}
	}
	

	/* procedure */
	TiXmlElement *pProcedure = NULL;
	if( (pProcedure= pMessage->FirstChildElement("procedure")) != NULL)
	{
		SProcedure proc;
		proc.sProcName = pProcedure->GetText();
		sMsgAtrri.exeSPs.push_back(proc);

		SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s,procedure=[%s]\n",__FUNCTION__,proc.sProcName.c_str());
		
		while((pProcedure=pProcedure->NextSiblingElement("procedure"))!=NULL)
		{
			SProcedure proc;
			string strProcedure = pProcedure->GetText();
			MakeSQLToLower(strProcedure);
			proc.sProcName = strProcedure;
			sMsgAtrri.exeSPs.push_back(proc);
			SC_XLOG(XLOG_DEBUG, "CDBServiceConfig::%s,procedure=[%s]\n",__FUNCTION__,proc.sProcName.c_str());
		}

		sMsgAtrri.eOperType = DBO_WRITE;
	}
	

	/* simple sql and compose sql */
	TiXmlElement *pExeSQLs = NULL;
	if((pExeSQLs=pMessage->FirstChildElement("sql")) != NULL)
	{

		LoadSQLs(pExeSQLs,sMsgAtrri);
		while((pExeSQLs=pExeSQLs->NextSiblingElement("sql"))!=NULL)
		{
			LoadSQLs(pExeSQLs,sMsgAtrri);
		}
	}

	/* request param */
	TiXmlElement * pRequestParams = NULL;
	if((pRequestParams=pMessage->FirstChildElement("requestparameter"))!=NULL)
	{
		TiXmlElement * pField = NULL;
		if((pField=pRequestParams->FirstChildElement("field"))!=NULL)
		{
			SParam param;
			if(LoadRequestParam(pField,param)<0)
			{
				return -1;
			}
			sMsgAtrri.requestParams.push_back(param);
			
			while((pField=pField->NextSiblingElement("field"))!=NULL)
			{
				SParam param;
				if(LoadRequestParam(pField,param)<0)
				{
					return -1;
				}
				sMsgAtrri.requestParams.push_back(param);
			}
		}
	}


	/* respone */
	TiXmlElement * pResponeParams = NULL;
	if((pResponeParams=pMessage->FirstChildElement("responseparameter"))!=NULL)
//.........这里部分代码省略.........
开发者ID:victorzjl,项目名称:BPE,代码行数:101,代码来源:dbserviceconfig.cpp

示例13: load

void AppBrushes::load(const std::string& filename)
{
  XmlDocumentRef doc = app::open_xml(filename);
  TiXmlHandle handle(doc.get());
  TiXmlElement* brushElem = handle
    .FirstChild("brushes")
    .FirstChild("brush").ToElement();

  while (brushElem) {
    // flags
    int flags = 0;
    BrushRef brush;
    app::Color fgColor;
    app::Color bgColor;
    tools::InkType inkType = tools::InkType::DEFAULT;
    int inkOpacity = 255;
    Shade shade;
    bool pixelPerfect = false;

    // Brush
    const char* type = brushElem->Attribute("type");
    const char* size = brushElem->Attribute("size");
    const char* angle = brushElem->Attribute("angle");
    if (type || size || angle) {
      if (type) flags |= int(BrushSlot::Flags::BrushType);
      if (size) flags |= int(BrushSlot::Flags::BrushSize);
      if (angle) flags |= int(BrushSlot::Flags::BrushAngle);
      brush.reset(
        new Brush(
          string_id_to_brush_type(type),
          (size ? base::convert_to<int>(std::string(size)): 1),
          (angle ? base::convert_to<int>(std::string(angle)): 0)));
    }

    // Brush image
    if (TiXmlElement* imageElem = brushElem->FirstChildElement("image")) {
      ImageRef image = load_xml_image(imageElem);
      if (image) {
        if (!brush)
          brush.reset(new Brush());
        brush->setImage(image.get());
      }
    }

    // Colors
    if (TiXmlElement* fgcolorElem = brushElem->FirstChildElement("fgcolor")) {
      if (auto value = fgcolorElem->Attribute("value")) {
        fgColor = app::Color::fromString(value);
        flags |= int(BrushSlot::Flags::FgColor);
      }
    }

    if (TiXmlElement* bgcolorElem = brushElem->FirstChildElement("bgcolor")) {
      if (auto value = bgcolorElem->Attribute("value")) {
        bgColor = app::Color::fromString(value);
        flags |= int(BrushSlot::Flags::BgColor);
      }
    }

    // Ink
    if (TiXmlElement* inkTypeElem = brushElem->FirstChildElement("inktype")) {
      if (auto value = inkTypeElem->Attribute("value")) {
        inkType = app::tools::string_id_to_ink_type(value);
        flags |= int(BrushSlot::Flags::InkType);
      }
    }

    if (TiXmlElement* inkOpacityElem = brushElem->FirstChildElement("inkopacity")) {
      if (auto value = inkOpacityElem->Attribute("value")) {
        inkOpacity = base::convert_to<int>(std::string(value));
        flags |= int(BrushSlot::Flags::InkOpacity);
      }
    }

    // Shade
    if (TiXmlElement* shadeElem = brushElem->FirstChildElement("shade")) {
      if (auto value = shadeElem->Attribute("value")) {
        shade = shade_from_string(value);
        flags |= int(BrushSlot::Flags::Shade);
      }
    }

    // Pixel-perfect
    if (TiXmlElement* pixelPerfectElem = brushElem->FirstChildElement("pixelperfect")) {
      pixelPerfect = bool_attr_is_true(pixelPerfectElem, "value");
      flags |= int(BrushSlot::Flags::PixelPerfect);
    }

    if (flags != 0)
      flags |= int(BrushSlot::Flags::Locked);

    BrushSlot brushSlot(BrushSlot::Flags(flags),
                        brush, fgColor, bgColor,
                        inkType, inkOpacity, shade,
                        pixelPerfect);
    m_slots.push_back(brushSlot);

    brushElem = brushElem->NextSiblingElement();
  }
}
开发者ID:sliekasirdis79,项目名称:aseprite,代码行数:100,代码来源:app_brushes.cpp

示例14: LoadXML

	RenderContext* RenderContext::LoadXML(const char* xmlFileNamePtr, const char* indentifier)
	{
		TiXmlDocument doc((ContentManager::theContentPath + xmlFileNamePtr).c_str());

		if(!doc.LoadFile())
		{
			InternalOutput::GetReference().Error(
				"Failed to load %s, does the file exist?\n", xmlFileNamePtr);
			return 0;
		}

		TiXmlHandle hDoc(&doc);
		TiXmlElement* elementPtr;
		TiXmlHandle hRoot(0);

		elementPtr = hDoc.FirstChildElement().Element();
		if( !elementPtr )
		{
			InternalOutput::GetReference().Error(
				"Failed to load %s, is the file empty?\n", xmlFileNamePtr);
			return 0;
		}

		std::string rootName = elementPtr->Value();

		if( strcmp(rootName.c_str(), "GDRenderContext") != 0 )
		{
			InternalOutput::GetReference().Error(
				"Failed to load %s, missing a GDRenderContext element\n", 
				xmlFileNamePtr);
			return 0;
		}

		TiXmlElement* pMaterialElement = elementPtr->FirstChildElement("Material");

		std::string materialString;
		std::string shaderEffectString;
		std::string techniqueString;
		std::string vertexFormatString;
		std::string castShadowString;
		std::string renderStyleString;

		if( pMaterialElement != 0 )
		{
			if(pMaterialElement->GetText() != 0)
				materialString = pMaterialElement->GetText();
		}

		// Error check for old Effect based shader usage
		TiXmlElement* pEffectElement = elementPtr->FirstChildElement("Effect");
		if(nullptr == pEffectElement )
		{
			InternalOutput::GetReference().Error(
				"Failed to load %s, missing Effect element", xmlFileNamePtr);
			return 0;
		}
		shaderEffectString = pEffectElement->GetText();

		TiXmlElement* pTechniqueElement = elementPtr->FirstChildElement("Technique");

		if( pTechniqueElement != 0 )
		{
			if( pTechniqueElement->GetText() != 0 )
				techniqueString = pTechniqueElement->GetText();
		}

		if( techniqueString.length() == 0 )
			techniqueString = "Basic";

		TiXmlElement* pVertexFormatElement = elementPtr->FirstChildElement("VertexFormat");

		if( pVertexFormatElement == 0 )
		{
			InternalOutput::GetReference().Error(
				"Failed to load %s, missing a VertexFormat element\n", xmlFileNamePtr);
			return 0;
		}

		vertexFormatString = pVertexFormatElement->GetText();

		bool isDeferredPointLightContext = false;
		TiXmlElement* pPointLightTechnique = elementPtr->FirstChildElement("PointLightTechnique");
		if( pPointLightTechnique != 0 )
		{
			if( pPointLightTechnique->GetText() != 0 )
			{
				std::string technique = pPointLightTechnique->GetText();
				if( technique.length() != 0 )
					isDeferredPointLightContext = true;
			}

		}	
		bool isDeferredDirLightContext = false;
		TiXmlElement* pDirLightTechnique = elementPtr->FirstChildElement("DirLightTechnique");
		if( pDirLightTechnique != 0 )
		{
			if( pDirLightTechnique->GetText() != 0 )
			{
				std::string technique = pDirLightTechnique->GetText();
				if( technique.length() != 0 )
//.........这里部分代码省略.........
开发者ID:Burnsidious,项目名称:FSGDEngine,代码行数:101,代码来源:RenderContext.cpp

示例15: parseCollision

/**
* Parses a XML collision file.
* Uses Tinyxml
* @param pBList		TODO describtion
* @param pFile		the filepath of the file
*/
bool CollisionParser::parseCollision(list <BOUNDING_COLLISION *> *pBList, const char *pFile) {
	TiXmlDocument   *mXmlDoc = new TiXmlDocument(pFile);

	// Fatal error, cannot load
	if (!mXmlDoc->LoadFile()) return 0;

	// Document root
	TiXmlElement *mXBoundingAreas = 0;
	mXBoundingAreas = mXmlDoc->FirstChildElement("bounding_areas");

	if (!mXBoundingAreas) {
		g_debug->header("Invalid name for document root, should be <bounding_areas>", 2);
		mXmlDoc->Clear();
		delete mXmlDoc;
		return 0;
	}

	// ----- Triangle -----
	TiXmlElement *mXTriangle = 0;
	mXTriangle = mXBoundingAreas->FirstChildElement("triangle");

	while (mXTriangle) {
		if (mXTriangle->Attribute("id") &&
		        mXTriangle->Attribute("ax") &&
		        mXTriangle->Attribute("ay") &&
		        mXTriangle->Attribute("bx") &&
		        mXTriangle->Attribute("by") &&
		        mXTriangle->Attribute("cx") &&
		        mXTriangle->Attribute("cy")) {
			setBoundingTriangle(pBList,
			                    mXTriangle->Attribute("id"),
			                    atoi(mXTriangle->Attribute("ax")),
			                    atoi(mXTriangle->Attribute("ay")),
			                    atoi(mXTriangle->Attribute("bx")),
			                    atoi(mXTriangle->Attribute("by")),
			                    atoi(mXTriangle->Attribute("cx")),
			                    atoi(mXTriangle->Attribute("cy")));
		} else {
			g_debug->header("The triangle doesn't have all the attributes", 2);
			mXmlDoc->Clear();
			delete mXmlDoc;
			return 0;
		}

		// Move to the next element
		mXTriangle = mXTriangle->NextSiblingElement("triangle");
	}

	// ----- Circle -----
	TiXmlElement *mXCircle = 0;
	mXCircle = mXBoundingAreas->FirstChildElement("circle");

	while (mXCircle) {
		if (mXCircle->Attribute("id") &&
		        mXCircle->Attribute("x") &&
		        mXCircle->Attribute("y") &&
		        mXCircle->Attribute("radius")) {
			setBoundingCircle(pBList,
			                  mXCircle->Attribute("id"),
			                  atoi(mXCircle->Attribute("x")),
			                  atoi(mXCircle->Attribute("y")),
			                  atoi(mXCircle->Attribute("radius")));
		} else {
			g_debug->header("The circle doesn't have all the attributes", 2);
			mXmlDoc->Clear();
			delete mXmlDoc;
			return 0;
		}

		// Move to the next element
		mXCircle = mXCircle->NextSiblingElement("circle");
	}

	// ----- Rectangle -----
	TiXmlElement *mXRectangle = 0;
	mXRectangle = mXBoundingAreas->FirstChildElement("rectangle");

	while (mXRectangle) {
		if (mXRectangle->Attribute("id") &&
		        mXRectangle->Attribute("x") &&
		        mXRectangle->Attribute("y") &&
		        mXRectangle->Attribute("width") &&
		        mXRectangle->Attribute("height")) {
			setBoundingRectangle(pBList,
			                     mXRectangle->Attribute("id"),
			                     atoi(mXRectangle->Attribute("x")),
			                     atoi(mXRectangle->Attribute("y")),
			                     atoi(mXRectangle->Attribute("width")),
			                     atoi(mXRectangle->Attribute("height")));
		} else {
			g_debug->header("The rectangle doesn't have all the attributes", 2);
			mXmlDoc->Clear();
			delete mXmlDoc;
			return 0;
//.........这里部分代码省略.........
开发者ID:Javilop,项目名称:indielib-crossplatform,代码行数:101,代码来源:CollisionParser.cpp


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