About Store Forum Documentation Contact



Post Reply 
XML - Load from Memory
Author Message
Dwight Offline
Member

Post: #1
XML - Load from Memory
Hi all,

As I am working on an online game, I want to make use of some XML files that I have stored on the server (e.g showing some news, loading some server information). As per the post here in this thread, Greg stated that loading xml from memory would be added ( https://www.esenthel.com/forum/showthread.php?tid=3113 ).

The load method from XmlData only accepts a name, id or file, but not any file from memory.

Currently, I have worked around it by downloading the files locally to the machine from the webserver using the Download class and reading it from there. Although preferably I would not like to store these xml files on the client's machines.

Has anyone tackled this beforeand found an elegant solution that did not require saving the files locally first before reading them?
04-11-2021 08:51 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: XML - Load from Memory
Hi,

You can use
XmlData:
Bool load(FileText &f ); // load from file, false on fail, 'f' file should be already opened for reading

and create FileText to read from memory:
FileText f;
FileText& readMem(const_mem_addr C Str &data ); // read from memory , 'data' must point to object in constant memory address (only pointer is stored through which the object can be later accessed)
FileText& readMem( CPtr data, Int size, Int encoding= -1, const_mem_addr Cipher *cipher=null); // read from memory , 'cipher' must point to object in constant memory address (only pointer is stored through which the object can be later accessed), 'encoding'=encoding of the memory (-1=autodetect)

Also I recommend TextData instead of XmlData.
04-11-2021 09:07 AM
Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #3
RE: XML - Load from Memory
Hi Greg,

Thanks a lot! That did the trick!
04-11-2021 08:37 PM
Find all posts by this user Quote this message in a reply
Post Reply