An introduction to GPDS


GPDS is a General Purpose Data Serializer implemented as a very small C++ library.


  • Leverages modern C++
  • XML backend
  • Easy to use
  • MIT licensed (open source)


There are plenty of different existing serializers that allow producing XML output. However, a lot of them enforce a strong scheme on the generated XML. GPDS allows generating XML files with a generic data format that can also be used efficiently within other XML processing applications.

Consider the following class:

Or represented as C++ classes:

class Color {
	std::string name;
	int red;
	int blue;
	int green;

class Car {
	std::string manufacturer;
	std::string model;
	int yearOfConstruction;
	Color color;

Many generic serializers with XML backends would generate the following XML (or similar):

  <value type="string">Jeep</value>
  <value type="string">Grand Cherokee</value>
  <value type="int">2009</value>
    <value type="string">Black</value>
    <value type="int">0</value>
    <value type="int">0</value>
    <value type="int">0</value>

This works fine as long as the produced XML content is only used by the class/software that serialized and deserialized to/from it. However, if the produced XML should also be used outside of that class/software it's very tedious to work with as it's not clear what the values refer to.

The goal of GPDS is to produce XML that consists of a more generic structure that can also be used by other applications:

  <model>Grand Cherokee</model>

Furthermore, GPDS provides comments and attributes which allow to take advantage of more powerful XML tools/techniques when processing the generated XML outside of the application which (de)serializes it:

  <model>Grand Cherokee</model>
  <color name="Black" format="rgb">
    <red depth="32">0</red>
    <green depth="32">0</green>
    <blue depth="32">0</blue>

GPDS also provides several configuration options to still annotate the element types if desired so:

  <manufacturer gpds:type="string">Jeep</manufacturer>
  <model gpds:type="string">Grand Cherokee</model>
  <year_of_construction gpds:type="int">2009</year_of_construction>
  <color gpds:type="nested">
    <red gpds:type="int">0</red>
    <green gpds:type="int">0</green>
    <blue gpds:type="int">0</blue>