Base/core/exports/librr/runes.h

53 lines
2.3 KiB
C

#ifndef RR_RUNES_H
#define RR_RUNES_H
#include <librr/types.h>
/// @brief Extracts an UTF-8 rune at a given offset in a string and ADDS the length
/// of the rune to the number pointed to by 'increase'.
/// @param string The string to get the data from. For safety reasons, this should be null-terminated.
/// @param offset The offset in the string to get the data from.
/// @param increase A pointer to the number to which the length of the rune will be added.
/// @return The UTF-8 character which was extracted OR 0 is the function failed.
rune_t rr_extract_utf8(const char *string, usz_t offset, usz_t *increase);
/// @brief Checks if there is a newline delimiter at a specific offset in a string
/// and writes the offset right after it to a given pointer's destination.
/// @attention The next rune's offset will replace the previous content of the given pointer,
/// the offset will not be added to.
/// @param string The string in question
/// @param offset The offset in the string at which the test should be done.
/// @param next The pointer to the integer to which the offset will be written.
/// in contrast to the other rune functions, this does NOT add, it SETS the value
/// relative to 'offset'. This will NOT be set if no newline was found.
/// @return TRUE if there is a newline at that point and FALSE if not.
bool_t rr_check_newline(const char *string, usz_t offset, usz_t *next);
/// @brief Checks if a rune is a lowercase ASCII-rune.
/// @param rune The rune to be checked.
/// @return Whether the rune is a lowercase ASCII-rune.
bool_t rr_rune_is_lower(rune_t rune);
/// @brief Checks if a rune is an uppercase ASCII-rune.
/// @param rune The rune to be checked.
/// @return Whether the rune is an uppercase ASCII-rune.
bool_t rr_rune_is_upper(rune_t rune);
/// @brief Checks if a rune is an ASCII-letter.
/// @param rune The rune to be checked.
/// @return Whether the rune is an ASCII-letter.
bool_t rr_rune_is_letter(rune_t rune);
/// @brief Checks if a rune is a digit in ASCII.
/// @param rune The rune to be checked.
/// @return Whether the rune is a digit in ASCII.
bool_t rr_rune_is_digit(rune_t rune);
/// @brief Checks if a rune is of one of the four ASCII sign ranges.
/// @param rune The rune to be checked.
/// @return Whether the rune is of one of the four ASCII sign ranges.
bool_t rr_rune_is_ascii_special(rune_t rune);
#endif // LIBRR_RUNES_H