TinyXML embedded zlib

Posts: 117
Joined: 2010.09
Post: #1
Hi all,

I've got my map xml parser working with tinyxml; but how do I get a pointer to the embedded map data so that I can send it into zlib.
How is it referenced???; it's not an element or node; so how do I get it.
Here's the test xml I am using so you can see the format:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="100" height="100" tilewidth="32" tileheight="32">
<tileset firstgid="1" name="cas" tilewidth="32" tileheight="32" spacing="2" margin="2">
<image source="castle1.png"/>
<layer name="Tile Layer 1" width="100" height="100">
<data encoding="base64" compression="zlib">

Currently in my parser I halt with I find the "zlib" key for compression; is it at that point I "do something" to get a proper pointer to the compressed embedded string????

Any help/suggestions appreciated

Quote this message in a reply
Posts: 117
Joined: 2010.09
Post: #2
I *guess* it's simply element->GetText(); ?
How do I store the text though before passing it to zlib for de-compression?
i.e. I don't know it's length so it's a bit tricky to char text[500] and store it there on the stack!!
Or perhaps, I just send the pointer (source) into z lib; but how do I know the length again for the destination???

Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #3
If you do that, you'll obviously have to call strlen() on the result to find its length. That's pretty inefficient. The docs suggest you get the first child, call ToText() to get a TiXMLText object, and StrValue() on that to get a std::string, which has a size() method.

zlib doesn't handle base64 data directly AFAICT, so you'll need to use something like BIO_f_base64 (or google up some source) to decode the data.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Embedded frameworks not working for everybody akb825 8 6,294 Oct 24, 2005 09:26 AM
Last Post: akb825