All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cl_object.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 #pragma once
23 
24 #include <stdlib.h>
25 
26 /******************************************************************************
27  * TYPES
28  ******************************************************************************/
29 
30 
31 typedef enum cl_type_e {
32  CL_NULL = 0,
33  CL_INT = 1,
34  CL_FLOAT = 2,
35  CL_STR = 3,
36  CL_BLOB = 4,
38  CL_DIGEST = 6,
45  CL_APPEND = 13,
51  CL_MAP = 19,
52  CL_LIST = 20,
53  CL_UNKNOWN = 666666
54 } cl_type;
55 
56 /**
57  * An object is the value in a bin, or it is used as a key
58  * The object is typed according to the citrusleaf typing system
59  * These are often stack allocated, and are assigned using the 'wrap' calls
60  */
61 typedef struct cl_object_s {
63  size_t sz;
64  union {
65  char * str; // note for str: sz is strlen (not strlen+1
66  void * blob;
67  int64_t i64; // easiest to have one large int type
68  } u;
69  void * free; // if this is set, this must be freed on destructuion
70 } cl_object;
71 
72 /******************************************************************************
73  * FUNCTIONS
74  ******************************************************************************/
75 
77 void citrusleaf_object_init_str(cl_object * o, char const * str);
78 void citrusleaf_object_init_str2(cl_object * o, char const * str, size_t str_len);
79 void citrusleaf_object_init_blob(cl_object * o, void const * buf, size_t buf_len);
80 void citrusleaf_object_init_blob2(cl_object * o, void const * buf, size_t buf_len, cl_type type);
81 void citrusleaf_object_init_blob_handoff(cl_object *o, void *blob, size_t len, cl_type t);
82 void citrusleaf_object_init_int(cl_object * o, int64_t i);
85 int citrusleaf_copy_object(cl_object * destobj, cl_object * srcobj);
void citrusleaf_object_init(cl_object *o)
cl_type type
Definition: cl_object.h:62
void citrusleaf_object_init_null(cl_object *o)
void * free
Definition: cl_object.h:69
char * str
Definition: cl_object.h:65
void citrusleaf_object_init_blob(cl_object *o, void const *buf, size_t buf_len)
void citrusleaf_object_init_str(cl_object *o, char const *str)
size_t sz
Definition: cl_object.h:63
int citrusleaf_copy_object(cl_object *destobj, cl_object *srcobj)
void * blob
Definition: cl_object.h:66
int64_t i64
Definition: cl_object.h:67
void citrusleaf_object_init_str2(cl_object *o, char const *str, size_t str_len)
void citrusleaf_object_init_int(cl_object *o, int64_t i)
void citrusleaf_object_init_blob2(cl_object *o, void const *buf, size_t buf_len, cl_type type)
void citrusleaf_object_free(cl_object *o)
cl_type
Definition: cl_object.h:31
void citrusleaf_object_init_blob_handoff(cl_object *o, void *blob, size_t len, cl_type t)