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


C++ TiXmlAttribute::QueryDoubleValue方法代码示例

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


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

示例1: QueryDoubleAttribute

int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
{
	TiXmlAttribute* node = attributeSet.Find( name );
	if ( !node )
		return TIXML_NO_ATTRIBUTE;

	return node->QueryDoubleValue( dval );
}
开发者ID:joshdekock,项目名称:jim-pspware,代码行数:8,代码来源:tinyxml.cpp

示例2: ParseWire

void HoOrionModelParser::ParseWire(TiXmlNode* pParent) {
	double C, R, Pitch;
	int Layer;
	TiXmlAttribute* Attribute = ( pParent->ToElement())->FirstAttribute() ;
	while (Attribute ) {
		if (string(Attribute->Name() ) == "type") {
		} else if (string(Attribute->Name() ) == "layer") {
			Attribute->QueryIntValue(&Layer) ;
		} else if (string(Attribute->Name() ) == "r") {
			Attribute->QueryDoubleValue(&R) ;
		} else if (string(Attribute->Name() ) == "c") {
			Attribute->QueryDoubleValue(&C) ;
		} else if (string(Attribute->Name() ) == "pitch") {
			Attribute->QueryDoubleValue(&Pitch) ;
		} else {
			cout << "Unknown attribute "<< Attribute->Name() << " for wire"
					<< endl ;
		}
		Attribute = Attribute->Next() ;
	}
	mR[Layer] = R ;
	mC[Layer] = C ;
	mPitch[Layer] = Pitch ;
}
开发者ID:alessandro-pinto,项目名称:commsynth,代码行数:24,代码来源:HoOrionModelParser.cpp

示例3: Output_attributes

//Función que vuelca el contenido de los atributos de un elemento del fichero XML, y
// devuelve el número de atributos del elemento.
int cLoadXML::Output_attributes(TiXmlElement* lpElement, unsigned int luiIndent)
{
	if ( !lpElement ) return 0;
    //Se accede al primer atributo del elemento.
	TiXmlAttribute* lpAttrib = lpElement->FirstAttribute();
	int i = 0;
	int liVal;
	double ldVal;
	//Se obtiene la cadena de indentación.
	const char* kpcIndent = GetIndent(luiIndent, true);
	OutputDebugString("\n");
	//Se recorren los atributos.
	while (lpAttrib)
	{
		//Se imprime la indentación concatenada con el nombre del atributo y su valor.
		OutputDebugString( ((std::string)kpcIndent + lpAttrib->Name() + ": value = " + lpAttrib->Value()).c_str());		
		//"QueryIntValue()" es una alternativa al método IntValue() con verificación de error. Si el valor del atributo es integer, es almacenado en el parámetro
		// "liVal" y se retorna TIXML_SUCCESS. Si no es integer se devuelve TIXML_WRONG_TYPE.
		if (lpAttrib->QueryIntValue(&liVal)==TIXML_SUCCESS)
		{
			char lpcCadenaNum[4];
			//Convertimos el número integer en cadena
			sprintf_s(lpcCadenaNum, 4, "%d", liVal);
			OutputDebugString((", the value is integer = " + (std::string)lpcCadenaNum).c_str());
		}
		//"QueryDoubleValue()" es una alternativa al método DoubleValue() con verificación de error. Si el valor del atributo es double, es almacenado en el parámetro
		// "ldVal" y se retorna TIXML_SUCCESS. Si no es double se devuelve TIXML_WRONG_TYPE.
		else if (lpAttrib->QueryDoubleValue(&ldVal)==TIXML_SUCCESS)
		{
			char lpcCadenaNum[20];
			//Convertimos el número integer en cadena
			sprintf_s(lpcCadenaNum, 20, "%0.2f", ldVal);
			OutputDebugString((", the value is double = " + (std::string)lpcCadenaNum).c_str());
		}			
		OutputDebugString("\n");
		i++;
		//Next(): Get the next sibling attribute in the DOM. Returns null at end. 
		lpAttrib=lpAttrib->Next();
	}
	//Se devuelve el número de atributos
	return i;
}
开发者ID:Juanmaramon,项目名称:aplicacion-practica-basica,代码行数:44,代码来源:LoadXML.cpp

示例4: dump_attribs_to_stdout

int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int indent)
{
	if (!pElement) return 0;

	TiXmlAttribute* pAttrib = pElement->FirstAttribute();
	int i = 0;
	int ival;
	double dval;
	const char* pIndent = getIndent(indent);
	printf("\n");
	while (pAttrib)
	{
		printf("%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value());

		if (pAttrib->QueryIntValue(&ival) == TIXML_SUCCESS)    printf(" int=%d", ival);
		if (pAttrib->QueryDoubleValue(&dval) == TIXML_SUCCESS) printf(" d=%1.1f", dval);
		printf("\n");
		i++;
		pAttrib = pAttrib->Next();
	}
	return i;
}
开发者ID:HmsChumsai,项目名称:TestXML,代码行数:22,代码来源:main.cpp

示例5: ReadXML_Curves_

bool CGmResMan::ReadXML_Curves_( CList<CCurvePathBezier3 *> *poLstCurve, TiXmlNode* poParent, unsigned int uiCounter )
{
	if( !poParent )
		return false;
	
	static CCurvePathBezier3 * poCurve_;
	static CCurveBezier3 * poBezier_;
	static unsigned int uiVertex_;
	static char acTxt_[256];
	if( uiCounter == 0 )
	{
		poCurve_ = 0;
		poBezier_ = 0;
		uiVertex_ = 0;
	}
	bool bCurveTag = false;
	bool bBezierTag = false;
	
	switch ( poParent->Type() )
	{
	case TiXmlNode::DOCUMENT:
		LOG( "XML: Document" );
	break;
	case TiXmlNode::ELEMENT:
	{
		const char *pcName = poParent->Value();
		//LOG( "name: %s\n", pcName );
		if( !strcmp( pcName, "curve" ) )
		{
			LOG( "curve:\n" );
			
			poCurve_ = new CCurvePathBezier3;
			poLstCurve->Append( poCurve_ );
			bCurveTag = true;
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "name" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "name: %s\n", acTxt_ );
						poCurve_->m_oName = acTxt_;
					}
					poAttrib = poAttrib->Next();
				}
			}
		}
		else if( !strcmp( pcName, "bezier" ) )
		{
			LOG( "bezier:\n" );
			poBezier_ = new CCurveBezier3;
			bBezierTag = true;
		}
		else if( !strcmp( pcName, "point" ) && poBezier_ )
		{
			LOG( "point:\n" );
			CCurve::CVertex oVertex;
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					
					if( !strcmp( pcName, "x" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_oPos[0] = float( dVal );
						}
					}
					else if( !strcmp( pcName, "y" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_oPos[1] = float( dVal );
						}
					}
					else if( !strcmp( pcName, "z" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							oVertex.m_oPos[2] = float( dVal );
						}
					}
					else if( !strcmp( pcName, "weight" ) )
					{
//.........这里部分代码省略.........
开发者ID:0rel,项目名称:okkuplektor,代码行数:101,代码来源:GmResMan.cpp

示例6: ParseRouter

void HoOrionModelParser::ParseRouter(TiXmlNode* pParent) {
	double TmpDouble;
	int TmpInt;
	string Type;
	stringstream Energy;
	stringstream Area;
	int MaxIn = 0;
	int MaxOut = 0;
	TiXmlAttribute* Attribute = ( pParent->ToElement())->FirstAttribute() ;
	while (Attribute ) {
		if (string(Attribute->Name() ) == "type") {
			Type = string(Attribute->Value() ) ;
		} else if (string(Attribute->Name() ) == "maxin") {
			Attribute->QueryIntValue(&TmpInt) ;
			MaxIn = TmpInt ;
		} else if (string(Attribute->Name() ) == "maxout") {
			Attribute->QueryIntValue(&TmpInt) ;
			MaxOut = TmpInt ;
		} else if (string(Attribute->Name() ) == "maxbw") {
			Attribute->QueryDoubleValue(&TmpDouble) ;
			//mModel->RouterMaxBw = TmpDouble ;
		} else if (string(Attribute->Name() ) == "energy") {
			Energy << Attribute->ValueStr() ;
		} else if (string(Attribute->Name() ) == "area") {
			Area << Attribute->ValueStr() ;
		} else {
			cout << "Unknown attribute "<< Attribute->Name() << " for wire"
					<< endl ;
		}
		Attribute = Attribute->Next() ;
	}

	mMaxIn = MaxIn ;
	mMaxOut = MaxOut ;

	if (Type == "r1ch32") {
		mArouter1ch32.resize(MaxIn + 1) ;
		mErouter1ch32.resize(MaxIn + 1) ;
		mErouterLeak1ch32.resize(MaxIn + 1) ;
		mArouter1ch32[0].resize(MaxOut + 1) ;
		mErouter1ch32[0].resize(MaxOut + 1) ;
		mErouterLeak1ch32[0].resize(MaxOut + 1) ;
		for (int i = 1; i <= MaxIn ; i++) {
			mArouter1ch32[i].resize(MaxOut + 1) ;
			mErouter1ch32[i].resize(MaxOut + 1) ;
			mErouterLeak1ch32[i].resize(MaxOut + 1) ;
			for (int j = 1; j <= MaxOut ; j++) {
				Area >> mArouter1ch32[i][j];
				mArouter1ch32[i][j] = mArouter1ch32[i][j]*1e-12;
				Energy >> mErouter1ch32[i][j];
				Energy >> mErouterLeak1ch32[i][j];
			}
		}

		//handle first rows nad first column
		for (int j = 0; j <= MaxOut ; j++) {
			mArouter1ch32[0][j] = 0;
			mErouter1ch32[0][j] = 0;
			mErouterLeak1ch32[0][j] = 0;
		}
		for (int i = 0; i <= MaxIn ; i++) {
			mArouter1ch32[i][0] = 0;
			mErouter1ch32[i][0] = 0;
			mErouterLeak1ch32[i][0] = 0;
		}

	} else if (Type == "r4ch32") {
开发者ID:alessandro-pinto,项目名称:commsynth,代码行数:67,代码来源:HoOrionModelParser.cpp

示例7: ReadXML

bool CGmObjShapeStaticItem::ReadXML( TiXmlNode* poParent, unsigned int uiCounter )
{
	if( !poParent )
		return false;
	
	static char acTxt_[256];
	if( uiCounter == 0 )
	{
	}
	
	switch ( poParent->Type() )
	{
	case TiXmlNode::DOCUMENT:
		LOG( "XML: Document" );
	break;
	case TiXmlNode::ELEMENT:
	{
		const char *pcName = poParent->Value();
		//LOG( "name: %s\n", pcName );
		if( !strcmp( pcName, "item" ) )
		{
			LOG( "item:\n" );
			
			TiXmlElement * poElement = poParent->ToElement();
			if( poElement )
			{
				TiXmlAttribute* poAttrib = poElement->FirstAttribute();
				while( poAttrib )
				{
					const char *pcName = poAttrib->Name();
					if( !strcmp( pcName, "name" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						m_oName = acTxt_;
					}
					if( !strcmp( pcName, "type" ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						if( !strcmp( acTxt_, "weapon" ) )
							m_eType = TYPE_WEAPON;
						else if( !strcmp( acTxt_, "energy" ) )
							m_eType = TYPE_ENERGY;
						else if( !strcmp( acTxt_, "ammo" ) )
							m_eType = TYPE_AMMO;
						else if( !strcmp( acTxt_, "key" ) )
							m_eType = TYPE_KEY;
						else
							m_eType = TYPE_UNDEFINED;
					}
					if( !strcmp( pcName, "cycle_duration" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							if( dVal >= 0.0 )
								m_iTickDurCycle = int( dVal / m_dTInteractionInterval_ );
							else
								m_iTickDurCycle = -1;
						}
					}
					if( !strcmp( pcName, "rotation_y_speed" ) )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							m_fRotationYSpeed = float( dVal * 360.0 );
						}
					}
					if( !strcmp( pcName, "weapon_name" )
					 && ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) )
					{
						STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
						LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
						m_oWeaponName = acTxt_;
					}
					if( !strcmp( pcName, "energy" ) && m_eType == TYPE_ENERGY )
					{
						double dVal;
						if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
						{
							LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
							m_fEnergy = float( dVal );
						}
					}
					if( !strcmp( pcName, "ammo" )
					 && ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) )
					{
						int iVal;
						if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS
						 && iVal > 0 )
						{
							LOG( "%s: %d\n", poAttrib->Name(), iVal );
							m_uiAmmo = iVal;
						}
					}
					if( !strcmp( pcName, "key" ) && m_eType == TYPE_ENERGY )
//.........这里部分代码省略.........
开发者ID:0rel,项目名称:okkuplektor,代码行数:101,代码来源:GmObjShapeStaticItem.cpp

示例8: if

int CSkeleton::CBone::ReadXMLAttrib( TiXmlElement* poElement )
{
	if( !poElement )
		return 0;
	
	TiXmlAttribute* poAttrib = poElement->FirstAttribute();
	int i = 0;
	int iVal;
	double dVal;
	static char acName_[256];
	
	while( poAttrib )
	{
		const char *pcName = poAttrib->Name();
		if( !strcmp( pcName, "name" ) )
		{
			SKELETON_STR_COPY( acName_, sizeof(acName_), poAttrib->Value() );
			SKELETON_LOG( "name: %s\n", acName_ );
			m_oName = acName_;
		}
		else if( !strcmp( pcName, "parent_index" ) )
		{
			if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %d\n", poAttrib->Name(), iVal );
				m_iIndexParent = iVal;
			}
		}
		else if( !strcmp( pcName, "head_x" ) )
		{
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
				m_oHead[0] = float( dVal );
			}
		}
		else if( !strcmp( pcName, "head_y" ) )
		{
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
				m_oHead[1] = float( dVal );
			}
		}
		else if( !strcmp( pcName, "head_z" ) )
		{
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
				m_oHead[2] = float( dVal );
			}
		}
		else if( !strcmp( pcName, "tail_x" ) )
		{
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
				m_oTail[0] = float( dVal );
			}
		}
		else if( !strcmp( pcName, "tail_y" ) )
		{
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
				m_oTail[1] = float( dVal );
			}
		}
		else if( !strcmp( pcName, "tail_z" ) )
		{
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
			{
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
				m_oTail[2] = float( dVal );
			}
		}
#define CHECK_M( i, j ) \
		else if( !strcmp( pcName, "m" #i #j ) ) \
		{ \
			if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS ) \
			{ \
				SKELETON_LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) ); \
				m_oTransform( i, j ) = float( dVal ); \
			} \
		}
		CHECK_M( 0, 0 )
		CHECK_M( 1, 0 )
		CHECK_M( 2, 0 )
		CHECK_M( 3, 0 )
		CHECK_M( 0, 1 )
		CHECK_M( 1, 1 )
		CHECK_M( 2, 1 )
		CHECK_M( 3, 1 )
		CHECK_M( 0, 2 )
		CHECK_M( 1, 2 )
		CHECK_M( 2, 2 )
		CHECK_M( 3, 2 )
		CHECK_M( 0, 3 )
		CHECK_M( 1, 3 )
		CHECK_M( 2, 3 )
//.........这里部分代码省略.........
开发者ID:0rel,项目名称:okkuplektor,代码行数:101,代码来源:Skeleton.cpp

示例9: read_graphml

  Graph read_graphml(
      std::string input_filename
      )
  {
    typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex;
#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3))
    typedef typename __gnu_cxx::hash_map<std::string, vertex> HashMap;
#else
    typedef typename std::unordered_map<std::string, vertex> HashMap;
#endif

    TiXmlDocument doc(input_filename.c_str());
    if (!doc.LoadFile())
      throw std::runtime_error("read_graphml: cannot open input file");

    TiXmlHandle hDoc(&doc);
    TiXmlElement *pElem;

    pElem = hDoc.FirstChildElement().Element();
    if (!pElem || strcmp(pElem->Value(), "graphml"))
      throw std::runtime_error("read_graphml: malformed input graphml file");

    pElem = hDoc.FirstChildElement().FirstChild().Element();
    while (pElem)
    {
      if ( ! strcmp(pElem->Value(), "graph") )
        break;
      pElem = pElem->NextSiblingElement();
    }

    if ( ! pElem )
      throw std::runtime_error("read_graphml: malformed input graphml file");

    TiXmlHandle hRoot(pElem);
    Graph out_g;
    pElem = hRoot.FirstChild().Element();
    HashMap id_hash;

    while (pElem)
    {
      std::string id, source_id, target_id, name;
      double weight = 1.0;

      TiXmlAttribute *pAttrib = pElem->FirstAttribute();
#ifdef CONAN_DEBUG
      std::cerr << "  " << pElem->Value() << ":" << std::endl;
#endif
      while (pAttrib)
      {
        if (!strcmp(pAttrib->Name(), "id"))
        {
          const char *pId = pAttrib->Value();
          if (pId)
            id = pId;
        }
        else if (!strcmp(pAttrib->Name(), "source"))
        {
          const char *pSource = pAttrib->Value();
          if (pSource)
            source_id = pSource;
        }
        else if (!strcmp(pAttrib->Name(), "target"))
        {
          const char *pTarget = pAttrib->Value();
          if (pTarget)
            target_id = pTarget;
        }
        else if (!strcmp(pAttrib->Name(), "weight"))
        {
          if (pAttrib->QueryDoubleValue(&weight) != TIXML_SUCCESS)
            std::cerr << "weight isn't a double presicion number" << std::endl;
        }
        else if (!strcmp(pAttrib->Name(), "label"))
        {
          const char *pName = pAttrib->Value();
          if (pName)
            name = pName;
        }
#ifdef CONAN_DEBUG
        std::cerr << "    " << pAttrib->Name() << " = " << pAttrib->Value() << std::endl;
#endif
        pAttrib = pAttrib->Next();
      }

      if (!strcmp(pElem->Value(), "node"))
      {
        vertex v = boost::add_vertex(out_g);
        id_hash[id] = v;
        if (!name.empty())
          out_g[v].name = name;
        else
          out_g[v].name = id;
#ifdef CONAN_DEBUG
        std::cerr << "Added node with id = " << id << " (remapped to " << v << ") and name = '" << out_g[v].name << "'" << std::endl;
#endif
      }
      else if (!strcmp(pElem->Value(), "edge"))
      {
        boost::add_edge(id_hash[source_id], id_hash[target_id], weight, out_g);
#ifdef CONAN_DEBUG
//.........这里部分代码省略.........
开发者ID:kirpen,项目名称:conan,代码行数:101,代码来源:graphml.hpp


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