104 lines
No EOL
2.8 KiB
C
104 lines
No EOL
2.8 KiB
C
#ifndef ARC_STD_STRING_H_
|
|
#define ARC_STD_STRING_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief substring position within a string
|
|
*/
|
|
typedef struct ARC_StringSubstr {
|
|
uint64_t index;
|
|
uint64_t length;
|
|
} ARC_StringSubstr;
|
|
|
|
/**
|
|
* @brief substring position within a string, stored as 4 bytes
|
|
*/
|
|
typedef struct ARC_StringSubstr32_t {
|
|
uint32_t index;
|
|
uint32_t length;
|
|
} ARC_StringSubstr32_t;
|
|
|
|
/**
|
|
* @brief substring position within a string, stored as 1 byte
|
|
*/
|
|
typedef struct ARC_StringSubstr8_t {
|
|
uint8_t index;
|
|
uint8_t length;
|
|
} ARC_StringSubstr8_t;
|
|
|
|
/**
|
|
* @brief checks if string is alphabetic
|
|
*
|
|
* @param val string to check
|
|
* @param length length of string to check
|
|
*
|
|
* @return 1 if alphabetic, 0 if not alphabetic
|
|
*/
|
|
uint8_t ARC_String_Alpha(char *val, uint64_t length);
|
|
|
|
/**
|
|
* @brief converst substring from string to uint64_t
|
|
*
|
|
* @param data string to get substring from
|
|
* @param substr substring to convert to long
|
|
*
|
|
* @return uint64_t converted number
|
|
*/
|
|
uint64_t ARC_String_ToUint64_t(const char *data, ARC_StringSubstr *substr);
|
|
|
|
/**
|
|
* @brief takes a given string, and assigns index and length for position of first matching substring
|
|
*
|
|
* @param data the string to find substring in
|
|
* @param substr the string to find
|
|
* @param index the index of substring within the string will be ~uint64_t if not found
|
|
*
|
|
* @return int ARC_ERRNO_ error code
|
|
*/
|
|
int32_t ARC_String_Find(char *data, char *substr, uint64_t *index);
|
|
|
|
/**
|
|
* @brief takes a given string, and assigns index and length for position of last matching substring
|
|
*
|
|
* @param data the string to find substring in
|
|
* @param substr the string to find
|
|
* @param index the index of substring within the string will be ~uint64_t if not found
|
|
*
|
|
* @return int ARC_ERRNO_ error code
|
|
*/
|
|
int32_t ARC_String_FindBack(char *data, char *substr, uint64_t *index);
|
|
|
|
/**
|
|
* @brief strips the ends based on a given substing
|
|
*
|
|
* @param data the string to find the substring in
|
|
* @param substr the substring to strip ends by, defaults to " " if NULL
|
|
* @param subdata the substring of data, will use given substring data, or strlen if length == 0
|
|
* also will hold the return values
|
|
*
|
|
* @return int ARC_ERRNO_ error code
|
|
*/
|
|
int32_t ARC_StringSubstr_StripEnds(char *data, char *substr, ARC_StringSubstr *subdata);
|
|
|
|
/**
|
|
* @brief strips the ends based on a given substing
|
|
*
|
|
* @param data the string to find the substring in
|
|
* @param substr the substring to strip ends by, defaults to " " if NULL
|
|
* @param subdata the substring of data, will use given substring data, or strlen if length == 0
|
|
* also will hold the return values
|
|
*
|
|
* @return int ARC_ERRNO_ error code
|
|
*/
|
|
int32_t ARC_StringSubstr_StripWhitespaceEnds(char *data, ARC_StringSubstr *subdata);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif //ARC_STD_STRING_H_
|