Mstdlib-1.24.0
|
Data Structures | |
struct | M_bitlist_t |
Enumerations | |
enum | M_bitlist_flags_t { M_BITLIST_FLAG_NONE = 0 , M_BITLIST_FLAG_DONT_TRIM_WHITESPACE = 1<<0 , M_BITLIST_FLAG_CASE_SENSITIVE = 1<<1 , M_BITLIST_FLAG_IGNORE_DUPLICATE_ID = 1<<2 , M_BITLIST_FLAG_IGNORE_UNKNOWN = 1<<3 , M_BITLIST_FLAG_DONT_REQUIRE_POWEROF2 = 1<<4 } |
Functions | |
M_bool | M_bitlist_list (char **out, M_bitlist_flags_t flags, const M_bitlist_t *list, M_uint64 bits, unsigned char delim, char *error, size_t error_len) |
M_bool | M_bitlist_parse (M_uint64 *out, M_bitlist_flags_t flags, const M_bitlist_t *list, const char *data, unsigned char delim, char *error, size_t error_len) |
M_bool | M_bitlist_tohash (M_hash_stru64_t **hash_toint, M_hash_u64str_t **hash_tostr, M_bitlist_flags_t flags, const M_bitlist_t *list, char *error, size_t error_len) |
M_bool | M_bitlist_hash_parse (M_uint64 *out, M_bitlist_flags_t flags, const M_hash_stru64_t *hash_toint, const char *data, unsigned char delim, char *error, size_t error_len) |
const char * | M_bitlist_single_tostr (const M_bitlist_t *list, M_uint64 id) |
M_uint64 | M_bitlist_single_toint (const M_bitlist_t *list, const char *name) |
Allows for easy creation of a data structure to parse and generate human readable flags lists made up of bits.
struct M_bitlist_t |
enum M_bitlist_flags_t |
Flags that may be passed on to the parser or human-readable generator
M_bool M_bitlist_list | ( | char ** | out, |
M_bitlist_flags_t | flags, | ||
const M_bitlist_t * | list, | ||
M_uint64 | bits, | ||
unsigned char | delim, | ||
char * | error, | ||
size_t | error_len | ||
) |
Generate a human-readable list from the array provided and bits provided, delimited by the specified delimiter. Note that there is not a 'hash' version of this function as it would likely be less efficient and would also not support the ability to handle aggregate entries that might contain more than 1 bit set.
[out] | out | Null-terminated string representing the human-readable bit list |
[in] | flags | Flags used when generating the list or determining errors |
[in] | list | Array passed in defining all bits to human-readable |
[in] | bits | Machine-readable bits passed in to be converted |
[in] | delim | Delimiter for human-readable list output |
[in,out] | error | Buffer to hold error string. |
[in] | error_len | Length of error buffer |
M_bool M_bitlist_parse | ( | M_uint64 * | out, |
M_bitlist_flags_t | flags, | ||
const M_bitlist_t * | list, | ||
const char * | data, | ||
unsigned char | delim, | ||
char * | error, | ||
size_t | error_len | ||
) |
Generate an integer after parsing the provided human-readable string of bits/flags.
[out] | out | 64bit integer of set bits |
[in] | flags | Flags used when parsing the provided human-readable string |
[in] | list | Array passed in defining all bits to human-readable name |
[in] | data | Human-readable bits/flags in null terminated string form |
[in] | delim | Delimiter for human-readable list input |
[in,out] | error | Buffer to hold error string. |
[in] | error_len | Length of error buffer |
M_bool M_bitlist_tohash | ( | M_hash_stru64_t ** | hash_toint, |
M_hash_u64str_t ** | hash_tostr, | ||
M_bitlist_flags_t | flags, | ||
const M_bitlist_t * | list, | ||
char * | error, | ||
size_t | error_len | ||
) |
Convert a bitlist into hash implementations for more efficient lookups.
[out] | hash_toint | Hashtable for conversion from string to integer. |
[out] | hash_tostr | Hashtable for conversion from integer to string. |
[in] | flags | Flags used when generating the list or determining errors. |
[in] | list | Array passed in defining all bits to human-readable name |
[in,out] | error | Buffer to hold error string. |
[in] | error_len | Length of error buffer |
M_bool M_bitlist_hash_parse | ( | M_uint64 * | out, |
M_bitlist_flags_t | flags, | ||
const M_hash_stru64_t * | hash_toint, | ||
const char * | data, | ||
unsigned char | delim, | ||
char * | error, | ||
size_t | error_len | ||
) |
Generate an integer after parsing the provided human-readable string of bits/flags.
[out] | out | 64bit integer of set bits |
[in] | flags | Flags used when parsing the provided human-readable string |
[in] | hash_toint | hash_toint returned from M_bitlist_tohash() with appropriate list. |
[in] | data | Human-readable bits/flags in null terminated string form |
[in] | delim | Delimiter for human-readable list input |
[in,out] | error | Buffer to hold error string. |
[in] | error_len | Length of error buffer |
const char * M_bitlist_single_tostr | ( | const M_bitlist_t * | list, |
M_uint64 | id | ||
) |
Extract a single name from a bitlist that exactly matches the passed in id.
[in] | list | Array passed in defining all bits to human-readable name |
[in] | id | ID to match |
M_uint64 M_bitlist_single_toint | ( | const M_bitlist_t * | list, |
const char * | name | ||
) |
Extract a single id from a bitlist that exactly matches the passed in name.
[in] | list | Array passed in defining all bits to human-readable name |
[in] | name | name to match |