Location/Reading custom xml files
#1
Information 
Hi,

I have some questions regarding custom xml files.

What I want is to read custom xml config files.
I guess the perfect location would be inside .murlres package.

Reading and parsing xml files using Murl::Util::FileTools::LoadBinaryFile and Murl::Util::XmlParser works great, but my question is how to open the file when it's inside a .murlres package?

If the .murlres package is the wrong choice what would be the right one?

thx

Andreas
Reply
#2
Apost 
The .murlres package can easily be used to host any type of custom files. Simply specify your resource inside the package.xml file using the type="BINARY" attribute:
<?xml version="1.0" ?>
<Package id="Main">
    <Resource type="BINARY" id="MyXmlFile" fileName="my_fancy_file.xml"/>
</Package>

You can then access that file from e.g. a logic class' OnInit() method like this:
Bool App::MyLogic::OnInit(const Logic::IState* state)
{
    const Resource::ICollection* resourceCollection = state->GetResourceCollection();
    const Resource::IBinary* myXmlFile = resourceCollection->GetBinary("Main:MyXmlFile");

	const ConstData& myXmlFileDataObject = myXmlFile->GetData();
    
	const UInt8* data = myXmlFileDataObject.GetData();
	UInt32 byteSize = myXmlFileDataObject.GetByteSize();

	// Do something useful...

    return true;
}
Reply
#3
Apost 
Thank you!!!

Thats exactly what I want/need!

Andreas
Reply


Forum Jump:


Copyright © 2011-2017 Spraylight GmbH.