src/cx/string.h

changeset 1424
563033aa998c
parent 1416
e67caa21d5a7
equal deleted inserted replaced
1423:9a72258446cd 1424:563033aa998c
110 /** 110 /**
111 * Position of the currently active token in the source string. 111 * Position of the currently active token in the source string.
112 */ 112 */
113 size_t pos; 113 size_t pos;
114 /** 114 /**
115 * Position of next delimiter in the source string. 115 * Position of the next delimiter in the source string.
116 * 116 *
117 * If the tokenizer has not yet returned a token, the content of this field 117 * If the tokenizer has not yet returned a token, the content of this field
118 * is undefined. If the tokenizer reached the end of the string, this field 118 * is undefined. If the tokenizer reaches the end of the string, this field
119 * contains the length of the source string. 119 * contains the length of the source string.
120 */ 120 */
121 size_t delim_pos; 121 size_t delim_pos;
122 /** 122 /**
123 * The position of the next token in the source string. 123 * The position of the next token in the source string.
172 * @note the wrapped string will share the specified pointer to the string. 172 * @note the wrapped string will share the specified pointer to the string.
173 * If you do want a copy, use cx_strdup() on the return value of this function. 173 * If you do want a copy, use cx_strdup() on the return value of this function.
174 * 174 *
175 * If you need to wrap a constant string, use cx_str(). 175 * If you need to wrap a constant string, use cx_str().
176 * 176 *
177 * @param cstring the string to wrap, must be zero-terminated 177 * @param cstring the string to wrap (must be zero-terminated)
178 * @return the wrapped string 178 * @return the wrapped string
179 * 179 *
180 * @see cx_mutstrn() 180 * @see cx_mutstrn()
181 */ 181 */
182 cx_attr_nodiscard 182 cx_attr_nodiscard
218 * @note the wrapped string will share the specified pointer to the string. 218 * @note the wrapped string will share the specified pointer to the string.
219 * If you do want a copy, use cx_strdup() on the return value of this function. 219 * If you do want a copy, use cx_strdup() on the return value of this function.
220 * 220 *
221 * If you need to wrap a non-constant string, use cx_mutstr(). 221 * If you need to wrap a non-constant string, use cx_mutstr().
222 * 222 *
223 * @param cstring the string to wrap, must be zero-terminated 223 * @param cstring the string to wrap (must be zero-terminated)
224 * @return the wrapped string 224 * @return the wrapped string
225 * 225 *
226 * @see cx_strn() 226 * @see cx_strn()
227 */ 227 */
228 cx_attr_nodiscard 228 cx_attr_nodiscard
319 #endif 319 #endif
320 320
321 /** 321 /**
322 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. 322 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function.
323 * 323 *
324 * The pointer in the struct is set to @c NULL and the length is set to zero 324 * The pointer in the struct is set to @c NULL, and the length is set to zero,
325 * which means that this function protects you against double-free. 325 * which means that this function protects you against double-free.
326 * 326 *
327 * @note There is no implementation for cxstring, because it is unlikely that 327 * @note There is no implementation for cxstring, because it is unlikely that
328 * you ever have a <code>const char*</code> you are really supposed to free. 328 * you ever have a <code>const char*</code> you are really supposed to free.
329 * If you encounter such situation, you should double-check your code. 329 * If you encounter such a situation, you should double-check your code.
330 * 330 *
331 * @param str the string to free 331 * @param str the string to free
332 */ 332 */
333 cx_attr_export 333 cx_attr_export
334 void cx_strfree(cxmutstr *str); 334 void cx_strfree(cxmutstr *str);
335 335
336 /** 336 /**
337 * Passes the pointer in this string to the allocators free function. 337 * Passes the pointer in this string to the allocator's free function.
338 * 338 *
339 * The pointer in the struct is set to @c NULL and the length is set to zero 339 * The pointer in the struct is set to @c NULL, and the length is set to zero,
340 * which means that this function protects you against double-free. 340 * which means that this function protects you against double-free.
341 * 341 *
342 * @note There is no implementation for cxstring, because it is unlikely that 342 * @note There is no implementation for cxstring, because it is unlikely that
343 * you ever have a <code>const char*</code> you are really supposed to free. 343 * you ever have a <code>const char*</code> you are really supposed to free.
344 * If you encounter such situation, you should double-check your code. 344 * If you encounter such a situation, you should double-check your code.
345 * 345 *
346 * @param alloc the allocator 346 * @param alloc the allocator
347 * @param str the string to free 347 * @param str the string to free
348 */ 348 */
349 cx_attr_nonnull_arg(1) 349 cx_attr_nonnull_arg(1)
981 cx_attr_nodiscard 981 cx_attr_nodiscard
982 cx_attr_export 982 cx_attr_export
983 cxmutstr cx_strtrim_m(cxmutstr string); 983 cxmutstr cx_strtrim_m(cxmutstr string);
984 984
985 /** 985 /**
986 * Checks, if a string has a specific prefix. 986 * Checks if a string has a specific prefix.
987 * 987 *
988 * @param string the string to check 988 * @param string the string to check
989 * @param prefix the prefix the string should have 989 * @param prefix the prefix the string should have
990 * @return @c true, if and only if the string has the specified prefix, 990 * @return @c true, if and only if the string has the specified prefix,
991 * @c false otherwise 991 * @c false otherwise
996 cxstring string, 996 cxstring string,
997 cxstring prefix 997 cxstring prefix
998 ); 998 );
999 999
1000 /** 1000 /**
1001 * Checks, if a string has a specific suffix. 1001 * Checks if a string has a specific suffix.
1002 * 1002 *
1003 * @param string the string to check 1003 * @param string the string to check
1004 * @param suffix the suffix the string should have 1004 * @param suffix the suffix the string should have
1005 * @return @c true, if and only if the string has the specified suffix, 1005 * @return @c true, if and only if the string has the specified suffix,
1006 * @c false otherwise 1006 * @c false otherwise
1011 cxstring string, 1011 cxstring string,
1012 cxstring suffix 1012 cxstring suffix
1013 ); 1013 );
1014 1014
1015 /** 1015 /**
1016 * Checks, if a string has a specific prefix, ignoring the case. 1016 * Checks if a string has a specific prefix, ignoring the case.
1017 * 1017 *
1018 * @param string the string to check 1018 * @param string the string to check
1019 * @param prefix the prefix the string should have 1019 * @param prefix the prefix the string should have
1020 * @return @c true, if and only if the string has the specified prefix, 1020 * @return @c true, if and only if the string has the specified prefix,
1021 * @c false otherwise 1021 * @c false otherwise
1043 ); 1043 );
1044 1044
1045 /** 1045 /**
1046 * Replaces a string with another string. 1046 * Replaces a string with another string.
1047 * 1047 *
1048 * Replaces at most @p replmax occurrences. 1048 * The function replaces at most @p replmax occurrences.
1049 * 1049 *
1050 * The returned string will be allocated by @p allocator and is guaranteed 1050 * The returned string will be allocated by @p allocator and is guaranteed
1051 * to be zero-terminated. 1051 * to be zero-terminated.
1052 * 1052 *
1053 * If allocation fails, or the input string is empty, 1053 * If allocation fails, or the input string is empty,
1072 ); 1072 );
1073 1073
1074 /** 1074 /**
1075 * Replaces a string with another string. 1075 * Replaces a string with another string.
1076 * 1076 *
1077 * Replaces at most @p replmax occurrences. 1077 * The function replaces at most @p replmax occurrences.
1078 * 1078 *
1079 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed 1079 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed
1080 * to be zero-terminated. 1080 * to be zero-terminated.
1081 * 1081 *
1082 * If allocation fails, or the input string is empty, 1082 * If allocation fails, or the input string is empty,
1223 * It sets errno to ERANGE when the target datatype is too small. 1223 * It sets errno to ERANGE when the target datatype is too small.
1224 * 1224 *
1225 * @param str the string to convert 1225 * @param str the string to convert
1226 * @param output a pointer to the integer variable where the result shall be stored 1226 * @param output a pointer to the integer variable where the result shall be stored
1227 * @param base 2, 8, 10, or 16 1227 * @param base 2, 8, 10, or 16
1228 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1228 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1229 * @retval zero success 1229 * @retval zero success
1230 * @retval non-zero conversion was not possible 1230 * @retval non-zero conversion was not possible
1231 */ 1231 */
1232 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1232 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1233 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep); 1233 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep);
1240 * It sets errno to ERANGE when the target datatype is too small. 1240 * It sets errno to ERANGE when the target datatype is too small.
1241 * 1241 *
1242 * @param str the string to convert 1242 * @param str the string to convert
1243 * @param output a pointer to the integer variable where the result shall be stored 1243 * @param output a pointer to the integer variable where the result shall be stored
1244 * @param base 2, 8, 10, or 16 1244 * @param base 2, 8, 10, or 16
1245 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1245 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1246 * @retval zero success 1246 * @retval zero success
1247 * @retval non-zero conversion was not possible 1247 * @retval non-zero conversion was not possible
1248 */ 1248 */
1249 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1249 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1250 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep); 1250 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep);
1257 * It sets errno to ERANGE when the target datatype is too small. 1257 * It sets errno to ERANGE when the target datatype is too small.
1258 * 1258 *
1259 * @param str the string to convert 1259 * @param str the string to convert
1260 * @param output a pointer to the integer variable where the result shall be stored 1260 * @param output a pointer to the integer variable where the result shall be stored
1261 * @param base 2, 8, 10, or 16 1261 * @param base 2, 8, 10, or 16
1262 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1262 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1263 * @retval zero success 1263 * @retval zero success
1264 * @retval non-zero conversion was not possible 1264 * @retval non-zero conversion was not possible
1265 */ 1265 */
1266 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1266 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1267 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep); 1267 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep);
1274 * It sets errno to ERANGE when the target datatype is too small. 1274 * It sets errno to ERANGE when the target datatype is too small.
1275 * 1275 *
1276 * @param str the string to convert 1276 * @param str the string to convert
1277 * @param output a pointer to the integer variable where the result shall be stored 1277 * @param output a pointer to the integer variable where the result shall be stored
1278 * @param base 2, 8, 10, or 16 1278 * @param base 2, 8, 10, or 16
1279 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1279 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1280 * @retval zero success 1280 * @retval zero success
1281 * @retval non-zero conversion was not possible 1281 * @retval non-zero conversion was not possible
1282 */ 1282 */
1283 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1283 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1284 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep); 1284 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep);
1291 * It sets errno to ERANGE when the target datatype is too small. 1291 * It sets errno to ERANGE when the target datatype is too small.
1292 * 1292 *
1293 * @param str the string to convert 1293 * @param str the string to convert
1294 * @param output a pointer to the integer variable where the result shall be stored 1294 * @param output a pointer to the integer variable where the result shall be stored
1295 * @param base 2, 8, 10, or 16 1295 * @param base 2, 8, 10, or 16
1296 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1296 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1297 * @retval zero success 1297 * @retval zero success
1298 * @retval non-zero conversion was not possible 1298 * @retval non-zero conversion was not possible
1299 */ 1299 */
1300 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1300 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1301 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep); 1301 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep);
1308 * It sets errno to ERANGE when the target datatype is too small. 1308 * It sets errno to ERANGE when the target datatype is too small.
1309 * 1309 *
1310 * @param str the string to convert 1310 * @param str the string to convert
1311 * @param output a pointer to the integer variable where the result shall be stored 1311 * @param output a pointer to the integer variable where the result shall be stored
1312 * @param base 2, 8, 10, or 16 1312 * @param base 2, 8, 10, or 16
1313 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1313 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1314 * @retval zero success 1314 * @retval zero success
1315 * @retval non-zero conversion was not possible 1315 * @retval non-zero conversion was not possible
1316 */ 1316 */
1317 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1317 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1318 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep); 1318 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep);
1325 * It sets errno to ERANGE when the target datatype is too small. 1325 * It sets errno to ERANGE when the target datatype is too small.
1326 * 1326 *
1327 * @param str the string to convert 1327 * @param str the string to convert
1328 * @param output a pointer to the integer variable where the result shall be stored 1328 * @param output a pointer to the integer variable where the result shall be stored
1329 * @param base 2, 8, 10, or 16 1329 * @param base 2, 8, 10, or 16
1330 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1330 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1331 * @retval zero success 1331 * @retval zero success
1332 * @retval non-zero conversion was not possible 1332 * @retval non-zero conversion was not possible
1333 */ 1333 */
1334 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1334 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1335 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep); 1335 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep);
1342 * It sets errno to ERANGE when the target datatype is too small. 1342 * It sets errno to ERANGE when the target datatype is too small.
1343 * 1343 *
1344 * @param str the string to convert 1344 * @param str the string to convert
1345 * @param output a pointer to the integer variable where the result shall be stored 1345 * @param output a pointer to the integer variable where the result shall be stored
1346 * @param base 2, 8, 10, or 16 1346 * @param base 2, 8, 10, or 16
1347 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1347 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1348 * @retval zero success 1348 * @retval zero success
1349 * @retval non-zero conversion was not possible 1349 * @retval non-zero conversion was not possible
1350 */ 1350 */
1351 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1351 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1352 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep); 1352 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep);
1359 * It sets errno to ERANGE when the target datatype is too small. 1359 * It sets errno to ERANGE when the target datatype is too small.
1360 * 1360 *
1361 * @param str the string to convert 1361 * @param str the string to convert
1362 * @param output a pointer to the integer variable where the result shall be stored 1362 * @param output a pointer to the integer variable where the result shall be stored
1363 * @param base 2, 8, 10, or 16 1363 * @param base 2, 8, 10, or 16
1364 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1364 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1365 * @retval zero success 1365 * @retval zero success
1366 * @retval non-zero conversion was not possible 1366 * @retval non-zero conversion was not possible
1367 */ 1367 */
1368 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1368 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1369 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep); 1369 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep);
1376 * It sets errno to ERANGE when the target datatype is too small. 1376 * It sets errno to ERANGE when the target datatype is too small.
1377 * 1377 *
1378 * @param str the string to convert 1378 * @param str the string to convert
1379 * @param output a pointer to the integer variable where the result shall be stored 1379 * @param output a pointer to the integer variable where the result shall be stored
1380 * @param base 2, 8, 10, or 16 1380 * @param base 2, 8, 10, or 16
1381 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1381 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1382 * @retval zero success 1382 * @retval zero success
1383 * @retval non-zero conversion was not possible 1383 * @retval non-zero conversion was not possible
1384 */ 1384 */
1385 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1385 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1386 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep); 1386 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep);
1393 * It sets errno to ERANGE when the target datatype is too small. 1393 * It sets errno to ERANGE when the target datatype is too small.
1394 * 1394 *
1395 * @param str the string to convert 1395 * @param str the string to convert
1396 * @param output a pointer to the integer variable where the result shall be stored 1396 * @param output a pointer to the integer variable where the result shall be stored
1397 * @param base 2, 8, 10, or 16 1397 * @param base 2, 8, 10, or 16
1398 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1398 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1399 * @retval zero success 1399 * @retval zero success
1400 * @retval non-zero conversion was not possible 1400 * @retval non-zero conversion was not possible
1401 */ 1401 */
1402 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1402 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1403 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep); 1403 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep);
1410 * It sets errno to ERANGE when the target datatype is too small. 1410 * It sets errno to ERANGE when the target datatype is too small.
1411 * 1411 *
1412 * @param str the string to convert 1412 * @param str the string to convert
1413 * @param output a pointer to the integer variable where the result shall be stored 1413 * @param output a pointer to the integer variable where the result shall be stored
1414 * @param base 2, 8, 10, or 16 1414 * @param base 2, 8, 10, or 16
1415 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1415 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1416 * @retval zero success 1416 * @retval zero success
1417 * @retval non-zero conversion was not possible 1417 * @retval non-zero conversion was not possible
1418 */ 1418 */
1419 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1419 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1420 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep); 1420 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep);
1427 * It sets errno to ERANGE when the target datatype is too small. 1427 * It sets errno to ERANGE when the target datatype is too small.
1428 * 1428 *
1429 * @param str the string to convert 1429 * @param str the string to convert
1430 * @param output a pointer to the integer variable where the result shall be stored 1430 * @param output a pointer to the integer variable where the result shall be stored
1431 * @param base 2, 8, 10, or 16 1431 * @param base 2, 8, 10, or 16
1432 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1432 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1433 * @retval zero success 1433 * @retval zero success
1434 * @retval non-zero conversion was not possible 1434 * @retval non-zero conversion was not possible
1435 */ 1435 */
1436 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1436 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1437 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep); 1437 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep);
1444 * It sets errno to ERANGE when the target datatype is too small. 1444 * It sets errno to ERANGE when the target datatype is too small.
1445 * 1445 *
1446 * @param str the string to convert 1446 * @param str the string to convert
1447 * @param output a pointer to the integer variable where the result shall be stored 1447 * @param output a pointer to the integer variable where the result shall be stored
1448 * @param base 2, 8, 10, or 16 1448 * @param base 2, 8, 10, or 16
1449 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1449 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1450 * @retval zero success 1450 * @retval zero success
1451 * @retval non-zero conversion was not possible 1451 * @retval non-zero conversion was not possible
1452 */ 1452 */
1453 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1453 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1454 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep); 1454 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep);
1461 * It sets errno to ERANGE when the target datatype is too small. 1461 * It sets errno to ERANGE when the target datatype is too small.
1462 * 1462 *
1463 * @param str the string to convert 1463 * @param str the string to convert
1464 * @param output a pointer to the integer variable where the result shall be stored 1464 * @param output a pointer to the integer variable where the result shall be stored
1465 * @param base 2, 8, 10, or 16 1465 * @param base 2, 8, 10, or 16
1466 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1466 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1467 * @retval zero success 1467 * @retval zero success
1468 * @retval non-zero conversion was not possible 1468 * @retval non-zero conversion was not possible
1469 */ 1469 */
1470 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1470 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1471 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep); 1471 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep);
1478 * It sets errno to ERANGE when the target datatype is too small. 1478 * It sets errno to ERANGE when the target datatype is too small.
1479 * 1479 *
1480 * @param str the string to convert 1480 * @param str the string to convert
1481 * @param output a pointer to the integer variable where the result shall be stored 1481 * @param output a pointer to the integer variable where the result shall be stored
1482 * @param base 2, 8, 10, or 16 1482 * @param base 2, 8, 10, or 16
1483 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1483 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1484 * @retval zero success 1484 * @retval zero success
1485 * @retval non-zero conversion was not possible 1485 * @retval non-zero conversion was not possible
1486 */ 1486 */
1487 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1487 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1488 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep); 1488 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep);
1495 * It sets errno to ERANGE when the target datatype is too small. 1495 * It sets errno to ERANGE when the target datatype is too small.
1496 * 1496 *
1497 * @param str the string to convert 1497 * @param str the string to convert
1498 * @param output a pointer to the integer variable where the result shall be stored 1498 * @param output a pointer to the integer variable where the result shall be stored
1499 * @param base 2, 8, 10, or 16 1499 * @param base 2, 8, 10, or 16
1500 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1500 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1501 * @retval zero success 1501 * @retval zero success
1502 * @retval non-zero conversion was not possible 1502 * @retval non-zero conversion was not possible
1503 */ 1503 */
1504 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1504 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1505 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep); 1505 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep);
1506 1506
1507 /** 1507 /**
1508 * Converts a string to a single precision floating point number. 1508 * Converts a string to a single precision floating-point number.
1509 * 1509 *
1510 * The function returns non-zero when conversion is not possible. 1510 * The function returns non-zero when conversion is not possible.
1511 * In that case the function sets errno to EINVAL when the reason is an invalid character. 1511 * In that case the function sets errno to EINVAL when the reason is an invalid character.
1512 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 1512 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
1513 * 1513 *
1514 * @param str the string to convert 1514 * @param str the string to convert
1515 * @param output a pointer to the float variable where the result shall be stored 1515 * @param output a pointer to the float variable where the result shall be stored
1516 * @param decsep the decimal separator 1516 * @param decsep the decimal separator
1517 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1517 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1518 * @retval zero success 1518 * @retval zero success
1519 * @retval non-zero conversion was not possible 1519 * @retval non-zero conversion was not possible
1520 */ 1520 */
1521 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1521 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1522 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep); 1522 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep);
1523 1523
1524 /** 1524 /**
1525 * Converts a string to a double precision floating point number. 1525 * Converts a string to a double precision floating-point number.
1526 * 1526 *
1527 * The function returns non-zero when conversion is not possible. 1527 * The function returns non-zero when conversion is not possible.
1528 * In that case the function sets errno to EINVAL when the reason is an invalid character. 1528 * In that case the function sets errno to EINVAL when the reason is an invalid character.
1529 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 1529 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
1530 * 1530 *
1531 * @param str the string to convert 1531 * @param str the string to convert
1532 * @param output a pointer to the float variable where the result shall be stored 1532 * @param output a pointer to the float variable where the result shall be stored
1533 * @param decsep the decimal separator 1533 * @param decsep the decimal separator
1534 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1534 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1535 * @retval zero success 1535 * @retval zero success
1536 * @retval non-zero conversion was not possible 1536 * @retval non-zero conversion was not possible
1537 */ 1537 */
1538 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1538 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1539 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep); 1539 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep);
1546 * It sets errno to ERANGE when the target datatype is too small. 1546 * It sets errno to ERANGE when the target datatype is too small.
1547 * 1547 *
1548 * @param str the string to convert 1548 * @param str the string to convert
1549 * @param output a pointer to the integer variable where the result shall be stored 1549 * @param output a pointer to the integer variable where the result shall be stored
1550 * @param base 2, 8, 10, or 16 1550 * @param base 2, 8, 10, or 16
1551 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1551 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1552 * @retval zero success 1552 * @retval zero success
1553 * @retval non-zero conversion was not possible 1553 * @retval non-zero conversion was not possible
1554 */ 1554 */
1555 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep) 1555 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep)
1556 1556
1562 * It sets errno to ERANGE when the target datatype is too small. 1562 * It sets errno to ERANGE when the target datatype is too small.
1563 * 1563 *
1564 * @param str the string to convert 1564 * @param str the string to convert
1565 * @param output a pointer to the integer variable where the result shall be stored 1565 * @param output a pointer to the integer variable where the result shall be stored
1566 * @param base 2, 8, 10, or 16 1566 * @param base 2, 8, 10, or 16
1567 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1567 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1568 * @retval zero success 1568 * @retval zero success
1569 * @retval non-zero conversion was not possible 1569 * @retval non-zero conversion was not possible
1570 */ 1570 */
1571 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep) 1571 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep)
1572 1572
1578 * It sets errno to ERANGE when the target datatype is too small. 1578 * It sets errno to ERANGE when the target datatype is too small.
1579 * 1579 *
1580 * @param str the string to convert 1580 * @param str the string to convert
1581 * @param output a pointer to the integer variable where the result shall be stored 1581 * @param output a pointer to the integer variable where the result shall be stored
1582 * @param base 2, 8, 10, or 16 1582 * @param base 2, 8, 10, or 16
1583 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1583 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1584 * @retval zero success 1584 * @retval zero success
1585 * @retval non-zero conversion was not possible 1585 * @retval non-zero conversion was not possible
1586 */ 1586 */
1587 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep) 1587 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep)
1588 1588
1594 * It sets errno to ERANGE when the target datatype is too small. 1594 * It sets errno to ERANGE when the target datatype is too small.
1595 * 1595 *
1596 * @param str the string to convert 1596 * @param str the string to convert
1597 * @param output a pointer to the integer variable where the result shall be stored 1597 * @param output a pointer to the integer variable where the result shall be stored
1598 * @param base 2, 8, 10, or 16 1598 * @param base 2, 8, 10, or 16
1599 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1599 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1600 * @retval zero success 1600 * @retval zero success
1601 * @retval non-zero conversion was not possible 1601 * @retval non-zero conversion was not possible
1602 */ 1602 */
1603 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep) 1603 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep)
1604 1604
1610 * It sets errno to ERANGE when the target datatype is too small. 1610 * It sets errno to ERANGE when the target datatype is too small.
1611 * 1611 *
1612 * @param str the string to convert 1612 * @param str the string to convert
1613 * @param output a pointer to the integer variable where the result shall be stored 1613 * @param output a pointer to the integer variable where the result shall be stored
1614 * @param base 2, 8, 10, or 16 1614 * @param base 2, 8, 10, or 16
1615 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1615 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1616 * @retval zero success 1616 * @retval zero success
1617 * @retval non-zero conversion was not possible 1617 * @retval non-zero conversion was not possible
1618 */ 1618 */
1619 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep) 1619 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep)
1620 1620
1626 * It sets errno to ERANGE when the target datatype is too small. 1626 * It sets errno to ERANGE when the target datatype is too small.
1627 * 1627 *
1628 * @param str the string to convert 1628 * @param str the string to convert
1629 * @param output a pointer to the integer variable where the result shall be stored 1629 * @param output a pointer to the integer variable where the result shall be stored
1630 * @param base 2, 8, 10, or 16 1630 * @param base 2, 8, 10, or 16
1631 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1631 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1632 * @retval zero success 1632 * @retval zero success
1633 * @retval non-zero conversion was not possible 1633 * @retval non-zero conversion was not possible
1634 */ 1634 */
1635 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep) 1635 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep)
1636 1636
1642 * It sets errno to ERANGE when the target datatype is too small. 1642 * It sets errno to ERANGE when the target datatype is too small.
1643 * 1643 *
1644 * @param str the string to convert 1644 * @param str the string to convert
1645 * @param output a pointer to the integer variable where the result shall be stored 1645 * @param output a pointer to the integer variable where the result shall be stored
1646 * @param base 2, 8, 10, or 16 1646 * @param base 2, 8, 10, or 16
1647 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1647 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1648 * @retval zero success 1648 * @retval zero success
1649 * @retval non-zero conversion was not possible 1649 * @retval non-zero conversion was not possible
1650 */ 1650 */
1651 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep) 1651 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep)
1652 1652
1658 * It sets errno to ERANGE when the target datatype is too small. 1658 * It sets errno to ERANGE when the target datatype is too small.
1659 * 1659 *
1660 * @param str the string to convert 1660 * @param str the string to convert
1661 * @param output a pointer to the integer variable where the result shall be stored 1661 * @param output a pointer to the integer variable where the result shall be stored
1662 * @param base 2, 8, 10, or 16 1662 * @param base 2, 8, 10, or 16
1663 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1663 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1664 * @retval zero success 1664 * @retval zero success
1665 * @retval non-zero conversion was not possible 1665 * @retval non-zero conversion was not possible
1666 */ 1666 */
1667 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep) 1667 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep)
1668 1668
1674 * It sets errno to ERANGE when the target datatype is too small. 1674 * It sets errno to ERANGE when the target datatype is too small.
1675 * 1675 *
1676 * @param str the string to convert 1676 * @param str the string to convert
1677 * @param output a pointer to the integer variable where the result shall be stored 1677 * @param output a pointer to the integer variable where the result shall be stored
1678 * @param base 2, 8, 10, or 16 1678 * @param base 2, 8, 10, or 16
1679 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1679 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1680 * @retval zero success 1680 * @retval zero success
1681 * @retval non-zero conversion was not possible 1681 * @retval non-zero conversion was not possible
1682 */ 1682 */
1683 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep) 1683 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep)
1684 1684
1690 * It sets errno to ERANGE when the target datatype is too small. 1690 * It sets errno to ERANGE when the target datatype is too small.
1691 * 1691 *
1692 * @param str the string to convert 1692 * @param str the string to convert
1693 * @param output a pointer to the integer variable where the result shall be stored 1693 * @param output a pointer to the integer variable where the result shall be stored
1694 * @param base 2, 8, 10, or 16 1694 * @param base 2, 8, 10, or 16
1695 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1695 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1696 * @retval zero success 1696 * @retval zero success
1697 * @retval non-zero conversion was not possible 1697 * @retval non-zero conversion was not possible
1698 */ 1698 */
1699 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep) 1699 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep)
1700 1700
1706 * It sets errno to ERANGE when the target datatype is too small. 1706 * It sets errno to ERANGE when the target datatype is too small.
1707 * 1707 *
1708 * @param str the string to convert 1708 * @param str the string to convert
1709 * @param output a pointer to the integer variable where the result shall be stored 1709 * @param output a pointer to the integer variable where the result shall be stored
1710 * @param base 2, 8, 10, or 16 1710 * @param base 2, 8, 10, or 16
1711 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1711 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1712 * @retval zero success 1712 * @retval zero success
1713 * @retval non-zero conversion was not possible 1713 * @retval non-zero conversion was not possible
1714 */ 1714 */
1715 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep) 1715 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep)
1716 1716
1722 * It sets errno to ERANGE when the target datatype is too small. 1722 * It sets errno to ERANGE when the target datatype is too small.
1723 * 1723 *
1724 * @param str the string to convert 1724 * @param str the string to convert
1725 * @param output a pointer to the integer variable where the result shall be stored 1725 * @param output a pointer to the integer variable where the result shall be stored
1726 * @param base 2, 8, 10, or 16 1726 * @param base 2, 8, 10, or 16
1727 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1727 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1728 * @retval zero success 1728 * @retval zero success
1729 * @retval non-zero conversion was not possible 1729 * @retval non-zero conversion was not possible
1730 */ 1730 */
1731 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep) 1731 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep)
1732 1732
1738 * It sets errno to ERANGE when the target datatype is too small. 1738 * It sets errno to ERANGE when the target datatype is too small.
1739 * 1739 *
1740 * @param str the string to convert 1740 * @param str the string to convert
1741 * @param output a pointer to the integer variable where the result shall be stored 1741 * @param output a pointer to the integer variable where the result shall be stored
1742 * @param base 2, 8, 10, or 16 1742 * @param base 2, 8, 10, or 16
1743 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1743 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1744 * @retval zero success 1744 * @retval zero success
1745 * @retval non-zero conversion was not possible 1745 * @retval non-zero conversion was not possible
1746 */ 1746 */
1747 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep) 1747 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep)
1748 1748
1754 * It sets errno to ERANGE when the target datatype is too small. 1754 * It sets errno to ERANGE when the target datatype is too small.
1755 * 1755 *
1756 * @param str the string to convert 1756 * @param str the string to convert
1757 * @param output a pointer to the integer variable where the result shall be stored 1757 * @param output a pointer to the integer variable where the result shall be stored
1758 * @param base 2, 8, 10, or 16 1758 * @param base 2, 8, 10, or 16
1759 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1759 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1760 * @retval zero success 1760 * @retval zero success
1761 * @retval non-zero conversion was not possible 1761 * @retval non-zero conversion was not possible
1762 */ 1762 */
1763 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep) 1763 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep)
1764 1764
1770 * It sets errno to ERANGE when the target datatype is too small. 1770 * It sets errno to ERANGE when the target datatype is too small.
1771 * 1771 *
1772 * @param str the string to convert 1772 * @param str the string to convert
1773 * @param output a pointer to the integer variable where the result shall be stored 1773 * @param output a pointer to the integer variable where the result shall be stored
1774 * @param base 2, 8, 10, or 16 1774 * @param base 2, 8, 10, or 16
1775 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1775 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1776 * @retval zero success 1776 * @retval zero success
1777 * @retval non-zero conversion was not possible 1777 * @retval non-zero conversion was not possible
1778 */ 1778 */
1779 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep) 1779 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep)
1780 1780
1786 * It sets errno to ERANGE when the target datatype is too small. 1786 * It sets errno to ERANGE when the target datatype is too small.
1787 * 1787 *
1788 * @param str the string to convert 1788 * @param str the string to convert
1789 * @param output a pointer to the integer variable where the result shall be stored 1789 * @param output a pointer to the integer variable where the result shall be stored
1790 * @param base 2, 8, 10, or 16 1790 * @param base 2, 8, 10, or 16
1791 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1791 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1792 * @retval zero success 1792 * @retval zero success
1793 * @retval non-zero conversion was not possible 1793 * @retval non-zero conversion was not possible
1794 */ 1794 */
1795 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep) 1795 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep)
1796 1796
1802 * It sets errno to ERANGE when the target datatype is too small. 1802 * It sets errno to ERANGE when the target datatype is too small.
1803 * 1803 *
1804 * @param str the string to convert 1804 * @param str the string to convert
1805 * @param output a pointer to the integer variable where the result shall be stored 1805 * @param output a pointer to the integer variable where the result shall be stored
1806 * @param base 2, 8, 10, or 16 1806 * @param base 2, 8, 10, or 16
1807 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1807 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1808 * @retval zero success 1808 * @retval zero success
1809 * @retval non-zero conversion was not possible 1809 * @retval non-zero conversion was not possible
1810 */ 1810 */
1811 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep) 1811 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep)
1812 1812
1815 * 1815 *
1816 * The function returns non-zero when conversion is not possible. 1816 * The function returns non-zero when conversion is not possible.
1817 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1817 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1818 * It sets errno to ERANGE when the target datatype is too small. 1818 * It sets errno to ERANGE when the target datatype is too small.
1819 * 1819 *
1820 * The comma character is treated as group separator and ignored during parsing. 1820 * The comma character is treated as a group separator and ignored during parsing.
1821 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1821 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1822 * 1822 *
1823 * @param str the string to convert 1823 * @param str the string to convert
1824 * @param output a pointer to the integer variable where the result shall be stored 1824 * @param output a pointer to the integer variable where the result shall be stored
1825 * @param base 2, 8, 10, or 16 1825 * @param base 2, 8, 10, or 16
1833 * 1833 *
1834 * The function returns non-zero when conversion is not possible. 1834 * The function returns non-zero when conversion is not possible.
1835 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1835 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1836 * It sets errno to ERANGE when the target datatype is too small. 1836 * It sets errno to ERANGE when the target datatype is too small.
1837 * 1837 *
1838 * The comma character is treated as group separator and ignored during parsing. 1838 * The comma character is treated as a group separator and ignored during parsing.
1839 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1839 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1840 * 1840 *
1841 * @param str the string to convert 1841 * @param str the string to convert
1842 * @param output a pointer to the integer variable where the result shall be stored 1842 * @param output a pointer to the integer variable where the result shall be stored
1843 * @param base 2, 8, 10, or 16 1843 * @param base 2, 8, 10, or 16
1851 * 1851 *
1852 * The function returns non-zero when conversion is not possible. 1852 * The function returns non-zero when conversion is not possible.
1853 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1853 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1854 * It sets errno to ERANGE when the target datatype is too small. 1854 * It sets errno to ERANGE when the target datatype is too small.
1855 * 1855 *
1856 * The comma character is treated as group separator and ignored during parsing. 1856 * The comma character is treated as a group separator and ignored during parsing.
1857 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1857 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1858 * 1858 *
1859 * @param str the string to convert 1859 * @param str the string to convert
1860 * @param output a pointer to the integer variable where the result shall be stored 1860 * @param output a pointer to the integer variable where the result shall be stored
1861 * @param base 2, 8, 10, or 16 1861 * @param base 2, 8, 10, or 16
1869 * 1869 *
1870 * The function returns non-zero when conversion is not possible. 1870 * The function returns non-zero when conversion is not possible.
1871 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1871 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1872 * It sets errno to ERANGE when the target datatype is too small. 1872 * It sets errno to ERANGE when the target datatype is too small.
1873 * 1873 *
1874 * The comma character is treated as group separator and ignored during parsing. 1874 * The comma character is treated as a group separator and ignored during parsing.
1875 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1875 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1876 * 1876 *
1877 * @param str the string to convert 1877 * @param str the string to convert
1878 * @param output a pointer to the integer variable where the result shall be stored 1878 * @param output a pointer to the integer variable where the result shall be stored
1879 * @param base 2, 8, 10, or 16 1879 * @param base 2, 8, 10, or 16
1887 * 1887 *
1888 * The function returns non-zero when conversion is not possible. 1888 * The function returns non-zero when conversion is not possible.
1889 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1889 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1890 * It sets errno to ERANGE when the target datatype is too small. 1890 * It sets errno to ERANGE when the target datatype is too small.
1891 * 1891 *
1892 * The comma character is treated as group separator and ignored during parsing. 1892 * The comma character is treated as a group separator and ignored during parsing.
1893 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1893 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1894 * 1894 *
1895 * @param str the string to convert 1895 * @param str the string to convert
1896 * @param output a pointer to the integer variable where the result shall be stored 1896 * @param output a pointer to the integer variable where the result shall be stored
1897 * @param base 2, 8, 10, or 16 1897 * @param base 2, 8, 10, or 16
1905 * 1905 *
1906 * The function returns non-zero when conversion is not possible. 1906 * The function returns non-zero when conversion is not possible.
1907 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1907 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1908 * It sets errno to ERANGE when the target datatype is too small. 1908 * It sets errno to ERANGE when the target datatype is too small.
1909 * 1909 *
1910 * The comma character is treated as group separator and ignored during parsing. 1910 * The comma character is treated as a group separator and ignored during parsing.
1911 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1911 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1912 * 1912 *
1913 * @param str the string to convert 1913 * @param str the string to convert
1914 * @param output a pointer to the integer variable where the result shall be stored 1914 * @param output a pointer to the integer variable where the result shall be stored
1915 * @param base 2, 8, 10, or 16 1915 * @param base 2, 8, 10, or 16
1923 * 1923 *
1924 * The function returns non-zero when conversion is not possible. 1924 * The function returns non-zero when conversion is not possible.
1925 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1925 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1926 * It sets errno to ERANGE when the target datatype is too small. 1926 * It sets errno to ERANGE when the target datatype is too small.
1927 * 1927 *
1928 * The comma character is treated as group separator and ignored during parsing. 1928 * The comma character is treated as a group separator and ignored during parsing.
1929 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1929 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1930 * 1930 *
1931 * @param str the string to convert 1931 * @param str the string to convert
1932 * @param output a pointer to the integer variable where the result shall be stored 1932 * @param output a pointer to the integer variable where the result shall be stored
1933 * @param base 2, 8, 10, or 16 1933 * @param base 2, 8, 10, or 16
1941 * 1941 *
1942 * The function returns non-zero when conversion is not possible. 1942 * The function returns non-zero when conversion is not possible.
1943 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1943 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1944 * It sets errno to ERANGE when the target datatype is too small. 1944 * It sets errno to ERANGE when the target datatype is too small.
1945 * 1945 *
1946 * The comma character is treated as group separator and ignored during parsing. 1946 * The comma character is treated as a group separator and ignored during parsing.
1947 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1947 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1948 * 1948 *
1949 * @param str the string to convert 1949 * @param str the string to convert
1950 * @param output a pointer to the integer variable where the result shall be stored 1950 * @param output a pointer to the integer variable where the result shall be stored
1951 * @param base 2, 8, 10, or 16 1951 * @param base 2, 8, 10, or 16
1959 * 1959 *
1960 * The function returns non-zero when conversion is not possible. 1960 * The function returns non-zero when conversion is not possible.
1961 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1961 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1962 * It sets errno to ERANGE when the target datatype is too small. 1962 * It sets errno to ERANGE when the target datatype is too small.
1963 * 1963 *
1964 * The comma character is treated as group separator and ignored during parsing. 1964 * The comma character is treated as a group separator and ignored during parsing.
1965 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1965 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1966 * 1966 *
1967 * @param str the string to convert 1967 * @param str the string to convert
1968 * @param output a pointer to the integer variable where the result shall be stored 1968 * @param output a pointer to the integer variable where the result shall be stored
1969 * @param base 2, 8, 10, or 16 1969 * @param base 2, 8, 10, or 16
1977 * 1977 *
1978 * The function returns non-zero when conversion is not possible. 1978 * The function returns non-zero when conversion is not possible.
1979 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1979 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1980 * It sets errno to ERANGE when the target datatype is too small. 1980 * It sets errno to ERANGE when the target datatype is too small.
1981 * 1981 *
1982 * The comma character is treated as group separator and ignored during parsing. 1982 * The comma character is treated as a group separator and ignored during parsing.
1983 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1983 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1984 * 1984 *
1985 * @param str the string to convert 1985 * @param str the string to convert
1986 * @param output a pointer to the integer variable where the result shall be stored 1986 * @param output a pointer to the integer variable where the result shall be stored
1987 * @param base 2, 8, 10, or 16 1987 * @param base 2, 8, 10, or 16
1995 * 1995 *
1996 * The function returns non-zero when conversion is not possible. 1996 * The function returns non-zero when conversion is not possible.
1997 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1997 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1998 * It sets errno to ERANGE when the target datatype is too small. 1998 * It sets errno to ERANGE when the target datatype is too small.
1999 * 1999 *
2000 * The comma character is treated as group separator and ignored during parsing. 2000 * The comma character is treated as a group separator and ignored during parsing.
2001 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2001 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2002 * 2002 *
2003 * @param str the string to convert 2003 * @param str the string to convert
2004 * @param output a pointer to the integer variable where the result shall be stored 2004 * @param output a pointer to the integer variable where the result shall be stored
2005 * @param base 2, 8, 10, or 16 2005 * @param base 2, 8, 10, or 16
2013 * 2013 *
2014 * The function returns non-zero when conversion is not possible. 2014 * The function returns non-zero when conversion is not possible.
2015 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2015 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2016 * It sets errno to ERANGE when the target datatype is too small. 2016 * It sets errno to ERANGE when the target datatype is too small.
2017 * 2017 *
2018 * The comma character is treated as group separator and ignored during parsing. 2018 * The comma character is treated as a group separator and ignored during parsing.
2019 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2019 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2020 * 2020 *
2021 * @param str the string to convert 2021 * @param str the string to convert
2022 * @param output a pointer to the integer variable where the result shall be stored 2022 * @param output a pointer to the integer variable where the result shall be stored
2023 * @param base 2, 8, 10, or 16 2023 * @param base 2, 8, 10, or 16
2031 * 2031 *
2032 * The function returns non-zero when conversion is not possible. 2032 * The function returns non-zero when conversion is not possible.
2033 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2033 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2034 * It sets errno to ERANGE when the target datatype is too small. 2034 * It sets errno to ERANGE when the target datatype is too small.
2035 * 2035 *
2036 * The comma character is treated as group separator and ignored during parsing. 2036 * The comma character is treated as a group separator and ignored during parsing.
2037 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2037 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2038 * 2038 *
2039 * @param str the string to convert 2039 * @param str the string to convert
2040 * @param output a pointer to the integer variable where the result shall be stored 2040 * @param output a pointer to the integer variable where the result shall be stored
2041 * @param base 2, 8, 10, or 16 2041 * @param base 2, 8, 10, or 16
2049 * 2049 *
2050 * The function returns non-zero when conversion is not possible. 2050 * The function returns non-zero when conversion is not possible.
2051 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2051 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2052 * It sets errno to ERANGE when the target datatype is too small. 2052 * It sets errno to ERANGE when the target datatype is too small.
2053 * 2053 *
2054 * The comma character is treated as group separator and ignored during parsing. 2054 * The comma character is treated as a group separator and ignored during parsing.
2055 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2055 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2056 * 2056 *
2057 * @param str the string to convert 2057 * @param str the string to convert
2058 * @param output a pointer to the integer variable where the result shall be stored 2058 * @param output a pointer to the integer variable where the result shall be stored
2059 * @param base 2, 8, 10, or 16 2059 * @param base 2, 8, 10, or 16
2067 * 2067 *
2068 * The function returns non-zero when conversion is not possible. 2068 * The function returns non-zero when conversion is not possible.
2069 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2069 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2070 * It sets errno to ERANGE when the target datatype is too small. 2070 * It sets errno to ERANGE when the target datatype is too small.
2071 * 2071 *
2072 * The comma character is treated as group separator and ignored during parsing. 2072 * The comma character is treated as a group separator and ignored during parsing.
2073 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2073 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2074 * 2074 *
2075 * @param str the string to convert 2075 * @param str the string to convert
2076 * @param output a pointer to the integer variable where the result shall be stored 2076 * @param output a pointer to the integer variable where the result shall be stored
2077 * @param base 2, 8, 10, or 16 2077 * @param base 2, 8, 10, or 16
2085 * 2085 *
2086 * The function returns non-zero when conversion is not possible. 2086 * The function returns non-zero when conversion is not possible.
2087 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2087 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2088 * It sets errno to ERANGE when the target datatype is too small. 2088 * It sets errno to ERANGE when the target datatype is too small.
2089 * 2089 *
2090 * The comma character is treated as group separator and ignored during parsing. 2090 * The comma character is treated as a group separator and ignored during parsing.
2091 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2091 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2092 * 2092 *
2093 * @param str the string to convert 2093 * @param str the string to convert
2094 * @param output a pointer to the integer variable where the result shall be stored 2094 * @param output a pointer to the integer variable where the result shall be stored
2095 * @param base 2, 8, 10, or 16 2095 * @param base 2, 8, 10, or 16
2103 * 2103 *
2104 * The function returns non-zero when conversion is not possible. 2104 * The function returns non-zero when conversion is not possible.
2105 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2105 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2106 * It sets errno to ERANGE when the target datatype is too small. 2106 * It sets errno to ERANGE when the target datatype is too small.
2107 * 2107 *
2108 * The comma character is treated as group separator and ignored during parsing. 2108 * The comma character is treated as a group separator and ignored during parsing.
2109 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2109 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2110 * 2110 *
2111 * @param str the string to convert 2111 * @param str the string to convert
2112 * @param output a pointer to the integer variable where the result shall be stored 2112 * @param output a pointer to the integer variable where the result shall be stored
2113 * @param base 2, 8, 10, or 16 2113 * @param base 2, 8, 10, or 16
2115 * @retval non-zero conversion was not possible 2115 * @retval non-zero conversion was not possible
2116 */ 2116 */
2117 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",") 2117 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",")
2118 2118
2119 /** 2119 /**
2120 * Converts a string to a single precision floating point number. 2120 * Converts a string to a single precision floating-point number.
2121 * 2121 *
2122 * The function returns non-zero when conversion is not possible. 2122 * The function returns non-zero when conversion is not possible.
2123 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2123 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2124 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 2124 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
2125 * 2125 *
2126 * @param str the string to convert 2126 * @param str the string to convert
2127 * @param output a pointer to the float variable where the result shall be stored 2127 * @param output a pointer to the float variable where the result shall be stored
2128 * @param decsep the decimal separator 2128 * @param decsep the decimal separator
2129 * @param groupsep each character in this string is treated as group separator and ignored during conversion 2129 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
2130 * @retval zero success 2130 * @retval zero success
2131 * @retval non-zero conversion was not possible 2131 * @retval non-zero conversion was not possible
2132 */ 2132 */
2133 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep) 2133 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep)
2134 2134
2135 /** 2135 /**
2136 * Converts a string to a double precision floating point number. 2136 * Converts a string to a double precision floating-point number.
2137 * 2137 *
2138 * The function returns non-zero when conversion is not possible. 2138 * The function returns non-zero when conversion is not possible.
2139 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2139 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2140 * 2140 *
2141 * @param str the string to convert 2141 * @param str the string to convert
2142 * @param output a pointer to the double variable where the result shall be stored 2142 * @param output a pointer to the double variable where the result shall be stored
2143 * @param decsep the decimal separator 2143 * @param decsep the decimal separator
2144 * @param groupsep each character in this string is treated as group separator and ignored during conversion 2144 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
2145 * @retval zero success 2145 * @retval zero success
2146 * @retval non-zero conversion was not possible 2146 * @retval non-zero conversion was not possible
2147 */ 2147 */
2148 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep) 2148 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep)
2149 2149
2150 /** 2150 /**
2151 * Converts a string to a single precision floating point number. 2151 * Converts a string to a single precision floating-point number.
2152 * 2152 *
2153 * The function returns non-zero when conversion is not possible. 2153 * The function returns non-zero when conversion is not possible.
2154 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2154 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2155 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 2155 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
2156 * 2156 *
2157 * The decimal separator is assumed to be a dot character. 2157 * The decimal separator is assumed to be a dot character.
2158 * The comma character is treated as group separator and ignored during parsing. 2158 * The comma character is treated as a group separator and ignored during parsing.
2159 * If you want to choose a different format, use cx_strtof_lc(). 2159 * If you want to choose a different format, use cx_strtof_lc().
2160 * 2160 *
2161 * @param str the string to convert 2161 * @param str the string to convert
2162 * @param output a pointer to the float variable where the result shall be stored 2162 * @param output a pointer to the float variable where the result shall be stored
2163 * @retval zero success 2163 * @retval zero success
2164 * @retval non-zero conversion was not possible 2164 * @retval non-zero conversion was not possible
2165 */ 2165 */
2166 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",") 2166 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",")
2167 2167
2168 /** 2168 /**
2169 * Converts a string to a double precision floating point number. 2169 * Converts a string to a double precision floating-point number.
2170 * 2170 *
2171 * The function returns non-zero when conversion is not possible. 2171 * The function returns non-zero when conversion is not possible.
2172 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2172 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2173 * 2173 *
2174 * The decimal separator is assumed to be a dot character. 2174 * The decimal separator is assumed to be a dot character.
2175 * The comma character is treated as group separator and ignored during parsing. 2175 * The comma character is treated as a group separator and ignored during parsing.
2176 * If you want to choose a different format, use cx_strtof_lc(). 2176 * If you want to choose a different format, use cx_strtof_lc().
2177 * 2177 *
2178 * @param str the string to convert 2178 * @param str the string to convert
2179 * @param output a pointer to the double variable where the result shall be stored 2179 * @param output a pointer to the double variable where the result shall be stored
2180 * @retval zero success 2180 * @retval zero success

mercurial