35 lines
1.6 KiB
C
35 lines
1.6 KiB
C
|
|
#ifndef RR_STRING_UTILITY_H
|
|
#define RR_STRING_UTILITY_H
|
|
|
|
#include <librr/types.h>
|
|
|
|
/// @brief Gets the length of a null-terminated string.
|
|
/// @param string A null-terminated string of which to get the length.
|
|
/// @return The length of the given string.
|
|
usz_t rr_measure_string(const char *string);
|
|
|
|
/// @brief Compares two strings completely until the end.
|
|
/// @param string1 First string to compare.
|
|
/// @param string2 Second string to compare. If there's a clear correct way for the
|
|
/// first string to be, this should be the correct string to be tested against.
|
|
/// @return Whether the two strings' contents are equal.
|
|
bool_t rr_strings_equal(const char *string1, const char *string2);
|
|
|
|
/// @brief Compares two strings up to a maximum given length, returning TRUE if they end
|
|
/// before or if they are equal up to the maximum length.
|
|
/// @param string1 First string to compare.
|
|
/// @param string2 Second string to compare. If there's a clear correct way for the
|
|
/// first string to be, this should be the correct string to be tested against.
|
|
/// @param max_length How many bytes to test at most; it can be less nonetheless.
|
|
/// @return Whether the two strings' contents are equal up to the given length.
|
|
bool_t rr_strings_equal_up_to(const char *string1, const char *string2, usz_t max_length);
|
|
|
|
/// @brief Tests if 'base' starts with 'prefix'.
|
|
/// @param base Base string to be tested for starting with 'prefix'.
|
|
/// @param prefix The prefix which 'base' should have.
|
|
/// @return Whether the string 'base' starts with the string 'prefix'.
|
|
bool_t rr_string_is_prefixed(const char *base, const char *prefix);
|
|
|
|
#endif // RR_STRING_UTILITY_H
|