EFL 1.7 svn doobies
[profile/ivi/eina.git] / src / lib / eina_strbuf_common.h
1 #ifndef EINA_STRBUF_COMMON_H
2 #define EINA_STRBUF_COMMON_H
3
4 #include <stdlib.h>
5
6 #include "eina_private.h"
7 #include "eina_magic.h"
8 #include "eina_strbuf.h"
9
10 /**
11  * @struct _Eina_Strbuf
12  * String buffer to facilitate string operations.
13  */
14 struct _Eina_Strbuf
15 {
16    void *buf;
17    size_t len;
18    size_t size;
19    size_t step;
20
21    EINA_MAGIC
22 };
23
24 #define EINA_MAGIC_CHECK_STRBUF(d, ...)                         \
25    do {                                                         \
26         if (!EINA_MAGIC_CHECK((d), _STRBUF_MAGIC))              \
27           {                                                     \
28              EINA_MAGIC_FAIL((d), _STRBUF_MAGIC);               \
29              return __VA_ARGS__;                                \
30           }                                                     \
31      } while (0)
32
33 Eina_Bool
34 eina_strbuf_common_init(void);
35
36 Eina_Bool
37 eina_strbuf_common_shutdown(void);
38 Eina_Strbuf *
39 eina_strbuf_common_new(size_t csize);
40 Eina_Strbuf *
41 eina_strbuf_common_manage_new(size_t csize,
42                                void *str,
43                                size_t len);
44 void
45 eina_strbuf_common_free(Eina_Strbuf *buf);
46 void
47 eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf);
48 Eina_Bool
49 eina_strbuf_common_append(size_t csize,
50                           Eina_Strbuf *buf,
51                           const void *str,
52                           size_t len);
53 Eina_Bool
54 eina_strbuf_common_append_escaped(size_t csize,
55                                   Eina_Strbuf *buf,
56                                   const void *str);
57 Eina_Bool
58 eina_strbuf_common_append_n(size_t csize,
59                             Eina_Strbuf *buf,
60                             const void *str,
61                             size_t len,
62                             size_t maxlen);
63 Eina_Bool
64 eina_strbuf_common_append_length(size_t csize,
65                                  Eina_Strbuf *buf,
66                                  const void *str,
67                                  size_t length);
68 Eina_Bool
69 eina_strbuf_common_insert(size_t csize,
70                           Eina_Strbuf *buf,
71                           const void *str,
72                           size_t len,
73                           size_t pos);
74 Eina_Bool
75 eina_strbuf_common_insert_escaped(size_t csize,
76                                   Eina_Strbuf *buf,
77                                   const void *str,
78                                   size_t len,
79                                   size_t pos);
80 Eina_Bool
81 eina_strbuf_common_insert_n(size_t csize,
82                             Eina_Strbuf *buf,
83                             const void *str,
84                             size_t len,
85                             size_t maxlen,
86                             size_t pos);
87 Eina_Bool
88 eina_strbuf_common_insert_length(size_t csize,
89                                  Eina_Strbuf *buf,
90                                  const void *str,
91                                  size_t length,
92                                  size_t pos);
93 Eina_Bool
94 eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c);
95 Eina_Bool
96 eina_strbuf_common_insert_char(size_t csize,
97                                Eina_Strbuf *buf,
98                                const void *c,
99                                size_t pos);
100 Eina_Bool
101 eina_strbuf_common_remove(size_t csize,
102                           Eina_Strbuf *buf,
103                           size_t start,
104                           size_t end);
105 const void *
106 eina_strbuf_common_string_get(const Eina_Strbuf *buf);
107 void *
108 eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf *buf);
109 void
110 eina_strbuf_common_string_free(size_t csize, Eina_Strbuf *buf);
111 size_t
112 eina_strbuf_common_length_get(const Eina_Strbuf *buf);
113
114 Eina_Bool
115 _eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size);
116 /**
117  * @}
118  */
119
120 #endif