Mstdlib-1.24.0
|
Enumerations | |
enum | M_str_int_retval_t { M_STR_INT_SUCCESS = 0 , M_STR_INT_OVERFLOW = 1 , M_STR_INT_INVALID = 2 } |
enum | M_str_hexdump_flags { M_STR_HEXDUMP_NONE = 0 , M_STR_HEXDUMP_DECLEN = 1 << 0 , M_STR_HEXDUMP_NOASCII = 1 << 1 , M_STR_HEXDUMP_HEADER = 1 << 2 , M_STR_HEXDUMP_NOLEN = 1 << 3 , M_STR_HEXDUMP_CRLF = 1 << 4 , M_STR_HEXDUMP_UPPER = 1 << 5 , M_STR_HEXDUMP_NOSECTS = 1 << 6 } |
Functions | |
long | M_atofi100 (const char *s) M_WARN_UNUSED_RESULT |
M_int64 | M_atofi_prec (const char *s, int impliedDecimals) M_WARN_UNUSED_RESULT |
M_int64 | M_str_to_int64 (const char *s) M_WARN_UNUSED_RESULT |
M_uint64 | M_str_to_uint64 (const char *s) M_WARN_UNUSED_RESULT |
M_str_int_retval_t | M_str_to_int64_ex (const char *s, size_t len, unsigned char base, M_int64 *val, const char **endptr) |
M_str_int_retval_t | M_str_to_uint64_ex (const char *s, size_t len, unsigned char base, M_uint64 *val, const char **endptr) |
M_str_int_retval_t | M_str_to_int32_ex (const char *s, size_t len, unsigned char base, M_int32 *val, const char **endptr) |
M_str_int_retval_t | M_str_to_uint32_ex (const char *s, size_t len, unsigned char base, M_uint32 *val, const char **endptr) |
M_int32 | M_str_to_int32 (const char *s) M_WARN_UNUSED_RESULT |
M_uint32 | M_str_to_uint32 (const char *s) M_WARN_UNUSED_RESULT |
char * | M_str_dot_money_out (const char *amount) |
char * | M_str_hexdump (int flags, size_t bytes_per_line, const char *line_prefix, const unsigned char *data, size_t data_len) |
String Conversion
enum M_str_int_retval_t |
enum M_str_hexdump_flags |
Hex dump flags
long M_atofi100 | ( | const char * | s | ) |
Convert a string representing money (a fractional decimal amount) to an integer number of cents. Fractional amounts are rounded to the nearest cent.
s | String containing a floating point (2 decimal places) money representation. |
M_int64 M_atofi_prec | ( | const char * | s, |
int | impliedDecimals | ||
) |
Convert a floating point number into a 64bit integer using arbitrary precision as defined by impliedDecimals.
For instance, if impliedDecimals is 5, and 12.34 is passed, the resulting value would be 1234000.
[in] | s | string to convert to decimal |
[in] | impliedDecimals | Number of implied decimals resulting output should have |
M_int64 M_str_to_int64 | ( | const char * | s | ) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
M_uint64 M_str_to_uint64 | ( | const char * | s | ) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
M_str_int_retval_t M_str_to_int64_ex | ( | const char * | s, |
size_t | len, | ||
unsigned char | base, | ||
M_int64 * | val, | ||
const char ** | endptr | ||
) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
[in] | len | Maximum length of given string to parse. |
[in] | base | Valid range 2 - 36. 0 to autodetect based on input (0x = hex, 0 = octal, anything else is decimal). |
[out] | val | Integer to store result. |
[out] | endptr | Pointer to store the end of the parsed string. |
M_str_int_retval_t M_str_to_uint64_ex | ( | const char * | s, |
size_t | len, | ||
unsigned char | base, | ||
M_uint64 * | val, | ||
const char ** | endptr | ||
) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
[in] | len | Maximum length of given string to parse. |
[in] | base | Valid range 2 - 36. 0 to autodetect based on input (0x = hex, 0 = octal, anything else is decimal). |
[out] | val | Integer to store result. |
[out] | endptr | Pointer to store the end of the parsed string. |
M_str_int_retval_t M_str_to_int32_ex | ( | const char * | s, |
size_t | len, | ||
unsigned char | base, | ||
M_int32 * | val, | ||
const char ** | endptr | ||
) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
[in] | len | Maximum length of given string to parse. |
[in] | base | Valid range 2 - 36. 0 to autodetect based on input (0x = hex, 0 = octal, anything else is decimal). |
[out] | val | Integer to store result. |
[out] | endptr | Pointer to store the end of the parsed string. |
M_str_int_retval_t M_str_to_uint32_ex | ( | const char * | s, |
size_t | len, | ||
unsigned char | base, | ||
M_uint32 * | val, | ||
const char ** | endptr | ||
) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
[in] | len | Maximum length of given string to parse. |
[in] | base | Valid range 2 - 36. 0 to autodetect based on input (0x = hex, 0 = octal, anything else is decimal). |
[out] | val | Integer to store result |
[out] | endptr | Pointer to store the end of the parsed string. |
M_int32 M_str_to_int32 | ( | const char * | s | ) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
M_uint32 M_str_to_uint32 | ( | const char * | s | ) |
Interpret a string as an ascii numeric. String may begin with whitespace which will be ignored, then an optional + or - sign.
[in] | s | NULL-terminated string. |
char * M_str_dot_money_out | ( | const char * | amount | ) |
Verify and convert the amount so it always has 2 decimal digits.
Example: 1 for $1 and turns it into 1.00. 1.1 for $1.10 and turns it into 1.10.
[in] | amount | Amount to verify/convert. |
char * M_str_hexdump | ( | int | flags, |
size_t | bytes_per_line, | ||
const char * | line_prefix, | ||
const unsigned char * | data, | ||
size_t | data_len | ||
) |
Generate a hex dump format of binary data meant to be human-readable, or imported via various hex-dump conversion tools such as Text2pcap.
flags | one or more enum M_str_hexdump_flags |
bytes_per_line | Number of bytes represented per line. If zero is used, defaults to 16 |
line_prefix | Prefix each line of the hex dump with the given data. |
data | Binary data to be dumped |
data_len | length of binary data to be dumped |