本文整理汇总了C++中TiXmlNode::InsertEndChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::InsertEndChild方法的具体用法?C++ TiXmlNode::InsertEndChild怎么用?C++ TiXmlNode::InsertEndChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::InsertEndChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
bool CArtist::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath)
{
if (!node) return false;
// we start with a <tag> tag
TiXmlElement artistElement(tag.c_str());
TiXmlNode *artist = node->InsertEndChild(artistElement);
if (!artist) return false;
XMLUtils::SetString(artist, "name", strArtist);
XMLUtils::SetString(artist, "musicBrainzArtistID", strMusicBrainzArtistID);
XMLUtils::SetStringArray(artist, "genre", genre);
XMLUtils::SetStringArray(artist, "style", styles);
XMLUtils::SetStringArray(artist, "mood", moods);
XMLUtils::SetStringArray(artist, "yearsactive", yearsActive);
XMLUtils::SetStringArray(artist, "instruments", instruments);
XMLUtils::SetString(artist, "born", strBorn);
XMLUtils::SetString(artist, "formed", strFormed);
XMLUtils::SetString(artist, "biography", strBiography);
XMLUtils::SetString(artist, "died", strDied);
XMLUtils::SetString(artist, "disbanded", strDisbanded);
if (!thumbURL.m_xml.empty())
{
CXBMCTinyXML doc;
doc.Parse(thumbURL.m_xml);
const TiXmlNode* thumb = doc.FirstChild("thumb");
while (thumb)
{
artist->InsertEndChild(*thumb);
thumb = thumb->NextSibling("thumb");
}
}
XMLUtils::SetString(artist, "path", strPath);
if (fanart.m_xml.size())
{
CXBMCTinyXML doc;
doc.Parse(fanart.m_xml);
artist->InsertEndChild(*doc.RootElement());
}
// albums
for (vector< pair<CStdString,CStdString> >::const_iterator it = discography.begin(); it != discography.end(); ++it)
{
// add a <album> tag
TiXmlElement cast("album");
TiXmlNode *node = artist->InsertEndChild(cast);
TiXmlElement title("title");
TiXmlNode *titleNode = node->InsertEndChild(title);
TiXmlText name(it->first);
titleNode->InsertEndChild(name);
TiXmlElement year("year");
TiXmlNode *yearNode = node->InsertEndChild(year);
TiXmlText name2(it->second);
yearNode->InsertEndChild(name2);
}
return true;
}
示例2: Save
bool CDisplaySettings::Save(TiXmlNode *settings) const
{
if (settings == NULL)
return false;
CSingleLock lock(m_critical);
TiXmlElement xmlRootElement("resolutions");
TiXmlNode *pRoot = settings->InsertEndChild(xmlRootElement);
if (pRoot == NULL)
return false;
// save calibrations
for (ResolutionInfos::const_iterator it = m_calibrations.begin(); it != m_calibrations.end(); ++it)
{
// Write the resolution tag
TiXmlElement resElement("resolution");
TiXmlNode *pNode = pRoot->InsertEndChild(resElement);
if (pNode == NULL)
return false;
// Now write each of the pieces of information we need...
XMLUtils::SetString(pNode, "description", it->strMode);
XMLUtils::SetInt(pNode, "subtitles", it->iSubtitles);
XMLUtils::SetFloat(pNode, "pixelratio", it->fPixelRatio);
#ifdef HAS_XRANDR
XMLUtils::SetFloat(pNode, "refreshrate", it->fRefreshRate);
XMLUtils::SetString(pNode, "output", it->strOutput);
XMLUtils::SetString(pNode, "xrandrid", it->strId);
#endif
// create the overscan child
TiXmlElement overscanElement("overscan");
TiXmlNode *pOverscanNode = pNode->InsertEndChild(overscanElement);
if (pOverscanNode == NULL)
return false;
XMLUtils::SetInt(pOverscanNode, "left", it->Overscan.left);
XMLUtils::SetInt(pOverscanNode, "top", it->Overscan.top);
XMLUtils::SetInt(pOverscanNode, "right", it->Overscan.right);
XMLUtils::SetInt(pOverscanNode, "bottom", it->Overscan.bottom);
}
return true;
}
示例3: Serialize
bool CSettingsManager::Serialize(TiXmlNode *parent) const
{
if (parent == NULL)
return false;
for (SettingMap::const_iterator it = m_settings.begin(); it != m_settings.end(); ++it)
{
if (it->second.setting->GetType() == SettingTypeAction)
continue;
std::vector<std::string> parts = StringUtils::Split(it->first, ".");
if (parts.size() != 2 || parts.at(0).empty() || parts.at(1).empty())
{
CLog::Log(LOGWARNING, "CSettingsManager: unable to save setting \"%s\"", it->first.c_str());
continue;
}
TiXmlNode *sectionNode = parent->FirstChild(parts.at(0));
if (sectionNode == NULL)
{
TiXmlElement sectionElement(parts.at(0));
sectionNode = parent->InsertEndChild(sectionElement);
if (sectionNode == NULL)
{
CLog::Log(LOGWARNING, "CSettingsManager: unable to write <%s> tag", parts.at(0).c_str());
continue;
}
}
TiXmlElement settingElement(parts.at(1));
TiXmlNode *settingNode = sectionNode->InsertEndChild(settingElement);
if (settingNode == NULL)
{
CLog::Log(LOGWARNING, "CSetting: unable to write <%s> tag in <%s>", parts.at(1).c_str(), parts.at(0).c_str());
continue;
}
TiXmlText value(it->second.setting->ToString());
settingNode->InsertEndChild(value);
}
return true;
}
示例4: LoadFromPlexMediaServer
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;
}
示例5: SetString
void XMLUtils::SetString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue)
{
TiXmlElement newElement(strTag);
TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
if (pNewNode)
{
TiXmlText value(strValue);
pNewNode->InsertEndChild(value);
}
}
示例6: nameNode
/** Changes the server's technical note
*
* The xml document should be saved after this call.
*
* \param v The new server's technical note
*
*/
void RainbruRPG::Server::xmlServerConf::setTechNote(const std::string& v){
TiXmlText nameNode(v.c_str());
TiXmlNode* childNode = root->FirstChild( "TechnicalNote" );
if (childNode){
childNode->Clear();
childNode->InsertEndChild(nameNode);
}
}
示例7: para
bool LinearParameter::Write2XML(TiXmlNode& root)
{
TiXmlElement para("Parameter");
para.SetAttribute("Type","Linear");
Parameter::Write2XML(para);
para.SetDoubleAttribute("min",dMin);
para.SetDoubleAttribute("max",dMax);
para.SetDoubleAttribute("step",dStep);
root.InsertEndChild(para);
return true;
}
示例8: SetPath
void XMLUtils::SetPath(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue)
{
TiXmlElement newElement(strTag);
newElement.SetAttribute("pathversion", path_version);
TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
if (pNewNode)
{
TiXmlText value(strValue);
pNewNode->InsertEndChild(value);
}
}
示例9: _Encode
static int _Encode( TiXmlNode *pNode, sqbind::CSqMulti *pData, int bIndexed, int nDepth = 0 )
{_STT();
if ( !pNode || !pData )
return 0;
// For each element
for ( sqbind::CSqMulti::iterator it = pData->list().begin(); it != pData->list().end(); it++ )
{
// Key name?
if ( it->first == oexT( "$" ) )
; // Ignore
else
{
// Is it just an attribute
if ( nDepth && !it->second.size() )
{
((TiXmlElement*)pNode)->SetAttribute( oexStrToMbPtr( it->first.c_str() ), oexStrToMbPtr( it->second.str().c_str() ) );
} // end else if
// Handle nested tag
else
{
TiXmlNode *pItem = oexNULL;
if ( !bIndexed )
{ if ( it->first.length() )
pItem = pNode->InsertEndChild( TiXmlElement( oexStrToMbPtr( it->first.c_str() ) ) );
} // end if
else if ( it->second.isset( oexT( "$" ) ) && it->second[ oexT( "$" ) ].str().length() )
pItem = pNode->InsertEndChild( TiXmlElement( oexStrToMbPtr( it->second[ oexT( "$" ) ].str().c_str() ) ) );
// Did we get an item?
if ( pItem )
{
// Default value?
if ( it->second.str().length() )
pItem->InsertEndChild( TiXmlText( oexStrToMbPtr( it->second.str().c_str() ) ) );
// Encode sub items
_Encode( pItem, &it->second, bIndexed, nDepth + 1 );
} // end if
} // end else if
} // end if
} // end for
return 1;
}
示例10: SaveToXML
void CWakeOnAccess::SaveToXML()
{
CXBMCTinyXML xmlDoc;
TiXmlElement xmlRootElement("onaccesswakeup");
TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
if (!pRoot) return;
XMLUtils::SetInt(pRoot, "netinittimeout", m_netinit_sec);
XMLUtils::SetInt(pRoot, "netsettletime", m_netsettle_ms);
for (EntriesVector::const_iterator i = m_entries.begin(); i != m_entries.end(); ++i)
{
TiXmlElement xmlSetting("wakeup");
TiXmlNode* pWakeUpNode = pRoot->InsertEndChild(xmlSetting);
if (pWakeUpNode)
{
XMLUtils::SetString(pWakeUpNode, "host", i->host);
XMLUtils::SetString(pWakeUpNode, "mac", i->mac);
XMLUtils::SetInt(pWakeUpNode, "pingport", i->ping_port);
XMLUtils::SetInt(pWakeUpNode, "pingmode", i->ping_mode);
XMLUtils::SetInt(pWakeUpNode, "timeout", GetTotalSeconds(i->timeout));
XMLUtils::SetInt(pWakeUpNode, "waitonline", i->wait_online1_sec);
XMLUtils::SetInt(pWakeUpNode, "waitonline2", i->wait_online2_sec);
XMLUtils::SetInt(pWakeUpNode, "waitservices", i->wait_services_sec);
}
}
for (const auto& upnp : m_UPnPServers)
{
TiXmlElement xmlSetting("upnp_map");
TiXmlNode* pUPnPNode = pRoot->InsertEndChild(xmlSetting);
if (pUPnPNode)
{
XMLUtils::SetString(pUPnPNode, "name", upnp.m_name);
XMLUtils::SetString(pUPnPNode, "uuid", upnp.m_uuid);
XMLUtils::SetString(pUPnPNode, "mac", upnp.m_mac);
}
}
xmlDoc.SaveFile(GetSettingFile());
}
示例11: Save
bool CArtist::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath)
{
if (!node) return false;
// we start with a <tag> tag
TiXmlElement artistElement(tag.c_str());
TiXmlNode *artist = node->InsertEndChild(artistElement);
if (!artist) return false;
XMLUtils::SetString(artist, "name", strArtist);
CStdStringArray array;
StringUtils::SplitString(strGenre, g_advancedSettings.m_musicItemSeparator,array);
for (unsigned int i=0;i<array.size();++i)
XMLUtils::SetString(artist, "genre", array[i]);
array.clear();
StringUtils::SplitString(strStyles, g_advancedSettings.m_musicItemSeparator,array);
for (unsigned int i=0;i<array.size();++i)
XMLUtils::SetString(artist, "style", array[i]);
array.clear();
StringUtils::SplitString(strMoods, g_advancedSettings.m_musicItemSeparator,array);
for (unsigned int i=0;i<array.size();++i)
XMLUtils::SetString(artist, "mood", array[i]);
array.clear();
StringUtils::SplitString(strYearsActive, g_advancedSettings.m_musicItemSeparator,array);
for (unsigned int i=0;i<array.size();++i)
XMLUtils::SetString(artist, "yearsactive", array[i]);
XMLUtils::SetString(artist, "born", strBorn);
XMLUtils::SetString(artist, "formed", strFormed);
XMLUtils::SetString(artist, "instruments", strInstruments);
XMLUtils::SetString(artist, "biography", strBiography);
XMLUtils::SetString(artist, "died", strDied);
XMLUtils::SetString(artist, "disbanded", strDisbanded);
XMLUtils::SetString(artist, "thumbs", thumbURL.m_xml);
XMLUtils::SetString(artist, "path", strPath);
if (fanart.m_xml.size())
{
TiXmlDocument doc;
doc.Parse(fanart.m_xml);
artist->InsertEndChild(*doc.RootElement());
}
// albums
for (vector< pair<CStdString,CStdString> >::const_iterator it = discography.begin(); it != discography.end(); ++it)
{
// add a <album> tag
TiXmlElement cast("album");
TiXmlNode *node = artist->InsertEndChild(cast);
TiXmlElement title("title");
TiXmlNode *titleNode = node->InsertEndChild(title);
TiXmlText name(it->first);
titleNode->InsertEndChild(name);
TiXmlElement year("year");
TiXmlNode *yearNode = node->InsertEndChild(year);
TiXmlText name2(it->second);
yearNode->InsertEndChild(name2);
}
return true;
}
示例12: addLeafNode
XBool addLeafNode(TiXmlNode &pElmParent, const char* pszNode, bool flag)
{
if (pszNode == NULL) return XFalse;
std::string text("0");
if (flag) text = "1";
TiXmlElement elmNode(pszNode);
TiXmlText elmText(text.c_str());
return !(elmNode.InsertEndChild(elmText) == NULL ||
pElmParent.InsertEndChild(elmNode) == NULL);
//if(elmNode.InsertEndChild(elmText) == NULL) return XFalse;
//if(pElmParent.InsertEndChild(elmNode) == NULL) return XFalse;
//return XTrue;
}
示例13: setAnimations
void Control::setAnimations(const std::vector< Tuple<String,String> >& eventAttr)
{
CXBMCTinyXML xmlDoc;
TiXmlElement xmlRootElement("control");
TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
if (!pRoot)
throw WindowException("TiXmlNode creation error");
std::vector<CAnimation> animations;
for (unsigned int anim = 0; anim < eventAttr.size(); anim++)
{
const Tuple<String,String>& pTuple = eventAttr[anim];
if (pTuple.GetNumValuesSet() != 2)
throw WindowException("Error unpacking tuple found in list");
const String& cEvent = pTuple.first();
const String& cAttr = pTuple.second();
TiXmlElement pNode("animation");
std::vector<std::string> attrs = StringUtils::Split(cAttr, " ");
for (std::vector<std::string>::const_iterator i = attrs.begin(); i != attrs.end(); ++i)
{
std::vector<std::string> attrs2 = StringUtils::Split(*i, "=");
if (attrs2.size() == 2)
pNode.SetAttribute(attrs2[0], attrs2[1]);
}
TiXmlText value(cEvent.c_str());
pNode.InsertEndChild(value);
pRoot->InsertEndChild(pNode);
}
const CRect animRect((float)dwPosX, (float)dwPosY, (float)dwPosX + dwWidth, (float)dwPosY + dwHeight);
LOCKGUI;
if (pGUIControl)
{
CGUIControlFactory::GetAnimations(pRoot, animRect, iParentId, animations);
pGUIControl->SetAnimations(animations);
}
}
示例14: Save
void CPasswordManager::Save() const
{
if (!m_permanentCache.size())
return;
CXBMCTinyXML doc;
TiXmlElement rootElement("passwords");
TiXmlNode *root = doc.InsertEndChild(rootElement);
if (!root)
return;
for (map<CStdString, CStdString>::const_iterator i = m_permanentCache.begin(); i != m_permanentCache.end(); ++i)
{
TiXmlElement pathElement("path");
TiXmlNode *path = root->InsertEndChild(pathElement);
XMLUtils::SetPath(path, "from", i->first);
XMLUtils::SetPath(path, "to", i->second);
}
doc.SaveFile(g_settings.GetUserDataItem("passwords.xml"));
}
示例15: Save
bool CViewStateSettings::Save(TiXmlNode *settings) const
{
if (settings == NULL)
return false;
CSingleLock lock(m_critical);
// add the <viewstates> tag
TiXmlElement xmlViewStateElement(XML_VIEWSTATESETTINGS);
TiXmlNode *pViewStateNode = settings->InsertEndChild(xmlViewStateElement);
if (pViewStateNode == NULL)
{
CLog::Log(LOGWARNING, "CViewStateSettings: could not create <viewstates> tag");
return false;
}
for (map<string, CViewState*>::const_iterator viewState = m_viewStates.begin(); viewState != m_viewStates.end(); viewState++)
{
TiXmlElement newElement(viewState->first);
TiXmlNode *pNewNode = pViewStateNode->InsertEndChild(newElement);
if (pNewNode == NULL)
continue;
XMLUtils::SetInt(pNewNode, XML_VIEWMODE, viewState->second->m_viewMode);
XMLUtils::SetInt(pNewNode, XML_SORTMETHOD, (int)viewState->second->m_sortMethod);
XMLUtils::SetInt(pNewNode, XML_SORTORDER, (int)viewState->second->m_sortOrder);
}
TiXmlNode *generalNode = settings->FirstChild(XML_GENERAL);
if (generalNode == NULL)
{
TiXmlElement generalElement(XML_GENERAL);
generalNode = settings->InsertEndChild(generalElement);
if (generalNode == NULL)
return false;
}
XMLUtils::SetInt(generalNode, XML_SETTINGLEVEL, (int)m_settingLevel);
return true;
}