Norminette 'static' functions

This commit is contained in:
Maieul BOYER 2024-07-16 19:42:30 +02:00
parent 698d1088e2
commit 74336f37a3
No known key found for this signature in database
2 changed files with 86 additions and 73 deletions

View file

@ -1,4 +1,3 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
@ -7,14 +6,14 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/16 17:18:47 by maiboyer #+# #+# */
/* Updated: 2024/07/16 17:19:31 by maiboyer ### ########.fr */
/* Updated: 2024/07/16 19:41:42 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef NUMBERS_TO_STR_H
#define NUMBERS_TO_STR_H
# define NUMBERS_TO_STR_H
#include "me/types.h"
# include "me/types.h"
typedef struct s_num_str t_num_str;
typedef struct s_num_str_state t_num_str_state;
@ -39,7 +38,8 @@ struct s_num_str_state
t_usize idx;
};
union u_nums {
union u_nums
{
t_u64 u64;
t_i64 i64;
t_u32 u32;
@ -48,17 +48,17 @@ union u_nums {
t_i16 i16;
t_u8 u8;
t_i8 i8;
};
/// @brief Convert a signed 8-bit integer to a string with a base and a prefix.
/// @brief Convert a signed 8-bit integer to a string with a base + a prefix.
/// @param val The signed 8-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i8_to_str_base_prefix(t_i8 val, t_str base, t_str prefix, t_str *out);
t_error i8_to_str_base_prefix(t_i8 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a signed 8-bit integer to a string with a base
/// @param val The signed 8-bit integer to convert.
@ -66,7 +66,8 @@ t_error i8_to_str_base_prefix(t_i8 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i8_to_str_base(t_i8 val, t_str base, t_str *out);
t_error i8_to_str_base(t_i8 val, t_str base,
t_str *out);
/// @brief Convert a signed 8-bit integer to a string.
/// @param val The signed 8-bit integer to convert.
@ -74,14 +75,15 @@ t_error i8_to_str_base(t_i8 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error i8_to_str(t_i8 val, t_str *out);
/// @brief Convert a unsigned 8-bit integer to a string with a base and a prefix.
/// @brief Convert a unsigned 8-bit integer to a string with a base + a prefix.
/// @param val The unsigned 8-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u8_to_str_base_prefix(t_u8 val, t_str base, t_str prefix, t_str *out);
t_error u8_to_str_base_prefix(t_u8 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a unsigned 8-bit integer to a string with a base
/// @param val The unsigned 8-bit integer to convert.
@ -89,7 +91,8 @@ t_error u8_to_str_base_prefix(t_u8 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u8_to_str_base(t_u8 val, t_str base, t_str *out);
t_error u8_to_str_base(t_u8 val, t_str base,
t_str *out);
/// @brief Convert a unsigned 8-bit integer to a string.
/// @param val The unsigned 8-bit integer to convert.
@ -97,14 +100,15 @@ t_error u8_to_str_base(t_u8 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error u8_to_str(t_u8 val, t_str *out);
/// @brief Convert a signed 16-bit integer to a string with a base and a prefix.
/// @brief Convert a signed 16-bit integer to a string with a base + a prefix.
/// @param val The signed 16-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i16_to_str_base_prefix(t_i16 val, t_str base, t_str prefix, t_str *out);
t_error i16_to_str_base_prefix(t_i16 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a signed 16-bit integer to a string with a base
/// @param val The signed 16-bit integer to convert.
@ -112,7 +116,8 @@ t_error i16_to_str_base_prefix(t_i16 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i16_to_str_base(t_i16 val, t_str base, t_str *out);
t_error i16_to_str_base(t_i16 val, t_str base,
t_str *out);
/// @brief Convert a signed 16-bit integer to a string.
/// @param val The signed 16-bit integer to convert.
@ -120,14 +125,15 @@ t_error i16_to_str_base(t_i16 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error i16_to_str(t_i16 val, t_str *out);
/// @brief Convert a unsigned 16-bit integer to a string with a base and a prefix.
/// @brief Convert a unsigned 16-bit integer to a string with a base + a prefix.
/// @param val The unsigned 16-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u16_to_str_base_prefix(t_u16 val, t_str base, t_str prefix, t_str *out);
t_error u16_to_str_base_prefix(t_u16 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a unsigned 16-bit integer to a string with a base
/// @param val The unsigned 16-bit integer to convert.
@ -135,7 +141,8 @@ t_error u16_to_str_base_prefix(t_u16 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u16_to_str_base(t_u16 val, t_str base, t_str *out);
t_error u16_to_str_base(t_u16 val, t_str base,
t_str *out);
/// @brief Convert a unsigned 16-bit integer to a string.
/// @param val The unsigned 16-bit integer to convert.
@ -143,14 +150,15 @@ t_error u16_to_str_base(t_u16 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error u16_to_str(t_u16 val, t_str *out);
/// @brief Convert a signed 32-bit integer to a string with a base and a prefix.
/// @brief Convert a signed 32-bit integer to a string with a base + a prefix.
/// @param val The signed 32-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i32_to_str_base_prefix(t_i32 val, t_str base, t_str prefix, t_str *out);
t_error i32_to_str_base_prefix(t_i32 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a signed 32-bit integer to a string with a base
/// @param val The signed 32-bit integer to convert.
@ -158,7 +166,8 @@ t_error i32_to_str_base_prefix(t_i32 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i32_to_str_base(t_i32 val, t_str base, t_str *out);
t_error i32_to_str_base(t_i32 val, t_str base,
t_str *out);
/// @brief Convert a signed 32-bit integer to a string.
/// @param val The signed 32-bit integer to convert.
@ -166,14 +175,15 @@ t_error i32_to_str_base(t_i32 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error i32_to_str(t_i32 val, t_str *out);
/// @brief Convert a unsigned 32-bit integer to a string with a base and a prefix.
/// @brief Convert a unsigned 32-bit integer to a string with a base + a prefix.
/// @param val The unsigned 32-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u32_to_str_base_prefix(t_u32 val, t_str base, t_str prefix, t_str *out);
t_error u32_to_str_base_prefix(t_u32 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a unsigned 32-bit integer to a string with a base
/// @param val The unsigned 32-bit integer to convert.
@ -181,7 +191,8 @@ t_error u32_to_str_base_prefix(t_u32 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u32_to_str_base(t_u32 val, t_str base, t_str *out);
t_error u32_to_str_base(t_u32 val, t_str base,
t_str *out);
/// @brief Convert a unsigned 32-bit integer to a string.
/// @param val The unsigned 32-bit integer to convert.
@ -196,7 +207,8 @@ t_error u32_to_str(t_u32 val, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i64_to_str_base_prefix(t_i64 val, t_str base, t_str prefix, t_str *out);
t_error i64_to_str_base_prefix(t_i64 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a signed 64-bit integer to a string with a base
/// @param val The signed 64-bit integer to convert.
@ -204,7 +216,8 @@ t_error i64_to_str_base_prefix(t_i64 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error i64_to_str_base(t_i64 val, t_str base, t_str *out);
t_error i64_to_str_base(t_i64 val, t_str base,
t_str *out);
/// @brief Convert a signed 64-bit integer to a string.
/// @param val The signed 64-bit integer to convert.
@ -212,14 +225,15 @@ t_error i64_to_str_base(t_i64 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error i64_to_str(t_i64 val, t_str *out);
/// @brief Convert a unsigned 64-bit integer to a string with a base and a prefix.
/// @brief Convert a unsigned 64-bit integer to a string with a base + a prefix.
/// @param val The unsigned 64-bit integer to convert.
/// @param base The base to use for the conversion.
/// @param prefix The prefix to use for the conversion.
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u64_to_str_base_prefix(t_u64 val, t_str base, t_str prefix, t_str *out);
t_error u64_to_str_base_prefix(t_u64 val, t_str base,
t_str prefix, t_str *out);
/// @brief Convert a unsigned 64-bit integer to a string with a base
/// @param val The unsigned 64-bit integer to convert.
@ -227,7 +241,8 @@ t_error u64_to_str_base_prefix(t_u64 val, t_str base, t_str prefix, t_str *out);
/// @param out The output string.
/// @return True in case of error, false otherwise.
/// @note The base must be a string of at least 2 characters and no duplicates.
t_error u64_to_str_base(t_u64 val, t_str base, t_str *out);
t_error u64_to_str_base(t_u64 val, t_str base,
t_str *out);
/// @brief Convert a unsigned 64-bit integer to a string.
/// @param val The unsigned 64-bit integer to convert.
@ -235,5 +250,4 @@ t_error u64_to_str_base(t_u64 val, t_str base, t_str *out);
/// @return True in case of error, false otherwise.
t_error u64_to_str(t_u64 val, t_str *out);
#endif /* NUMBERS_TO_STR_H */

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/16 18:15:57 by maiboyer #+# #+# */
/* Updated: 2024/07/16 18:19:42 by maiboyer ### ########.fr */
/* Updated: 2024/07/16 19:39:57 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -96,4 +96,3 @@ t_error _format_u64(t_num_str args, t_str *out)
return (ERROR);
return (*out = res, NO_ERROR);
}