In C#, I use XSD2Code in order to:
generate automatically entities from XSD
generate methods which serialize/deserialize XML stream in these entities
Does it exist in the native C++ world?
I am looking for libs which work on Windows.
No, C++ has no such feature.
However, there are a plurality of libraries for C++ which provide everything you could possibly need. I am sure that at least several will exist to suit your XML needs (yuck!).
In particular, "CodeSynthesis XSD - XML Data Binding for C++" looks promising.
I get 1,120,000 Google results for xsd xml c++.
Related
I want to serialize several C++ objects into JSON, and deserialize them back. Obviously since C++ is lacking reflection, this can't be done automatically. I will need to somehow tell the serializer which data member goes into which JSON property.
I can do that with C++, but I'd rather use something like Protobuf's message to specify the mapping. Out of the many many JSON C++ libraries out there, is there one that support some sort of metadata that allows me to map the serialization process without implementing it myself?
You can simply use the JSON cpp or C files and use them as API. That is what I have done for my previous project. C++ does not come with inbuilt JSON support like JAVA.
So include the files and use the JSON function as APIs. You can build it separately and link it statically to your program. Go to the JSON home page for language wise files:
http://json.org/
For CPP files:
http://sourceforge.net/projects/jsoncpp/
i think its moved to git repo. The link is present there.
Hope this helps.
The ASN.1 tools from OSS Nokalva support JSON encoding rules for ASN.1 schemae.
You write an ASN.1 schema (protobufs schema are similar but inferior), compile it to whatever language you want (C++ in your case), and you get the bunch of classes that can serialise to/from JSON.
Not free I'm afraid.
ASN.1 is great - there's all sorts of encoding rules to suit all occasions.
We require the ability to generate C++ classes from XML (akin to JAXB in Java) but for commercial reasons do not wish to use CodeSynthesisXSD. Are there any other libraries out there that will allow this? The platform we are targeting is Windows.
We have been looking at xmlbeansxx but this has not been maintained for 5 years and requires an older version of Boost than we have currently in our system (and do not want to have multiple Boost versions).
CodeSynthesis XSD author here.
First of all, a small nitpick: CodeSynthesis XSD doesn't generate C++ classes from XML. It generates them from XML Schema. From your question it appears that XSD would have worked for you. So I assume you are actually looking to generate C++ from XML Schema.
Now to your question. I don't believe there is a usable and more liberally-licensed C++ tool out there that can do this. Also, if your XML vocabulary is fairly small (e.g., a configuration format), then you may consider using XSD under the free proprietary license. It allows you to use XSD in a commercial application without having to release your source code as long as the amount of the generated code is less than 10,000 lines. And, as the name suggests, it is free (as in no charge).
Any recommendations for XML generators in C++?
There are quite a few XML generators for C++. Some of them work with DOM, others can serialize your classes, and yet others work in even more different ways, like Boost.PropertyTree. Whichever you should choose, depends entirely on your requirements.
If you need to write a small set of data to an XML file (and may also want to write this data to other formats in the end), consider using Boost.PropertyTree. If you want to serialize C++ classes to XML, or make C++ class representation of XSD Schemas, consider using a binding generator such as CodeSynthesis XSD. And if you just want to manipulate the XML directly, you can use a DOM parser/writer like the cross-platform Xerces C++.
MSXML is a sensible option if you're limiting your application to Windows.
Xerces could prove useful if you're wanting to write code that can be ported to other platforms.
I'm sure there are a few that exist already, but if one were inclined to implement their own it would be an easy task using Boost.Spirit.Karma.
I'm not sure what exactly the right term is, kind of like ORM using XML as the data store. Are there any decent tools which will autogenerate C++ classes (including data and serialization/deserialization) based on an XML schema? Or will create XML-sync code and schema based on a C++ class definition?
TinyXML is great but it's so old-school to spend all that time writing code to load/save XML data to classes. I've seen similar tools focused on SOAP/WSDL, but they generated all kinds of other code on top of the basics.
Any good open-source libraries out there?
The only thing I've seen that attempts to do this is CodeSynthesisXSD.
If you are looking for an open source and commercial licensed tool to auto-generate C++ classes, including data and serialization/deserialization, based on an XML schema, then I strongly recommend GSOAP. It is easy to use, compliant to industry standards, and actively maintained.
See also http://www.rpbourret.com/xml/XMLDataBinding.htm
I was disappointed with many other C++ XML tools that promise full data bindings but will fail to process more extensive sets of WSDLs and schemas such as ONVIF. Having to retool an entire project was a pain. I know that GSOAP will do the job. A winner IMHO.
Not open source, but won't XML Thunder work for you?
I'm tasked with reading Apple's property list files within a c++ application. Focusing primarily on the xml-type plist files specified in OS X, which mimic a xml-type implementation.. Apple's implementation of their property list is described here:
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man5/plist.5.html
I'm wondering if there are classes or libraries available that already can read this type of implementation within standard c++ (not Objective-C); hoping to find something rather than rolling our own. Are there any open-source implementations of this available?
PList files are not only mimicing XML, they are XML, including valid XML headers.
Any XML reader should be able to parse these files as a result. If you're looking for a logical class that abstracts the files, I'm not aware of any existing ones. Given Apple's documentation, you should be able to write one yourself with an XML reader, although it would take some work for full compatibility.
For topic starter it is too late, I know, but maybe it helps somebody
https://github.com/animetrics/PlistCpp
This is a C++ Property List (plist) serialization library (MIT license).
It supports both XML and binary versions of the plist format and is designed to
be cross platform with minimal dependencies.
Is that target-specific?
For Windows, there is a crude solution which consists of using the functions of iTunes dynamic libraries to parse plist files (either binary or plain text format work).
That's a code originally written to interface an iPod, but you can easily extract the few functions you are interested in.
The repository is on this project page: http://code.google.com/p/t-pot/
Look for the file iPoTApi.h and iPoTApi.cpp, the function TranslatePLIST of the class CiPoTApi.
I wish there were a better solution, at the time I tried to compile it from Apple's sources targeted at Windows but it is a real nightmare, and files are missing. So using their libraries was a considerable shortcut.