Loading...
Searching...
No Matches
Data Fields | Related Symbols
as_record_iterator Struct Reference

Detailed Description

Iterator over bins of a record.

Initialization

The as_record_iterator can be initialized via:

Both of the function require the record on which it will iterate.

To initialize an as_record_iterator on the stack:

AS_EXTERN as_record_iterator * as_record_iterator_init(as_record_iterator *iterator, const as_record *record)
const as_record * record

To initialize an as_record_iterator on the heap:

AS_EXTERN as_record_iterator * as_record_iterator_new(const as_record *record)

Destruction

When you no longer require the iterator, you should release it and associated resource via as_record_iterator_destroy():

AS_EXTERN void as_record_iterator_destroy(as_record_iterator *iterator)

Usage

With an initialized as_record_iterator, you can traverse the bins of a record.

Traversal is usually performed by first checking to see if the there are any bins available to traverse to via as_record_iterator_has_next(), which returns true if there are more bins, or false if there are no more bins.

AS_EXTERN bool as_record_iterator_has_next(const as_record_iterator *iterator)

When you are sure there are more bins, then you will use as_record_iterator_next() to read the next bin. If there are no bins available, then NULL is returned.

AS_EXTERN as_bin * as_record_iterator_next(as_record_iterator *iterator)

If as_record_iterator_next() returns a bin, then you can use the following functions to get information about the bin:

Most often, a traversal is performed in a while loop. The following is a simple example:

char* name = as_bin_get_name(bin);
as_val* value = (as_val*) as_bin_get_value(bin);
}

Definition at line 117 of file as_record_iterator.h.

#include "as_record_iterator.h"

+ Collaboration diagram for as_record_iterator:

Data Fields

uint32_t pos
 
const as_recordrecord
 

Related Symbols

(Note that these are not member symbols.)

AS_EXTERN void as_record_iterator_destroy (as_record_iterator *iterator)
 
AS_EXTERN bool as_record_iterator_has_next (const as_record_iterator *iterator)
 
AS_EXTERN as_record_iteratoras_record_iterator_init (as_record_iterator *iterator, const as_record *record)
 
AS_EXTERN as_record_iteratoras_record_iterator_new (const as_record *record)
 
AS_EXTERN as_binas_record_iterator_next (as_record_iterator *iterator)
 

Friends And Related Symbol Documentation

◆ as_record_iterator_destroy()

AS_EXTERN void as_record_iterator_destroy ( as_record_iterator * iterator)
related

Destroy the as_record_iterator and associated resources.

Parameters
iteratorThe iterator to destroy.

◆ as_record_iterator_has_next()

AS_EXTERN bool as_record_iterator_has_next ( const as_record_iterator * iterator)
related

Test if there are more bins in the iterator.

Parameters
iteratorThe iterator to test.
Returns
the number of bins in the record.

◆ as_record_iterator_init()

AS_EXTERN as_record_iterator * as_record_iterator_init ( as_record_iterator * iterator,
const as_record * record )
related

Initializes a stack allocated as_record_iterator for the specified record.

When you are finished using the as_record instance, you should release the resources allocated to it by calling as_record_destroy().

Parameters
iteratorThe iterator to initialize.
recordThe record to iterate over
Returns
On success, a new as_record_iterator. Otherwise an error occurred.

◆ as_record_iterator_new()

AS_EXTERN as_record_iterator * as_record_iterator_new ( const as_record * record)
related

Create and initialize a heap allocated as_record_iterator for the specified record.

Parameters
recordThe record to iterate over.
Returns
On success, a new as_record_iterator. Otherwise an error occurred.

◆ as_record_iterator_next()

AS_EXTERN as_bin * as_record_iterator_next ( as_record_iterator * iterator)
related

Read the next bin from the iterator.

Parameters
iteratorThe iterator to read from.
Returns
The next bin from the iterator.

Field Documentation

◆ pos

uint32_t as_record_iterator::pos

Current position of the iterator

Definition at line 133 of file as_record_iterator.h.

◆ record

const as_record* as_record_iterator::record

The record being iterated over.

Definition at line 128 of file as_record_iterator.h.


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