interop.h
Include dependency graph for interop.h:
This graph shows which files directly or indirectly include interop.h:
Defines
-
SELECT_INT_DEFAULT(i_val)
{ \
.as_val = NULL, i_val \
}
An idiomatic macro for marking an AtomStringIntPair table entry as a interop_atom_term_select_int default.
Typedefs
-
typedef InteropFunctionResult (*interop_chardata_fold_fun)(term t, void *accum)
-
typedef void (*interop_chardata_rest_fun)(term t, void *accum)
Enums
-
enum InteropFunctionResult
Values:
-
enumerator InteropOk
-
enumerator InteropMemoryAllocFail
-
enumerator InteropBadArg
-
enumerator InteropOk
-
enum UnicodeConversionResult
Values:
-
enumerator UnicodeMemoryAllocFail = InteropMemoryAllocFail
-
enumerator UnicodeBadArg = InteropBadArg
-
enumerator UnicodeError
-
enumerator UnicodeIncompleteTransform
-
enumerator UnicodeMemoryAllocFail = InteropMemoryAllocFail
Functions
-
char *interop_term_to_string(term t, int *ok)
-
char *interop_binary_to_string(term binary)
-
char *interop_list_to_utf8_string(term list, int *ok)
-
char *interop_list_to_string(term list, int *ok)
-
char *interop_iolist_to_string(term list, int *ok)
-
term interop_proplist_get_value(term list, term key)
-
term interop_proplist_get_value_default(term list, term key, term default_value)
-
term interop_map_get_value(GlobalContext *glb, term map, term key)
-
term interop_map_get_value_default(GlobalContext *glb, term map, term key, term default_value)
-
term interop_chars_to_list(const char *chars, size_t len, Heap *heap)
- NO_DISCARD InteropFunctionResult interop_iolist_size (term t, size_t *size)
- NO_DISCARD InteropFunctionResult interop_write_iolist (term t, char *p)
- inline NO_DISCARD InteropFunctionResult interop_chardata_fold (term t, interop_chardata_fold_fun fold_fun, interop_chardata_rest_fun rest_fun, void *accum)
- NO_DISCARD enum UnicodeConversionResult interop_chardata_to_bytes_size (term t, size_t *size, size_t *rest_size, enum CharDataEncoding in_encoding, enum CharDataEncoding out_encoding)
- NO_DISCARD enum UnicodeConversionResult interop_chardata_to_bytes (term t, uint8_t *output, term *rest, enum CharDataEncoding in_encoding, enum CharDataEncoding out_encoding, Heap *heap)
-
int interop_atom_term_select_int(const AtomStringIntPair *table, term atom, GlobalContext *global)
Finds on a table the first matching atom string.
Allows to quickly translate atoms to any integer constant. This function is useful for creating switch statements for atom values. A linear search is performed, so table entries should be sorted by frequency.
- Parameters:
table – an array AtomStringIntPair structs, terminated with a default entry marked with SELECT_INT_DEFAULT macro.
atom – the atom used for comparison.
global – the global context.
- Returns:
the found int value which corresponds to the given atom.
-
term interop_atom_term_select_atom(const AtomStringIntPair *table, int value, GlobalContext *global)
Finds the first matching atom in an atoms table .
Allows to quickly translate integer constants to an atom in an atoms table. This function is the inverse of interop_atom_term_select_int.
- Parameters:
table – an array AtomStringIntPair structs, terminated with a default entry marked with SELECT_INT_DEFAULT macro.
value – the in value used for comparison.
global – the global context.
- Returns:
the found atom which corresponds to the given int value, or the invalid term, if there is no such value in the table.
-
term interop_kv_get_value_default(term kv, AtomString key, term default_value, GlobalContext *glb)
Get a value given a key (as AtomString) from any proplist or map.
This function allows to easily get values from proplists or maps, without poluting the atom table.
- Parameters:
kv – any proplist or map.
key – an AtomString, such as ATOM_STR(“\x3”, “key”).
default_value – that is returned in case of missing item.
glb – the global context.
- Returns:
the value term in case given key exists, otherwise the default_value.
-
static inline term interop_kv_get_value(term kv, AtomString key, GlobalContext *glb)
Get a value given a key (as AtomString) from any proplist or map.
This function allows to easily get values from proplists or maps, without poluting the atom table. This function returns the invalid term if there is no such entry in kv.
- Parameters:
kv – any proplist or map.
key – an AtomString, such as ATOM_STR(“\x3”, “key”).
glb – the global context.
- Returns:
the value term in case given key exists, otherwise the invalid term.
-
static inline term interop_bytes_to_list(const void *bytes, int len, Heap *heap)
-
struct AtomStringIntPair
- #include <interop.h>
A structure to represent atom strings and int pairs. Such as {“\x8” “universe”, 42}.