本文整理汇总了C++中TiXmlElement::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::Clear方法的具体用法?C++ TiXmlElement::Clear怎么用?C++ TiXmlElement::Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadLogo
AppRet CConfReader::loadLogo(CRect &rt, int &fontSize, COLORREF &color)
{
if ( m_rootelement == NULL )
{
return Ret_ERR;
}
TiXmlElement* element = m_rootelement->FirstChildElement("logo");
AppRet ret = loadRect(element, rt);
if ( Ret_OK != ret )
{
return ret;
}
TiXmlElement* fontElement = element->FirstChildElement("font");
int r, g, b;
ret = loadFont(fontElement, r, g, b, fontSize);
if ( Ret_OK != ret )
{
return ret;
}
color = RGB(r,g,b);
if ( fontElement )
{
fontElement->Clear();
}
if (element)
{
element->Clear();
}
return Ret_OK;
}
示例2: SetXmlValue
void COptions::SetXmlValue(unsigned int nID, wxString value)
{
if (!m_pXmlFile)
return;
// No checks are made about the validity of the value, that's done in SetOption
char *utf8 = ConvUTF8(value);
if (!utf8)
return;
TiXmlElement *settings = m_pXmlFile->GetElement()->FirstChildElement("Settings");
if (!settings)
{
TiXmlNode *node = m_pXmlFile->GetElement()->LinkEndChild(new TiXmlElement("Settings"));
if (!node)
{
delete [] utf8;
return;
}
settings = node->ToElement();
if (!settings)
{
delete [] utf8;
return;
}
}
else
{
TiXmlNode *node = 0;
while ((node = settings->IterateChildren("Setting", node)))
{
TiXmlElement *setting = node->ToElement();
if (!setting)
continue;
const char *attribute = setting->Attribute("name");
if (!attribute)
continue;
if (strcmp(attribute, options[nID].name))
continue;
//setting->RemoveAttribute("type");
setting->Clear();
//setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number");
setting->LinkEndChild(new TiXmlText(utf8));
delete [] utf8;
return;
}
}
wxASSERT(options[nID].name[0]);
TiXmlElement *setting = new TiXmlElement("Setting");
setting->SetAttribute("name", options[nID].name);
//setting->SetAttribute("type", (options[nID].type == string) ? "string" : "number");
setting->LinkEndChild(new TiXmlText(utf8));
settings->LinkEndChild(setting);
delete [] utf8;
}
示例3: SaveCache
bool SData::SaveCache()
{
std::string strCacheFile;
TiXmlDocument xml_doc;
TiXmlElement *pRootElement = NULL;
TiXmlElement *pTokenElement = NULL;
strCacheFile = GetFilePath("cache.xml");
if (!xml_doc.LoadFile(strCacheFile)) {
XBMC->Log(LOG_ERROR, "failed to load \"%s\"", strCacheFile.c_str());
return false;
}
pRootElement = xml_doc.RootElement();
if (strcmp(pRootElement->Value(), "cache") != 0) {
XBMC->Log(LOG_ERROR, "invalid xml doc. root tag 'cache' not found");
return false;
}
pTokenElement = pRootElement->FirstChildElement("token");
pTokenElement->Clear();
pTokenElement->LinkEndChild(new TiXmlText(m_identity.token));
strCacheFile = GetFilePath("cache.xml");
if (!xml_doc.SaveFile(strCacheFile)) {
XBMC->Log(LOG_ERROR, "failed to save \"%s\"", strCacheFile.c_str());
return false;
}
return true;
}
示例4: SetXmlValue
void COptions::SetXmlValue(unsigned int nID, wxString const& value)
{
if (!m_pXmlFile)
return;
// No checks are made about the validity of the value, that's done in SetOption
wxScopedCharBuffer utf8 = value.utf8_str();
if (!utf8)
return;
TiXmlElement *settings = CreateSettingsXmlElement();
if (settings) {
TiXmlElement *setting = 0;
for (setting = settings->FirstChildElement("Setting"); setting; setting = setting->NextSiblingElement("Setting")) {
const char *attribute = setting->Attribute("name");
if (!attribute)
continue;
if (!strcmp(attribute, options[nID].name))
break;
}
if (setting) {
setting->Clear();
}
else {
setting = new TiXmlElement("Setting");
setting->SetAttribute("name", options[nID].name);
settings->LinkEndChild(setting);
}
setting->LinkEndChild(new TiXmlText(utf8));
}
}
示例5: CleanStorm_Clean
//路径|节点|子节点|属性
//C:\Documents and Settings\All Users\Application Data\Storm\config.xml
//localplayhist
//item
//url
//C:\Documents and Settings\Administrator\桌面\0812_195706.3gp
BOOL CSpecialApp::CleanStorm_Clean(int Itype,LPCTSTR lpcszAppPath)
{
CString strPath = lpcszAppPath;
g_regClean.ConvetPath(strPath);
CSimpleArray<CString> vec_String;
int iCount = SplitCString1(strPath,vec_String,'|');
if(iCount<2)
{
return FALSE;
}
TiXmlDocument xmlDoc;
//获得文件夹名称改变其属性
iCount = vec_String[0].ReverseFind('\\');
CString strTmp;
if (iCount>0)
{
strTmp = vec_String[0].Mid(0,iCount);
}
DWORD dwErrCode=0;
if(FALSE == SetFileAttributes(strTmp, FILE_ATTRIBUTE_NORMAL))
{
dwErrCode=GetLastError();
}
USES_CONVERSION;
FILE* lpFile = _tfopen(vec_String[0], _T("a+b"));
if ( lpFile != NULL )
{
xmlDoc.LoadFile(lpFile);
fclose(lpFile);
if ( xmlDoc.Error() == 0 )
{
OutputDebugString(_T("\n打开文件成功\n"));
TiXmlElement* rootNode = xmlDoc.RootElement();
if (rootNode !=NULL)
{
TiXmlElement* nodeGeneral = rootNode->FirstChildElement(W2A(vec_String[1]));
if ( nodeGeneral != NULL )
{
// rootNode->RemoveChild(nodeGeneral);
nodeGeneral->Clear();
xmlDoc.SaveFile(W2A(vec_String[0]));
}
}
}
}
return TRUE;
}
示例6: WriteConfiguration
void wxsProject::WriteConfiguration(TiXmlElement* element)
{
TiXmlElement* SmithElement = element->FirstChildElement("wxsmith");
if ( !m_GUI && m_Resources.empty() && m_UnknownConfig.NoChildren() && m_UnknownResources.NoChildren() )
{
// Nothing to write
if ( SmithElement )
{
element->RemoveChild(SmithElement);
}
return;
}
if ( !SmithElement )
{
SmithElement = element->InsertEndChild(TiXmlElement("wxsmith"))->ToElement();
}
SmithElement->Clear();
SmithElement->SetAttribute("version",CurrentVersionStr);
// saving GUI item
if ( m_GUI )
{
TiXmlElement* GUIElement = SmithElement->InsertEndChild(TiXmlElement("gui"))->ToElement();
GUIElement->SetAttribute("name",cbU2C(m_GUI->GetName()));
m_GUI->WriteConfig(GUIElement);
}
// saving resources
if ( !m_Resources.empty() || !m_UnknownResources.NoChildren() )
{
TiXmlElement* ResElement = SmithElement->InsertEndChild(TiXmlElement("resources"))->ToElement();
size_t Count = m_Resources.Count();
for ( size_t i=0; i<Count; i++ )
{
const wxString& Name = m_Resources[i]->GetResourceName();
const wxString& Type = m_Resources[i]->GetResourceType();
TiXmlElement* Element = ResElement->InsertEndChild(TiXmlElement(cbU2C(Type)))->ToElement();
// TODO: Check value returned from WriteConfig
m_Resources[i]->WriteConfig(Element);
Element->SetAttribute("name",cbU2C(Name));
}
// Saving all unknown resources
for ( TiXmlNode* Node = m_UnknownResources.FirstChild(); Node; Node=Node->NextSibling() )
{
SmithElement->InsertEndChild(*Node);
}
}
// Saving all unknown configuration nodes
for ( TiXmlNode* Node = m_UnknownConfig.FirstChild(); Node; Node=Node->NextSibling() )
{
SmithElement->InsertEndChild(*Node);
}
}
示例7: removeALLChild
bool xmlManager::removeALLChild(std::string parent)
{
TiXmlElement * node = getNode(parent);
if (node == NULL)
return false;
node->Clear();
return true;
}
示例8:
/** Change the database informations in the xml file
*
* \param host The hostname of the postgres server
* \param dbName The database name
* \param user The user name
* \param pwd The user password
*
*/
void RainbruRPG::Server::xmlServerConf::
setDatabase(const std::string& host,const std::string& dbName,
const std::string& user,const std::string& pwd){
TiXmlElement* childNode = root->FirstChild( "Database" )->ToElement();
if (childNode){
childNode->Clear();
childNode->SetAttribute("hostname", host.c_str());
childNode->SetAttribute("dbname", dbName.c_str());
childNode->SetAttribute("user", user.c_str());
childNode->SetAttribute("pwd", pwd.c_str());
}
}
示例9: RebuildXrcFile
bool wxsItemResData::RebuildXrcFile()
{
// First - opening file
TiXmlDocument Doc;
TiXmlElement* Resources = nullptr;
TiXmlElement* Object = nullptr;
if ( TinyXML::LoadDocument(m_XrcFileName,&Doc) )
{
Resources = Doc.FirstChildElement("resource");
}
if ( !Resources )
{
Doc.Clear();
Doc.InsertEndChild(TiXmlDeclaration("1.0","utf-8",""));
Resources = Doc.InsertEndChild(TiXmlElement("resource"))->ToElement();
Resources->SetAttribute("xmlns","http://www.wxwidgets.org/wxxrc");
}
// Searching for object representing this resource
for ( Object = Resources->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") )
{
if ( cbC2U(Object->Attribute("name")) == m_ClassName )
{
Object->Clear();
while ( Object->FirstAttribute() )
{
Object->RemoveAttribute(Object->FirstAttribute()->Name());
}
break;
}
}
if ( !Object )
{
Object = Resources->InsertEndChild(TiXmlElement("object"))->ToElement();
}
// The only things left are: to dump item into object ...
m_RootItem->XmlWrite(Object,true,false);
Object->SetAttribute("name",cbU2C(m_ClassName));
for ( int i=0; i<GetToolsCount(); i++ )
{
TiXmlElement* ToolElement = Object->InsertEndChild(TiXmlElement("object"))->ToElement();
m_Tools[i]->XmlWrite(ToolElement,true,false);
}
// ... and save back the file
return TinyXML::SaveDocument(m_XrcFileName,&Doc);
}
示例10: loadFrame
AppRet CConfReader::loadFrame(CRect &rt)
{
if ( m_rootelement == NULL )
{
return Ret_ERR;
}
TiXmlElement* element = m_rootelement->FirstChildElement("frame");
AppRet ret = loadRect(element, rt);
if (element)
{
element->Clear();
}
return ret;
}
示例11: SetMostRecentServer
void CRecentServerList::SetMostRecentServer(const CServer& server)
{
CInterProcessMutex mutex(MUTEX_MOSTRECENTSERVERS);
// Make sure list is initialized
GetMostRecentServers(false);
bool relocated = false;
for (std::list<CServer>::iterator iter = m_mostRecentServers.begin(); iter != m_mostRecentServers.end(); ++iter)
{
if (iter->EqualsNoPass(server))
{
m_mostRecentServers.erase(iter);
m_mostRecentServers.push_front(server);
relocated = true;
break;
}
}
if (!relocated)
{
m_mostRecentServers.push_front(server);
if (m_mostRecentServers.size() > 10)
m_mostRecentServers.pop_back();
}
if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2)
return;
TiXmlElement* pDocument = m_XmlFile.GetElement();
if (!pDocument)
return;
TiXmlElement* pElement = pDocument->FirstChildElement("RecentServers");
if (!pElement)
pElement = pDocument->LinkEndChild(new TiXmlElement("RecentServers"))->ToElement();
pElement->Clear();
for (std::list<CServer>::const_iterator iter = m_mostRecentServers.begin(); iter != m_mostRecentServers.end(); ++iter)
{
TiXmlElement* pServer = pElement->LinkEndChild(new TiXmlElement("Server"))->ToElement();
SetServer(pServer, *iter);
}
wxString error;
m_XmlFile.Save(&error);
}
示例12: xml_ModifyNode_Text
/*!
* /brief 修改指定节点的文本。
*
* /param XmlFile xml文件全路径。
* /param strNodeName 指定的节点名。
* /param strText 重新设定的文本的值
* /return 是否成功。true为成功,false表示失败。
*/
bool xml_ModifyNode_Text(TiXmlElement *pRootEle, std::string strNodeName,
std::string strText)
{
if (NULL == pRootEle) {
return false;
}
TiXmlElement *pNode = NULL;
xml_GetNodePointerByName(pRootEle, strNodeName, pNode);
if (NULL != pNode) {
pNode->Clear(); // 首先清除所有文本
// 然后插入文本,保存文件
TiXmlText *pValue = new TiXmlText(strText);
pNode->LinkEndChild(pValue);
return true;
} else
return false;
}
示例13: UpdateProfileIndexText
/***********************************************************************************************************
* 程序作者:赵进军
* 函数功能:更新XML文件中指定节点名的节点Text
* 参数说明:
* strNodeName:需要更新的节点指针的名称
* nodeIndex:需要更新的节点的位置
* newStr:更新后的节点的内容
* 注意事项:null
* 修改日期:2015/12/13 15:09:00
***********************************************************************************************************/
bool OperationProfile_XML::UpdateProfileIndexText(char* delNodeName, int nodeIndex, char* newStr)
{
if (nodeIndex >= groupNodeCount)
printf("当前更新的节点位置不存在!");
if (!OperationProfile_XML::XMLExits())
return false;
TiXmlDocument* myDocument = new TiXmlDocument();
if (NULL == myDocument)
return false;
myDocument->LoadFile(IOperationProfile::ProfileAddress);
TiXmlElement* pRootEle = myDocument->RootElement();
if (NULL == pRootEle)
return false;
TiXmlElement *pNode = NULL;
if (arrayIndex != 0)
arrayIndex = 0;
if (!GetNodePointerByName(pRootEle, delNodeName, pNode, nodeIndex))
return false;
if (pRootEle == pNode)
return false;
if (NULL != pNode)
{
pNode->Clear();
TiXmlText *AgeContent = new TiXmlText(newStr);
if (pNode->LinkEndChild(AgeContent))
{
myDocument->SaveFile(IOperationProfile::ProfileAddress);
return true;
}
else
return false;
}
else
{
return false;
}
return false;
}
示例14: SaveCache
bool SData::SaveCache()
{
XBMC->Log(LOG_DEBUG, "%s", __FUNCTION__);
std::string strCacheFile;
bool bFailed(false);
TiXmlDocument doc;
TiXmlElement *pRootElement = NULL;
TiXmlElement *pTokenElement = NULL;
strCacheFile = Utils::GetFilePath("cache.xml");
if ((bFailed = !doc.LoadFile(strCacheFile))) {
XBMC->Log(LOG_ERROR, "%s: failed to load \"%s\"", __FUNCTION__, strCacheFile.c_str());
} else {
pRootElement = doc.RootElement();
if (!pRootElement || strcmp(pRootElement->Value(), "cache") != 0) {
XBMC->Log(LOG_ERROR, "%s: invalid xml doc. root element 'cache' not found", __FUNCTION__);
bFailed = true;
}
}
if (bFailed) {
XBMC->Log(LOG_DEBUG, "%s: creating root element 'cache'", __FUNCTION__);
pRootElement = new TiXmlElement("cache");
doc.LinkEndChild(pRootElement);
}
pTokenElement = pRootElement->FirstChildElement("token");
if (!pTokenElement) {
pTokenElement = new TiXmlElement("token");
pRootElement->LinkEndChild(pTokenElement);
}
pTokenElement->Clear();
if (m_profile.store_auth_data_on_stb)
pTokenElement->LinkEndChild(new TiXmlText(m_identity.token));
if (!doc.SaveFile(strCacheFile)) {
XBMC->Log(LOG_ERROR, "%s: failed to save \"%s\"", __FUNCTION__, strCacheFile.c_str());
return false;
}
return true;
}
示例15: SetMostRecentServer
void CRecentServerList::SetMostRecentServer(const CServer& server)
{
CInterProcessMutex mutex(MUTEX_MOSTRECENTSERVERS);
// Make sure list is initialized
GetMostRecentServers(false);
bool relocated = false;
for (std::list<CServer>::iterator iter = m_mostRecentServers.begin(); iter != m_mostRecentServers.end(); iter++)
{
if (*iter == server)
{
m_mostRecentServers.erase(iter);
m_mostRecentServers.push_front(server);
relocated = true;
break;
}
}
if (!relocated)
{
m_mostRecentServers.push_front(server);
if (m_mostRecentServers.size() > 10)
m_mostRecentServers.pop_back();
}
TiXmlElement* pDocument = m_XmlFile.GetElement();
if (!pDocument)
return;
TiXmlElement* pElement = pDocument->FirstChildElement("RecentServers");
if (!pElement)
pElement = pDocument->InsertEndChild(TiXmlElement("RecentServers"))->ToElement();
pElement->Clear();
for (std::list<CServer>::const_iterator iter = m_mostRecentServers.begin(); iter != m_mostRecentServers.end(); iter++)
{
TiXmlElement* pServer = pElement->InsertEndChild(TiXmlElement("Server"))->ToElement();
SetServer(pServer, *iter);
}
wxString error;
m_XmlFile.Save(&error);
}