| 300 static inline cxstring cx_strcast_z(const char *str) { |
302 static inline cxstring cx_strcast_z(const char *str) { |
| 301 return cx_str(str); |
303 return cx_str(str); |
| 302 } |
304 } |
| 303 |
305 |
| 304 /** |
306 /** |
| 305 * Casts a mutable string to an immutable string. |
307 * Wraps any string into an UCX string. |
| 306 * |
308 * |
| 307 * Does nothing for already immutable strings. |
309 * @param str (any supported string type) the string to cast |
| 308 * |
310 * @return (@c cxstring) the string wrapped as UCX string |
| 309 * @note This is not seriously a cast. Instead, you get a copy |
311 */ |
| 310 * of the struct with the desired pointer type. Both structs still |
|
| 311 * point to the same location, though! |
|
| 312 * |
|
| 313 * @param str (@c cxstring or @c cxmutstr) the string to cast |
|
| 314 * @return (@c cxstring) an immutable copy of the string pointer |
|
| 315 */ |
|
| 316 #define cx_strcast(str) _Generic((str), \ |
312 #define cx_strcast(str) _Generic((str), \ |
| 317 cxmutstr: cx_strcast_m, \ |
313 cxmutstr: cx_strcast_m, \ |
| 318 cxstring: cx_strcast_c, \ |
314 cxstring: cx_strcast_c, \ |
| |
315 const unsigned char*: cx_strcast_z, \ |
| |
316 unsigned char *: cx_strcast_z, \ |
| 319 const char*: cx_strcast_z, \ |
317 const char*: cx_strcast_z, \ |
| 320 char *: cx_strcast_z) (str) |
318 char *: cx_strcast_z) (str) |
| 321 #endif |
319 #endif |
| 322 |
320 |
| 323 /** |
321 /** |
| 324 * 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. |
| 325 * |
323 * |
| 326 * 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, |
| 327 * which means that this function protects you against double-free. |
325 * which means that this function protects you against double-free. |
| 328 * |
326 * |
| 329 * @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 |
| 330 * 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. |
| 331 * If you encounter such situation, you should double-check your code. |
329 * If you encounter such a situation, you should double-check your code. |
| 332 * |
330 * |
| 333 * @param str the string to free |
331 * @param str the string to free |
| 334 */ |
332 */ |
| 335 cx_attr_export |
333 cx_attr_export |
| 336 void cx_strfree(cxmutstr *str); |
334 void cx_strfree(cxmutstr *str); |
| 337 |
335 |
| 338 /** |
336 /** |
| 339 * Passes the pointer in this string to the allocators free function. |
337 * Passes the pointer in this string to the allocator's free function. |
| 340 * |
338 * |
| 341 * 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, |
| 342 * which means that this function protects you against double-free. |
340 * which means that this function protects you against double-free. |
| 343 * |
341 * |
| 344 * @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 |
| 345 * 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. |
| 346 * If you encounter such situation, you should double-check your code. |
344 * If you encounter such a situation, you should double-check your code. |
| 347 * |
345 * |
| 348 * @param alloc the allocator |
346 * @param alloc the allocator |
| 349 * @param str the string to free |
347 * @param str the string to free |
| 350 */ |
348 */ |
| 351 cx_attr_nonnull_arg(1) |
349 cx_attr_nonnull_arg(1) |
| 1225 * 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. |
| 1226 * |
1224 * |
| 1227 * @param str the string to convert |
1225 * @param str the string to convert |
| 1228 * @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 |
| 1229 * @param base 2, 8, 10, or 16 |
1227 * @param base 2, 8, 10, or 16 |
| 1230 * @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 |
| 1231 * @retval zero success |
1229 * @retval zero success |
| 1232 * @retval non-zero conversion was not possible |
1230 * @retval non-zero conversion was not possible |
| 1233 */ |
1231 */ |
| 1234 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 |
| 1235 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); |
| 1242 * 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. |
| 1243 * |
1241 * |
| 1244 * @param str the string to convert |
1242 * @param str the string to convert |
| 1245 * @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 |
| 1246 * @param base 2, 8, 10, or 16 |
1244 * @param base 2, 8, 10, or 16 |
| 1247 * @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 |
| 1248 * @retval zero success |
1246 * @retval zero success |
| 1249 * @retval non-zero conversion was not possible |
1247 * @retval non-zero conversion was not possible |
| 1250 */ |
1248 */ |
| 1251 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 |
| 1252 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); |
| 1259 * 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. |
| 1260 * |
1258 * |
| 1261 * @param str the string to convert |
1259 * @param str the string to convert |
| 1262 * @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 |
| 1263 * @param base 2, 8, 10, or 16 |
1261 * @param base 2, 8, 10, or 16 |
| 1264 * @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 |
| 1265 * @retval zero success |
1263 * @retval zero success |
| 1266 * @retval non-zero conversion was not possible |
1264 * @retval non-zero conversion was not possible |
| 1267 */ |
1265 */ |
| 1268 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 |
| 1269 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); |
| 1276 * 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. |
| 1277 * |
1275 * |
| 1278 * @param str the string to convert |
1276 * @param str the string to convert |
| 1279 * @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 |
| 1280 * @param base 2, 8, 10, or 16 |
1278 * @param base 2, 8, 10, or 16 |
| 1281 * @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 |
| 1282 * @retval zero success |
1280 * @retval zero success |
| 1283 * @retval non-zero conversion was not possible |
1281 * @retval non-zero conversion was not possible |
| 1284 */ |
1282 */ |
| 1285 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 |
| 1286 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); |
| 1293 * 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. |
| 1294 * |
1292 * |
| 1295 * @param str the string to convert |
1293 * @param str the string to convert |
| 1296 * @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 |
| 1297 * @param base 2, 8, 10, or 16 |
1295 * @param base 2, 8, 10, or 16 |
| 1298 * @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 |
| 1299 * @retval zero success |
1297 * @retval zero success |
| 1300 * @retval non-zero conversion was not possible |
1298 * @retval non-zero conversion was not possible |
| 1301 */ |
1299 */ |
| 1302 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 |
| 1303 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); |
| 1310 * 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. |
| 1311 * |
1309 * |
| 1312 * @param str the string to convert |
1310 * @param str the string to convert |
| 1313 * @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 |
| 1314 * @param base 2, 8, 10, or 16 |
1312 * @param base 2, 8, 10, or 16 |
| 1315 * @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 |
| 1316 * @retval zero success |
1314 * @retval zero success |
| 1317 * @retval non-zero conversion was not possible |
1315 * @retval non-zero conversion was not possible |
| 1318 */ |
1316 */ |
| 1319 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 |
| 1320 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); |
| 1327 * 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. |
| 1328 * |
1326 * |
| 1329 * @param str the string to convert |
1327 * @param str the string to convert |
| 1330 * @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 |
| 1331 * @param base 2, 8, 10, or 16 |
1329 * @param base 2, 8, 10, or 16 |
| 1332 * @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 |
| 1333 * @retval zero success |
1331 * @retval zero success |
| 1334 * @retval non-zero conversion was not possible |
1332 * @retval non-zero conversion was not possible |
| 1335 */ |
1333 */ |
| 1336 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 |
| 1337 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); |
| 1344 * 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. |
| 1345 * |
1343 * |
| 1346 * @param str the string to convert |
1344 * @param str the string to convert |
| 1347 * @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 |
| 1348 * @param base 2, 8, 10, or 16 |
1346 * @param base 2, 8, 10, or 16 |
| 1349 * @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 |
| 1350 * @retval zero success |
1348 * @retval zero success |
| 1351 * @retval non-zero conversion was not possible |
1349 * @retval non-zero conversion was not possible |
| 1352 */ |
1350 */ |
| 1353 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 |
| 1354 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); |
| 1361 * 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. |
| 1362 * |
1360 * |
| 1363 * @param str the string to convert |
1361 * @param str the string to convert |
| 1364 * @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 |
| 1365 * @param base 2, 8, 10, or 16 |
1363 * @param base 2, 8, 10, or 16 |
| 1366 * @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 |
| 1367 * @retval zero success |
1365 * @retval zero success |
| 1368 * @retval non-zero conversion was not possible |
1366 * @retval non-zero conversion was not possible |
| 1369 */ |
1367 */ |
| 1370 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 |
| 1371 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); |
| 1378 * 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. |
| 1379 * |
1377 * |
| 1380 * @param str the string to convert |
1378 * @param str the string to convert |
| 1381 * @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 |
| 1382 * @param base 2, 8, 10, or 16 |
1380 * @param base 2, 8, 10, or 16 |
| 1383 * @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 |
| 1384 * @retval zero success |
1382 * @retval zero success |
| 1385 * @retval non-zero conversion was not possible |
1383 * @retval non-zero conversion was not possible |
| 1386 */ |
1384 */ |
| 1387 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 |
| 1388 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); |
| 1395 * 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. |
| 1396 * |
1394 * |
| 1397 * @param str the string to convert |
1395 * @param str the string to convert |
| 1398 * @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 |
| 1399 * @param base 2, 8, 10, or 16 |
1397 * @param base 2, 8, 10, or 16 |
| 1400 * @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 |
| 1401 * @retval zero success |
1399 * @retval zero success |
| 1402 * @retval non-zero conversion was not possible |
1400 * @retval non-zero conversion was not possible |
| 1403 */ |
1401 */ |
| 1404 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 |
| 1405 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); |
| 1412 * 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. |
| 1413 * |
1411 * |
| 1414 * @param str the string to convert |
1412 * @param str the string to convert |
| 1415 * @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 |
| 1416 * @param base 2, 8, 10, or 16 |
1414 * @param base 2, 8, 10, or 16 |
| 1417 * @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 |
| 1418 * @retval zero success |
1416 * @retval zero success |
| 1419 * @retval non-zero conversion was not possible |
1417 * @retval non-zero conversion was not possible |
| 1420 */ |
1418 */ |
| 1421 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 |
| 1422 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); |
| 1429 * 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. |
| 1430 * |
1428 * |
| 1431 * @param str the string to convert |
1429 * @param str the string to convert |
| 1432 * @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 |
| 1433 * @param base 2, 8, 10, or 16 |
1431 * @param base 2, 8, 10, or 16 |
| 1434 * @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 |
| 1435 * @retval zero success |
1433 * @retval zero success |
| 1436 * @retval non-zero conversion was not possible |
1434 * @retval non-zero conversion was not possible |
| 1437 */ |
1435 */ |
| 1438 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 |
| 1439 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); |
| 1446 * 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. |
| 1447 * |
1445 * |
| 1448 * @param str the string to convert |
1446 * @param str the string to convert |
| 1449 * @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 |
| 1450 * @param base 2, 8, 10, or 16 |
1448 * @param base 2, 8, 10, or 16 |
| 1451 * @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 |
| 1452 * @retval zero success |
1450 * @retval zero success |
| 1453 * @retval non-zero conversion was not possible |
1451 * @retval non-zero conversion was not possible |
| 1454 */ |
1452 */ |
| 1455 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 |
| 1456 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); |
| 1463 * 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. |
| 1464 * |
1462 * |
| 1465 * @param str the string to convert |
1463 * @param str the string to convert |
| 1466 * @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 |
| 1467 * @param base 2, 8, 10, or 16 |
1465 * @param base 2, 8, 10, or 16 |
| 1468 * @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 |
| 1469 * @retval zero success |
1467 * @retval zero success |
| 1470 * @retval non-zero conversion was not possible |
1468 * @retval non-zero conversion was not possible |
| 1471 */ |
1469 */ |
| 1472 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 |
| 1473 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); |
| 1480 * 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. |
| 1481 * |
1479 * |
| 1482 * @param str the string to convert |
1480 * @param str the string to convert |
| 1483 * @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 |
| 1484 * @param base 2, 8, 10, or 16 |
1482 * @param base 2, 8, 10, or 16 |
| 1485 * @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 |
| 1486 * @retval zero success |
1484 * @retval zero success |
| 1487 * @retval non-zero conversion was not possible |
1485 * @retval non-zero conversion was not possible |
| 1488 */ |
1486 */ |
| 1489 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 |
| 1490 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); |
| 1497 * 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. |
| 1498 * |
1496 * |
| 1499 * @param str the string to convert |
1497 * @param str the string to convert |
| 1500 * @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 |
| 1501 * @param base 2, 8, 10, or 16 |
1499 * @param base 2, 8, 10, or 16 |
| 1502 * @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 |
| 1503 * @retval zero success |
1501 * @retval zero success |
| 1504 * @retval non-zero conversion was not possible |
1502 * @retval non-zero conversion was not possible |
| 1505 */ |
1503 */ |
| 1506 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 |
| 1507 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); |
| 1508 |
1506 |
| 1509 /** |
1507 /** |
| 1510 * Converts a string to a single precision floating point number. |
1508 * Converts a string to a single precision floating-point number. |
| 1511 * |
1509 * |
| 1512 * The function returns non-zero when conversion is not possible. |
1510 * The function returns non-zero when conversion is not possible. |
| 1513 * 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. |
| 1514 * 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. |
| 1515 * |
1513 * |
| 1516 * @param str the string to convert |
1514 * @param str the string to convert |
| 1517 * @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 |
| 1518 * @param decsep the decimal separator |
1516 * @param decsep the decimal separator |
| 1519 * @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 |
| 1520 * @retval zero success |
1518 * @retval zero success |
| 1521 * @retval non-zero conversion was not possible |
1519 * @retval non-zero conversion was not possible |
| 1522 */ |
1520 */ |
| 1523 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 |
| 1524 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); |
| 1525 |
1523 |
| 1526 /** |
1524 /** |
| 1527 * Converts a string to a double precision floating point number. |
1525 * Converts a string to a double precision floating-point number. |
| 1528 * |
1526 * |
| 1529 * The function returns non-zero when conversion is not possible. |
1527 * The function returns non-zero when conversion is not possible. |
| 1530 * 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. |
| 1531 * 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. |
| 1532 * |
1530 * |
| 1533 * @param str the string to convert |
1531 * @param str the string to convert |
| 1534 * @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 |
| 1535 * @param decsep the decimal separator |
1533 * @param decsep the decimal separator |
| 1536 * @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 |
| 1537 * @retval zero success |
1535 * @retval zero success |
| 1538 * @retval non-zero conversion was not possible |
1536 * @retval non-zero conversion was not possible |
| 1539 */ |
1537 */ |
| 1540 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 |
| 1541 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); |
| 1548 * 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. |
| 1549 * |
1547 * |
| 1550 * @param str the string to convert |
1548 * @param str the string to convert |
| 1551 * @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 |
| 1552 * @param base 2, 8, 10, or 16 |
1550 * @param base 2, 8, 10, or 16 |
| 1553 * @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 |
| 1554 * @retval zero success |
1552 * @retval zero success |
| 1555 * @retval non-zero conversion was not possible |
1553 * @retval non-zero conversion was not possible |
| 1556 */ |
1554 */ |
| 1557 #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) |
| 1558 |
1556 |
| 1564 * 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. |
| 1565 * |
1563 * |
| 1566 * @param str the string to convert |
1564 * @param str the string to convert |
| 1567 * @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 |
| 1568 * @param base 2, 8, 10, or 16 |
1566 * @param base 2, 8, 10, or 16 |
| 1569 * @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 |
| 1570 * @retval zero success |
1568 * @retval zero success |
| 1571 * @retval non-zero conversion was not possible |
1569 * @retval non-zero conversion was not possible |
| 1572 */ |
1570 */ |
| 1573 #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) |
| 1574 |
1572 |
| 1580 * 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. |
| 1581 * |
1579 * |
| 1582 * @param str the string to convert |
1580 * @param str the string to convert |
| 1583 * @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 |
| 1584 * @param base 2, 8, 10, or 16 |
1582 * @param base 2, 8, 10, or 16 |
| 1585 * @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 |
| 1586 * @retval zero success |
1584 * @retval zero success |
| 1587 * @retval non-zero conversion was not possible |
1585 * @retval non-zero conversion was not possible |
| 1588 */ |
1586 */ |
| 1589 #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) |
| 1590 |
1588 |
| 1596 * 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. |
| 1597 * |
1595 * |
| 1598 * @param str the string to convert |
1596 * @param str the string to convert |
| 1599 * @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 |
| 1600 * @param base 2, 8, 10, or 16 |
1598 * @param base 2, 8, 10, or 16 |
| 1601 * @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 |
| 1602 * @retval zero success |
1600 * @retval zero success |
| 1603 * @retval non-zero conversion was not possible |
1601 * @retval non-zero conversion was not possible |
| 1604 */ |
1602 */ |
| 1605 #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) |
| 1606 |
1604 |
| 1612 * 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. |
| 1613 * |
1611 * |
| 1614 * @param str the string to convert |
1612 * @param str the string to convert |
| 1615 * @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 |
| 1616 * @param base 2, 8, 10, or 16 |
1614 * @param base 2, 8, 10, or 16 |
| 1617 * @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 |
| 1618 * @retval zero success |
1616 * @retval zero success |
| 1619 * @retval non-zero conversion was not possible |
1617 * @retval non-zero conversion was not possible |
| 1620 */ |
1618 */ |
| 1621 #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) |
| 1622 |
1620 |
| 1628 * 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. |
| 1629 * |
1627 * |
| 1630 * @param str the string to convert |
1628 * @param str the string to convert |
| 1631 * @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 |
| 1632 * @param base 2, 8, 10, or 16 |
1630 * @param base 2, 8, 10, or 16 |
| 1633 * @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 |
| 1634 * @retval zero success |
1632 * @retval zero success |
| 1635 * @retval non-zero conversion was not possible |
1633 * @retval non-zero conversion was not possible |
| 1636 */ |
1634 */ |
| 1637 #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) |
| 1638 |
1636 |
| 1644 * 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. |
| 1645 * |
1643 * |
| 1646 * @param str the string to convert |
1644 * @param str the string to convert |
| 1647 * @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 |
| 1648 * @param base 2, 8, 10, or 16 |
1646 * @param base 2, 8, 10, or 16 |
| 1649 * @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 |
| 1650 * @retval zero success |
1648 * @retval zero success |
| 1651 * @retval non-zero conversion was not possible |
1649 * @retval non-zero conversion was not possible |
| 1652 */ |
1650 */ |
| 1653 #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) |
| 1654 |
1652 |
| 1660 * 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. |
| 1661 * |
1659 * |
| 1662 * @param str the string to convert |
1660 * @param str the string to convert |
| 1663 * @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 |
| 1664 * @param base 2, 8, 10, or 16 |
1662 * @param base 2, 8, 10, or 16 |
| 1665 * @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 |
| 1666 * @retval zero success |
1664 * @retval zero success |
| 1667 * @retval non-zero conversion was not possible |
1665 * @retval non-zero conversion was not possible |
| 1668 */ |
1666 */ |
| 1669 #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) |
| 1670 |
1668 |
| 1676 * 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. |
| 1677 * |
1675 * |
| 1678 * @param str the string to convert |
1676 * @param str the string to convert |
| 1679 * @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 |
| 1680 * @param base 2, 8, 10, or 16 |
1678 * @param base 2, 8, 10, or 16 |
| 1681 * @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 |
| 1682 * @retval zero success |
1680 * @retval zero success |
| 1683 * @retval non-zero conversion was not possible |
1681 * @retval non-zero conversion was not possible |
| 1684 */ |
1682 */ |
| 1685 #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) |
| 1686 |
1684 |
| 1692 * 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. |
| 1693 * |
1691 * |
| 1694 * @param str the string to convert |
1692 * @param str the string to convert |
| 1695 * @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 |
| 1696 * @param base 2, 8, 10, or 16 |
1694 * @param base 2, 8, 10, or 16 |
| 1697 * @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 |
| 1698 * @retval zero success |
1696 * @retval zero success |
| 1699 * @retval non-zero conversion was not possible |
1697 * @retval non-zero conversion was not possible |
| 1700 */ |
1698 */ |
| 1701 #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) |
| 1702 |
1700 |
| 1708 * 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. |
| 1709 * |
1707 * |
| 1710 * @param str the string to convert |
1708 * @param str the string to convert |
| 1711 * @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 |
| 1712 * @param base 2, 8, 10, or 16 |
1710 * @param base 2, 8, 10, or 16 |
| 1713 * @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 |
| 1714 * @retval zero success |
1712 * @retval zero success |
| 1715 * @retval non-zero conversion was not possible |
1713 * @retval non-zero conversion was not possible |
| 1716 */ |
1714 */ |
| 1717 #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) |
| 1718 |
1716 |
| 1724 * 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. |
| 1725 * |
1723 * |
| 1726 * @param str the string to convert |
1724 * @param str the string to convert |
| 1727 * @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 |
| 1728 * @param base 2, 8, 10, or 16 |
1726 * @param base 2, 8, 10, or 16 |
| 1729 * @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 |
| 1730 * @retval zero success |
1728 * @retval zero success |
| 1731 * @retval non-zero conversion was not possible |
1729 * @retval non-zero conversion was not possible |
| 1732 */ |
1730 */ |
| 1733 #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) |
| 1734 |
1732 |
| 1740 * 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. |
| 1741 * |
1739 * |
| 1742 * @param str the string to convert |
1740 * @param str the string to convert |
| 1743 * @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 |
| 1744 * @param base 2, 8, 10, or 16 |
1742 * @param base 2, 8, 10, or 16 |
| 1745 * @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 |
| 1746 * @retval zero success |
1744 * @retval zero success |
| 1747 * @retval non-zero conversion was not possible |
1745 * @retval non-zero conversion was not possible |
| 1748 */ |
1746 */ |
| 1749 #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) |
| 1750 |
1748 |
| 1756 * 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. |
| 1757 * |
1755 * |
| 1758 * @param str the string to convert |
1756 * @param str the string to convert |
| 1759 * @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 |
| 1760 * @param base 2, 8, 10, or 16 |
1758 * @param base 2, 8, 10, or 16 |
| 1761 * @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 |
| 1762 * @retval zero success |
1760 * @retval zero success |
| 1763 * @retval non-zero conversion was not possible |
1761 * @retval non-zero conversion was not possible |
| 1764 */ |
1762 */ |
| 1765 #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) |
| 1766 |
1764 |
| 1772 * 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. |
| 1773 * |
1771 * |
| 1774 * @param str the string to convert |
1772 * @param str the string to convert |
| 1775 * @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 |
| 1776 * @param base 2, 8, 10, or 16 |
1774 * @param base 2, 8, 10, or 16 |
| 1777 * @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 |
| 1778 * @retval zero success |
1776 * @retval zero success |
| 1779 * @retval non-zero conversion was not possible |
1777 * @retval non-zero conversion was not possible |
| 1780 */ |
1778 */ |
| 1781 #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) |
| 1782 |
1780 |
| 1788 * 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. |
| 1789 * |
1787 * |
| 1790 * @param str the string to convert |
1788 * @param str the string to convert |
| 1791 * @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 |
| 1792 * @param base 2, 8, 10, or 16 |
1790 * @param base 2, 8, 10, or 16 |
| 1793 * @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 |
| 1794 * @retval zero success |
1792 * @retval zero success |
| 1795 * @retval non-zero conversion was not possible |
1793 * @retval non-zero conversion was not possible |
| 1796 */ |
1794 */ |
| 1797 #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) |
| 1798 |
1796 |
| 1804 * 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. |
| 1805 * |
1803 * |
| 1806 * @param str the string to convert |
1804 * @param str the string to convert |
| 1807 * @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 |
| 1808 * @param base 2, 8, 10, or 16 |
1806 * @param base 2, 8, 10, or 16 |
| 1809 * @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 |
| 1810 * @retval zero success |
1808 * @retval zero success |
| 1811 * @retval non-zero conversion was not possible |
1809 * @retval non-zero conversion was not possible |
| 1812 */ |
1810 */ |
| 1813 #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) |
| 1814 |
1812 |
| 2117 * @retval non-zero conversion was not possible |
2115 * @retval non-zero conversion was not possible |
| 2118 */ |
2116 */ |
| 2119 #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, ",") |
| 2120 |
2118 |
| 2121 /** |
2119 /** |
| 2122 * Converts a string to a single precision floating point number. |
2120 * Converts a string to a single precision floating-point number. |
| 2123 * |
2121 * |
| 2124 * The function returns non-zero when conversion is not possible. |
2122 * The function returns non-zero when conversion is not possible. |
| 2125 * 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. |
| 2126 * 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. |
| 2127 * |
2125 * |
| 2128 * @param str the string to convert |
2126 * @param str the string to convert |
| 2129 * @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 |
| 2130 * @param decsep the decimal separator |
2128 * @param decsep the decimal separator |
| 2131 * @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 |
| 2132 * @retval zero success |
2130 * @retval zero success |
| 2133 * @retval non-zero conversion was not possible |
2131 * @retval non-zero conversion was not possible |
| 2134 */ |
2132 */ |
| 2135 #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) |
| 2136 |
2134 |
| 2137 /** |
2135 /** |
| 2138 * Converts a string to a double precision floating point number. |
2136 * Converts a string to a double precision floating-point number. |
| 2139 * |
2137 * |
| 2140 * The function returns non-zero when conversion is not possible. |
2138 * The function returns non-zero when conversion is not possible. |
| 2141 * 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. |
| 2142 * |
2140 * |
| 2143 * @param str the string to convert |
2141 * @param str the string to convert |
| 2144 * @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 |
| 2145 * @param decsep the decimal separator |
2143 * @param decsep the decimal separator |
| 2146 * @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 |
| 2147 * @retval zero success |
2145 * @retval zero success |
| 2148 * @retval non-zero conversion was not possible |
2146 * @retval non-zero conversion was not possible |
| 2149 */ |
2147 */ |
| 2150 #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) |
| 2151 |
2149 |
| 2152 /** |
2150 /** |
| 2153 * Converts a string to a single precision floating point number. |
2151 * Converts a string to a single precision floating-point number. |
| 2154 * |
2152 * |
| 2155 * The function returns non-zero when conversion is not possible. |
2153 * The function returns non-zero when conversion is not possible. |
| 2156 * 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. |
| 2157 * 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. |
| 2158 * |
2156 * |
| 2159 * The decimal separator is assumed to be a dot character. |
2157 * The decimal separator is assumed to be a dot character. |
| 2160 * 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. |
| 2161 * 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(). |
| 2162 * |
2160 * |
| 2163 * @param str the string to convert |
2161 * @param str the string to convert |
| 2164 * @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 |
| 2165 * @retval zero success |
2163 * @retval zero success |
| 2166 * @retval non-zero conversion was not possible |
2164 * @retval non-zero conversion was not possible |
| 2167 */ |
2165 */ |
| 2168 #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, '.', ",") |
| 2169 |
2167 |
| 2170 /** |
2168 /** |
| 2171 * Converts a string to a double precision floating point number. |
2169 * Converts a string to a double precision floating-point number. |
| 2172 * |
2170 * |
| 2173 * The function returns non-zero when conversion is not possible. |
2171 * The function returns non-zero when conversion is not possible. |
| 2174 * 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. |
| 2175 * |
2173 * |
| 2176 * The decimal separator is assumed to be a dot character. |
2174 * The decimal separator is assumed to be a dot character. |
| 2177 * 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. |
| 2178 * 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(). |
| 2179 * |
2177 * |
| 2180 * @param str the string to convert |
2178 * @param str the string to convert |
| 2181 * @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 |
| 2182 * @retval zero success |
2180 * @retval zero success |