Results 1 to 3 of 3

Thread: XML and Binary

  1. #1

    Default XML and Binary

    hi,

    I was wondering if anyone could help me, newish to c++ and i liked the look of clanlib, i am trying to create a map editor for an RPG.
    So far i can read in just plain binary (using read_uint8() ) and write (using just rand() at moment).

    but now i want to add layers so i was thinking of using XML plus binary so the basic form would be

    Code:
    <Map width="10" height="10" name="foo">
        <Layer name="Collision" id="0">
        //binary data
       </Layer>
       <Layer name="layer01" id="1">
       // binary data
       </Layer>
       ..
       ..
    </Map>
    so i was hoping that clanlibs XML functions could provide the support to do this, or if you you know of a library that could help.

    Thanks.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    In general it is a really bad idea to include binary data in a XML file. XML is a character based format, not binary. This means that you will have to encode any binary data, i.e. hex encode it or base64 encode it.

    Encoding the data will make it much larger than its original form, and the DOM will load and keep that encoded version in memory. This will effectively double the memory usage for your binary data and force you to have a copy (in the DOM) of all binary data present in the XML file.

    If you still really want to store binary data in a XML file, there are two classes in ClanLib 0.9, CL_Base64Encoder and CL_Base64Decoder, that can be used to convert between character format and binary format. It will require a little work to move those to 0.8 though.

  3. #3

    Default

    thanks for the info,

    now i guess i will just stick with binary only maps, makes it harder with layers i suppose

    cya and thanks again

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •