Debian Codegraph @

collection/collection_stack.h

raw symbols SCIP
1 /*
2 STACK
3
4 Header file for stack implemented using collection interface.
5
6 Copyright (C) Dmitri Pal <[email protected]> 2009
7
8 Collection Library is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 Collection Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with Collection Library. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef COLLECTION_STACK_H
23 #define COLLECTION_STACK_H
24
25 #include <collection.h>
26
27 /**
28 * @defgroup stack STACK interface
29 *
30 * Stack interface is a wrapper on top of the \ref collection
31 * interface. It implements a stack using a collection object.
32 *
33 * @{
34 */
35
36 /** @brief Class for the stack object */
37 #define COL_CLASS_STACK 30000
38 /** @brief All stacks use this name as the name of the collection */
39 #define COL_NAME_STACK "stack"
40
41 /**
42 * @brief Create stack.
43 *
44 * Function that creates a stack object.
45 *
46 * @param[out] stack Newly created stack object.
47 *
48 * @return 0 - Stack was created successfully.
49 * @return ENOMEM - No memory.
50 *
51 */
52 int col_create_stack(struct collection_item **stack);
53
54 /**
55 * @brief Destroy stack.
56 *
57 * Function that destroys a stack object.
58 *
59 * @param[in] stack Stack object to destroy.
60 *
61 */
62
63 void col_destroy_stack(struct collection_item *stack);
64
65 /**
66 * @brief Push string to the stack.
67 *
68 * @param[in] stack Stack object.
69 * @param[in] property Name of the property.<br>
70 * Name should consist of the ASCII characters
71 * with codes non less than space.
72 * Exclamation mark character is
73 * a special character and can't be used
74 * in name of collection or property.<br>
75 * Maximum allowed length is defined at compile time.
76 * The default value is 64k.
77 * @param[in] string Null terminated string to add.
78 * @param[in] length Length of the string. Should include the length
79 * of the terminating 0.
80 * If the length is shorter than the full string
81 * the string will be truncated. If the length is
82 * longer than the actual string there might be
83 * garbage at end of the actual string.
84 * Library will always properly NULL terminate
85 * the string at the given position dictated
86 * by length but in no way will inspect the validity
87 * of the passed in data. This is left to the calling
88 * application.
89 *
90 * @return 0 - Property was pushed successfully.
91 * @return ENOMEM - No memory.
92 * @return EINVAL - Invalid characters in the property name.
93 * Value argument is invalid in some way.
94 * @return EMSGSIZE - Property name is too long.
95 *
96 */
97 int col_push_str_property(struct collection_item *stack,
98 const char *property,
99 const char *string,
100 int length);
101 /**
102 * @brief Push binary value to the stack.
103 *
104 * @param[in] stack Stack object.
105 * @param[in] property Name of the property.<br>
106 * Name should consist of the ASCII characters
107 * with codes non less than space.
108 * Exclamation mark character is
109 * a special character and can't be used
110 * in name of collection or property.<br>
111 * Maximum allowed length is defined at compile time.
112 * The default value is 64k.
113 * @param[in] binary_data Data to add.
114 * @param[in] length Length of the binary data.
115 *
116 * @return 0 - Property was pushed successfully.
117 * @return ENOMEM - No memory.
118 * @return EINVAL - Invalid argument.
119 * @return EMSGSIZE - Property name is too long.
120 *
121 */
122 int col_push_binary_property(struct collection_item *stack,
123 const char *property,
124 void *binary_data,
125 int length);
126 /**
127 * @brief Push integer value to the stack.
128 *
129 * @param[in] stack Stack object.
130 * @param[in] property Name of the property.<br>
131 * Name should consist of the ASCII characters
132 * with codes non less than space.
133 * Exclamation mark character is
134 * a special character and can't be used
135 * in name of collection or property.<br>
136 * Maximum allowed length is defined at compile time.
137 * The default value is 64k.
138 * @param[in] number Value to add.
139 *
140 * @return 0 - Property was pushed successfully.
141 * @return ENOMEM - No memory.
142 * @return EINVAL - Invalid argument.
143 * @return EMSGSIZE - Property name is too long.
144 *
145 */
146 int col_push_int_property(struct collection_item *stack,
147 const char *property,
148 int32_t number);
149 /**
150 * @brief Push unsigned value to the stack.
151 *
152 * @param[in] stack Stack object.
153 * @param[in] property Name of the property.<br>
154 * Name should consist of the ASCII characters
155 * with codes non less than space.
156 * Exclamation mark character is
157 * a special character and can't be used
158 * in name of collection or property.<br>
159 * Maximum allowed length is defined at compile time.
160 * The default value is 64k.
161 * @param[in] number Value to add.
162 *
163 * @return 0 - Property was pushed successfully.
164 * @return ENOMEM - No memory.
165 * @return EINVAL - Invalid argument.
166 * @return EMSGSIZE - Property name is too long.
167 *
168 */
169 int col_push_unsigned_property(struct collection_item *stack,
170 const char *property,
171 uint32_t number);
172 /**
173 * @brief Push long integer value to the stack.
174 *
175 * @param[in] stack Stack object.
176 * @param[in] property Name of the property.<br>
177 * Name should consist of the ASCII characters
178 * with codes non less than space.
179 * Exclamation mark character is
180 * a special character and can't be used
181 * in name of collection or property.<br>
182 * Maximum allowed length is defined at compile time.
183 * The default value is 64k.
184 * @param[in] number Value to add.
185 *
186 * @return 0 - Property was pushed successfully.
187 * @return ENOMEM - No memory.
188 * @return EINVAL - Invalid argument.
189 * @return EMSGSIZE - Property name is too long.
190 *
191 */
192 int col_push_long_property(struct collection_item *stack,
193 const char *property,
194 int64_t number);
195 /**
196 * @brief Push unsigned long value to the stack.
197 *
198 * @param[in] stack Stack object.
199 * @param[in] property Name of the property.<br>
200 * Name should consist of the ASCII characters
201 * with codes non less than space.
202 * Exclamation mark character is
203 * a special character and can't be used
204 * in name of collection or property.<br>
205 * Maximum allowed length is defined at compile time.
206 * The default value is 64k.
207 * @param[in] number Value to add.
208 *
209 * @return 0 - Property was pushed successfully.
210 * @return ENOMEM - No memory.
211 * @return EINVAL - Invalid argument.
212 * @return EMSGSIZE - Property name is too long.
213 *
214 */
215 int col_push_ulong_property(struct collection_item *stack,
216 const char *property,
217 uint64_t number);
218 /**
219 * @brief Push floating point value to the stack.
220 *
221 * @param[in] stack Stack object.
222 * @param[in] property Name of the property.<br>
223 * Name should consist of the ASCII characters
224 * with codes non less than space.
225 * Exclamation mark character is
226 * a special character and can't be used
227 * in name of collection or property.<br>
228 * Maximum allowed length is defined at compile time.
229 * The default value is 64k.
230 * @param[in] number Value to add.
231 *
232 * @return 0 - Property was pushed successfully.
233 * @return ENOMEM - No memory.
234 * @return EINVAL - Invalid argument.
235 * @return EMSGSIZE - Property name is too long.
236 *
237 */
238 int col_push_double_property(struct collection_item *stack,
239 const char *property,
240 double number);
241 /**
242 * @brief Push Boolean value to the stack.
243 *
244 * @param[in] stack Stack object.
245 * @param[in] property Name of the property.<br>
246 * Name should consist of the ASCII characters
247 * with codes non less than space.
248 * Exclamation mark character is
249 * a special character and can't be used
250 * in name of collection or property.<br>
251 * Maximum allowed length is defined at compile time.
252 * The default value is 64k.
253 * @param[in] logical Value to add.
254 *
255 * @return 0 - Property was pushed successfully.
256 * @return ENOMEM - No memory.
257 * @return EINVAL - Invalid argument.
258 * @return EMSGSIZE - Property name is too long.
259 *
260 */
261 int col_push_bool_property(struct collection_item *stack,
262 const char *property,
263 unsigned char logical);
264
265 /**
266 * @brief Push value of any type to the stack.
267 *
268 * @param[in] stack Stack object.
269 * @param[in] property Name of the property.<br>
270 * Name should consist of the ASCII characters
271 * with codes non less than space.
272 * Exclamation mark character is
273 * a special character and can't be used
274 * in name of collection or property.<br>
275 * Maximum allowed length is defined at compile time.
276 * The default value is 64k.
277 * @param[in] type Type to use.
278 * @param[in] data Data to add.
279 * @param[in] length Length of the data.
280 *
281 * @return 0 - Property was pushed successfully.
282 * @return ENOMEM - No memory.
283 * @return EINVAL - Invalid characters in the property name.
284 * Value argument is invalid in some way.
285 * @return EMSGSIZE - Property name is too long.
286 *
287 */
288 int col_push_any_property(struct collection_item *stack,
289 const char *property,
290 int type,
291 void *data,
292 int length);
293
294 /**
295 * @brief Push item into the stack.
296 *
297 * @param[in] stack Stack object.
298 * @param[in] item Item to push.
299 *
300 * @return 0 - Item was pushed successfully.
301 * @return ENOMEM - No memory.
302 * @return EINVAL - Invalid argument.
303 */
304
305 int col_push_item(struct collection_item *stack,
306 struct collection_item *item);
307
308
309 /**
310 * @brief Pop item from the stack.
311 *
312 * @param[in] stack Stack object.
313 * @param[out] item Variable receives the value
314 * of the retrieved item.
315 * Will be set to NULL if there are
316 * no more items in the stack.
317 *
318 * @return 0 - No internal issues detected.
319 * @return ENOMEM - No memory.
320 * @return EINVAL - Invalid argument.
321 */
322 int col_pop_item(struct collection_item *stack,
323 struct collection_item **item);
324
325 /**
326 * @}
327 */
328 #endif