SetNameOfProperty

Sets or updates the name of the property, it returns 0 on success.

Error return codes:
    0 successful
    1 argument rdfProperty is incorrect (not a proper handle to an active property)
    2 argument name is incorrect (nullptr or zero length name)
    3 the name of rdfProperty is locked
    4 name is already used by another class
    5 name is already used by a property
    6 name is already used by an instance
    7 undefined error

Syntax

//
//   Strong typing definition
//
int64_t         SetNameOfProperty(
                        RdfProperty             rdfProperty,
                        const char              * name
                    );

static  inline  int64_t SetNameOfProperty(
                                RdfProperty             rdfProperty,
                                char                    * name
                            )
{
    return  SetNameOfProperty(
                    rdfProperty,
                    (const char*) name
                );
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall SetNameOfProperty(
                                                int64_t                 rdfProperty,
                                                const char              * name
                                            );

static  inline  int64_t SetNameOfProperty(
                                int64_t                 rdfProperty,
                                char                    * name
                            )
{
    return  SetNameOfProperty(
                    rdfProperty,
                    (const char*) name
                );
}
    

Property rdfProperty

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the property, this can be either a datatype property (attribute), an object property (relation) or non-defined property. The handle will be static during the life-time of the model, when the model (or part of it) is saved and opened again, the handle will most probably be different.

Property name

Size: 32 bit / 4 byte (reference)
This attribute represents the name of the property; either a datatype property or a relation (given as char array / ASCII). The name is given by the host and the attribute is not changed.

Example (based on pure API calls)

Here you can find code snippits that show how the API call SetNameOfProperty can be used.

#include    "./include/engine.h"
#include    <cmath>

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classCollection = GetClassByName(model, "Collection"),
            classCube = GetClassByName(model, "Cube");

    //
    //  Object Properties (relations)
    //
    int64_t propertyAbcd = CreateProperty(model, OBJECTPROPERTY_TYPE, "abcd"),
            propertyObjects = GetPropertyByName(model, "objects");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyLength = GetPropertyByName(model, "length"),
            propertyEfgh = CreateProperty(model, DATATYPEPROPERTY_TYPE_DOUBLE, "efgh");

    //
    //  Instances (creating)
    //
    int64_t instanceCollection = CreateInstance(classCollection, nullptr),
            instanceCube = CreateInstance(classCube, nullptr);

    double  length = 2.,
            efgh = 1.7;

    SetDatatypeProperty(instanceCube, propertyLength, &length, 1);
    SetDatatypeProperty(instanceCollection, propertyEfgh, &efgh, 1);

    assert(GetVolume(instanceCollection, 0, 0) == 0.);

    char    * propertyNameI = nullptr;
    GetNameOfProperty(propertyAbcd, &propertyNameI);

    char    * propertyNameII = nullptr;
    GetNameOfProperty(propertyEfgh, &propertyNameII);

    SetNameOfProperty(propertyAbcd, "InverseRelationControledByThirdParty");

    SetObjectProperty(instanceCube, propertyAbcd, &instanceCollection, 1);
    SetObjectProperty(instanceCollection, propertyObjects, &instanceCube, 1);

    assert(GetVolume(instanceCollection, 0, 0) == 8.);

    char    * propertyNameIII = nullptr;
    GetNameOfProperty(propertyAbcd, &propertyNameIII);

    //
    //  The retrieved property names have the following values 
    //      propertyNameI   :  'abcd'
    //      propertyNameII  :  'efgh'
    //      propertyNameIII :  'InverseRelationControledByThirdParty'
    //

    //
    //  The resulting model can be viewed in 3D-Editor.exe
    //
    SaveModel(model, "c:\\created\\myFile.bin");
    CloseModel(model);
}