void BulletMLParserTinyXML::translateNode(TiXmlNode* node) {
    TiXmlElement* elem = node->ToElement();
    assert(elem != 0);

    BulletMLNode* xmlNode = addContent(elem->Value());

	if (xmlNode->getName() == BulletMLNode::bulletml) {
		TiXmlAttribute* attr;
		for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) {
			if (attr->Value() == "horizontal") setHorizontal();
		}
	}
	else {
		MyAttributes mattr;
		TiXmlAttribute* attr;
		for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) {
			mattr.push_back(attr->Name());
			mattr.push_back(attr->Value());
		}
		addAttribute(mattr, xmlNode);
		if (curNode_ != 0) curNode_->addChild(xmlNode);
	}
	curNode_ = xmlNode;
}
Example #2
0
std::vector<std::string>
XMLReader::getAttrs() const noexcept
{
	assert(this->_currentNode);

	std::vector<std::string> attrs;

	TiXmlAttribute* attr = this->_currentNode->FirstAttribute();
	while (0 != attr)
	{
		attrs.push_back(attr->Name());
		attr = attr->Next();
	}

	return attrs;
}
Example #3
0
void TaggedObject::Load(TiXmlElement* load) {	
	TiXmlElement* wrapper = load->FirstChildElement("tagged-object");
	if(wrapper!=0) {
		TiXmlAttribute* att = load->FirstAttribute();
		while(att!=0) {
			String name = Wcs(att->Name());
			_tags.insert(name);
			att = att->Next();
		}
		
		if(_original) _original->Load(wrapper);
	}
	else {
		if(_original) _original->Load(load);
	}
}
Example #4
0
void SE_AnimationHandler::handle(SE_Element* parent, TiXmlElement* xmlElement, unsigned int indent)
{
    if(!xmlElement)
        return;
    TiXmlAttribute* pAttribute = xmlElement->FirstAttribute();
    while(pAttribute)
    {
        const char* name = pAttribute->Name();
        const char* value = pAttribute->Value();
        if(!strcmp(name , "FileName"))
        {
            elementManager->load(parent, value);
        }
        pAttribute = pAttribute->Next();
    }
}
Example #5
0
bool ObjectFactory::match_node_type(TiXmlElement *elmt)
{
    bool result = false;

    TiXmlAttribute *attr = elmt->FirstAttribute();
    while (attr) {
        if (strcmp(attr->Name(), "type") == 0) {
            strcpy(priv_object_type, attr->Value());
            result = true;
        }

        attr = attr->Next();
    }

    return result;
}
Example #6
0
int em::EmXml::ReadRootChildAttrMap( const char* szKeyName, const char* szKeyValue, EmMapStr &rMapStr )
{
	int iResult = 0;
	rMapStr.clear();

	TiXmlElement *pElemRoot = m_pDoc->RootElement();
	if(pElemRoot == NULL)
	{
		return 0;
	}
	
	TiXmlElement *pElemChild = pElemRoot->FirstChildElement();
	TiXmlAttribute *pAttrChild = NULL;
	while(true)
	{
		if(pElemChild == NULL)
		{
			break;
		}
		
		if(pElemChild->Type() != TiXmlNode::TINYXML_ELEMENT)
		{
			continue;
		}
		
		if(EmSz::Equal( pElemChild->Attribute( szKeyName) , szKeyValue))
		{
			pAttrChild = pElemChild->FirstAttribute();
			while(true)
			{
				if(pAttrChild == NULL)
				{
					break;
				}
				
				rMapStr[  pAttrChild->Name() ] = pAttrChild->Value();
				pAttrChild = pAttrChild->Next();
			}
			break;
		}
		
		pElemChild = pElemChild->NextSiblingElement();
	}
	iResult = rMapStr.size();
	
	return iResult;
}
Example #7
0
Globals::Globals(TiXmlElement *root)
    :
    nodeCounter(-1),
    linkCounter(-1),
    speciesCounter(-1)
{
    cout << "Populating sigmoid table...";
    for (int a=0; a<6001; a++)
    {
        signedSigmoidTable[a] = ((1 / (1+exp(-((a-3000)/1000.0)))) - 0.5)*2.0;
        unsignedSigmoidTable[a] = 1 / (1+exp(-((a-3000)/1000.0)));
    }
    cout << "done!\n";

    TiXmlAttribute *firstAttribute = root->FirstAttribute();

    while (firstAttribute)
    {
        if (iequals(firstAttribute->Name(),"NodeCounter"))
        {
            nodeCounter = firstAttribute->IntValue();
        }
        else if (iequals(firstAttribute->Name(),"LinkCounter"))
        {
            linkCounter = firstAttribute->IntValue();
        }
        else if (iequals(firstAttribute->Name(),"SpeciesCounter"))
        {
            speciesCounter = firstAttribute->IntValue();
        }
        else
        {
            addParameter( firstAttribute->Name() , firstAttribute->DoubleValue());
        }

        firstAttribute = firstAttribute->Next();
    }

    if (nodeCounter==-1 || linkCounter==-1 || speciesCounter==-1)
    {
        throw CREATE_LOCATEDEXCEPTION_INFO("MALFORMED XML!");
    }

    cacheParameters();

    initRandom();
}
Example #8
0
info_t *CLinhaXML::getInfo(){
	
	if(!getLinhaXML())
		return NULL;
	//Pega argumentos da linha passados na tag
	char *argumento;
	
	TiXmlAttribute *pAttrib = linhaXML->ToElement()->FirstAttribute();
	
	//printf("\n");
	while (pAttrib)
	{
		argumento = (char*)pAttrib->Name();
		switch(*argumento){
			case 't': 
				pAttrib->QueryIntValue(&info.top);
				break;
			case 'l':
				pAttrib->QueryIntValue(&info.left);
				break;
			case 'w':
				pAttrib->QueryIntValue(&info.width);
				break;
			case 'h':
				pAttrib->QueryIntValue(&info.height);
				break;
			case 'f':
				pAttrib->QueryIntValue(&info.font);
				break;		
		}
		info.bottom = info.top + info.height;
		info.right  = info.left + info.width;
		info.area   = info.height * info.width;
		
		pAttrib=pAttrib->Next();
	}
/*
	printf("t%-4d b%-4d l%-4d r%-4d w%-4d h%-4d a%-8d f%-4d n%-4d i%-4d\n", info.top, info.bottom,
															 info.left, info.right, 
															 info.width,info.height, 
															 info.area, info.font,
															 info.negrito, info.italico);
*/
	return &info;
	
}
void LibraryParser::GetBiLinkAttributes(TiXmlNode* pParent) {
	TiXmlAttribute* Attribute = ( pParent->ToElement())->FirstAttribute() ;
	string Name;
	string Type ;
	while (Attribute ) {
		if (string(Attribute->Name() ) == "name") {
			Name = Attribute->ValueStr() ;
		}else if (string(Attribute->Name() ) == "type") {
			Type = Attribute->ValueStr() ;
		}
		Attribute = Attribute->Next() ;
	}
	BiLink L ;
	L.SetName(Name );
	L.SetType( Type);
	mCurrentBiLink = L ;
}
Example #10
0
void ParticleFactory::InitXML()
{
	std::string pPath = 
		GameResourceManager::sharedManager()->storedFullPathFromRelativePath("Data/particles.xml");

	unsigned long	_size;
	char			*_pFileContent = (char*)CCFileUtils::sharedFileUtils()->getFileData(pPath.c_str() , "r", &_size);
	TiXmlDocument	*_document = new TiXmlDocument();
	_document->Parse(_pFileContent, 0, TIXML_ENCODING_UTF8);

	CC_SAFE_DELETE_ARRAY(_pFileContent);

	TiXmlElement *RootElement = _document->RootElement();
	if (RootElement)
	{
		TiXmlElement *childElement = RootElement->FirstChildElement();
		while (0 != childElement)
		{
			OneParticleInfo oneParticleInfo;
			TiXmlAttribute* pAttribute = childElement->FirstAttribute();
			while(pAttribute)
			{
				std::string strName(pAttribute->Name());
				std::string content = childElement->Attribute(strName.c_str());
				if (strName == "ID")
				{
					unsigned int id = atoi(content.c_str());
					oneParticleInfo.id = id;
				}
				else if (strName == "fileName")
				{
					oneParticleInfo.fileName = content;
				}
				pAttribute = pAttribute->Next();
			}
			m_particleListInfo.insert(std::make_pair(oneParticleInfo.id,oneParticleInfo));

			childElement = childElement->NextSiblingElement();
		}

		TiXmlDocument *doc = RootElement->GetDocument();
		doc->Clear();
		CC_SAFE_DELETE(doc);
	}
}
Example #11
0
bool ValidateProjXML(char* path)
{
	TiXmlDocument doc(path);
	if (doc.LoadFile())
	{
		TiXmlNode* first = doc.FirstChild();
		while (first->Type() != TiXmlNode::TINYXML_ELEMENT)
		{
			first = first->NextSibling();
		}
		if (!strncmp(first->Value(), "TRSProject", strlen(first->Value())))
		{
			TiXmlAttribute* art = first->ToElement()->FirstAttribute();
			if (!art)
				return false;
			if (strncmp(art->Name(), "name", 4))
			{
				return false;
			}
			art = art->Next();
			if (art)
			{
				if (strncmp(art->Name(), "ProjectPath", 11))
				{
					return false;
				}
			}
			else
			{
				return false;
			}
			TiXmlNode* head = first->FirstChild();
			for (head; head != 0; head = head->NextSibling())
			{
				if (strncmp(head->Value(), "path", strlen(head->Value())))
				{
					return false;
				}
			}
			return true;
		}
		return false;
	}
	return false;
}
Example #12
0
void searchXMLData(TiXmlElement* pElem)  
{  
	TiXmlHandle hRoot(0);  
	TiXmlElement* pSubElem = pElem;  
	TiXmlAttribute* pAttrib = NULL;  


	//Set current node to root node and determine childe node is exist or not  
	hRoot = TiXmlHandle(pSubElem);  
	pSubElem = hRoot.FirstChildElement().Element();  
	if (!pSubElem) return;  

	char* pszNode = NULL;  
	char* pszAttrib = NULL;  
	char* pszText = NULL;  

	while (pSubElem)  
	{  
		//node  
		pszNode = (char*)pSubElem->Value();  
		if (pszNode)  
		printf("Node: %s\n", pszNode);  

		//Attribute  
		pAttrib = pSubElem->FirstAttribute();  
		while (pAttrib)  
		{  
			char* pszAttrib = (char*)pAttrib->Name();  
			char* pszText = (char*)pAttrib->Value();  

			printf("------------Attribute: %s, Data: %s\n", pszAttrib, pszText);  

			pAttrib = pAttrib->Next();  
		}  

		//Data  
		pszText = (char*)pSubElem->GetText();  
		if (pszText)  
		printf("Text: %s\n", pszText);  

		// Recursive call for searching child node based current node  
		searchXMLData(pSubElem);  
		pSubElem = pSubElem->NextSiblingElement();  
	}  
}  
Example #13
0
bool xml_QueryNode_Attribute(TiXmlElement *pNode, std::string &attr_name,
        std::string &value)
{
    if (NULL != pNode) {
        TiXmlAttribute* pAttr = NULL;
        for (pAttr = pNode->FirstAttribute(); pAttr; pAttr = pAttr->Next()) {
            if (attr_name == pAttr->Name()){
                value               = pAttr->Value();
                break;
            }
        }
        if (pAttr == NULL){
            return false;
        }
        return true;
    }
    return false;
}
Example #14
0
map<string, string> XmlParser::getAttributes(TiXmlElement* element)
{
    map<string, string> attributeMap;
    if (element == NULL) {
       cerr << "No element passed to getAttributes!" << endl;
       return attributeMap; 
    }
    TiXmlAttribute* currentAttribute = element->FirstAttribute();
    while (currentAttribute != NULL) {
        string name = (string) currentAttribute->Name(); 
        string value = (string) currentAttribute->Value(); 
        if (!name.empty() && !value.empty()) {
            attributeMap[name] = value;
        }
        currentAttribute = currentAttribute->Next(); 
    }
    return attributeMap;
};
void LibraryParser::GetInterfaceAttributes(TiXmlNode* pParent) {
	TiXmlAttribute* Attribute = ( pParent->ToElement())->FirstAttribute() ;
	string Name;
	string Type;
	int Count = 1;
	while (Attribute ) {
		if (string(Attribute->Name() ) == "name") {
			Name = Attribute->ValueStr() ;
		} else if (string(Attribute->Name() ) == "type") {
			Type = Attribute->ValueStr() ;
		} else if (string(Attribute->Name() ) == "count") {
			Attribute->QueryIntValue(&Count) ;
		}
		Attribute = Attribute->Next() ;
	}
	//Add the interface to the current node
	mCurrentNode.Add(Name, Type, Count) ;
}
void CKSXML_Read_Project::Read_Master_Insert(TiXmlElement* pElement)
{
	if ( !pElement ) return ;
	
	TiXmlAttribute* pAttrib	=	pElement->FirstAttribute();
	tint32 ival;
	
	// aux id
	if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS)    
		;//printf( "insert slot;%d,  ", ival);
	
	if(pAttrib=pAttrib->Next())
		
		// aux id
		if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS)    
			;//printf( "id:%d \n", ival);
	
}
Example #17
0
// QC:G
ObjectMold* Factory::createMold(TiXmlElement *xmlData, VFS::File* xmlFile)
{
	Factory::moldmapping::iterator it;

	if(!xmlData) {
		return NULL;
	}

	const char* id = xmlData->Attribute("id");

	const char* src = xmlData->Attribute("src");
	if(src) {
		std::map<const char*, const char*> overrides;
		TiXmlAttribute* attr = xmlData->FirstAttribute();
		while(attr) {
			if(strcmp(attr->Name(), "id")!=0 && strcmp(attr->Name(), "src")!=0) {
				overrides[attr->Name()] = attr->Value();
			}
			attr = attr->Next();
		}

		VFS::File* srcFile = VFS::openFile(src, xmlFile);
		ObjectMold* createdObject = loadMold(srcFile, &overrides);
		delete srcFile;

		return createdObject;
	}

	// Find the factory for this class and call it.
	it = moldFactories.find(xmlData->Value());
	xassert(it != moldFactories.end(), "Don't know how to make molds of %s", xmlData->Value());
	xassert(it->second, "NULL mold factory for class %s", xmlData->Value());

	// Call the class-specific factory
	ObjectMold* createdObject = (this->*(it->second))(xmlData, xmlFile);
	createdObject->sourceFile = xmlFile->copy();
	if(id) {
		createdObject->setObjectId(id);
	}

	xwarn(createdObject, "Warning : could not create an instance of %s", xmlData->Value() );

	return createdObject;
}
Example #18
0
void MeshCompiler::CompileArmature( TiXmlElement* Arm )
{
	if( Arm )
	{
		m_Header.m_HasSkeleton = true;
		TiXmlAttribute* ArmAttr = Arm->FirstAttribute();	// "frames"
		m_Header.m_NumFrames = ArmAttr->IntValue() + 1;	// + 1 for T-pose at frame 0
		for( TiXmlElement* Bone = Arm->FirstChildElement( "bonedef" ); Bone; Bone = Bone->NextSiblingElement( "bonedef" ) )
		{
			SNamedBone sbone;
			TiXmlAttribute* BoneAttr = Bone->FirstAttribute();
			const char* pName = BoneAttr->Value();
			sbone.m_Name = HashedString( pName );

			// Push an identity so frame 0 is the T-pose
			sbone.m_FrameQuats.PushBack( Quat() );
			sbone.m_FrameTransVecs.PushBack( Vector() );

			for( TiXmlElement* Frame = Bone->FirstChildElement( "frame" ); Frame; Frame = Frame->NextSiblingElement( "frame" ) )
			{
				Matrix FrameMatrix;
				TiXmlAttribute* FrameAttr = Frame->FirstAttribute();

				// In case I ever need separate frame values
				int FrameNum = FrameAttr->IntValue();
				Unused( FrameNum );

				FrameAttr = FrameAttr->Next();
				GetXMLMatrix( FrameAttr, FrameMatrix );

				Quat FrameQuat = FrameMatrix.ToQuaternion();
				Vector FrameTransVec = FrameMatrix.GetTranslationElements();

				sbone.m_FrameQuats.PushBack( FrameQuat );
				sbone.m_FrameTransVecs.PushBack( FrameTransVec );
			}

			m_Bones.PushBack( sbone );
			++m_Header.m_NumBones;
		}

		CompileAnimations( Arm );
	}
}
Example #19
0
void processNode(XmlElement* parent, TiXmlNode* node)
{
    XmlElement* new_element = 0;
    switch (node->Type())
    {
    case TiXmlNode::TINYXML_ELEMENT:
        {
            TiXmlElement* element = node->ToElement();
            std::string tag = element->Value();
            std::transform( tag.begin(), tag.end(), tag.begin(), tolower);

            //Get all the attributes
            XmlAttributes attrs;
            TiXmlAttribute* attr = element->FirstAttribute();
            while (attr)
            {
                std::string name  = attr->Name();
                std::string value = attr->Value();
                std::transform( name.begin(), name.end(), name.begin(), tolower);
                attrs[name] = value;
                attr = attr->Next();
            }

            //All the element to the stack
            new_element = new XmlElement( tag, attrs );
            parent->getChildren().push_back( new_element );
        }
        break;
    case TiXmlNode::TINYXML_TEXT:
        {
            TiXmlText* text = node->ToText();
            std::string data( text->Value());
            parent->getChildren().push_back( new XmlText( data ) );
        }
        break;
    }    

    XmlElement* new_parent = new_element ? new_element : parent;
    TiXmlNode* child;
    for (child = node->FirstChild(); child != 0; child = child->NextSibling())
    {    
        processNode( new_parent, child );
    }
}
//---------------------------------------------------------
bool ofxXmlSettings::getAttributeNames(const string& tag, vector<string>& outNames, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();

		// Do stuff with the element here
		for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next())
			outNames.push_back( string(a->Name()) );
	}
	return !outNames.empty();
}
void WindowUser::ReadXML()
{


        doc.LoadFile();

       TiXmlNode *patr=doc.FirstChild();


    int i=0;
    while(patr){
        int x,y;


        TiXmlAttribute *atrX =patr->ToElement()->FirstAttribute();
        TiXmlAttribute *atrY =patr->ToElement()->LastAttribute();


        atrX->Next()->QueryIntValue(&x);
        //cout<<x<<endl;

        atrY->QueryIntValue(&y);
        //cout<<y<<endl;


//        cout<<patr->ToElement()->Attribute("Codigo")<<endl;
//        cout<<patr->ToElement()->Attribute("X")<<endl;
//        cout<<patr->ToElement()->Attribute("Y")<<endl;

          QLabel *pin =new QLabel(this);
          QPixmap qp=QPixmap(":/imgs/map-pin-md.png");
          pin->setPixmap(qp);
          pin->setGeometry(x,y,20,25);
          pin->setScaledContents(true);
          pin->raise();
          pin->show();
        patr=patr->NextSibling();
        i++;
    }



}
Example #22
0
int MAMELoader::LoadRomGroupEntry(TiXmlElement *romgroupElmt, MAMEGameEntry *gameentry) {
  MAMERomGroupEntry romgroupentry;

  //First, get the "type" and "load_method" attributes.  If they don't exist, we return with an error.
  string load_method;
  if (romgroupElmt->QueryValueAttribute("type", &romgroupentry.type) != TIXML_SUCCESS)
    return 1;
  if (romgroupElmt->QueryValueAttribute("load_method", &load_method) != TIXML_SUCCESS)
    return 1;

  // Read the encryption type string, if it exists
  romgroupElmt->QueryValueAttribute("encryption", &romgroupentry.encryption);

  //Iterate through the attributes of the romgroup element, recording any user-defined values.
  for (TiXmlAttribute *attr = romgroupElmt->FirstAttribute(); attr; attr = attr->Next()) {
    // NameTStr() is returning an std::string because we have defined TIXML_USE_STL
    const string &attrName = attr->NameTStr();
    // Ignore the attribute if it is "type" or "load_method"; we already dealt with those, they are mandated.
    if (attrName.compare("type") && attrName.compare("load_method"))
      romgroupentry.attributes[attrName] = attr->ValueStr();
  }

  if (load_method == "append")
    romgroupentry.loadmethod = LM_APPEND;
  else if (load_method == "append_swap16")
    romgroupentry.loadmethod = LM_APPEND_SWAP16;
  else if (load_method == "deinterlace")
    romgroupentry.loadmethod = LM_DEINTERLACE;
  else
    return 1;

  // load rom entries
  for (TiXmlElement *romElmt = romgroupElmt->FirstChildElement(); romElmt != 0;
       romElmt = romElmt->NextSiblingElement()) {
    const string &elmtName = romElmt->ValueStr();
    if (elmtName != "rom")
      return 1;
    romgroupentry.roms.push_back(romElmt->GetText());
  }

  gameentry->romgroupentries.push_back(romgroupentry);
  return 0;
}
Example #23
0
bool CPluginSettings::LoadFromPlexMediaServer(TiXmlElement* root)
{
  m_pluginXmlDoc.Clear();
  m_userXmlDoc.Clear();

  // This holds the settings.
  TiXmlElement xmlSettingsElement("settings");
  TiXmlNode* pSettings = m_pluginXmlDoc.InsertEndChild(xmlSettingsElement);
  
  // This holds the values.
  TiXmlElement xmlValuesElement("settings");
  TiXmlNode* pValues = m_userXmlDoc.InsertEndChild(xmlValuesElement);
  
  TiXmlElement *setting = root->FirstChildElement("Setting");
  while (setting)
  {
    TiXmlElement xmlSetting("setting");
    TiXmlElement xmlValueSetting("setting");
    
    // Walk through the attributes.
    TiXmlAttribute* attrib = setting->FirstAttribute();
    while (attrib)
    {
      string name = attrib->Name();
      string value = attrib->Value();
      
      if (name == "id" || name == "value")
        xmlValueSetting.SetAttribute(name, value);
      
      if (name != "value")
        xmlSetting.SetAttribute(name, value);
      
      attrib = attrib->Next();
    }
    
    pSettings->InsertEndChild(xmlSetting);
    pValues->InsertEndChild(xmlValueSetting);
    
    setting = setting->NextSiblingElement("Setting");
  }
  
  return true;
}
Example #24
0
	inline void xml_to_lua(lua_State* L, TiXmlElement* ele){
		// element table
		lua_newtable(L);

		// try set tag
		if(const char* value =ele->Value()){
			lua_pushstring(L, value);
			lua_setfield(L, -2, "tag");
		}

		// try set text
		if(const char* text =ele->GetText()){
			lua_pushstring(L, text);
			lua_setfield(L, -2, "text");
		}

		// try set attribute
		lua_newtable(L);
		TiXmlAttribute *attr =ele->FirstAttribute();
		while(attr){
			const char* name =attr->Name();
			const char* value =attr->Value();
			if(name && value){
				lua_pushstring(L, value);
				lua_setfield(L, -2, name);
			}
			attr =attr->Next();
		}
		lua_setfield(L, -2, "attr");

		// try set child
		lua_newtable(L);
		int idx =1;
		TiXmlElement * child_ele =ele->FirstChildElement();
		while(child_ele){
			xml_to_lua(L, child_ele);
			lua_rawseti(L, -2, idx);
			idx +=1;
			child_ele =child_ele->NextSiblingElement();
		}
		lua_setfield(L, -2, "child");
	}
//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;
}
Example #26
0
//static
HeeksObj* HPoint::ReadFromXMLElement(TiXmlElement* pElem)
{
	gp_Pnt p;
	HeeksColor c;

	// get the attributes
	for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
	{
		std::string name(a->Name());
		if(name == "col"){c = HeeksColor((long)(a->IntValue()));}
		else if(name == "x"){p.SetX(a->DoubleValue());}
		else if(name == "y"){p.SetY(a->DoubleValue());}
		else if(name == "z"){p.SetZ(a->DoubleValue());}
	}

	HPoint* new_object = new HPoint(p, &c);
	new_object->ReadBaseXML(pElem);

	return new_object;
}
Example #27
0
TiXmlNode* QCSXCAD::ReadOpenEMS(TiXmlNode* openEMS)
{
	// read FDTD options
	m_BC.clear();
	TiXmlElement* element = openEMS->FirstChildElement("FDTD");
	if (element)
	{
		TiXmlElement* BC = element->FirstChildElement("BoundaryCond");
		if (BC)
		{
			TiXmlAttribute *attr = BC->FirstAttribute();
			while (attr)
			{
				m_BC[attr->Name()] = attr->Value();
				attr = attr->Next();
			}
		}
	}
	return openEMS;
}
Example #28
0
 void add_parts(TiXmlElement *elmt) {
     CollisionPart *part = new CollisionPart;
     TiXmlAttribute *attr = elmt->FirstAttribute();
     while (attr) {
         if (strcmp(attr->Name(), "x1") == 0) {
             part->x1 = atoi(attr->Value());
         }
         else if (strcmp(attr->Name(), "y1") == 0) {
             part->y1 = atoi(attr->Value());
         }
         else if (strcmp(attr->Name(), "x2") == 0) {
             part->x2 = atoi(attr->Value());
         }
         else if (strcmp(attr->Name(), "y2") == 0) {
             part->y2 = atoi(attr->Value());
         }
         attr = attr->Next();
     }
     m_parts.push_back(part);
 }
Example #29
0
void TiXmlElement::CopyTo( TiXmlElement* target ) const
{
	// superclass:
	TiXmlNode::CopyTo( target );

	// Element class: 
	// Clone the attributes, then clone the children.
	TiXmlAttribute* attribute = 0;
	for(	attribute = attributeSet.First();
	attribute;
	attribute = attribute->Next() )
	{
		target->SetAttribute( attribute->Name(), attribute->Value() );
	}

	TiXmlNode* node = 0;
	for ( node = firstChild; node; node = node->NextSibling() )
	{
		target->LinkEndChild( node->Clone() );
	}
}
//---------------------------------------------------------
bool ofxXmlSettings::attributeExists(const string& tag, const string& attribute, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();

		// Do stuff with the element here
		for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next()) {
			if (a->Name() == attribute)
				return true;
		}
	}
	return false;
}