SetDatatypeProperty

This function sets the value(s) of a certain datatypeTypeProperty of an instance, class or model.
The value of card gives the actual card of the values list.
The list values of undefined (void) items is a list of booleans, chars, integers or doubles, this list has a length as given in the values card. The actual used type is given by the definition of the dataTypeProperty.
The return value always should be 0, if not something is wrong in the way this property is called.

Note: the client application needs to make sure the cardinality of
    the property is within the boundaries.

Syntax

//
//   Strong typing definition
//
int64_t         SetDatatypeProperty(
                        RdfsResource            rdfsResource,
                        OwlDatatypeProperty     owlDatatypeProperty,
                        const void              * values,
                        int64_t                 card
                    );

static  inline  int64_t SetDatatypeProperty(
                                RdfsResource            rdfsResource,
                                OwlDatatypeProperty     owlDatatypeProperty,
                                bool                    value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_BOOLEAN);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                RdfsResource            rdfsResource,
                                OwlDatatypeProperty     owlDatatypeProperty,
                                const char              * value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_STRING || GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_CHAR_ARRAY);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                RdfsResource            rdfsResource,
                                OwlDatatypeProperty     owlDatatypeProperty,
                                const wchar_t           * value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_STRING || GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_WCHAR_T_ARRAY);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                RdfsResource            rdfsResource,
                                OwlDatatypeProperty     owlDatatypeProperty,
                                int64_t                 value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_INTEGER);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                RdfsResource            rdfsResource,
                                OwlDatatypeProperty     owlDatatypeProperty,
                                double                  value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_DOUBLE);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                RdfsResource            rdfsResource,
                                OwlDatatypeProperty     owlDatatypeProperty,
                                unsigned char           value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_BYTE);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall SetDatatypeProperty(
                                                int64_t                 rdfsResource,
                                                int64_t                 owlDatatypeProperty,
                                                const void              * values,
                                                int64_t                 card
                                            );

static  inline  int64_t SetDatatypeProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlDatatypeProperty,
                                bool                    value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_BOOLEAN);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlDatatypeProperty,
                                const char              * value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_STRING || GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_CHAR_ARRAY);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlDatatypeProperty,
                                const wchar_t           * value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_STRING || GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_WCHAR_T_ARRAY);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlDatatypeProperty,
                                int64_t                 value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_INTEGER);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlDatatypeProperty,
                                double                  value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_DOUBLE);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}

static  inline  int64_t SetDatatypeProperty(
                                int64_t                 rdfsResource,
                                int64_t                 owlDatatypeProperty,
                                unsigned char           value
                            )
{
    assert(GetPropertyType(owlDatatypeProperty) == DATATYPEPROPERTY_TYPE_BYTE);
    const int64_t  card = 1;
    return  SetDatatypeProperty(
                    rdfsResource,
                    owlDatatypeProperty,
                    (const void*) &value,
                    card
                );
}
    

Property rdfsResource

Size: 64 bit / 8 byte (value)
???.

Property owlDatatypeProperty

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the datatype property (attribute). 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 values

Size: 32 bit / 4 byte (reference)
The input array for datatype properties content. The contents memory is allocated by the host

Property card

Size: 64 bit / 8 byte (value)
The cardinality (i.e. number of elements) of the array as given or returned.

Example (based on pure and inline API calls)

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

#include    "./include/engine.h"
#include    <stdio.h>
#include    <string.h>

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classAbcd = CreateClass(model, "ABCD");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyAb = CreateProperty(model, DATATYPEPROPERTY_TYPE_BOOLEAN, "Ab"),
            propertyCd = CreateProperty(model, DATATYPEPROPERTY_TYPE_CHAR, "Cd"),
            propertyEf = CreateProperty(model, DATATYPEPROPERTY_TYPE_INTEGER, "Ef"),
            propertyGh = CreateProperty(model, DATATYPEPROPERTY_TYPE_DOUBLE, "Gh");

    //
    //  Instances
    //
    int64_t instanceAbcd = CreateInstance(classAbcd, nullptr);

    //
    //  Set Properties
    //
        
    {
        bool    valuesAb[2] = { true, false };
        SetDatatypeProperty(instanceAbcd, propertyAb, valuesAb, 2);

        char    * valuesCd[2] = { "First Line", "Second Line" };
        SetDatatypeProperty(instanceAbcd, propertyCd, valuesCd, 2);

        int64_t valuesEf[2] = { 1234, 5678 };
        SetDatatypeProperty(instanceAbcd, propertyEf, valuesEf, 2);

        double  valuesGh[2] = { 12.34, 56.78 };
        SetDatatypeProperty(instanceAbcd, propertyGh, valuesGh, 2);
    }

    //
    //  Get Properties
    //

    {
        int64_t card = 0;
        bool    * values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyAb, (void**) &values, &card);

        assert(card == 2 && values[0] == true && values[1] == false);
    }

    {
        int64_t card = 0;
        char    ** values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyCd, (void**) &values, &card);

        assert(card == 2 && strcmp(values[0], "First Line") == 0 && strcmp(values[1], "Second Line") == 0);
    }

    {
        int64_t card = 0,
                * values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyEf, (void**) &values, &card);

        assert(card == 2 && values[0] == 1234 && values[1] == 5678);
    }

    {
        int64_t card = 0;
        double  * values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyGh, (void**) &values, &card);

        assert(card == 2 && values[0] == 12.34 && values[1] == 56.78);
    }

    //
    //  The same can be applied to existing classes and properties
    //

    //
    //  Classes
    //
    int64_t classCylinder = GetClassByName(model, "Cylinder");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyClosed = GetPropertyByName(model, "closed"),
            propertyLength = GetPropertyByName(model, "length"),
            propertyName = GetPropertyByName(model, "name"),
            propertyRadius = GetPropertyByName(model, "radius"),
            propertySegmentationParts = GetPropertyByName(model, "segmentationParts");

    //
    //  Instances (creating)
    //
    int64_t myInstanceCylinder = CreateInstance(classCylinder);

    SetDatatypeProperty(myInstanceCylinder, propertyLength, 1.8);
    SetDatatypeProperty(myInstanceCylinder, propertyRadius, 1.3);
    SetDatatypeProperty(myInstanceCylinder, propertySegmentationParts, (int64_t) 36);

    //
    //  non related / restricted properties (user defined and pre defined) can be connected in any quantity
    //
    SetDatatypeProperty(myInstanceCylinder, propertyClosed, (bool) true);
    SetDatatypeProperty(myInstanceCylinder, propertyName, (char*) "Example text added");

    assert(GetArea(myInstanceCylinder) > 0.);

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

Example (based on pure API calls)

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

#include    "./include/engine.h"
#include    <stdio.h>
#include    <string.h>

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classAbcd = CreateClass(model, "ABCD");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyAb = CreateProperty(model, DATATYPEPROPERTY_TYPE_BOOLEAN, "Ab"),
            propertyCd = CreateProperty(model, DATATYPEPROPERTY_TYPE_CHAR, "Cd"),
            propertyEf = CreateProperty(model, DATATYPEPROPERTY_TYPE_INTEGER, "Ef"),
            propertyGh = CreateProperty(model, DATATYPEPROPERTY_TYPE_DOUBLE, "Gh");

    //
    //  Instances
    //
    int64_t instanceAbcd = CreateInstance(classAbcd, nullptr);

    //
    //  Set Properties
    //
        
    {
        bool    valuesAb[2] = { true, false };
        SetDatatypeProperty(instanceAbcd, propertyAb, valuesAb, 2);

        char    * valuesCd[2] = { "First Line", "Second Line" };
        SetDatatypeProperty(instanceAbcd, propertyCd, valuesCd, 2);

        int64_t valuesEf[2] = { 1234, 5678 };
        SetDatatypeProperty(instanceAbcd, propertyEf, valuesEf, 2);

        double  valuesGh[2] = { 12.34, 56.78 };
        SetDatatypeProperty(instanceAbcd, propertyGh, valuesGh, 2);
    }

    //
    //  Get Properties
    //

    {
        int64_t card = 0;
        bool    * values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyAb, (void**) &values, &card);

        assert(card == 2 && values[0] == true && values[1] == false);
    }

    {
        int64_t card = 0;
        char    ** values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyCd, (void**) &values, &card);

        assert(card == 2 && strcmp(values[0], "First Line") == 0 && strcmp(values[1], "Second Line") == 0);
    }

    {
        int64_t card = 0,
                * values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyEf, (void**) &values, &card);

        assert(card == 2 && values[0] == 1234 && values[1] == 5678);
    }

    {
        int64_t card = 0;
        double  * values = nullptr;
        GetDatatypeProperty(instanceAbcd, propertyGh, (void**) &values, &card);

        assert(card == 2 && values[0] == 12.34 && values[1] == 56.78);
    }

    //
    //  The same can be applied to existing classes and properties
    //

    //
    //  Classes
    //
    int64_t classCylinder = GetClassByName(model, "Cylinder");

    //
    //  Datatype Properties (attributes)
    //
    int64_t propertyClosed = GetPropertyByName(model, "closed"),
            propertyLength = GetPropertyByName(model, "length"),
            propertyName = GetPropertyByName(model, "name"),
            propertyRadius = GetPropertyByName(model, "radius"),
            propertySegmentationParts = GetPropertyByName(model, "segmentationParts");

    //
    //  Instances (creating)
    //
    int64_t myInstanceCylinder = CreateInstance(classCylinder, nullptr);

    double  length = 1.8,
            radius = 1.3;
    int64_t segmentationParts = 36;
        
    SetDatatypeProperty(myInstanceCylinder, propertyLength, &length, 1);
    SetDatatypeProperty(myInstanceCylinder, propertyRadius, &radius, 1);
    SetDatatypeProperty(myInstanceCylinder, propertySegmentationParts, &segmentationParts, 1);

    //
    //  non related / restricted properties (user defined and pre defined) can be connected in any quantity
    //
    bool    closed = true;
    char    * name = "Example text added";

    SetDatatypeProperty(myInstanceCylinder, propertyClosed, &closed, 1);
    SetDatatypeProperty(myInstanceCylinder, propertyName, &name, 1);

    assert(GetArea(myInstanceCylinder, nullptr, nullptr) > 0.);

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