2 * Copyright (C) 2006-2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
8 * Summary: Functions to manipulate the result structure.
12 #ifndef __LIBMEMCACHED_RESULT_H__
13 #define __LIBMEMCACHED_RESULT_H__
15 struct memcached_result_st
{
17 time_t item_expiration
;
20 const memcached_st
*root
;
21 memcached_string_st value
;
22 char item_key
[MEMCACHED_MAX_KEY
];
24 bool is_allocated MEMCACHED_BITFIELD
;
25 bool is_initialized MEMCACHED_BITFIELD
;
27 /* Add result callback function */
36 void memcached_result_free(memcached_result_st
*result
);
39 void memcached_result_reset(memcached_result_st
*ptr
);
42 memcached_result_st
*memcached_result_create(const memcached_st
*ptr
,
43 memcached_result_st
*result
);
45 static inline const char *memcached_result_key_value(const memcached_result_st
*self
)
47 return self
->key_length
? self
->item_key
: NULL
;
50 static inline size_t memcached_result_key_length(const memcached_result_st
*self
)
52 return self
->key_length
;
55 static inline const char *memcached_result_value(const memcached_result_st
*self
)
57 const memcached_string_st
*sptr
= &self
->value
;
58 return memcached_string_value(sptr
);
61 static inline size_t memcached_result_length(const memcached_result_st
*self
)
63 const memcached_string_st
*sptr
= &self
->value
;
64 return memcached_string_length(sptr
);
67 static inline uint32_t memcached_result_flags(const memcached_result_st
*self
)
69 return self
->item_flags
;
72 static inline uint64_t memcached_result_cas(const memcached_result_st
*self
)
74 return self
->item_cas
;
78 memcached_return_t
memcached_result_set_value(memcached_result_st
*ptr
, const char *value
, size_t length
);
80 static inline void memcached_result_set_flags(memcached_result_st
*self
, uint32_t flags
)
82 self
->item_flags
= flags
;
85 static inline void memcached_result_set_expiration(memcached_result_st
*self
, time_t expiration
)
87 self
->item_expiration
= expiration
;
95 #endif /* __LIBMEMCACHED_RESULT_H__ */