libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches

Dynamic array of string objects. More...

Data Fields

void(* Add )(CMUTIL_StringArray *array, CMUTIL_String *string)
 Add a string object to this array.
 
void(* AddCString )(CMUTIL_StringArray *array, const char *string)
 Add a new c-style string.
 
CMBool(* InsertAt )(CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index)
 Insert a string object to this array at the index.
 
CMBool(* InsertAtCString )(CMUTIL_StringArray *array, const char *string, uint32_t index)
 Insert a new c-style string at the given index.
 
CMUTIL_String *(* RemoveAt )(CMUTIL_StringArray *array, uint32_t index)
 Remove string element at given index, and return it.
 
CMUTIL_String *(* SetAt )(CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index)
 Set the new string object to this array at given index and old string will be returned.
 
CMUTIL_String *(* SetAtCString )(CMUTIL_StringArray *array, const char *string, uint32_t index)
 Set a new c-style string to this array at given index and old string will be returned.
 
const CMUTIL_String *(* GetAt )(const CMUTIL_StringArray *array, uint32_t index)
 Get string object at given index.
 
const char *(* GetCString )(const CMUTIL_StringArray *array, uint32_t index)
 Get c-style string at the given index.
 
size_t(* GetSize )(const CMUTIL_StringArray *array)
 Get the number of items in this array.
 
CMUTIL_Iterator *(* Iterator )(const CMUTIL_StringArray *array)
 Get the iterator of this array.
 
void(* Destroy )(CMUTIL_StringArray *array)
 Destroy this array object and it's contents.
 
void(* PrintTo )(const CMUTIL_StringArray *array, CMUTIL_String *out)
 Function pointer used to format and output the contents of a string array.
 

Detailed Description

Dynamic array of string objects.

Field Documentation

◆ Add

void(* CMUTIL_StringArray::Add) (CMUTIL_StringArray *array, CMUTIL_String *string)

Add a string object to this array.

Note that ownership of the string object will be moved to this array object. So destroying the original string will lead to undefined behavior. Destroying this array object will destroy all owned strings.

Parameters
arrayThis string array object.
stringString object to be added, ownership of the string object will be moved to this array object.

◆ AddCString

void(* CMUTIL_StringArray::AddCString) (CMUTIL_StringArray *array, const char *string)

Add a new c-style string.

This method will create a new CMUTIL_String object whose contents will be the same as the given string.

Parameters
arrayThis string array object.
stringC-style (NULL-terminated) string to be added.

◆ InsertAt

CMBool(* CMUTIL_StringArray::InsertAt) (CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index)

Insert a string object to this array at the index.

Note that ownership of the string object will be moved to this array object. So destroying the original string will lead to undefined behavior. Destroying this array object will destroy all owned strings.

Parameters
arrayThis string array object.
stringString object to be added, ownership of the string object will be moved to this array object if CMTrue returned.
indexThe index where the new string will be inserted.
Returns
CMTrue if insertion performed successfully. CMFalse if failed, the ownership of string did not move.

◆ InsertAtCString

CMBool(* CMUTIL_StringArray::InsertAtCString) (CMUTIL_StringArray *array, const char *string, uint32_t index)

Insert a new c-style string at the given index.

This method will create a new CMUTIL_String object whose contents will be the same as given string.

Parameters
arrayThis string array object.
stringC-style (NULL-terminated) string to be added.
indexThe index where the new string will be inserted.
Returns
CMTrue if insertion performed successfully. CMFalse if failed.

◆ RemoveAt

CMUTIL_String *(* CMUTIL_StringArray::RemoveAt) (CMUTIL_StringArray *array, uint32_t index)

Remove string element at given index, and return it.

Note, this method will transfer ownership of the result string to the caller. The caller must receive the return value and destroy it after use.

Parameters
arrayThis string array object.
indexThe index where the string wanted to remove.
Returns
String object which removed from this array, ownership of the string will be transferred to caller. NULL if the index is out of bound.

◆ SetAt

CMUTIL_String *(* CMUTIL_StringArray::SetAt) (CMUTIL_StringArray *array, CMUTIL_String *string, uint32_t index)

Set the new string object to this array at given index and old string will be returned.

Note that ownership of the string object will be moved to this array object. So destroying the original string will lead to undefined behavior. Destroying this array object will destroy all owned strings. And this method will transfer ownership of the result string to the caller. The caller must receive the return value and destroy it after use.

Parameters
arrayThis string array object.
stringString object to be added, ownership of the string object will be moved to this array object if CMTrue returned.
indexThe index where the string wanted to remove.
Returns
String object which removed from this array, ownership of the string will be transferred to caller. NULL if the index is out of bound.

◆ SetAtCString

CMUTIL_String *(* CMUTIL_StringArray::SetAtCString) (CMUTIL_StringArray *array, const char *string, uint32_t index)

Set a new c-style string to this array at given index and old string will be returned.

Note this method will transfer ownership of the result string to the caller. The caller must receive the return value and destroy it after use.

Parameters
arrayThis string array object.
stringC-style (NULL-terminated) string to be added.
indexThe index where the string wanted to remove.
Returns
String object which removed from this array, ownership of the string will be transferred to caller. NULL if the index is out of bound.

◆ GetAt

const CMUTIL_String *(* CMUTIL_StringArray::GetAt) (const CMUTIL_StringArray *array, uint32_t index)

Get string object at given index.

Note, this method does not transfer ownership of the result string to the caller. The caller must not destroy the result object.

Parameters
arrayThis string array object.
indexThe index where the string wanted to get.
Returns
Result string object. NULL if the index is out of bound.

◆ GetCString

const char *(* CMUTIL_StringArray::GetCString) (const CMUTIL_StringArray *array, uint32_t index)

Get c-style string at the given index.

Parameters
arrayThis string array object.
indexThe index where the string wanted to get.
Returns
Result c-style string object. NULL if the index is out of bound.

◆ GetSize

size_t(* CMUTIL_StringArray::GetSize) (const CMUTIL_StringArray *array)

Get the number of items in this array.

Parameters
arrayThis string array object.
Returns
The size of this array.

◆ Iterator

CMUTIL_Iterator *(* CMUTIL_StringArray::Iterator) (const CMUTIL_StringArray *array)

Get the iterator of this array.

Parameters
arrayThis string object.
Returns
Iterator object of this array must be destroyed after use.

◆ Destroy

void(* CMUTIL_StringArray::Destroy) (CMUTIL_StringArray *array)

Destroy this array object and it's contents.

Parameters
arrayThis string object.

◆ PrintTo

void(* CMUTIL_StringArray::PrintTo) (const CMUTIL_StringArray *array, CMUTIL_String *out)

Function pointer used to format and output the contents of a string array.

This function pointer allows the user to specify a custom implementation for processing a string array and formatting its contents into a string output.

Parameters
arrayPointer to the CMUTIL_StringArray object that contains the input strings.
outPointer to the CMUTIL_String object where the formatted output will be stored.

The documentation for this struct was generated from the following file: