1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2015 Olaf Wintermann. All rights reserved. |
4 * Copyright 2016 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
135 * @return the concatenated string |
135 * @return the concatenated string |
136 */ |
136 */ |
137 sstr_t sstrcat(size_t count, sstr_t s1, sstr_t s2, ...); |
137 sstr_t sstrcat(size_t count, sstr_t s1, sstr_t s2, ...); |
138 |
138 |
139 /** |
139 /** |
140 * Concatenates two or more strings using an UcxAllocator. |
140 * Concatenates two or more strings using a UcxAllocator. |
141 * |
141 * |
142 * See sstrcat() for details. |
142 * See sstrcat() for details. |
143 * |
143 * |
144 * @param a the allocator to use |
144 * @param a the allocator to use |
145 * @param count the total number of strings to concatenate |
145 * @param count the total number of strings to concatenate |
210 * @return a substring starting at the last location of <code>chr</code> |
210 * @return a substring starting at the last location of <code>chr</code> |
211 * |
211 * |
212 * @see sstrsubs() |
212 * @see sstrsubs() |
213 */ |
213 */ |
214 sstr_t sstrrchr(sstr_t string, int chr); |
214 sstr_t sstrrchr(sstr_t string, int chr); |
|
215 |
|
216 /** |
|
217 * Returns a substring starting at the location of the first occurrence of the |
|
218 * specified string. |
|
219 * |
|
220 * If the string does not contain the other string, an empty string is returned. |
|
221 * |
|
222 * If <code>match</code> is an empty string, the complete <code>string</code> is |
|
223 * returned. |
|
224 * |
|
225 * @param string the string to be scanned |
|
226 * @param match string containing the sequence of characters to match |
|
227 * @return a substring starting at the first occurrence of |
|
228 * <code>match</code>, or an empty string, if the sequence is not |
|
229 * present in <code>string</code> |
|
230 */ |
|
231 sstr_t sstrstr(sstr_t string, sstr_t match); |
215 |
232 |
216 /** |
233 /** |
217 * Splits a string into parts by using a delimiter string. |
234 * Splits a string into parts by using a delimiter string. |
218 * |
235 * |
219 * This function will return <code>NULL</code>, if one of the following happens: |
236 * This function will return <code>NULL</code>, if one of the following happens: |
258 * @see sstrsplit_a() |
275 * @see sstrsplit_a() |
259 */ |
276 */ |
260 sstr_t* sstrsplit(sstr_t string, sstr_t delim, ssize_t *count); |
277 sstr_t* sstrsplit(sstr_t string, sstr_t delim, ssize_t *count); |
261 |
278 |
262 /** |
279 /** |
263 * Performing sstrsplit() using an UcxAllocator. |
280 * Performing sstrsplit() using a UcxAllocator. |
264 * |
281 * |
265 * <i>Read the description of sstrsplit() for details.</i> |
282 * <i>Read the description of sstrsplit() for details.</i> |
266 * |
283 * |
267 * The memory for the sstr_t.ptr pointers of the array items and the memory for |
284 * The memory for the sstr_t.ptr pointers of the array items and the memory for |
268 * the sstr_t array itself are allocated by using the UcxAllocator.malloc() |
285 * the sstr_t array itself are allocated by using the UcxAllocator.malloc() |
329 * @see sstrdup_a() |
346 * @see sstrdup_a() |
330 */ |
347 */ |
331 sstr_t sstrdup(sstr_t string); |
348 sstr_t sstrdup(sstr_t string); |
332 |
349 |
333 /** |
350 /** |
334 * Creates a duplicate of the specified string using an UcxAllocator. |
351 * Creates a duplicate of the specified string using a UcxAllocator. |
335 * |
352 * |
336 * The new sstr_t will contain a copy allocated by the allocators |
353 * The new sstr_t will contain a copy allocated by the allocators |
337 * ucx_allocator_malloc function. So it is implementation depended, whether the |
354 * ucx_allocator_malloc function. So it is implementation depended, whether the |
338 * returned sstr_t.ptr pointer must be passed to the allocators |
355 * returned sstr_t.ptr pointer must be passed to the allocators |
339 * ucx_allocator_free function manually. |
356 * ucx_allocator_free function manually. |
340 * |
357 * |
341 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>- |
358 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>- |
342 * terminated. |
359 * terminated. |
343 * |
360 * |
344 * @param allocator a valid instance of an UcxAllocator |
361 * @param allocator a valid instance of a UcxAllocator |
345 * @param string the string to duplicate |
362 * @param string the string to duplicate |
346 * @return a duplicate of the string |
363 * @return a duplicate of the string |
347 * @see sstrdup() |
364 * @see sstrdup() |
348 */ |
365 */ |
349 sstr_t sstrdup_a(UcxAllocator *allocator, sstr_t string); |
366 sstr_t sstrdup_a(UcxAllocator *allocator, sstr_t string); |