Value
#include "max/c/value.h"
#include "max/c/value.h"
Functions
M_getValueByNameFrom()
M_AsyncValue *M_getValueByNameFrom(M_AsyncTensorMap *valueMap, const char *valueName, M_Status *status)
Gets a value from the value map by name.
-
Parameters:
- valueMap – The value map.
- valueName – The name of the value.
- status – The status object for reporting errors.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is simply borrowed from the corresponding inputM_AsyncTensorMap
. If the value map or name are invalid, aNULL
pointer is returned and thestatus
parameter contains an error message.
M_getValueFromMapIterator()
M_AsyncValue *M_getValueFromMapIterator(M_TensorMapIterator *iterator)
Gets the tensor from the tensor map iterator.
-
Parameters:
iterator – The tensor map iterator.
-
Returns:
A pointer to the tensor. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeTensor()
. The held tensor inside the return value is simply borrowed from the corresponding inputM_AsyncTensorMap
. If the tensor map iterator is invalid, aNULL
pointer is returned.
M_freeValue()
void M_freeValue(M_AsyncValue *value)
Deallocates the memory for the container. No-op if container
is NULL
.
-
Parameters:
container – The container to deallocate.
M_getStringFromValue()
const char *M_getStringFromValue(M_AsyncValue *value)
Gets a string from the async value.
-
Parameters:
value – The async value.
-
Returns:
A null-terminated string if the
value
is valid. Otherwise,NULL
. The memory associated with the returned string is owned by thevalue
.
M_createStringAsyncValue()
M_AsyncValue *M_createStringAsyncValue(const char *data, M_RuntimeContext *context)
Creates a string wrapped in an AsyncValue
.
-
Parameters:
- data – The zero-terminated string data.
- context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_getDoubleFromValue()
double M_getDoubleFromValue(M_AsyncValue *value)
Gets a double from the async value.
-
Parameters:
value – The async value.
-
Returns:
A double value.
M_createDoubleAsyncValue()
M_AsyncValue *M_createDoubleAsyncValue(double value, M_RuntimeContext *context)
Creates a double value wrapped in an AsyncValue
.
-
Parameters:
- value – The double value.
- context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_getLongFromValue()
int64_t M_getLongFromValue(M_AsyncValue *value)
Gets a long from the async value.
-
Parameters:
value – The async value.
-
Returns:
A long value.
M_createLongAsyncValue()
M_AsyncValue *M_createLongAsyncValue(int64_t value, M_RuntimeContext *context)
Creates a long value wrapped in an AsyncValue
.
-
Parameters:
- value – The long value.
- context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_getBoolFromValue()
bool M_getBoolFromValue(M_AsyncValue *value)
Gets a boolean from the async value.
-
Parameters:
value – The async value.
-
Returns:
A boolean value.
M_createBoolAsyncValue()
M_AsyncValue *M_createBoolAsyncValue(bool value, M_RuntimeContext *context)
Creates a boolean value wrapped in an AsyncValue
.
-
Parameters:
- value – The boolean value.
- context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_borrowValueInto()
void M_borrowValueInto(M_AsyncTensorMap *tensors, const char *name, const M_AsyncValue *value, M_Status *status)
Adds a value to the tensor map.
You are responsible for the lifetime of the input value. It gets “borrowed” into the TensorMap
.
-
Parameters:
- tensors – The tensor map, from
M_newAsyncTensorMap()
. - name – The zero-terminated string data, representing the name of the value.
- value – The input value.
- status – The status object for reporting errors.
- tensors – The tensor map, from
M_getValueType()
M_ValueType M_getValueType(M_AsyncValue *value)
Returns the type contained in the underlying value.
-
Parameters:
value – The async value.
-
Returns:
An enum describing the type of the underlying value. Returns
M_UNKNOWN_VALUE
for unsupported values and if the value is invalid.
M_getDictFromValue()
M_AsyncDict *M_getDictFromValue(M_AsyncValue *value)
Gets a Dict
from the async value.
-
Parameters:
value – The async value.
-
Returns:
A pointer to the
Dict
. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by callingM_freeDict()
. The heldDict
inside the return value is simply borrowed from theM_AsyncValue
. If the value is invalid or not aDict
, aNULL
pointer is returned.
M_createDictAsyncValue()
M_AsyncValue *M_createDictAsyncValue(M_RuntimeContext *context)
Creates an empty Dict
wrapped in an AsyncValue
.
-
Parameters:
context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_insertIntoDict()
void M_insertIntoDict(M_AsyncDict *dict, M_AsyncValue *key, M_AsyncValue *value)
Inserts a key-value pair to the Dict
.
You are responsible for the lifetime of the key and value. Their data gets “borrowed” into the Dict
. No-op if either the dict, key or value are invalid.
-
Parameters:
- dict – The dict to insert into.
- key – The key to insert.
- value – The value to insert.
M_getListFromValue()
M_AsyncList *M_getListFromValue(M_AsyncValue *value)
Gets a List
from the async value.
-
Parameters:
value – The async value.
-
Returns:
A pointer to the
List
. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by callingM_freeList()
. The heldList
inside the return value is simply borrowed from theM_AsyncValue
. If the value is invalid or not aList
, aNULL
pointer is returned.
M_createListAsyncValue()
M_AsyncValue *M_createListAsyncValue(M_RuntimeContext *context)
Creates an empty List
wrapped in an AsyncValue
.
-
Parameters:
context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_appendToList()
void M_appendToList(M_AsyncList *list, M_AsyncValue *value)
Appends a value to the List
.
You are responsible for the lifetime of the value. Its data gets “borrowed” into the List
. No-op if either the list or value are invalid.
-
Parameters:
- list – The list to append onto.
- value – The value to append.
M_getTupleFromValue()
M_AsyncTuple *M_getTupleFromValue(M_AsyncValue *value)
Gets a Tuple
from the async value.
-
Parameters:
value – The async value.
-
Returns:
A pointer to the
Tuple
. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by callingM_freeTuple()
. The heldTuple
inside the return value is simply borrowed from theM_AsyncValue
. If the value is invalid or not aTuple
, aNULL
pointer is returned.
M_borrowIntoTuple()
void M_borrowIntoTuple(M_AsyncTuple *tuple, M_AsyncValue *value)
Adds a value to the Tuple
.
You are responsible for the lifetime of the value. Its data gets “borrowed” into the Tuple
. No-op if either the tuple or value are invalid.
-
Parameters:
- tuple – The tuple to add into.
- value – The value to add.
M_createTupleAsyncValue()
M_AsyncValue *M_createTupleAsyncValue(M_RuntimeContext *context)
Creates an empty Tuple
wrapped in an AsyncValue
.
-
Parameters:
context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_getDictSize()
size_t M_getDictSize(M_AsyncDict *dict)
Returns the number of elements in the Dict
.
-
Parameters:
dict – The dict.
-
Returns:
The number of elements in the
Dict
. Returns 0 if the dict is invalid.
M_getListSize()
size_t M_getListSize(M_AsyncList *list)
Returns the number of elements in the List
.
-
Parameters:
list – The list.
-
Returns:
The number of elements in the
List
. Returns 0 if the list is invalid.
M_getTupleSize()
size_t M_getTupleSize(M_AsyncTuple *tuple)
Returns the number of elements in the Tuple
.
-
Parameters:
tuple – The tuple.
-
Returns:
The number of elements in the
Tuple
. Returns 0 if the tuple is invalid.
M_getDictKey()
M_AsyncValue *M_getDictKey(M_AsyncDict *dict, size_t i)
Returns the dict key at position i
.
-
Parameters:
- dict – The dict.
- i – The index to return.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
. If the dict is invalid or the index out of bounds, aNULL
pointer is returned.
M_getDictValue()
M_AsyncValue *M_getDictValue(M_AsyncDict *dict, size_t i)
Returns the dict value at position i
.
-
Parameters:
- dict – The dict.
- i – The index to return.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
. If the dict is invalid or the index out of bounds, aNULL
pointer is returned.
M_getListValue()
M_AsyncValue *M_getListValue(M_AsyncList *list, size_t i)
Returns the list value at position i
.
-
Parameters:
- list – The list.
- i – The index to return.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
. If the list is invalid or the index out of bounds, aNULL
pointer is returned.
M_getTupleValue()
M_AsyncValue *M_getTupleValue(M_AsyncTuple *tuple, size_t i)
Returns the tuple value at position i
.
-
Parameters:
- dict – The tuple.
- i – The index to return.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
. If the tuple is invalid or the index out of bounds, aNULL
pointer is returned.
M_createNoneAsyncValue()
M_AsyncValue *M_createNoneAsyncValue(M_RuntimeContext *context)
Creates a None
value wrapped in an AsyncValue
.
-
Parameters:
context – The runtime context.
-
Returns:
A pointer to the value. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling
M_freeValue()
. The held value inside the return value is owned by theAsyncValue
.
M_freeDict()
void M_freeDict(M_AsyncDict *dict)
Deallocates the memory for the dictionary. No-op if dict
is NULL
.
-
Parameters:
dict – The dictionary to deallocate.
M_freeList()
void M_freeList(M_AsyncList *list)
Deallocates the memory for the list. No-op if list
is NULL
.
-
Parameters:
list – The list to deallocate.
M_freeTuple()
void M_freeTuple(M_AsyncTuple *list)
Deallocates the memory for the tuple. No-op if tuple
is NULL
.
-
Parameters:
list – The list to deallocate.
M_freeNone()
void M_freeNone(M_AsyncNone *none)
Deallocates the memory for the none value. No-op if none
is NULL
.
-
Parameters:
list – The list to deallocate.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
😔 What went wrong?