本文整理汇总了C++中TiXmlElement::Parent方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::Parent方法的具体用法?C++ TiXmlElement::Parent怎么用?C++ TiXmlElement::Parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::Parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VisitEnter
bool XMLSceneVisitor::VisitEnter(const TiXmlElement& element, const TiXmlAttribute* attribute)
{
if(element.ValueStr() == "scene")
{
return (element.Parent() == element.GetDocument());
}
else if (element.ValueStr() == "materials")
{
return true;
}
else if (element.ValueStr() == "primitives")
{
return (element.Parent()->ValueStr() == "scene");
}
else if (element.ValueStr() == "plane")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double nx(0.0f), ny(1.0f), nz(0.0f), value(0.0f);
element.Attribute("nx", &nx);
element.Attribute("ny", &ny);
element.Attribute("nz", &nz);
element.Attribute("value", &value);
glm::vec3 normal(nx, ny, nz);
normal = glm::normalize(normal);
m_current = new Scene::Plane(normal, value);
return true;
}
else if (element.ValueStr() == "sphere")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double cx(0.0f), cy(1.0f), cz(0.0f), radius(0.0f);
element.Attribute("cx", &cx);
element.Attribute("cy", &cy);
element.Attribute("cz", &cz);
element.Attribute("radius", &radius);
glm::vec3 center(cx, cy, cz);
m_current = new Scene::Sphere(center, radius);
return true;
}
else
return false;
}
示例2: CWElementToParent
bool xmlFile::CWElementToParent()
{
if(!m_pWorkingElement)
return false;
if( m_pWorkingElement->Parent() )
{
m_pWorkingElement = (TiXmlElement*)m_pWorkingElement->Parent();
return true;
}
return false;
}
示例3: VisitExit
bool XMLSceneVisitor::VisitExit( const TiXmlElement& element)
{
if(element.ValueStr() == "scene")
{
return (element.Parent() == element.GetDocument());
}
else if (element.ValueStr() == "materials")
{
return true;
}
else if (element.ValueStr() == "primitives")
{
return true;
}
else if (element.ValueStr() == "plane")
{
m_scene->insert_primitive(m_current);
m_current = NULL;
return true;
}
else if (element.ValueStr() == "sphere")
{
m_scene->insert_primitive(m_current);
m_current = NULL;
return true;
}
else
return false;
}
示例4: xml_DelNode
/*!
* /brief 删除指定节点的值。
*
* /param XmlFile xml文件全路径。
* /param strNodeName 指定的节点名。
* /return 是否成功。true为成功,false表示失败。
*/
bool xml_DelNode(TiXmlDocument *pDoc, std::string strNodeName)
{
TiXmlElement *pRootEle = pDoc->RootElement();
if (NULL == pRootEle) {
return false;
}
TiXmlElement *pNode = NULL;
xml_GetNodePointerByName(pRootEle, strNodeName, pNode);
// 假如是根节点
if (pRootEle == pNode) {
if (pDoc->RemoveChild(pRootEle)) {
return true;
} else
return false;
}
// 假如是其它节点
if (NULL != pNode) {
TiXmlNode *pParNode = pNode->Parent();
if (NULL == pParNode) {
return false;
}
TiXmlElement* pParentEle = pParNode->ToElement();
if (NULL != pParentEle) {
if (pParentEle->RemoveChild(pNode))
return true;
else
return false;
}
} else {
return false;
}
return false;
}
示例5: deleteServerProfile
void joinNetworkGameDialogImpl::deleteServerProfile()
{
TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString());
if(!doc.LoadFile()) {
MyMessageBox::warning(this, tr("Load Server-Profile-File Error"),
tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()),
QMessageBox::Close);
} else {
TiXmlHandle docHandle( &doc );
TiXmlElement* profile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild( treeWidget->currentItem()->data(0,0).toString().toUtf8().constData() ).ToElement();
if ( profile ) {
profile->Parent()->RemoveChild(profile);
}
if(!doc.SaveFile()) {
MyMessageBox::warning(this, tr("Save Server-Profile-File Error"),
tr("Could not save server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()),
QMessageBox::Close);
}
//Liste Füllen
fillServerProfileList();
}
pushButton_delete->setDisabled(TRUE);
}
示例6: DeleteNodeByNameIndex
/***********************************************************************************************************
* 程序作者:赵进军
* 函数功能:删除XML文件中指定的节点的最后一个节点
* 参数说明:
* delNodeName:需要删除的节点的名称
* nodeIndex:需要删除的节点的位置
* 注意事项:null
* 修改日期:2015/12/12 16:49:00
***********************************************************************************************************/
bool OperationProfile_XML::DeleteNodeByNameIndex(char* delNodeName, int nodeIndex)
{
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)
{
if (myDocument->RemoveChild(pRootEle))
{
myDocument->SaveFile(IOperationProfile::ProfileAddress);
return true;
}
else
{
return false;
}
}
if (NULL != pNode)
{
TiXmlNode* pParNode = pNode->Parent();
if (NULL == pParNode)
return false;
TiXmlElement* pParentEle = pParNode->ToElement();
if (NULL != pParentEle)
{
if (pParentEle->RemoveChild(pNode))
myDocument->SaveFile(IOperationProfile::ProfileAddress);
else
return false;
}
}
else
{
return false;
}
return false;
}
示例7: RemoveItem
void XMLLanguages::RemoveItem(int id)
{
TiXmlElement* item = GetItem(id);
TiXmlNode* parent;
if(item && (parent = item->Parent()))
{
parent->RemoveChild(item);
}
}
示例8: DoLayers
static void DoLayers()
{
/* ---- */
/* Open */
/* ---- */
XML_TKEM xml( gArgs.GetXML(), flog );
TiXmlElement* layer = xml.GetFirstLayer();
/* ------------------------- */
/* Kill layers outside range */
/* ------------------------- */
TiXmlNode* lyrset = layer->Parent();
TiXmlElement* next;
for( ; layer; layer = next ) {
// next layer0 before deleting anything
next = layer->NextSiblingElement();
int z = atoi( layer->Attribute( "z" ) );
if( z < gArgs.zmin || z > gArgs.zmax )
lyrset->RemoveChild( layer );
}
/* --------------------------- */
/* Copies for remaining layers */
/* --------------------------- */
layer = lyrset->FirstChild( "t2_layer" )->ToElement();
for( ; layer; layer = layer->NextSiblingElement() ) {
int z = atoi( layer->Attribute( "z" ) );
gArgs.NewLayer( z );
UpdateTiles( layer );
}
/* ---- */
/* Save */
/* ---- */
xml.Save( "xmltmp.txt", true );
/* ------------------ */
/* Rename version two */
/* ------------------ */
gArgs.RenameXML();
}
示例9: AssertPath
TiXmlElement* ConfigManager::AssertPath(wxString& path)
{
Collapse(path);
wxString illegal(_T(" -:.\"\'$&()[]<>+#"));
size_t i = 0;
while ((i = path.find_first_of(illegal, i)) != wxString::npos)
path[i] = _T('_');
TiXmlElement *localPath = pathNode ? pathNode : root;
if (path.GetChar(0) == '/') // absolute path
{
localPath = root;
path = path.Mid(1);
}
if (path.find(_T('/')) != wxString::npos) // need for path walking
to_lower(path);
wxString sub;
while (path.find(_T('/')) != wxString::npos)
{
sub = path.BeforeFirst(_T('/'));
path = path.AfterFirst(_T('/'));
if (localPath != root && sub.IsSameAs(CfgMgrConsts::dotDot))
localPath = localPath->Parent()->ToElement();
else if (sub.GetChar(0) < _T('a') || sub.GetChar(0) > _T('z'))
{
cbThrow(InvalidNameMessage(_T("subpath"), sub, localPath));
}
else
{
TiXmlElement* n = localPath->FirstChildElement(cbU2C(sub));
if (n)
localPath = n;
else
localPath = (TiXmlElement*) localPath->InsertEndChild(TiXmlElement(cbU2C(sub)));
}
}
to_upper(path);
if (!path.IsEmpty() && (path.GetChar(0) < _T('A') || path.GetChar(0) > _T('Z')))
cbThrow(InvalidNameMessage(_T("key"), path, localPath));
return localPath;
}
示例10: GetPath
wxString ConfigManager::GetPath() const
{
TiXmlElement *e = pathNode;
wxString ret;
ret.Alloc(64);
ret = cbC2U(e->Value());
while ((e = e->Parent()->ToElement()) && e != root)
{
ret.Prepend(_T('/'));
ret.Prepend(cbC2U(e->Value()));
}
ret.Prepend(_T('/'));
return ret;
}
示例11: DeleteField
int CFieldDataXML::DeleteField(CString strFieldID)
{
if (!m_bInit)
{
if (!myDocument.LoadFile(m_strXML.GetBuffer()))
{
return ERROR_OPEN_FILE;
}
m_bInit = TRUE;
}
//获得根元素
TiXmlElement *RootElement = myDocument.RootElement();
//获得第一个field节点。
TiXmlElement *field = RootElement->FirstChildElement();
int i=0;
while(field)
{
CString strIDFind = field->Attribute("id");
if (strIDFind == strFieldID)
{
//找到了
break;
}
field = field->NextSiblingElement("field");
}
if (field)
{
//找到了
TiXmlNode *pParNode = field->Parent();
if (NULL == pParNode)
{
return ERROR_UNKNOW_ERROR;
}
TiXmlElement* pParentEle = pParNode->ToElement();
if (NULL != pParentEle)
{
if(pParentEle->RemoveChild(field))
{
myDocument.SaveFile();
}
}
}
return ERROR_OK;
}
示例12: keyset_load_key
int keyset_load_key(TiXmlHandle node, unsigned char* key, unsigned int size, int* valid)
{
TiXmlElement* elem = node.ToElement();
if (valid)
*valid = 0;
if (!elem)
return 0;
const char* text = elem->GetText();
unsigned int textlen = strlen(text);
int status = keyset_parse_key(text, textlen, key, size, valid);
if (status == KEY_ERR_LEN_MISMATCH)
{
fprintf(stderr, "Error size mismatch for key \"%s/%s\"\n", elem->Parent()->Value(), elem->Value());
return 0;
}
return 1;
}
示例13: readParameters
/*
* Attempts to read parameters from a XML file.
*
* @param element TiXmlElement to examine.
* @return true if successful, false otherwise.
*/
bool FixedLayout::readParameters(const TiXmlElement& element)
{
cerr << "Attempting to parse a layout param" << endl;
if (Layout::readParameters(element)) {
// this parameter was already handled
return true;
}
if (element.ValueStr().compare("LayoutFiles") == 0) {
nParams++;
return true;
}
/*
* Following statements exist because although the logic for reading the parameters
* contained in these elements is later in this function, the traversal of nodes
* causes this function to be called to handle the each of the elements individually.
*/
/*needed?
if (element.ValueStr().compare("A") == 0){
if(element.Parent()->ValueStr().compare("FixedLayoutParams") == 0){
return true;
}
}
if (element.ValueStr().compare("I") == 0){
if(element.Parent()->ValueStr().compare("FixedLayoutParams") == 0){
return true;
}
}
*/
/*
// Parse fixed layout (overrides random layouts)
if (element.ValueStr().compare("FixedLayoutParams") == 0) {
const TiXmlNode* pNode = NULL;
while ((pNode = element.IterateChildren(pNode)) != NULL) {
string activeNListFileName;
string inhNListFileName;
string probedNListFileName;
if (strcmp(pNode->Value(), "A") == 0) {
getValueList(pNode->ToElement()->GetText(), &m_endogenously_active_neuron_list);
num_endogenously_active_neurons = m_endogenously_active_neuron_list.size();
} else if (strcmp(pNode->Value(), "I") == 0) {
getValueList(pNode->ToElement()->GetText(), &m_inhibitory_neuron_layout);
}
else if (strcmp(pNode->Value(), "LayoutFiles") == 0)
{
if (pNode->ToElement()->QueryValueAttribute( "inhNListFileName", &inhNListFileName ) == TIXML_SUCCESS)
{
TiXmlDocument simDoc( inhNListFileName.c_str( ) );
if (!simDoc.LoadFile( ))
{
cerr << "Failed loading positions of inhibitory neurons list file " << inhNListFileName << ":" << "\n\t"
<< simDoc.ErrorDesc( ) << endl;
cerr << " error: " << simDoc.ErrorRow( ) << ", " << simDoc.ErrorCol( ) << endl;
return false;
}
TiXmlNode* temp2 = NULL;
if (( temp2 = simDoc.FirstChildElement( "I" ) ) == NULL)
{
cerr << "Could not find <I> in positons of inhibitory neurons list file " << inhNListFileName << endl;
return false;
}
getValueList(temp2->ToElement()->GetText(), &m_inhibitory_neuron_layout);
}
if (pNode->ToElement()->QueryValueAttribute( "activeNListFileName", &activeNListFileName ) == TIXML_SUCCESS)
{
TiXmlDocument simDoc( activeNListFileName.c_str( ) );
if (!simDoc.LoadFile( ))
{
cerr << "Failed loading positions of endogenously active neurons list file " << activeNListFileName << ":" << "\n\t"
<< simDoc.ErrorDesc( ) << endl;
cerr << " error: " << simDoc.ErrorRow( ) << ", " << simDoc.ErrorCol( ) << endl;
return false;
}
TiXmlNode* temp2 = NULL;
if (( temp2 = simDoc.FirstChildElement( "A" ) ) == NULL)
{
cerr << "Could not find <A> in positons of endogenously active neurons list file " << activeNListFileName << endl;
return false;
}
getValueList(temp2->ToElement()->GetText(), &m_endogenously_active_neuron_list);
num_endogenously_active_neurons = m_endogenously_active_neuron_list.size();
}
if (pNode->ToElement()->QueryValueAttribute( "probedNListFileName", &probedNListFileName ) == TIXML_SUCCESS) {
TiXmlDocument simDoc( probedNListFileName.c_str( ) );
if (!simDoc.LoadFile( ))
{
cerr << "Failed loading positions of probed neurons list file " << probedNListFileName << ":" << "\n\t"
<< simDoc.ErrorDesc( ) << endl;
cerr << " error: " << simDoc.ErrorRow( ) << ", " << simDoc.ErrorCol( ) << endl;
return false;
}
//.........这里部分代码省略.........
示例14: OnBtnExportClick
void MainFrame::OnBtnExportClick(wxCommandEvent& event)
{
TiXmlDocument* doc = new TiXmlDocument();
if (doc)
{
if (mCfgSrcValid)
{
wxMessageBox(wxT("You are about to export the selected node(s) to a backup C::B configuration file.\n"
"Please note that this is *not* complete because it includes the selected node(s) only.\n"
"It's purpose is to backup misc. nodes for transferring them using cb_share_config."),
wxT("Information"), wxICON_INFORMATION);
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", "yes");
TiXmlElement* root = new TiXmlElement("CodeBlocksConfig");
// NOTE (Morten#1#): This has to be in sync with C::B SDK (confimanager)!
root->SetAttribute("version", 1);
doc->LinkEndChild(decl);
doc->LinkEndChild(root);
// Save all (checked) variables of lstEnvVars
int items_selected = 0;
for (int i=0; i<clbCfgSrc->GetCount(); ++i)
{
if (clbCfgSrc->IsChecked(i) && (mNodesSrc.size()>i))
{
items_selected++;
TiXmlNode* node = mNodesSrc.at(i);
wxString path = clbCfgSrc->GetString(i);
wxArrayString path_arr = PathToArray(path);
TiXmlElement* element = root;
for (size_t i=0; i<path_arr.Count(); ++i)
{
wxString section_path = path_arr.Item(i);
if (element->NoChildren())
{
// element has no children -> create new child named after section
element = (TiXmlElement*) element->InsertEndChild(
TiXmlElement(
#if wxUSE_UNICODE
section_path.mb_str(wxConvUTF8)
#else
(wxChar*)section_path.mb_str()
#endif
));
}// if
else
{
// element has children -> find child named after section
TiXmlElement* new_element = element->FirstChildElement(
#if wxUSE_UNICODE
section_path.mb_str(wxConvUTF8)
#else
(wxChar*)section_path.mb_str()
#endif
);
if (!new_element)
{
// child could not be found -> create child named after section
element = (TiXmlElement*) element->InsertEndChild(TiXmlElement(
#if wxUSE_UNICODE
section_path.mb_str(wxConvUTF8)
#else
(wxChar*)section_path.mb_str()
#endif
));
}
else
{
// child has been found -> switch to this child
element = new_element;
}
}
if (!element)
return;
// ...continue with next section.
}
TiXmlNode* parent_node = element->Parent();
parent_node->ReplaceChild(element, *node);
}
}
if (items_selected)
{
wxString filename = wxFileSelector
(
wxT("Choose a Code::Blocks backup configuration file"), // title
wxT(""), // default path
wxT("backup.conf"), // default file
wxT("*.conf"), // default extension
wxT("Code::Blocks configuration files (*.conf)|*.conf|"
"All files (*.*)|*.*"), // wildcards
wxFD_SAVE // flags
);
//.........这里部分代码省略.........
示例15: VisitEnter
bool XMLSceneVisitor::VisitEnter(const TiXmlElement& element, const TiXmlAttribute* attribute)
{
if(element.ValueStr() == "scene")
{
return (element.Parent() == element.GetDocument());
}
else if (element.ValueStr() == "materials")
{
return true;
}
else if (element.ValueStr() == "primitives")
{
return (element.Parent()->ValueStr() == "scene");
}
else if (element.ValueStr() == "plane")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double nx(0.0), ny(1.0), nz(0.0), value(0.0);
element.Attribute("nx", &nx);
element.Attribute("ny", &ny);
element.Attribute("nz", &nz);
element.Attribute("value", &value);
glm::vec3 normal(nx, ny, nz);
normal = glm::normalize(normal);
m_current = new Plane(normal, value);
m_current->m_ini_pos=m_current->m_pos;
return true;
}
else if (element.ValueStr() == "sphere")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double cx(0.0), cy(1.0), cz(0.0), radius(0.0);
double vx,vy,vz;
element.Attribute("cx", &cx);
element.Attribute("cy", &cy);
element.Attribute("cz", &cz);
element.Attribute("vx", &vx);
element.Attribute("vy", &vy);
element.Attribute("vz", &vz);
element.Attribute("radius", &radius);
glm::vec3 center(cx, cy, cz);
m_current = new Sphere(center, glm::vec3(vx,vy,vz),radius);
m_current->m_ini_pos=m_current->m_pos;
return true;
}
else if (element.ValueStr() == "cube")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double cx(0.0), cy(1.0), cz(0.0), hx(0.0), hy(0.0), hz(0.0);
element.Attribute("cx", &cx);
element.Attribute("cy", &cy);
element.Attribute("cz", &cz);
element.Attribute("hx", &hx);
element.Attribute("hy", &hy);
element.Attribute("hz", &hz);
glm::vec3 center(cx, cy, cz);
glm::vec3 hf_dims(hx, hy, hz);
m_current = new Cube(center, hf_dims);
m_current->m_ini_pos=m_current->m_pos;
return true;
}
else if (element.ValueStr() == "obj")
{
if(element.Parent()->ValueStr() != "primitives")
return false;
assert(m_current == NULL);
double cx(0.0), cy(1.0), cz(0.0), scale(0.0);
element.Attribute("cx", &cx);
element.Attribute("cy", &cy);
element.Attribute("cz", &cz);
element.Attribute("scale", &scale);
glm::vec3 center(cx, cy, cz);
m_current = new ObjMesh(DEFAULT_OBJ_MODEL, center, scale);
m_current->m_ini_pos=m_current->m_pos;
return true;
}
else
return false;
}