All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_bin.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 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 
19 #include <aerospike/as_integer.h>
20 #include <aerospike/as_string.h>
21 #include <aerospike/as_bytes.h>
22 #include <aerospike/as_list.h>
23 #include <aerospike/as_map.h>
24 #include <aerospike/as_val.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /******************************************************************************
31  * MACROS
32  *****************************************************************************/
33 
34 /**
35  * Maximum bin name size
36  */
37 #define AS_BIN_NAME_MAX_SIZE 15
38 
39 /**
40  * Maximum bin name length
41  */
42 #define AS_BIN_NAME_MAX_LEN (AS_BIN_NAME_MAX_SIZE - 1)
43 
44 /******************************************************************************
45  * TYPES
46  *****************************************************************************/
47 
48 /**
49  * Bin Name
50  */
52 
53 /**
54  * Bin Value
55  */
56 typedef union as_bin_value_s {
64 } as_bin_value;
65 
66 /**
67  * Represents a bin of a record. Each bin is a (name,value) pair.
68  *
69  * Bins of a record should never be directly accessed. The bins should only
70  * be modified via as_record functions. The only time an as_bin is directly
71  * accessible is during iteration via as_record_iterator, but the
72  * as_bin functions should be used to read the values.
73  *
74  * @ingroup client_objects
75  */
76 typedef struct as_bin_s {
77 
78  /**
79  * Bin name.
80  */
81  as_bin_name name;
82 
83  /**
84  * Bin value.
85  */
87 
88  /**
89  * Bin value pointer.
90  * If NULL, then there is no value.
91  * It can point to as_bin.value or a different value.
92  */
94 
95 } as_bin;
96 
97 /**
98  * Sequence of bins.
99  */
100 typedef struct as_bins_s {
101 
102  /**
103  * @private
104  * If true, then as_record_destroy() will free data
105  */
106  bool _free;
107 
108  /**
109  * Number of entries allocated to data.
110  */
111  uint16_t capacity;
112 
113  /**
114  * Number of entries currently holding data.
115  */
116  uint16_t size;
117 
118  /**
119  * Storage for bins
120  */
122 
123 } as_bins;
124 
125 /******************************************************************************
126  * INLINE FUNCTIONS
127  *****************************************************************************/
128 
129 /**
130  * Get the name of the bin.
131  *
132  * ~~~~~~~~~~{.c}
133  * char * name = as_bin_get_name(bin);
134  * ~~~~~~~~~~
135  *
136  * @param bin The bin to get the name of.
137  *
138  * @return The name of the bin.
139  *
140  * @relates as_bin
141  */
142 static inline char * as_bin_get_name(const as_bin * bin) {
143  return (char *) bin->name;
144 }
145 
146 
147 /**
148  * Get the value of the bin.
149  *
150  * ~~~~~~~~~~{.c}
151  * as_bin_value val = as_bin_get_value(bin);
152  * ~~~~~~~~~~
153  *
154  * @param bin The bin to get the value of.
155  *
156  * @return The value of the bin.
157  *
158  * @relates as_bin
159  */
160 static inline as_bin_value * as_bin_get_value(const as_bin * bin) {
161  return bin->valuep;
162 }
163 
164 
165 /**
166  * Get the type for the value of the bin.
167  *
168  * ~~~~~~~~~~{.c}
169  * as_val_t type = as_bin_get_type(bin);
170  * ~~~~~~~~~~
171  *
172  * @param bin The bin to get value's type.
173  *
174  * @return The type of the bin's value
175  *
176  * @relates as_bin
177  */
178 static inline as_val_t as_bin_get_type(const as_bin * bin) {
179  return as_val_type(bin->valuep);
180 }
181 
182 #ifdef __cplusplus
183 } // end extern "C"
184 #endif
as_list list
Definition: as_bin.h:62
as_bytes bytes
Definition: as_bin.h:61
Definition: as_map.h:61
as_bin_value * valuep
Definition: as_bin.h:93
#define AS_BIN_NAME_MAX_SIZE
Definition: as_bin.h:37
as_bin_value value
Definition: as_bin.h:86
as_val nil
Definition: as_bin.h:57
as_bin_name name
Definition: as_bin.h:81
uint16_t capacity
Definition: as_bin.h:111
as_val_t
Definition: as_val.h:36
as_bin * entries
Definition: as_bin.h:121
Definition: as_bin.h:76
bool _free
Definition: as_bin.h:106
Definition: as_val.h:56
as_map map
Definition: as_bin.h:63
as_integer integer
Definition: as_bin.h:58
as_double dbl
Definition: as_bin.h:59
char as_bin_name[AS_BIN_NAME_MAX_SIZE]
Definition: as_bin.h:51
#define as_val_type(__v)
Definition: as_val.h:90
static char * as_bin_get_name(const as_bin *bin)
Definition: as_bin.h:142
as_string string
Definition: as_bin.h:60
static as_val_t as_bin_get_type(const as_bin *bin)
Definition: as_bin.h:178
static as_bin_value * as_bin_get_value(const as_bin *bin)
Definition: as_bin.h:160
uint16_t size
Definition: as_bin.h:116