ASON_ITER_VALUE(3)
π NAME π
okay bestie, meet the whole squad: ason_iterate, ason_iter_enter, ason_iter_exit, ason_iter_next, ason_iter_prev, ason_iter_long, ason_iter_double, ason_iter_string, ason_iter_value, ason_iter_key, ason_iter_destroy, ason_iter_type β they're all about creating and adjusting iterators so you can go explore ason_t values. this is the ASON ITERATORS(3) page from the User Manuals, and it's giving main character energy fr fr π
β¨ SYNOPSIS β¨
#include <ason/ason.h>
#include <ason/iter.h>
ason_iter_t *ason_iterate(ason_t *value);
int ason_iter_enter(ason_iter_t *iter);
int ason_iter_exit(ason_iter_t *iter);
int ason_iter_next(ason_iter_t *iter);
int ason_iter_prev(ason_iter_t *iter);
long ason_iter_long(ason_iter_t *iter);
double ason_iter_double(ason_iter_t *iter);
char *ason_iter_string(ason_iter_t *iter);
ason_t *ason_iter_value(ason_iter_t *iter);
char *ason_iter_key(ason_iter_t *iter);
void ason_iter_destroy(ason_iter_t *iter);
ason_type_t ason_iter_type(ason_iter_t *iter);
π DESCRIPTION π
so like, ASON iterators are the lil tour guides you use to traverse ASON values and query the individual values hiding inside. you make one with ason_iterate, and the way that you should always release it after use with ason_iter_destroy β no leaving your iterator out in the cold, okay? π₯Ί
the second you create it, the iterator is pointing at the object you passed into ason_iterate. want a copy of that value? ason_iter_value has you covered, bestie.
ason_iter_enterβ this is your "go deeper" button. it starts iterating the sub-values of a value. it'll let you walk through:- operands of an irreducible operator,
- values in a list,
- and key-value pairs in an object or universal object.
plot twist: values joined by union operators get merged into one value, so if you entered 6 | 7 | 8 you'd be able to iterate through 6, 7, and 8 sequentially. iconic behavior honestly.
ason_iter_exitβ reverses the effect ofason_enter. the iterator points back to the containing value. bye, we're going back up πason_iter_nextandason_iter_prevβ shift to the next and previous values being iterated, respectively. if you're already at the beginning or the end of the set? they have no effect. nothing happens. no drama. it's fine.ason_iter_typeβ returns a constant indicating the type of value the iterator currently points to. seeason_values(3)for the tea βason_iter_long,ason_iter_double, andason_iter_stringβ these return the C value of ASON numerical values or ASON string values. and ngl, it is an error to use these functions when the iterator is not pointing to a value of the type they convert. so like... always useason_iter_typeto verify the type first. no cap. alsoason_iter_stringreturns a pointer to a region that must be freed withfree(3)β don't forget, bestie π«Άason_iter_valueβ Returns anason_t *copy of the value the iterator is currently pointing to.ason_iter_keyβ returns the key for the value the iterator currently points to, if we are iterating through an object.
πΈ RETURN VALUE πΈ
ason_iteratereturns a new iterator which should be released withason_iter_destroy. (yes, release it. it's the rules π)ason_iter_enter,ason_iter_exit,ason_iter_next, andason_iter_prevwill return nonzero when and only when it was possible to move the iterator in the way prescribed.ason_iter_typereturns a constant indicating the type of the value the iterator points to.ason_iter_long, andason_iter_doublereturn the numerical value that the iterator points to.ason_iter_string, andason_iter_keyreturn string pointers that should be released withfree(3)and which contain the string value the iterator points to, or the key for the value the iterator points to.ason_iter_valuereturns a value of typeason_t *which should be released withason_destroy(3).
π ERRORS π
libason will abort ifason_iter_long,ason_iter_double, orason_iter_stringare used when the iterator does not point to the appropriate type of value. π check the type first, i am literally begging.
ason_iter_key will cause an abort if used while not iterating through an object. π
π¦ SEE ALSO π¦
π AUTHOR π
Casey Dahlin <casey.dahlin@gmail.com>
okay that's the whole page, you ate that bestie β¨ this lil gem comes to you from Linux, dated JANUARY 2014, and it's the ASON ITERATORS(3) manual page. go forth and iterate responsibly, mwah πππ¦
π¦ where this page comes from
- fedora 43: libason-devel 0.1.2-27.fc43 Β· GPL-3.0-or-later
- fedora 43: libason-devel 0.1.2-27.fc43 Β· GPL-3.0-or-later
- fedora 44: libason-devel 0.1.2-28.fc44 Β· GPL-3.0-or-later
- fedora 44: libason-devel 0.1.2-28.fc44 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms