General Purpose Data Serializer
-
Hi,
Our company is developing several C++ / Qt applications that need to generate XML files that can be processed by other (3rd-party) XML processors/applications. Unfortunately, most existing serializers that produce XML output did not fit our requirements.
I'm proud to present our solution: GPDS - A General Purpose Data Serializer.It's still in a very rough state but definitely usable. Everything can be found here: https://gpds.simulton.com
The library comes with a
*.pri
file for easy integration into Qt projects. Furthermore, we'll add (de)serialization support for Qt types such asQString
very soon.Any kind of feedback is welcomed.
-
Looks good! Any plans to support JSON output, too?
-
Yep, a JSON backend (within GPDS I call them "Archiver") is planned. However, adding support for Qt's standard types is higher up in the list of priorities right now. I assume JSON support will be there within a few days/weeks.
After the JSON archiver there are plans to add support for binary formats such as BSON as well.
-
Nice, thanks :-)
-
Oh man, we have a serializer that produces <key> for every tag. I was wondering why on earth anyone would design a format that way. Now I understand why, it was produced by some kind of serializer. Thank you for providing some sanity to this mess we call xml. I like xml in concept, but some of the tools out there make me wonder about my sanity at times.
-
We've added support for the first Qt types:
QString
andqreal
.
You can now do this:class Color : public Gpds::Serialize { public: QString name; int red; int green; int blue; virtual Gpds::Container toContainer() const override { Gpds::Container c; c.setComment("a color object"); c.addAttribute("format", "rgb"); c.addAttribute("name", name); c.addValue("red", red).addAttribute("depth", "32"); c.addValue("green", green).addAttribute("depth", "32"); c.addValue("blue", blue).addAttribute("depth", "32"); return c; } virtual void fromContainer(const Gpds::Container& c) override { // Retrieve format const QString& formatString = c.getAttribute("format").value_or("n/a"); assert( formatString == "rgb" ); name = c.getAttribute("name").value_or("n/a"); red = c.getValue<int>("red"); green = c.getValue<int>("green"); blue = c.getValue<int>("blue"); } };
Which will result in the following XML:
<color format="rgb" name="Black"> <blue depth="32">0</blue> <green depth="32">0</green> <red depth="32">0</red> </color>
There's also a Qt specific demo/example in the repo.
Isn't the world wonderful?
There's still a lot of stuff left to do tho.