The Container class.


The Container class represents an object which should be (de)serializable through GPDS.

The following figure shows the Container class design and related classes:

Figure 1: Container class design


A value is a key-value pair consisting of a string key and a value of one of the following types:
  • bool
  • int
  • double
  • std::string
  • Container* (for nesting)

Add a value

Adding a value can be achieved by using the Container::addValue() function:

Gpds::Container c;

double scale = 4.2;
c.addValue( "scale", scale );

Get a value

Getting a value from a deserialized Container can be achieved through the Container::getValue() function. The value's key is passed as a parameter:

double scale = c.getValue<double>( "scale" );

Get a value with a default value

The Container::getValue() function also allows supplying an optional default value which will be returned if no value exists for the specified key:

double scale = c.getValue<double>( "scale", 1.0 );

Get multiple values with the same key

It's possible to store multiple values with the same key in a container. Multiple values can be retrieved from a deserialized container by using the Container::getValues() function:

for (const Gpds::Container* carContainer : c.getValues<Gpds::Container*>( "car" ) ) {
    Car car;
    car.fromContainer( *carContainer );
    cars.push_front( car );


An attribute is a key-value pair where both the key and the value or of type std::string.

Keys are unique. Calling addArgument() with a key that has previously alredy been added will have no effect. The previously passed value will remain being associated with the specified key.

Add an argument

Gpds::Container c;
c.addAttribute("id", "72042135");

Get an argument

Gpds::Container c;
std::cout << "id=" << c.getAttribute("id") << std::endl;