engiOpenModelByStream

This function opens the model via a stream. Attribute repository will be ignored, they are their because of backward compatibility. A handle to the model will be returned, or 0 in case something went wrong.

Syntax

//
//   Strong typing definition
//
SdaiModel       engiOpenModelByStream(
                        SdaiRep                 repository,
                        const void              * callback,
                        const char              * schemaName
                    );

static  inline  SdaiModel   engiOpenModelByStream(
                                    SdaiRep                 repository,
                                    const void              * callback,
                                    char                    * schemaName
                                )
{
    return  engiOpenModelByStream(
                    repository,
                    callback,
                    (const char*) schemaName
                );
}


//
//   Weak typing definition
//
int_t   __declspec(dllexport) __stdcall engiOpenModelByStream(
                                                int_t                   repository,
                                                const void              * callback,
                                                const char              * schemaName
                                            );

static  inline  int_t   engiOpenModelByStream(
                                int_t                   repository,
                                const void              * callback,
                                char                    * schemaName
                            )
{
    return  engiOpenModelByStream(
                    repository,
                    callback,
                    (const char*) schemaName
                );
}
    

Property repository

Size: 64 bit / 8 byte (value)
Ignore this attribute, the value will be ignored in the current implementation, present for backwards compatibility.

Property callback

Size: 64 bit / 8 byte (reference)
The pointer to the function that will be called within this function. Please look at the examples how to create the callback function and how it will be called. In case this is not possible or complex there is an array call, technically the same call, however the callback function is embedded within the library.

Property schemaName

Size: 64 bit / 8 byte (reference)
The schema name of the file as available in the file system in ASCII (char *). The given char array will not be adjusted, on each OS the size of a char element is 8 bit / 1 byte.

Example (based on pure API calls)

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

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

const int_t BLOCK_LENGTH_READ = 20000;  //  MAX: 65535

FILE        * myFileRead = nullptr;

int_t   __stdcall   ReadCallBackFunction(unsigned char * content)
{
    if (myFileRead == nullptr || feof(myFileRead)) {
        return  -1;
    }

    int_t   size = fread(content, 1, BLOCK_LENGTH_READ, myFileRead);

    return  size;
}

SdaiModel   OpenModelByStream(wchar_t * fileName)
{
    assert(myFileRead == nullptr);

    _wfopen_s(&myFileRead, fileName, L"rb");
    if (&myFileRead) {
        SdaiModel   model = engiOpenModelByStream(0, &ReadCallBackFunction, "");

        fclose(myFileRead);
        myFileRead = nullptr;

        return  model;
    }

    assert(false);
    return  0;
}