String table is a data type to store integers or pointers to more complex data in pairs.
More...
|
#define | SOL_STR_TABLE_INT64_ITEM(_key, _val) |
| Helper macro to make easier to declare a <key, value> pair. More...
|
|
#define | sol_str_table_int64_lookup(_table_int64, _key, _pval) |
| Similar to sol_str_table_int64_lookup_fallback, but returning true/false. More...
|
|
#define | SOL_STR_TABLE_INT64_NOT_FOUND INT64_MAX |
| flag to detect key 'misses' in sol_str_table_int64_lookup. More...
|
|
#define | SOL_STR_TABLE_ITEM(_key, _val) { .key = SOL_STR_STATIC_ASSERT_LITERAL(_key), .len = sizeof(_key) - 1, .val = _val } |
| Helper macro to make easier to declare a <key, int16_t> pair. More...
|
|
#define | sol_str_table_lookup(_table, _key, _pval) |
| Similar to sol_str_table_lookup_fallback, but returning true/false. More...
|
|
#define | SOL_STR_TABLE_NOT_FOUND INT16_MAX |
| flag to detect key 'misses' in sol_str_table_lookup. More...
|
|
#define | SOL_STR_TABLE_PTR_ITEM(_key, _val) |
| Helper macro to make easier to declare a <key, value> pair. More...
|
|
#define | sol_str_table_ptr_lookup(_table_ptr, _key, _pval) |
| Similar to sol_str_table_ptr_lookup_fallback, but returning true/false. More...
|
|
String table is a data type to store integers or pointers to more complex data in pairs.
It could be a table of <string, 16-bit integer>, <string, int64_t> or <string, pointer> pairs.
#define SOL_STR_TABLE_INT64_ITEM |
( |
|
_key, |
|
|
|
_val |
|
) |
| |
Value:
.len = sizeof(_key) - 1, \
.val = _val }
#define SOL_STR_STATIC_ASSERT_LITERAL(_s)
Helper macro to assert that the parameter is a string literal.
Definition: sol-str-slice.h:57
Helper macro to make easier to declare a <key, value> pair.
- Parameters
-
_key | Pair's key (string) |
_val | Pair's value (int64_t) |
#define sol_str_table_int64_lookup |
( |
|
_table_int64, |
|
|
|
_key, |
|
|
|
_pval |
|
) |
| |
Value:({ \
*_pval = _v; \
})
int64_t sol_str_table_int64_lookup_fallback(const struct sol_str_table_int64 *table_int64, const struct sol_str_slice key, int64_t fallback)
Retrieves the value associated with a given key from the string/int64_t table.
#define SOL_STR_TABLE_INT64_NOT_FOUND
flag to detect key 'misses' in sol_str_table_int64_lookup.
Definition: sol-str-table.h:291
Similar to sol_str_table_int64_lookup_fallback, but returning true/false.
Returns true/false depending if key is found/not found and write the found value in _pval
. If not found, errno is set to ENOENT
. If parameters where invalid, errno is set to EINVAL
.
- Parameters
-
_table_int64 | The string/int64_t table |
_key | Key to search |
_pval | int64_t to int64_t that will hold the found value |
- See Also
- sol_str_table_lookup_fallback
#define SOL_STR_TABLE_INT64_NOT_FOUND INT64_MAX |
Helper macro to make easier to declare a <key, int16_t> pair.
For larger integers see struct sol_str_table_int64, for pointers see struct sol_str_table_ptr.
- Parameters
-
_key | Pair's key (string) |
_val | Pair's value (integer) |
#define sol_str_table_lookup |
( |
|
_table, |
|
|
|
_key, |
|
|
|
_pval |
|
) |
| |
Value:({ \
if (_v != INT16_MAX) \
*_pval = _v; \
_v != INT16_MAX; \
})
int16_t sol_str_table_lookup_fallback(const struct sol_str_table *table, const struct sol_str_slice key, int16_t fallback)
Retrieves the value associated with a given key from the string table.
Similar to sol_str_table_lookup_fallback, but returning true/false.
Returns true/false depending if key is found/not found and write the found value in _pval
. If not found, errno is set to ENOENT
. If parameters were invalid, errno is set to EINVAL
.
- Note
- Uses
SOL_STR_TABLE_NOT_FOUND
as a flag to detect when key isn't found, so this value cannot be used in the string table for use with this macro.
- Parameters
-
_table | The string table |
_key | Key to search |
_pval | Pointer that will hold the found value |
- See Also
- sol_str_table_lookup_fallback
#define SOL_STR_TABLE_NOT_FOUND INT16_MAX |
#define SOL_STR_TABLE_PTR_ITEM |
( |
|
_key, |
|
|
|
_val |
|
) |
| |
Value:
.val = _val, \
.len = sizeof(_key) - 1 }
#define SOL_STR_STATIC_ASSERT_LITERAL(_s)
Helper macro to assert that the parameter is a string literal.
Definition: sol-str-slice.h:57
Helper macro to make easier to declare a <key, value> pair.
- Parameters
-
_key | Pair's key (string) |
_val | Pair's value (pointer) |
#define sol_str_table_ptr_lookup |
( |
|
_table_ptr, |
|
|
|
_key, |
|
|
|
_pval |
|
) |
| |
Value:({ \
_key, NULL); \
if (_v != NULL) \
*_pval = _v; \
_v != NULL; \
})
const void * sol_str_table_ptr_lookup_fallback(const struct sol_str_table_ptr *table_ptr, const struct sol_str_slice key, const void *fallback)
Retrieves the value associated with a given key from the string/pointer table.
Similar to sol_str_table_ptr_lookup_fallback, but returning true/false.
Returns true/false depending if key is found/not found and write the found value in _pval
. If not found, errno is set to ENOENT
. If parameters were invalid, errno is set to EINVAL
.
- Parameters
-
_table_ptr | The string/pointer table |
_key | Key to search |
_pval | Pointer to pointer that will hold the found value |
- See Also
- sol_str_table_lookup_fallback
String/int64_t table type.
String/Pointer table type.
Retrieves the table entry associated with a given key from the string/integer table.
Searches table for key
string and returns its table entry pointer. If key
isn't found (or a bad table argument is passed), NULL
is returned and errno
is set (either to EINVAL
or to ENOENT
).
- Parameters
-
table | String/integer table |
key | Key to search |
- Returns
- If
key
is found, it returns its table entry, otherwise NULL
is returned and errno is set to ENOENT
if the item was not found or to EINVAL
if parameters were invalid.
Retrieves the table entry associated with a given key from the string/pointer table.
Searches table for key
string and returns its table entry pointer. If key
isn't found (or a bad table argument is passed), NULL
is returned and errno
is set (either to EINVAL
or to ENOENT
).
- Parameters
-
table | String/pointer table |
key | Key to search |
- Returns
- If
key
is found, it returns its table entry, otherwise NULL
is returned and errno is set to ENOENT
if the item was not found or to EINVAL
if parameters were invalid.
Retrieves the value associated with a given key from the string/int64_t table.
Searches table for key
string and returns its int64_t value. If key
isn't found, fallback
is returned.
- Parameters
-
table_int64 | String/int64_t table |
key | Key to search |
fallback | Fallback int64_t |
- Returns
- If
key
is found, return its value, otherwise fallback
is returned and errno is set to ENOENT
if item is not found of EINVAL
if parameters were invalid.
Retrieves the value associated with a given key from the string table.
Searches the string table for key
and returns its value. If key
isn't found, fallback
is returned.
- Parameters
-
table | String table |
key | Key to search |
fallback | Fallback value |
- Returns
- If
key
is found, return its value, otherwise fallback
is returned and errno is set to ENOENT
if item is not found of EINVAL
if parameters were invalid.
Retrieves the table entry associated with a given key from the string/pointer table.
Searches table for key
string and returns its table entry pointer. If key
isn't found (or a bad table argument is passed), NULL
is returned and errno
is set (either to EINVAL
or to ENOENT
).
- Parameters
-
table | String/pointer table |
key | Key to search |
- Returns
- If
key
is found, it returns its table entry, otherwise NULL
is returned and errno is set to ENOENT
if the item was not found or to EINVAL
if parameters were invalid.
Retrieves the value associated with a given key from the string/pointer table.
Searches table for key
string and returns its pointer. If key
isn't found, fallback
is returned.
- Parameters
-
table_ptr | String/pointer table |
key | Key to search |
fallback | Fallback pointer |
- Returns
- If
key
is found, return its value, otherwise fallback
is returned and errno is set to ENOENT
if item is not found of EINVAL
if parameters were invalid.