Fix conversion from macro to inline.
[awesomized/libmemcached] / libmemcached / result.h
1 /* LibMemcached
2 * Copyright (C) 2006-2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: Functions to manipulate the result structure.
9 *
10 */
11
12 #ifndef __MEMCACHED_RESULT_H__
13 #define __MEMCACHED_RESULT_H__
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 struct memcached_result_st {
20 struct {
21 bool is_allocated:1;
22 bool is_initialized:1;
23 } options;
24 uint32_t flags;
25 time_t expiration;
26 memcached_st *root;
27 size_t key_length;
28 uint64_t cas;
29 memcached_string_st value;
30 char key[MEMCACHED_MAX_KEY];
31 /* Add result callback function */
32 };
33
34 /* Result Struct */
35 LIBMEMCACHED_API
36 void memcached_result_free(memcached_result_st *result);
37 LIBMEMCACHED_API
38 void memcached_result_reset(memcached_result_st *ptr);
39 LIBMEMCACHED_API
40 memcached_result_st *memcached_result_create(memcached_st *ptr,
41 memcached_result_st *result);
42
43 static inline const char *memcached_result_key_value(const memcached_result_st *self)
44 {
45 return self->key;
46 }
47
48 static inline size_t memcached_result_key_length(const memcached_result_st *self)
49 {
50 return self->key_length;
51 }
52
53 static inline const char *memcached_result_value(const memcached_result_st *self)
54 {
55 const memcached_string_st *sptr= &self->value;
56 return memcached_string_value(sptr);
57 }
58
59 static inline size_t memcached_result_length(const memcached_result_st *self)
60 {
61 const memcached_string_st *sptr= &self->value;
62 return memcached_string_length(sptr);
63 }
64
65 static inline uint32_t memcached_result_flags(const memcached_result_st *self)
66 {
67 return self->flags;
68 }
69
70 static inline uint64_t memcached_result_cas(const memcached_result_st *self)
71 {
72 return self->cas;
73 }
74
75 static inline memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length)
76 {
77 return memcached_string_append(&ptr->value, value, length);
78 }
79
80 static inline void memcached_result_set_flags(memcached_result_st *self, uint32_t flags)
81 {
82 self->flags= flags;
83 }
84
85 static inline void memcached_result_set_expiration(memcached_result_st *self, time_t expiration)
86 {
87 self->expiration= expiration;
88 }
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* __MEMCACHED_RESULT_H__ */