Updated stats object to use a root like other structures.
[m6w6/libmemcached] / libmemcached / string.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: String structure used for libmemcached.
9 *
10 */
11
12 #ifndef __MEMCACHED_STRING_H__
13 #define __MEMCACHED_STRING_H__
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 LIBMEMCACHED_LOCAL
20 struct memcached_string_st {
21 memcached_st *root;
22 char *end;
23 char *string;
24 size_t current_size;
25 size_t block_size;
26 struct {
27 bool is_allocated:1;
28 bool is_initialized:1;
29 } options;
30 };
31
32 #define memcached_string_length(A) (size_t)((A)->end - (A)->string)
33 #define memcached_string_set_length(A, B) (A)->end= (A)->string + B
34 #define memcached_string_size(A) (A)->current_size
35 #define memcached_string_value(A) (A)->string
36
37 LIBMEMCACHED_LOCAL
38 memcached_string_st *memcached_string_create(memcached_st *ptr,
39 memcached_string_st *string,
40 size_t initial_size);
41 LIBMEMCACHED_LOCAL
42 memcached_return_t memcached_string_check(memcached_string_st *string, size_t need);
43
44 LIBMEMCACHED_LOCAL
45 char *memcached_string_c_copy(memcached_string_st *string);
46
47 LIBMEMCACHED_LOCAL
48 memcached_return_t memcached_string_append_character(memcached_string_st *string,
49 char character);
50 LIBMEMCACHED_LOCAL
51 memcached_return_t memcached_string_append(memcached_string_st *string,
52 const char *value, size_t length);
53 LIBMEMCACHED_LOCAL
54 memcached_return_t memcached_string_reset(memcached_string_st *string);
55
56 LIBMEMCACHED_LOCAL
57 void memcached_string_free(memcached_string_st *string);
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif /* __MEMCACHED_STRING_H__ */