iDevGames Forums
TinyXML embedded zlib - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: TinyXML embedded zlib (/thread-8174.html)

TinyXML embedded zlib - markhula - Oct 5, 2010 06:58 AM

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


RE: TinyXML embedded zlib - markhula - Oct 5, 2010 08:49 AM

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???


RE: TinyXML embedded zlib - OneSadCookie - Oct 5, 2010 09:12 AM

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.