Archeus 0.0.0
A C library and game engine that focuses on documentation
Loading...
Searching...
No Matches
string.h File Reference
#include <stdint.h>
#include "bool.h"

Go to the source code of this file.

Data Structures

struct  ARC_String
 substring position within a string More...
 

Typedefs

typedef struct ARC_String ARC_String
 substring position within a string
 

Functions

void ARC_String_Create (ARC_String **string, char *data, uint64_t length)
 creates ARC_String type
 
void ARC_String_CreateWithStrlen (ARC_String **string, char *data)
 creates ARC_String type with strinlen
 
void ARC_String_CreateEmpty (ARC_String **string, uint64_t length)
 creates an empty ARC_String type, useful if you want to add to the string over time without having to keep adding to the size
 
void ARC_String_Destroy (ARC_String *string)
 destroys ARC_String type
 
void ARC_String_Copy (ARC_String **copy, ARC_String *original)
 copy a ARC_String
 
void ARC_String_CopySubstring (ARC_String **substring, ARC_String *original, uint64_t start, uint64_t length)
 copy a subtring from a givin ARC_String
 
void ARC_String_ReplaceWithSubstring (ARC_String **string, uint64_t start, uint64_t length)
 replaces a string with a section of itself
 
void ARC_String_RemoveSubstring (ARC_String **newString, ARC_String *original, ARC_String *substring)
 copy a subtring from a givin ARC_String
 
void ARC_String_Append (ARC_String **string, ARC_String *append)
 appends to an ARC_String with an ARC_String
 
void ARC_String_AppendCString (ARC_String **string, const char *cstring, uint64_t length)
 appends to an ARC_String with an ARC_String
 
void ARC_String_AppendCStringWithStrlen (ARC_String **string, const char *cstring)
 appends to an ARC_String with an ARC_String
 
ARC_Bool ARC_String_Equals (ARC_String *first, ARC_String *second)
 checks if two strings are the same
 
ARC_Bool ARC_String_EqualsCString (ARC_String *string, const char *cstring, uint64_t length)
 check if ARC_String and cstring match
 
ARC_Bool ARC_String_EqualsCStringWithStrlen (ARC_String *string, const char *cstring)
 check if ARC_String and cstring match
 
ARC_Bool ARC_String_SubstringEquals (ARC_String *first, uint64_t offset, ARC_String *second)
 check if substring of first equals second string
 
ARC_Bool ARC_String_SubstringEqualsCString (ARC_String *string, uint64_t offset, const char *cstring, uint64_t length)
 check if ARC_String and cstring match
 
ARC_Bool ARC_String_IsAlpha (ARC_String *string)
 checks if string is alphabetic
 
ARC_Bool ARC_String_IsNumeric (ARC_String *string)
 checks if string is made out of only numbers
 
uint64_t ARC_String_ToUint64_t (ARC_String *string)
 converst substring from string to uint64_t
 
int64_t ARC_String_ToInt64_t (ARC_String *string)
 converst substring from string to int64_t
 
double ARC_String_ToDouble (ARC_String *string)
 converst substring from string to double
 
uint64_t ARC_String_Find (ARC_String *string, ARC_String *substring)
 takes a given string, and assigns index and length for position of first matching substring
 
uint64_t ARC_String_FindCString (ARC_String *string, const char *cstring, uint64_t length)
 takes given cstring and gives position of first matching
 
uint64_t ARC_String_FindCStringWithStrlen (ARC_String *string, const char *cstring)
 takes given cstring and gives position of first matching
 
uint64_t ARC_String_FindBack (ARC_String *string, ARC_String *substring)
 takes a given string, and assigns index and length for position of last matching substring
 
uint64_t ARC_String_FindBackCString (ARC_String *string, const char *cstring, uint64_t length)
 takes a given cstring and give position of last matching
 
uint64_t ARC_String_FindBackCStringWithStrlen (ARC_String *string, const char *cstring)
 takes a given cstring and give position of last matching
 
void ARC_String_StripEnds (ARC_String **stripped, ARC_String *original, char charToStrip)
 strips the ends based on a given char
 
void ARC_String_StripWhitespace (ARC_String **stripped, ARC_String *original)
 strips whitespace from a ARC_String
 
void ARC_String_StripEndsWhitespace (ARC_String **stripped, ARC_String *original)
 strips the whitespace from the ends of a string
 
void ARC_String_Merge (ARC_String **combined, ARC_String *first, ARC_String *second)
 merges two strings together
 
void ARC_String_RemoveSection (ARC_String **newString, ARC_String *original, uint64_t removeIndex, uint64_t removeLength)
 copy a subtring from a givin ARC_String
 
void ARC_String_ReplaceMatching (ARC_String **string, ARC_String *pattern, ARC_String *replacement)
 replaces characters in string matching the given pattern
 
void ARC_String_CopyReplaceMatching (ARC_String **newString, ARC_String *original, ARC_String *pattern, ARC_String *replacement)
 replaces characters in a copy of a string matching the given pattern
 
void ARC_String_ReplaceMatchingCString (ARC_String **string, char *patternCString, uint64_t patternLength, char *replacementCString, uint64_t replacementLength)
 replaces characters in string matching the given pattern
 
void ARC_String_ReplaceMatchingCStringWithStrlen (ARC_String **string, char *patternCString, char *replacement)
 replaces characters in string matching the given pattern
 

Typedef Documentation

◆ ARC_String

typedef struct ARC_String ARC_String

substring position within a string

Function Documentation

◆ ARC_String_Append()

void ARC_String_Append ( ARC_String ** string,
ARC_String * append )

appends to an ARC_String with an ARC_String

Note
this uses ARC_String_AppendCString, so debug logs will be thrown in that function not this one
Parameters
stringthe string to add to, will not change on error
appendthe string that will be added to the back of string

◆ ARC_String_AppendCString()

void ARC_String_AppendCString ( ARC_String ** string,
const char * cstring,
uint64_t length )

appends to an ARC_String with an ARC_String

Parameters
stringthe string to add to, will not change on error
cstringthe cstring that will be added to the back of string
lengththe length of the cstring that is being added

◆ ARC_String_AppendCStringWithStrlen()

void ARC_String_AppendCStringWithStrlen ( ARC_String ** string,
const char * cstring )

appends to an ARC_String with an ARC_String

Note
this uses ARC_String_AppendCString, so debug logs will be thrown in that function not this one
Parameters
stringthe string to add to, will not change on error
cstringthe cstring that will be added to the back of string

◆ ARC_String_Copy()

void ARC_String_Copy ( ARC_String ** copy,
ARC_String * original )

copy a ARC_String

Parameters
copycopy of oldString, will be set to NULL on error
originaloriginal string that is being copied

◆ ARC_String_CopyReplaceMatching()

void ARC_String_CopyReplaceMatching ( ARC_String ** newString,
ARC_String * original,
ARC_String * pattern,
ARC_String * replacement )

replaces characters in a copy of a string matching the given pattern

Note
original will not be modified
newString will need to be destroyed if it is not set to NULL
Parameters
newStringan empty string that this function will fill with a copy with replacements, will be set to NULL and arc_errno set on fail
originalthe original string that will be copied
patternthe pattern to replace in the string on match
replacementthe string that will replace the matched pattern

◆ ARC_String_CopySubstring()

void ARC_String_CopySubstring ( ARC_String ** substring,
ARC_String * original,
uint64_t start,
uint64_t length )

copy a subtring from a givin ARC_String

Parameters
substringnew coppied substring, will be null on error
originalstring to copy substring from
startstarting index in relation on original
lengthlength of substring that is being created

◆ ARC_String_Create()

void ARC_String_Create ( ARC_String ** string,
char * data,
uint64_t length )

creates ARC_String type

Parameters
stringARC_String to create
datacstring that will be stored in ARC_String
lengthlength of ARC_String

◆ ARC_String_CreateEmpty()

void ARC_String_CreateEmpty ( ARC_String ** string,
uint64_t length )

creates an empty ARC_String type, useful if you want to add to the string over time without having to keep adding to the size

Parameters
stringARC_String to create
lengthlength of ARC_String

◆ ARC_String_CreateWithStrlen()

void ARC_String_CreateWithStrlen ( ARC_String ** string,
char * data )

creates ARC_String type with strinlen

Parameters
stringARC_String to create
datacstring that will be stored in ARC_String

◆ ARC_String_Destroy()

void ARC_String_Destroy ( ARC_String * string)

destroys ARC_String type

Parameters
stringstring that will be destroyed

◆ ARC_String_Equals()

ARC_Bool ARC_String_Equals ( ARC_String * first,
ARC_String * second )

checks if two strings are the same

Parameters
firststring to check against second
secondstring to check against first
Returns
ARC_True if match, ARC_False if they don't match

◆ ARC_String_EqualsCString()

ARC_Bool ARC_String_EqualsCString ( ARC_String * string,
const char * cstring,
uint64_t length )

check if ARC_String and cstring match

Parameters
stringARC_string to check
cstringcstring to check
lengthlength of cstring
Returns
ARC_True if match, ARC_False if they don't match

◆ ARC_String_EqualsCStringWithStrlen()

ARC_Bool ARC_String_EqualsCStringWithStrlen ( ARC_String * string,
const char * cstring )

check if ARC_String and cstring match

Note
will use strlen to get the length of the cstring
Parameters
stringARC_string to check
cstringcstring to check
Returns
ARC_True if match, ARC_False if they don't match

◆ ARC_String_Find()

uint64_t ARC_String_Find ( ARC_String * string,
ARC_String * substring )

takes a given string, and assigns index and length for position of first matching substring

Parameters
stringthe string that will be searched
substrsubstring to find within string
Returns
~(uint64_t)0 on error, anything else on success

◆ ARC_String_FindBack()

uint64_t ARC_String_FindBack ( ARC_String * string,
ARC_String * substring )

takes a given string, and assigns index and length for position of last matching substring

Parameters
stringthe string that will be searched
substrsubstring to find within string
Returns
~(uint64_t)0 on error, anything else on success

◆ ARC_String_FindBackCString()

uint64_t ARC_String_FindBackCString ( ARC_String * string,
const char * cstring,
uint64_t length )

takes a given cstring and give position of last matching

Parameters
stringthe string that will be searched
cstringthe cstring to find within string
lengththe length of cstring
Returns
~(uint64_t)0 on error, anything else on success

◆ ARC_String_FindBackCStringWithStrlen()

uint64_t ARC_String_FindBackCStringWithStrlen ( ARC_String * string,
const char * cstring )

takes a given cstring and give position of last matching

Note
will use strlen to get the length of the cstring
Parameters
stringthe string that will be searched
cstringthe cstring to find within string
Returns
~(uint64_t)0 on error, anything else on success

◆ ARC_String_FindCString()

uint64_t ARC_String_FindCString ( ARC_String * string,
const char * cstring,
uint64_t length )

takes given cstring and gives position of first matching

Parameters
stringthe string that will be searched
cstringthe cstring to find within string
lengththe length of cstring
Returns
~(uint64_t)0 on error, anything else on success

◆ ARC_String_FindCStringWithStrlen()

uint64_t ARC_String_FindCStringWithStrlen ( ARC_String * string,
const char * cstring )

takes given cstring and gives position of first matching

Note
will use strlen to get the length of the cstring
Parameters
stringthe string that will be searched
cstringthe cstring to find within string
Returns
~(uint64_t)0 on error, anything else on success

◆ ARC_String_IsAlpha()

ARC_Bool ARC_String_IsAlpha ( ARC_String * string)

checks if string is alphabetic

Parameters
stringstring to check
Returns
ARC_True if alphabetic, ARC_False if not alphabetic

◆ ARC_String_IsNumeric()

ARC_Bool ARC_String_IsNumeric ( ARC_String * string)

checks if string is made out of only numbers

Parameters
stringstring to check
Returns
ARC_True if it is numeric, ARC_False if it is not numeric

◆ ARC_String_Merge()

void ARC_String_Merge ( ARC_String ** combined,
ARC_String * first,
ARC_String * second )

merges two strings together

Parameters
combinednew ARC_String of combined strings frist + second
firstfirst part of string to combine
secondsecond part of string to combine

◆ ARC_String_RemoveSection()

void ARC_String_RemoveSection ( ARC_String ** newString,
ARC_String * original,
uint64_t removeIndex,
uint64_t removeLength )

copy a subtring from a givin ARC_String

Parameters
newStringnew string without specified section, will be NULL on error
originalstring to remove section from
removeIndexstarting index in relation on original of what is to be removed
removeLengthlength of section that is being removed

◆ ARC_String_RemoveSubstring()

void ARC_String_RemoveSubstring ( ARC_String ** newString,
ARC_String * original,
ARC_String * substring )

copy a subtring from a givin ARC_String

Parameters
newStringstring that doesn't have substring in it, will be null on error
originalstring to remove substring from
substringsubstring to remove

◆ ARC_String_ReplaceMatching()

void ARC_String_ReplaceMatching ( ARC_String ** string,
ARC_String * pattern,
ARC_String * replacement )

replaces characters in string matching the given pattern

Note
this uses ARC_String_CopyReplaceMatching, so debug logs will be thrown in that function not this one
Parameters
stringthe string that will be modified, will discard changes and set arc_errno on fail
patternthe pattern to replace in the string on match
replacementthe string that will replace the matched pattern

◆ ARC_String_ReplaceMatchingCString()

void ARC_String_ReplaceMatchingCString ( ARC_String ** string,
char * patternCString,
uint64_t patternLength,
char * replacementCString,
uint64_t replacementLength )

replaces characters in string matching the given pattern

Parameters
stringthe string that will be modified, will discard changes and set arc_errno on fail
patternCStringthe cstring pattern to replace in the string on match
patternLengththe lenght of the cstring pattern
replacementCstringthe cstring that will replace the matched pattern
replacementLengththe length of the cstring replacement

◆ ARC_String_ReplaceMatchingCStringWithStrlen()

void ARC_String_ReplaceMatchingCStringWithStrlen ( ARC_String ** string,
char * patternCString,
char * replacement )

replaces characters in string matching the given pattern

Note
this uses ARC_String_ReplaceMatchingCString, so debug logs will be thrown in that function not this one
Parameters
stringthe string that will be modified, will discard changes and set arc_errno on fail
patternCStringthe cstring pattern to replace in the string on match
replacementCstringthe cstring that will replace the matched pattern

◆ ARC_String_ReplaceWithSubstring()

void ARC_String_ReplaceWithSubstring ( ARC_String ** string,
uint64_t start,
uint64_t length )

replaces a string with a section of itself

Note
this uses ARC_String_CopySubstring so errors logs will be thrown in that function not this one
Parameters
stringthe string to replace, will not change on error
startthe starting index of the substring
lengththe length of the substring

◆ ARC_String_StripEnds()

void ARC_String_StripEnds ( ARC_String ** stripped,
ARC_String * original,
char charToStrip )

strips the ends based on a given char

Parameters
strippedwhere to store the string which has witespace stripped will be null if there is an error
originalthe string which whill have the matching char stripped from
charToStripthe char that will be stripped from the ends

◆ ARC_String_StripEndsWhitespace()

void ARC_String_StripEndsWhitespace ( ARC_String ** stripped,
ARC_String * original )

strips the whitespace from the ends of a string

Parameters
strippedwhere to store the string which has witespace stripped from the ends will be null if there is an error
originalthe string which whill have the whitespace stripped from its ends

◆ ARC_String_StripWhitespace()

void ARC_String_StripWhitespace ( ARC_String ** stripped,
ARC_String * original )

strips whitespace from a ARC_String

Parameters
strippedwhere to store the string which has witespace stripped will be null if there is an error
originalthe string which whill have whitespace stripped from

◆ ARC_String_SubstringEquals()

ARC_Bool ARC_String_SubstringEquals ( ARC_String * first,
uint64_t offset,
ARC_String * second )

check if substring of first equals second string

Parameters
firststring to check against second
offsetpostion based on first to start comparing against second
secondstring to check against first
Returns
ARC_True if match, ARC_False if they don't match

◆ ARC_String_SubstringEqualsCString()

ARC_Bool ARC_String_SubstringEqualsCString ( ARC_String * string,
uint64_t offset,
const char * cstring,
uint64_t length )

check if ARC_String and cstring match

Parameters
stringARC_string to check
offsetpostion based on string to start comparing against cstring
cstringcstring to check
lengthlength of cstring
Returns
ARC_True if match, ARC_False if they don't match

◆ ARC_String_ToDouble()

double ARC_String_ToDouble ( ARC_String * string)

converst substring from string to double

Parameters
stringstring to convert to double
Returns
double converted number

◆ ARC_String_ToInt64_t()

int64_t ARC_String_ToInt64_t ( ARC_String * string)

converst substring from string to int64_t

Parameters
stringstring to convert to int64_t
Returns
int64_t converted number

◆ ARC_String_ToUint64_t()

uint64_t ARC_String_ToUint64_t ( ARC_String * string)

converst substring from string to uint64_t

Parameters
stringstring to convert to uint64_t
Returns
uint64_t converted number