ucx/string.h

changeset 21
d599fefc7620
parent 20
db7d9860dbbd
child 31
91ac86557290
equal deleted inserted replaced
19:cdd7a3173249 21:d599fefc7620
1 /*
2 * File: sstring.h
3 * Author: olaf
4 *
5 * Created on 17. Juni 2010, 13:26
6 */
7
8 #ifndef _SSTRING_H
9 #define _SSTRING_H
10
11 #define S(s) { s, sizeof(s)-1 }
12 #define ST(s) sstrn(s, sizeof(s)-1)
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 typedef struct sstring {
19 char *ptr;
20 size_t length;
21 } sstr_t;
22
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);
29
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);
37
38
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, ...);
47
48
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, ...);
57
58
59 /*
60 *
61 */
62 sstr_t sstrsubs (sstr_t s, size_t start);
63
64 /*
65 *
66 */
67 sstr_t sstrsubsl (sstr_t s, size_t start, size_t end);
68
69
70 int sstrcmp(sstr_t s1, sstr_t s2);
71
72 sstr_t sstrdub(sstr_t s);
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif /* _SSTRING_H */

mercurial