ucx/string.h

Thu, 05 Jan 2012 14:53:54 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 05 Jan 2012 14:53:54 +0100
changeset 20
db7d9860dbbd
child 31
91ac86557290
permissions
-rw-r--r--

added some map functions

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

mercurial