Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
include
citrusleaf
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,
37
CL_TIMESTAMP
= 5,
38
CL_DIGEST
= 6,
39
CL_JAVA_BLOB
= 7,
40
CL_CSHARP_BLOB
= 8,
41
CL_PYTHON_BLOB
= 9,
42
CL_RUBY_BLOB
= 10,
43
CL_PHP_BLOB
= 11,
44
CL_ERLANG_BLOB
= 12,
45
CL_APPEND
= 13,
46
CL_RTA_LIST
= 14,
47
CL_RTA_DICT
= 15,
48
CL_RTA_APPEND_DICT
= 16,
49
CL_RTA_APPEND_LIST
= 17,
50
CL_LUA_BLOB
= 18,
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 {
62
cl_type
type
;
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
76
void
citrusleaf_object_init
(
cl_object
* o);
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);
83
void
citrusleaf_object_init_null
(
cl_object
* o);
84
void
citrusleaf_object_free
(
cl_object
* o);
85
int
citrusleaf_copy_object
(
cl_object
* destobj,
cl_object
* srcobj);