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

Defines the data structure for handling arrays of enums. More...

Go to the source code of this file.

Data Structures

struct  icalenumarray_element

Macros

#define icalenumarray_new(increment_size)

Functions

void icalenumarray_add (icalenumarray *array, const icalenumarray_element *elem)
 Appends an element to the array, omitting duplicates.
void icalenumarray_append (icalenumarray *array, const icalenumarray_element *elem)
 Appends an element to the array.
icalenumarray * icalenumarray_clone (icalenumarray *array)
 Clones the array and all its elements.
const icalenumarray_elementicalenumarray_element_at (icalenumarray *array, size_t position)
 Accesses an element stored in the array.
size_t icalenumarray_find (icalenumarray *array, const icalenumarray_element *needle)
 Finds an element in the array.
void icalenumarray_free (icalenumarray *array)
 Frees this array's memory and all its elements.
void icalenumarray_remove (icalenumarray *array, const icalenumarray_element *del)
 Removes all occurrences of an element.
void icalenumarray_remove_element_at (icalenumarray *array, size_t position)
 Removes the element at an array position.
size_t icalenumarray_size (const icalenumarray *array)
 Indicates the count of elements stored in the array.
void icalenumarray_sort (icalenumarray *array)
 Sorts the elements in the array in ascending order.

Detailed Description

Defines the data structure for handling arrays of enums.

Definition in file icalenumarray.h.

Macro Definition Documentation

◆ icalenumarray_new

#define icalenumarray_new ( increment_size)
Value:
icalarray_new(sizeof(icalenumarray_element), increment_size)
icalarray * icalarray_new(size_t element_size, size_t increment_size)
Definition icalarray.c:36

Creates a new icalenumarray object.

Parameters
increment_sizeHow many slots to allocate on array expansion
Returns
The new icalenumarray object
See also
icalenumarray_free()

Creates a new icalenumarray object. The parameter increment_size determines how many slots to allocate when expanding the array. If zero, then the default increment size specified when libical was built is chosen.

Error handling
If there is an error while creating the object, it returns NULL and sets icalerrno to ICAL_NEWFAILED_ERROR.
Ownership
The returned icalenumarray object is owned by the caller of the function, and needs to be released properly after it's no longer needed with icalenumarray_free().

Definition at line 56 of file icalenumarray.h.

Function Documentation

◆ icalenumarray_add()

void icalenumarray_add ( icalenumarray * array,
const icalenumarray_element * elem )

Appends an element to the array, omitting duplicates.

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

Appends element 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 93 of file icalenumarray.c.

◆ icalenumarray_append()

void icalenumarray_append ( icalenumarray * array,
const icalenumarray_element * elem )

Appends an element to the array.

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

Appends element elem to array, not checking for duplicates. Use icalenumarray_add() to only add elements 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 80 of file icalenumarray.c.

◆ icalenumarray_clone()

icalenumarray * icalenumarray_clone ( icalenumarray * 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 elements.

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

Definition at line 160 of file icalenumarray.c.

◆ icalenumarray_element_at()

const icalenumarray_element * icalenumarray_element_at ( icalenumarray * array,
size_t position )

Accesses an element stored in the array.

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

Accesses an element 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 element is owned by the icalenumarray, it must not be freed by the user.
Since
4.0

Definition at line 31 of file icalenumarray.c.

◆ icalenumarray_find()

size_t icalenumarray_find ( icalenumarray * array,
const icalenumarray_element * needle )

Finds an element in the array.

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

Looks for element needle in the array, comparing the numeric value for equality and the optional xvalue for byte-equality. The position of the first occurrence is returned if the element is found. If the element 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 61 of file icalenumarray.c.

◆ icalenumarray_free()

void icalenumarray_free ( icalenumarray * 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 137 of file icalenumarray.c.

◆ icalenumarray_remove()

void icalenumarray_remove ( icalenumarray * array,
const icalenumarray_element * del )

Removes all occurrences of an element.

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

Removes all occurrences of the element del from array.

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

Definition at line 117 of file icalenumarray.c.

◆ icalenumarray_remove_element_at()

void icalenumarray_remove_element_at ( icalenumarray * array,
size_t position )

Removes the element at an array position.

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

Removes the element at position in the array.

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

Definition at line 104 of file icalenumarray.c.

◆ icalenumarray_size()

size_t icalenumarray_size ( const icalenumarray * array)

Indicates the count of elements stored in the array.

Parameters
arrayThe array object in which the element is stored
Returns
the count of elements

Returns the count of elements stored in the array.

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

Definition at line 23 of file icalenumarray.c.

◆ icalenumarray_sort()

void icalenumarray_sort ( icalenumarray * array)

Sorts the elements in the array in ascending order.

Parameters
arrayThe array object to sort.

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

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

Definition at line 151 of file icalenumarray.c.