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
src/include/aerospike/as_serializer.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_types.h>
27
#include <aerospike/as_buffer.h>
28
29
#include <stdint.h>
30
31
/******************************************************************************
32
* TYPES
33
*****************************************************************************/
34
35
struct
as_serializer_hooks_s;
36
37
/**
38
* Serializer Object
39
*/
40
typedef
struct
as_serializer_s {
41
42
/**
43
* @private
44
* If true, then as_serializer_destroy() will free this.
45
*/
46
bool
free
;
47
48
/**
49
* Data for the serializer.
50
*/
51
void
*
data
;
52
53
/**
54
* Hooks for the serializer
55
*/
56
const
struct
as_serializer_hooks_s *
hooks
;
57
58
}
as_serializer
;
59
60
/**
61
* Serializer Function Hooks
62
*/
63
typedef
struct
as_serializer_hooks_s {
64
void (* destroy)(
as_serializer
*);
65
int (* serialize)(
as_serializer
*,
as_val
*,
as_buffer
*);
66
int (* deserialize)(
as_serializer
*,
as_buffer
*,
as_val
**);
67
}
as_serializer_hooks
;
68
69
/******************************************************************************
70
* FUNCTIONS
71
*****************************************************************************/
72
73
as_serializer
*
as_serializer_cons
(
as_serializer
* serializer,
bool
free,
void
*
data
,
const
as_serializer_hooks
* hooks);
74
75
as_serializer
*
as_serializer_init
(
as_serializer
* serializer,
void
*
data
,
const
as_serializer_hooks
* hooks);
76
77
as_serializer
*
as_serializer_new
(
void
*
data
,
const
as_serializer_hooks
*);
78
79
void
as_serializer_destroy
(
as_serializer
*);
80
81
/******************************************************************************
82
* INLINE FUNCTIONS
83
*****************************************************************************/
84
85
static
inline
int
as_serializer_serialize
(
as_serializer
* serializer,
as_val
* val,
as_buffer
* buffer)
86
{
87
return
as_util_hook
(serialize, 1, serializer, val, buffer);
88
}
89
90
static
inline
int
as_serializer_deserialize
(
as_serializer
* serializer,
as_buffer
* buffer,
as_val
** val)
91
{
92
return
as_util_hook
(deserialize, 1, serializer, buffer, val);
93
}