I have a large C program which needs to communicate some XML files to Java/Obj-C and other languages. 99% of the program business logic is in C/C++ mix. Java, Obj-C all have a way to parse XML and in most cases I'll be using HTML5 and Javascript (via PhoneGap) to parse the XML on that end. The part that is frustrating is finding a decent C or C++ library that compiles on each platform and is relatively straight forward to use.
I've looked into libxml2 first. It is not easy to get compiling for Android at least, required ICU4 to get working. I then checked out libroxml, unfortunately its xml modification core is weak at best.
Does anyone have a tip for a nice XML Parsing library that isn't hell to compile or use? That supports modification of the XML file? Do I need to be concerned about language support (unicode)?
TinyXML seems like the way to go.
http://sourceforge.net/projects/tinyxml/
Small, supports modification of the tree, utf8 and compiles easily (just a few files, no platform dependencies).
Related
I am not sure, if this is the right place to ask, but I am curious, if there are any Android NDK examples (apks), on how to read a file with Java and pass it over to C/ C++ using JNI.
Currently I am trying to read pdf or office files (e.g. docx) with C/ C++ and I am trying to understand the concept behind it.
Maybe there are some full apk examples or just some snippets, with which I could extend the hello-jni/ hello-jnicallback examples.
I already found the android ndk samples site https://github.com/android/ndk-samples, but there seems to be no example on how to simply read files.
Thank you for your help.
I'd like to load and play '.mid' MIDI files in Kivy but mainly on mobile platforms (i.e. IOS and Android).
I'm assuming that, I don't want to get into the intricacies of native-C/C++ based stuff (i.e. to avoid have to cross-compile, I'm not a seasoned Python dev), so the library, most probably, would need to be pure Python.
I'll start the bidding with some Frameworks I've found (some require C/C++), I've used none (0, zero), maybe someone could offer some feedback (or they might come in useful for the wider community):
BTW, it would be great if the/a MIDI library could also read the lyrics from a '.mid' file
Python Midi libraries
http://web.mit.edu/music21
https://github.com/cuthbertLab/music21
https://code.google.com/p/midiutil <- Pure Python, no lyrics (?)
https://code.google.com/p/mingus
http://mxm.dk/products/public/pythonmidi
http://das.nasophon.de/mididings
https://github.com/vishnubob/python-midi
https://gist.github.com/anonymous/202595 <- smidi.py
http://webcache.googleusercontent.com/search?q=cache%3Alarndham.net%2Fservice%2Fpys60%2Fsmidi.py
https://pypi.python.org/pypi/midi <- C for Alsa (!)
http://www.fluidsynth.org <- For pypi midi
http://sourceforge.net/p/fluidsynth <- C based
I'm using Fluidsynth to give me cross-platform MIDI output. It plays MIDI files with a SoundFont module for high quality audio. If you're happy with the LGPL licence, you can get Python bindings for it from pyFluidSynth (https://code.google.com/p/pyfluidsynth), but it's pretty straightforward to write your own bindings module using the standard Python ctypes module.
Normally, you would be expected to compile (and thus cross-compile) Fluidsynth from the supplied sources, however you can just take a pre-compiled version from another project, for instance MuseScore. This is what I'm doing for the moment, I'll switch to compiling Fluidsynth once (and if) the project I'm working on gets close to completion.
If you want to process MIDI files, e.g. to extract the lyrics, take a look at Mido (https://mido.readthedocs.org/en/latest). I've found it very useful for reading/writing MIDI files.
I'm working to create a library for my app in C. I want to parse a XML file in my code.
So, how can i do it in C ?
I know its java implementation but how can i parse a XML in my C code ?
What are the libraries that can be used for the purpose ?
I suggest Expat, I've used with many projects and it is very simple to use and has extremely small overhead. Its code base is also quite stable.
Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags).
However with every other external project mentioned, you need to build it yourself.
you should use c library for parsing xmls. here are some famous library links.. you can check
http://www.jclark.com/xml/expat.html
http://www.xmlsoft.org/
http://tibleiz.net/asm-xml/benchmark.html
you can find many other library to parse xml. But if you have any lightweight parsing task then you can use
http://www.minixml.org/
I have used http://www.minixml.org/ so i suggest to use this. Minixml is quite simple and easy to understand and use.
So you can download whole code of minixml and cross compile it for Android using Android toolchain or android NDK. And now Link that library to your jni code and use its API in your c code.
Just refference for includeing 3rd party library in jni code see
How to link any library in ndk application
I am developing an application for android/iOS/windows using c++ code for the core logic. The application uses the free fuzzy logic library and it works perfectly for windows mobile, iOS and on my local Ubuntu machine, but it doesn't quite work under android.
The application reads a .fcl file from the sd card and then parses it using the free fuzzy logic library parser. The problem is, that the parser gets stuck at random stages of parsing.
Some notes to my project settings:
I enabled the Android read/write permissions for the sdcard in the manifest.xml.
The code I am trying to run is the basic example from the free fuzzy logic library website.
I am using the stlport_static library for stl support and the -frtti compiler flag.
My question is: Am I missing something android specific, like file encoding or some permissions I didn't set?
Some notes I thought about:
File compression should not be an issues, because, to my knowledge, files on the SD card are not compressed and I can parse the file partially.
Using other fuzzy logic libraries is out of the option, because I can't use GPL licenced libraries. The only other library I found didn't hat a manual / how to and couldn't parse the fcl standard.
The free fuzzy logic library uses a lot of wchar_t's whitch could be an issue.
Thank you for your time and hopefully for some help ;)
Ok after plowing through some android manuals and some Google abuse I found the problem. Currently Android doesn't support the wchar_t type. Well you can use it, but the results will not be the same as on any other operating system.
By changing all the wchar_t and wstring types in the free fuzzy logic library to their corresponding char and string types I was able to make the parser work. Well sort of, there are still some sleight inconsistencies, but nothing i can't handle ;).
Conclusion: Don't use wide characters in android c++ Programs.
Thank you for your time & help
I have an external compiled static C++ library that I'm using in my android application. This library is reading a file. I want to know if there is a way I can "redirect" the function that's reading the file so that it reads another file.
So if it does:
fopen("myfile.txt", "rb");
I want to intercept it and to do this instead:
fopen("myotherfile.txt", "rb");
In Objective-C I use MethodSwizzling. Is there something similar I can do in C++ or the android NDK?
Short of editing the binary (with uncertain results), your best option is to use a symlink... if you're just doing it for development purposes, you could use adb shell into your test device to create the symlink.
http://developer.android.com/guide/developing/tools/adb.html#issuingcommands
How about contact the author of the library and ask them to introduce a parameter? Having hard-coded file paths is a lousy design anyway, the library will be better off.