![]() |
F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
|
Enumerations | |
| enum | StringToNumberStatus { SUCCESSFUL_CONVERSION, NULL_INPUT, INVALID_STRING, INVALID_BASE, INVALID_NUMBER, INVALID_RANGE } |
Functions | |
| char * | string_copy (char *destination, const char *source, FwSizeType num) |
| copy string with null-termination guaranteed More... | |
| FwSizeType | string_length (const CHAR *source, FwSizeType buffer_size) |
| get the length of the source string More... | |
| FwSignedSizeType | substring_find (const CHAR *source_string, FwSizeType source_size, const CHAR *sub_string, FwSizeType sub_size) |
| find the first occurrence of a substring More... | |
| StringToNumberStatus | string_to_number (const CHAR *input, FwSizeType buffer_size, U8 &output, char **next, U8 base=0) |
| converts a string to a U8 More... | |
| StringToNumberStatus | string_to_number (const CHAR *input, FwSizeType buffer_size, I8 &output, char **next, U8 base=0) |
| converts a string to a I8 More... | |
| StringToNumberStatus | string_to_number (const CHAR *input, FwSizeType buffer_size, F32 &output, char **next) |
| converts a string to a F32 More... | |
| Enumerator | |
|---|---|
| SUCCESSFUL_CONVERSION | Output should be valid. |
| NULL_INPUT | A null string was supplied. |
| INVALID_STRING | No \0 detected within the supplied length. |
| INVALID_BASE | Base was not supplied as 0, or 2-36. |
| INVALID_NUMBER | String did not contain a valid number matching supplied base. |
| INVALID_RANGE | |
Definition at line 52 of file StringUtils.hpp.
| char * Fw::StringUtils::string_copy | ( | char * | destination, |
| const char * | source, | ||
| FwSizeType | num | ||
| ) |
copy string with null-termination guaranteed
Standard implementations of strncpy fail to guarantee the termination of a string with the null terminator. This implementation guarantees the string is properly null-terminated at the possible expense of the last character of the copied string being lost. The user is responsible for providing a destination large enough for the content and a null-character. Other behavior retains the behavior of strncpy.
| destination | destination buffer to hold copied contents |
| source | source buffer to read content to copy |
| num | length of destination buffer |
Definition at line 7 of file StringUtils.cpp.
| FwSizeType Fw::StringUtils::string_length | ( | const CHAR * | source, |
| FwSizeType | buffer_size | ||
| ) |
get the length of the source string
If no string termination character is detected within buffer_size number of characters then buffer_size is returned. When buffer_size is returned, it can be assumed that the source string is invalid within a bound of buffer_size.
| source | string to calculate the length |
| buffer_size | the size of the buffer containing source string. |
Definition at line 24 of file StringUtils.cpp.
| Fw::StringUtils::StringToNumberStatus Fw::StringUtils::string_to_number | ( | const CHAR * | input, |
| FwSizeType | buffer_size, | ||
| U8 & | output, | ||
| char ** | next, | ||
| U8 | base = 0 |
||
| ) |
converts a string to a U8
See string_to_number (above) for full explanation.
| input | input string |
| buffer_size | maximum length of string bounding the conversion |
| base | base of the number. 0 to detect decimal, octal, hexadecimal. 2-36 to use specified base. |
| output | (output) will contain the converted number or 0 on error |
| next | (output) will contain a pointer to the next character after the number and null pointer on error |
Definition at line 100 of file StringToNumber.cpp.
| Fw::StringUtils::StringToNumberStatus Fw::StringUtils::string_to_number | ( | const CHAR * | input, |
| FwSizeType | buffer_size, | ||
| I8 & | output, | ||
| char ** | next, | ||
| U8 | base = 0 |
||
| ) |
converts a string to a I8
See string_to_number (above) for full explanation.
| input | input string |
| buffer_size | maximum length of string bounding the conversion |
| base | base of the number. 0 to detect decimal, octal, hexadecimal. 2-36 to use specified base. |
| output | (output) will contain the converted number or 0 on error |
| next | (output) will contain a pointer to the next character after the number and null pointer on error |
Definition at line 103 of file StringToNumber.cpp.
| Fw::StringUtils::StringToNumberStatus Fw::StringUtils::string_to_number | ( | const CHAR * | input, |
| FwSizeType | buffer_size, | ||
| F32 & | output, | ||
| char ** | next | ||
| ) |
converts a string to a F32
See string_to_number (above) for full explanation. base is not supported on floating point conversions.
| input | input string |
| buffer_size | maximum length of string bounding the conversion |
| base | base of the number. 0 to detect decimal, octal, hexadecimal. 2-36 to use specified base. |
| output | (output) will contain the converted number or 0 on error |
| next | (output) will contain a pointer to the next character after the number and null pointer on error |
Definition at line 118 of file StringToNumber.cpp.
| FwSignedSizeType Fw::StringUtils::substring_find | ( | const CHAR * | source_string, |
| FwSizeType | source_size, | ||
| const CHAR * | sub_string, | ||
| FwSizeType | sub_size | ||
| ) |
find the first occurrence of a substring
| source_string | string to search for the substring |
| source_size | the size of the source string |
| substring | string to search for |
| sub_size | the size of the string to search for |
Definition at line 35 of file StringUtils.cpp.