added more cstring find and equals functions
This commit is contained in:
parent
d173f943ee
commit
4d7ba1cf4e
2 changed files with 53 additions and 3 deletions
|
|
@ -87,6 +87,18 @@ uint8_t ARC_String_Equals(ARC_String *first, ARC_String *second);
|
||||||
*/
|
*/
|
||||||
uint8_t ARC_String_EqualsCString(ARC_String *string, const char *cstring, uint64_t length);
|
uint8_t ARC_String_EqualsCString(ARC_String *string, const char *cstring, uint64_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief check if ARC_String and cstring match
|
||||||
|
*
|
||||||
|
* @note will use strlen to get the length of the cstring
|
||||||
|
*
|
||||||
|
* @param string ARC_string to check
|
||||||
|
* @param cstring cstring to check
|
||||||
|
*
|
||||||
|
* @return 1 if match, 0 if they don't match
|
||||||
|
*/
|
||||||
|
uint8_t ARC_String_EqualsCStringWithStrlen(ARC_String *string, const char *cstring);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief check if ARC_String and cstring match
|
* @brief check if ARC_String and cstring match
|
||||||
*
|
*
|
||||||
|
|
@ -156,6 +168,18 @@ uint64_t ARC_String_Find(ARC_String *string, ARC_String *substring);
|
||||||
*/
|
*/
|
||||||
uint64_t ARC_String_FindCString(ARC_String *string, const char *cstring, uint64_t length);
|
uint64_t ARC_String_FindCString(ARC_String *string, const char *cstring, uint64_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief takes given cstring and gives position of first matching
|
||||||
|
*
|
||||||
|
* @note will use strlen to get the length of the cstring
|
||||||
|
*
|
||||||
|
* @param string the string that will be searched
|
||||||
|
* @param cstring the cstring to find within string
|
||||||
|
*
|
||||||
|
* @return ~(uint64_t)0 on error, anything else on success
|
||||||
|
*/
|
||||||
|
uint64_t ARC_String_FindCStringWithStrlen(ARC_String *string, const char *cstring);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief takes a given string, and assigns index and length for position of last matching substring
|
* @brief takes a given string, and assigns index and length for position of last matching substring
|
||||||
*
|
*
|
||||||
|
|
@ -167,7 +191,7 @@ uint64_t ARC_String_FindCString(ARC_String *string, const char *cstring, uint64_
|
||||||
uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring);
|
uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief takes a given string, and assigns index and length for position of last matching substring
|
* @brief takes a given cstring and give position of last matching
|
||||||
*
|
*
|
||||||
* @param string the string that will be searched
|
* @param string the string that will be searched
|
||||||
* @param cstring the cstring to find within string
|
* @param cstring the cstring to find within string
|
||||||
|
|
@ -177,6 +201,18 @@ uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring);
|
||||||
*/
|
*/
|
||||||
uint64_t ARC_String_FindBackCString(ARC_String *string, const char *cstring, uint64_t length);
|
uint64_t ARC_String_FindBackCString(ARC_String *string, const char *cstring, uint64_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief takes a given cstring and give position of last matching
|
||||||
|
*
|
||||||
|
* @note will use strlen to get the length of the cstring
|
||||||
|
*
|
||||||
|
* @param string the string that will be searched
|
||||||
|
* @param cstring the cstring to find within string
|
||||||
|
*
|
||||||
|
* @return ~(uint64_t)0 on error, anything else on success
|
||||||
|
*/
|
||||||
|
uint64_t ARC_String_FindBackCStringWithStrlen(ARC_String *string, const char *cstring);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief strips the ends based on a given char
|
* @brief strips the ends based on a given char
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ void ARC_String_CreateWithStrlen(ARC_String **string, char *data){
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARC_String_Destroy(ARC_String *string){
|
void ARC_String_Destroy(ARC_String *string){
|
||||||
|
if(string->data){
|
||||||
free(string->data);
|
free(string->data);
|
||||||
|
}
|
||||||
free(string);
|
free(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,6 +102,10 @@ uint8_t ARC_String_EqualsCString(ARC_String *string, const char *cstring, uint64
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t ARC_String_EqualsCStringWithStrlen(ARC_String *string, const char *cstring){
|
||||||
|
return ARC_String_EqualsCString(string, cstring, strlen(cstring));
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t ARC_String_SubstringEqualsCString(ARC_String *string, uint64_t offset, const char *cstring, uint64_t length){
|
uint8_t ARC_String_SubstringEqualsCString(ARC_String *string, uint64_t offset, const char *cstring, uint64_t length){
|
||||||
if(string->length - offset < length){
|
if(string->length - offset < length){
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -183,6 +189,10 @@ uint64_t ARC_String_FindCString(ARC_String *string, const char *cstring, uint64_
|
||||||
return ~(uint64_t)0;
|
return ~(uint64_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t ARC_String_FindCStringWithStrlen(ARC_String *string, const char *cstring){
|
||||||
|
return ARC_String_FindCString(string, cstring, strlen(cstring));
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring){
|
uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring){
|
||||||
if(!string || !substring){
|
if(!string || !substring){
|
||||||
arc_errno = ARC_ERRNO_NULL;
|
arc_errno = ARC_ERRNO_NULL;
|
||||||
|
|
@ -225,6 +235,10 @@ uint64_t ARC_String_FindBackCString(ARC_String *string, const char *cstring, uin
|
||||||
return ~(uint64_t)0;
|
return ~(uint64_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t ARC_String_FindBackCStringWithStrlen(ARC_String *string, const char *cstring){
|
||||||
|
return ARC_String_FindBackCString(string, cstring, strlen(cstring));
|
||||||
|
}
|
||||||
|
|
||||||
void ARC_String_StripEnds(ARC_String **stripped, ARC_String *original, char charToStrip){
|
void ARC_String_StripEnds(ARC_String **stripped, ARC_String *original, char charToStrip){
|
||||||
if(!original){
|
if(!original){
|
||||||
arc_errno = ARC_ERRNO_NULL;
|
arc_errno = ARC_ERRNO_NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue