ucx/string.h

changeset 146
aa376dba1ba8
parent 125
fca8efb122de
child 148
c27c2425c0b1
equal deleted inserted replaced
145:e974640ec4e0 146:aa376dba1ba8
52 #include "allocator.h" 52 #include "allocator.h"
53 #include <stddef.h> 53 #include <stddef.h>
54 54
55 /** Shortcut for a <code>sstr_t struct</code> literal. */ 55 /** Shortcut for a <code>sstr_t struct</code> literal. */
56 #define ST(s) { (char*)s, sizeof(s)-1 } 56 #define ST(s) { (char*)s, sizeof(s)-1 }
57
57 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */ 58 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */
58 #define S(s) sstrn((char*)s, sizeof(s)-1) 59 #define S(s) sstrn((char*)s, sizeof(s)-1)
59 60
60 #ifdef __cplusplus 61 #ifdef __cplusplus
61 extern "C" { 62 extern "C" {
336 * @param string the string that shall be trimmed 337 * @param string the string that shall be trimmed
337 * @return a new sstr_t containing the trimmed string 338 * @return a new sstr_t containing the trimmed string
338 */ 339 */
339 sstr_t sstrtrim(sstr_t string); 340 sstr_t sstrtrim(sstr_t string);
340 341
342 /**
343 * Checks, if a string has a specific prefix.
344 * @param string the string to check
345 * @param prefix the prefix the string should have
346 * @return 1, if and only if the string has the specified prefix, 0 otherwise
347 */
348 int sstrprefix(sstr_t string, sstr_t prefix);
349
350 /**
351 * Checks, if a string has a specific suffix.
352 * @param string the string to check
353 * @param suffix the suffix the string should have
354 * @return 1, if and only if the string has the specified suffix, 0 otherwise
355 */
356 int sstrsuffix(sstr_t string, sstr_t suffix);
357
341 #ifdef __cplusplus 358 #ifdef __cplusplus
342 } 359 }
343 #endif 360 #endif
344 361
345 #endif /* UCX_STRING_H */ 362 #endif /* UCX_STRING_H */

mercurial