MeVisLab Toolbox Reference
mlUtilsAPI.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_UTILS_API_H
14#define ML_UTILS_API_H
15
18
19// Attention: All includes must be pure C!
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#ifndef ML_DISABLE_CPP
26#define ML_DISABLE_CPP
27#endif
28
29#include "mlUtilsSystemC.h"
30
31//--------------------------------------------------------------------------------------------
32//
35//
36//--------------------------------------------------------------------------------------------
37
40
45
49[[nodiscard]]
51
54[[nodiscard]]
56
59
65
66
67//-----------------------------------------------------------------------------------
68//
71//
72//-----------------------------------------------------------------------------------
73
76
79
83
84
85//-----------------------------------------------------------------------------------
86//
89//
90//-----------------------------------------------------------------------------------
91
96
103
104
105
106//-----------------------------------------------------------------------------------
107//
110//
111//-----------------------------------------------------------------------------------
112
115
120
121
122//-----------------------------------------------------------------------------------
123//
126//
127//-----------------------------------------------------------------------------------
128
131
134
137
142
145
149
151ML_UTILS_EXPORT void MLSetThreadName(const char* threadName);
152
154
155
156//-----------------------------------------------------------------------------------
157//
160//
161//-----------------------------------------------------------------------------------
162
169
176
182ML_UTILS_EXPORT char* MLDoubleToStringCopy(double doubleValue);
184
185
186
187//--------------------------------------------------------------------------------------------------
188//
191//
192//--------------------------------------------------------------------------------------------------
193
198[[nodiscard]]
200
206[[nodiscard]]
207ML_UTILS_EXPORT void* MLRealloc(void* ptr, MLuint numBytes, MLMemoryErrorHandling handleFailure);
208
213ML_UTILS_EXPORT void MLFree(void* ptr);
214ML_UTILS_EXPORT void MLFreeMemoryManagerCallback(void* ptr, const size_t size, void* userData);
216
222[[nodiscard]]
223ML_UTILS_EXPORT void* MLMemDup(const void* src, MLuint numBytes, MLMemoryErrorHandling handleFailure);
224
228[[nodiscard]]
229ML_UTILS_EXPORT char* MLStrDup(const char* str, MLMemoryErrorHandling handleFailure);
231
232
233
234
235
236//-----------------------------------------------------------------------------------
237//
240//
241//-----------------------------------------------------------------------------------
249// void MLMessageCB(void* usrData,
250// MLErrorCode errCode,
251// MLMessageType messageType,
252// const char* messStr,
253// int line,
254// const char** infos)
278ML_UTILS_EXPORT void MLSetMessageCB(void* userData, MLMessageCB* callback);
279
283ML_UTILS_EXPORT void MLGetMessageCB(void** userData, MLMessageCB** callback);
285
286
287
288//-----------------------------------------------------------------------------------
289//
292//
293//-----------------------------------------------------------------------------------
296ML_UTILS_EXPORT void MLDebugAddEnvName(const char* envName);
297
301ML_UTILS_EXPORT void MLDebugRemoveEnvName(const char* envName);
302
306
310
314
318
319
320
321//-----------------------------------------------------------------------------------
322//
325//
326//-----------------------------------------------------------------------------------
348 const char* libraryPrefix,
349 const char* fPrefix,
350 const char* functionName,
351 const char* reason,
352 const char* handling,
353 const char* file,
354 int line,
355 MLErrorCode errCode);
356
361 int line,
362 MLErrorCode errCode);
363
371ML_UTILS_EXPORT void MLHandleDebugPrint(const char* envVar,
372 const char* libraryPrefix,
373 const char* outStr,
374 const char* file,
375 int line);
377
378
379//-----------------------------------------------------------------------------------
380//
383//
384//-----------------------------------------------------------------------------------
390
395
396
397//-----------------------------------------------------------------------------------
398//
401//
402//-----------------------------------------------------------------------------------
407
411
412
413//-----------------------------------------------------------------------------------
414//
417//
418//-----------------------------------------------------------------------------------
425
430
431
432//-----------------------------------------------------------------------------------
433//
436//
437//-----------------------------------------------------------------------------------
446
450
451
452//-----------------------------------------------------------------------------------
453//
456//
457//-----------------------------------------------------------------------------------
458
472 MLuint32 fromMessageId, MLuint32 toMessageId);
473
479
480
481//-----------------------------------------------------------------------------------
482//
485//
486//-----------------------------------------------------------------------------------
487
493
498
499
505
508
512
513//-----------------------------------------------------------------------------------
514//
517//
518//-----------------------------------------------------------------------------------
519
523
527
531
532
533//-----------------------------------------------------------------------------------
534//
537//
538//-----------------------------------------------------------------------------------
539
567ML_UTILS_EXPORT void* MLStringToPtr(const char* valueString, int postError, const char* errFunc);
569
570
571
572//--------------------------------------------------------------------------------------------------
573//
576//
577//--------------------------------------------------------------------------------------------------
580
584ML_UTILS_EXPORT void MLMakeLittleEndian(unsigned char* data, size_t numBytes, size_t dTypeSize);
585
589ML_UTILS_EXPORT void MLMakeBigEndian(unsigned char* data, size_t numBytes, size_t dTypeSize);
590
596ML_UTILS_EXPORT void MLSwapBytes(unsigned char* data, size_t numBytes, size_t dTypeSize);
598
599
600//-----------------------------------------------------------------------------------
601//
604//
605//-----------------------------------------------------------------------------------
608
612
613//-----------------------------------------------------------------------------------
614//
617//
618//-----------------------------------------------------------------------------------
621
625
626//-----------------------------------------------------------------------------------
627//
630//
631//-----------------------------------------------------------------------------------
634
638
639
645
646
647#ifdef __cplusplus
648}
649#endif
650
651#undef ML_DISABLE_CPP
652
653#endif // __mlUtilsAPI_H
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
MLTerminator
Termination types for error handling.
@ MLNumTerminators
MLMemoryErrorHandling
Enumerator to specify memory error handling.
Definition mlTypeDefs.h:675
MLuint32 MLThreadId
Definition mlTypeDefs.h:603
unsigned int MLuint32
Definition mlTypeDefs.h:184
MLuint64 MLuint
Definition mlTypeDefs.h:505
void MLEventFilterApplicationHookCB(void *applicationUsrData, MLEventFilterApplicationMessage type, MLEventFilterCB *cb, void *usrData, MLuint32 fromMessageId, MLuint32 toMessageId)
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Definition mlTypeDefs.h:411
void MLMessageCB(void *usrData, MLErrorCode errCode, MLMessageType messageType, const char *messStr, int line, const char **infos)
Handling/setting/getting of ML messages callbacks.
MLint32 MLEventFilterCB(void *usrData, void *event)
signed int MLint32
Definition mlTypeDefs.h:160
MLMessageType
Message types handled by the ErrorOutput class.
Definition mlTypeDefs.h:695
#define ML_UTILS_EXPORT
Definition mlUtilities.h:18
ML_UTILS_EXPORT size_t MLDebugGetNumEnvNames()
Returns number of registered debug environment names.
ML_UTILS_EXPORT const char * MLTerminatorStrings[MLNumTerminators]
Strings for MLTerminator enumeration.
ML_UTILS_EXPORT MLThreadId MLGetCurrentThreadID()
Returns the thread ID for the current thread.
ML_UTILS_EXPORT void MLRemoveEventFilterCB(MLEventFilterCB *cb, void *usrData)
ML_UTILS_EXPORT MLint32 MLIsCurrentThreadMainThread()
Returns whether the current thread equals the main thread (MLGetMainThreadID() == MLGetCurrentThreadI...
ML_UTILS_EXPORT void MLSetTraceDumpMessageBits(MLuint32 messageBitMask)
Sets the trace dump mask to messageBitMask.
ML_UTILS_EXPORT void MLAddEventFilterCB(MLEventFilterCB *cb, void *usrData, MLuint32 fromMessageId, MLuint32 toMessageId)
ML_UTILS_EXPORT const char * MLGetErrorCodeDescription(MLErrorCode errCode)
ML_UTILS_EXPORT MLint32 MLDebugHasEnvName(const char *envName)
ML_UTILS_EXPORT void MLPrintAndNotify(MLMessageType messageType, const char *libraryPrefix, const char *fPrefix, const char *functionName, const char *reason, const char *handling, const char *file, int line, MLErrorCode errCode)
ML_UTILS_EXPORT void MLSetApplicationPropertiesHook(MLApplicationPropertyCallbacks *callbacks)
ML_UTILS_EXPORT MLuint32 MLIsFullDebuggingEnabled()
Returns 1 if full debugging is enabled; otherwise, 0 is returned.
ML_UTILS_EXPORT MLuint32 MLGetMessageFilter()
ML_UTILS_EXPORT void MLMakeLittleEndian(unsigned char *data, size_t numBytes, size_t dTypeSize)
ML_UTILS_EXPORT MLuint32 MLGetRandomNumber()
ML_UTILS_EXPORT MLint32 MLUtilsDestroy()
Destroys MLUtils library. Returns 0 on error, 1 on success.
ML_UTILS_EXPORT MLEventFilterApplicationHookCB * MLGetEventFilterApplicationHookCB()
Returns the current MLEventFilterApplicationHookCB.
ML_UTILS_EXPORT MLuint32 MLIsExceptionHandlingEnabled()
Returns 1 if exception handling is enabled; otherwise, 0 is returned.
ML_UTILS_EXPORT void MLDebugRemoveEnvName(const char *envName)
ML_UTILS_EXPORT MLint32 MLIsUtilsInitialized()
Returns 1 if mlUtils is initialized, 0 otherwise.
ML_UTILS_EXPORT void * MLAlloc(MLuint numBytes, MLMemoryErrorHandling handleFailure)
ML_UTILS_EXPORT void MLHandleDebugPrint(const char *envVar, const char *libraryPrefix, const char *outStr, const char *file, int line)
ML_UTILS_EXPORT void MLSetMaxNumTraceStackDumps(MLuint32 numMaxEntries)
Sets the maximum number of trace stack entries to be shown on fatal error outputs to numMaxEntries.
ML_UTILS_EXPORT const char *const * MLGetErrorCodeDescriptionTable()
ML_UTILS_EXPORT void * MLRealloc(void *ptr, MLuint numBytes, MLMemoryErrorHandling handleFailure)
ML_UTILS_EXPORT char * MLInt64ToStringCopy(MLint64 int64Value)
ML_UTILS_EXPORT MLuint32 MLGetMaxNumTraceListDumps()
Returns the maximum number of trace list entries to be shown on fatal error outputs.
ML_UTILS_EXPORT void MLDebugAddEnvName(const char *envName)
ML_UTILS_EXPORT void MLSetTerminationType(MLMessageType level, MLTerminator term)
ML_UTILS_EXPORT MLuint32 MLGetMaxNumTraceStackDumps()
Returns the maximum number of trace stack entries to be shown on fatal error outputs.
ML_UTILS_EXPORT MLuint32 MLGetCheckBitMask()
ML_UTILS_EXPORT void MLSetEventFilterApplicationHook(MLEventFilterApplicationHookCB *cb, void *usrData)
ML_UTILS_EXPORT MLint32 MLIsMultithreadingActive()
Returns true if more than one ML thread is running; otherwise, it returns false.
ML_UTILS_EXPORT MLint32 MLSetNotifyEnabled(MLint32 flag)
ML_UTILS_EXPORT MLErrorCode MLFindErrorCodeDescription(const char *errorString)
ML_UTILS_EXPORT void MLMakeBigEndian(unsigned char *data, size_t numBytes, size_t dTypeSize)
ML_UTILS_EXPORT void MLSetMaxNumTraceListDumps(MLuint32 numMaxEntries)
Sets the maximum number of trace list entries to be shown on fatal error outputs to numMaxEntries.
ML_UTILS_EXPORT MLThreadId MLGetMainThreadID()
Returns the thread ID of the main thread, which is the thread from which the DLL was loaded.
ML_UTILS_EXPORT void MLDebugRemoveAllEnvNames()
ML_UTILS_EXPORT void MLSetThreadName(const char *threadName)
Sets the name of the thread for debugging purposes. This is currently only implemented for Windows.
ML_UTILS_EXPORT char * MLIntToStringCopy(int intValue)
ML_UTILS_EXPORT void MLSetCheckBitMask(MLuint32 bitMask)
ML_UTILS_EXPORT void MLSetMessageCB(void *userData, MLMessageCB *callback)
ML_UTILS_EXPORT void MLSetMainThreadID(MLThreadId threadId)
ML_UTILS_EXPORT MLint32 MLInitializeUtils()
Initializes library. Returns 0 on error, 1 on success.
ML_UTILS_EXPORT MLTerminator MLGetTerminationType(MLMessageType level)
ML_UTILS_EXPORT const char * MLDebugGetEnvName(MLuint32 envNameIdx)
ML_UTILS_EXPORT MLuint32 MLGetTraceDumpMessageBits()
Returns the trace dump bit mask.
ML_UTILS_EXPORT MLErrorCode MLEnableFullDebugging(MLuint32 enable)
ML_UTILS_EXPORT MLThreadId _MLMainThreadId
ML_UTILS_EXPORT void * MLGetEventFilterApplicationHookCBUserData()
Returns the user data for the current MLEventFilterApplicationHookCB.
ML_UTILS_EXPORT const MLApplicationPropertyCallbacks * MLGetApplicationPropertiesHook()
ML_UTILS_EXPORT char * MLStrDup(const char *str, MLMemoryErrorHandling handleFailure)
ML_UTILS_EXPORT MLuint32 MLGetNumErrorCodes()
Returns the number of available error codes.
ML_UTILS_EXPORT void MLSetMessageFilter(MLuint32 messageTypes)
ML_UTILS_EXPORT int MLSetHighPrecisionMessageTimeStampsEnabled(int enabled)
ML_UTILS_EXPORT char * MLDoubleToStringCopy(double doubleValue)
ML_UTILS_EXPORT void MLFreeMemoryManagerCallback(void *ptr, const size_t size, void *userData)
ML_UTILS_EXPORT void MLPrintAndNotifyFatal(const char *file, int line, MLErrorCode errCode)
ML_UTILS_EXPORT MLint32 MLCompareThreadIDs(const MLThreadId &id1, const MLThreadId &id2)
Returns 1 if the thread IDs id1 and id2 reference the same thread, 0 otherwise.
ML_UTILS_EXPORT void * MLStringToPtr(const char *valueString, int postError, const char *errFunc)
ML_UTILS_EXPORT void MLSwapBytes(unsigned char *data, size_t numBytes, size_t dTypeSize)
ML_UTILS_EXPORT void MLGetMessageCB(void **userData, MLMessageCB **callback)
ML_UTILS_EXPORT MLint32 MLIsNotifyEnabled()
Returns 1 if MLNotify is enabled, 0 otherwise.
ML_UTILS_EXPORT void * MLMemDup(const void *src, MLuint numBytes, MLMemoryErrorHandling handleFailure)
ML_UTILS_EXPORT MLErrorCode MLAddNewErrorCodeDescription(const char *errorString)
ML_UTILS_EXPORT void _MLSetMultithreadingActive(MLint32 isActive)
ML_UTILS_EXPORT MLErrorCode MLEnableExceptionHandling(MLuint32 enable)
ML_UTILS_EXPORT MLint32 MLIsLittleEndian()
Returns 1 (=true) if machine is little endian; otherwise, 0 (=false) is returned.
ML_UTILS_EXPORT void MLFree(void *ptr)
Defines all callbacks that an application has to support for property access.