ucx/string.h

changeset 160
302dddaf741d
parent 149
3bf87676d42d
child 173
31a8682fffb7
equal deleted inserted replaced
159:a22b6da0587e 160:302dddaf741d
225 * <li>the string equals the delimeter</li> 225 * <li>the string equals the delimeter</li>
226 * <li>memory allocation fails</li> 226 * <li>memory allocation fails</li>
227 * </ul> 227 * </ul>
228 * 228 *
229 * The integer referenced by <code>count</code> is used as input and determines 229 * The integer referenced by <code>count</code> is used as input and determines
230 * the maximum size of the resulting list, i.e. the maximum count of splits to 230 * the maximum size of the resulting array, i.e. the maximum count of splits to
231 * perform + 1. 231 * perform + 1.
232 * 232 *
233 * The integer referenced by <code>count</code> is also used as output and is 233 * The integer referenced by <code>count</code> is also used as output and is
234 * set to 234 * set to
235 * <ul> 235 * <ul>
236 * <li>-2, on memory allocation errors</li> 236 * <li>-2, on memory allocation errors</li>
237 * <li>-1, if either the string or the delimiter is an empty string</li> 237 * <li>-1, if either the string or the delimiter is an empty string</li>
238 * <li>0, if the string equals the delimiter</li> 238 * <li>0, if the string equals the delimiter</li>
239 * <li>1, if the string does not contain the delimiter</li> 239 * <li>1, if the string does not contain the delimiter</li>
240 * <li>the count of list items, otherwise</li> 240 * <li>the count of array items, otherwise</li>
241 * </ul> 241 * </ul>
242 * 242 *
243 * If the string starts with the delimiter, the first item of the resulting 243 * If the string starts with the delimiter, the first item of the resulting
244 * list will be an empty string. 244 * array will be an empty string.
245 * 245 *
246 * If the string ends with the delimiter and the maximum list size is not 246 * If the string ends with the delimiter and the maximum list size is not
247 * exceeded, the last list item will be an empty string. 247 * exceeded, the last array item will be an empty string.
248 * 248 *
249 * <b>Attention:</b> All list items <b>AND</b> all sstr_t.ptr of the list 249 * <b>Attention:</b> The array pointer <b>AND</b> all sstr_t.ptr of the array
250 * items must be manually passed to <code>free()</code>. Use sstrsplit_a() with 250 * items must be manually passed to <code>free()</code>. Use sstrsplit_a() with
251 * an allocator to managed memory, to avoid this. 251 * an allocator to managed memory, to avoid this.
252 * 252 *
253 * @param string the string to split 253 * @param string the string to split
254 * @param delim the delimiter string 254 * @param delim the delimiter string
255 * @param count IN: the maximum size of the resulting list (0 for an 255 * @param count IN: the maximum size of the resulting array (0 = no limit),
256 * unbounded list), OUT: the actual size of the list 256 * OUT: the actual size of the array
257 * @return a list of the split strings as sstr_t array or 257 * @return a sstr_t array containing the split strings or
258 * <code>NULL</code> on error 258 * <code>NULL</code> on error
259 * 259 *
260 * @see sstrsplit_a() 260 * @see sstrsplit_a()
261 */ 261 */
262 sstr_t* sstrsplit(sstr_t string, sstr_t delim, size_t *count); 262 sstr_t* sstrsplit(sstr_t string, sstr_t delim, size_t *count);
264 /** 264 /**
265 * Performing sstrsplit() using an UcxAllocator. 265 * Performing sstrsplit() using an UcxAllocator.
266 * 266 *
267 * <i>Read the description of sstrsplit() for details.</i> 267 * <i>Read the description of sstrsplit() for details.</i>
268 * 268 *
269 * The memory for the sstr_t.ptr pointers of the list items and the memory for 269 * The memory for the sstr_t.ptr pointers of the array items and the memory for
270 * the sstr_t array itself are allocated by using the UcxAllocator.malloc() 270 * the sstr_t array itself are allocated by using the UcxAllocator.malloc()
271 * function. 271 * function.
272 * 272 *
273 * <b>Note:</b> the allocator is not used for memory that is freed within the 273 * <b>Note:</b> the allocator is not used for memory that is freed within the
274 * same call of this function (locally scoped variables). 274 * same call of this function (locally scoped variables).
275 * 275 *
276 * @param allocator the UcxAllocator used for allocating memory 276 * @param allocator the UcxAllocator used for allocating memory
277 * @param string the string to split 277 * @param string the string to split
278 * @param delim the delimiter string 278 * @param delim the delimiter string
279 * @param count IN: the maximum size of the resulting list (0 for an 279 * @param count IN: the maximum size of the resulting array (0 = no limit),
280 * unbounded list), OUT: the actual size of the list 280 * OUT: the actual size of the array
281 * @return a list of the split strings as sstr_t array or 281 * @return a sstr_t array containing the split strings or
282 * <code>NULL</code> on error 282 * <code>NULL</code> on error
283 * 283 *
284 * @see sstrsplit() 284 * @see sstrsplit()
285 */ 285 */
286 sstr_t* sstrsplit_a(UcxAllocator *allocator, sstr_t string, sstr_t delim, 286 sstr_t* sstrsplit_a(UcxAllocator *allocator, sstr_t string, sstr_t delim,

mercurial