diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/include/eina_binbuf.h | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/include/eina_binbuf.h | 217 |
1 files changed, 217 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_binbuf.h b/libraries/eina/src/include/eina_binbuf.h new file mode 100644 index 0000000..92f788e --- /dev/null +++ b/libraries/eina/src/include/eina_binbuf.h | |||
@@ -0,0 +1,217 @@ | |||
1 | #ifndef EINA_BINBUF_H | ||
2 | #define EINA_BINBUF_H | ||
3 | |||
4 | #include <stddef.h> | ||
5 | #include <stdarg.h> | ||
6 | |||
7 | #include "eina_types.h" | ||
8 | |||
9 | /** | ||
10 | * @addtogroup Eina_Binary_Buffer_Group Binary Buffer | ||
11 | * | ||
12 | * @brief These functions provide string buffers management. | ||
13 | * | ||
14 | * The Binary Buffer data type is designed to be a mutable string, | ||
15 | * allowing to append, prepend or insert a string to a buffer. | ||
16 | */ | ||
17 | |||
18 | /** | ||
19 | * @addtogroup Eina_Data_Types_Group Data Types | ||
20 | * | ||
21 | * @{ | ||
22 | */ | ||
23 | |||
24 | /** | ||
25 | * @defgroup Eina_Binary_Buffer_Group Binary Buffer | ||
26 | * | ||
27 | * @{ | ||
28 | */ | ||
29 | |||
30 | /** | ||
31 | * @typedef Eina_Binbuf | ||
32 | * Type for a string buffer. | ||
33 | */ | ||
34 | typedef struct _Eina_Strbuf Eina_Binbuf; | ||
35 | |||
36 | /** | ||
37 | * @brief Create a new string buffer. | ||
38 | * | ||
39 | * @return Newly allocated string buffer instance. | ||
40 | * | ||
41 | * This function creates a new string buffer. On error, @c NULL is | ||
42 | * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To | ||
43 | * free the resources, use eina_binbuf_free(). | ||
44 | * | ||
45 | * @see eina_binbuf_free() | ||
46 | * @see eina_binbuf_append() | ||
47 | * @see eina_binbuf_string_get() | ||
48 | */ | ||
49 | EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | ||
50 | |||
51 | /** | ||
52 | * @brief Free a string buffer. | ||
53 | * | ||
54 | * @param buf The string buffer to free. | ||
55 | * | ||
56 | * This function frees the memory of @p buf. @p buf must have been | ||
57 | * created by eina_binbuf_new(). | ||
58 | */ | ||
59 | EAPI void eina_binbuf_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); | ||
60 | |||
61 | /** | ||
62 | * @brief Reset a string buffer. | ||
63 | * | ||
64 | * @param buf The string buffer to reset. | ||
65 | * | ||
66 | * This function reset @p buf: the buffer len is set to 0, and the | ||
67 | * string is set to '\\0'. No memory is free'd. | ||
68 | */ | ||
69 | EAPI void eina_binbuf_reset(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); | ||
70 | |||
71 | /** | ||
72 | * @brief Append a string of exact length to a buffer, reallocating as necessary. | ||
73 | * | ||
74 | * @param buf The string buffer to append to. | ||
75 | * @param str The string to append. | ||
76 | * @param length The exact length to use. | ||
77 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
78 | * | ||
79 | * This function appends @p str to @p buf. @p str must be of size at | ||
80 | * most @p length. It is slightly faster than eina_binbuf_append() as | ||
81 | * it does not compute the size of @p str. It is useful when dealing | ||
82 | * with strings of known size, such as eina_strngshare. If @p buf | ||
83 | * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is | ||
84 | * returned. | ||
85 | * | ||
86 | * @see eina_stringshare_length() | ||
87 | * @see eina_binbuf_append() | ||
88 | * @see eina_binbuf_append_n() | ||
89 | */ | ||
90 | EAPI Eina_Bool eina_binbuf_append_length(Eina_Binbuf *buf, const unsigned char *str, size_t length) EINA_ARG_NONNULL(1, 2); | ||
91 | |||
92 | /** | ||
93 | * @brief Append a character to a string buffer, reallocating as | ||
94 | * necessary. | ||
95 | * | ||
96 | * @param buf The string buffer to append to. | ||
97 | * @param c The char to append. | ||
98 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
99 | * | ||
100 | * This function inserts @p c to @p buf. If it can not insert it, | ||
101 | * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. | ||
102 | */ | ||
103 | EAPI Eina_Bool eina_binbuf_append_char(Eina_Binbuf *buf, unsigned char c) EINA_ARG_NONNULL(1); | ||
104 | |||
105 | /** | ||
106 | * @brief Insert a string of exact length to a buffer, reallocating as necessary. | ||
107 | * | ||
108 | * @param buf The string buffer to insert to. | ||
109 | * @param str The string to insert. | ||
110 | * @param length The exact length to use. | ||
111 | * @param pos The position to insert the string. | ||
112 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
113 | * | ||
114 | * This function inserts @p str to @p buf. @p str must be of size at | ||
115 | * most @p length. It is slightly faster than eina_binbuf_insert() as | ||
116 | * it does not compute the size of @p str. It is useful when dealing | ||
117 | * with strings of known size, such as eina_strngshare. If @p buf | ||
118 | * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is | ||
119 | * returned. | ||
120 | * | ||
121 | * @see eina_stringshare_length() | ||
122 | * @see eina_binbuf_insert() | ||
123 | * @see eina_binbuf_insert_n() | ||
124 | */ | ||
125 | EAPI Eina_Bool eina_binbuf_insert_length(Eina_Binbuf *buf, const unsigned char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2); | ||
126 | |||
127 | /** | ||
128 | * @brief Insert a character to a string buffer, reallocating as | ||
129 | * necessary. | ||
130 | * | ||
131 | * @param buf The string buffer to insert to. | ||
132 | * @param c The char to insert. | ||
133 | * @param pos The position to insert the char. | ||
134 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
135 | * | ||
136 | * This function inserts @p c to @p buf at position @p pos. If @p buf | ||
137 | * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is | ||
138 | * returned. | ||
139 | */ | ||
140 | EAPI Eina_Bool eina_binbuf_insert_char(Eina_Binbuf *buf, unsigned char c, size_t pos) EINA_ARG_NONNULL(1); | ||
141 | |||
142 | /** | ||
143 | * @brief Remove a slice of the given string buffer. | ||
144 | * | ||
145 | * @param buf The string buffer to remove a slice. | ||
146 | * @param start The initial (inclusive) slice position to start | ||
147 | * removing, in bytes. | ||
148 | * @param end The final (non-inclusive) slice position to finish | ||
149 | * removing, in bytes. | ||
150 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
151 | * | ||
152 | * This function removes a slice of @p buf, starting at @p start | ||
153 | * (inclusive) and ending at @p end (non-inclusive). Both values are | ||
154 | * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. | ||
155 | */ | ||
156 | |||
157 | EAPI Eina_Bool eina_binbuf_remove(Eina_Binbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); | ||
158 | |||
159 | /** | ||
160 | * @brief Retrieve a pointer to the contents of a string buffer | ||
161 | * | ||
162 | * @param buf The string buffer. | ||
163 | * @return The current string in the string buffer. | ||
164 | * | ||
165 | * This function returns the string contained in @p buf. The returned | ||
166 | * value must not be modified and will no longer be valid if @p buf is | ||
167 | * modified. In other words, any eina_binbuf_append() or similar will | ||
168 | * make that pointer invalid. | ||
169 | * | ||
170 | * @see eina_binbuf_string_steal() | ||
171 | */ | ||
172 | EAPI const unsigned char *eina_binbuf_string_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
173 | |||
174 | /** | ||
175 | * @brief Steal the contents of a string buffer. | ||
176 | * | ||
177 | * @param buf The string buffer to steal. | ||
178 | * @return The current string in the string buffer. | ||
179 | * | ||
180 | * This function returns the string contained in @p buf. @p buf is | ||
181 | * then initialized and does not own the returned string anymore. The | ||
182 | * caller must release the memory of the returned string by calling | ||
183 | * free(). | ||
184 | * | ||
185 | * @see eina_binbuf_string_get() | ||
186 | */ | ||
187 | EAPI unsigned char *eina_binbuf_string_steal(Eina_Binbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); | ||
188 | |||
189 | /** | ||
190 | * @brief Free the contents of a string buffer but not the buffer. | ||
191 | * | ||
192 | * @param buf The string buffer to free the string of. | ||
193 | * | ||
194 | * This function frees the string contained in @p buf without freeing | ||
195 | * @p buf. | ||
196 | */ | ||
197 | EAPI void eina_binbuf_string_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); | ||
198 | |||
199 | /** | ||
200 | * @brief Retrieve the length of the string buffer content. | ||
201 | * | ||
202 | * @param buf The string buffer. | ||
203 | * @return The current length of the string, in bytes. | ||
204 | * | ||
205 | * This function returns the length of @p buf. | ||
206 | */ | ||
207 | EAPI size_t eina_binbuf_length_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
208 | |||
209 | /** | ||
210 | * @} | ||
211 | */ | ||
212 | |||
213 | /** | ||
214 | * @} | ||
215 | */ | ||
216 | |||
217 | #endif /* EINA_STRBUF_H */ | ||