Base/core/exports/librr/runes.h

94 lines
3.3 KiB
C

#ifndef RR_RUNES_H
#define RR_RUNES_H
#include <librr/types.h>
typedef enum
{
RR_ASCII_EXCLAMATION_MARK,
RR_ASCII_DOUBLE_QUOTATION_MARK,
RR_ASCII_HASH_SIGN,
RR_ASCII_DOLLAR_SIGN,
RR_ASCII_PERCENT_SIGN,
RR_ASCII_AMPERSAND,
RR_ASCII_SINGLE_QUOTATION_MARK,
RR_ASCII_OPENING_PARENTHESIS,
RR_ASCII_CLOSING_PARENTHESIS,
RR_ASCII_ASTERISK,
RR_ASCII_PLUS,
RR_ASCII_COMMA,
RR_ASCII_MINUS,
RR_ASCII_POINT,
RR_ASCII_SLASH,
RR_ASCII_COLON,
RR_ASCII_SEMICOLON,
RR_ASCII_SMALLER_THAN,
RR_ASCII_EQUALS_SIGN,
RR_ASCII_BIGGER_THAN,
RR_ASCII_QUESTION_MARK,
RR_ASCII_AT_SIGN,
RR_ASCII_OPENING_SQUARE_BRACKET,
RR_ASCII_BACKSLASH,
RR_ASCII_CLOSING_SQUARE_BRACKET,
RR_ASCII_CIRCUMFLEX,
RR_ASCII_UNDERSCORE,
RR_ASCII_TICK,
RR_ASCII_OPENING_CURLY_BRACE,
RR_ASCII_VERTICAL_BAR,
RR_ASCII_CLOSING_CURLY_BRACE,
RR_ASCII_TILDE,
RR_ASCII_NOT_A_SIGN
} rr_ascii_sign_e;
/// @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);
rr_ascii_sign_e rr_rune_to_ascii_sign(rune_t rune);
#endif // LIBRR_RUNES_H