F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Fw::StringUtils Namespace Reference

Functions

char * string_copy (char *destination, const char *source, U32 num)
 copy string with null-termination guaranteed More...
 
U32 string_length (const CHAR *source, U32 max_len)
 get the length of the source string or max_len if the string is longer than max_len. 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...
 

Function Documentation

◆ string_copy()

char * Fw::StringUtils::string_copy ( char *  destination,
const char *  source,
U32  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.

Parameters
destinationdestination buffer to hold copied contents
sourcesource buffer to read content to copy
numlength of destination buffer
Returns
destination buffer

Definition at line 6 of file StringUtils.cpp.

◆ string_length()

U32 Fw::StringUtils::string_length ( const CHAR source,
U32  max_len 
)

get the length of the source string or max_len if the string is longer than max_len.

Parameters
sourcestring to calculate the length
max_lenthe maximum length of the source string
Returns
length of the source string or max_len

Definition at line 23 of file StringUtils.cpp.

◆ substring_find()

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

Parameters
source_stringstring to search for the substring
source_sizethe size of the source string
substringstring to search for
sub_sizethe size of the string to search for
Returns
index of substring, -1 if not found

Definition at line 34 of file StringUtils.cpp.