Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
icalstrarray.c File Reference

Implements the data structure for handling string arrays. More...

Go to the source code of this file.

Functions

void icalstrarray_add (icalstrarray *array, const char *elem)
 Appends a string to the array, omitting duplicates.
void icalstrarray_append (icalstrarray *array, const char *elem)
 Appends a string to the array.
icalstrarray * icalstrarray_clone (icalstrarray *array)
 Clones the array and all its elements.
const char * icalstrarray_element_at (icalstrarray *array, size_t position)
 Accesses a string stored in the array.
size_t icalstrarray_find (icalstrarray *array, const char *needle)
 Finds a string in the array.
void icalstrarray_free (icalstrarray *array)
 Frees this array's memory and all its elements.
void icalstrarray_remove (icalstrarray *array, const char *del)
 Removes all occurrences of a string.
void icalstrarray_remove_element_at (icalstrarray *array, size_t position)
 Removes the string at an array position.
size_t icalstrarray_size (const icalstrarray *array)
 Indicates the count of strings stored in the array.
void icalstrarray_sort (icalstrarray *array)
 Sorts the strings in the array in ascending order.

Detailed Description

Implements the data structure for handling string arrays.

Definition in file icalstrarray.c.

Function Documentation

◆ icalstrarray_add()

void icalstrarray_add ( icalstrarray * array,
const char * elem )

Appends a string to the array, omitting duplicates.

Parameters
arrayThe array object to which the string append to
elemThe string to append

Appends string elem to array unless a byte-equal string already is present in the array.

Error handling
If array or elem is NULL then this function is a noop.
Since
4.0

Definition at line 71 of file icalstrarray.c.

◆ icalstrarray_append()

void icalstrarray_append ( icalstrarray * array,
const char * elem )

Appends a string to the array.

Parameters
arrayThe array object to which the string append to
elemThe string to append

Appends string elem to array, not checking for duplicates. Use icalstrarray_add() to only add strings that are not present already in the array.

Error handling
If array or elem is NULL then this function is a noop.
Since
4.0

Definition at line 59 of file icalstrarray.c.

◆ icalstrarray_clone()

icalstrarray * icalstrarray_clone ( icalstrarray * array)

Clones the array and all its elements.

Parameters
arrayThe array object to clone.
Returns
the cloned array

Creates an independent copy of the array and all its string elements.

Error handling
If array is NULL then the return value is NULL.
Since
4.0

Definition at line 145 of file icalstrarray.c.

◆ icalstrarray_element_at()

const char * icalstrarray_element_at ( icalstrarray * array,
size_t position )

Accesses a string stored in the array.

Parameters
arrayThe array object in which the string is stored
positionThe slot position of the string in the array
Returns
A pointer to the string

Accesses a string by returning a pointer to it, given an array and a valid slot position.

Error handling
If array is NULL or position is not set in the array, then the return value is NULL.
Ownership
The string is owned by the icalstrarray, it must not be freed by the user.
Since
4.0

Definition at line 32 of file icalstrarray.c.

◆ icalstrarray_find()

size_t icalstrarray_find ( icalstrarray * array,
const char * needle )

Finds a string in the array.

Parameters
arrayThe array object in which to search for the string
needleThe string to search for
Returns
the slot position of the string in the array, or icalstrarray_size()

Looks for string needle in the array, comparing strings for byte-equality. The position of the first occurrence is returned if the string is found. If the string is not found, then the count of elements in the array is returned.

Error handling
If array or needle is NULL, then the return value is the same as if the value is not found.
Since
4.0

Definition at line 40 of file icalstrarray.c.

◆ icalstrarray_free()

void icalstrarray_free ( icalstrarray * array)

Frees this array's memory and all its elements.

Parameters
arrayThe array object to free

Frees the array.

Error handling
If array is NULL, this is a noop.
Since
4.0

Definition at line 116 of file icalstrarray.c.

◆ icalstrarray_remove()

void icalstrarray_remove ( icalstrarray * array,
const char * del )

Removes all occurrences of a string.

Parameters
arrayThe array object from which to remove the string
delThe string to remove from the array

Removes all occurrences of the string del from array.

Error handling
If array or del is NULL, then this function is a noop.
Since
4.0

Definition at line 96 of file icalstrarray.c.

◆ icalstrarray_remove_element_at()

void icalstrarray_remove_element_at ( icalstrarray * array,
size_t position )

Removes the string at an array position.

Parameters
arrayThe array object from which to remove the string
positionThe array position of the string to remove

Removes the string at position in the array.

Error handling
If array is NULL or position is higher or equal to the count of strings, this function is a noop.
Since
4.0

Definition at line 82 of file icalstrarray.c.

◆ icalstrarray_size()

size_t icalstrarray_size ( const icalstrarray * array)

Indicates the count of strings stored in the array.

Parameters
arrayThe array object in which the string is stored
Returns
the count of strings

Returns the count of strings stored in the array.

Error handling
If array is NULL then the return value is zero.
Since
4.0

Definition at line 24 of file icalstrarray.c.

◆ icalstrarray_sort()

void icalstrarray_sort ( icalstrarray * array)

Sorts the strings in the array in ascending order.

Parameters
arrayThe array object to sort.

Sorts the array such that all string elements occur in ascending order, comparing the strings as bytes.

Error handling
If array is NULL, this is a noop.
Since
4.0

Definition at line 137 of file icalstrarray.c.