sdaiGetADBType

This call can be used to get the used type within this ADB type.

Syntax

//
//   Strong typing definition
//
SdaiPrimitiveType   sdaiGetADBType(
                            const SdaiADB           ADB
                        );


//
//   Weak typing definition
//
int_t   __declspec(dllexport) __stdcall   sdaiGetADBType(
                                                                            const void              * ADB
                                                                        );
    

Property ADB

Size: 32 bit / 4 byte (reference)
...

Example (based on pure API calls)

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

#include    "./include/ifcengine.h"
#include    <iostream>

//
//  The following code allows output as found in SPFF (STEP Physical File Format)
//

using namespace std;

void    CreateLineAggregation__cout(
                SdaiAggr        aggregation
            );

char    BUFF__cout[512];

char    * UpperCase__cout(
                char    * in
            )
{
    assert(strlen(in) < 256);
    size_t  len = strlen(in);
    for (size_t i = 0; i <= len; i++) {
        if (in[i] >= 'a' && in[i] <= 'z')
            BUFF__cout[i] = in[i] - 'a' + 'A';
        else
            BUFF__cout[i] = in[i];
    }
    return  BUFF__cout;
}

void    CreateInstance__cout(
                SdaiInstance    instance
            )
{
    assert(instance);

    cout << "#" << internalGetP21Line(instance);
}

void    CreateBoolean__cout(
                bool            value
            )
{
    if (value)
        cout << ".T.";
    else
        cout << ".F.";
}

void    CreateLogical__cout(
                char            * value
            )
{
    cout << "." << value << ".";
}

void    CreateEnumeration__cout(
                char            * value
            )
{
    cout << "." << value << ".";
}

void    CreateReal__cout(
                double          value
            )
{
    cout << value;
}

void    CreateInteger__cout(
                int_t           value
            )
{
    cout << value;
}

void    CreateString__cout(
                char            * value
            )
{
    if (value)
        cout << "'" << value << "'";
    else
        cout << "''";
}

void    CreateLineADB__cout(
                SdaiADB         ADB
            )
{
    cout << sdaiGetADBTypePath(ADB, sdaiSTRING);

    switch (sdaiGetADBType(ADB)) {
        case  sdaiADB:
            {
                SdaiADB    attributeDataBlock = 0;
                if (sdaiGetADBValue(ADB, sdaiADB, &attributeDataBlock)) {
                    CreateLineADB__cout(attributeDataBlock);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiAGGR:
            {
                SdaiAggr        valueAggr = nullptr;
                SdaiInstance    valueInstance = 0;
                if (sdaiGetADBValue(ADB, sdaiAGGR, &valueAggr)) {
                    cout << "(";
                    CreateLineAggregation__cout(valueAggr);
                    cout << ")";
                }
                else if (sdaiGetADBValue(ADB, sdaiINSTANCE, &valueInstance)) {
                    CreateInstance__cout(valueInstance);
                }
                else {
                    assert(false);
                }
            }
            break;
        case  sdaiINSTANCE:
            {
                SdaiInstance    value = 0;
                if (sdaiGetADBValue(ADB, sdaiINSTANCE, &value)) {
                    CreateInstance__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiBOOLEAN:
            {
                bool    value = false;
                if (sdaiGetADBValue(ADB, sdaiBOOLEAN, &value)) {
                    CreateBoolean__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiLOGICAL:
            {
                char    * value = nullptr;
                if (sdaiGetADBValue(ADB, sdaiLOGICAL, &value)) {
                    CreateLogical__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiENUM:
            {
                char    * value = nullptr;
                if (sdaiGetADBValue(ADB, sdaiENUM, &value)) {
                    CreateEnumeration__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiREAL:
            {
                double  value = 0.;
                if (sdaiGetADBValue(ADB, sdaiREAL, &value)) {
                    CreateReal__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiINTEGER:
            {
                int_t   value = 0;
                if (sdaiGetADBValue(ADB, sdaiINTEGER, &value)) {
                    CreateInteger__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiSTRING:
            {
                char    * value = nullptr;
                if (sdaiGetADBValue(ADB, sdaiEXPRESSSTRING, &value)) {
                    CreateString__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        default:
            assert(false);
            cout << "??";
            break;
    }

    cout << ")";
}

void    CreateLineAggregationElement__cout(
                SdaiAggr        aggregation,
                int_t           aggrType,
                SdaiInteger     index
            )
{
    switch (aggrType) {
        case  sdaiADB:
            {
                SdaiADB    attributeDataBlock = 0;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiADB, &attributeDataBlock)) {
                    CreateLineADB__cout(attributeDataBlock);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiAGGR:
            {
                SdaiAggr        valueAggr = nullptr;
                SdaiInstance    valueInstance = 0;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiAGGR, &valueAggr)) {
                    cout << "(";
                    CreateLineAggregation__cout(valueAggr);
                    cout << ")";
                }
                else if (sdaiGetAggrByIndex(aggregation, index, sdaiINSTANCE, &valueInstance)) {
                    CreateInstance__cout(valueInstance);
                }
                else {
                    assert(false);
                }
            }
            break;
        case  sdaiINSTANCE:
            {
                SdaiInstance    value = 0;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiINSTANCE, &value)) {
                    CreateInstance__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiBOOLEAN:
            {
                bool    value = false;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiBOOLEAN, &value)) {
                    CreateBoolean__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiLOGICAL:
            {
                char    * value = nullptr;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiLOGICAL, &value)) {
                    CreateLogical__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiENUM:
            {
                char    * value = nullptr;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiENUM, &value)) {
                    CreateEnumeration__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiREAL:
            {
                double  value = 0.;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiREAL, &value)) {
                    CreateReal__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiINTEGER:
            {
                int_t   value = 0;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiINTEGER, &value)) {
                    CreateInteger__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiSTRING:
            {
                char    * value = nullptr;
                if (sdaiGetAggrByIndex(aggregation, index, sdaiEXPRESSSTRING, &value)) {
                    CreateString__cout(value);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        default:
            assert(false);
            cout << "??";
            break;
    }
}

void    CreateLineAggregation__cout(
                SdaiAggr        aggregation
            )
{
    SdaiInteger memberCount = sdaiGetMemberCount(aggregation);
    if (memberCount == 0)
        return;

    int_t   aggrType = 0;
    engiGetAggrType(aggregation, &aggrType);

    SdaiInteger index = 0;
    CreateLineAggregationElement__cout(aggregation, aggrType, index++);
    while (index < memberCount) {
        cout << ", ";
        CreateLineAggregationElement__cout(aggregation, aggrType, index++);
    }
}

void    CreateLineAttribute__cout(
                SdaiInstance    instance,
                SdaiAttr        attribute
            )
{
    int_t   attrType = engiGetAttrType(attribute);
    if (attrType & engiTypeFlagAggr ||
        attrType & engiTypeFlagAggrOption)
        attrType = sdaiAGGR;

    switch (attrType) {
        case  sdaiADB:
            {
                SdaiADB    attributeDataBlock = 0;
                if (sdaiGetAttr(instance, attribute, sdaiADB, &attributeDataBlock)) {
                    assert(attributeDataBlock);
                    CreateLineADB__cout(attributeDataBlock);
                }
                else {
                    assert(false);
                    cout << "$";
                }
            }
            break;
        case  sdaiAGGR:
            {
                SdaiAggr        valueAggr = nullptr;
                SdaiInstance    valueInstance = 0;
                if (sdaiGetAttr(instance, attribute, sdaiAGGR, &valueAggr)) {
                    cout << "(";
                    CreateLineAggregation__cout(valueAggr);
                    cout << ")";
                }
                else if (sdaiGetAttr(instance, attribute, sdaiINSTANCE, &valueInstance)) {
                    CreateInstance__cout(valueInstance);
                }
                else {
                    cout << "$";
                }
            }
            break;
        case  sdaiINSTANCE:
            {
                SdaiInstance    value = 0;
                if (sdaiGetAttr(instance, attribute, sdaiINSTANCE, &value)) {
                    CreateInstance__cout(value);
                }
                else {
                    if (engiGetAttrDerived(sdaiGetInstanceType(instance), attribute)) {
                        cout << "*";
                    }
                    else {
                        cout << "$";
                    }
                }
            }
            break;
        case  sdaiBOOLEAN:
            {
                bool    value = false;
                if (sdaiGetAttr(instance, attribute, sdaiBOOLEAN, &value)) {
                    CreateBoolean__cout(value);
                }
                else {
                    cout << "$";
                }
            }
            break;
        case  sdaiLOGICAL:
            {
                char    * value = nullptr;
                if (sdaiGetAttr(instance, attribute, sdaiLOGICAL, &value)) {
                    CreateLogical__cout(value);
                }
                else {
                    cout << "$";
                }
            }
            break;
        case  sdaiENUM:
            {
                char    * value = nullptr;
                if (sdaiGetAttr(instance, attribute, sdaiENUM, &value)) {
                    CreateEnumeration__cout(value);
                }
                else {
                    cout << "$";
                }
            }
            break;
        case  sdaiREAL:
            {
                double  value = 0.;
                if (sdaiGetAttr(instance, attribute, sdaiREAL, &value)) {
                    CreateReal__cout(value);
                }
                else {
                    cout << "$";
                }
            }
            break;
        case  sdaiINTEGER:
            {
                int_t   value = 0;
                if (sdaiGetAttr(instance, attribute, sdaiINTEGER, &value)) {
                    CreateInteger__cout(value);
                }
                else {
                    cout << "$";
                }
            }
            break;
        case  sdaiSTRING:
            {
                char    * value = nullptr;
                if (sdaiGetAttr(instance, attribute, sdaiEXPRESSSTRING, &value)) {
                    CreateString__cout(value);
                }
                else {
                    cout << "$";
                }
            }
            break;
        default:
            assert(false);
            cout << "??";
            break;
    }
}

void    CreateLineInstance__cout(
                SdaiInstance    instance
            )
{
    //
    //  Create a generic line, similar to an IFC file in SPFF (STEP Phyical File Format)
    //
    char    * entityName = nullptr;
    engiGetEntityName(sdaiGetInstanceType(instance), sdaiSTRING, (const char**) &entityName);
    cout << "#" << internalGetP21Line(instance) << " = " << UpperCase__cout(entityName) << "(";

    bool    countedWithParents = true,
            countedWithInverse = false;

    SdaiEntity  entity = sdaiGetInstanceType(instance);
    SdaiInteger index = 0;
    SdaiAttr    attribute = engiGetEntityAttributeByIndex(
                                    entity,
                                    index++,
                                    countedWithParents,
                                    countedWithInverse
                                );
    CreateLineAttribute__cout(instance, attribute);
    while (attribute) {
        attribute = engiGetEntityAttributeByIndex(
                        entity,
                        index++,
                        countedWithParents,
                        countedWithInverse
                    );
        if (attribute) {
            cout << ", ";
            CreateLineAttribute__cout(instance, attribute);
        }
    }

    cout << ");\n";
}