Loading...
Searching...
No Matches
as_bin.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2021 Aerospike, Inc.
3 *
4 * Portions may be licensed to Aerospike, Inc. under one or more contributor
5 * license agreements.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8 * use this file except in compliance with the License. You may obtain a copy of
9 * the License at http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#pragma once
18
21#include <aerospike/as_string.h>
23#include <aerospike/as_bytes.h>
24#include <aerospike/as_list.h>
25#include <aerospike/as_map.h>
26#include <aerospike/as_val.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/******************************************************************************
33 * MACROS
34 *****************************************************************************/
35
36/**
37 * Maximum bin name size
38 */
39#define AS_BIN_NAME_MAX_SIZE 16
40
41/**
42 * Maximum bin name length
43 */
44#define AS_BIN_NAME_MAX_LEN (AS_BIN_NAME_MAX_SIZE - 1)
45
46/******************************************************************************
47 * TYPES
48 *****************************************************************************/
49
50/**
51 * Bin Name
52 */
54
55/**
56 * Bin Value
57 */
68
69/**
70 * Represents a bin of a record. Each bin is a (name,value) pair.
71 *
72 * Bins of a record should never be directly accessed. The bins should only
73 * be modified via as_record functions. The only time an as_bin is directly
74 * accessible is during iteration via as_record_iterator, but the
75 * as_bin functions should be used to read the values.
76 *
77 * @ingroup client_objects
78 */
79typedef struct as_bin_s {
80
81 /**
82 * Bin name.
83 */
85
86 /**
87 * Bin value.
88 */
90
91 /**
92 * Bin value pointer.
93 * If NULL, then there is no value.
94 * It can point to as_bin.value or a different value.
95 */
97
98} as_bin;
99
100/**
101 * Sequence of bins.
102 */
103typedef struct as_bins_s {
104
105 /**
106 * Storage for bins
107 */
109
110 /**
111 * Number of entries allocated to data.
112 */
113 uint16_t capacity;
114
115 /**
116 * Number of entries currently holding data.
117 */
118 uint16_t size;
119
120 /**
121 * @private
122 * If true, then as_record_destroy() will free data
123 */
124 bool _free;
125
126} as_bins;
127
128/******************************************************************************
129 * INLINE FUNCTIONS
130 *****************************************************************************/
131
132/**
133 * Get the name of the bin.
134 *
135 * ~~~~~~~~~~{.c}
136 * char * name = as_bin_get_name(bin);
137 * ~~~~~~~~~~
138 *
139 * @param bin The bin to get the name of.
140 *
141 * @return The name of the bin.
142 *
143 * @relates as_bin
144 */
145static inline char*
147{
148 return (char *) bin->name;
149}
150
151/**
152 * Get the value of the bin.
153 *
154 * ~~~~~~~~~~{.c}
155 * as_bin_value val = as_bin_get_value(bin);
156 * ~~~~~~~~~~
157 *
158 * @param bin The bin to get the value of.
159 *
160 * @return The value of the bin.
161 *
162 * @relates as_bin
163 */
164static inline as_bin_value*
166{
167 return bin->valuep;
168}
169
170/**
171 * Get the type for the value of the bin.
172 *
173 * ~~~~~~~~~~{.c}
174 * as_val_t type = as_bin_get_type(bin);
175 * ~~~~~~~~~~
176 *
177 * @param bin The bin to get value's type.
178 *
179 * @return The type of the bin's value
180 *
181 * @relates as_bin
182 */
183static inline as_val_t
185{
186 return as_val_type(bin->valuep);
187}
188
189#ifdef __cplusplus
190} // end extern "C"
191#endif
char as_bin_name[AS_BIN_NAME_MAX_SIZE]
Definition as_bin.h:53
#define AS_BIN_NAME_MAX_SIZE
Definition as_bin.h:39
uint8_t as_val_t
Definition as_val.h:32
#define as_val_type(__v)
Definition as_val.h:95
static char * as_bin_get_name(const as_bin *bin)
Definition as_bin.h:146
as_bin_value value
Definition as_bin.h:89
static as_val_t as_bin_get_type(const as_bin *bin)
Definition as_bin.h:184
as_bin_name name
Definition as_bin.h:84
as_bin_value * valuep
Definition as_bin.h:96
static as_bin_value * as_bin_get_value(const as_bin *bin)
Definition as_bin.h:165
uint16_t size
Definition as_bin.h:118
as_bin * entries
Definition as_bin.h:108
uint16_t capacity
Definition as_bin.h:113
as_integer integer
Definition as_bin.h:61
as_bytes bytes
Definition as_bin.h:64
as_val nil
Definition as_bin.h:59
as_double dbl
Definition as_bin.h:62
as_string string
Definition as_bin.h:63
as_list list
Definition as_bin.h:65
as_boolean boolean
Definition as_bin.h:60
as_map map
Definition as_bin.h:66