Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
modules
common
src
include
aerospike
modules/common/src/include/aerospike/as_iterator.h
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright 2008-2013 by Aerospike.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to
6
* deal in the Software without restriction, including without limitation the
7
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
* sell copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
* IN THE SOFTWARE.
21
*****************************************************************************/
22
23
#pragma once
24
25
#include <aerospike/as_util.h>
26
#include <aerospike/as_val.h>
27
28
#include <stdbool.h>
29
30
/******************************************************************************
31
* TYPES
32
******************************************************************************/
33
34
struct
as_iterator_hooks_s;
35
36
/**
37
* Iterator Object
38
*/
39
typedef
struct
as_iterator_s {
40
41
/**
42
* @private
43
* If TRUE, then free this instance.
44
*/
45
bool
free
;
46
47
/**
48
* Data for the iterator.
49
*/
50
void
*
data
;
51
52
/**
53
* Hooks for subtypes of as_iterator.
54
*/
55
const
struct
as_iterator_hooks_s *
hooks
;
56
57
}
as_iterator
;
58
59
/**
60
* Iterator Function Hooks
61
*/
62
typedef
struct
as_iterator_hooks_s {
63
64
/**
65
* Releases the subtype of as_iterator.
66
*/
67
bool (* destroy)(
as_iterator
*);
68
69
/**
70
* Tests whether there is another element in the iterator.
71
*/
72
bool (* has_next)(
const
as_iterator
*);
73
74
/**
75
* Read the next value.
76
*/
77
const
as_val
* (* next)(
as_iterator
*);
78
79
}
as_iterator_hooks
;
80
81
/******************************************************************************
82
* INSTANCE FUNCTIONS
83
******************************************************************************/
84
85
/**
86
* Initialize a stack allocated iterator.
87
*/
88
as_iterator
*
as_iterator_init
(
as_iterator
* iterator,
bool
free,
void
*
data
,
const
as_iterator_hooks
* hooks);
89
90
/**
91
* Destroys the iterator and releasing associated resources.
92
*/
93
void
as_iterator_destroy
(
as_iterator
* iterator);
94
95
/******************************************************************************
96
* VALUE FUNCTIONS
97
******************************************************************************/
98
99
/**
100
* Tests if there are more values available in the iterator.
101
*
102
* @param iterator The iterator to be tested.
103
*
104
* @return true if there are more values, otherwise false.
105
*/
106
static
inline
bool
as_iterator_has_next
(
const
as_iterator
* iterator)
107
{
108
return
as_util_hook
(has_next,
false
, iterator);
109
}
110
111
/**
112
* Attempts to get the next value from the iterator.
113
* This will return the next value, and iterate past the value.
114
*
115
* @param iterator The iterator to get the next value from.
116
*
117
* @return the next value available in the iterator.
118
*/
119
static
inline
const
as_val
*
as_iterator_next
(
as_iterator
* iterator)
120
{
121
return
as_util_hook
(next, NULL, iterator);
122
}
as_iterator_init
as_iterator * as_iterator_init(as_iterator *iterator, bool free, void *data, const as_iterator_hooks *hooks)
as_iterator::free
bool free
Definition:
modules/common/src/include/aerospike/as_iterator.h:45
as_iterator_hooks
Definition:
modules/common/src/include/aerospike/as_iterator.h:62
as_iterator_destroy
void as_iterator_destroy(as_iterator *iterator)
as_val
Definition:
modules/common/src/include/aerospike/as_val.h:56
as_iterator::hooks
struct as_iterator_hooks_s * hooks
Definition:
modules/common/src/include/aerospike/as_iterator.h:55
data
uint8_t data[]
Definition:
src/include/citrusleaf/cf_proto.h:58
as_iterator_next
static const as_val * as_iterator_next(as_iterator *iterator)
Definition:
modules/common/src/include/aerospike/as_iterator.h:119
as_iterator_has_next
static bool as_iterator_has_next(const as_iterator *iterator)
Definition:
modules/common/src/include/aerospike/as_iterator.h:106
as_util_hook
#define as_util_hook(hook, default, object, args...)
Definition:
modules/common/src/include/aerospike/as_util.h:37
as_iterator::data
void * data
Definition:
modules/common/src/include/aerospike/as_iterator.h:50
as_iterator
Definition:
modules/common/src/include/aerospike/as_iterator.h:39