4#ifndef MATHWORKS_MPS_CLIENT
5#define MATHWORKS_MPS_CLIENT
7#define MPS_CLIENT_1_0 0x00010000
8#define MPS_CLIENT_1_1 0x00010001
11#define MPS_MAX_VER MPS_CLIENT_1_1
15#define MPS_DLL_EXPORT_SYM __declspec(dllexport)
16#define MPS_DLL_IMPORT_SYM __declspec(dllimport)
18#define MPS_DLL_EXPORT_SYM __attribute__((visibility("default")))
19#define MPS_DLL_IMPORT_SYM __attribute__((visibility("default")))
21#define MPS_DLL_EXPORT_SYM
22#define MPS_DLL_IMPORT_SYM
25#if defined(BUILDING_MPSCLIENT)
26#define MPSCLIENT_PUBLISHED_API MPS_DLL_EXPORT_SYM
28#define MPSCLIENT_PUBLISHED_API MPS_DLL_IMPORT_SYM
32#define MPSCLIENT_PUBLISHED_API_EXTERN_C extern "C" MPSCLIENT_PUBLISHED_API
34#define MPSCLIENT_PUBLISHED_API_EXTERN_C extern MPSCLIENT_PUBLISHED_API
40typedef unsigned __int64
uint64;
71#ifndef TMW_BITS_PER_INT
73#define TMW_BITS_PER_INT 8
74#elif INT_MAX == 0x7FFFL
75#define TMW_BITS_PER_INT 16
76#elif INT_MAX == 0x7FFFFFFFL
77#define TMW_BITS_PER_INT 32
79#define TMW_BITS_PER_INT -1
83#ifndef TMW_BITS_PER_LONG
85#define TMW_BITS_PER_LONG 8
86#elif LONG_MAX == 0x7FFFL
87#define TMW_BITS_PER_LONG 16
88#elif LONG_MAX == 0x7FFFFFFFL
89#define TMW_BITS_PER_LONG 32
91#define TMW_BITS_PER_LONG -1
95#ifndef TMW_BITS_PER_SCHAR
97#define TMW_BITS_PER_SCHAR 8
98#elif SCHAR_MAX == 0x7FFFL
99#define TMW_BITS_PER_SCHAR 16
100#elif SCHAR_MAX == 0x7FFFFFFFL
101#define TMW_BITS_PER_SCHAR 32
103#define TMW_BITS_PER_SCHAR -1
107#ifndef TMW_BITS_PER_SHRT
109#define TMW_BITS_PER_SHRT 8
110#elif SHRT_MAX == 0x7FFFL
111#define TMW_BITS_PER_SHRT 16
112#elif SHRT_MAX == 0x7FFFFFFFL
113#define TMW_BITS_PER_SHRT 32
115#define TMW_BITS_PER_SHRT -1
120#if TMW_BITS_PER_INT == 16
121#define UINT16_T unsigned int
122#elif TMW_BITS_PER_LONG == 16
123#define UINT16_T unsigned long
124#elif TMW_BITS_PER_SCHAR == 16
125#define UINT16_T unsigned char
126#elif TMW_BITS_PER_SHRT == 16
127#define UINT16_T unsigned short
132#if (defined(__cplusplus) && (__cplusplus + 0 >= 201103L)) || \
133 (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT)
135#elif defined(_MSC_VER)
143#if !defined(__cplusplus)
145typedef unsigned char bool;
422#if MPS_MAX_VER >= MPS_CLIENT_1_1
756 const char** fieldnames);
770 const char** fieldnames);
990 const char* fieldname);
1001 const char* fieldname,
1016 const char* fieldname);
bool mpsIsSparse(const mpsArray *mlArr)
Determine whether array is sparse.
bool mpsIsUint8(const mpsArray *mlArr)
Determine whether mpsArray represents data as unsigned 8-bit integers.
int mpsGetNumberOfFields(const mpsArray *mlArr)
Determine the number of fields in an array of struct.
int mpsSetDimensions(mpsArray *mlArr, const mpsSize *dims, mpsSize ndim)
Modify number of dimensions and size of each dimension of an array.
mpsErrorInfoType
Types of errors that can be thrown when MATLAB function invocation fails.
@ MPS_GENERIC_ERROR_INFO
Any error other than MATLAB execution error or a non-200 HTTP response.
@ MPS_HTTP_ERROR_INFO
A non-200 HTTP response when MATLAB function in invoked from the client.
@ MPS_MATLAB_ERROR_INFO
A MATLAB execution error.
mpsLogical * mpsGetLogicals(const mpsArray *mlArr)
Access the first logical element in an array.
mpsArray * mpsCreateCellMatrix(mpsSize m, mpsSize n)
Create a two-dimensional cell array.
size_t mpsGetNumberOfElements(const mpsArray *mlArr)
Determine how many elements are in the array.
bool mpsIsDouble(const mpsArray *mlArr)
Determine whether mpsArray represents data as double-precision, floating-point numbers.
double mpsGetScalar(const mpsArray *mlArr)
Determine the value of the first real element of an array.
#define MPSCLIENT_PUBLISHED_API_EXTERN_C
bool mpsIsLogicalScalarTrue(const mpsArray *mlArr)
Determine whether scalar array is true.
mpsArray * mpsCreateLogicalScalar(mpsLogical value)
Create a scalar logical array.
bool mpsIsStruct(const mpsArray *mlArr)
Determine whether input is structure array.
int mpsAddField(mpsArray *mlArr, const char *fieldname)
Add a field to an array of struct.
struct mpsClientContext mpsClientContext
Establishes a connection between a client and a server.
mpsComplexity
Flag specifying whether array has imaginary components.
@ mpsREAL
Identifies an mpsArray with no imaginary components.
@ mpsCOMPLEX
Identifies an mpsArray with imaginary components.
mpsArray * mpsCreateSparse(mpsSize m, mpsSize n, mpsSize nzmax, mpsComplexity complexFlag)
Create a two-dimensional sparse array.
mpsArray * mpsCreateCellArray(mpsSize ndim, const mpsSize *dims)
Create a N-dimensional cell array.
uint64 mpsSize
Type that represents size values, such as array dimensions.
bool mpsIsUint32(const mpsArray *mlArr)
Determine whether mpsArray represents data as unsigned 32-bit integers.
mpsArray * mpsGetCell(const mpsArray *mlArr, mpsIndex index)
Access the contents of a cell array at a specified index.
mpsArray * mpsCreateLogicalMatrix(mpsSize m, mpsSize n)
Create a two-dimensional logical array.
void mpsSetM(mpsArray *mlArr, mpsSize m)
Set the first dimension of an array.
bool mpsIsUint64(const mpsArray *mlArr)
Determine whether mpsArray represents data as unsigned 64-bit integers.
mpsChar * mpsGetChars(const mpsArray *mlArr)
Access the data in a character array.
const char * mpsGetInitializationErrorMessage(void)
Returns the error message representing the failure in global initialization that sets up the programm...
uint64 mpsIndex
Type that represents index values, such as indices into arrays.
bool mpsIsInt32(const mpsArray *mlArr)
Determine whether mpsArray represents data as signed 32-bit integers.
int mpsGetFieldNumber(const mpsArray *mlArr, const char *fieldname)
Determine the number of a field in an array of struct given the field name.
bool mpsIsClass(const mpsArray *mlArr, const char *classname)
Determine whether array is member of specified class.
mpsArray * mpsCreateString(const char *str)
Create a string array.
mpsArray * mpsCreateLogicalArray(mpsSize ndim, const mpsSize *dims)
Create a N-dimensional logical array.
int mpsGetString(const mpsArray *mlArr, char *str, mpsSize len)
Copy the character data of a string array into a C-style string.
size_t mpsGetElementSize(const mpsArray *mlArr)
Determine the number of bytes in each data element of an array.
mpsArray * mpsCreateNumericMatrix(mpsSize m, mpsSize n, mpsClassID classid, mpsComplexity complexFlag)
Create a two-dimensional numeric array.
mpsSize mpsGetNumberOfDimensions(const mpsArray *mlArr)
Determine the number of dimensions in an array.
mpsArray * mpsCreateCharMatrixFromStrings(mpsSize rows, const char **str)
Create a two-dimensional string array.
void mpsSetNzmax(mpsArray *mlArr, mpsSize nzmax)
Set the maximum number of non-zero elements in a sparse array.
mpsClassID mpsGetClassID(const mpsArray *mlArr)
Determine the class of an array.
mpsIndex * mpsGetJc(const mpsArray *mlArr)
Determine the starting address of the jc array in a sparse array.
size_t mpsGetM(const mpsArray *mlArr)
Determine the first dimension of an array.
bool mpsIsSingle(const mpsArray *mlArr)
Determine whether mpsArray represents data as single-precision, floating-point numbers.
mpsArray * mpsCreateSparseLogicalMatrix(mpsSize m, mpsSize n, mpsSize nzmax)
Create a two-dimensional sparse array.
bool mpsIsEmpty(const mpsArray *mlArr)
Determine whether array is empty.
double * mpsGetPr(const mpsArray *mlArr)
Access the real data in an array of doubles.
mpsSize mpsGetNzmax(const mpsArray *mlArr)
Determine the number of non-zero elements in a sparse array.
mpsArray * mpsCreateCharArray(mpsSize ndim, const mpsSize *dims)
Create a N-dimensional string array.
void mpsTerminate(void)
Perform global clean up of resources consumed by MATLAB Production Server client environment.
void mpsSetFieldByNumber(mpsArray *mlArr, mpsIndex index, int fieldnumber, mpsArray *pvalue)
Set the value held in the specified field number at the indexed element of an array.
mpsArray * mpsCreateDoubleScalar(double value)
Create a scalar double-precision floating-point array.
bool mpsLogical
Type for logical array.
mpsClassID
Flag identifying class of array.
@ mpsCHAR_CLASS
Identifies a string mpsArray.
@ mpsINT8_CLASS
Identifies a numeric mpsArray whose data is stored as either char or byte.
@ mpsINT64_CLASS
Identifies a numeric mpsArray whose data is stored as long long.
@ mpsUINT8_CLASS
Identifies a numeric mpsArray whose data is stored as either unsigned char or byte.
@ mpsDOUBLE_CLASS
Identifies a numeric mpsArray whose data is stored as double.
@ mpsINT32_CLASS
Identifies a numeric mpsArray whose data is stored as int.
@ mpsINT16_CLASS
Identifies a numeric mpsArray whose data is stored as short.
@ mpsUINT16_CLASS
Identifies a numeric mpsArray whose data is stored as unsigned short.
@ mpsSTRUCT_CLASS
Identifies a structure mpsArray.
@ mpsCELL_CLASS
Identifies a cell mpsArray.
@ mpsUINT64_CLASS
Identifies a numeric mpsArray whose data is stored as unsigned long long.
@ mpsSINGLE_CLASS
Identifies a numeric mpsArray whose data is stored as float.
@ mpsUINT32_CLASS
Identifies a numeric mpsArray whose data is stored as unsigned int.
@ mpsLOGICAL_CLASS
Identifies a logical mpsArray.
bool mpsIsUint16(const mpsArray *mlArr)
Determine whether mpsArray represents data as unsigned 16-bit integers.
mpsIndex * mpsGetIr(const mpsArray *mlArr)
Determine the starting address of the ir array in a sparse array.
mpsArray * mpsDuplicateArray(const mpsArray *mlArr)
Make a deep copy of input mpsArray.
bool mpsIsComplex(const mpsArray *mlArr)
Determine whether mpsArray contains an imaginary part.
void mpsRemoveField(mpsArray *mlArr, int fieldnumber)
Delete a field from an array of struct.
const char * mpsGetClassName(const mpsArray *mlArr)
Determine the class of an array.
double * mpsGetPi(const mpsArray *mlArr)
Access the imaginary data in an array of doubles.
mpsIndex mpsCalcSingleSubscript(const mpsArray *mlArr, mpsSize nsubs, mpsIndex *subs)
Determine how many elements there are between the beginning of an array and a given element.
bool mpsIsNumeric(const mpsArray *mlArr)
Determine whether mpsArray contains numeric data.
size_t mpsGetN(const mpsArray *mlArr)
Determine the number of columns in an array.
bool mpsIsLogical(const mpsArray *mlArr)
Determine whether mpsArray represents data as mpsLogical.
bool mpsIsCell(const mpsArray *mlArr)
Determine whether input is cell array.
void mpsSetN(mpsArray *mlArr, mpsSize n)
Set the number of columns in an array.
mpsArray * mpsCreateStructArray(mpsSize ndim, const mpsSize *dims, int nfields, const char **fieldnames)
Create a N-dimensional struct array.
mpsStatus
Error status codes for all methods which are part of the MATLAB Production Server client API.
@ MPS_OK
Successful invocation of a method.
mpsClientRuntime * mpsInitialize(void)
Set up the programming environment for MATLAB Production Server client based on version 1....
void mpsDestroyArray(mpsArray *mlArr)
Deallocate the memory occupied by an array.
bool mpsIsInt8(const mpsArray *mlArr)
Determine whether mpsArray represents data as signed 8-bit integers.
bool mpsIsInt64(const mpsArray *mlArr)
Determine whether mpsArray represents data as signed 64-bit integers.
mpsArray * mpsGetFieldByNumber(const mpsArray *mlArr, mpsIndex index, int fieldnumber)
Access the value held in the specified field number at the indexed element of an array.
char * mpsArrayToString(const mpsArray *mlArr)
Copy the character data of a string array into a C-style string.
void mpsSetCell(mpsArray *mlArr, mpsIndex index, mpsArray *value)
Set the contents of a cell array at a specified index.
void * mpsGetImagData(const mpsArray *mlArr)
Access the imaginary data in an array.
void * mpsGetData(const mpsArray *mlArr)
Access the real numeric data in an array.
const mpsSize * mpsGetDimensions(const mpsArray *mlArr)
Determine how many elements are in each dimension of an array.
bool mpsIsInt16(const mpsArray *mlArr)
Determine whether mpsArray represents data as signed 16-bit integers.
bool mpsIsLogicalScalar(const mpsArray *mlArr)
Determine whether MATLAB treats the scalar data in the mpsArray as logical or numerical.
mpsArray * mpsCreateStructMatrix(mpsSize m, mpsSize n, int nfields, const char **fieldnames)
Create a two-dimensional struct array.
void mpsSetField(mpsArray *mlArr, mpsIndex index, const char *fieldname, mpsArray *pvalue)
Set the value held in the specified element of the specified field of an array of struct.
mpsClientRuntime * mpsInitializeEx(int version)
Set up the programming environment for MATLAB Production Server client based on the version number pr...
const char * mpsGetFieldNameByNumber(const mpsArray *mlArr, int fieldnumber)
Determine the name of a field in an array of struct given the field number.
bool mpsIsChar(const mpsArray *mlArr)
Determine whether mpsArray represents a string array.
struct mpsClientConfig mpsClientConfig
Structure containing information configuring the connection between the client and a server instance.
void mpsFree(void *data)
Deallocate heap space using the MATLAB memory management facility.
mpsArray * mpsCreateNumericArray(mpsSize ndim, const mpsSize *dims, mpsClassID classid, mpsComplexity complexFlag)
Create a two-dimensional numeric array.
mpsArray * mpsGetField(const mpsArray *mlArr, mpsIndex index, const char *fieldname)
Access the value held in the specified element of the specified field of an array of struct.
mpsArray * mpsCreateDoubleMatrix(mpsSize m, mpsSize n, mpsComplexity complexFlag)
Create a two-dimensional double-precision floating-point array.
struct mpsArray mpsArray
Fundamental type underlying MATLAB data.
Entry in the MATLAB runtime stack.
const char * function
Name of the MATLAB function which in most cases is same as the MATLAB file name.
const char * file
Name of the MATLAB file that threw the MATLAB error.
int line
Line number in the MATLAB file where the error occurred.
MATLAB Production Server client API container.
mpsStatus(* createConfig)(mpsClientConfig **config)
Initialize pointer to MATLAB Production Server client configuration instance with default values.
void(* setCAFile)(mpsClientConfig *config, const char *caFile)
Set file Certificate Authority file in PEM format.
mpsLogical(* getVerifyPeer)(const mpsClientConfig *config)
Get the peer verification flag value.
void(* setVerifyPeer)(mpsClientConfig *config, mpsLogical verifyPeer)
Setting this flag to false will not peform the authentication of server certificate.
void(* setClientCertFile)(mpsClientConfig *config, const char *certFile)
MPS_CLIENT_1_1 version provides support for request execution using HTTPS protocol for secure client-...
mpsLogical(* getVerifyHost)(const mpsClientConfig *config)
Get the host verification flag value.
void(* setPrivateKeyPasswd)(mpsClientConfig *config, const char *passwd)
Set password for private key file.
mpsStatus(* feval)(mpsClientContext *context, const char *url, int nlhs, mpsArray *plhs[], int nrhs, const mpsArray *prhs[])
Invoke MATLAB function hosted by a server instance and available at a Url.
void(* getLastErrorInfo)(mpsClientContext const *context, mpsErrorInfo *errorInfo)
Access the error thrown while invoking a MATLAB function from the client A MATLAB function invocation...
void(* setPrivateKeyFile)(mpsClientConfig *config, const char *pkFile)
Set private key file in PEM format.
mpsStatus(* createContext)(mpsClientContext **context, const mpsClientConfig *config)
Initialize the MATLAB Production Server client execution context.
void(* setRevocationListFile)(mpsClientConfig *config, const char *crlFile)
Set the revocation list file.
void(* destroyContext)(mpsClientContext *context)
Clean up the memory allocated for the client execution context.
unsigned int(* getResponseSizeLimit)(const mpsClientConfig *config)
Get the responze size limit value, in bytes, for the client.
unsigned long(* getResponseTimeOutSec)(const mpsClientConfig *config)
Get the timeout value, in seconds, for the client to receive response from the server.
void(* destroyLastErrorInfo)(mpsErrorInfo *errorInfo)
Cleans up dynamic memory allocated while initializing mpsErrorInfo instance.
void(* destroyConfig)(mpsClientConfig *config)
Clean up the memory allocated to the client configuration instance.
void(* setVerifyHost)(mpsClientConfig *config, mpsLogical verifyHost)
Setting this flag to true will verify the hostname in thr url against the common name in the certific...
void(* setResponseSizeLimit)(mpsClientConfig *config, unsigned int value)
Set the response size limit value, in bytes, for the client.
void(* setResponseTimeOutSec)(mpsClientConfig *config, unsigned long value)
Set the timeout value, in seconds, for the client to receive response from the server.
Details about an error not caused by non-200 HTTP errors or MATLAB execution errors.
const char * genericErrorMsg
Error message corresponding to the generic error.
Details about a non-200 HTTP response.
const char * responseMessage
HTTP response message.
unsigned int responseCode
HTTP response code.
Details about a MATLAB execution error.
size_t matlabStackDepth
Number of entries in the MATLAB stack.
const char * message
Error message corresponding to the error thrown in MATLAB.
const matlabStackFrame * matlabStack
MATLAB stack associated with the MATLAB error.
const char * identifier
Unique error identifier corresponding to the MATLAB error.
Error thrown when a MATLAB function is invoked by the MATLAB Production Server client context.
union mpsErrorInfo::@0 details
All possible errors that can be thrown when a MATLAB function is invoked from the client.
mpsErrorInfoType type
Type of underlying error.
mpsErrorInfoGeneric general
Error other than MATLAB execution error and non-200 HTTP response.
char const * message
Message regarding the error.
mpsErrorInfoHTTP http
Error caused by a non-200 HTTP response.
mpsErrorInfoMATLAB matlab
Error thrown during execution of MATLAB code.