config and string reworked, hashtable updated to use arc_errno
This commit is contained in:
parent
0bbce28469
commit
f8d987da8e
12 changed files with 1121 additions and 657 deletions
|
|
@ -10,92 +10,168 @@ extern "C" {
|
|||
/**
|
||||
* @brief substring position within a string
|
||||
*/
|
||||
typedef struct ARC_StringSubstr {
|
||||
uint64_t index;
|
||||
uint64_t length;
|
||||
} ARC_StringSubstr;
|
||||
typedef struct ARC_String {
|
||||
char *data;
|
||||
uint64_t length;
|
||||
} ARC_String;
|
||||
|
||||
/**
|
||||
* @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 creates ARC_String type
|
||||
*
|
||||
* @param string ARC_String to create
|
||||
* @param data cstring that will be stored in ARC_String
|
||||
* @param length length of ARC_String
|
||||
*/
|
||||
void ARC_String_Create(ARC_String **string, char *data, uint64_t length);
|
||||
|
||||
/**
|
||||
* @brief substring position within a string, stored as 1 byte
|
||||
* @brief destroys ARC_String type
|
||||
*
|
||||
* @param string string that will be destroyed
|
||||
*/
|
||||
void ARC_String_Destroy(ARC_String *string);
|
||||
|
||||
/**
|
||||
* @brief copy a ARC_String
|
||||
*
|
||||
* @param copy copy of oldString, will be set to NULL on error
|
||||
* @param original original string that is being copied
|
||||
*/
|
||||
typedef struct ARC_StringSubstr8_t {
|
||||
uint8_t index;
|
||||
uint8_t length;
|
||||
} ARC_StringSubstr8_t;
|
||||
void ARC_String_Copy(ARC_String **copy, ARC_String *original);
|
||||
|
||||
/**
|
||||
* @brief copy a subtring from a givin ARC_String
|
||||
*
|
||||
* @param substring new coppied substring, will be null on error
|
||||
* @param original string to copy substring from
|
||||
* @param start starting index in relation on original
|
||||
* @param length length of substring that is being created
|
||||
*/
|
||||
void ARC_String_CopySubstring(ARC_String **substring, ARC_String *original, uint64_t start, uint64_t length);
|
||||
|
||||
/**
|
||||
* @brief copy a subtring from a givin ARC_String
|
||||
*
|
||||
* @param newString string that doesn't have substring in it, will be null on error
|
||||
* @param original string to remove substring from
|
||||
* @param substring substring to remove
|
||||
*/
|
||||
void ARC_String_RemoveSubstring(ARC_String **newString, ARC_String *original, ARC_String *substring);
|
||||
|
||||
/**
|
||||
* @brief checks if two strings are the same
|
||||
*
|
||||
* @param first string to check against second
|
||||
* @param second string to check against first
|
||||
*
|
||||
* @return 1 if match, 0 if they don't match
|
||||
*/
|
||||
uint8_t ARC_String_Equals(ARC_String *first, ARC_String *second);
|
||||
|
||||
/**
|
||||
* @brief check if ARC_String and cstring match
|
||||
*
|
||||
* @param string ARC_string to check
|
||||
* @param cstring cstring to check
|
||||
* @param length length of cstring
|
||||
*/
|
||||
uint8_t ARC_String_EqualsCString(ARC_String *string, const char *cstring, uint64_t length);
|
||||
|
||||
/**
|
||||
* @brief checks if string is alphabetic
|
||||
*
|
||||
* @param val string to check
|
||||
* @param length length of string to check
|
||||
* @param string string to check
|
||||
*
|
||||
* @return 1 if alphabetic, 0 if not alphabetic
|
||||
*/
|
||||
uint8_t ARC_String_Alpha(char *val, uint64_t length);
|
||||
uint8_t ARC_String_Alpha(ARC_String *string);
|
||||
|
||||
/**
|
||||
* @brief converst substring from string to uint64_t
|
||||
*
|
||||
* @param data string to get substring from
|
||||
* @param substr substring to convert to long
|
||||
*
|
||||
*
|
||||
* @param string string to convert to long
|
||||
*
|
||||
* @return uint64_t converted number
|
||||
*/
|
||||
uint64_t ARC_String_ToUint64_t(const char *data, ARC_StringSubstr *substr);
|
||||
uint64_t ARC_String_ToUint64_t(ARC_String *string);
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @param string the string that will be searched
|
||||
* @param substr substring to find within string
|
||||
*
|
||||
* @return int ARC_ERRNO_ error code
|
||||
* @return ~(uint64_t)0 on error, anything else on success
|
||||
*/
|
||||
int32_t ARC_String_Find(char *data, char *substr, uint64_t *index);
|
||||
uint64_t ARC_String_Find(ARC_String *string, ARC_String *substring);
|
||||
|
||||
/**
|
||||
* @brief takes given cstring and gives position of first matching
|
||||
*
|
||||
* @param string the string that will be searched
|
||||
* @param cstring the cstring to find within string
|
||||
* @param length the length of cstring
|
||||
*
|
||||
* @return ~(uint64_t)0 on error, anything else on success
|
||||
*/
|
||||
uint64_t ARC_String_FindCString(ARC_String *string, const char *cstring, uint64_t length);
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @param string the string that will be searched
|
||||
* @param substr substring to find within string
|
||||
*
|
||||
* @return int ARC_ERRNO_ error code
|
||||
* @return ~(uint64_t)0 on error, anything else on success
|
||||
*/
|
||||
int32_t ARC_String_FindBack(char *data, char *substr, uint64_t *index);
|
||||
uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring);
|
||||
|
||||
/**
|
||||
* @brief strips the ends based on a given substing
|
||||
* @brief strips the ends based on a given char
|
||||
*
|
||||
* @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
|
||||
* @param original the string which whill have the matching char stripped from
|
||||
* @param stripped where to store the string which has witespace stripped
|
||||
* will be null if there is an error
|
||||
* @param charToStrip the char that will be stripped from the ends
|
||||
*/
|
||||
int32_t ARC_StringSubstr_StripEnds(char *data, char *substr, ARC_StringSubstr *subdata);
|
||||
void ARC_String_StripEnds(ARC_String *original, ARC_String **stripped, char charToStrip);
|
||||
|
||||
/**
|
||||
* @brief strips the ends based on a given substing
|
||||
* @brief strips whitespace from a ARC_String
|
||||
*
|
||||
* @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
|
||||
* @param original the string which whill have whitespace stripped from
|
||||
* @param stripped where to store the string which has witespace stripped
|
||||
* will be null if there is an error
|
||||
*/
|
||||
int32_t ARC_StringSubstr_StripWhitespaceEnds(char *data, ARC_StringSubstr *subdata);
|
||||
void ARC_String_StripWhitespace(ARC_String *original, ARC_String **stripped);
|
||||
|
||||
/**
|
||||
* @brief strips the whitespace from the ends of a string
|
||||
*
|
||||
* @param original the string which whill have the whitespace stripped from its ends
|
||||
* @param stripped where to store the string which has witespace stripped from the ends
|
||||
* will be null if there is an error
|
||||
*/
|
||||
void ARC_String_StripEndsWhitespace(ARC_String *original, ARC_String **stripped);
|
||||
|
||||
/**
|
||||
* @brief merges two strings together
|
||||
*
|
||||
* @param first first part of string to combine
|
||||
* @param second second part of string to combine
|
||||
* @param combined new ARC_String of combined strings frist + second
|
||||
*/
|
||||
void ARC_String_Merge(ARC_String *first, ARC_String *second, ARC_String **combined);
|
||||
|
||||
/**
|
||||
* @brief copy a subtring from a givin ARC_String
|
||||
*
|
||||
* @param newString new string without specified section, will be NULL on error
|
||||
* @param original string to remove section from
|
||||
* @param removeIndex starting index in relation on original of what is to be removed
|
||||
* @param removeLength length of section that is being removed
|
||||
*/
|
||||
void ARC_String_RemoveSection(ARC_String **newString, ARC_String *original, uint64_t removeIndex, uint64_t removeLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue