DataDescription Manual

About

A DataDescription contains settings that describe the attributes of a data type. While a maxon::DataDescriptionDefinitionInterface contains the "raw" definition the maxon::DataDescriptionInterface includes the complete, resolved description.

Description

The data in a DataDescription is stored as a DataDictionary.

General information (maxon::DESCRIPTION::DATA::INFO) is accessed with:

The various attribute descriptions in the description are stored as DataDictionaries:

// This example loads the description of the given data type and prints the attributes to the console.
// data type ID
const maxon::Id dataType { "net.maxonexample.class.descriptionElement" };
// load description data
const maxon::DataDescription descriptionData = maxon::DataDescriptionDatabaseInterface::LoadDescription(category, maxon::LanguageRef(), dataType) iferr_return;
// load description string data
const maxon::LanguageRef language = maxon::Resource::GetDefaultLanguage();
const maxon::DataDescription descriptionStrings = maxon::DataDescriptionDatabaseInterface::LoadDescription(category, language, dataType) iferr_return;
// list all attributes
const auto attributes = descriptionData.GetEntries() iferr_return;
for (const maxon::DataDictionary& attribute : attributes)
{
// get attribute settings
const maxon::InternedId ID = attribute.Get(maxon::DESCRIPTION::BASE::IDENTIFIER) iferr_return;
const maxon::Id attributeDataType = attribute.Get(maxon::DESCRIPTION::DATA::BASE::DATATYPE) iferr_return;
DiagnosticOutput("Attribute \"@\" of type @. Default value: @", ID, attributeDataType, defaultData);
// get localized attribute name
ifnoerr (const maxon::DataDictionary attributeString = descriptionStrings.GetEntry(ID))
{
const maxon::String translatedString = attributeString.Get(maxon::DESCRIPTION::STRING::BASE::TRANSLATEDSTRING) iferr_return;
DiagnosticOutput("Name: \"@\" (@)", translatedString, language.GetName());
}
}
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:65
static MAXON_METHOD Result< DataDescription > LoadDescription(const Id &category, const LanguageRef &language, const Id &dataType)
Definition: datatypebase.h:1179
Result< typename std::conditional< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, T, typename ByValueParam< T >::type >::type > Get() const
Definition: datatypebase.h:1384
Definition: apibaseid.h:251
Definition: datatypelib.h:27
const Id & Get() const
Definition: datatypelib.h:137
const Id & Get() const
Definition: apibaseid.h:183
static MAXON_METHOD LanguageRef GetDefaultLanguage()
Definition: string.h:1226
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define ifnoerr(...)
The opposite of iferr.
Definition: errorbase.h:393
const Id DATADESCRIPTION_CATEGORY_STRING
Definition: datadescriptiondatabase.h:17
const Id DATADESCRIPTION_CATEGORY_DATA
Definition: datadescriptiondatabase.h:15
#define iferr_return
Definition: resultbase.h:1465

It is possible to compare two descriptions with:

Database

The data descriptions are stored in the maxon::DataDescriptionDatabaseInterface database.

// This example lists all registered data descriptions and the number of defined attributes.
// get all registered descriptions
const maxon::Id descriptionID { "net.maxonexample.class.descriptionElement" };
// load description
const maxon::DataDescription description = maxon::DataDescriptionDatabaseInterface::LoadDescription(category, maxon::LanguageRef(), descriptionID) iferr_return;
// get number of attributes
const maxon::Int count = description.GetEntryCount();
DiagnosticOutput("Data type @ has @ attributes.", descriptionID, count);
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:190

Further Reading