XML module

This topic contains 22 replies, has 5 voices, and was last updated by  Arjailer 2 years, 8 months ago.

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #3963

    impixi
    Participant

    Is anyone coding an XML module for MX2?

    If not, any suggestions for a C/C++ XML library to wrap? Or maybe a “native” BlitzMax or Monkey1 solution to port?

    I just need something simple: load and parse basic but “well-formed” XML and create a DOM-like tree structure from it.

    #3964

    Mark Sibly
    Keymaster

    tinyxml2 looks very tidy…

    http://www.grinninglizard.com/tinyxml2/

    The mx2 API would probably look something like:

    There’s more methods, but that’s the jist of it, just yer basic tree. Is that the sort of thing you’re after?

    #3965

    Arjailer
    Participant

    I converted skn3’s Monkey X xml module to Monkey 2. It’s pure Monkey 2 code with no dependencies. I don’t have it on this PC, but I could post it later if you’re interested.

    TinyXML looks good though  🙂

    #3966

    Mark Sibly
    Keymaster

    I’ve made a pretty good start on tinyxml2, but the more the merrier! Wish people would staring using that module manager thingy though…

    Anyway, I’m more of a JSON guy myself, but is this pretty much what you need from an xml module?

    …which produces…

    #3970

    impixi
    Participant

    @Mark

    Anyway, I’m more of a JSON guy myself, but is this pretty much what you need from an xml module?

    That’s exactly what I’m looking for. 🙂

    Regarding JSON, XML, etc. I’m usually an INI or CSV or pure binary data guy, but I’m working on a project where I can actually see the benefit of using XML-formatted data. JSON has never really “gelled” with me, I tend to avoid it.

    Wish people would staring using that module manager thingy though…

    Indeed, that would be nice. :). I have a few half-finished modules I hope to finish soon. I’ll upload them when I do.

    @arjailer

    That Monkey1 module by skn3 is the one I had planned to port if nobody else had started on an XML module…

    #3971

    Arjailer
    Participant

    Here’s the xml parser.

    I might upload it as a module later, but between adding a demo app and adding documentation it’s actually a fair amount of work.

    Edit: Especially as it’s not originally my code so documenting it might be “fun”  🙂

    Attachments:
    1. skn3xml.zip
    #3973

    Arjailer
    Participant

    I do have Linq-like extension methods for List<T> and Stack<T> that I would like to upload to the module manager. Might work on that a bit today.

    #3977

    Arjailer
    Participant

    Hmmm … do extension methods not work in modules?

    The module builds but I’m getting pretty much empty .cpp source files in my windows_debug folder and if I try to use any of the extension methods I get “undefined reference” errors.

    It all works fine when built as an app where the .cpp source files contain everything I’d expect to see.

    If I build the app without actually referencing or using any of the extension methods I get the same empty .cpp source files as I’m seeing in the module. This makes sense for building an app ‘cos it’s only building what it needs to, but I wouldn’t have thought a module would do that?

    Am I missing something about building modules?

    #3984

    impixi
    Participant

    @Mark

    Woohoo! Just tried the latest GIT release and have been playing around with the tinyxml module. Works nicely so far. Thanks!

    Here’s an example that builds a mojox tree from that “dream.xml” file included with the banana:

    [/crayon]

    @arjailer

    Thanks for posting your code. I’ll experiment with that later, see how it compares to Mark’s tinyxml wrapper solution.

    #3985

    impixi
    Participant

    Another tinyxml2 example with element attributes and “embedded XML”:

    [/crayon]
    #3989

    Mark Sibly
    Keymaster

    The module builds but I’m getting pretty much empty .cpp source files in my windows_debug folder and if I try to use any of the extension methods I get “undefined reference” errors.

    Are you using the latest mx2cc? Extensions are undergoing ongoing maintenance…

    If you are, can you reproduce with a simple example?

    #3994

    Arjailer
    Participant

    Actually, it looks like I’m not on the latest version. I’ll update later and give it a try.

    #4006

    Arjailer
    Participant

    Extension methods fail to build at all with the latest code, whether as a module or not.

    Lots of “Blah:T?(T?) must be a generic class type” errors.

    The code built fine in v1.0.5

    Have attached if you want to have a look.

    Attachments:
    1. linq.zip
    #4009

    Arjailer
    Participant

    Also, the following no longer works in the latest build either:

    Get error: Can’t find overload for ‘TestGenericMethod<int>(…)’ with argument types ()

    Again, this used to work in v1.0.5, and works in 1.0.6 if I remove the Where clause

    #4010

    Mark Sibly
    Keymaster

    Have you got a small test program for the Linq stuff?

Viewing 15 posts - 1 through 15 (of 23 total)

You must be logged in to reply to this topic.