src/cx/string.h

Tue, 30 Dec 2025 13:50:55 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 30 Dec 2025 13:50:55 +0100
changeset 1680
1aa21afb8763
parent 1679
4a08dabe5e8f
permissions
-rw-r--r--

add full generic support for cx_strsplit()

resolves #792

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

mercurial