src/cx/string.h

Fri, 17 Oct 2025 21:03:11 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 17 Oct 2025 21:03:11 +0200
changeset 1430
5917ed4e5a79
parent 1426
3a89b31f0724
permissions
-rw-r--r--

minor wording improvements in buffer documentation

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

mercurial