ucx/cx/string.h

Wed, 31 Dec 2025 16:40:12 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 31 Dec 2025 16:40:12 +0100
changeset 1040
473d8cb58a6c
parent 1016
ccde46662db7
permissions
-rw-r--r--

update ucx to version 4.0

174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0358f1d9c506 upgrade ucx
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
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
29 * @file string.h
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
30 * @brief Strings that know their length.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
31 * @author Mike Becker
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
32 * @author Olaf Wintermann
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
33 * @copyright 2-Clause BSD License
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
36 #ifndef UCX_STRING_H
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
37 #define UCX_STRING_H
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "common.h"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "allocator.h"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
42 #include <string.h>
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
43
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
44 /** Convenience macro for creating a null string */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
45 #define CX_NULLSTR cx_mutstr(NULL)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
46
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
47 /** Expands a UCX string as printf arguments. */
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
48 #define CX_SFMT(s) (int) (s).length, (s).ptr
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
49
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
50 /** Format specifier for a UCX string */
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
51 #define CX_PRIstr ".*s"
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
52
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 /**
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
54 * The maximum length of the "needle" in cx_strstr() that can use SBO.
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
55 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
56 CX_EXPORT extern const unsigned cx_strstr_sbo_size;
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
57
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
58 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 * The UCX string structure.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 struct cx_mutstr_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 * A pointer to the string.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
64 * @note The string is not necessarily @c NULL terminated.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 char *ptr;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 /** The length of the string */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 size_t length;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 };
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 * A mutable string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 typedef struct cx_mutstr_s cxmutstr;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 * The UCX string structure for immutable (constant) strings.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 struct cx_string_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 * A pointer to the immutable string.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
82 * @note The string is not necessarily @c NULL terminated.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 */
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
84 const char *ptr;
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 /** The length of the string */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 size_t length;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 };
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 * An immutable string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 typedef struct cx_string_s cxstring;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 * Context for string tokenizing.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 struct cx_strtok_ctx_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 * The string to tokenize.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 cxstring str;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 * The primary delimiter.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 cxstring delim;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 * Optional array of more delimiters.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 */
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
109 const cxstring *delim_more;
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 * Length of the array containing more delimiters.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 size_t delim_more_count;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 * Position of the currently active token in the source string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 size_t pos;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
119 * Position of the next delimiter in the source string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 * If the tokenizer has not yet returned a token, the content of this field
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
122 * is undefined. If the tokenizer reaches the end of the string, this field
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 * contains the length of the source string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 size_t delim_pos;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 * The position of the next token in the source string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 size_t next_pos;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 * The number of already found tokens.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 size_t found;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 * The maximum number of tokens that shall be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 size_t limit;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 };
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 * A string tokenizing context.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 typedef struct cx_strtok_ctx_s CxStrtokCtx;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 * Wraps a mutable string that must be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
148 * The length is implicitly inferred by using a call to @c strlen().
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
150 * When @c NULL is passed, the length will be set to zero.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
151 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
152 * @note the wrapped string will share the specified pointer to the string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 * If you do want a copy, use cx_strdup() on the return value of this function.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 * If you need to wrap a constant string, use cx_str().
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
157 * @param cstring the string to wrap (must be zero-terminated)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 * @return the wrapped string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 * @see cx_mutstrn()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
162 CX_NODISCARD CX_CSTR_ARG(1)
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
163 CX_INLINE cxmutstr cx_mutstr(char *cstring) {
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
164 cxmutstr str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
165 str.ptr = cstring;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
166 str.length = cstring == NULL ? 0 : strlen(cstring);
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
167 return str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
168 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 * Wraps a string that does not need to be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
173 * The argument may be @c NULL if the length is zero.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
175 * @note the wrapped string will share the specified pointer to the string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 * If you do want a copy, use cx_strdup() on the return value of this function.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 * If you need to wrap a constant string, use cx_strn().
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
180 * @param cstring the string to wrap (or @c NULL, only if the length is zero)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 * @param length the length of the string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 * @return the wrapped string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 * @see cx_mutstr()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
186 CX_NODISCARD CX_ACCESS_RW(1, 2)
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
187 CX_INLINE cxmutstr cx_mutstrn(char *cstring, size_t length) {
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
188 cxmutstr str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
189 str.ptr = cstring;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
190 str.length = length;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
191 return str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
192 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 * Wraps a string that must be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
197 * The length is implicitly inferred by using a call to @c strlen().
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
199 * When @c NULL is passed, the length will be set to zero.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
200 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
201 * @note the wrapped string will share the specified pointer to the string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 * If you do want a copy, use cx_strdup() on the return value of this function.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 * If you need to wrap a non-constant string, use cx_mutstr().
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
206 * @param cstring the string to wrap (must be zero-terminated)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 * @return the wrapped string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 * @see cx_strn()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
211 CX_NODISCARD CX_CSTR_ARG(1)
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
212 CX_INLINE cxstring cx_str(const char *cstring) {
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
213 cxstring str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
214 str.ptr = cstring;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
215 str.length = cstring == NULL ? 0 : strlen(cstring);
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
216 return str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
217 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 * Wraps a string that does not need to be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
223 * The argument may be @c NULL if the length is zero.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
225 * @note the wrapped string will share the specified pointer to the string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 * If you do want a copy, use cx_strdup() on the return value of this function.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 * If you need to wrap a non-constant string, use cx_mutstrn().
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
230 * @param cstring the string to wrap (or @c NULL, only if the length is zero)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 * @param length the length of the string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 * @return the wrapped string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 * @see cx_str()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
236 CX_NODISCARD CX_ACCESS_R(1, 2)
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
237 CX_INLINE cxstring cx_strn(const char *cstring, size_t length) {
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
238 cxstring str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
239 str.ptr = cstring;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
240 str.length = length;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
241 return str;
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
242 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
244 #ifdef __cplusplus
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
245 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
246 CX_CPPDECL cxmutstr cx_strcast_m(cxmutstr str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
247 return str;
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
248 }
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
249 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
250 CX_CPPDECL cxstring cx_strcast_m(cxstring str) {
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
251 return str;
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
252 }
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
253 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
254 CX_CPPDECL cxmutstr cx_strcast_m(char *str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
255 return cx_mutstr(str);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
256 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
257 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
258 CX_CPPDECL cxmutstr cx_strcast_m(unsigned char *str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
259 return cx_mutstr(reinterpret_cast<char*>(str));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
260 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
261 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
262 CX_CPPDECL cxstring cx_strcast_m(const char *str) {
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
263 return cx_str(str);
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
264 }
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
265 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
266 CX_CPPDECL cxstring cx_strcast_m(const unsigned char *str) {
943
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
267 return cx_str(reinterpret_cast<const char*>(str));
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
268 }
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
269 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
270 CX_CPPDECL cxstring cx_strcast_(cxmutstr str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
271 return cx_strn(str.ptr, str.length);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
272 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
273 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
274 CX_CPPDECL cxstring cx_strcast_(cxstring str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
275 return str;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
276 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
277 #define cx_strcast(s) cx_strcast_(cx_strcast_m(s))
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
278 #else
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
279 /**
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
280 * Internal function, do not use.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
281 * @param str
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
282 * @return
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
283 * @see cx_strcast_m()
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
284 * @see cx_strcast()
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
285 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
286 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
287 CX_INLINE cxmutstr cx_strcast_cxms(cxmutstr str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
288 return str;
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
289 }
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
290 /**
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
291 * Internal function, do not use.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
292 * @param str
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
293 * @return
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
294 * @see cx_strcast_m()
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
295 * @see cx_strcast()
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
296 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
297 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
298 CX_INLINE cxstring cx_strcast_cxs(cxstring str) {
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
299 return str;
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
300 }
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
301
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 /**
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
303 * Internal function, do not use.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
304 * @param str
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
305 * @return
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
306 * @see cx_strcast_m()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
307 * @see cx_strcast()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
308 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
309 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
310 CX_INLINE cxmutstr cx_strcast_uc(unsigned char *str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
311 return cx_mutstr((char*)str);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
312 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
313
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
314 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
315 * Internal function, do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
316 * @param str
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
317 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
318 * @see cx_strcast_m()
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
319 * @see cx_strcast()
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
320 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
321 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
322 CX_INLINE cxmutstr cx_strcast_c(char *str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
323 return cx_mutstr(str);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
324 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
325
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
326 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
327 * Internal function, do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
328 * @param str
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
329 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
330 * @see cx_strcast_m()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
331 * @see cx_strcast()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
332 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
333 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
334 CX_INLINE cxstring cx_strcast_ucc(const unsigned char *str) {
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
335 return cx_str((const char*)str);
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
336 }
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
337
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
338 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
339 * Internal function, do not use.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
340 * @param str
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
341 * @return
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
342 * @see cx_strcast_m()
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
343 * @see cx_strcast()
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
344 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
345 CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
346 CX_INLINE cxstring cx_strcast_cc(const char *str) {
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
347 return cx_str(str);
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
348 }
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
349
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
350 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
351 * Wraps any string into an UCX string.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
352 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
353 * @param str (any supported string type) the string to cast
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
354 * @return (@c cxstring) or (@c cxmutstr) the string wrapped as UCX string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
355 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
356 #define cx_strcast_m(str) _Generic((str), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
357 cxstring: cx_strcast_cxs, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
358 cxmutstr: cx_strcast_cxms, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
359 const unsigned char*: cx_strcast_ucc, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
360 unsigned char *: cx_strcast_uc, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
361 const char*: cx_strcast_cc, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
362 char *: cx_strcast_c) (str)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
363
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
364 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
365 * Internal function, do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
366 * @param str
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
367 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
368 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
369 CX_INLINE cxstring cx_strcast_1(cxmutstr str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
370 return (cxstring){str.ptr, str.length};
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
371 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
372
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
373 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
374 * Internal function, do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
375 * @param str
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
376 * @return
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
377 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
378 CX_INLINE cxstring cx_strcast_2(cxstring str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
379 return str;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
380 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
381
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
382 /** internal conversion macro */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
383 #define cx_strcast_(str) _Generic((str), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
384 cxmutstr: cx_strcast_1, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
385 cxstring: cx_strcast_2)(str)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
386
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
387 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
388 * Converts any string to a cxstring.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
389 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
390 * @param str (any supported string type) the string to cast
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
391 * @return he string converted to a (@c cxstring)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
392 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
393 #define cx_strcast(str) cx_strcast_(cx_strcast_m(str))
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
394 #endif
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
397 * Casts away constness and converts a cxstring to a cxmutstr.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
398 * For internal use only!
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
399 * @param str
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
400 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
401 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
402 CX_INLINE cxmutstr cx_mutstrcast(cxstring str) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
403 cxmutstr s;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
404 s.ptr = (char*)str.ptr;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
405 s.length = str.length;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
406 return s;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
407 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
408
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
409 /**
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
410 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
412 * The pointer in the struct is set to @c NULL, and the length is set to zero,
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
413 * which means that this function protects you against double-free.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
415 * @note There is no implementation for cxstring, because it is unlikely that
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
416 * you ever have a <code>const char*</code> you are really supposed to free.
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
417 * If you encounter such a situation, you should double-check your code.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419 * @param str the string to free
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
421 CX_EXTERN
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
422 void cx_strfree(cxmutstr *str);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
425 * Passes the pointer in this string to the allocator's free function.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
427 * The pointer in the struct is set to @c NULL, and the length is set to zero,
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
428 * which means that this function protects you against double-free.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
430 * @note There is no implementation for cxstring, because it is unlikely that
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
431 * you ever have a <code>const char*</code> you are really supposed to free.
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
432 * If you encounter such a situation, you should double-check your code.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 * @param alloc the allocator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 * @param str the string to free
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
437 CX_EXTERN CX_NONNULL_ARG(1)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
438 void cx_strfree_a(const CxAllocator *alloc, cxmutstr *str);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
439
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
440 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
441 * Copies a string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
442 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
443 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
444 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
445 * @param alloc the allocator
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
446 * @param dest a pointer to the structure where to copy the contents to
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
447 * @param src the source string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
448 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
449 * @retval zero success
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
450 * @retval non-zero if re-allocation failed
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
451 * @see cx_strcpy_a()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
452 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
453 CX_EXTERN CX_NONNULL_ARG(1)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
454 int cx_strcpy_a_(const CxAllocator *alloc, cxmutstr *dest, cxstring src);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 /**
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
457 * Copies a string.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
458 *
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
459 * The memory in the @p dest structure is either allocated or re-allocated to fit the entire
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
460 * source string, including a zero-terminator.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
461 *
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
462 * The string in @p dest is guaranteed to be zero-terminated, regardless of whether @p src is.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
463 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
464 * @param alloc (@c CxAllocator*) the allocator
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
465 * @param dest (@c cxmutstr*) a pointer to the structure where to copy the contents to
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
466 * @param src the source string
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
467 * @retval zero success
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
468 * @retval non-zero if re-allocation failed
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
469 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
470 #define cx_strcpy_a(alloc, dest, src) cx_strcpy_a_(alloc, dest, cx_strcast(src))
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
471
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
472 /**
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
473 * Copies a string.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
474 *
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
475 * The memory in the @p dest structure is either allocated or re-allocated to fit the entire
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
476 * source string, including a zero-terminator.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
477 *
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
478 * The string in @p dest is guaranteed to be zero-terminated, regardless of whether @p src is.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
479 *
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
480 * @param dest (@c cxmutstr*) a pointer to the structure where to copy the contents to
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
481 * @param src the source string
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
482 * @retval zero success
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
483 * @retval non-zero if re-allocation failed
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
484 */
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
485 #define cx_strcpy(dest, src) cx_strcpy_a(cxDefaultAllocator, dest, src)
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
486
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
487 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 * Returns the accumulated length of all specified strings.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
489 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
490 * If this sum overflows, errno is set to EOVERFLOW.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
492 * @attention if the count argument is larger than the number of the
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 * specified strings, the behavior is undefined.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 * @param count the total number of specified strings
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
496 * @param ... all strings
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 * @return the accumulated length of all strings
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
499 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
500 size_t cx_strlen(size_t count, ...);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 * Concatenates strings.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505 * The resulting string will be allocated by the specified allocator.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
506 * So developers @em must pass the return value to cx_strfree_a() eventually.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
508 * If @p str already contains a string, the memory will be reallocated and
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 * the other strings are appended. Otherwise, new memory is allocated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
511 * @note It is guaranteed that there is only one allocation for the
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
512 * resulting string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 * It is also guaranteed that the returned string is zero-terminated.
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
514 * If allocation fails, the @c ptr in the returned string will be @c NULL.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516 * @param alloc the allocator to use
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 * @param str the string the other strings shall be concatenated to
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 * @param count the number of the other following strings to concatenate
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
519 * @param ... all other UCX strings
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 * @return the concatenated string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
522 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
523 cxmutstr cx_strcat_a(const CxAllocator *alloc,
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
524 cxmutstr str, size_t count, ...);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
525
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
526 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527 * Concatenates strings and returns a new string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
528 *
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
529 * The resulting string will be allocated by the cxDefaultAllocator.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
530 * So developers @em must pass the return value to cx_strfree() eventually.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
532 * @note It is guaranteed that there is only one allocation for the
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
533 * resulting string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
534 * It is also guaranteed that the returned string is zero-terminated.
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
535 * If allocation fails, the @c ptr in the returned string will be @c NULL.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
536 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
537 * @param str (@c cxmutstr*) the string the other strings shall be concatenated to
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
538 * @param count (@c size_t) the number of the other following strings to concatenate
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
539 * @param ... all other UCX strings
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
540 * @return the concatenated string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
541 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
542 #define cx_strcat(str, count, ...) \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
543 cx_strcat_a(cxDefaultAllocator, str, count, __VA_ARGS__)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
544
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
545 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
546 * Returns a substring.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
547 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
548 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
549 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
550 * @param string input string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
551 * @param start start location of the substring
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
552 * @param length the maximum length of the returned string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
553 * @return a substring of @p string starting at @p start
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
554 * @see cx_strsubsl()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
556 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
557 cxstring cx_strsubsl_(cxstring string, size_t start, size_t length);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
558
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
559 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
560 * Returns a substring.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
561 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
562 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
563 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
564 * @param string input string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
565 * @param start start location of the substring
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
566 * @return a substring of @p string starting at @p start
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
567 * @see cx_strsubs()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
568 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
569 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
570 cxstring cx_strsubs_(cxstring string, size_t start);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
573 * Internal conversion function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
574 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
575 * @param start
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
576 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
577 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
578 CX_INLINE
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
579 cxmutstr cx_strsubs_m_(cxmutstr string, size_t start) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
580 return cx_mutstrcast(cx_strsubs_(cx_strcast(string), start));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
581 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
582
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
583 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
584 * Internal conversion function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
585 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
586 * @param start
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
587 * @param length
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
588 * @return
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
590 CX_INLINE
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
591 cxmutstr cx_strsubsl_m_(cxmutstr string, size_t start, size_t length) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
592 return cx_mutstrcast(cx_strsubsl_(cx_strcast(string), start, length));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
593 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
595 #ifdef __cplusplus
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
596 CX_CPPDECL cxstring cx_strsubs_cpp_(cxstring string, size_t start) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
597 return cx_strsubs_(string, start);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
598 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
599 CX_CPPDECL cxstring cx_strsubsl_cpp_(cxstring string, size_t start, size_t length) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
600 return cx_strsubsl_(string, start, length);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
601 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
602 CX_CPPDECL cxmutstr cx_strsubs_cpp_(cxmutstr string, size_t start) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
603 return cx_strsubs_m_(string, start);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
604 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
605 CX_CPPDECL cxmutstr cx_strsubsl_cpp_(cxmutstr string, size_t start, size_t length) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
606 return cx_strsubsl_m_(string, start, length);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
607 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
608 #define cx_strsubs(string, start) cx_strsubs_cpp_(cx_strcast_m(string), start)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
609 #define cx_strsubsl(string, start, length) cx_strsubsl_cpp_(cx_strcast_m(string), start, length)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
610 #else
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612 * Returns a substring starting at the specified location.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
613 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
614 * @attention the new string references the same memory area as the
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
615 * input string and is @em not zero-terminated.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
616 * Use cx_strdup() to get a copy.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
617 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
618 * @param string input string
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
619 * @param start (@c size_t) start location of the substring
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
620 * @return (@c cxstring or @c cxmutstr) a substring of @p string starting at @p start
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
621 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
622 * @see cx_strsubsl()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
623 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
624 #define cx_strsubs(string, start) _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
625 cxstring: cx_strsubs_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
626 cxmutstr: cx_strsubs_m_)(cx_strcast_m(string), start)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
627
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
628 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
629 * Returns a substring starting at the specified location.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
630 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
631 * The returned string will be limited to @p length bytes or the number
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
632 * of bytes available in @p string, whichever is smaller.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
633 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
634 * @attention the new string references the same memory area as the
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
635 * input string and is usually @em not zero-terminated.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636 * Use cx_strdup() to get a copy.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
637 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 * @param string input string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 * @param start start location of the substring
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
640 * @param length the maximum length of the returned string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
641 * @return a substring of @p string starting at @p start
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 * @see cx_strsubs()
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
644 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
645 #define cx_strsubsl(string, start, length) _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
646 cxstring: cx_strsubsl_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
647 cxmutstr: cx_strsubsl_m_)(cx_strcast_m(string), start, length)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
648 #endif
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
649
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
650 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
651 * Returns the character at the specified index offset.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
652 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
653 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
654 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
655 * @param str the string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
656 * @param index the index offset
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
657 * @return the character at the index
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
658 * @see cx_strat()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
659 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
660 CX_INLINE
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
661 char cx_strat_(cxstring str, off_t index) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
662 size_t i;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
663 if (index >= 0) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
664 i = index;
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
665 } else {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
666 i = (size_t) (str.length + index);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
667 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
668 if (i >= str.length) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
669 return '\0';
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
670 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
671 return str.ptr[i];
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
672 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
673
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
674 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
675 * Returns the character at the specified index offset.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
676 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
677 * When the @p index is negative, the character is counted from the end of the
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
678 * string where -1 denotes the last character in the string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
679 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
680 * When the @p index is out of bounds, the function returns zero.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
681 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
682 * @param str the string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
683 * @param index the index offset
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
684 * @return the character at the index
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
685 * @see cx_strat()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
686 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
687 #define cx_strat(str, index) cx_strat_(cx_strcast(str), index)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
688
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
689 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
690 * Searches for a character in a string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
691 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
692 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
693 * @param chr
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
694 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
695 * @see cx_strchr()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
696 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
697 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
698 cxstring cx_strchr_(cxstring string, int chr);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
699
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
700 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
701 * Searches for a character in a string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
702 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
703 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
704 * @param chr
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
705 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
706 * @see cx_strrchr()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
707 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
708 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
709 cxstring cx_strrchr_(cxstring string, int chr);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
710
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
711 #ifdef __cplusplus
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
712 CX_CPPDECL cxstring cx_strchr_cpp_(cxstring string, int chr) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
713 return cx_strchr_(string, chr);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
714 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
715 CX_CPPDECL cxmutstr cx_strchr_cpp_(cxmutstr string, int chr) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
716 return cx_mutstrcast(cx_strchr_(cx_strcast(string), chr));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
717 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
718 #define cx_strchr(s, chr) cx_strchr_cpp_(cx_strcast_m(s), chr)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
719 CX_CPPDECL cxstring cx_strrchr_cpp_(cxstring string, int chr) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
720 return cx_strrchr_(string, chr);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
721 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
722 CX_CPPDECL cxmutstr cx_strrchr_cpp_(cxmutstr string, int chr) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
723 return cx_mutstrcast(cx_strrchr_(cx_strcast(string), chr));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
724 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
725 #define cx_strrchr(s, chr) cx_strrchr_cpp_(cx_strcast_m(s), chr)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
726 #else
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
727 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
728 * Internal conversion function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
729 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
730 * @param chr
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
731 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
732 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
733 CX_INLINE cxmutstr cx_strchr_m_(cxmutstr string, int chr) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
734 return cx_mutstrcast(cx_strchr_(cx_strcast(string), chr));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
735 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
736 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
737 * Internal conversion function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
738 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
739 * @param chr
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
740 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
741 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
742 CX_INLINE cxmutstr cx_strrchr_m_(cxmutstr string, int chr) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
743 return cx_mutstrcast(cx_strrchr_(cx_strcast(string), chr));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
744 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
745
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
746 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
747 * Returns a substring starting at the location of the first occurrence of the
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
748 * specified character.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
749 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
750 * If the string does not contain the character, an empty string is returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
751 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
752 * @param string the string where to locate the character
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
753 * @param chr (@c int) the character to locate
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
754 * @return (@c cxstring or @c cxmutstr) a substring starting at the first
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
755 * location of @p chr
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
756 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
757 #define cx_strchr(string, chr) _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
758 cxstring: cx_strchr_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
759 cxmutstr: cx_strchr_m_)(cx_strcast_m(string), chr)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
760
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
761 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
762 * Returns a substring starting at the location of the last occurrence of the
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
763 * specified character.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
764 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
765 * If the string does not contain the character, an empty string is returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
766 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
767 * @param string the string where to locate the character
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
768 * @param chr (@c int) the character to locate
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
769 * @return (@c cxstring or @c cxmutstr) a substring starting at the last
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
770 * location of @p chr
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
771 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
772 #define cx_strrchr(string, chr) _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
773 cxstring: cx_strrchr_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
774 cxmutstr: cx_strrchr_m_)(cx_strcast_m(string), chr)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
775 #endif
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
776
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
777 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
778 * Searches for a specific substring.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
779 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
780 * Internal function - do not use.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
781 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
782 * @param haystack the string to be scanned
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
783 * @param needle string containing the sequence of characters to match
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
784 * @return a substring starting at the first occurrence of @p needle,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
785 * or an empty string, if the sequence is not contained
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
786 * @see cx_strstr()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
787 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
788 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
789 cxstring cx_strstr_(cxstring haystack, cxstring needle);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
790
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
791 #ifdef __cplusplus
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
792 CX_CPPDECL cxstring cx_strstr_cpp_(cxstring haystack, cxstring needle) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
793 return cx_strstr_(haystack, needle);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
794 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
795 CX_CPPDECL cxmutstr cx_strstr_cpp_(cxmutstr haystack, cxstring needle) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
796 return cx_mutstrcast(cx_strstr_(cx_strcast(haystack), needle));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
797 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
798 #define cx_strstr(h,n) cx_strstr_cpp_(cx_strcast_m(h), cx_strcast(n))
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
799 #else
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
800 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
801 * Internal conversion - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
802 * @param haystack
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
803 * @param needle
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
804 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
805 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
806 CX_INLINE cxmutstr cx_strstr_m_(cxmutstr haystack, cxstring needle) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
807 return cx_mutstrcast(cx_strstr_(cx_strcast(haystack), needle));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
808 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
809
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
810 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
811 * Returns a substring starting at the location of the first occurrence of the
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
812 * specified string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
813 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
814 * If @p haystack does not contain @p needle, an empty string is returned.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
815 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
816 * If @p needle is an empty string, the complete @p haystack is
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
817 * returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
818 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
819 * @param haystack the string to be scanned
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
820 * @param needle string containing the sequence of characters to match
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
821 * @return (@c cxstring or @c cxmutstr) a substring starting at the first
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
822 * occurrence of @p needle, or an empty string, if the sequence is not contained
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
823 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
824 #define cx_strstr(haystack, needle) _Generic(cx_strcast_m(haystack), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
825 cxstring: cx_strstr_,\
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
826 cxmutstr: cx_strstr_m_)(cx_strcast_m(haystack), cx_strcast(needle))
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
827 #endif
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
828
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
829 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
830 * Splits a given string using a delimiter string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
831 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
832 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
833 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
834 * @param string the string to split
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
835 * @param delim the delimiter
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
836 * @param limit the maximum number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
837 * @param output the output array
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
838 * @return the actual number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
839 * @see cx_strsplit()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
840 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
841 CX_EXTERN CX_NODISCARD CX_NONNULL CX_ACCESS_W(4, 3)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
842 size_t cx_strsplit_(cxstring string, cxstring delim,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
843 size_t limit, cxstring *output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
844
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
845 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
846 * Splits a given string using a delimiter string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
847 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
848 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
849 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
850 * @param allocator the allocator to use for allocating the resulting array
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
851 * @param string the string to split
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
852 * @param delim the delimiter
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
853 * @param limit the maximum number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
854 * @param output the output array
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
855 * @return the actual number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
856 * @see cx_strsplit_a()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
857 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
858 CX_EXTERN CX_NODISCARD CX_NONNULL CX_ACCESS_W(5)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
859 size_t cx_strsplit_a_(const CxAllocator *allocator,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
860 cxstring string, cxstring delim,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
861 size_t limit, cxstring **output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
862
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
863
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
864 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
865 * Splits a given string using a delimiter string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
866 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
867 * Internal function - do not use.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
868 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
869 * @param string the string to split
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
870 * @param delim the delimiter
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
871 * @param limit the maximum number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
872 * @param output the output array
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
873 * @return the actual number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
874 * @see cx_strsplit_m()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
875 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
876 CX_EXTERN CX_NODISCARD CX_NONNULL CX_ACCESS_W(4, 3)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
877 size_t cx_strsplit_m_(cxmutstr string, cxstring delim,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
878 size_t limit, cxmutstr *output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
879
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
880 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
881 * Splits a given string using a delimiter string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
882 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
883 * Internal function - do not use.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
884 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
885 * @param allocator the allocator to use for allocating the resulting array
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
886 * @param string the string to split
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
887 * @param delim the delimiter
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
888 * @param limit the maximum number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
889 * @param output the output array
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
890 * @return the actual number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
891 * @see cx_strsplit_ma()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
892 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
893 CX_EXTERN CX_NODISCARD CX_NONNULL CX_ACCESS_W(5)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
894 size_t cx_strsplit_ma_(const CxAllocator *allocator,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
895 cxmutstr string, cxstring delim, size_t limit,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
896 cxmutstr **output);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
897
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
898 #ifdef __cplusplus
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
899 CX_CPPDECL size_t cx_strsplit_cpp_(cxstring string, cxstring delim,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
900 size_t limit, cxstring *output) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
901 return cx_strsplit_(string, delim, limit, output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
902 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
903 CX_CPPDECL size_t cx_strsplit_cpp_(cxmutstr string, cxstring delim,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
904 size_t limit, cxmutstr *output) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
905 return cx_strsplit_m_(string, delim, limit, output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
906 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
907 CX_CPPDECL size_t cx_strsplit_a_cpp_(const CxAllocator *allocator,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
908 cxstring string, cxstring delim, size_t limit, cxstring **output) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
909 return cx_strsplit_a_(allocator, string, delim, limit, output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
910 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
911 CX_CPPDECL size_t cx_strsplit_a_cpp_(const CxAllocator *allocator,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
912 cxmutstr string, cxstring delim, size_t limit, cxmutstr **output) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
913 return cx_strsplit_ma_(allocator, string, delim, limit, output);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
914 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
915 #define cx_strsplit(string, delim, limit, output) \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
916 cx_strsplit_cpp_(cx_strcast_m(string), cx_strcast(delim), limit, output)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
917 #define cx_strsplit_a(allocator, string, delim, limit, output) \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
918 cx_strsplit_a_cpp_(allocator, cx_strcast_m(string), cx_strcast(delim), limit, output)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
919 #else
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
920 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
921 * Splits a given string using a delimiter string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
922 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
923 * @note The resulting array contains strings that point to the source
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
924 * @p string. Use cx_strdup() to get copies.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
925 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
926 * @param string the string to split
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
927 * @param delim the delimiter
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
928 * @param limit (@c size_t) the maximum number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
929 * @param output (@c cxstring* or @c cxmutstr*) a preallocated array of at
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
930 * least @p limit length
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
931 * @return the actual number of split items
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
932 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
933 #define cx_strsplit(string, delim, limit, output) \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
934 _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
935 cxstring: cx_strsplit_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
936 cxmutstr: cx_strsplit_m_)\
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
937 (cx_strcast_m(string), cx_strcast(delim), limit, output)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
938
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
939 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
940 * Splits a given string using a delimiter string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
941 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
942 * The array pointed to by @p output will be allocated by @p allocator.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
943 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
944 * @note The resulting array contains strings that point to the source
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
945 * @p string. Use cx_strdup() to get copies.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
946 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
947 * @attention If allocation fails, the @c NULL pointer will be written to
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
948 * @p output and the number returned will be zero.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
949 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
950 * @param allocator (@c CxAllocator*) the allocator to use for allocating the resulting array
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
951 * @param string the string to split
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
952 * @param delim the delimiter
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
953 * @param limit (@c size_t) the maximum number of split items
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
954 * @param output (@c cxstring** or @c cxmutstr**) a pointer where the address
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
955 * of the allocated array shall be written to
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
956 * @return the actual number of split items
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
957 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
958 #define cx_strsplit_a(allocator, string, delim, limit, output) \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
959 _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
960 cxstring: cx_strsplit_a_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
961 cxmutstr: cx_strsplit_ma_)\
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
962 (allocator, cx_strcast_m(string), cx_strcast(delim), limit, output)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
963 #endif
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
964
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
965 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
966 * Compares two strings.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
967 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
968 * @param s1 the first string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
969 * @param s2 the second string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
970 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
971 * than @p s2, zero if both strings equal
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
972 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
973 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
974 int cx_strcmp_(cxstring s1, cxstring s2);
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
975
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
976 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
977 * Compares two strings.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
978 *
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
979 * @param s1 the first string
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
980 * @param s2 the second string
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
981 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
982 * than @p s2, zero if both strings equal
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
983 */
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
984 #define cx_strcmp(s1, s2) cx_strcmp_(cx_strcast(s1), cx_strcast(s2))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
985
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
986 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
987 * Compares two strings ignoring case.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
988 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
989 * @param s1 the first string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
990 * @param s2 the second string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
991 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
992 * than @p s2, zero if both strings equal ignoring case
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
993 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
994 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
995 int cx_strcasecmp_(cxstring s1, cxstring s2);
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
996
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
997 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
998 * Compares two strings ignoring case.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
999 *
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1000 * @param s1 the first string
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1001 * @param s2 the second string
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1002 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1003 * than @p s2, zero if both strings equal ignoring case
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1004 */
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1005 #define cx_strcasecmp(s1, s2) cx_strcasecmp_(cx_strcast(s1), cx_strcast(s2))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1006
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1007 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1008 * Compares two strings.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1009 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1010 * This function has a compatible signature for the use as a cx_compare_func.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1011 *
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1012 * @attention This function can @em only compare UCX strings. It is unsafe to
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1013 * pass normal C-strings to this function.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1014 *
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1015 * @param s1 the first string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1016 * @param s2 the second string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1017 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1018 * than @p s2, zero if both strings equal
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1019 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1020 CX_EXTERN CX_NODISCARD CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1021 int cx_strcmp_p(const void *s1, const void *s2);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1022
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1023 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1024 * Compares two strings ignoring case.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1025 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1026 * This function has a compatible signature for the use as a cx_compare_func.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1027 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1028 * @param s1 the first string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1029 * @param s2 the second string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1030 * @return negative if @p s1 is smaller than @p s2, positive if @p s1 is larger
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1031 * than @p s2, zero if both strings equal ignoring case
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1032 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1033 CX_EXTERN CX_NODISCARD CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1034 int cx_strcasecmp_p(const void *s1, const void *s2);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1035
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1036 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1037 * Creates a duplicate of the specified string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1038 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1039 * The new string will contain a copy allocated by @p allocator.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1040 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1041 * @note The returned string is guaranteed to be zero-terminated.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1042 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1043 * @param allocator the allocator to use
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1044 * @param string the string to duplicate
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1045 * @return a duplicate of the string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1046 * @see cx_strdup()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1047 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1048 CX_EXTERN CX_NODISCARD CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1049 cxmutstr cx_strdup_a_(const CxAllocator *allocator, cxstring string);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1050
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1051 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1052 * Creates a duplicate of the specified string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1053 *
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1054 * The new string will contain a copy allocated by @p allocator.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1055 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1056 * @note The returned string is guaranteed to be zero-terminated.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1057 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1058 * @param allocator (@c CxAllocator*) the allocator to use
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1059 * @param string the string to duplicate
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1060 * @return (@c cxmutstr) a duplicate of the string
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1061 * @see cx_strdup()
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1062 * @see cx_strfree_a()
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1063 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1064 #define cx_strdup_a(allocator, string) cx_strdup_a_((allocator), cx_strcast(string))
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1065
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1066 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1067 * Creates a duplicate of the specified string.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1068 *
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
1069 * The new string will contain a copy allocated by the cxDefaultAllocator.
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
1070 * So developers @em must pass the return value to cx_strfree().
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1071 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1072 * @note The returned string is guaranteed to be zero-terminated.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1073 *
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1074 * @param string the string to duplicate
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1075 * @return (@c cxmutstr) a duplicate of the string
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1076 * @see cx_strdup_a()
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1077 * @see cx_strfree()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1078 */
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
1079 #define cx_strdup(string) cx_strdup_a(cxDefaultAllocator, string)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1080
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1081 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1082 * Trims a string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1083 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1084 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1085 * @return
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1086 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1087 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1088 cxstring cx_strtrim_(cxstring string);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1089
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1090 #ifdef __cplusplus
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1091 CX_CPPDECL cxstring cx_strtrim_cpp_(cxstring string) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1092 return cx_strtrim_(string);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1093 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1094 CX_CPPDECL cxmutstr cx_strtrim_cpp_(cxmutstr string) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1095 return cx_mutstrcast(cx_strtrim_(cx_strcast(string)));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1096 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1097 #define cx_strtrim(string) cx_strtrim_cpp_(cx_strcast_m(string))
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1098 #else
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1099 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1100 * Internal conversion function.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1101 * @param string
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1102 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1103 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1104 CX_INLINE cxmutstr cx_strtrim_m_(cxmutstr string) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1105 return cx_mutstrcast(cx_strtrim_(cx_strcast(string)));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1106 }
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1107
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1108 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1109 * Omits leading and trailing spaces.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1110 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1111 * @note the returned string references the same memory, thus you
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1112 * must @em not free the returned memory.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1113 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1114 * @param string the string that shall be trimmed
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1115 * @return (@c cxstring or @c cxmutstr) the trimmed string
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1116 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1117 #define cx_strtrim(string) _Generic(cx_strcast_m(string), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1118 cxstring: cx_strtrim_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1119 cxmutstr: cx_strtrim_m_)(cx_strcast_m(string))
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1120 #endif
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1121
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1122 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1123 * Checks if a string has a specific prefix.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1124 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1125 * @param string the string to check
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1126 * @param prefix the prefix the string should have
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1127 * @return @c true, if and only if the string has the specified prefix,
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1128 * @c false otherwise
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1129 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1130 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1131 bool cx_strprefix_(cxstring string, cxstring prefix);
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1132
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1133 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1134 * Checks if a string has a specific prefix.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1135 *
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1136 * @param string the string to check
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1137 * @param prefix the prefix the string should have
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1138 * @return @c true, if and only if the string has the specified prefix,
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1139 * @c false otherwise
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1140 */
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1141 #define cx_strprefix(string, prefix) cx_strprefix_(cx_strcast(string), cx_strcast(prefix))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1142
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1143 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1144 * Checks if a string has a specific suffix.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1145 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1146 * @param string the string to check
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1147 * @param suffix the suffix the string should have
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1148 * @return @c true, if and only if the string has the specified suffix,
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1149 * @c false otherwise
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1150 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1151 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1152 bool cx_strsuffix_(cxstring string, cxstring suffix);
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1153
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1154 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1155 * Checks if a string has a specific suffix.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1156 *
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1157 * @param string the string to check
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1158 * @param suffix the suffix the string should have
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1159 * @return @c true, if and only if the string has the specified suffix,
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1160 * @c false otherwise
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1161 */
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1162 #define cx_strsuffix(string, suffix) cx_strsuffix_(cx_strcast(string), cx_strcast(suffix))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1163
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1164 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1165 * Checks if a string has a specific prefix, ignoring the case.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1166 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1167 * @param string the string to check
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1168 * @param prefix the prefix the string should have
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1169 * @return @c true, if and only if the string has the specified prefix,
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1170 * @c false otherwise
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1171 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1172 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1173 bool cx_strcaseprefix_(cxstring string, cxstring prefix);
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1174
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1175 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1176 * Checks if a string has a specific prefix, ignoring the case.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1177 *
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1178 * @param string the string to check
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1179 * @param prefix the prefix the string should have
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1180 * @return @c true, if and only if the string has the specified prefix,
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1181 * @c false otherwise
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1182 */
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1183 #define cx_strcaseprefix(string, prefix) cx_strcaseprefix_(cx_strcast(string), cx_strcast(prefix))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1184
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1185 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1186 * Checks, if a string has a specific suffix, ignoring the case.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1187 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1188 * @param string the string to check
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1189 * @param suffix the suffix the string should have
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1190 * @return @c true, if and only if the string has the specified suffix,
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1191 * @c false otherwise
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1192 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1193 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1194 bool cx_strcasesuffix_(cxstring string, cxstring suffix);
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1195
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1196 /**
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1197 * Checks, if a string has a specific suffix, ignoring the case.
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1198 *
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1199 * @param string the string to check
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1200 * @param suffix the suffix the string should have
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1201 * @return @c true, if and only if the string has the specified suffix,
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1202 * @c false otherwise
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1203 */
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1204 #define cx_strcasesuffix(string, suffix) cx_strcasesuffix_(cx_strcast(string), cx_strcast(suffix))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1205
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1206 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1207 * Replaces a string with another string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1208 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1209 * Internal function - do not use.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1210 *
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1211 * @param allocator
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1212 * @param str
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1213 * @param search
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1214 * @param replacement
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1215 * @param replmax
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1216 * @return
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1217 * @see cx_strreplace_a()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1218 * @see cx_strreplace()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1219 * @see cx_strreplacen_a()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1220 * @see cx_strreplacen()
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1221 */
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1222 CX_EXTERN CX_NODISCARD CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1223 cxmutstr cx_strreplace_(const CxAllocator *allocator,
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1224 cxstring str, cxstring search, cxstring replacement, size_t replmax);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1225
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1226 /**
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1227 * Replaces a string with another string.
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1228 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1229 * The function replaces at most @p replmax occurrences.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1230 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1231 * The returned string will be allocated by @p allocator and is guaranteed
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1232 * to be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1233 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1234 * If allocation fails, or the input string is empty,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1235 * the returned string will be empty.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1236 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1237 * @param allocator (@c CxAllocator*) the allocator to use
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1238 * @param str the string where replacements should be applied
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1239 * @param search the string to search for
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1240 * @param replacement the replacement string
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1241 * @param replmax (@c size_t) maximum number of replacements
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1242 * @return (@c cxmutstr) the resulting string after applying the replacements
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1243 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1244 #define cx_strreplacen_a(allocator, str, search, replacement, replmax) \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1245 cx_strreplace_(allocator, cx_strcast(str), cx_strcast(search), cx_strcast(replacement), replmax)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1246
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1247 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1248 * Replaces a string with another string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1249 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1250 * The function replaces at most @p replmax occurrences.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1251 *
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
1252 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1253 * to be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1254 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1255 * If allocation fails, or the input string is empty,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1256 * the returned string will be empty.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1257 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1258 * @param str the string where replacements should be applied
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1259 * @param search the string to search for
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1260 * @param replacement the replacement string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1261 * @param replmax (@c size_t) maximum number of replacements
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1262 * @return (@c cxmutstr) the resulting string after applying the replacements
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1263 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1264 #define cx_strreplacen(str, search, replacement, replmax) \
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1265 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, replmax)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1266
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1267 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1268 * Replaces a string with another string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1269 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1270 * The returned string will be allocated by @p allocator and is guaranteed
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1271 * to be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1272 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1273 * If allocation fails, or the input string is empty,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1274 * the returned string will be empty.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1275 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1276 * @param allocator (@c CxAllocator*) the allocator to use
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1277 * @param str the string where replacements should be applied
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1278 * @param search the string to search for
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1279 * @param replacement the replacement string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1280 * @return (@c cxmutstr) the resulting string after applying the replacements
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1281 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1282 #define cx_strreplace_a(allocator, str, search, replacement) \
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1283 cx_strreplacen_a(allocator, str, search, replacement, SIZE_MAX)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1284
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1285 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1286 * Replaces a string with another string.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1287 *
629
0385a450c2a6 add list initializer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
1288 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1289 * to be zero-terminated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1290 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1291 * If allocation fails, or the input string is empty,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1292 * the returned string will be empty.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1293 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1294 * @param str the string where replacements should be applied
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1295 * @param search the string to search for
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1296 * @param replacement the replacement string
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1297 * @return (@c cxmutstr) the resulting string after applying the replacements
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1298 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1299 #define cx_strreplace(str, search, replacement) \
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1300 cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, SIZE_MAX)
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1301
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1302 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1303 * Creates a string tokenization context.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1304 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1305 * @param str the string to tokenize
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1306 * @param delim the delimiter (must not be empty)
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1307 * @param limit the maximum number of tokens that shall be returned
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1308 * @return a new string tokenization context
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1309 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1310 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1311 CxStrtokCtx cx_strtok_(cxstring str, cxstring delim, size_t limit);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1312
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1313 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1314 * Creates a string tokenization context.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1315 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1316 * @param str the string to tokenize
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1317 * @param delim the delimiter string (must not be empty)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1318 * @param limit (@c size_t) the maximum number of tokens that shall be returned
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1319 * @return (@c CxStrtokCtx) a new string tokenization context
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1320 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1321 #define cx_strtok(str, delim, limit) \
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
1322 cx_strtok_(cx_strcast(str), cx_strcast(delim), (limit))
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1323
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1324 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1325 * Returns the next token.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1326 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1327 * The token will point to the source string.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1328 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1329 * @param ctx the tokenization context
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1330 * @param token a pointer to memory where the next token shall be stored
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1331 * @return true if successful, false if the limit or the end of the string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1332 * has been reached
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1333 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1334 CX_EXTERN CX_NONNULL CX_NODISCARD CX_ACCESS_W(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1335 bool cx_strtok_next_(CxStrtokCtx *ctx, cxstring *token);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1336
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1337 #ifdef __cplusplus
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1338 CX_CPPDECL cx_strtok_next(CxStrtokCtx *ctx, cxstring *token) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1339 return cx_strtok_next_(ctx, token);
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1340 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1341 CX_CPPDECL cx_strtok_next(CxStrtokCtx *ctx, cxmutstr *token) {
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1342 // Note: this is actually UB - fixed with start_lifetime_as() in C++23
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1343 // but it works on all supported platforms
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1344 return cx_strtok_next_(ctx, reinterpret_cast<cxstring*>(token));
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1345 }
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1346 #else // ! __cplusplus
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1347 /**
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1348 * Returns the next token.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1349 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1350 * The token will point to the source string.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1351 *
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1352 * @param ctx (@c CxStrtokCtx*) the tokenization context
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1353 * @param token a pointer to either a @c cxstring or @c cxmutstr
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1354 * where the next token shall be stored
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1355 * @return true if successful, false if the limit or the end of the string
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1356 * has been reached
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1357 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1358 #define cx_strtok_next(ctx, token) _Generic((token), \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1359 cxstring*: cx_strtok_next_, \
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1360 cxmutstr*: cx_strtok_next_)(ctx, (cxstring*)token)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1361 #endif
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1362
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1363 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1364 * Defines an array of more delimiters for the specified tokenization context.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1365 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1366 * @param ctx the tokenization context
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1367 * @param delim array of more delimiters
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1368 * @param count number of elements in the array
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1369 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1370 CX_EXTERN CX_NONNULL CX_ACCESS_R(2, 3)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1371 void cx_strtok_delim(CxStrtokCtx *ctx, const cxstring *delim, size_t count);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1372
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1373 /* ------------------------------------------------------------------------- *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1374 * string to number conversion functions *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1375 * ------------------------------------------------------------------------- */
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1376
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1377 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1378 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1379 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1380 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1381 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1382 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1383 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1384 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1385 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1386 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1387 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1388 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1389 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1390 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1391 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1392 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1393
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1394 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1395 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1396 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1397 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1398 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1399 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1400 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1401 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1402 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1403 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1404 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1405 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1406 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1407 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1408 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1409 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1410
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1411 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1412 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1413 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1414 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1415 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1416 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1417 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1418 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1419 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1420 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1421 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1422 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1423 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1424 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1425 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1426 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1427
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1428 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1429 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1430 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1431 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1432 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1433 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1434 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1435 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1436 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1437 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1438 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1439 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1440 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1441 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1442 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1443 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1444
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1445 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1446 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1447 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1448 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1449 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1450 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1451 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1452 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1453 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1454 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1455 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1456 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1457 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1458 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1459 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1460 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1461
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1462 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1463 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1464 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1465 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1466 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1467 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1468 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1469 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1470 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1471 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1472 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1473 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1474 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1475 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1476 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1477 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1478
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1479 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1480 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1481 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1482 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1483 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1484 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1485 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1486 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1487 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1488 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1489 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1490 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1491 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1492 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1493 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1494 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1495
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1496 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1497 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1498 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1499 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1500 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1501 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1502 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1503 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1504 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1505 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1506 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1507 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1508 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1509 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1510 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1511 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1512
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1513 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1514 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1515 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1516 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1517 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1518 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1519 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1520 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1521 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1522 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1523 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1524 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1525 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1526 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1527 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1528 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1529
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1530 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1531 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1532 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1533 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1534 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1535 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1536 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1537 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1538 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1539 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1540 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1541 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1542 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1543 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1544 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1545 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1546
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1547 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1548 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1549 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1550 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1551 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1552 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1553 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1554 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1555 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1556 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1557 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1558 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1559 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1560 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1561 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1562 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1563
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1564 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1565 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1566 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1567 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1568 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1569 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1570 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1571 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1572 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1573 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1574 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1575 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1576 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1577 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1578 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1579 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1580
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1581 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1582 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1583 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1584 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1585 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1586 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1587 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1588 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1589 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1590 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1591 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1592 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1593 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1594 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1595 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1596 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1597
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1598 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1599 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1600 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1601 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1602 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1603 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1604 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1605 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1606 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1607 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1608 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1609 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1610 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1611 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1612 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1613 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1614
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1615 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1616 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1617 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1618 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1619 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1620 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1621 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1622 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1623 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1624 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1625 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1626 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1627 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1628 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1629 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1630 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep);
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1631
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1632 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1633 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1634 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1635 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1636 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1637 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1638 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1639 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1640 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1641 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1642 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1643 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1644 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1645 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1646 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1647 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep);
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1648
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1649 /**
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1650 * Converts a string to a number.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1651 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1652 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1653 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1654 * It sets errno to ERANGE when the target datatype is too small.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1655 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1656 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1657 * @param output a pointer to the integer variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1658 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1659 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1660 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1661 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1662 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1663 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1664 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep);
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1665
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1666 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1667 * Converts a string to a single precision floating-point number.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1668 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1669 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1670 * In that case the function sets errno to EINVAL when the reason is an invalid character.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1671 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1672 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1673 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1674 * @param output a pointer to the float variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1675 * @param decsep the decimal separator
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1676 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1677 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1678 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1679 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1680 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1681 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep);
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1682
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1683 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1684 * Converts a string to a double precision floating-point number.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1685 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1686 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1687 * In that case the function sets errno to EINVAL when the reason is an invalid character.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1688 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1689 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1690 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1691 * @param output a pointer to the float variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1692 * @param decsep the decimal separator
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1693 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1694 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1695 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1696 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1697 CX_EXTERN CX_ACCESS_W(2) CX_NONNULL_ARG(2)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
1698 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep);
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1699
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1700 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1701 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1702 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1703 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1704 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1705 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1706 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1707 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1708 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1709 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1710 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1711 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1712 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1713 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1714 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1715
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1716 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1717 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1718 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1719 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1720 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1721 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1722 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1723 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1724 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1725 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1726 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1727 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1728 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1729 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1730 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1731
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1732 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1733 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1734 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1735 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1736 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1737 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1738 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1739 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1740 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1741 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1742 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1743 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1744 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1745 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1746 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1747
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1748 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1749 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1750 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1751 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1752 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1753 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1754 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1755 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1756 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1757 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1758 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1759 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1760 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1761 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1762 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1763
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1764 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1765 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1766 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1767 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1768 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1769 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1770 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1771 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1772 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1773 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1774 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1775 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1776 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1777 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1778 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1779
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1780 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1781 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1782 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1783 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1784 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1785 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1786 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1787 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1788 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1789 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1790 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1791 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1792 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1793 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1794 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1795
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1796 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1797 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1798 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1799 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1800 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1801 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1802 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1803 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1804 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1805 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1806 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1807 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1808 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1809 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1810 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1811
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1812 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1813 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1814 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1815 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1816 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1817 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1818 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1819 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1820 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1821 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1822 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1823 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1824 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1825 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1826 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1827
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1828 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1829 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1830 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1831 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1832 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1833 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1834 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1835 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1836 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1837 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1838 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1839 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1840 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1841 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1842 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1843
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1844 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1845 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1846 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1847 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1848 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1849 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1850 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1851 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1852 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1853 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1854 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1855 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1856 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1857 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1858 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1859
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1860 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1861 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1862 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1863 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1864 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1865 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1866 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1867 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1868 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1869 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1870 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1871 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1872 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1873 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1874 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1875
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1876 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1877 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1878 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1879 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1880 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1881 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1882 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1883 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1884 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1885 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1886 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1887 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1888 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1889 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1890 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1891
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1892 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1893 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1894 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1895 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1896 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1897 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1898 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1899 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1900 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1901 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1902 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1903 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1904 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1905 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1906 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1907
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1908 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1909 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1910 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1911 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1912 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1913 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1914 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1915 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1916 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1917 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1918 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1919 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1920 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1921 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1922 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1923
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1924 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1925 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1926 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1927 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1928 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1929 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1930 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1931 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1932 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1933 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1934 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1935 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1936 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1937 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1938 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1939
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1940 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1941 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1942 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1943 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1944 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1945 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1946 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1947 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1948 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1949 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1950 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1951 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1952 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1953 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1954 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1955
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1956 /**
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1957 * Converts a string to a number.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1958 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1959 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1960 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1961 * It sets errno to ERANGE when the target datatype is too small.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1962 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1963 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1964 * @param output a pointer to the integer variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
1965 * @param base 2, 8, 10, or 16
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1966 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1967 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1968 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1969 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1970 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1971
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1972 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1973 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1974 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1975 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1976 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1977 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1978 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1979 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1980 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1981 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1982 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1983 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1984 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1985 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1986 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1987 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1988 #define cx_strtos(str, output, base) cx_strtos_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1989
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1990 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1991 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1992 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1993 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1994 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1995 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1996 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
1997 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1998 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
1999 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2000 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2001 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2002 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2003 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2004 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2005 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2006 #define cx_strtoi(str, output, base) cx_strtoi_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2007
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2008 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2009 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2010 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2011 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2012 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2013 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2014 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2015 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2016 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2017 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2018 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2019 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2020 * @param base 2, 8, 10, or 16
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2021 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2022 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2023 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2024 #define cx_strtol(str, output, base) cx_strtol_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2025
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2026 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2027 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2028 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2029 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2030 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2031 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2032 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2033 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2034 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2035 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2036 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2037 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2038 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2039 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2040 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2041 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2042 #define cx_strtoll(str, output, base) cx_strtoll_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2043
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2044 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2045 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2046 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2047 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2048 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2049 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2050 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2051 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2052 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2053 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2054 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2055 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2056 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2057 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2058 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2059 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2060 #define cx_strtoi8(str, output, base) cx_strtoi8_lc_(cx_strcast(str), output, base, ",")
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2061
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2062 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2063 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2064 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2065 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2066 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2067 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2068 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2069 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2070 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2071 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2072 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2073 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2074 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2075 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2076 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2077 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2078 #define cx_strtoi16(str, output, base) cx_strtoi16_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2079
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2080 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2081 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2082 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2083 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2084 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2085 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2086 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2087 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2088 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2089 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2090 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2091 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2092 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2093 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2094 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2095 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2096 #define cx_strtoi32(str, output, base) cx_strtoi32_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2097
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2098 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2099 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2100 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2101 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2102 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2103 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2104 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2105 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2106 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2107 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2108 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2109 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2110 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2111 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2112 * @retval non-zero conversion was not possible
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2113 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2114 #define cx_strtoi64(str, output, base) cx_strtoi64_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2115
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2116 /**
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2117 * Converts a string to a number.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2118 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2119 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2120 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2121 * It sets errno to ERANGE when the target datatype is too small.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2122 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2123 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2124 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2125 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2126 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2127 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2128 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2129 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2130 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2131 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2132 #define cx_strtoz(str, output, base) cx_strtoz_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2133
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2134 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2135 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2136 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2137 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2138 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2139 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2140 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2141 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2142 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2143 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2144 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2145 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2146 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2147 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2148 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2149 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2150 #define cx_strtous(str, output, base) cx_strtous_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2151
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2152 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2153 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2154 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2155 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2156 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2157 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2158 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2159 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2160 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2161 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2162 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2163 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2164 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2165 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2166 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2167 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2168 #define cx_strtou(str, output, base) cx_strtou_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2169
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2170 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2171 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2172 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2173 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2174 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2175 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2176 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2177 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2178 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2179 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2180 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2181 * @param output a pointer to the integer variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2182 * @param base 2, 8, 10, or 16
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2183 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2184 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2185 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2186 #define cx_strtoul(str, output, base) cx_strtoul_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2187
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2188 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2189 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2190 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2191 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2192 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2193 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2194 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2195 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2196 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2197 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2198 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2199 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2200 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2201 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2202 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2203 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2204 #define cx_strtoull(str, output, base) cx_strtoull_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2205
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2206 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2207 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2208 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2209 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2210 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2211 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2212 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2213 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2214 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2215 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2216 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2217 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2218 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2219 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2220 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2221 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2222 #define cx_strtou8(str, output, base) cx_strtou8_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2223
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2224 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2225 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2226 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2227 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2228 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2229 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2230 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2231 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2232 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2233 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2234 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2235 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2236 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2237 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2238 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2239 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2240 #define cx_strtou16(str, output, base) cx_strtou16_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2241
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2242 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2243 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2244 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2245 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2246 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2247 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2248 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2249 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2250 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2251 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2252 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2253 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2254 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2255 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2256 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2257 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2258 #define cx_strtou32(str, output, base) cx_strtou32_lc_(cx_strcast(str), output, base, ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2259
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2260 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2261 * Converts a string to a number.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2262 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2263 * The function returns non-zero when conversion is not possible.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2264 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2265 * It sets errno to ERANGE when the target datatype is too small.
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2266 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2267 * The comma character is treated as a group separator and ignored during parsing.
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2268 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2269 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2270 * @param str the string to convert
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2271 * @param output a pointer to the integer variable where the result shall be stored
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2272 * @param base 2, 8, 10, or 16
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2273 * @retval zero success
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2274 * @retval non-zero conversion was not possible
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2275 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2276 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",")
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2277
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2278 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2279 * Converts a string to a single precision floating-point number.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2280 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2281 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2282 * In that case the function sets errno to EINVAL when the reason is an invalid character.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2283 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2284 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2285 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2286 * @param output a pointer to the float variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2287 * @param decsep the decimal separator
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2288 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2289 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2290 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2291 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2292 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep)
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2293
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2294 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2295 * Converts a string to a double precision floating-point number.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2296 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2297 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2298 * In that case the function sets errno to EINVAL when the reason is an invalid character.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2299 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2300 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2301 * @param output a pointer to the double variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2302 * @param decsep the decimal separator
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2303 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2304 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2305 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2306 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2307 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep)
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2308
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2309 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2310 * Converts a string to a single precision floating-point number.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2311 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2312 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2313 * In that case the function sets errno to EINVAL when the reason is an invalid character.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2314 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2315 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2316 * The decimal separator is assumed to be a dot character.
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2317 * The comma character is treated as a group separator and ignored during parsing.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2318 * If you want to choose a different format, use cx_strtof_lc().
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2319 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2320 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2321 * @param output a pointer to the float variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2322 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2323 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2324 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2325 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",")
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2326
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2327 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2328 * Converts a string to a double precision floating-point number.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2329 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2330 * The function returns non-zero when conversion is not possible.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2331 * In that case the function sets errno to EINVAL when the reason is an invalid character.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2332 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2333 * The decimal separator is assumed to be a dot character.
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 629
diff changeset
2334 * The comma character is treated as a group separator and ignored during parsing.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2335 * If you want to choose a different format, use cx_strtof_lc().
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2336 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2337 * @param str the string to convert
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2338 * @param output a pointer to the double variable where the result shall be stored
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2339 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2340 * @retval non-zero conversion was not possible
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
2341 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
2342 #define cx_strtod(str, output) cx_strtod_lc_(cx_strcast(str), output, '.', ",")
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2343
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
2344 #endif //UCX_STRING_H

mercurial