Fri, 25 May 2012 17:39:27 +0200
added map iterator
1 /*
2 * File: sstring.h
3 * Author: olaf
4 *
5 * Created on 17. Juni 2010, 13:26
6 */
8 #ifndef _SSTRING_H
9 #define _SSTRING_H
11 #define S(s) { s, sizeof(s)-1 }
12 #define ST(s) sstrn(s, sizeof(s)-1)
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
18 typedef struct sstring {
19 char *ptr;
20 size_t length;
21 } sstr_t;
23 /*
24 * creates a new sstr_t from a null terminated string
25 *
26 * s null terminated string
27 */
28 sstr_t sstr (char *s);
30 /*
31 * creates a new sstr_t from a string and length
32 *
33 * s string
34 * n length of string
35 */
36 sstr_t sstrn (char *s, size_t n);
39 /*
40 * gets the length of n sstr_t strings
41 *
42 * n number of strings
43 * s string
44 * ... strings
45 */
46 size_t sstrnlen (size_t n, sstr_t s, ...);
49 /*
50 * concatenates n strings
51 *
52 * n number of strings
53 * s new string with enough memory allocated
54 * ... strings
55 */
56 sstr_t sstrncat (size_t n, sstr_t s, sstr_t c1, ...);
59 /*
60 *
61 */
62 sstr_t sstrsubs (sstr_t s, size_t start);
64 /*
65 *
66 */
67 sstr_t sstrsubsl (sstr_t s, size_t start, size_t end);
70 int sstrcmp(sstr_t s1, sstr_t s2);
72 sstr_t sstrdup(sstr_t s);
74 #ifdef __cplusplus
75 }
76 #endif
78 #endif /* _SSTRING_H */