本文整理汇总了C++中TiXmlNode::LinkEndChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::LinkEndChild方法的具体用法?C++ TiXmlNode::LinkEndChild怎么用?C++ TiXmlNode::LinkEndChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::LinkEndChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddUserInfoToCrashDescriptorXML
void CMainDlg::AddUserInfoToCrashDescriptorXML(CString sEmail, CString sDesc)
{
strconv_t strconv;
TiXmlDocument doc;
CString sFileName = g_CrashInfo.m_sErrorReportDirName + _T("\\crashrpt.xml");
bool bLoad = doc.LoadFile(strconv.t2a(sFileName.GetBuffer(0)));
if(!bLoad)
return;
TiXmlNode* root = doc.FirstChild("CrashRpt");
if(!root)
return;
// Write user e-mail
TiXmlElement* email = new TiXmlElement("UserEmail");
root->LinkEndChild(email);
LPCSTR lpszEmail = strconv.t2a(sEmail.GetBuffer(0));
TiXmlText* email_text = new TiXmlText(lpszEmail);
email->LinkEndChild(email_text);
// Write problem description
TiXmlElement* desc = new TiXmlElement("ProblemDescription");
root->LinkEndChild(desc);
LPCSTR lpszDesc = strconv.t2a(sDesc.GetBuffer(0));
TiXmlText* desc_text = new TiXmlText(lpszDesc);
desc->LinkEndChild(desc_text);
doc.SaveFile();
}
示例2: set_value
void XMLConfiguration::set_value(const string& section, const string& object, const string& value)
{
bool section_found = false;
bool object_found = false;
TiXmlNode* child = 0;
TiXmlNode* nephew = 0;
if(m_document->NoChildren()==false)
{
while((!section_found) && ( child = m_document->IterateChildren( child ) ))
{
if(string(child->Value())==section)
{
section_found = true;
}
}
}
if(section_found == false)
{
LOG_INFO("XMLConfiguration: no section "<<section<<" found, creating.");
child = new TiXmlElement( section.c_str() );
m_document->LinkEndChild( child );
}
if(child->NoChildren()==false)
{
while((!object_found) &&( nephew = child->IterateChildren( nephew ) ))
{
if(string(nephew->Value())==object)
{
object_found = true;
}
}
}
if(object_found == false)
{
LOG_INFO("XMLConfiguration: no object "<<section<<"/"<<object<<" found, creating.");
nephew = new TiXmlElement( object.c_str() );
child->LinkEndChild( nephew );
}
nephew->Clear();
TiXmlText* text_element = new TiXmlText( value.c_str() );
nephew->LinkEndChild( text_element );
}
示例3: AddUserInfoToCrashDescriptorXML
void CMainDlg::AddUserInfoToCrashDescriptorXML(CString sEmail, CString sDesc)
{
USES_CONVERSION;
HZIP hz = CreateZip(m_sZipName, NULL);
TStrStrMap::iterator cur = m_pUDFiles.begin();
unsigned int i;
for (i = 0; i < m_pUDFiles.size(); i++, cur++)
{
CString sFileName = cur->first.c_str();
sFileName = sFileName.Mid(sFileName.ReverseFind('\\')+1);
if(sFileName.CompareNoCase(_T("crashrpt.xml"))==0)
{
TiXmlDocument doc;
bool bLoad = doc.LoadFile(cur->first.c_str());
if(!bLoad)
return;
TiXmlNode* root = doc.FirstChild("CrashRpt");
if(!root)
return;
// Write user e-mail
TiXmlElement* email = new TiXmlElement("UserEmail");
root->LinkEndChild(email);
LPSTR lpszEmail = T2A(sEmail.GetBuffer(0));
TiXmlText* email_text = new TiXmlText(lpszEmail);
email->LinkEndChild(email_text);
// Write problem description
TiXmlElement* desc = new TiXmlElement("ProblemDescription");
root->LinkEndChild(desc);
LPSTR lpszDesc = T2A(sDesc.GetBuffer(0));
TiXmlText* desc_text = new TiXmlText(lpszDesc);
desc->LinkEndChild(desc_text);
doc.SaveFile();
}
LPTSTR lptszFilePath = A2T((char*)cur->first.c_str());
ZRESULT zr = ZipAdd(hz, sFileName, lptszFilePath);
ATLASSERT(zr==ZR_OK);
zr;
}
CloseZip(hz);
}
示例4: WriteToXml
void WriteToXml(string& strXml, vector<bool>& vecType,string& FileName)
{
COriFileOperate oriFile(FileName);
size_t nVecSize = vecType.size();
if (strXml.find("chinese_simple") != -1)
{
for (size_t i=1;i<nVecSize;++i)
{
vecType[i] = false;
}
}
char* szNumOrStrInfo = new char[nVecSize+1];
for (size_t i = 0; i < nVecSize; i++)
{
if (vecType[i])
{
szNumOrStrInfo[i] = 'n';
}
else
{
szNumOrStrInfo[i] = 's';
}
}
szNumOrStrInfo[nVecSize] = '\0';
TiXmlDocument* pXmlDoc = new TiXmlDocument;
pXmlDoc->InsertEndChild(TiXmlElement("config"));
TiXmlNode* pXmlNode = pXmlDoc->FirstChild("config");
pXmlNode->InsertEndChild(TiXmlElement("TableType"));
TiXmlElement* pXmlElem = pXmlNode->FirstChildElement("TableType");
pXmlElem->InsertEndChild(TiXmlText("S"));
string str = szNumOrStrInfo;
string str1 = oriFile.GetDataByRowCol(0,0);
transform(str1.begin(),str1.end(),str1.begin(),toupper);
for(uint32 i=1;i<=str.size();i++)
{
TiXmlElement* cxn = new TiXmlElement("Col");
pXmlNode->LinkEndChild(cxn);
// cxn->SetAttribute("ColNum",i);
if(str1!="NOTE:")
{
cxn->SetAttribute("Name",oriFile.GetDataByRowCol(0,i-1).c_str());
}
else
{
cxn->SetAttribute("Name",oriFile.GetDataByRowCol(1,i-1).c_str());
}
string ss;
stringstream temp;
temp<<szNumOrStrInfo[i-1];
temp>>ss;
cxn->SetAttribute("Type",ss);
}
pXmlDoc->SaveFile(strXml);
delete pXmlDoc;
pXmlDoc = NULL;
delete[] szNumOrStrInfo;
szNumOrStrInfo = NULL;
}
示例5: settingsTreeToXml
/**
* Transform a StringNode to a XML node.
*
* @param node A settings tree node representing a string node.
* @param parent The parent node of the XML document.
*/
Void XmlSettingsTree::settingsTreeToXml( StringNode& node, TiXmlNode& parent ) {
TiXmlElement* element = new TiXmlElement( XMLSETTINGSTREE_STRING_ELEMENT );
TiXmlText* text = new TiXmlText( node.getValue().c_str() );
element->LinkEndChild( text );
parent.LinkEndChild( element );
}
示例6: setParameter
//----------------------------------------------------------------------------
bool XmlConfig::setParameter( const std::string& key,
const std::string& val,
const std::string& type )
{
if( !_config )
return false;
std::cout << "setParameter(key = " << key
<< ", val = " << val
<< ", type = " << type
<< ")"
<< std::endl;
//resolve parts of identifier (Renderer:FeatureX) and find in config
std::string valname;
TiXmlNode* container = parseIdentifier(key, valname, true);
if( key.length() > valname.length() + 1 )
{
std::string component_name =
key.substr(0, key.length() - valname.length() - 1);
Configurable* comp = findComponent(component_name);
if( !comp )
LOG_ERROR("No such component: " << component_name);
else
comp->setParameter(valname, val, type);
}
//check if exists
TiXmlNode* node = container->FirstChild(valname);
TiXmlElement* arg = 0;
if( node )
{
arg = node->ToElement();
//check if it matches
int res = checkTypeMatch(key, arg, type);
if(res == 1)
arg->SetAttribute("type", type);
else if(res == 0)
return false;
}
else
{
//create new one
arg = new TiXmlElement( valname );
container->LinkEndChild(arg);
arg->SetAttribute("type", type);
}
arg->SetAttribute("val", val);
_dirty_write = true;
saveFile(); // TODO check if multiple variables changed within small
// time window
return true;
}
示例7: ToXml
void ArchiveTemplate::ToXml(TiXmlNode& node)
{
FakeUtf8String strName = m_strName;
FakeUtf8String strParams = m_strParams;
FakeUtf8String strConfig = m_strConfig;
FakeUtf8String strFormatUID = GUID2STR(m_uidFormat);
FakeUtf8String strPluginUID = GUID2STR(m_uidPlugin);
FakeUtf8String strModuleUID = GUID2STR(m_uidModule);
node.ToElement()->SetAttribute("name", strName);
//нечего мусорить в xml
if ( !strParams.IsEmpty() )
{
TiXmlElement* xmlParams = new TiXmlElement("params");
xmlParams->LinkEndChild(new TiXmlText(strParams));
node.LinkEndChild(xmlParams);
}
if ( !strConfig.IsEmpty() )
{
TiXmlElement* xmlConfig = new TiXmlElement("config");
xmlConfig->LinkEndChild(new TiXmlText(strConfig));
node.LinkEndChild(xmlConfig);
}
TiXmlElement* xmlFormatUID = new TiXmlElement("fid");
xmlFormatUID->LinkEndChild(new TiXmlText(strFormatUID));
node.LinkEndChild(xmlFormatUID);
TiXmlElement* xmlPluginUID = new TiXmlElement("pid");
xmlPluginUID->LinkEndChild(new TiXmlText(strPluginUID));
node.LinkEndChild(xmlPluginUID);
TiXmlElement* xmlModuleUID = new TiXmlElement("mid");
xmlModuleUID->LinkEndChild(new TiXmlText(strModuleUID));
node.LinkEndChild(xmlModuleUID);
}
示例8: Set
void CXmlConfig::Set(const char* szParElemName,const char* szChildElemName, const char* szElemTexName)
{
vector<const char*> vecParElemNames;
vecParElemNames.push_back( szParElemName );
TiXmlNode *pParentNode = this->GetNode(vecParElemNames, false);
TiXmlElement *pSetElement = new TiXmlElement(szChildElemName);
TiXmlText *pElementText = new TiXmlText(szElemTexName);
pSetElement->LinkEndChild(pElementText);
pParentNode->LinkEndChild(pSetElement);
}
示例9: AttribSet
void CXmlConfig::AttribSet(const char* szParElemName,const char* szChildElemName)
{
vector<const char*> vecParElemNames;
vecParElemNames.push_back( szParElemName );
TiXmlNode *pParentNode = this->GetNode(vecParElemNames, false);
if( pParentNode == NULL )
pParentNode = m_pRoot;
TiXmlElement *pSetElement = new TiXmlElement(szChildElemName);
pParentNode->LinkEndChild(pSetElement);
}
示例10: WriteXmlNode
TiXmlNode* WriteXmlNode(const std::string& tag, const std::string& data, bool cdata)
{
TiXmlNode* node = new TiXmlElement(tag);
TiXmlText* text = new TiXmlText(data);
text->SetCDATA(cdata);
node->LinkEndChild(text);
return node;
}
示例11: tixmldocument_write
int tixmldocument_write(lua_State *L) {
TiXmlDocument *xmldoc;
TiXmlDocument_ud* xmldoc_userdata = (TiXmlDocument_ud *) luaL_checkudata(L, 1, "TiXmlDocument");
xmldoc = xmldoc_userdata->xmldoc;
const char *path = luaL_checkstring(L, 2); // path
const char *value = luaL_checkstring(L, 3); // new value
lua_pop(L, 3);
char *attr_name;
TiXmlNode *node = find_node(path, xmldoc->RootElement(), &attr_name);
if (node) {
if (attr_name) {
if (node->Type() == TiXmlNode::ELEMENT) {
TiXmlElement *elt_node = dynamic_cast<TiXmlElement *>(node);
if (elt_node->Attribute(attr_name)) {
elt_node->SetAttribute(attr_name, value);
delete attr_name;
lua_pushboolean(L, 1);
return 1;
}
}
luaL_error(L, "invalid attribute: %s", attr_name);
delete attr_name;
return 0;
} else {
TiXmlNode *n = node->FirstChild();
if (n) {
if (n->Type()==TiXmlNode::TEXT) {
n->SetValue(value);
} else {
return luaL_error(L, "%s does not point to a text node", path);
}
} else {
// create the text child
TiXmlText *new_text_node = new TiXmlText(value);
// and add it
node->LinkEndChild(new_text_node);
}
}
lua_pushboolean(L, 1);
return 1;
} else {
return luaL_error(L, "path not found: %s", path);
}
}
示例12: AddUserInfoToCrashDescriptionXML
BOOL CCrashInfoReader::AddUserInfoToCrashDescriptionXML(CString sEmail, CString sDesc)
{
strconv_t strconv;
TiXmlDocument doc;
CString sFileName = g_CrashInfo.m_Reports[0].m_sErrorReportDirName + _T("\\crashrpt.xml");
bool bLoad = doc.LoadFile(strconv.t2a(sFileName.GetBuffer(0)));
if(!bLoad)
return FALSE;
TiXmlNode* root = doc.FirstChild("CrashRpt");
if(!root)
return FALSE;
// Write user e-mail
TiXmlElement* email = new TiXmlElement("UserEmail");
root->LinkEndChild(email);
TiXmlText* email_text = new TiXmlText(strconv.t2utf8(sEmail));
email->LinkEndChild(email_text);
// Write problem description
TiXmlElement* desc = new TiXmlElement("ProblemDescription");
root->LinkEndChild(desc);
TiXmlText* desc_text = new TiXmlText(strconv.t2utf8(sDesc));
desc->LinkEndChild(desc_text);
bool bSave = doc.SaveFile();
if(!bSave)
return FALSE;
return TRUE;
}
示例13: TiXmlElement
bool Parameter::Write2XML(TiXmlNode& root)
{
TiXmlElement *elem=NULL;
if (Type==Const)
{
elem = new TiXmlElement("Parameter");
elem->SetAttribute("Type","Const");
}
else elem = root.ToElement();
if (elem==NULL) return false;
elem->SetAttribute("name",sName.c_str());
elem->SetAttribute("Sweep",bSweep);
elem->SetDoubleAttribute("value",dValue);
if (Type==Const) root.LinkEndChild(elem);
return true;
}
示例14: InsertElementIntoAnother
void GD_EXTENSION_API InsertElementIntoAnother(const std::string &refNameOfElementToAdd, const std::string &refNameOfParentElement, const std::string &refNameOfNextElement, RuntimeScene &scene)
{
TiXmlNode *parentEle = RefManager::GetInstance(&scene)->GetRef(refNameOfParentElement);
TiXmlNode *nextEle = RefManager::GetInstance(&scene)->GetRef(refNameOfNextElement);
TiXmlNode *toBeAddedEle = RefManager::GetInstance(&scene)->GetRef(refNameOfElementToAdd);
if(!nextEle || nextEle->Parent() != parentEle)
{
parentEle->LinkEndChild(toBeAddedEle);
}
else
{
TiXmlNode *insertedEle = 0;
insertedEle = parentEle->InsertBeforeChild(nextEle, *toBeAddedEle);
RefManager::GetInstance(&scene)->SetRef(refNameOfElementToAdd, insertedEle);
}
}
示例15: AddFilesToCrashDescriptionXML
BOOL CCrashInfoReader::AddFilesToCrashDescriptionXML(std::vector<FileItem> FilesToAdd)
{
strconv_t strconv;
TiXmlDocument doc;
CString sFileName = g_CrashInfo.m_Reports[0].m_sErrorReportDirName + _T("\\crashrpt.xml");
bool bLoad = doc.LoadFile(strconv.t2a(sFileName.GetBuffer(0)));
if(!bLoad)
return FALSE;
TiXmlNode* root = doc.FirstChild("CrashRpt");
if(!root)
return FALSE;
TiXmlHandle hFileItems = root->FirstChild("FileList");
if(hFileItems.ToElement()==NULL)
{
hFileItems = new TiXmlElement("FileList");
root->LinkEndChild(hFileItems.ToNode());
}
unsigned i;
for(i=0; i<FilesToAdd.size(); i++)
{
TiXmlHandle hFileItem = new TiXmlElement("FileItem");
hFileItem.ToElement()->SetAttribute("name", strconv.t2utf8(FilesToAdd[i].m_sDestFile));
hFileItem.ToElement()->SetAttribute("description", strconv.t2utf8(FilesToAdd[i].m_sDesc));
hFileItems.ToElement()->LinkEndChild(hFileItem.ToNode());
m_Reports[0].m_FileItems[FilesToAdd[i].m_sDestFile] = FilesToAdd[i];
}
bool bSave = doc.SaveFile();
if(!bSave)
return FALSE;
return TRUE;
}