void
SipRedirectorJoin::textContentDeepRecursive(UtlString& string,
                                              TiXmlElement *element)
{
   // Iterate through all the children.
   for (TiXmlNode* child = element->FirstChild(); child;
        child = child->NextSibling())
   {
      // Examine the text nodes.
      if (child->Type() == TiXmlNode::TEXT)
      {
         // Append the content to the string.
         string.append(child->Value());
      }
      else if (child->Type() == TiXmlNode::ELEMENT)
      {
         // Recurse on this element.
         textContentDeepRecursive(string, child->ToElement());
      }
   }
}
Exemple #2
0
void TiXmlElement::CopyTo( TiXmlElement* target ) const
{
	// superclass:
	TiXmlNode::CopyTo( target );

	// Element class: 
	// Clone the attributes, then clone the children.
	const 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() );
	}
}
Exemple #3
0
void tPlayer::Load()
{
	TiXmlDocument  xmlDoc( (PLAYER_DIR + playername + PLAYER_EXT).c_str() );
	TiXmlElement  *xmlePlr;
	TiXmlNode     *node = 0;
	bool loadOkay = xmlDoc.LoadFile();

	if( loadOkay )
	{
		TiXmlHandle xmlDocHandle( &xmlDoc );

		xmlePlr = xmlDocHandle.FirstChild( "player" ).Element();
		if( xmlePlr != NULL )
		{
			password = xmlePlr->Attribute( "password" );
			room = atoi( xmlePlr->Attribute( "room" ) );
			for( node = xmlePlr->FirstChild( "flags" )->FirstChild( "flag" );
				 node;
				 node = node->NextSibling( "flag" ) )
			{
				flags.insert( node->ToElement()->GetText() );
			}

			node = xmlePlr->FirstChild( "stats" );

			if( node )
			{
				maxhp = atoi( node->FirstChild( "maxHP" )->FirstChild()->Value() );
				curhp = atoi( node->FirstChild( "curHP" )->FirstChild()->Value() );
				baseskl = atoi( node->FirstChild( "baseSkill" )->FirstChild()->Value() );
			}
			else
				throw runtime_error( "Player data corrupt, please contact an admin for assistance" );
		}
	}
	else
		throw runtime_error( "That player does not exist, type 'new' to create a new one." );

} /* end of tPlayer::Load */
void XmlParser::geoNode(TiXmlNode* pParent) {

	TiXmlNode* pChild;
	for (pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
		int t = pChild->Type();
		if (t == TiXmlNode::ELEMENT) {
			string element_value(pChild->Value());
			if (element_value == "surface")
				objects.push_back(surfaceAttrib(pChild->ToElement()));
			else if (element_value == "cell")
				objects.push_back(cellAttrib(pChild->ToElement()));
			else if (element_value == "lattice")
				objects.push_back(latticeAttrib(pChild->ToElement()));
			else {
				vector<string> keywords;
				keywords.push_back(element_value);
				throw KeywordParserError("Unrecognized geometry keyword <" + element_value + ">",keywords);
			}
		}
	}

}
Exemple #5
0
bool TLFSemanticImageDescriptor::LoadXML(const char* lpFileName)
{
   this->Clear();

   TiXmlDocument doc;
   if (!doc.LoadFile(lpFileName))
    return false;
   TiXmlHandle hDoc(&doc);
   TiXmlElement* pElem = NULL;

   pElem = hDoc.FirstChildElement().Element();
   if (pElem == NULL)
    return false;

   if (strcmp(pElem->Value(), GetName()) != 0)
    return false;

   int w, h;
   pElem->QueryIntAttribute("ImageWidth", &w);
   pElem->QueryIntAttribute("ImageHeight", &h);

   for(TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling() )
   {
        TLFDetectedItem* di = new TLFDetectedItem();
        if (strcmp(child->Value(), di->GetName()) != 0)
        {
            Clear();
            return false;
        }
        if (!di->LoadXML(child->ToElement()))
        {
            Clear();
            return false;
        }
        Add(di);
   }

   return true;
}
Exemple #6
0
bool CButtonTranslator::LoadKeymap(const CStdString &keymapPath)
{
  TiXmlDocument xmlDoc;

  CLog::Log(LOGINFO, "Loading %s", keymapPath.c_str());
  if (!xmlDoc.LoadFile(keymapPath))
  {
    CLog::Log(LOGERROR, "Error loading keymap: %s, Line %d\n%s", keymapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
    return false;
  }
  TiXmlElement* pRoot = xmlDoc.RootElement();
  CStdString strValue = pRoot->Value();
  if ( strValue != "keymap")
  {
    CLog::Log(LOGERROR, "%s Doesn't contain <keymap>", keymapPath.c_str());
    return false;
  }
  // run through our window groups
  TiXmlNode* pWindow = pRoot->FirstChild();
  while (pWindow)
  {
    if (pWindow->Type() == TiXmlNode::ELEMENT)
    {
      int windowID = WINDOW_INVALID;
      const char *szWindow = pWindow->Value();
      if (szWindow)
      {
        if (strcmpi(szWindow, "global") == 0)
          windowID = -1;
        else
          windowID = TranslateWindow(szWindow);
      }
      MapWindowActions(pWindow, windowID);
    }
    pWindow = pWindow->NextSibling();
  }

  return true;
}
Exemple #7
0
void Triangle::read(TiXmlNode* node)
{
	String materialName;
	TiXMLHelper::GetAttribute(node, "materialName", &materialName);
	material = resourceManager.getMaterial(materialName);

	TiXmlNode* vertexInfosNode = node->FirstChild("vertexInfos");
	assert(vertexInfosNode);

	TiXmlNode* vertexInfoNode = vertexInfosNode->FirstChild("vertexInfo");
	int vertexIndex = 0;
	while (vertexInfoNode)
	{
		TiXMLHelper::GetAttribute(vertexInfoNode, "position", &coords[vertexIndex]);

		vertexIndex++;
		vertexInfoNode = vertexInfoNode->NextSibling();
	}
	assert(vertexIndex == 3);

	recomputeNormal();
}
Exemple #8
0
void XCFParser::parsePartitioning(TiXmlElement* root){
    TiXmlNode* node = root->FirstChild();


    while (node != NULL){
        if (node->Type() == TiXmlNode::TINYXML_ELEMENT) {
            TiXmlElement* element = (TiXmlElement*)node;
            TiXmlString name(node->Value());

            if (name == XCFMapping::PARTITIONING) {
                parsePartitioning(element);
            }else if (name == XCFMapping::PARTITION) {
                parsePartition(element);
            }else {
                cerr << "Invalid node "<< name.c_str() << endl;
                exit(1);
            }

        }
        node = node->NextSibling();
    }
}
bool CButtonTranslator::LoadLircMap()
{
  // load our xml file, and fill up our mapping tables
  TiXmlDocument xmlDoc;

  // Load the config file
  CStdString lircmapPath = g_settings.GetUserDataItem("Lircmap.xml");
  CLog::Log(LOGINFO, "Loading %s", lircmapPath.c_str());
  if (!xmlDoc.LoadFile(lircmapPath))
  {
    g_LoadErrorStr.Format("%s, Line %d\n%s", lircmapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
    return true; // This is so people who don't have the file won't fail, just warn
  }

  lircRemotesMap.clear();
  TiXmlElement* pRoot = xmlDoc.RootElement();
  CStdString strValue = pRoot->Value();
  if (strValue != "lircmap")
  {
    g_LoadErrorStr.Format("%sl Doesn't contain <lircmap>", lircmapPath.c_str());
    return false;
  }

  // run through our window groups
  TiXmlNode* pRemote = pRoot->FirstChild();
  while (pRemote)
  {
    const char *szRemote = pRemote->Value();
    if (szRemote)
    {
      TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute();
      const char* szDeviceName = pAttr->Value();
      MapRemote(pRemote, szDeviceName);
    }
    pRemote = pRemote->NextSibling();
  }
  
  return true;
}
Exemple #10
0
bool TLFSemanticDictinary::LoadXML(const char* lpFileName)
{
   this->Clear();

   TiXmlDocument doc(lpFileName);
   if (!doc.LoadFile())
    return false;
   TiXmlHandle hDoc(&doc);
   TiXmlElement* pElem = NULL;

   pElem = hDoc.FirstChildElement().Element();
   if (pElem == NULL)
    return false;

   if (strcmp(pElem->Value(), GetName()) != 0)
    return false;

   //int w, h;
   this->m_Description =  pElem->Attribute("Description");


   for(TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling() )
   {
        TLFSemanticDictinaryItem* di = new TLFSemanticDictinaryItem();
        if (strcmp(child->Value(), di->GetName()) != 0)
        {
            Clear();
            return false;
        }
        if (!di->LoadXML(child->ToElement()))
        {
            Clear();
            return false;
        }
        this->m_Items.Add(di);
   }

   return true;
}
/*
 * TinyXml has loaded and parsed the XML document for us.  We need to
 * run through the DOM tree, pull out the interesting bits, and make
 * sure the stuff we need is present.
 *
 * Returns "true" on success, "false" on failure.
 */
bool PhoneData::ProcessAndValidate(TiXmlDocument* pDoc)
{
    bool deviceFound = false;
    TiXmlNode* pChild;

    assert(pDoc->Type() == TiXmlNode::DOCUMENT);

    for (pChild = pDoc->FirstChild(); pChild != NULL;
        pChild = pChild->NextSibling())
    {
        /*
         * Find the <device> entry.  There should be exactly one.
         */
        if (pChild->Type() == TiXmlNode::ELEMENT) {
            if (strcasecmp(pChild->Value(), "device") != 0) {
                fprintf(stderr,
                    "SimCFG: Warning: unexpected element '%s' at top level\n",
                    pChild->Value());
                continue;
            }
            if (deviceFound) {
                fprintf(stderr, "SimCFG: one <device> per customer\n");
                return false;
            }

            bool result = ProcessDevice(pChild);
            if (!result)
                return false;
            deviceFound = true;
        }
    }

    if (!deviceFound) {
        fprintf(stderr, "SimCFG: no <device> section found\n");
        return false;
    }

    return true;
}
Exemple #12
0
void User::parseNewsAndGifts(TiXmlNode* xmlNode, Event<std::vector<UserCore::Misc::NewsItem*> > &onEvent)
{
	if (!xmlNode)
		return;

	std::vector<UserCore::Misc::NewsItem*> itemList;

	TiXmlNode* pChild = xmlNode->FirstChild();
	while (pChild)
	{
		if (XML::isValidElement(pChild))
		{
			TiXmlElement *itemElem = pChild->ToElement();

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

			gcString szTitle;
			gcString szUrl;

			XML::GetChild("title", szTitle, itemElem);
			XML::GetChild("url", szUrl, itemElem);
			
			if (szId && szTitle != "" && szUrl != "")
			{
				uint32 id = (uint32)atoi(szId);

				UserCore::Misc::NewsItem *temp = new UserCore::Misc::NewsItem(id, 0, szTitle.c_str(), szUrl.c_str());
				itemList.push_back(temp);
			}
		}

		pChild = pChild->NextSibling();
	}

	if (itemList.size() > 0)
		onEvent(itemList);

	safe_delete(itemList);
}
Scene* SceneLoader::loadScene(Ogre::DataStreamPtr &data)
{
    TiXmlDocument* doc = loadDocument(data);
    TiXmlElement* root = doc->RootElement();
    Scene* scene = new Scene(getAttributeValueAsString(root, "name"));
    
    for (TiXmlNode* cur = root->FirstChild(); cur; cur = cur->NextSibling())
    {
        if (cur->Type() == TiXmlNode::ELEMENT)
        {
            TiXmlElement* elem = cur->ToElement();
            if (hasNodeName(elem, "map"))
            {
                scene->addMap(getAttributeValueAsStdString(elem, "file"));
            }
        }
    }

    delete doc;

    return scene;
}
Exemple #14
0
bool WSWorld::init()
{
	m_worldPopulation = 0;
	if( !loadTerrain( WSApp::instance()->getSetting("/config/WorldCfg")) )
		return false;

	TiXmlDocument	doc;
	CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlInfo,__FUNCTION__, _("Loading mobs info..."));
	doc.LoadFile("../data/zones/teeran/mobs.xml");
	if (doc.Error())
	{
		CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlError,__FUNCTION__, _("XML parser returned an error: %s\n"), doc.ErrorDesc());
		return false;
	}


	TiXmlElement* mobsxml = doc.FirstChildElement("mobs");
	CWorldCharMob::setDefaults(mobsxml);

	TiXmlNode* childNode;
	for ( childNode = mobsxml->FirstChild(); childNode != 0; childNode = childNode->NextSibling() )
		if (childNode->Type() == TiXmlNode::ELEMENT)
			if (!strcmp(childNode->Value(), "mob"))
//			{
				insertEntity(WSEntityPtr(new CWorldCharMob(getNewEntityID(), childNode->ToElement())));
//			 	CharMobPtr mob(new CWorldCharMob(childNode->ToElement()));
//				insertCharMob(mob);
//			}
			else if (!strcmp(childNode->Value(), "flock"))
//			{
				insertEntity(WSEntityPtr(new CMobFlock(getNewEntityID(), childNode->ToElement())));
//				MobFlockPtr flock(new CMobFlock(childNode->ToElement()));
//				m_flocks.push_back(flock);
//			}

	CLog::instance()->log(CLog::msgFlagResources, CLog::msgLvlInfo,__FUNCTION__, _("WSWorld.init: Done."));
	return true;
};
void CLocalPathBrowser::SetResPkgFindPath()
{
	char* aliasArray[] = {"cfg","gui","res","lan","shd"};
	int num = sizeof(aliasArray)/sizeof(char*);

	list<string> lstPath;

	//载入配置文件
	CEditorConfig::GetInst()->InitEditorConfig();

	//加入PathBrowser里面设置的路径
	TiXmlNode* pConfig_xml = CEditorConfig::GetInst()->GetEditorConfig(st_szCtrlType);
	for( TiXmlNode* pNode = pConfig_xml->FirstChild("Path"); pNode; pNode = pNode->NextSibling("Path") )
	{
		TiXmlElement* pElem  = pNode->ToElement();
		if(pElem && pElem->GetText())
		{
			string strText = pElem->GetText();
			lstPath.push_back(strText);
		}
	}

	//lstPath.push_back("F:/company/ybtx/artist/resbin");
	for ( list<string>::iterator iter = lstPath.begin(); iter != lstPath.end(); ++iter )
	{
		for (int i=0;i<num;++i)
		{
			string path = *iter;
			string pathLan = *iter + "/lang";
			string pathRes = *iter + "/res";
			string strTemp = aliasArray[i];
			wstring wstrTemp = gbk_to_utf16(strTemp);
			CPkgFile::AddLoadPath(wstrTemp.c_str(), gbk_to_utf16(path).c_str());
			CPkgFile::AddLoadPath(wstrTemp.c_str(), gbk_to_utf16(pathLan).c_str());
			CPkgFile::AddLoadPath(wstrTemp.c_str(), gbk_to_utf16(pathRes).c_str());
		}
	}
}
void
XmlPrototypesFile::LoadPrototypes()
{
    TiXmlNode* node = m_File.RootElement();

    if( node == NULL || node->ValueStr() != "prototypes" )
    {
        LOG_ERROR( "UI Manager: " + m_File.ValueStr() + " is not a valid prototypes file! No <prototypes> in root." );
        return;
    }

    node = node->FirstChild();
    while( node != NULL )
    {
        if( node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "prototype" )
        {
            Ogre::String name = GetString( node, "name" );
            UiManager::getSingleton().AddPrototype( name, node->Clone() );
        }

        node = node->NextSibling();
    }
}
Exemple #17
0
void CXmlConfig::AttribSet(const char* szParElemName1,const char* szParElemName2, size_t parElemName2Index, const char* szChildElemName, const vector<string>& vecAttribValueName, const vector<string>& vecAttribValueValue)
{
	vector<const char*> vecParElemNames;
	vecParElemNames.push_back( szParElemName1 );
	vecParElemNames.push_back( szParElemName2 );
	TiXmlNode *pParentNode = this->GetNode(vecParElemNames, false);
	if( pParentNode == NULL )
		pParentNode = m_pRoot;

	for ( size_t i = 0; i< parElemName2Index; ++i )
		pParentNode = pParentNode->NextSibling(szParElemName2);

	TiXmlElement *pSetElement = new TiXmlElement(szChildElemName);
	pParentNode->LinkEndChild(pSetElement);

	size_t size = vecAttribValueName.size();
	for (size_t i = 0; i < size; ++i )
	{
		string name  = vecAttribValueName[i];
		string value = vecAttribValueValue[i];
		pSetElement->SetAttribute(name.c_str(), value.c_str());
	}
}
std::vector<Shader*> MaterialManager::loadShadersFromFile(String fileName) {
	std::vector<Shader*> retVector;
	
	TiXmlDocument doc(fileName.c_str());
	doc.LoadFile();
	
	if(doc.Error()) {
		Logger::log("XML Error: %s\n", doc.ErrorDesc());
	} else {
		TiXmlElement *mElem = doc.RootElement()->FirstChildElement("shaders");
		if(mElem) {
			TiXmlNode* pChild;					
			for (pChild = mElem->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {	
				Shader *newShader = createShaderFromXMLNode(pChild);
				if(newShader != NULL) {
					Logger::log("Adding shader %s\n", newShader->getName().c_str());
					retVector.push_back(newShader);
				}
			}
		}
	}
	return retVector;
}
Exemple #19
0
void CUIDesignerView::CopyUI(TiXmlElement* pParentNode)
{
	ASSERT(pParentNode);
	CArray<CControlUI*,CControlUI*> arrSelected;
	TiXmlElement* pContainerNode = new TiXmlElement("Container");

	m_MultiTracker.GetSelected(arrSelected);

	TiXmlNode* pNode;
	for(int i=0; i<arrSelected.GetSize(); i++)
	{
		m_LayoutManager.SaveProperties(arrSelected[i], pContainerNode);

		if(i == 0)
			pNode = pContainerNode->FirstChild();
		else
			pNode = pNode->NextSibling();
		pNode->ToElement()->RemoveAttribute("name");
	}

	pParentNode->InsertEndChild(*pContainerNode);
	delete pContainerNode;
}
Exemple #20
0
CUICommandElement::CUICommandElement(CArray<CControlUI*,CControlUI*>& arrSelected, BOOL bModify)
	: m_pElementXml(NULL)
{
	TiXmlNode* pNode;
	m_pElementXml = new TiXmlElement("UIHistory");
	for(int i=0; i<arrSelected.GetSize(); i++)
	{
		CLayoutManager::SaveProperties(arrSelected[i], m_pElementXml, !bModify);

		if(i == 0)
			pNode = m_pElementXml->FirstChild();
		else
			pNode = pNode->NextSibling();

		CControlUI* pControl = arrSelected[i];
		ASSERT(pNode && pControl);
		pNode->ToElement()->SetAttribute("myname", StringConvertor::WideToUtf8(pControl->GetName()));

		CControlUI* pParent = arrSelected[i]->GetParent();
		ASSERT(pNode && pParent);
		pNode->ToElement()->SetAttribute("parentname", StringConvertor::WideToUtf8(pParent->GetName()));
	}
}
Exemple #21
0
void CXMLConfig::processTinyXMLOutput(TiXmlNode* node, String path, bool useAsDefault)
{
	if ( !node ) return;

	switch ( node->Type() )
	{
	case TiXmlNode::DOCUMENT:
		rmTrailingSlash(path);
		break;

	case TiXmlNode::TEXT:
		rmTrailingSlash(path);
		appendValue(path, node->ToText()->Value(), useAsDefault);
		break;

	default:
		break;
	}

	TiXmlNode* childNode;
	for ( childNode = node->FirstChild(); childNode != 0; childNode = childNode->NextSibling() )
		processTinyXMLOutput(childNode, path + String(node->Value()) + '/', useAsDefault);
}
std::vector<Material*> MaterialManager::loadMaterialsFromFile(String fileName) {
	std::vector<Material*> retVector;
	
	TiXmlDocument doc(fileName.c_str());
	doc.LoadFile();
	
	if(doc.Error()) {
		Logger::log("XML Error: %s\n", doc.ErrorDesc());
	} else {
		TiXmlElement *mElem = doc.RootElement()->FirstChildElement("materials");
		if(mElem) {
			TiXmlNode* pChild;					
			for (pChild = mElem->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
				Material *newMat = materialFromXMLNode(pChild);
				if (newMat) {
					retVector.push_back(newMat);
				}
			}
		}
	}
	
	return retVector;
}
void TiXmlElement::Print( FILE* fp, int depth )
{
	int i;
	for ( i=0; i<depth; i++ )
		fprintf( fp, "    " );

	fprintf( fp, "<%s", value.c_str() );

	TiXmlAttribute* attrib;
	for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
	{	
		fprintf( fp, " " );
		attrib->Print( fp, 0 );
	}
	// If this node has children, give it a closing tag. Else
	// make it an empty tag.
	TiXmlNode* node;
	if ( firstChild )
	{ 		
		fprintf( fp, ">" );

		for ( node = firstChild; node; node=node->NextSibling() )
		{
	 		if ( !node->ToText() )
				fprintf( fp, "\n" );
			node->Print( fp, depth+1 );
		}
 		fprintf( fp, "\n" );
		for ( i=0; i<depth; i++ )
			fprintf( fp, "    " );
		fprintf( fp, "</%s>", value.c_str() );
	}
	else
	{
		fprintf( fp, " />" );
	}
}
/***********************************************************************************************************
 * 程序作者:赵进军
 * 函数功能:获取 XML文件所有的数据
 * 参数说明:null
 * 注意事项:null
 * 修改日期:2015/12/14 23:10:00
 ***********************************************************************************************************/
void OperationProfile_XML::GetXmlDataAll(TiXmlNode* pRootEle, char* groupName)
{
	if (NULL == pRootEle)
		return;

	TiXmlNode* pElement = pRootEle->FirstChild();
	TiXmlElement* element;
	TiXmlAttribute* attr;
	int kl;
	for (; pElement; pElement = pElement->NextSibling())
	{
		int nType = pElement->Type();
		switch (nType)
		{
		case TiXmlNode::TINYXML_ELEMENT:
			element = pElement->ToElement();
			if (element != NULL)
			{
				attr = element->FirstAttribute();
				if (attr != NULL)
					std::cout << attr->Value() << std::endl;
			}
			GetXmlDataAll(pElement, groupName);
			break;

		case TiXmlNode::TINYXML_TEXT:
			std::cout << pElement->Value() << std::endl;
			break;

		case TiXmlNode::TINYXML_DOCUMENT:
			kl = 0;
			break;
		default:
			break;
		}
	}
}
bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)
{
    TiXmlDocument *pXmlDocProject = new TiXmlDocument(projectFileName);
    bool loadOkay = pXmlDocProject->LoadFile();
    if (!loadOkay)
        return false;

    TiXmlNode *root = pXmlDocProject->FirstChild(TEXT("NotepadPlus"));
    if (!root)
        return false;


    TiXmlNode *childNode = root->FirstChildElement(TEXT("Project"));
    if (!childNode)
        return false;

    if (!::PathFileExists(projectFileName))
        return false;

    _treeView.removeAllItems();
    _workSpaceFilePath = projectFileName;

    NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
    generic_string workspace = pNativeSpeaker->getAttrNameStr(PM_WORKSPACEROOTNAME, "ProjectManager", "WorkspaceRootName");
    HTREEITEM rootItem = _treeView.addItem(workspace.c_str(), TVI_ROOT, INDEX_CLEAN_ROOT);

    for ( ; childNode ; childNode = childNode->NextSibling(TEXT("Project")))
    {
        HTREEITEM projectItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), rootItem, INDEX_PROJECT);
        buildTreeFrom(childNode, projectItem);
    }
    setWorkSpaceDirty(false);
    _treeView.expand(rootItem);

    delete pXmlDocProject;
    return loadOkay;
}
Exemple #26
0
	void XmlParser::IterateTags( TiXmlNode* pParent )
	{
		if ( !pParent ) return;

		TiXmlNode* pChild;
		int t = pParent->Type();

		switch ( t )
		{
		case TiXmlNode::TINYXML_ELEMENT:
			OnXmlElement(pParent->ToElement());
			break;
		case TiXmlNode::TINYXML_TEXT:
			OnXmlText(pParent->ToText());
			break;

		default:
			break;
		}
		for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) 
		{
			IterateTags( pChild);
		}
	}
TiXmlNode* TiXmlElement::Clone() const
{
	TiXmlElement* clone = new TiXmlElement( Value() );
	if ( !clone )
		return 0;

	CopyToClone( clone );

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

	TiXmlNode* node = 0;
	for ( node = firstChild; node; node = node->NextSibling() )
	{
		clone->LinkEndChild( node->Clone() );
	}
	return clone;
}
Exemple #28
0
void StaticObject::Deserialize(TiXmlElement* root)
{
    World* world = World::GetPtr();
    TiXmlNode* node = NULL;
    TiXmlElement* cmeta = NULL;
    TiXmlElement* components = NULL;
    IComponentMeta* com = NULL;
    std::string cname;

    _short = root->Attribute("short");
    _plural = root->Attribute("plural");
    node = root->FirstChild("components");
    if (node)
        {
            components = node->ToElement();
            for (node = components->FirstChild(); node; node = node->NextSibling())
                {
                    cmeta = node->ToElement();
                    cname = cmeta->Attribute("name");
                    com = world->GetComponentFactory()->GetMeta(cname);
                    com->Deserialize(cmeta);
                }
        }
}
Exemple #29
0
	void Folder::Init(TiXmlNode *node)
	{
		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;

			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				mId= intValue;


			mName = element->Attribute("name");

			for (TiXmlNode* fileNode = node->FirstChild(); fileNode; fileNode = fileNode->NextSibling())
			{
				File *file = new File();
				file->Init(fileNode);

				mFiles.push_back(file);
			}

		}

	}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool XmlElementImpl::setValueText(const String& text)
{
    TiXmlText* pText = NULL;
    TiXmlNode* pNode = NULL;
    for (pNode = FirstChild(); pNode; pNode = pNode->NextSibling())
    {
        pText = pNode->ToText();
        if (pText) break;
    }

    cvf::CharArray charArr = text.toUtf8();

    if (pText) 
    {
       pText->SetValue(charArr.ptr());
    }
    else
    {
        pText = new TiXmlText(charArr.ptr());
        LinkEndChild(pText);
    }

    return true;
}