Value
#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!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?