DataDictionary Manual


A maxon::DataDictionary is a data container that stores arbitrary MAXON API ALIASES data filed under a given key. The base interface is maxon::DataDictionaryInterface.

For custom interfaces inheriting maxon::DataDictionary functionality use maxon::DataDictionaryObjectInterface.


A new maxon::DataDictionary object can be created on the stack:

// This example creates a new DataDictionary object and stores some values.
maxon::DataDictionary dataDict;
dataDict.Set(0, maxon::Int32(100)) iferr_return;
dataDict.Set(1, maxon::Int32(200)) iferr_return;

Keys and Values

A DataDictionary stores data for one or many keys. Both the stored data and the key must be a registered MAXON API ALIASES data type (see MAXON Data Type).

To access data with a defined type one can use resource IDs, see Resource IDs.
// This example stores and reads values from the given DataDictionary object.
// simple set
dataDict.Set(0, maxon::Int32(100)) iferr_return;
// set maxon::Data
const maxon::Data number(maxon::Int32(123));
dataDict.SetData(maxon::ConstDataPtr(1), std::move(number)) iferr_return;
// simple get
const maxon::Int32 value = dataDict.Get<maxon::Int32>(0) iferr_return;
DiagnosticOutput("Value: @", value);
// get maxon::Data
const maxon::Data data = dataDict.GetData(maxon::ConstDataPtr(1)) iferr_return;
DiagnosticOutput("Data: @", data);

The data stored in the DataDictionary can be inspected and deleted with:

// This example checks if a certain key is defined in the given DataDictionary.
// If so the value stored at the key is printed to the debug console and then deleted.
const maxon::Int key = 0;
if (dataDict.Contains(key))
const maxon::Data value = dataDict.GetData(keyPtr) iferr_return;
DiagnosticOutput("Key: @, Value: @", key, value);
// remove
dataDict.Erase(key) iferr_return;
if (!dataDict.Contains(key))
DiagnosticOutput("Key @ deleted.", key);


Using an iterator it is simple to loop through all elements stored in the DataDictionary.

// This example loops through all values stored in the given DataDictionary.
for (const auto& data : dataDict)
const maxon::Data key = data.first.GetCopy() iferr_return;
const maxon::Data value = data.second.GetCopy() iferr_return;
const maxon::DataType type = value.GetType();
DiagnosticOutput("Key: @, Value: @ (@)", key, value, type);


Further utility functions are:

// This example get the maxon::String representation and a hash value
// for the given DataDictionary and prints it to the debug console.
const maxon::String str = dataDict.ToString(nullptr);
const maxon::UInt hash = dataDict.GetHashCode();
DiagnosticOutput("Hash: @, String: @", hash, str);

Further Reading

Definition: datatypebase.h:753
Definition: string.h:1225
Definition: datatypebase.h:1178
#define iferr_return
Definition: resultbase.h:1465
Definition: datatypebase.h:1767
Result< Data > GetCopy() const
Returns a copy of the data.
Definition: datatype.h:1193
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:178
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:190
const DataType & GetType() const
Definition: datatypebase.h:1252
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:191