ucx/ucx/string.h

Sun, 12 May 2019 13:49:36 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 12 May 2019 13:49:36 +0200
changeset 599
508cbc4d30ea
parent 505
481802342fdf
permissions
-rw-r--r--

fix res_link initialization

335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 * Bounded string implementation.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 * The UCX strings (<code>sstr_t</code>) provide an alternative to C strings.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 * The main difference to C strings is, that <code>sstr_t</code> does <b>not
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 * need to be <code>NULL</code>-terminated</b>. Instead the length is stored
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 * within the structure.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 * When using <code>sstr_t</code>, developers must be full aware of what type
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 * of string (<code>NULL</code>-terminated) or not) they are using, when
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 * accessing the <code>char* ptr</code> directly.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 * The UCX string module provides some common string functions, known from
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 * standard libc, working with <code>sstr_t</code>.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 * @file string.h
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 * @author Mike Becker
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 * @author Olaf Wintermann
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 #ifndef UCX_STRING_H
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 #define UCX_STRING_H
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 #include "ucx.h"
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 #include "allocator.h"
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 #include <stddef.h>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
55 /*
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
56 * Use this macro to disable the shortcuts if you experience macro collision.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
57 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
58 #ifndef UCX_NO_SSTR_SHORTCUTS
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
59 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
60 * Shortcut for a <code>sstr_t struct</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
61 * or <code>scstr_t struct</code> literal.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
62 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
63 #define ST(s) { s, sizeof(s)-1 }
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 /** Shortcut for the conversion of a C string to a <code>sstr_t</code>. */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
66 #define S(s) sstrn(s, sizeof(s)-1)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
67
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
68 /** Shortcut for the conversion of a C string to a <code>scstr_t</code>. */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
69 #define SC(s) scstrn(s, sizeof(s)-1)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
70 #endif /* UCX_NO_SSTR_SHORTCUTS */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
71
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
72 /*
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
73 * Use this macro to disable the format macros.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
74 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
75 #ifndef UCX_NO_SSTR_FORMAT_MACROS
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
76 /** Expands a sstr_t or scstr_t to printf arguments. */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
77 #define SFMT(s) (int) (s).length, (s).ptr
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
78
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
79 /** Format specifier for a sstr_t or scstr_t. */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
80 #define PRIsstr ".*s"
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
81 #endif /* UCX_NO_SSTR_FORMAT_MACROS */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
82
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
83 #ifdef __cplusplus
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
84 extern "C" {
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
85 #endif
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
86 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
87 * The UCX string structure.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
88 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
89 typedef struct {
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
90 /** A pointer to the string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
91 * (<b>not necessarily <code>NULL</code>-terminated</b>) */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
92 char *ptr;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
93 /** The length of the string */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
94 size_t length;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
95 } sstr_t;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
96
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
97 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
98 * The UCX string structure for immutable (constant) strings.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
99 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
100 typedef struct {
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
101 /** A constant pointer to the immutable string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
102 * (<b>not necessarily <code>NULL</code>-terminated</b>) */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
103 const char *ptr;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
104 /** The length of the string */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
105 size_t length;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
106 } scstr_t;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
107
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
108 #ifdef __cplusplus
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
109 }
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
110 #endif
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
111
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
112
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
113 #ifdef __cplusplus
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
114 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
115 * One of two type adjustment functions that return a scstr_t.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
116 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
117 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
118 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
119 * <b>Do not use this function manually.</b>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
120 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
121 * @param str some sstr_t
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
122 * @return an immutable (scstr_t) version of the provided string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
123 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
124 inline scstr_t s2scstr(sstr_t s) {
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
125 scstr_t c;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
126 c.ptr = s.ptr;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
127 c.length = s.length;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
128 return c;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
129 }
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
130
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
131 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
132 * One of two type adjustment functions that return a scstr_t.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
133 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
134 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
135 * This variant is used, when the string is already immutable and no operation
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
136 * needs to be performed.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
137 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
138 * <b>Do not use this function manually.</b>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
139 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
140 * @param str some scstr_t
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
141 * @return the argument itself
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
142 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
143 inline scstr_t s2scstr(scstr_t str) {
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
144 return str;
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
145 }
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
146
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
147 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
148 * Converts a UCX string to an immutable UCX string (scstr_t).
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
149 * @param str some UCX string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
150 * @return the an immutable version of the provided string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
151 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
152 #define SCSTR(s) s2scstr(s)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
153 #else
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
154
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
155 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
156 * One of two type adjustment functions that return a scstr_t.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
157 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
158 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
159 * This variant is used, when the string is already immutable and no operation
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
160 * needs to be performed.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
161 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
162 * <b>Do not use this function manually.</b>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
163 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
164 * @param str some scstr_t
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
165 * @return the argument itself
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
166 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
167 scstr_t ucx_sc2sc(scstr_t str);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
168
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
169 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
170 * One of two type adjustment functions that return a scstr_t.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
171 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
172 * Used <b>internally</b> to convert a UCX string to an immutable UCX string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
173 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
174 * <b>Do not use this function manually.</b>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
175 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
176 * @param str some sstr_t
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
177 * @return an immutable (scstr_t) version of the provided string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
178 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
179 scstr_t ucx_ss2sc(sstr_t str);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
180
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
181 #if __STDC_VERSION__ >= 201112L
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
182 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
183 * Converts a UCX string to an immutable UCX string (scstr_t).
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
184 * @param str some UCX string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
185 * @return the an immutable version of the provided string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
186 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
187 #define SCSTR(str) _Generic(str, sstr_t: ucx_ss2sc, scstr_t: ucx_sc2sc)(str)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
188
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
189 #elif defined(__GNUC__) || defined(__clang__)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
190
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
191 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
192 * Converts a UCX string to an immutable UCX string (scstr_t).
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
193 * @param str some UCX string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
194 * @return the an immutable version of the provided string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
195 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
196 #define SCSTR(str) __builtin_choose_expr( \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
197 __builtin_types_compatible_p(typeof(str), sstr_t), \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
198 ucx_ss2sc, \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
199 ucx_sc2sc)(str)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
200
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
201 #elif defined(__sun)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
202
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
203 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
204 * Converts a UCX string to an immutable UCX string (scstr_t).
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
205 * @param str some UCX string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
206 * @return the an immutable version of the provided string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
207 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
208 #define SCSTR(str) ({typeof(str) ucx_tmp_var_str = str; \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
209 scstr_t ucx_tmp_var_c; \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
210 ucx_tmp_var_c.ptr = ucx_tmp_var_str.ptr;\
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
211 ucx_tmp_var_c.length = ucx_tmp_var_str.length;\
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
212 ucx_tmp_var_c; })
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
213 #else /* no generics and no builtins */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
214
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
215 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
216 * Converts a UCX string to an immutable UCX string (scstr_t).
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
217 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
218 * This <b>internal</b> function (ab)uses the C standard an expects one single
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
219 * argument which is then implicitly converted to scstr_t without a warning.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
220 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
221 * <b>Do not use this function manually.</b>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
222 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
223 * @return the an immutable version of the provided string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
224 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
225 scstr_t ucx_ss2c_s();
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
226
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
227 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
228 * Converts a UCX string to an immutable UCX string (scstr_t).
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
229 * @param str some UCX string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
230 * @return the an immutable version of the provided string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
231 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
232 #define SCSTR(str) ucx_ss2c_s(str)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
233 #endif /* C11 feature test */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
234
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
235 #endif /* C++ */
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 #ifdef __cplusplus
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 extern "C" {
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 #endif
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 * Creates a new sstr_t based on a C string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 * The length is implicitly inferred by using a call to <code>strlen()</code>.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 * <b>Note:</b> the sstr_t will hold a <i>reference</i> to the C string. If you
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 * do want a copy, use sstrdup() on the return value of this function.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 *
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
250 * If you need to wrap a constant string, use scstr().
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
251 *
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 * @param cstring the C string to wrap
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 * @return a new sstr_t containing the C string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 * @see sstrn()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 sstr_t sstr(char *cstring);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 * Creates a new sstr_t of the specified length based on a C string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 * <b>Note:</b> the sstr_t will hold a <i>reference</i> to the C string. If you
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 * do want a copy, use sstrdup() on the return value of this function.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 *
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
265 * If you need to wrap a constant string, use scstrn().
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
266 *
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 * @param cstring the C string to wrap
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 * @param length the length of the string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 * @return a new sstr_t containing the C string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 * @see sstr()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 * @see S()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 sstr_t sstrn(char *cstring, size_t length);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
276 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
277 * Creates a new scstr_t based on a constant C string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
278 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
279 * The length is implicitly inferred by using a call to <code>strlen()</code>.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
280 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
281 * <b>Note:</b> the scstr_t will hold a <i>reference</i> to the C string. If you
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
282 * do want a copy, use scstrdup() on the return value of this function.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
283 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
284 * @param cstring the C string to wrap
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
285 * @return a new scstr_t containing the C string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
286 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
287 * @see scstrn()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
288 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
289 scstr_t scstr(const char *cstring);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
290
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
291
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
292 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
293 * Creates a new scstr_t of the specified length based on a constant C string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
294 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
295 * <b>Note:</b> the scstr_t will hold a <i>reference</i> to the C string. If you
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
296 * do want a copy, use scstrdup() on the return value of this function.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
297 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
298 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
299 * @param cstring the C string to wrap
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
300 * @param length the length of the string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
301 * @return a new scstr_t containing the C string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
302 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
303 * @see scstr()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
304 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
305 scstr_t scstrn(const char *cstring, size_t length);
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 * Returns the cumulated length of all specified strings.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 * <b>Attention:</b> if the count argument does not match the count of the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 * specified strings, the behavior is undefined.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 * @param count the total number of specified strings (so at least 1)
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
314 * @param ... all strings
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 * @return the cumulated length of all strings
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
317 size_t scstrnlen(size_t count, ...);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
318
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
319 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
320 * Alias for scstrnlen() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
321 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
322 * @param count the total number of specified strings (so at least 1)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
323 * @param ... all strings
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
324 * @return the cumulated length of all strings
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
325 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
326 #define sstrnlen(count, ...) scstrnlen(count, __VA_ARGS__)
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 * Concatenates two or more strings.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 * The resulting string will be allocated by standard <code>malloc()</code>.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 * So developers <b>MUST</b> pass the sstr_t.ptr to <code>free()</code>.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 * terminated.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 * @param count the total number of strings to concatenate
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 * @param s1 first string
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
339 * @param ... all remaining strings
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
340 * @return the concatenated string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
341 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
342 sstr_t scstrcat(size_t count, scstr_t s1, ...);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
343
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
344 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
345 * Alias for scstrcat() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
346 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
347 * @param count the total number of strings to concatenate
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
348 * @param s1 first string
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 * @param ... all remaining strings
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 * @return the concatenated string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
352 #define sstrcat(count, s1, ...) scstrcat(count, SCSTR(s1), __VA_ARGS__)
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 * Concatenates two or more strings using a UcxAllocator.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 *
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
357 * See scstrcat() for details.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
358 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
359 * @param a the allocator to use
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
360 * @param count the total number of strings to concatenate
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
361 * @param s1 first string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
362 * @param ... all remaining strings
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
363 * @return the concatenated string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
364 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
365 sstr_t scstrcat_a(UcxAllocator *a, size_t count, scstr_t s1, ...);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
366
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
367 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
368 * Alias for scstrcat_a() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
369 *
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 * See sstrcat() for details.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 * @param a the allocator to use
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 * @param count the total number of strings to concatenate
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 * @param s1 first string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 * @param ... all remaining strings
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 * @return the concatenated string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
378 #define sstrcat_a(a, count, s1, ...) \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
379 scstrcat_a(a, count, SCSTR(s1), __VA_ARGS__)
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 * Returns a substring starting at the specified location.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 * <b>Attention:</b> the new string references the same memory area as the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 * input string and will <b>NOT</b> be <code>NULL</code>-terminated.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 * Use sstrdup() to get a copy.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 * @param string input string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 * @param start start location of the substring
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 * @return a substring of <code>string</code> starting at <code>start</code>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 * @see sstrsubsl()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393 * @see sstrchr()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 sstr_t sstrsubs(sstr_t string, size_t start);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 * Returns a substring with a maximum length starting at the specified location.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 * <b>Attention:</b> the new string references the same memory area as the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 * input string and will <b>NOT</b> be <code>NULL</code>-terminated.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 * Use sstrdup() to get a copy.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 * @param string input string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 * @param start start location of the substring
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 * @param length the maximum length of the substring
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 * @return a substring of <code>string</code> starting at <code>start</code>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 * with a maximum length of <code>length</code>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 * @see sstrsubs()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 * @see sstrchr()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 sstr_t sstrsubsl(sstr_t string, size_t start, size_t length);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415 /**
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
416 * Returns a substring of an immutable string starting at the specified
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
417 * location.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
418 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
419 * <b>Attention:</b> the new string references the same memory area as the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
420 * input string and will <b>NOT</b> be <code>NULL</code>-terminated.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
421 * Use scstrdup() to get a copy.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
422 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
423 * @param string input string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
424 * @param start start location of the substring
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
425 * @return a substring of <code>string</code> starting at <code>start</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
426 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
427 * @see scstrsubsl()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
428 * @see scstrchr()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
429 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
430 scstr_t scstrsubs(scstr_t string, size_t start);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
431
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
432 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
433 * Returns a substring of an immutable string with a maximum length starting
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
434 * at the specified location.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
435 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
436 * <b>Attention:</b> the new string references the same memory area as the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
437 * input string and will <b>NOT</b> be <code>NULL</code>-terminated.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
438 * Use scstrdup() to get a copy.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
439 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
440 * @param string input string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
441 * @param start start location of the substring
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
442 * @param length the maximum length of the substring
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
443 * @return a substring of <code>string</code> starting at <code>start</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
444 * with a maximum length of <code>length</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
445 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
446 * @see scstrsubs()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
447 * @see scstrchr()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
448 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
449 scstr_t scstrsubsl(scstr_t string, size_t start, size_t length);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
450
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
451 /**
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 * Returns a substring starting at the location of the first occurrence of the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 * specified character.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 * If the string does not contain the character, an empty string is returned.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 * @param string the string where to locate the character
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 * @param chr the character to locate
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 * @return a substring starting at the first location of <code>chr</code>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 * @see sstrsubs()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 sstr_t sstrchr(sstr_t string, int chr);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 * Returns a substring starting at the location of the last occurrence of the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 * specified character.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 * If the string does not contain the character, an empty string is returned.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 * @param string the string where to locate the character
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 * @param chr the character to locate
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 * @return a substring starting at the last location of <code>chr</code>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 * @see sstrsubs()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 sstr_t sstrrchr(sstr_t string, int chr);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 /**
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
480 * Returns an immutable substring starting at the location of the first
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
481 * occurrence of the specified character.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
482 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
483 * If the string does not contain the character, an empty string is returned.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
484 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
485 * @param string the string where to locate the character
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
486 * @param chr the character to locate
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
487 * @return a substring starting at the first location of <code>chr</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
488 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
489 * @see scstrsubs()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
490 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
491 scstr_t scstrchr(scstr_t string, int chr);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
492
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
493 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
494 * Returns an immutable substring starting at the location of the last
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
495 * occurrence of the specified character.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
496 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
497 * If the string does not contain the character, an empty string is returned.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
498 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
499 * @param string the string where to locate the character
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
500 * @param chr the character to locate
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
501 * @return a substring starting at the last location of <code>chr</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
502 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
503 * @see scstrsubs()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
504 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
505 scstr_t scstrrchr(scstr_t string, int chr);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
506
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
507 /**
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 * Returns a substring starting at the location of the first occurrence of the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 * specified string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 * If the string does not contain the other string, an empty string is returned.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 * If <code>match</code> is an empty string, the complete <code>string</code> is
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514 * returned.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516 * @param string the string to be scanned
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 * @param match string containing the sequence of characters to match
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 * @return a substring starting at the first occurrence of
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
519 * <code>match</code>, or an empty string, if the sequence is not
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 * present in <code>string</code>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
522 sstr_t scstrsstr(sstr_t string, scstr_t match);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
523
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
524 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
525 * Alias for scstrsstr() which automatically converts the match string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
526 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
527 * @param string the string to be scanned
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
528 * @param match string containing the sequence of characters to match
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
529 * @return a substring starting at the first occurrence of
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
530 * <code>match</code>, or an empty string, if the sequence is not
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
531 * present in <code>string</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
532 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
533 #define sstrstr(string, match) scstrsstr(string, SCSTR(match))
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
534
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
535 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
536 * Returns an immutable substring starting at the location of the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
537 * first occurrence of the specified immutable string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
538 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
539 * If the string does not contain the other string, an empty string is returned.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
540 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
541 * If <code>match</code> is an empty string, the complete <code>string</code> is
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
542 * returned.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
543 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
544 * @param string the string to be scanned
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
545 * @param match string containing the sequence of characters to match
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
546 * @return a substring starting at the first occurrence of
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
547 * <code>match</code>, or an empty string, if the sequence is not
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
548 * present in <code>string</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
549 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
550 scstr_t scstrscstr(scstr_t string, scstr_t match);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
551
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
552 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
553 * Alias for scstrscstr() which automatically converts the match string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
554 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
555 * @param string the string to be scanned
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
556 * @param match string containing the sequence of characters to match
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
557 * @return a substring starting at the first occurrence of
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
558 * <code>match</code>, or an empty string, if the sequence is not
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
559 * present in <code>string</code>
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
560 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
561 #define sstrscstr(string, match) scstrscstr(string, SCSTR(match))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 * Splits a string into parts by using a delimiter string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 * This function will return <code>NULL</code>, if one of the following happens:
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 * <ul>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 * <li>the string length is zero</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 * <li>the delimeter length is zero</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 * <li>the string equals the delimeter</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 * <li>memory allocation fails</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 * </ul>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 * The integer referenced by <code>count</code> is used as input and determines
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 * the maximum size of the resulting array, i.e. the maximum count of splits to
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
576 * perform + 1.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578 * The integer referenced by <code>count</code> is also used as output and is
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 * set to
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580 * <ul>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 * <li>-2, on memory allocation errors</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582 * <li>-1, if either the string or the delimiter is an empty string</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 * <li>0, if the string equals the delimiter</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 * <li>1, if the string does not contain the delimiter</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 * <li>the count of array items, otherwise</li>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586 * </ul>
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
588 * If the string starts with the delimiter, the first item of the resulting
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 * array will be an empty string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 * If the string ends with the delimiter and the maximum list size is not
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
592 * exceeded, the last array item will be an empty string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593 * In case the list size would be exceeded, the last array item will be the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594 * remaining string after the last split, <i>including</i> the terminating
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
595 * delimiter.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
596 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597 * <b>Attention:</b> The array pointer <b>AND</b> all sstr_t.ptr of the array
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598 * items must be manually passed to <code>free()</code>. Use sstrsplit_a() with
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 * an allocator to managed memory, to avoid this.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
600 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 * @param string the string to split
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602 * @param delim the delimiter string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603 * @param count IN: the maximum size of the resulting array (0 = no limit),
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 * OUT: the actual size of the array
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605 * @return a sstr_t array containing the split strings or
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
606 * <code>NULL</code> on error
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
607 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
608 * @see scstrsplit_a()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
609 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
610 sstr_t* scstrsplit(scstr_t string, scstr_t delim, ssize_t *count);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
611
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
612 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
613 * Alias for scstrsplit() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
614 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
615 * @param string the string to split
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
616 * @param delim the delimiter string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
617 * @param count IN: the maximum size of the resulting array (0 = no limit),
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
618 * OUT: the actual size of the array
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
619 * @return a sstr_t array containing the split strings or
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
620 * <code>NULL</code> on error
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
621 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
622 * @see sstrsplit_a()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
623 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
624 #define sstrsplit(string, delim, count) \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
625 scstrsplit(SCSTR(string), SCSTR(delim), count)
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
626
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
627 /**
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
628 * Performing scstrsplit() using a UcxAllocator.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
629 *
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
630 * <i>Read the description of scstrsplit() for details.</i>
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
631 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
632 * The memory for the sstr_t.ptr pointers of the array items and the memory for
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
633 * the sstr_t array itself are allocated by using the UcxAllocator.malloc()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
634 * function.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
635 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636 * <b>Note:</b> the allocator is not used for memory that is freed within the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
637 * same call of this function (locally scoped variables).
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 * @param allocator the UcxAllocator used for allocating memory
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
640 * @param string the string to split
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
641 * @param delim the delimiter string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642 * @param count IN: the maximum size of the resulting array (0 = no limit),
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 * OUT: the actual size of the array
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
644 * @return a sstr_t array containing the split strings or
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
645 * <code>NULL</code> on error
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
646 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
647 * @see scstrsplit()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
648 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
649 sstr_t* scstrsplit_a(UcxAllocator *allocator, scstr_t string, scstr_t delim,
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
650 ssize_t *count);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
651
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
652 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
653 * Alias for scstrsplit_a() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
654 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
655 * @param allocator the UcxAllocator used for allocating memory
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
656 * @param string the string to split
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
657 * @param delim the delimiter string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
658 * @param count IN: the maximum size of the resulting array (0 = no limit),
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
659 * OUT: the actual size of the array
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
660 * @return a sstr_t array containing the split strings or
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
661 * <code>NULL</code> on error
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
662 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
663 * @see sstrsplit()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
664 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
665 #define sstrsplit_a(allocator, string, delim, count) \
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
666 scstrsplit_a(allocator, SCSTR(string), SCSTR(delim), count)
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
667
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
668 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
669 * Compares two UCX strings with standard <code>memcmp()</code>.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
670 *
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
671 * At first it compares the scstr_t.length attribute of the two strings. The
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
672 * <code>memcmp()</code> function is called, if and only if the lengths match.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
673 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
674 * @param s1 the first string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
675 * @param s2 the second string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
676 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
677 * length of s1 is greater than the length of s2 or the result of
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
678 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match)
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
679 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
680 int scstrcmp(scstr_t s1, scstr_t s2);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
681
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
682 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
683 * Alias for scstrcmp() which automatically converts its arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
684 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
685 * @param s1 the first string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
686 * @param s2 the second string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
687 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
688 * length of s1 is greater than the length of s2 or the result of
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
689 * <code>memcmp()</code> otherwise (i.e. 0 if the strings match)
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
690 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
691 #define sstrcmp(s1, s2) scstrcmp(SCSTR(s1), SCSTR(s2))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
692
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
693 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
694 * Compares two UCX strings ignoring the case.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
695 *
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
696 * At first it compares the scstr_t.length attribute of the two strings. If and
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
697 * only if the lengths match, both strings are compared char by char ignoring
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
698 * the case.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
699 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
700 * @param s1 the first string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
701 * @param s2 the second string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
702 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
703 * length of s1 is greater than the length of s2 or the result of the platform
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
704 * specific string comparison function ignoring the case.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
705 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
706 int scstrcasecmp(scstr_t s1, scstr_t s2);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
707
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
708 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
709 * Alias for scstrcasecmp() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
710 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
711 * @param s1 the first string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
712 * @param s2 the second string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
713 * @return -1, if the length of s1 is less than the length of s2 or 1, if the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
714 * length of s1 is greater than the length of s2 or the result of the platform
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
715 * specific string comparison function ignoring the case.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
716 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
717 #define sstrcasecmp(s1, s2) scstrcasecmp(SCSTR(s1), SCSTR(s2))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
718
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
719 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
720 * Creates a duplicate of the specified string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
721 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
722 * The new sstr_t will contain a copy allocated by standard
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
723 * <code>malloc()</code>. So developers <b>MUST</b> pass the sstr_t.ptr to
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
724 * <code>free()</code>.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
725 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
726 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
727 * terminated and mutable, regardless of the argument.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
728 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
729 * @param string the string to duplicate
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
730 * @return a duplicate of the string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
731 * @see scstrdup_a()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
732 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
733 sstr_t scstrdup(scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
734
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
735 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
736 * Alias for scstrdup() which automatically converts the argument.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
737 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
738 * @param string the string to duplicate
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
739 * @return a duplicate of the string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
740 * @see sstrdup_a()
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
741 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
742 #define sstrdup(string) scstrdup(SCSTR(string))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
743
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
744 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
745 * Creates a duplicate of the specified string using a UcxAllocator.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
746 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
747 * The new sstr_t will contain a copy allocated by the allocators
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
748 * UcxAllocator.malloc() function. So it is implementation depended, whether the
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
749 * returned sstr_t.ptr pointer must be passed to the allocators
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
750 * UcxAllocator.free() function manually.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
751 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
752 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
753 * terminated and mutable, regardless of the argument.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
754 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
755 * @param allocator a valid instance of a UcxAllocator
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
756 * @param string the string to duplicate
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
757 * @return a duplicate of the string
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
758 * @see scstrdup()
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
759 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
760 sstr_t scstrdup_a(UcxAllocator *allocator, scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
761
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
762 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
763 * Alias for scstrdup_a() which automatically converts the argument.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
764 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
765 * @param allocator a valid instance of a UcxAllocator
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
766 * @param string the string to duplicate
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
767 * @return a duplicate of the string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
768 * @see scstrdup()
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
769 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
770 #define sstrdup_a(allocator, string) scstrdup_a(allocator, SCSTR(string))
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
771
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
772
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
773 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
774 * Omits leading and trailing spaces.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
775 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
776 * This function returns a new sstr_t containing a trimmed version of the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
777 * specified string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
778 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
779 * <b>Note:</b> the new sstr_t references the same memory, thus you
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
780 * <b>MUST NOT</b> pass the sstr_t.ptr of the return value to
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
781 * <code>free()</code>. It is also highly recommended to avoid assignments like
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
782 * <code>mystr = sstrtrim(mystr);</code> as you lose the reference to the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
783 * source string. Assignments of this type are only permitted, if the
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
784 * sstr_t.ptr of the source string does not need to be freed or if another
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
785 * reference to the source string exists.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
786 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
787 * @param string the string that shall be trimmed
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
788 * @return a new sstr_t containing the trimmed string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
789 */
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
790 sstr_t sstrtrim(sstr_t string);
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
791
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
792 /**
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
793 * Omits leading and trailing spaces.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
794 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
795 * This function returns a new scstr_t containing a trimmed version of the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
796 * specified string.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
797 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
798 * <b>Note:</b> the new scstr_t references the same memory, thus you
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
799 * <b>MUST NOT</b> pass the scstr_t.ptr of the return value to
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
800 * <code>free()</code>. It is also highly recommended to avoid assignments like
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
801 * <code>mystr = scstrtrim(mystr);</code> as you lose the reference to the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
802 * source string. Assignments of this type are only permitted, if the
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
803 * scstr_t.ptr of the source string does not need to be freed or if another
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
804 * reference to the source string exists.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
805 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
806 * @param string the string that shall be trimmed
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
807 * @return a new scstr_t containing the trimmed string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
808 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
809 scstr_t scstrtrim(scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
810
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
811 /**
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
812 * Checks, if a string has a specific prefix.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
813 * @param string the string to check
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
814 * @param prefix the prefix the string should have
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
815 * @return 1, if and only if the string has the specified prefix, 0 otherwise
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
816 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
817 int scstrprefix(scstr_t string, scstr_t prefix);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
818
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
819 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
820 * Alias for scstrprefix() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
821 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
822 * @param string the string to check
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
823 * @param prefix the prefix the string should have
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
824 * @return 1, if and only if the string has the specified prefix, 0 otherwise
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
825 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
826 #define sstrprefix(string, prefix) scstrprefix(SCSTR(string), SCSTR(prefix))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
827
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
828 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
829 * Checks, if a string has a specific suffix.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
830 * @param string the string to check
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
831 * @param suffix the suffix the string should have
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
832 * @return 1, if and only if the string has the specified suffix, 0 otherwise
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
833 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
834 int scstrsuffix(scstr_t string, scstr_t suffix);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
835
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
836 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
837 * Alias for scstrsuffix() which automatically converts the arguments.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
838 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
839 * @param string the string to check
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
840 * @param suffix the suffix the string should have
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
841 * @return 1, if and only if the string has the specified suffix, 0 otherwise
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
842 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
843 #define sstrsuffix(string, suffix) scstrsuffix(SCSTR(string), SCSTR(suffix))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
844
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
845 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
846 * Returns a lower case version of a string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
847 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
848 * This function creates a duplicate of the input string, first. See the
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
849 * documentation of scstrdup() for the implications.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
850 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
851 * @param string the input string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
852 * @return the resulting lower case string
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
853 * @see scstrdup()
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
854 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
855 sstr_t scstrlower(scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
856
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
857 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
858 * Alias for scstrlower() which automatically converts the argument.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
859 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
860 * @param string the input string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
861 * @return the resulting lower case string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
862 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
863 #define sstrlower(string) scstrlower(SCSTR(string))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
864
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
865 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
866 * Returns a lower case version of a string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
867 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
868 * This function creates a duplicate of the input string, first. See the
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
869 * documentation of scstrdup_a() for the implications.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
870 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
871 * @param allocator the allocator used for duplicating the string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
872 * @param string the input string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
873 * @return the resulting lower case string
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
874 * @see scstrdup_a()
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
875 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
876 sstr_t scstrlower_a(UcxAllocator *allocator, scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
877
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
878
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
879 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
880 * Alias for scstrlower_a() which automatically converts the argument.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
881 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
882 * @param allocator the allocator used for duplicating the string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
883 * @param string the input string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
884 * @return the resulting lower case string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
885 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
886 #define sstrlower_a(allocator, string) scstrlower_a(allocator, SCSTR(string))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
887
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
888 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
889 * Returns a upper case version of a string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
890 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
891 * This function creates a duplicate of the input string, first. See the
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
892 * documentation of scstrdup() for the implications.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
893 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
894 * @param string the input string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
895 * @return the resulting upper case string
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
896 * @see scstrdup()
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
897 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
898 sstr_t scstrupper(scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
899
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
900 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
901 * Alias for scstrupper() which automatically converts the argument.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
902 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
903 * @param string the input string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
904 * @return the resulting upper case string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
905 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
906 #define sstrupper(string) scstrupper(SCSTR(string))
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
907
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
908 /**
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
909 * Returns a upper case version of a string.
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
910 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
911 * This function creates a duplicate of the input string, first. See the
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
912 * documentation of scstrdup_a() for the implications.
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
913 *
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
914 * @param allocator the allocator used for duplicating the string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
915 * @param string the input string
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
916 * @return the resulting upper case string
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
917 * @see scstrdup_a()
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
918 */
505
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
919 sstr_t scstrupper_a(UcxAllocator *allocator, scstr_t string);
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
920
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
921 /**
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
922 * Alias for scstrupper_a() which automatically converts the argument.
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
923 *
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
924 * @param allocator the allocator used for duplicating the string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
925 * @param string the input string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
926 * @return the resulting upper case string
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
927 */
481802342fdf ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
928 #define sstrupper_a(allocator, string) scstrupper_a(allocator, string)
335
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
929
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
930 #ifdef __cplusplus
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
931 }
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
932 #endif
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
933
c1bc13faadaa updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
934 #endif /* UCX_STRING_H */

mercurial