GATE
enumerators.h File Reference

Enumerator objects allow to walk through a set of elements. More...

#include "gate/gate_core_api.h"
#include "gate/gatetypes.h"

Classes

struct  gate_enumerator_class
 Enumerator data type that stores the enumeration state. More...
 

Macros

#define GATE_FOR_ENUMERATOR(type, ptr_var, ptr_enumerator)   for(ptr_var = NULL; ptr_enumerator && (ptr_var = (type const*)gate_enumerator_next_item(ptr_enumerator)); )
 

Typedefs

typedef struct gate_enumerator_class gate_enumerator_t
 Enumerator data type that stores the enumeration state.
 

Functions

GATE_CORE_API gate_bool_t gate_enumerator_valid (gate_enumerator_t const *enumerator)
 Returns if the enumerator currently points to a valid item.
 
GATE_CORE_API gate_bool_t gate_enumerator_next (gate_enumerator_t *enumerator)
 Moves the iterator to the next following item.
 
GATE_CORE_API void const * gate_enumerator_get (gate_enumerator_t const *enumerator)
 Returns a pointer to the current element.
 
GATE_CORE_API void const * gate_enumerator_next_item (gate_enumerator_t *enumerator)
 Moves the iterator to the next following item and returns a pointer to it.
 
GATE_CORE_API gate_enumerator_tgate_enumerator_for_array (gate_enumerator_t *enumerator, void const *begin, gate_size_t item_size, gate_size_t item_count)
 Creates an enumerator for a native C sequence array.
 

Detailed Description

Enumerator objects allow to walk through a set of elements.

Function Documentation

◆ gate_enumerator_for_array()

GATE_CORE_API gate_enumerator_t * gate_enumerator_for_array ( gate_enumerator_t * enumerator,
void const * begin,
gate_size_t item_size,
gate_size_t item_count )

Creates an enumerator for a native C sequence array.

Parameters
enumeratorpointer to enumerator object
beginpointer to the first element in the C sequence array
item_sizesize of on item in the array in bytes (cannot be 0)
item_countamount of items in the array (can be 0)
Returns
returns the first parameter on success, or NULL on failure

◆ gate_enumerator_get()

GATE_CORE_API void const * gate_enumerator_get ( gate_enumerator_t const * enumerator)

Returns a pointer to the current element.

Parameters
[in]enumeratorpointer to enumerator object
Returns
returns a pointer if the current element is valid, otherwise the return value is unspecified (can be anything); use gate_enumerator_valid() to verify the state

◆ gate_enumerator_next()

GATE_CORE_API gate_bool_t gate_enumerator_next ( gate_enumerator_t * enumerator)

Moves the iterator to the next following item.

Parameters
[in]enumeratorpointer to enumerator object
Returns
returns TRUE if the functions was successful and the next element can be retrieved, or FALSE if the end of the set was reached.

◆ gate_enumerator_next_item()

GATE_CORE_API void const * gate_enumerator_next_item ( gate_enumerator_t * enumerator)

Moves the iterator to the next following item and returns a pointer to it.

Parameters
[in]enumeratorpointer to enumerator object
Returns
returns the pointer to the item or NULL if the end was reached.

◆ gate_enumerator_valid()

GATE_CORE_API gate_bool_t gate_enumerator_valid ( gate_enumerator_t const * enumerator)

Returns if the enumerator currently points to a valid item.

Parameters
[in]enumeratorpointer to enumerator object
Returns
returns TRUE if gate_enumerator_get() would return a valid item, or FALSE if the end of the set was reached.