Ejemplo n.º 1
0
 //--------------------------------------------------
 //--------------------------------------------------
 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;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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.");
                }
            }
        }
Ejemplo n.º 4
0
        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.");
            }
        }
Ejemplo n.º 5
0
        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.");
            }
        }
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();
	}
Ejemplo n.º 7
0
	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;
	}
Ejemplo n.º 8
0
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());
    }
}
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
Archivo: Xml.cpp Proyecto: Lemm/simbody
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());
}
Ejemplo n.º 11
0
        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());
            }
        }
Ejemplo n.º 12
0
    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);
    }
Ejemplo n.º 13
0
 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()));
         }
     }
 }
Ejemplo n.º 14
0
    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);
    }
Ejemplo n.º 15
0
 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); }
 }
Ejemplo n.º 16
0
FaerieAnimation::FaerieAnimation(Xml::Node* element)
{
	_name = Xml::GetStringAttribute(element, "name");
	_time = Xml::GetFloatAttribute(element, "time");
	Xml::Node* keyFrameXml = element->first_node("keyFrame");
	while (keyFrameXml != NULL) {
		_keyFrames.push_back(FaerieFrame(keyFrameXml));
		keyFrameXml = keyFrameXml->next_sibling("keyFrame");
	}
	CreateAnimationSplines();
}
Ejemplo n.º 17
0
        void SimpleRenderer::ProtoSerializeProperties(XML::Node& SelfRoot) const
        {
            XML::Node PropertiesNode = SelfRoot.AppendChild( SimpleRenderer::GetSerializableName() + "Properties" );

            if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
                PropertiesNode.AppendAttribute("PriAtlas").SetValue(this->PriAtlas) )
            {
                return;
            }else{
                SerializeError("Create XML Attribute Values",SimpleRenderer::GetSerializableName() + "Properties",true);
            }
        }
Ejemplo n.º 18
0
        void Widget::ProtoSerializeProperties(XML::Node& SelfRoot) const
        {
            this->QuadRenderable::ProtoSerializeProperties(SelfRoot);
            XML::Node PropertiesNode = SelfRoot.AppendChild( Widget::GetSerializableName() + "Properties" );

            if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
                PropertiesNode.AppendAttribute("State").SetValue( this->State ) )
            {
                return;
            }else{
                SerializeError("Create XML Attribute Values",Widget::GetSerializableName() + "Properties",true);
            }
        }
Ejemplo n.º 19
0
MouseEventManager::ConditionStruc MouseEventManager::getCondition (xml::Node node)
{
	const std::string button = node.getAttributeValue("button");
	const std::string modifiers = node.getAttributeValue("modifiers");
	const std::string minSelectionCount = node.getAttributeValue("minSelectionCount");

	ConditionStruc returnValue;

	returnValue.buttonId = getButtonId(button);
	returnValue.modifierFlags = _modifiers.getModifierFlags(modifiers);
	returnValue.minSelectionCount = string::toInt(minSelectionCount, DEFAULT_MIN_SELECTION_COUNT);

	return returnValue;
}
Ejemplo n.º 20
0
    void GravityWell::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
    {
        this->AreaEffect::ProtoDeSerializeProperties(SelfRoot);

        XML::Attribute CurrAttrib;
        XML::Node PropertiesNode = SelfRoot.GetChild( GravityWell::GetSerializableName() + "Properties" );

        if( !PropertiesNode.Empty() ) {
            if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                CurrAttrib = PropertiesNode.GetAttribute("AttenAmount");
                if( !CurrAttrib.Empty() )
                    this->SetAttenuationAmount( CurrAttrib.AsReal() );

                CurrAttrib = PropertiesNode.GetAttribute("AttenStyle");
                if( !CurrAttrib.Empty() )
                    this->SetAttenuationStyle( static_cast<Mezzanine::AttenuationStyle>( CurrAttrib.AsWhole() ) );

                CurrAttrib = PropertiesNode.GetAttribute("Strength");
                if( !CurrAttrib.Empty() )
                    this->SetFieldStrength( CurrAttrib.AsReal() );

                CurrAttrib = PropertiesNode.GetAttribute("AllowWorldGravity");
                if( !CurrAttrib.Empty() )
                    this->SetAllowWorldGravity( StringTools::ConvertToBool( CurrAttrib.AsString() ) );
            }else{
                MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (GravityWell::GetSerializableName() + "Properties" ) + ": Not Version 1.");
            }
        }else{
            MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,GravityWell::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
        }
    }
void FaerieAnimationsCollection::Reread() {
	Clear();
	Xml::ReadDocument doc(_filename);
	Xml::Node* rootNode = doc.first_node();
	assert(rootNode != NULL);
	Xml::Node* animationNode = rootNode->first_node("animation");
	while (animationNode != NULL) {
		FaerieAnimation* animation = new FaerieAnimation(animationNode);
		std::string animationName = animation->GetName();
		assert(_mapAnimations.find(animationName) == _mapAnimations.end());
		_mapAnimations[animationName] = animation;
		animationNode = animationNode->next_sibling("animation");
	}
}
Ejemplo n.º 22
0
    void Transform::ProtoSerialize(XML::Node& CurrentRoot) const
    {
        XML::Node TransformNode = CurrentRoot.AppendChild(SerializableName());                     // The base node all the base constraint stuff will go in
        if (!TransformNode)
            { SerializeError("Create TransformNode", SerializableName()); }

        Mezzanine::XML::Attribute Version = TransformNode.AppendAttribute("Version");                            // Version
        if (!Version)
            { SerializeError("Create Version", SerializableName()); }
        Version.SetValue(1);

        this->Location.ProtoSerialize(TransformNode);
        this->Rotation.ProtoSerialize(TransformNode);
    }
Ejemplo n.º 23
0
        void MeshCollisionShape::ProtoSerialize(XML::Node& CurrentRoot) const
        {
            XML::Node CollisionNode = CurrentRoot.AppendChild(this->MeshCollisionShape::GetSerializableName());
            if (!CollisionNode) { SerializeError("create CollisionNode",this->MeshCollisionShape::GetSerializableName());}

            XML::Attribute Version = CollisionNode.AppendAttribute("Version");
            if (Version)
                { Version.SetValue(1); }
            else
                { SerializeError("Create Version Attribute", GetSerializableName()); }

            this->CollisionShape::ProtoSerialize(CollisionNode);

        }
Ejemplo n.º 24
0
    void ActorRigid::ProtoSerialize(XML::Node& CurrentRoot) const
    {
        XML::Node ActorNode = CurrentRoot.AppendChild("ActorRigid");
        if (!ActorNode) { ThrowSerialError("create ActorRigidNode");}

        XML::Attribute Version = ActorNode.AppendAttribute("Version");
        if (Version)
            { Version.SetValue(1); }
        else
            { SerializeError("Create set Version on ActorRigid node", SerializableName()); }

        XML::Attribute ActorName = ActorNode.AppendAttribute("Name");
            ActorName.SetValue(this->GetName());
        XML::Attribute ActorFile = ActorNode.AppendAttribute("File");
            ActorFile.SetValue(this->GraphicsObject->getMesh()->getName());
        XML::Attribute ActorGroup = ActorNode.AppendAttribute("Group");
            ActorGroup.SetValue(this->GraphicsObject->getMesh()->getGroup());
        if( !(ActorName && ActorFile && ActorGroup) )
            { ThrowSerialError("creating ActorRigid Attributes");}

        XML::Node LinearMovementFactor = ActorNode.AppendChild("LinearMovementFactor");
        if (!LinearMovementFactor) { ThrowSerialError("create LinearMovementFactor Node"); }
        this->GetLinearMovementFactor().ProtoSerialize(LinearMovementFactor);

        XML::Node AngularMovementFactor = ActorNode.AppendChild("AngularMovementFactor");
        if (!AngularMovementFactor) { ThrowSerialError("create AngularMovementFactor Node"); }
        this->GetAngularMovementFactor().ProtoSerialize(AngularMovementFactor);

        ActorBase::ProtoSerialize(ActorNode);
    }
Ejemplo n.º 25
0
 void Transform::ProtoDeSerialize(const XML::Node& OneNode)
 {
     if ( Mezzanine::String(OneNode.Name())==Mezzanine::String(SerializableName()) )
     {
         if(OneNode.GetAttribute("Version").AsInt() == 1)
         {
             this->Location.ProtoDeSerialize(OneNode.GetChild("Vector3"));
             this->Rotation.ProtoDeSerialize(OneNode.GetChild("Quaternion"));
         }else{
             MEZZ_EXCEPTION(Exception::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + SerializableName() + ": Not Version 1.");
         }
     }else{
         MEZZ_EXCEPTION(Exception::II_IDENTITY_INVALID_EXCEPTION,"Attempting to deserialize a " + SerializableName() + ", found a " + String(OneNode.Name()));
     }
 }
Ejemplo n.º 26
0
	Node * Node::FindEditChildByAttrib (	std::string const & childName, 
											std::string const & attrName, 
											std::string const & attrValue)
	{
		XML::Node::ChildIter it = FirstChild ();
		XML::Node::ChildIter last = LastChild ();
		while (it != last)
		{
			XML::Node * child = *it;
			if (child->GetName () == childName && child->FindAttribValue (attrName) == attrValue)
				return child;
			++it;
		}
		return 0;
	}
Ejemplo n.º 27
0
void LevelZone::ProtoSerializeProperties(XML::Node& SelfRoot) const
{
    this->AreaEffect::ProtoSerializeProperties(SelfRoot);
    XML::Node PropertiesNode = SelfRoot.AppendChild( LevelZone::GetSerializableName() + "Properties" );

    if( PropertiesNode.AppendAttribute("Version").SetValue("1") )
    {
        XML::Node ZoneSizeNode = PropertiesNode.AppendChild("ZoneSize");
        this->ZoneSize.ProtoSerialize( ZoneSizeNode );

        return;
    }else{
        SerializeError("Create XML Attribute Values",LevelZone::GetSerializableName() + "Properties",true);
    }
}
Ejemplo n.º 28
0
void Cartridge::parse_markup_sufamiturbo(XML::Node &root) {
  if(root.exists() == false) return;
  if(mode.value != Mode::SufamiTurbo) return;

  for(auto &slot : root) {
    if(slot.name != "slot") continue;
    bool slotid = slot["id"].data == "A" ? 0 : slot["id"].data == "B" ? 1 : 0;
    for(auto &node : slot) {
      if(node.name == "rom") {
        for(auto &leaf : node) {
          if(leaf.name != "map") continue;
          Memory &memory = slotid == 0 ? sufamiturbo.slotA.rom : sufamiturbo.slotB.rom;
          Mapping m(memory);
          parse_markup_map(m, leaf);
          if(m.size == 0) m.size = memory.size();
          if(m.size) mapping.append(m);
        }
      }
      if(node.name == "ram") {
        unsigned ram_size = numeral(node["size"].data);
        for(auto &leaf : node) {
          if(leaf.name != "map") continue;
          Memory &memory = slotid == 0 ? sufamiturbo.slotA.ram : sufamiturbo.slotB.ram;
          Mapping m(memory);
          parse_markup_map(m, leaf);
          if(m.size == 0) m.size = ram_size;
          if(m.size) mapping.append(m);
        }
      }
    }
  }
}
Ejemplo n.º 29
0
void Cartridge::parse_markup_bsx(XML::Node &root) {
  if(root.exists() == false) return;
  if(mode.value != Mode::BsxSlotted && mode.value != Mode::Bsx) return;
  has_bsx_slot = true;

  for(auto &node : root["slot"]) {
    if(node.name != "map") continue;
    Mapping m(bsxflash.memory);
    parse_markup_map(m, node);
    mapping.append(m);
  }

  for(auto &node : root["mmio"]) {
    if(node.name != "map") continue;
    Mapping m({ &BSXCartridge::mmio_read, &bsxcartridge }, { &BSXCartridge::mmio_write, &bsxcartridge });
    parse_markup_map(m, node);
    mapping.append(m);
  }

  for(auto &node : root["mcu"]) {
    if(node.name != "map") continue;
    Mapping m({ &BSXCartridge::mcu_read, &bsxcartridge }, { &BSXCartridge::mcu_write, &bsxcartridge });
    parse_markup_map(m, node);
    mapping.append(m);
  }
}
Ejemplo n.º 30
0
void Cartridge::parse_markup_armdsp(XML::Node &root) {
  if(root.exists() == false) return;
  has_armdsp = true;

  string firmware = root["firmware"].data;
  string sha256 = root["sha256"].data;

  string path = interface()->path(Slot::Base, firmware);
  file fp;
  if(fp.open(path, file::mode::read) == false) {
    interface()->message({ "Warning: ARM DSP firmware ", firmware, " is missing." });
  } else if(fp.size() != 160 * 1024) {
    interface()->message({ "Warning: ARM DSP firmware ", firmware, " is of the wrong file size." });
    fp.close();
  } else {
    fp.read(armdsp.firmware, fp.size());

    if(!sha256.empty()) {
      if(sha256 != nall::sha256(armdsp.firmware, fp.size())) {
        interface()->message({ "Warning: ARM DSP firmware ", firmware, " SHA256 sum is incorrect." });
      }
    }

    fp.close();
  }

  for(auto &node : root) {
    if(node.name != "map") continue;
    Mapping m({ &ArmDSP::mmio_read, &armdsp }, { &ArmDSP::mmio_write, &armdsp });
    parse_markup_map(m, node);
    mapping.append(m);
  }
}