src/cx/string.h

Sun, 28 Dec 2025 14:47:36 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 28 Dec 2025 14:47:36 +0100
changeset 1673
0c338b80e7dd
parent 1672
94360453bce4
child 1674
8b0f162ac88e
permissions
-rw-r--r--

add cx_strcast_m()

relates to #792

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

mercurial