src/cx/string.h

Mon, 22 Dec 2025 16:21:04 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 22 Dec 2025 16:21:04 +0100
changeset 1654
5ab3fe0b7859
parent 1652
db8299984bfe
permissions
-rw-r--r--

adds cx_bstr() and cx_bstr_m()

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
1297
0811fb9a8dba bring back CX_PRIstr and CX_SFMT macros - resolves #612
Mike Becker <universe@uap-core.de>
parents: 1224
diff changeset
44 /** 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
45 #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
46
0811fb9a8dba bring back CX_PRIstr and CX_SFMT macros - resolves #612
Mike Becker <universe@uap-core.de>
parents: 1224
diff changeset
47 /** 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
48 #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
49
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 /**
806
e06249e09f99 add constant for reading out strstr sbo size - relates to #343
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
51 * 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
52 */
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
53 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
54
e06249e09f99 add constant for reading out strstr sbo size - relates to #343
Mike Becker <universe@uap-core.de>
parents: 759
diff changeset
55 /**
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 * The UCX string structure.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 */
577
26447d59a5ab wrong position of struct identifier
Mike Becker <universe@uap-core.de>
parents: 576
diff changeset
58 struct cx_mutstr_s {
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 * A pointer to the string.
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
61 * @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
62 */
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 char *ptr;
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 /** The length of the string */
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 size_t length;
577
26447d59a5ab wrong position of struct identifier
Mike Becker <universe@uap-core.de>
parents: 576
diff changeset
66 };
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 * A mutable string.
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 typedef struct cx_mutstr_s cxmutstr;
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72
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 * The UCX string structure for immutable (constant) strings.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 */
577
26447d59a5ab wrong position of struct identifier
Mike Becker <universe@uap-core.de>
parents: 576
diff changeset
76 struct cx_string_s {
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 * 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
79 * @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
80 */
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 806
diff changeset
81 const char *ptr;
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 /** The length of the string */
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 size_t length;
577
26447d59a5ab wrong position of struct identifier
Mike Becker <universe@uap-core.de>
parents: 576
diff changeset
84 };
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 * An immutable string.
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 typedef struct cx_string_s cxstring;
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90
583
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
91 /**
645
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
92 * Context for string tokenizing.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
93 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
94 struct cx_strtok_ctx_s {
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
95 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
96 * The string to tokenize.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
97 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
98 cxstring str;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
99 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
100 * The primary delimiter.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
101 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
102 cxstring delim;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
103 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
104 * Optional array of more delimiters.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
105 */
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 806
diff changeset
106 const cxstring *delim_more;
645
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
107 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
108 * Length of the array containing more delimiters.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
109 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
110 size_t delim_more_count;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
111 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
112 * 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
113 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
114 size_t pos;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
115 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
116 * 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
117 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
118 * 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
119 * 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
120 * contains the length of the source string.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
121 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
122 size_t delim_pos;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
123 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
124 * 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
125 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
126 size_t next_pos;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
127 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
128 * The number of already found tokens.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
129 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
130 size_t found;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
131 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
132 * 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
133 */
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
134 size_t limit;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
135 };
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 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
138 * A string tokenizing context.
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 typedef struct cx_strtok_ctx_s CxStrtokCtx;
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
141
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 * 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
144 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
145 * 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
146 *
1334
7763892ed801 allow NULL for creating UCX strings - resolves #683
Mike Becker <universe@uap-core.de>
parents: 1331
diff changeset
147 * 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
148 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
149 * @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
150 * 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
151 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 * 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
153 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
154 * @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
155 * @return the wrapped string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 * @see cx_mutstrn()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 */
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
159 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
160 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
161 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
162 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
163 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
164 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
165 }
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 * 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
169 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
170 * 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
171 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
172 * @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
173 * 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
174 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175 * 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
176 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
177 * @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
178 * @param length the length of the string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 * @return the wrapped string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181 * @see cx_mutstr()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 */
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
183 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
184 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
185 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
186 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
187 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
188 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
189 }
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 * Wraps a string that must be zero-terminated.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
194 * 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
195 *
1334
7763892ed801 allow NULL for creating UCX strings - resolves #683
Mike Becker <universe@uap-core.de>
parents: 1331
diff changeset
196 * 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
197 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
198 * @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
199 * 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
200 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
201 * 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
202 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
203 * @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
204 * @return the wrapped string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
205 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
206 * @see cx_strn()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
207 */
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
208 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
209 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
210 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
211 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
212 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
213 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
214 }
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
215
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
216
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
217 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
218 * 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
219 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
220 * 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
221 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
222 * @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
223 * 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
224 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
225 * 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
226 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
227 * @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
228 * @param length the length of the string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
229 * @return the wrapped string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231 * @see cx_str()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
232 */
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
233 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
234 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
235 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
236 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
237 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
238 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
239 }
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
240
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
241 #ifdef __cplusplus
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
242 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
243 CX_CPPDECL cxstring cx_strcast(cxmutstr str) {
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
244 return cx_strn(str.ptr, str.length);
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
245 }
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
246 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
247 CX_CPPDECL cxstring cx_strcast(cxstring str) {
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
248 return str;
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
249 }
1331
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
250 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
251 CX_CPPDECL cxstring cx_strcast(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
252 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
253 }
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
254 cx_attr_nodiscard
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
255 CX_CPPDECL cxstring cx_strcast(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
256 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
257 }
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
258 extern "C" {
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
259 #else
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
260 /**
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
261 * Internal function, do not use.
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
262 * @param str
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
263 * @return
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
264 * @see cx_strcast()
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
265 */
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
266 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
267 CX_INLINE cxstring cx_strcast_m(cxmutstr str) {
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
268 return (cxstring) {str.ptr, str.length};
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
269 }
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
270 /**
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
271 * Internal function, do not use.
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
272 * @param str
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
273 * @return
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
274 * @see cx_strcast()
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
275 */
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
276 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
277 CX_INLINE cxstring cx_strcast_c(cxstring str) {
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
278 return str;
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
279 }
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
280
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
281 /**
1331
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
282 * 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
283 * @param str
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
284 * @return
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
285 * @see cx_strcast()
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
286 */
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
287 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
288 CX_INLINE cxstring cx_strcast_u(const unsigned 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
289 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
290 }
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
291
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
292 /**
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
293 * 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
294 * @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
295 * @return
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
296 * @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
297 */
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
298 cx_attr_nodiscard
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
299 CX_INLINE cxstring cx_strcast_z(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
300 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
301 }
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
302
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
303 /**
1416
e67caa21d5a7 add unsigned char strings to cx_strcast() and changes documentation
Mike Becker <universe@uap-core.de>
parents: 1334
diff changeset
304 * 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
305 *
e67caa21d5a7 add unsigned char strings to cx_strcast() and changes documentation
Mike Becker <universe@uap-core.de>
parents: 1334
diff changeset
306 * @param str (any supported string type) the string to cast
e67caa21d5a7 add unsigned char strings to cx_strcast() and changes documentation
Mike Becker <universe@uap-core.de>
parents: 1334
diff changeset
307 * @return (@c cxstring) the string wrapped as UCX string
e67caa21d5a7 add unsigned char strings to cx_strcast() and changes documentation
Mike Becker <universe@uap-core.de>
parents: 1334
diff changeset
308 */
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
309 #define cx_strcast(str) _Generic((str), \
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
310 cxmutstr: 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
311 cxstring: cx_strcast_c, \
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
312 const unsigned char*: cx_strcast_u, \
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
313 unsigned char *: cx_strcast_u, \
1331
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
314 const char*: cx_strcast_z, \
02946dc73e6a add support for C-strings in cx_strcast() - resolves #549
Mike Becker <universe@uap-core.de>
parents: 1318
diff changeset
315 char *: cx_strcast_z) (str)
1050
3df63e95921a make cx_strcast() also support cxstring
Mike Becker <universe@uap-core.de>
parents: 1046
diff changeset
316 #endif
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
317
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
318 /**
1318
12fa1d37fe48 allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents: 1313
diff changeset
319 * 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
320 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
321 * 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
322 * 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
323 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
324 * @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
325 * 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
326 * 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
327 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328 * @param str the string to free
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
329 */
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
330 CX_EXPORT void cx_strfree(cxmutstr *str);
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
331
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
332 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
333 * 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
334 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
335 * 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
336 * 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
337 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
338 * @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
339 * 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
340 * 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
341 *
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
342 * @param alloc the allocator
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
343 * @param str the string to free
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
344 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
345 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
346 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
347
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
348 /**
1304
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
349 * Copies a string.
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
350 *
1644
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
351 * Internal function - do not use.
1304
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
352 *
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
353 * @param alloc the allocator
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
354 * @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
355 * @param src the source string
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
356 *
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
357 * @retval zero success
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
358 * @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
359 * @see cx_strcpy_a()
1304
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
360 */
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
361 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
362 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
363
1644
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
364 /**
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
365 * 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
366 *
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
367 * 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
368 * 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
369 *
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
370 * 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
371 *
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
372 * @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
373 * @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
374 * @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
375 * @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
376 * @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
377 */
bbe3199e37fc changes cx_strcpy() and cx_strcpy_a() to accept any string
Mike Becker <universe@uap-core.de>
parents: 1582
diff changeset
378 #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
379
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
380 /**
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
381 * Copies a string.
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
382 *
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
383 * 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
384 * source string, including a zero-terminator.
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
385 *
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
386 * 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
387 *
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
388 * @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
389 * @param src the source string
1304
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
390 * @retval zero success
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
391 * @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
392 */
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
393 #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
394
57e062a4bb05 adds cx_strcpy() and cx_strcpy_a()
Mike Becker <universe@uap-core.de>
parents: 1297
diff changeset
395 /**
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
396 * 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
397 *
1ecf4dbbc60c add some more overflow treatment and make sure to set errno properly
Mike Becker <universe@uap-core.de>
parents: 1001
diff changeset
398 * 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
399 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
400 * @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
401 * specified strings, the behavior is undefined.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
402 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
403 * @param count the total number of specified strings
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
404 * @param ... all strings
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
405 * @return the accumulated length of all strings
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
406 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
407 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
408 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
409
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
410 /**
697
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
411 * Concatenates strings.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
412 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
413 * 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
414 * 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
415 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
416 * 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
417 * 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
418 *
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
419 * If memory allocation fails, the pointer in the returned string will
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
420 * be @c NULL. Depending on the allocator, @c errno might be set.
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
421 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
422 * @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
423 * 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
424 * It is also guaranteed that the returned string is zero-terminated.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
425 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
426 * @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
427 * @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
428 * @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
429 * @param ... all other UCX strings
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
430 * @return the concatenated string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
431 */
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
432 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
433 CX_EXPORT cxmutstr cx_strcat_ma(const CxAllocator *alloc,
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
434 cxmutstr str, size_t count, ...);
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
435
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
436 /**
697
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
437 * Concatenates strings and returns a new string.
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
438 *
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
439 * 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
440 * 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
441 *
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
442 * If memory allocation fails, the pointer in the returned string will
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
443 * be @c NULL. Depending on the allocator, @c errno might be set.
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
444 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
445 * @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
446 * 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
447 * It is also guaranteed that the returned string is zero-terminated.
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
448 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
449 * @param alloc (@c CxAllocator*) the allocator to use
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
450 * @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
451 * @param ... all other UCX strings
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
452 * @return (@c cxmutstr) the concatenated 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
453 */
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
454 #define cx_strcat_a(alloc, count, ...) \
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
455 cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__)
697
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
456
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
457 /**
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
458 * Concatenates strings and returns a new string.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
459 *
1318
12fa1d37fe48 allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents: 1313
diff changeset
460 * 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
461 * 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
462 *
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
463 * If memory allocation fails, the pointer in the returned string will
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
464 * be @c NULL and @c errno might be set.
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
465 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
466 * @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
467 * resulting string.
589
c290f8fd979e add zero-termination guarantees
Mike Becker <universe@uap-core.de>
parents: 584
diff changeset
468 * It is also guaranteed that the returned string is zero-terminated.
c290f8fd979e add zero-termination guarantees
Mike Becker <universe@uap-core.de>
parents: 584
diff changeset
469 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
470 * @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
471 * @param ... all other UCX strings
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
472 * @return (@c cxmutstr) the concatenated string
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
473 */
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
474 #define cx_strcat(count, ...) \
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
475 cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__)
697
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
476
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
477 /**
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
478 * Concatenates strings.
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
479 *
1318
12fa1d37fe48 allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents: 1313
diff changeset
480 * 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
481 * So developers @em must pass the return value to cx_strfree() 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
482 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
483 * 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
484 * 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
485 *
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
486 * If memory allocation fails, the pointer in the returned string will
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
487 * be @c NULL and @c errno might be set.
1001
5c9ec5a0a4ef change cx_strcat variants to allow handling of ENOMEM
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
488 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
489 * @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
490 * 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
491 * It is also guaranteed that the returned string is zero-terminated.
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
492 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
493 * @param str (@c cxmutstr) the string the other strings shall be concatenated to
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
494 * @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
495 * @param ... all other strings
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
496 * @return (@c cxmutstr) the concatenated 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
497 */
ebdce4bf262b add cx_strcat_m() and cx_strcat_ma() for in-place concatenation
Mike Becker <universe@uap-core.de>
parents: 693
diff changeset
498 #define cx_strcat_m(str, count, ...) \
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
499 cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__)
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
500
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
501 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
502 * Returns a substring starting at the specified location.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
503 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
504 * @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
505 * 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
506 * Use cx_strdup() to get a copy.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
507 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
508 * @param string input string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
509 * @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
510 * @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
511 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
512 * @see cx_strsubsl()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
513 * @see cx_strsubs_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
514 * @see cx_strsubsl_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
515 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
516 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
517 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
518
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
519 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
520 * Returns a substring starting at the specified location.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
521 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
522 * 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
523 * 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
524 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
525 * @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
526 * 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
527 * Use cx_strdup() to get a copy.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
528 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
529 * @param string input string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
530 * @param start start location of the substring
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
531 * @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
532 * @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
533 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
534 * @see cx_strsubs()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
535 * @see cx_strsubs_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
536 * @see cx_strsubsl_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
537 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
538 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
539 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
540
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
541 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
542 * Returns a substring starting at the specified location.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
543 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
544 * @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
545 * 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
546 * Use cx_strdup() to get a copy.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
547 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
548 * @param string input string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
549 * @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
550 * @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
551 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
552 * @see cx_strsubsl_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
553 * @see cx_strsubs()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
554 * @see cx_strsubsl()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
555 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
556 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
557 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
558
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 * Returns a substring starting at the specified location.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
561 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
562 * 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
563 * 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
564 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
565 * @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
566 * 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
567 * Use cx_strdup() to get a copy.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
568 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
569 * @param string input string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
570 * @param start start location of the substring
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
571 * @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
572 * @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
573 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
574 * @see cx_strsubs_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
575 * @see cx_strsubs()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
576 * @see cx_strsubsl()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
577 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
578 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
579 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
580
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
581 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
582 * 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
583 * specified character.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
584 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
585 * 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
586 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
587 * @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
588 * @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
589 * @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
590 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
591 * @see cx_strchr_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
592 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
593 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
594 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
595
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
596 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
597 * 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
598 * specified character.
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 * 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
601 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
602 * @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
603 * @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
604 * @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
605 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
606 * @see cx_strchr()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
607 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
608 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
609 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
610
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 * 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
613 * specified character.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
614 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
615 * 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
616 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
617 * @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
618 * @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
619 * @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
620 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
621 * @see cx_strrchr_m()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
622 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
623 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
624 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
625
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
626 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
627 * 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
628 * specified character.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
629 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
630 * 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
631 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
632 * @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
633 * @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
634 * @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
635 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
636 * @see cx_strrchr()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
637 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
638 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
639 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
640
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
641 /**
1646
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
642 * Searches for a specific substring.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
643 *
1646
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
644 * Internal function - do not use.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
645 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
646 * @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
647 * @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
648 * @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
649 * 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
650 * @see cx_strstr()
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
651 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
652 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
653 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
654
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 * 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
657 * specified string.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
658 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
659 * 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
660 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
661 * 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
662 * returned.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
663 *
1646
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
664 * @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
665 * @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
666 * @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
667 * @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
668 * @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
669 */
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
670 #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
671
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
672 /**
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
673 * 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
674 *
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
675 * 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
676 *
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
677 * @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
678 * @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
679 * @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
680 * 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
681 * @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
682 */
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
683 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
684 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
685
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
686 /**
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
687 * 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
688 * 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
689 *
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
690 * 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
691 *
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
692 * 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
693 * returned.
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
694 *
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
695 * @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
696 * @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
697 * @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
698 * @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
699 * @see cx_strstr()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
700 */
1646
85fd3ff8416e add support for any string to cx_strstr() and cx_strstr_m()
Mike Becker <universe@uap-core.de>
parents: 1644
diff changeset
701 #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
702
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
703 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
704 * Splits a given string using a delimiter string.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
705 *
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
706 * 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
707 *
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
708 * @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
709 * @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
710 * @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
711 * @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
712 * @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
713 * @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
714 */
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
715 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
716 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
717 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
718
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
719 /**
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
720 * 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
721 *
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
722 * 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
723 *
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
724 * @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
725 * @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
726 * @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
727 * @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
728 * @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
729 * @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
730 * @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
731 */
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
732 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
733 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
734 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
735 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
736
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
737
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
738 /**
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
739 * 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
740 *
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
741 * Internal function - do not use.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
742 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
743 * @param string the string to split
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
744 * @param delim the delimiter
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
745 * @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
746 * @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
747 * @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
748 * @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
749 */
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
750 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
751 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
752 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
753
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
754 /**
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
755 * 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
756 *
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
757 * 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
758 *
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
759 * @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
760 * @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
761 * @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
762 * @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
763 * @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
764 * @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
765 * @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
766 */
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
767 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
768 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
769 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
770 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
771
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
772 /**
db8299984bfe add support for any string as a delimiter in all cx_strsplit() variants
Mike Becker <universe@uap-core.de>
parents: 1651
diff changeset
773 * 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
774 *
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 * @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
776 * @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
777 *
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 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
779 * @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
780 * @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
781 * @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
782 * @return the actual number of split items
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
783 */
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
784 #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
785 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
786
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
787 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
788 * Splits a given string using a delimiter string.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
789 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
790 * 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
791 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
792 * @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
793 * @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
794 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
795 * @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
796 * @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
797 *
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
798 * @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
799 * @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
800 * @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
801 * @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
802 * @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
803 * array shall be written to
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
804 * @return the actual number of split items
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
805 */
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
806 #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
807 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
808
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
809
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
810 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
811 * Splits a given string using a delimiter string.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
812 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
813 * @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
814 * @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
815 *
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
816 * @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
817 * @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
818 * @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
819 * @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
820 * @return the actual number of split items
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
821 */
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
822 #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
823 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
824
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
825 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
826 * Splits a given string using a delimiter string.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
827 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
828 * 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
829 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
830 * @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
831 * @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
832 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
833 * @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
834 * @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
835 *
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
836 * @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
837 * @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
838 * @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
839 * @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
840 * @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
841 * array shall be written to
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
842 * @return the actual number of split items
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
843 */
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
844 #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
845 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
846
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
847 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
848 * Compares two strings.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
849 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
850 * @param s1 the first string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
851 * @param s2 the second string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
852 * @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
853 * 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
854 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
855 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
856 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
857
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
858 /**
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
859 * 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
860 *
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
861 * @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
862 * @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
863 * @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
864 * 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
865 */
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
866 #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
867
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
868 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
869 * Compares two strings ignoring case.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
870 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
871 * @param s1 the first string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
872 * @param s2 the second string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
873 * @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
874 * 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
875 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
876 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
877 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
878
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
879 /**
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
880 * 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
881 *
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
882 * @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
883 * @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
884 * @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
885 * 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
886 */
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
887 #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
888
657
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
889 /**
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
890 * Compares two strings.
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
891 *
677
b09aae58bba4 refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents: 657
diff changeset
892 * 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
893 *
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
894 * @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
895 * 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
896 *
657
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
897 * @param s1 the first string
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
898 * @param s2 the second string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
899 * @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
900 * 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
901 */
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
902 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
903 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
904
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
905 /**
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
906 * Compares two strings ignoring case.
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
907 *
677
b09aae58bba4 refactoring of collections to make use of destructors in map implementations
Mike Becker <universe@uap-core.de>
parents: 657
diff changeset
908 * 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
909 *
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
910 * @param s1 the first string
3eeadf666d6b add CxListComparator compatible string compare functions
Mike Becker <universe@uap-core.de>
parents: 645
diff changeset
911 * @param s2 the second string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
912 * @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
913 * 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
914 */
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
915 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
916 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
917
576
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 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
920 * Creates a duplicate of the specified string.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
921 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
922 * 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
923 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
924 * @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
925 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
926 * @param allocator the allocator to use
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
927 * @param string the string to duplicate
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
928 * @return a duplicate of the string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
929 * @see cx_strdup()
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
930 */
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
931 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
932 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
933
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
934 /**
578
0b2c0cb280a9 some function can be macros using the default allocator
Mike Becker <universe@uap-core.de>
parents: 577
diff changeset
935 * 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
936 *
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
937 * 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
938 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
939 * @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
940 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
941 * @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
942 * @param string the string to duplicate
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
943 * @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
944 * @see cx_strdup()
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
945 * @see cx_strfree_a()
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
946 */
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
947 #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
948
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
949 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
950 * 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
951 *
1318
12fa1d37fe48 allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents: 1313
diff changeset
952 * 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
953 * 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
954 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
955 * @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
956 *
1127
1fd31909a3f8 removes some unnecessary string functions - fixes #561
Mike Becker <universe@uap-core.de>
parents: 1107
diff changeset
957 * @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
958 * @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
959 * @see cx_strdup_a()
1127
1fd31909a3f8 removes some unnecessary string functions - fixes #561
Mike Becker <universe@uap-core.de>
parents: 1107
diff changeset
960 * @see cx_strfree()
578
0b2c0cb280a9 some function can be macros using the default allocator
Mike Becker <universe@uap-core.de>
parents: 577
diff changeset
961 */
1223
be4c13de7c4f fix cx_strdup() not using cx_strcast()
Mike Becker <universe@uap-core.de>
parents: 1221
diff changeset
962 #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
963
0b2c0cb280a9 some function can be macros using the default allocator
Mike Becker <universe@uap-core.de>
parents: 577
diff changeset
964 /**
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
965 * Omits leading and trailing spaces.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
966 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
967 * @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
968 * must @em not free the returned memory.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
969 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
970 * @param string the string that shall be trimmed
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
971 * @return the trimmed string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
972 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
973 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
974 CX_EXPORT cxstring cx_strtrim(cxstring string);
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
975
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
976 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
977 * Omits leading and trailing spaces.
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
978 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
979 * @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
980 * must @em not free the returned memory.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
981 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
982 * @param string the string that shall be trimmed
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
983 * @return the trimmed string
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
984 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
985 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
986 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
987
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
988 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
989 * 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
990 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
991 * @param string the string to check
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
992 * @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
993 * @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
994 * @c false otherwise
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
995 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
996 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
997 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
998
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
999 /**
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 * 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
1001 *
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
1002 * @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
1003 * @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
1004 * @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
1005 * @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
1006 */
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
1007 #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
1008
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1009 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1010 * 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
1011 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1012 * @param string the string to check
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1013 * @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
1014 * @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
1015 * @c false otherwise
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1016 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
1017 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
1018 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
1019
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
1020 /**
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
1021 * 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
1022 *
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
1023 * @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
1024 * @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
1025 * @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
1026 * @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
1027 */
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
1028 #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
1029
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1030 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1031 * 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
1032 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1033 * @param string the string to check
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1034 * @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
1035 * @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
1036 * @c false otherwise
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1037 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
1038 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
1039 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
1040
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
1041 /**
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
1042 * 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
1043 *
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
1044 * @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
1045 * @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
1046 * @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
1047 * @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
1048 */
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
1049 #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
1050
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1051 /**
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1052 * 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
1053 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1054 * @param string the string to check
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1055 * @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
1056 * @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
1057 * @c false otherwise
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1058 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
1059 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
1060 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
1061
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
1062 /**
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
1063 * 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
1064 *
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
1065 * @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
1066 * @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
1067 * @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
1068 * @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
1069 */
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 #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
1071
1651
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1072
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1073 /**
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1074 * 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
1075 *
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1076 * 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
1077 *
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1078 * @param allocator
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1079 * @param str
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1080 * @param search
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1081 * @param replacement
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1082 * @param replmax
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1083 * @return
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1084 * @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
1085 * @see cx_strreplace()
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1086 * @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
1087 * @see cx_strreplacen()
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1088 */
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1089 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
1090 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
1091 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
1092
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1093 /**
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1094 * Replaces a string with another string.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1095 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1096 * 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
1097 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1098 * 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
1099 * to be zero-terminated.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1100 *
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1101 * 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
1102 * the returned string will be empty.
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1103 *
1651
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1104 * @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
1105 * @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
1106 * @param search the string to search for
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1107 * @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
1108 * @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
1109 * @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
1110 */
1651
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1111 #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
1112 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
1113
578
0b2c0cb280a9 some function can be macros using the default allocator
Mike Becker <universe@uap-core.de>
parents: 577
diff changeset
1114 /**
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1115 * 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
1116 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1117 * 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
1118 *
1318
12fa1d37fe48 allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents: 1313
diff changeset
1119 * 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
1120 * 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
1121 *
0b2c0cb280a9 some function can be macros using the default allocator
Mike Becker <universe@uap-core.de>
parents: 577
diff changeset
1122 * 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
1123 * 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
1124 *
1651
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1125 * @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
1126 * @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
1127 * @param replacement the replacement string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1128 * @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
1129 * @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
1130 */
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1131 #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
1132 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
1133
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1134 /**
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1135 * 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
1136 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1137 * 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
1138 * to be zero-terminated.
583
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1139 *
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1140 * 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
1141 * the returned string will be empty.
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1142 *
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1143 * @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
1144 * @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
1145 * @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
1146 * @param replacement the replacement string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1147 * @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
1148 */
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1149 #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
1150 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
1151
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1152 /**
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1153 * 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
1154 *
1318
12fa1d37fe48 allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents: 1313
diff changeset
1155 * 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
1156 * to be zero-terminated.
583
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1157 *
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1158 * 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
1159 * the returned string will be empty.
0f3c9662f9b5 add tests and missing implementations for strings
Mike Becker <universe@uap-core.de>
parents: 581
diff changeset
1160 *
1651
38b051dea6b1 add support for any string to all cx_strreplace() variants
Mike Becker <universe@uap-core.de>
parents: 1646
diff changeset
1161 * @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
1162 * @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
1163 * @param replacement the replacement string
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1164 * @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
1165 */
1221
304f4f7b37d1 document cx_strreplace() family of functions and improve docstrings
Mike Becker <universe@uap-core.de>
parents: 1193
diff changeset
1166 #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
1167 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
1168
645
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1169 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1170 * Creates a string tokenization context.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1171 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1172 * @param str the string to tokenize
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1173 * @param delim the delimiter (must not be empty)
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1174 * @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
1175 * @return a new string tokenization context
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1176 */
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 926
diff changeset
1177 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
1178 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
1179
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1180 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1181 * Creates a string tokenization context.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1182 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1183 * @param str the string to tokenize
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1184 * @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
1185 * @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
1186 * @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
1187 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1188 #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
1189 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
1190
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1191 /**
645
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1192 * Returns the next token.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1193 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1194 * The token will point to the source string.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1195 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1196 * @param ctx the tokenization context
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1197 * @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
1198 * @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
1199 * has been reached
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1200 */
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_attr_nonnull cx_attr_nodiscard cx_attr_access_w(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
1202 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
1203
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1204 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1205 * Returns the next token of a mutable string.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1206 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1207 * 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
1208 *
1fd31909a3f8 removes some unnecessary string functions - fixes #561
Mike Becker <universe@uap-core.de>
parents: 1107
diff changeset
1209 * @attention
645
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1210 * If the context was not initialized over a mutable string, modifying
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1211 * the data of the returned token is undefined behavior.
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1212 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1213 * @param ctx the tokenization context
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1214 * @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
1215 * @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
1216 * has been reached
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1217 */
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
1218 cx_attr_nonnull cx_attr_nodiscard cx_attr_access_w(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
1219 CX_EXPORT bool cx_strtok_next_m(CxStrtokCtx *ctx, cxmutstr *token);
645
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1220
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1221 /**
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1222 * 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
1223 *
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1224 * @param ctx the tokenization context
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1225 * @param delim array of more delimiters
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1226 * @param count number of elements in the array
ec50abb285ad add strtok API - fixes #220
Mike Becker <universe@uap-core.de>
parents: 589
diff changeset
1227 */
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
1228 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
1229 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
1230
1043
256ea5a36b5a add function prototypes and macros for string conversion function
Mike Becker <universe@uap-core.de>
parents: 1040
diff changeset
1231 /* ------------------------------------------------------------------------- *
256ea5a36b5a add function prototypes and macros for string conversion function
Mike Becker <universe@uap-core.de>
parents: 1040
diff changeset
1232 * 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
1233 * ------------------------------------------------------------------------- */
256ea5a36b5a add function prototypes and macros for string conversion function
Mike Becker <universe@uap-core.de>
parents: 1040
diff changeset
1234
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1235 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1236 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1237 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1238 * 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
1239 * 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
1240 * 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
1241 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1242 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1243 * @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
1244 * @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
1245 * @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
1246 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1247 * @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
1248 */
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
1249 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
1250 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
1251
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1252 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1253 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1254 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1255 * 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
1256 * 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
1257 * 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
1258 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1259 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1260 * @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
1261 * @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
1262 * @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
1263 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1264 * @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
1265 */
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
1266 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
1267 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
1268
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1269 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1270 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1271 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1272 * 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
1273 * 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
1274 * 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
1275 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1276 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1277 * @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
1278 * @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
1279 * @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
1280 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1281 * @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
1282 */
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
1283 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
1284 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
1285
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1286 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1287 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1288 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1289 * 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
1290 * 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
1291 * 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
1292 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1293 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1294 * @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
1295 * @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
1296 * @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
1297 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1298 * @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
1299 */
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
1300 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
1301 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
1302
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1303 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1304 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1305 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1306 * 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
1307 * 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
1308 * 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
1309 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1310 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1311 * @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
1312 * @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
1313 * @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
1314 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1315 * @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
1316 */
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
1317 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
1318 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
1319
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1320 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1321 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1322 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1323 * 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
1324 * 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
1325 * 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
1326 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1327 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1328 * @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
1329 * @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
1330 * @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
1331 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1332 * @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
1333 */
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
1334 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
1335 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
1336
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1337 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1338 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1339 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1340 * 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
1341 * 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
1342 * 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
1343 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1344 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1345 * @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
1346 * @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
1347 * @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
1348 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1349 * @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
1350 */
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
1351 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
1352 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
1353
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1354 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1355 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1356 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1357 * 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
1358 * 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
1359 * 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
1360 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1361 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1362 * @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
1363 * @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
1364 * @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
1365 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1366 * @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
1367 */
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
1368 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
1369 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
1370
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1371 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1372 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1373 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1374 * 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
1375 * 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
1376 * 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
1377 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1378 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1379 * @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
1380 * @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
1381 * @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
1382 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1383 * @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
1384 */
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
1385 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
1386 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
1387
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1388 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1389 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1390 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1391 * 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
1392 * 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
1393 * 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
1394 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1395 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1396 * @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
1397 * @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
1398 * @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
1399 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1400 * @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
1401 */
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
1402 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
1403 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
1404
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1405 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1406 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1407 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1408 * 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
1409 * 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
1410 * 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
1411 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1412 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1413 * @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
1414 * @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
1415 * @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
1416 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1417 * @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
1418 */
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
1419 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
1420 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
1421
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1422 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1423 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1424 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1425 * 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
1426 * 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
1427 * 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
1428 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1429 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1430 * @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
1431 * @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
1432 * @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
1433 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1434 * @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
1435 */
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
1436 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
1437 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
1438
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1439 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1440 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1441 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1442 * 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
1443 * 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
1444 * 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
1445 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1446 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1447 * @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
1448 * @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
1449 * @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
1450 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1451 * @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
1452 */
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
1453 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
1454 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
1455
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1456 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1457 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1458 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1459 * 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
1460 * 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
1461 * 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
1462 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1463 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1464 * @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
1465 * @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
1466 * @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
1467 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1468 * @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
1469 */
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
1470 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
1471 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
1472
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1473 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1474 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1475 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1476 * 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
1477 * 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
1478 * 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
1479 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1480 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1481 * @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
1482 * @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
1483 * @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
1484 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1485 * @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
1486 */
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
1487 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
1488 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
1489
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1490 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1491 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1492 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1493 * 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
1494 * 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
1495 * 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
1496 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1497 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1498 * @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
1499 * @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
1500 * @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
1501 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1502 * @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
1503 */
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
1504 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
1505 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
1506
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1507 /**
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1508 * 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
1509 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1510 * 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
1511 * 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
1512 * 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
1513 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1514 * @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
1515 * @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
1516 * @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
1517 * @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
1518 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1519 * @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
1520 */
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
1521 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
1522 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
1523
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1524 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1525 * 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
1526 *
468c868cc8a8 add attributes to string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1044
diff changeset
1527 * 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
1528 * 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
1529 * 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
1530 *
468c868cc8a8 add attributes to string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1044
diff changeset
1531 * @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
1532 * @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
1533 * @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
1534 * @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
1535 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1536 * @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
1537 */
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
1538 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
1539 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
1540
468c868cc8a8 add attributes to string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1044
diff changeset
1541 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1542 * 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
1543 *
468c868cc8a8 add attributes to string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1044
diff changeset
1544 * 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
1545 * 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
1546 * 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
1547 *
468c868cc8a8 add attributes to string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1044
diff changeset
1548 * @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
1549 * @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
1550 * @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
1551 * @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
1552 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1553 * @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
1554 */
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
1555 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
1556 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
1557
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1558 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1559 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1560 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1561 * 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
1562 * 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
1563 * 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
1564 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1565 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1566 * @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
1567 * @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
1568 * @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
1569 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1570 * @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
1571 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1572 #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
1573
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1574 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1575 * Converts a string to a number.
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 * 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
1578 * 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
1579 * 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
1580 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1581 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1582 * @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
1583 * @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
1584 * @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
1585 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1586 * @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
1587 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1588 #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
1589
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1590 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1591 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1592 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1593 * 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
1594 * 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
1595 * 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
1596 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1597 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1598 * @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
1599 * @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
1600 * @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
1601 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1602 * @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
1603 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1604 #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
1605
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1606 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1607 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1608 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1609 * 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
1610 * 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
1611 * 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
1612 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1613 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1614 * @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
1615 * @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
1616 * @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
1617 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1618 * @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
1619 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1620 #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
1621
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1622 /**
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1623 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1624 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1625 * 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
1626 * 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
1627 * 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
1628 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1629 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1630 * @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
1631 * @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
1632 * @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
1633 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1634 * @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
1635 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1636 #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
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_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
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_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
1669
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1670 /**
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1671 * 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
1672 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1673 * 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
1674 * 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
1675 * 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
1676 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1677 * @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
1678 * @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
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
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1683 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1684 #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
1685
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1686 /**
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
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1699 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1700 #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
1701
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1702 /**
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
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1715 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1716 #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
1717
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1718 /**
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
1107
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1729 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
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_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
1733
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1734 /**
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
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1747 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1748 #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
1749
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1750 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1751 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1752 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1753 * 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
1754 * 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
1755 * 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
1756 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1757 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1758 * @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
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_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
1765
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1766 /**
1134
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
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1779 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1780 #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
1781
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1782 /**
1134
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
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1795 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1796 #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
1797
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1798 /**
1134
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
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1809 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
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_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
1813
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1814 /**
1134
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
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1827 */
1162
e3bb67b72d33 remove dependency to ssize_t - fixes #552
Mike Becker <universe@uap-core.de>
parents: 1134
diff changeset
1828 #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
1829
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1830 /**
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1831 * 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
1832 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1833 * 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
1834 * 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
1835 * 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
1836 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1837 * 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
1838 * 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
1839 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
1840 * @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
1841 * @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
1842 * @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
1843 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
1844 * @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
1845 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1846 #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
1847
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 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1850 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1851 * 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
1852 * 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
1853 * 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
1854 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1855 * 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
1856 * 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
1857 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1858 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1859 * @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
1860 * @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
1861 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1862 * @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
1863 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1864 #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
1865
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1866 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1867 * Converts a string to a number.
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 * 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
1870 * 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
1871 * 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
1872 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1873 * 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
1874 * 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
1875 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1876 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1877 * @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
1878 * @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
1879 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1880 * @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
1881 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1882 #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
1883
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 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1886 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1887 * 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
1888 * 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
1889 * 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
1890 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1891 * 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
1892 * 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
1893 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1894 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1895 * @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
1896 * @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
1897 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1898 * @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
1899 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1900 #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
1901
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1902 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1903 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1904 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1905 * 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
1906 * 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
1907 * 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
1908 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1909 * 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
1910 * 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
1911 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1912 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1913 * @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
1914 * @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
1915 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1916 * @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
1917 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1918 #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
1919
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1920 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1921 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1922 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1923 * 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
1924 * 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
1925 * 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
1926 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1927 * 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
1928 * 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
1929 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1930 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1931 * @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
1932 * @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
1933 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1934 * @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
1935 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1936 #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
1937
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1938 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1939 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1940 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1941 * 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
1942 * 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
1943 * 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
1944 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1945 * 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
1946 * 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
1947 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1948 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1949 * @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
1950 * @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
1951 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1952 * @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
1953 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1954 #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
1955
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1956 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1957 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1958 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1959 * 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
1960 * 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
1961 * 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
1962 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1963 * 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
1964 * 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
1965 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1966 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1967 * @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
1968 * @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
1969 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1970 * @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
1971 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1972 #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
1973
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1974 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1975 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1976 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1977 * 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
1978 * 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
1979 * 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
1980 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1981 * 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
1982 * 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
1983 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1984 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1985 * @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
1986 * @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
1987 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1988 * @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
1989 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1990 #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
1991
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1992 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1993 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1994 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
1995 * 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
1996 * 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
1997 * 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
1998 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
1999 * 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
2000 * 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
2001 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2002 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2003 * @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
2004 * @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
2005 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2006 * @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
2007 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2008 #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
2009
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2010 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2011 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2012 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2013 * 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
2014 * 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
2015 * 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
2016 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2017 * 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
2018 * 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
2019 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2020 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2021 * @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
2022 * @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
2023 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2024 * @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
2025 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2026 #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
2027
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2028 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2029 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2030 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2031 * 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
2032 * 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
2033 * 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
2034 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2035 * 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
2036 * 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
2037 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2038 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2039 * @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
2040 * @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
2041 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2042 * @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
2043 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2044 #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
2045
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2046 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2047 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2048 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2049 * 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
2050 * 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
2051 * 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
2052 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2053 * 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
2054 * 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
2055 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2056 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2057 * @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
2058 * @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
2059 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2060 * @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
2061 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2062 #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
2063
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2064 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2065 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2066 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2067 * 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
2068 * 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
2069 * 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
2070 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2071 * 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
2072 * 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
2073 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2074 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2075 * @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
2076 * @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
2077 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2078 * @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
2079 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2080 #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
2081
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2082 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2083 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2084 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2085 * 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
2086 * 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
2087 * 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
2088 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2089 * 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
2090 * 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
2091 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2092 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2093 * @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
2094 * @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
2095 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2096 * @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
2097 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2098 #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
2099
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2100 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2101 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2102 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2103 * 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
2104 * 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
2105 * 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
2106 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2107 * 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
2108 * 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
2109 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2110 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2111 * @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
2112 * @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
2113 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2114 * @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
2115 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2116 #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
2117
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2118 /**
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2119 * Converts a string to a number.
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2120 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2121 * 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
2122 * 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
2123 * 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
2124 *
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2125 * 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
2126 * 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
2127 *
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2128 * @param str the string to convert
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2129 * @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
2130 * @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
2131 * @retval zero success
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2132 * @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
2133 */
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2134 #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
2135
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2136 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2137 * 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
2138 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2139 * 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
2140 * 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
2141 * 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
2142 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2143 * @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
2144 * @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
2145 * @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
2146 * @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
2147 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
2148 * @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
2149 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2150 #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
2151
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2152 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2153 * 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
2154 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2155 * 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
2156 * 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
2157 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2158 * @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
2159 * @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
2160 * @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
2161 * @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
2162 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
2163 * @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
2164 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2165 #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
2166
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2167 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2168 * 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
2169 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2170 * 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
2171 * 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
2172 * 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
2173 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2174 * 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
2175 * 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
2176 * 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
2177 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2178 * @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
2179 * @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
2180 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
2181 * @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
2182 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2183 #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
2184
1044
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2185 /**
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1416
diff changeset
2186 * 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
2187 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2188 * 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
2189 * 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
2190 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2191 * 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
2192 * 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
2193 * 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
2194 *
776001e4cc96 add documentation for string to number conversion functions
Mike Becker <universe@uap-core.de>
parents: 1043
diff changeset
2195 * @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
2196 * @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
2197 * @retval zero success
9d77c7a99441 refine docs for string.h - issue #548
Mike Becker <universe@uap-core.de>
parents: 1050
diff changeset
2198 * @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
2199 */
1134
60edcd57d54c fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents: 1127
diff changeset
2200 #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
2201
576
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2202 #ifdef __cplusplus
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2203 } // extern "C"
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2204 #endif
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2205
ba0c4ff6698e first proposal for the string header
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2206 #endif //UCX_STRING_H

mercurial