本文整理汇总了C++中TiXmlElement::LinkEndChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::LinkEndChild方法的具体用法?C++ TiXmlElement::LinkEndChild怎么用?C++ TiXmlElement::LinkEndChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::LinkEndChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveJobsXML
TiXmlElement* SaveJobsXML(TiXmlElement* pRoot, int buildingQualities[])
{
TiXmlElement* pJobs = new TiXmlElement("Jobs");
pRoot->LinkEndChild(pJobs);
for (int i = 0; i < NUMJOBTYPES; i++)
{
TiXmlElement* pJob = new TiXmlElement(XMLifyString(g_Brothels.m_JobManager.JobName[i]));
pJobs->LinkEndChild(pJob);
pJob->SetAttribute("Qual", buildingQualities[i]);
}
return pJobs;
}
示例2: SetSimpleExtension
void GpxWptElement::SetSimpleExtension(const wxString &name, const wxString &value)
{
//FIXME: if the extensions don't exist, we should create them
TiXmlElement * exts = FirstChildElement("extensions");
if (exts) {
TiXmlElement * ext = exts->FirstChildElement(name.ToUTF8());
if (ext)
exts->ReplaceChild(ext, GpxSimpleElement(name, value));
else
exts->LinkEndChild(new GpxSimpleElement(name, value));
}
}
示例3: AddBookmark
bool CBookmarksDialog::AddBookmark(const wxString &name, const wxString &local_dir, const CServerPath &remote_dir, bool sync)
{
if (local_dir.empty() && remote_dir.empty())
return false;
if ((local_dir.empty() || remote_dir.empty()) && sync)
return false;
CInterProcessMutex mutex(MUTEX_GLOBALBOOKMARKS);
CXmlFile file(wxGetApp().GetSettingsFile(_T("bookmarks")));
TiXmlElement* pDocument = file.Load();
if (!pDocument) {
wxString msg = file.GetError() + _T("\n\n") + _("The bookmark could not be added.");
wxMessageBoxEx(msg, _("Error loading xml file"), wxICON_ERROR);
return false;
}
TiXmlElement *pInsertBefore = 0;
TiXmlElement *pBookmark;
for (pBookmark = pDocument->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark")) {
wxString remote_dir_raw;
wxString old_name = GetTextElement(pBookmark, "Name");
if (!name.CmpNoCase(old_name)) {
wxMessageBoxEx(_("Name of bookmark already exists."), _("New bookmark"), wxICON_EXCLAMATION);
return false;
}
if (name < old_name && !pInsertBefore)
pInsertBefore = pBookmark;
}
if (pInsertBefore)
pBookmark = pDocument->InsertBeforeChild(pInsertBefore, TiXmlElement("Bookmark"))->ToElement();
else
pBookmark = pDocument->LinkEndChild(new TiXmlElement("Bookmark"))->ToElement();
AddTextElement(pBookmark, "Name", name);
if (!local_dir.empty())
AddTextElement(pBookmark, "LocalDir", local_dir);
if (!remote_dir.empty())
AddTextElement(pBookmark, "RemoteDir", remote_dir.GetSafePath());
if (sync)
AddTextElementRaw(pBookmark, "SyncBrowsing", "1");
if (!file.Save(false)) {
wxString msg = wxString::Format(_("Could not write \"%s\", the bookmark could not be added: %s"), file.GetFileName(), file.GetError());
wxMessageBoxEx(msg, _("Error writing xml file"), wxICON_ERROR);
return false;
}
return true;
}
示例4: toXmlElement
TiXmlElement* GeneticAddSpawnpointAction::toXmlElement() {
TiXmlElement* element;
element = new TiXmlElement("AddSpawnpointAction");
element->SetAttribute("Active",(int)active);
element->SetAttribute("Symetric",(int)symetric);
TiXmlElement* element2 = new TiXmlElement("Spawnpoint");
Bodypart::spawnpointToXmlElement(sp,element2);
element->LinkEndChild(element2);
return element;
};
示例5: saveMesh
/**
* Creates a mesh object in the XML structure.
**/
void IO::saveMesh(TiXmlElement *parent, Mesh *m)
{
vector<Vertex *> *vertices = m->getVertices();
vector<Face *> *faces = m->getFaces();
if (vertices->empty() && faces->empty())
return;
TiXmlElement *meshXML = new TiXmlElement("mesh");
parent->LinkEndChild(meshXML);
if (!vertices->empty())
{
TiXmlElement *vertXML = new TiXmlElement("vertices");
meshXML->LinkEndChild(vertXML);
unsigned n = vertices->size();
for (unsigned i = 0; i < n; i++)
{
Vertex *v = (*vertices)[i];
TiXmlElement *vertex = new TiXmlElement("vertex");
vertex->SetDoubleAttribute("x", v->coord.x);
vertex->SetDoubleAttribute("y", v->coord.y);
vertex->SetDoubleAttribute("u", v->texCoord.x);
vertex->SetDoubleAttribute("v", v->texCoord.y);
vertex->SetAttribute("selected", v->selected);
vertXML->LinkEndChild(vertex);
}
}
if (!faces->empty())
{
TiXmlElement *facesXML = new TiXmlElement("faces");
meshXML->LinkEndChild(facesXML);
saveFaces(facesXML, faces, vertices);
}
}
示例6: TiXmlElement
TiXmlElement *cpSpaceSerializer::createBodyElm(cpBody *body)
{
TiXmlElement *elm = new TiXmlElement("body");
CPSS_ID id;
if (delegate)
{
id = delegate->makeId(body);
delegate->writing(body, id);
}
else
id = CPSS_DEFAULT_MAKE_ID(body);
BodyMap::iterator itr = _bodyMap.find(id);
//It hasn't been written yet, so write it, but not the staticBody
if (itr == _bodyMap.end() && body != _space->staticBody)
{
elm->LinkEndChild(createValueElm("id", id));
elm->LinkEndChild(createValueElm("mass", body->m));
elm->LinkEndChild(createValueElm("inertia", body->i));
elm->LinkEndChild(createPointElm("p", body->p));
elm->LinkEndChild(createPointElm("v", body->v));
elm->LinkEndChild(createPointElm("f", body->f));
elm->LinkEndChild(createValueElm("a", body->a));
elm->LinkEndChild(createValueElm("w", body->w));
elm->LinkEndChild(createValueElm("t", body->t));
_bodyMap[id] = body;
}
return elm;
}
示例7: AddXmlFile
bool AddXmlFile(string& szFileName, int& m_ID, sockaddr_in& m_sockaddr)
{
string m_ip = inet_ntoa(m_sockaddr.sin_addr);
string m_id = itos(m_ID);
string m_port = itos(ntohs(m_sockaddr.sin_port));
CString appPath = GetAppPath();
string seperator = "\\";
string fullPath = appPath.GetBuffer(0) + seperator+szFileName;
m_file(fullPath);
TiXmlDocument *myDocument = new TiXmlDocument(fullPath.c_str());
myDocument->LoadFile();
TiXmlElement *RootElement = myDocument->RootElement();
//创建一个元素并连接。
TiXmlElement *server = new TiXmlElement("Server");
//设置元素的属性。
server->SetAttribute("ID", m_id.c_str());
//创建ip子元素、port子元素并连接。
RootElement->LinkEndChild(server);
//创建ip子元素、port子元素并连接。
TiXmlElement *ip = new TiXmlElement("ip");
TiXmlElement *port = new TiXmlElement("port");
server->LinkEndChild(ip);
server->LinkEndChild(port);
//设置ip子元素和port子元素的内容并连接。
TiXmlText *ipContent = new TiXmlText(m_ip.c_str());
TiXmlText *portContent = new TiXmlText(m_port.c_str());
ip->LinkEndChild(ipContent);
port->LinkEndChild(portContent);
//RootElement->InsertEndChild(*server);
myDocument->SaveFile(fullPath.c_str());//保存到文件
return true;
}
示例8: saveHistory
void CConnectRemoteMachineWindow::saveHistory()
{
//创建一个XML的文档对象。
TiXmlDocument *pDocument = new TiXmlDocument();
int i = 0;
std::deque<CString>::iterator iter = m_historyCommand.begin();
TiXmlElement *rootElement = new TiXmlElement("root");
pDocument->LinkEndChild(rootElement);
for(; iter != m_historyCommand.end(); iter++)
{
char key[256] = {0};
kbe_snprintf(key, 256, "item%d", i++);
TiXmlElement *rootElementChild = new TiXmlElement(key);
rootElement->LinkEndChild(rootElementChild);
char buffer[4096] = {0};
CString strCommand = (*iter);
int len = WideCharToMultiByte(CP_ACP, 0, strCommand, strCommand.GetLength(), NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP,0, strCommand, strCommand.GetLength(), buffer, len, NULL, NULL);
buffer[len + 1] = '\0';
TiXmlText *content = new TiXmlText(buffer);
rootElementChild->LinkEndChild(content);
}
CString appPath = GetAppPath();
CString fullPath = appPath + L"\\histroycommands1.xml";
char fname[4096] = {0};
int len = WideCharToMultiByte(CP_ACP, 0, fullPath, fullPath.GetLength(), NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP,0, fullPath, fullPath.GetLength(), fname, len, NULL, NULL);
fname[len + 1] = '\0';
pDocument->SaveFile(fname);
}
示例9: saveLayouts
void CStartServerWindow::saveLayouts()
{
//创建一个XML的文档对象。
TiXmlDocument *pDocument = new TiXmlDocument();
int i = 0;
KBEUnordered_map< std::string, std::vector<LAYOUT_ITEM> >::iterator iter = layouts_.begin();
TiXmlElement *rootElement = new TiXmlElement("root");
pDocument->LinkEndChild(rootElement);
for(; iter != layouts_.end(); iter++)
{
std::vector<LAYOUT_ITEM>::iterator iter1 = iter->second.begin();
TiXmlElement *rootElementChild = new TiXmlElement(iter->first.c_str());
rootElement->LinkEndChild(rootElementChild);
for(; iter1 != iter->second.end(); iter1++)
{
LAYOUT_ITEM& item = (*iter1);
TiXmlElement *rootElementChild1 = new TiXmlElement(item.componentName.c_str());
rootElementChild->LinkEndChild(rootElementChild1);
TiXmlText *content = new TiXmlText(item.addr.c_str());
rootElementChild1->LinkEndChild(content);
}
}
CString appPath = GetAppPath();
CString fullPath = appPath + L"\\layouts.xml";
char fname[4096] = {0};
int len = WideCharToMultiByte(CP_ACP, 0, fullPath, fullPath.GetLength(), NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP,0, fullPath, fullPath.GetLength(), fname, len, NULL, NULL);
fname[len + 1] = '\0';
pDocument->SaveFile(fname);
}
示例10: saveSettings
void Lagom::saveSettings()
{
TiXmlDocument settings;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" );
settings.LinkEndChild( decl );
TiXmlElement * settingsData = new TiXmlElement( "Settings" );
TiXmlElement * element;
TiXmlText * text;
AttachTextElementToXML(settingsData,sPropFullscreen,_fullscreen);
AttachTextElementToXML(settingsData,sPropEndlessMode,_endless);
AttachTextElementToXML(settingsData,sPropSSAO,_SSAO);
AttachTextElementToXML(settingsData,sPropFSAA,_FSAA);
AttachTextElementToXML(settingsData,sPropXResolution,_xResolution);
AttachTextElementToXML(settingsData,sPropYResolution,_yResolution);
AttachTextElementToXML(settingsData,sPropSoundVolume,_effectVolume);
AttachTextElementToXML(settingsData,sPropMusicVolume,_musicVolume);
AttachTextElementToXML(settingsData,sPropDataFile,_dataFile);
AttachTextElementToXML(settingsData,sPropPlayerColor,_playerColor);
AttachTextElementToXML(settingsData,sPropChallengeStage,_challengeStage);
TiXmlElement * highScoresNode = new TiXmlElement(sPropHighScores);
for(auto it = _highScores.begin(); it != _highScores.end(); ++it)
{
TiXmlElement * highScore = new TiXmlElement(sPropHighScoresEntry);
highScore->SetAttribute(sPropHighScoresScore,it->_score);
highScore->SetAttribute(sPropHighScoresName,it->_name);
highScore->SetAttribute(sPropHighScoresStage,it->_stage);
highScoresNode->LinkEndChild(highScore);
}
settingsData->LinkEndChild(highScoresNode);
settings.LinkEndChild( settingsData );
settings.SaveFile( sConfigFilename );
}
示例11: SetServer
void COptions::SetServer(wxString path, const CServer& server)
{
if (!m_pXmlFile)
return;
if (path == _T(""))
return;
TiXmlElement *element = m_pXmlFile->GetElement();
while (path != _T(""))
{
wxString sub;
int pos = path.Find('/');
if (pos != -1)
{
sub = path.Left(pos);
path = path.Mid(pos + 1);
}
else
{
sub = path;
path = _T("");
}
char *utf8 = ConvUTF8(sub);
if (!utf8)
return;
TiXmlElement *newElement = element->FirstChildElement(utf8);
delete [] utf8;
if (newElement)
element = newElement;
else
{
char *utf8 = ConvUTF8(sub);
if (!utf8)
return;
TiXmlNode *node = element->LinkEndChild(new TiXmlElement(utf8));
delete [] utf8;
if (!node || !node->ToElement())
return;
element = node->ToElement();
}
}
::SetServer(element, server);
if (GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2)
return;
CInterProcessMutex mutex(MUTEX_OPTIONS);
m_pXmlFile->Save();
}
示例12: saveXml
//save tsprite data to an xml file
bool TSprite::saveXml( const std::string& savefilename ){
// if theres no source, the s[prite is invalid/incomplete.
// we simply wont write it
if( src_ == NULL ){ return 0; }
filename_ = correctFilepath(savefilename);
//xml doc
TiXmlDocument doc;
//xml header
TiXmlDeclaration *decl = new TiXmlDeclaration( "1.0", "", "" );
doc.LinkEndChild( decl );
//tileset header
TiXmlElement *root = new TiXmlElement( "TSprite" );
doc.LinkEndChild( root );
//tileset Filename
TiXmlElement *fnEl = new TiXmlElement( "Tileset" );
root->LinkEndChild( fnEl );
TiXmlText *fnText = new TiXmlText( src_->getFilename() );
fnEl->LinkEndChild( fnText );
//source dimensions
TiXmlElement *countEl = new TiXmlElement( "ImageCount" );
root->LinkEndChild( countEl );
countEl->SetAttribute("frames", numImages_);
countEl->SetAttribute("perRow", imagesPerRow_);
countEl->SetAttribute("fps", getFps());
//offsets key
TiXmlElement *offsetsEl = new TiXmlElement( "Offsets" );
root->LinkEndChild( offsetsEl );
offsetsEl->SetAttribute("x", xOffset_);
offsetsEl->SetAttribute("y", yOffset_);
return doc.SaveFile( filename_ );
}
示例13: WriteSettings
void Settings::WriteSettings()
{
XmlDocument root_doc;
TiXmlElement * root = new TiXmlElement("settings");
// audio properties
TiXmlElement * audioProps = new TiXmlElement("audio");
audioProps->SetAttribute("music_enabled", mAudioSettings.MusicOn);
audioProps->SetAttribute("sfx_enabled", mAudioSettings.SfxOn);
root->LinkEndChild(audioProps);
root_doc.Save(settingsFilename, root);
}
示例14: saveProperties
void Properties::saveProperties(char * filename) {
TiXmlDocument * doc = new TiXmlDocument(filename);
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", "");
doc->LinkEndChild(decl);
std::map<char*, char*>::iterator it = this->properties.begin();
for (; it != this->properties.end(); ++it) {
TiXmlElement * element = new TiXmlElement(it->first);
TiXmlText * element_text = new TiXmlText(it->second);
element->LinkEndChild(element_text);
doc->LinkEndChild(element);
}
doc->SaveFile();
}
示例15: Serialize
void FEPlayer::Serialize(TiXmlDocument* _poXmlDoc, TiXmlElement* _poParent)
{
TiXmlElement* poPlayerElement = new TiXmlElement("Player");
_poParent->LinkEndChild(poPlayerElement);
poPlayerElement->SetAttribute("is_movable", HasFlags(EFEFlag_Movable));
poPlayerElement->SetAttribute("is_deletable", HasFlags(EFEFlag_Deletable));
TiXmlElement* poPosElement = new TiXmlElement("Position");
poPlayerElement->LinkEndChild(poPosElement);
poPosElement->SetDoubleAttribute("x", m_vPos.x);
poPosElement->SetDoubleAttribute("y", m_vPos.y);
}