OS
v1.7.5
Documentation
|
Utilities. More...
Typedefs | |
using | putChar_t |
Pointer to function that write-out a single character. | |
using | ioFcn_t |
Pointer to function that perform a single character I/O operation. | |
Functions | |
char * | strchr (const char *s, int c, size_t maxlen) noexcept |
Returns a pointer to the first occurrence of character in the C string s. The terminating null-character is considered part of the C string. Therefore, it can also be located in order to retrieve a pointer to the end of a string. | |
size_t | strlen (const char *s, size_t maxlen) noexcept |
Returns the length of the given null-terminated byte string, that is, the number of characters in a character array whose first element is pointed to by str up to and not including the first null character. The function returns zero if str is a null pointer and returns maxlen if the null character was not found in the first maxlen bytes of str. | |
size_t | strcpy (char *dst, const char *src, size_t maxlen) noexcept |
Copies up to (maxlen - 1) characters from the null-terminated string src to dst, null-terminating the result. | |
size_t | strcat (char *dst, const char *src, size_t maxlen) noexcept |
appends no more than maxlen−len(dst)−1 characters pointed to by src into the array pointed to by dst and always terminates the result with a null character if maxlen is greater than zero. Both the strings dst and src must be terminated with a null character on entry the function and a byte for the terminating null should be included in maxlen. | |
bool | swapBytes (void *pData, const size_t n) noexcept |
Invert the endianess for n bytes of the specified memory location. | |
bool | checkEndianness (void) noexcept |
Check the system endianess. | |
bool | outputString (util::putChar_t fcn, const char *s, void *pStorage=nullptr, bool aip=false) noexcept |
API interface to write a string through fcn. | |
bool | printXData (util::putChar_t fcn, void *pData, size_t n, bool eol=true, void *pStorage=nullptr) noexcept |
API interface to write data in HEX notation through fcn. | |
bool | outputRAW (const ioFcn_t fcn, void *pData, const size_t n, void *pStorage=nullptr, bool aip=false) noexcept |
API interface to write n RAW data through fcn. | |
bool | inputRAW (const ioFcn_t fcn, void *pData, const size_t n, void *pStorage=nullptr, bool aip=false) noexcept |
API interface to get n RAW data through fcn. | |
uint32_t | hexStringToUnsigned (const char *s) noexcept |
Converts the input string consisting of hexadecimal digits into an unsigned integer value. The input parameter should consist exclusively of hexadecimal digits, with optional whitespaces. The string will be processed one character at a time, until the function reaches a character which it doesn't recognize (including a null character). | |
float64_t | stringToFloat (const char *s) noexcept |
Parses the C string s, interpreting its content as a floating point number and returns its value as a float( float32_t ). The function first discards as many whitespace characters (as in isspace) as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax resembling that of floating point literals, and interprets them as a numerical value. The rest of the string after the last valid character is ignored and has no effect on the behavior of this function. | |
char * | floatToString (float64_t num, char *str, uint8_t precision=10U) noexcept |
Converts a float value to a formatted string. | |
int | stringToInt (const char *s) noexcept |
Parses the C-string s interpreting its content as an integral number, which is returned as a value of type int. The function first discards as many whitespace characters (as in isspace ) as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many base-10 digits as possible, and interprets them as a numerical value. The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace characters in s is not a valid integral number, or if no such sequence exists because either s is empty or it contains only whitespace characters, no conversion is performed and zero is returned. | |
char * | unsignedToString (unsigned_t num, char *str, uint8_t base=10U) noexcept |
Converts an unsigned value to a null-terminated string using the specified base and stores the result in the array given by str parameter. The argument str should be an array long enough to contain any possible value: "sizeof(int)*8+1" for radix=2, i.e. 17 bytes in 16-bits platforms and 33 in 32-bits platforms. | |
char * | integerToString (signed_t num, char *str, uint8_t base=10U) noexcept |
Converts an integer value to a null-terminated string using the specified base and stores the result in the array given by str parameter. If base is 10 and value is negative, the resulting string is preceded with a minus sign (-). With any other base, value is always considered unsigned. | |
char * | boolToString (const bool num, char *str) noexcept |
Converts a boolean value to a null-terminated string. Input is considered true with any value different to zero (0). The argument str should be an array long enough to contain the output. | |
Utilities.