本文整理汇总了C++中xml::Node类的典型用法代码示例。如果您正苦于以下问题:C++ Node类的具体用法?C++ Node怎么用?C++ Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFirstChildElement
//--------------------------------------------------
//--------------------------------------------------
XML::Node* GetFirstChildElement(const XML::Node* in_node, const std::string& in_name)
{
const s8* nameData = nullptr;
u32 nameSize = in_name.length();
if (nameSize > 0)
{
nameData = in_name.c_str();
}
XML::Node* child = in_node->first_node(nameData, nameSize);
if (child != nullptr && child->type() == rapidxml::node_type::node_element)
{
return child;
}
else if (child != nullptr)
{
XML::Node* sibling = child;
do
{
sibling = sibling->next_sibling(nameData, nameSize);
}
while(sibling != nullptr && sibling->type() != rapidxml::node_type::node_element);
return sibling;
}
return nullptr;
}
示例2: ProtoSerialize
void CapsuleCollisionShape::ProtoSerialize(XML::Node& CurrentRoot) const
{
XML::Node CollisionNode = CurrentRoot.AppendChild(this->CapsuleCollisionShape::SerializableName());
if (!CollisionNode) { SerializeError("create CollisionNode",this->CapsuleCollisionShape::SerializableName());}
XML::Attribute Version = CollisionNode.AppendAttribute("Version");
if (Version)
{ Version.SetValue(1); }
else
{ SerializeError("Create Version Attribute", SerializableName()); }
/*
XML::Attribute RadiusAttr = CollisionNode.AppendAttribute("Radius");
if (RadiusAttr)
{ RadiusAttr.SetValue(this->GetCleanRadius()); }
else
{ SerializeError("Create RadiusAttr Attribute", SerializableName()); }
XML::Attribute HeightAttr = CollisionNode.AppendAttribute("Height");
if (HeightAttr)
{ HeightAttr.SetValue(this->GetCleanHeight()); }
else
{ SerializeError("Create HeightAttr Attribute", SerializableName()); }
*/
XML::Attribute AxisAttr = CollisionNode.AppendAttribute("Axis");
if (AxisAttr)
{ AxisAttr.SetValue(this->GetUpStandardAxis()); }
else
{ SerializeError("Create AxisAttr Attribute", SerializableName()); }
this->PrimitiveCollisionShape::ProtoSerialize(CollisionNode);
}
示例3: ProtoDeSerializeEvents
void Widget::ProtoDeSerializeEvents(const XML::Node& SelfRoot)
{
this->RemoveAllEvents();
XML::Attribute CurrAttrib;
XML::Node EventsNode = SelfRoot.GetChild( "Events" );
if( !EventsNode.Empty() ) {
if( EventsNode.GetAttribute("Version").AsInt() == 1 ) {
for( XML::NodeIterator EvNodeIt = EventsNode.begin() ; EvNodeIt != EventsNode.end() ; ++EvNodeIt )
{
if( (*EvNodeIt).GetAttribute("Version").AsInt() == 1 ) {
String EvName;
CurrAttrib = (*EvNodeIt).GetAttribute("Name");
if( !CurrAttrib.Empty() )
EvName = CurrAttrib.AsString();
if( !EvName.empty() ) {
this->AddEvent(EvName);
}
}else{
MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("Events") + ": Not Version 1.");
}
}
}else{
MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + String("Events") + ": Not Version 1.");
}
}
}
示例4: LoadAtlasFromFile
void TextureAtlasHandler::LoadAtlasFromFile(const String& Name, const String& Group)
{
/// @todo Update after we have refactored the resource system if needed.
Resource::DataStreamPtr AtlasStream = Resource::ResourceManager::GetSingletonPtr()->OpenAssetStream(Name,Group);
AtlasStream->SetStreamPosition(0);
XML::Document AtlasDoc;
AtlasDoc.Load( *AtlasStream.Get() );
XML::Node RootNode = AtlasDoc.GetChild("Atlases");
if( !RootNode.Empty() )
{
for( XML::NodeIterator AtlasIt = RootNode.begin() ; AtlasIt != RootNode.end() ; ++AtlasIt )
{
// Parse the Atlas
TextureAtlas* NewAtlas = new TextureAtlas( (*AtlasIt) );
// Verify we don't already have one of the same name
AtlasIterator AtIt = this->Atlases.find( NewAtlas->GetName() );
if( AtIt != Atlases.end() )
{
MEZZ_EXCEPTION(ExceptionBase::II_DUPLICATE_IDENTITY_EXCEPTION,"Texture Atlas with the name \"" + NewAtlas->GetName() + "\" already exists.");
}
// Add the unique Atlas
this->Atlases[NewAtlas->GetName()] = NewAtlas;
}
}else{
MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Mezzanine Texture Atlas file \"" + Name + "\"does not contain expected \"Atlases\" root node. File is not valid and cannot be parsed.");
}
}
示例5: ProtoDeSerializeCustomParameters
void ParticleAffector::ProtoDeSerializeCustomParameters(const XML::Node& SelfRoot)
{
XML::Attribute CurrAttrib;
XML::Node CustomParametersNode = SelfRoot.GetChild( ParticleAffector::GetSerializableName() + "CustomParameters" );
if( !CustomParametersNode.Empty() ) {
if(CustomParametersNode.GetAttribute("Version").AsInt() == 1) {
String ParamName, ParamValue;
for( XML::NodeIterator ParamIt = CustomParametersNode.begin() ; ParamIt != CustomParametersNode.end() ; ++ParamIt )
{
if( !(*ParamIt).Empty() ) {
if((*ParamIt).GetAttribute("Version").AsInt() == 1) {
CurrAttrib = (*ParamIt).GetAttribute("ParamName");
if( !CurrAttrib.Empty() )
ParamName = CurrAttrib.AsString();
CurrAttrib = (*ParamIt).GetAttribute("ParamValue");
if( !CurrAttrib.Empty() )
ParamValue = CurrAttrib.AsString();
if( !ParamName.empty() && !ParamValue.empty() ) {
this->SetCustomParam(ParamName,ParamValue);
}
}
}
}
}else{
MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (ParticleAffector::GetSerializableName() + "CustomParameters" ) + ": Not Version 1.");
}
}else{
MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,ParticleAffector::GetSerializableName() + "CustomParameters" + " was not found in the provided XML node, which was expected.");
}
}
示例6: childIterator
map<uint, terrainFactory> setFactories(Poco::XML::Node* node)
{
using namespace Poco;
map<uint, terrainFactory> factories;
XML::NodeIterator childIterator(node, XML::NodeFilter::SHOW_ELEMENT);
XML::Node* tileNode = childIterator.nextNode();
while (tileNode)
{
if (tileNode->nodeName() == "tile")
{
ScopedNamedNodeMap tileAttributes(tileNode->attributes());
stringstream id(tileAttributes->getNamedItem("id")->getNodeValue());
uint tileId = 0;
id >>tileId;
auto propertiesNode = tileNode->firstChild()->nextSibling();
auto propertyNode = propertiesNode->firstChild()->nextSibling();
if (propertyNode->hasAttributes())
{
ScopedNamedNodeMap attributes(propertyNode->attributes());
setFactory(factories, tileId, attributes->getNamedItem("value")->nodeValue());
}
else
{
throw FileFormatException("TMX file malformed: tile>>properties should have a child, but does not.");
}
}
tileNode = childIterator.nextNode();
}
示例7: XmlTree
void XmlTree (std::ostream & out)
{
XML::Tree tree;
XML::Node * root = tree.SetRoot ("UnitTest");
std::auto_ptr<XML::Node> child1 (new XML::Node ("child"));
child1->AddAttribute ("num", "1");
child1->AddTransformAttribute ("level", "1");
child1->AddTransformAttribute ("upperExamples",
"some upper chars: А, ▓, ├ or нт and finally Ш.");
child1->AddTransformText ("This text contains all 5 special characters:\n"
"ampersand: &, quotation mark: \", apostrophe: ', less than: < "
"and greater than char: >.");
root->AddChild (child1);
root->AddText ("This is my next child");
XML::Node * node = root->AddChild ("child");
node->AddAttribute ("num", 2);
node->AddAttribute ("level", 1);
XML::Node * grandChild = node->AddEmptyChild ("Grandchild");
grandChild->AddAttribute ("age", 2);
tree.Write (out);
XML::Node const * firstChild = *tree.GetRoot ()->FirstChild ();
out << "\n\nTransform back upper-ascii characters: "
<< firstChild->GetTransformAttribValue ("upperExamples") << std::endl;
out << "\nTransform back the text: "
<< (*firstChild->FirstChild ())->GetTransformAttribValue ("Text") << std::endl;
}
示例8: Name_
CapsuleCollisionShape::CapsuleCollisionShape(XML::Node OneNode)
{
if(OneNode.GetAttribute("Version").AsInt() == 1)
{
XML::Attribute OneName = OneNode.GetChild("PrimitiveCollisionShape").GetChild("CollisionShape").GetAttribute("Name"); // get name
if(!OneName) {
MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Could not find Name Attribute on CollsionShape Node during preparation for deserialization");
}
String Name_(OneName.AsString());
XML::Attribute Axis = OneNode.GetAttribute("Axis");
if (!Axis) {
DeSerializeError("find Axis Attribute",CapsuleCollisionShape::GetSerializableName());
}
/*
XML::Attribute Radius = OneNode.GetAttribute("Radius");
if (!Radius) { DeSerializeError("find Radius Attribute",CapsuleCollisionShape::GetSerializableName()); }
XML::Attribute Height = OneNode.GetAttribute("Height");
if (!Height) { DeSerializeError("find Height Attribute",CapsuleCollisionShape::GetSerializableName()); }
//SetPointers(new CapsuleCollisionShape(Name_,Radius.AsReal(),Height.AsReal(), (StandardAxis)Axis.AsInteger()); // make and deserialize the shape
this->Construct(Name_,Radius.AsReal(),Height.AsReal(),(StandardAxis)Axis.AsInteger());
*/
this->Construct(Name_,0,0,(StandardAxis)Axis.AsInteger());
this->ProtoDeSerialize(OneNode);
} else {
DeSerializeError("find usable serialization version",CapsuleCollisionShape::GetSerializableName());
}
}
示例9: ProtoSerialize
void NonStaticWorldObject::ProtoSerialize(XML::Node& CurrentRoot) const
{
XML::Node NonStaticWorldObjectNode = CurrentRoot.AppendChild("NonStaticWorldObject");
if (!NonStaticWorldObjectNode) { ThrowSerialError("create NonStaticWorldObjectNode");}
XML::Attribute Version = NonStaticWorldObjectNode.AppendAttribute("Version");
Version.SetValue(1);
XML::Node OrientationNode = NonStaticWorldObjectNode.AppendChild("Orientation");
if(!OrientationNode) { ThrowSerialError("create OrientationNode"); }
this->GetOrientation().ProtoSerialize(OrientationNode);
// if actor node is in scenemanager just save a name
/*if( Entresol::GetSingletonPtr()->GetSceneManager()->GetNode( this->ObjectWorldNode->GetName() ) )
{
XML::Attribute NonStaticWorldObjectNodeAttrib = NonStaticWorldObjectNode.AppendAttribute("WorldNode");
if(!NonStaticWorldObjectNodeAttrib.SetValue(this->ObjectWorldNode->GetName()))
{ThrowSerialError("store WorldNode Name");}
}else{
SloppyProtoSerialize( *(this->ObjectWorldNode),NonStaticWorldObjectNode); //Serialization performed in older style
}// */
WorldObject::ProtoSerialize(NonStaticWorldObjectNode);
}
示例10: insertTopLevelNodeBefore
void Xml::insertTopLevelNodeBefore(const Xml::node_iterator& beforeThis,
Xml::Node insertThis) {
const char* method = "Xml::insertTopLevelNodeBefore()";
// Check that the supplied Node is OK.
SimTK_ERRCHK_ALWAYS(insertThis.isValid(), method,
"The supplied Node handle was empty.");
SimTK_ERRCHK_ALWAYS(insertThis.isOrphan(), method,
"The Node was not an orphan so can't be inserted.");
SimTK_ERRCHK1_ALWAYS(Comment::isA(insertThis) || Unknown::isA(insertThis),
method, "The Node had NodeType %s, but only Comment and Unknown nodes"
" can be inserted at the topmost document level.",
insertThis.getNodeTypeAsString().c_str());
// If no iterator, add the Node to the end and we're done.
if (beforeThis == node_end()) {
updImpl().m_tixml.LinkEndChild(insertThis.updTiNodePtr());
return;
}
// There is an iterator, make sure it's a top-level one.
SimTK_ERRCHK_ALWAYS(beforeThis->isTopLevelNode(), method,
"The node_iterator did not refer to a top-level Node.");
updImpl().m_tixml.LinkBeforeChild(beforeThis->updTiNodePtr(),
insertThis.updTiNodePtr());
}
示例11: ProtoDeSerialize
void GearConstraint::ProtoDeSerialize(const XML::Node& OneNode)
{
if ( Mezzanine::String(OneNode.Name())==this->GearConstraint::SerializableName() )
{
if(OneNode.GetAttribute("Version").AsInt() == 1)
{
this->Constraint::ProtoDeSerialize(OneNode.GetChild("Constraint"));
this->SetRotationRatio(OneNode.GetAttribute("Ratio").AsReal());
XML::Node ActorANode = OneNode.GetChild("ActorA");
if(!ActorANode)
{ DeSerializeError("Could not find ActorA axis",SerializableName()); }
XML::Node ActorBNode = OneNode.GetChild("ActorB");
if(!ActorBNode)
{ DeSerializeError("Could not find ActorB axis",SerializableName()); }
Vector3 temp;
temp.ProtoDeSerialize(ActorANode.GetFirstChild());
this->SetAxisA(temp);
temp.ProtoDeSerialize(ActorBNode.GetFirstChild());
this->SetAxisB(temp);
}else{
DeSerializeError("find usable serialization version",SerializableName());
}
}else{
DeSerializeError(String("find correct class to deserialize, found a ")+OneNode.Name(),SerializableName());
}
}
示例12: ProtoSerialize
void WorldProxy::ProtoSerialize(XML::Node& ParentNode) const
{
XML::Node SelfRoot = ParentNode.AppendChild(this->GetDerivedSerializableName());
if( !SelfRoot.AppendAttribute("InWorld").SetValue( this->IsInWorld() ? "true" : "false" ) ) {
SerializeError("Create XML Attribute Values",WorldProxy::GetSerializableName(),true);
}
this->ProtoSerializeImpl(SelfRoot);
}
示例13: ProtoDeSerialize
void AreaEffect::ProtoDeSerialize(const XML::Node& OneNode)
{
if ( Mezzanine::String(OneNode.Name())==this->AreaEffect::SerializableName() )
{
if(OneNode.GetAttribute("Version").AsInt() == 1)
{
NonStaticWorldObject::ProtoDeSerialize(OneNode.GetChild(this->NonStaticWorldObject::SerializableName()));
}
}
}
示例14: ProtoSerialize
void AreaEffect::ProtoSerialize(XML::Node& CurrentRoot) const
{
XML::Node AreaEffectNode = CurrentRoot.AppendChild("AreaEffect");
if (!AreaEffectNode) { ThrowSerialError("create AreaEffectNode");}
XML::Attribute AreaEffectVersion = AreaEffectNode.AppendAttribute("Version");
AreaEffectVersion.SetValue(1);
NonStaticWorldObject::ProtoSerialize(AreaEffectNode);
}
示例15: AppendCurrentSettings
void GraphicsManager::AppendCurrentSettings(XML::Node& SettingsRootNode)
{
// Create the Group node to be returned
XML::Node CurrentSettings = SettingsRootNode.AppendChild("Current");
// Create and initialize the rendersystem settings
XML::Node RenderSystemNode = CurrentSettings.AppendChild("RenderSystem");
RenderSystemNode.AppendAttribute("Name").SetValue( this->GetShortenedRenderSystemName(CurrRenderSys) );
// Create and initialize the window configuration
for( GameWindowIterator WinIt = this->BeginGameWindow() ; WinIt != this->EndGameWindow() ; ++WinIt )
{ (*WinIt)->ProtoSerialize(CurrentSettings); }
}