本文整理汇总了C++中TiXmlNode::Parent方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::Parent方法的具体用法?C++ TiXmlNode::Parent怎么用?C++ TiXmlNode::Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::Parent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteAnElement
void GD_EXTENSION_API DeleteAnElement(const std::string &refname, RuntimeScene &scene)
{
TiXmlNode *nodeToRemove = RefManager::Get(&scene)->GetRef(refname);
if(nodeToRemove)
{
RefManager::Get(&scene)->DeleteChildRefs(refname);
if(nodeToRemove->Parent())
{
nodeToRemove->Parent()->RemoveChild(nodeToRemove);
}
RefManager::Get(&scene)->SetRef(refname, 0);
}
}
示例2:
std::string
XMLReader::getCurrentNodePath() const noexcept
{
std::vector<std::string> components;
TiXmlNode* node = this->_currentNode;
while (node != _document.get())
{
components.push_back(node->Value());
node = node->Parent();
}
std::string path;
std::size_t size = components.size();
if (size > 0)
{
for (int i = size - 1; i >= 0; i--)
{
path.append(components[i]);
if (i > 0)
{
path.append("/");
}
}
}
return path;
}
示例3: processNodeChildren
void processNodeChildren(TiXmlNode* node, Model::geometryData* dData,
Model::physicsData* pData)
{
TiXmlNode* child = NULL;
for (child = node->FirstChild(); child; child = child->NextSibling())
{
if(child->Type() == 1)
{
std::string typeName = "";
typeName = child->Parent()->Value();
if (typeName == "library_geometries")
{
extractVertices(child, dData);
}
else if (typeName == "library_physics_materials")
{
extractPhysicsMaterials(child);
}
else if (typeName == "library_physics_models")
{
extractPhysics(child, pData);
}
}
processNodeChildren(child, dData, pData);
}
}
示例4: tixmldocument_delete
int tixmldocument_delete(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
lua_pop(L, 2);
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->RemoveAttribute(attr_name);
delete attr_name;
lua_pushboolean(L, 1);
return 1;
}
}
luaL_error(L, "invalid attribute: %s", attr_name);
delete attr_name;
return 0;
} else {
node->Parent()->RemoveChild(node);
lua_pushboolean(L, 1);
return 1;
}
} else {
return luaL_error(L, "path not found: %s", path);
}
}
示例5: 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);
}
}
示例6: InsertElementIntoAnother
void GD_EXTENSION_API InsertElementIntoAnother(const gd::String &refNameOfElementToAdd, const gd::String &refNameOfParentElement, const gd::String &refNameOfNextElement, RuntimeScene &scene)
{
TiXmlNode *parentEle = RefManager::Get(&scene)->GetRef(refNameOfParentElement);
TiXmlNode *nextEle = RefManager::Get(&scene)->GetRef(refNameOfNextElement);
TiXmlNode *toBeAddedEle = RefManager::Get(&scene)->GetRef(refNameOfElementToAdd);
if ( parentEle == NULL || toBeAddedEle == NULL )
return; //These element cannot be invalid
else
{
if(!nextEle || nextEle->Parent() != parentEle)
{
parentEle->LinkEndChild(toBeAddedEle);
}
else
{
TiXmlNode *insertedEle = 0;
insertedEle = parentEle->InsertBeforeChild(nextEle, *toBeAddedEle);
RefManager::Get(&scene)->SetRef(refNameOfElementToAdd, insertedEle);
}
}
}
示例7: LoadData
bool CPlayListASX::LoadData(istream& stream)
{
CLog::Log(LOGNOTICE, "Parsing ASX");
if(stream.peek() == '[')
{
return LoadAsxIniInfo(stream);
}
else
{
CXBMCTinyXML xmlDoc;
stream >> xmlDoc;
if (xmlDoc.Error())
{
CLog::Log(LOGERROR, "Unable to parse ASX info Error: %s", xmlDoc.ErrorDesc());
return false;
}
TiXmlElement *pRootElement = xmlDoc.RootElement();
// lowercase every element
TiXmlNode *pNode = pRootElement;
TiXmlNode *pChild = NULL;
CStdString value;
value = pNode->Value();
value.ToLower();
pNode->SetValue(value);
while(pNode)
{
pChild = pNode->IterateChildren(pChild);
if(pChild)
{
if (pChild->Type() == TiXmlNode::TINYXML_ELEMENT)
{
value = pChild->Value();
value.ToLower();
pChild->SetValue(value);
TiXmlAttribute* pAttr = pChild->ToElement()->FirstAttribute();
while(pAttr)
{
value = pAttr->Name();
value.ToLower();
pAttr->SetName(value);
pAttr = pAttr->Next();
}
}
pNode = pChild;
pChild = NULL;
continue;
}
pChild = pNode;
pNode = pNode->Parent();
}
CStdString roottitle = "";
TiXmlElement *pElement = pRootElement->FirstChildElement();
while (pElement)
{
value = pElement->Value();
if (value == "title")
{
roottitle = pElement->GetText();
}
else if (value == "entry")
{
CStdString title(roottitle);
TiXmlElement *pRef = pElement->FirstChildElement("ref");
TiXmlElement *pTitle = pElement->FirstChildElement("title");
if(pTitle)
title = pTitle->GetText();
while (pRef)
{ // multiple references may apear for one entry
// duration may exist on this level too
value = pRef->Attribute("href");
if (value != "")
{
if(title.IsEmpty())
title = value;
CLog::Log(LOGINFO, "Adding element %s, %s", title.c_str(), value.c_str());
CFileItemPtr newItem(new CFileItem(title));
newItem->SetPath(value);
Add(newItem);
}
pRef = pRef->NextSiblingElement("ref");
}
}
else if (value == "entryref")
{
value = pElement->Attribute("href");
if (value != "")
{ // found an entryref, let's try loading that url
auto_ptr<CPlayList> playlist(CPlayListFactory::Create(value));
if (NULL != playlist.get())
//.........这里部分代码省略.........
示例8: CalcAllInfo
void KrEncoder::CalcAllInfo( TiXmlNode* node,
AllInfo* i,
SDL_Surface* surface )
{
TiXmlElement* ele = node->ToElement();
if ( !ele )
{
GLASSERT( 0 );
return;
}
// Walk up the tree, get information as we go.
TiXmlNode* parent = ele->Parent();
while( parent )
{
TiXmlElement* parentEle = parent->ToElement();
if ( parentEle )
{
if ( parentEle->Value() == "Definition" )
{
// i->format = FORMAT_DEF;
//
// if ( parentEle->Attribute( "filename" ) )
// i->filename = *parentEle->Attribute( "filename" );
// We need go no higher.
break;
}
else if ( parentEle->Value() == "Sprite" )
{
i->type = TYPE_SPRITE;
if ( parentEle->Attribute( "name" ) )
i->name = *parentEle->Attribute( "name" );
}
else if ( parentEle->Value() == "Action" )
{
if ( parentEle->Attribute( "name" ) )
i->action = *parentEle->Attribute( "name" );
}
else if ( parentEle->Value() == "File" )
{
// if ( parentEle->Attribute( "filename" ) )
// i->filename = *parentEle->Attribute( "filename" );
}
else if ( parentEle->Value() == "Direct" )
{
//i->format = FORMAT_DIRECT;
// Go no higher.
break;
}
}
parent = parent->Parent();
}
// Now interpret the element itself:
if ( ele->Value() == "Image" )
{
// Could be sprite or tile.
i->useEntireImage = true;
}
else if ( ele->Value() == "ColorKey" )
{
// Could be sprite on tile.
//i->useEntireImage = false;
}
else if ( ele->Value() == "Frame" )
{
i->type = TYPE_SPRITE;
}
else if ( ele->Value() == "Font" )
{
i->type = TYPE_FONT;
}
else if ( ele->Value() == "Tile" )
{
i->type = TYPE_TILE;
}
// And its attributes. They don't have different meanings in different
// tags, so they can all be read in together.
// ColorKey and Image attributes:
if ( ele->Attribute( "tile" ) )
{
GLASSERT( i->type == TYPE_NONE );
i->name = *ele->Attribute( "tile" );
i->type = TYPE_TILE;
}
if ( ele->Attribute( "sprite" ) )
{
GLASSERT( i->type == TYPE_NONE );
i->name = *ele->Attribute( "sprite" );
i->type = TYPE_SPRITE;
}
if ( ele->Attribute( "color" ) )
{
gedString c = *ele->Attribute( "color" );
i->keyColor.FromString( c.c_str() );
i->keyColor.c.alpha = KrRGBA::KR_OPAQUE; // alpha not used
//.........这里部分代码省略.........