update stuff

This commit is contained in:
Maix0 2024-05-20 00:35:39 +02:00
parent 5973022688
commit 544ed8b045
194 changed files with 2060 additions and 1464 deletions

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_clone.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 16:05:48 by maiboyer #+# #+# */
/* Updated: 2023/12/11 17:30:19 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_CLONE_H
# define STR_CLONE_H
# include "me/types.h"
t_str str_clone(t_const_str source);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_compare.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 18:53:47 by maiboyer #+# #+# */
/* Updated: 2024/05/04 18:37:55 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_COMPARE_H
# define STR_COMPARE_H
# include "me/types.h"
bool str_compare(t_const_str lhs, t_const_str rhs);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_find_chr.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 17:29:13 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:07:01 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_FIND_CHR_H
# define STR_FIND_CHR_H
# include "me/types.h"
char *str_find_chr(t_const_str str, char chr);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_find_rev_chr.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 17:29:13 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:07:15 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_FIND_REV_CHR_H
# define STR_FIND_REV_CHR_H
# include "me/types.h"
char *str_find_rev_chr(t_const_str str, char chr);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_find_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/10 11:11:01 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:53:44 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_FIND_STR_H
# define STR_FIND_STR_H
# include "me/types.h"
const char *str_find_str(t_const_str str, t_const_str to_find);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_iter.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 18:26:00 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:08:09 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_ITER_H
# define STR_ITER_H
# include "me/types.h"
void str_iter(t_str s, void (*f)(t_usize, char *));
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_join.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 23:02:58 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:08:32 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_JOIN_H
# define STR_JOIN_H
# include "me/types.h"
t_str str_join(t_const_str s1, t_const_str s2);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_l_cat.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/09 18:01:09 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:09:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_L_CAT_H
# define STR_L_CAT_H
# include "me/types.h"
t_usize str_l_cat(t_str dest, t_const_str src, t_usize buffer_size);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_l_copy.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/09 18:01:09 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:09:38 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_L_COPY_H
# define STR_L_COPY_H
# include "me/types.h"
t_usize str_l_copy(t_str dest, t_const_str src, t_usize buffer_size);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_len.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 17:07:41 by maiboyer #+# #+# */
/* Updated: 2023/12/11 16:08:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_LEN_H
# define STR_LEN_H
# include "me/types.h"
t_usize str_len(t_const_str str);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_map.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/09 18:26:00 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:11:40 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_MAP_H
# define STR_MAP_H
# include "me/types.h"
t_str str_map(t_const_str s, char (*f)(t_usize, char));
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_n_compare.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/04 18:53:47 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:17:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_N_COMPARE_H
# define STR_N_COMPARE_H
# include "me/types.h"
t_i32 str_n_compare(t_const_str lhs, t_const_str rhs, t_usize n);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_n_find_str.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/10 11:11:01 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:53:35 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_N_FIND_STR_H
# define STR_N_FIND_STR_H
# include "me/types.h"
const char *str_n_find_str(t_const_str str, t_const_str to_find, t_usize len);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_split.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/17 15:56:59 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:18:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_SPLIT_H
# define STR_SPLIT_H
# include "me/types.h"
t_str *str_split(t_const_str str, char chr);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_substring.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 22:42:55 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:18:41 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_SUBSTRING_H
# define STR_SUBSTRING_H
# include "me/types.h"
t_str str_substring(t_const_str str, t_usize start, t_usize len);
#endif

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* str_trim.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 23:43:42 by maiboyer #+# #+# */
/* Updated: 2023/12/09 16:19:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STR_TRIM_H
# define STR_TRIM_H
# include "me/types.h"
t_str str_trim(t_const_str str, t_const_str charset);
#endif

View file

@ -0,0 +1,77 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* string.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 17:54:28 by maiboyer #+# #+# */
/* Updated: 2024/04/30 14:14:42 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STRING_H
# define STRING_H
# include "me/types.h"
typedef struct s_string
{
t_str buf;
t_usize capacity;
t_usize len;
} t_string;
/// @brief Push a string to a buffer
/// @param buf the string to be pushed to
/// @param to_push the string to push
/// @return true if it failed, false otherwise
t_error string_push(t_string *buf, t_const_str to_push);
/// @brief Push a character to a buffer
/// @param buf the string to be pushed to
/// @param to_push the character to push
/// @return true if it failed, false otherwise
t_error string_push_char(t_string *buf, char to_push);
/// @brief Clear a string
/// @param buf the string to clear
void string_clear(t_string *buf);
/// @brief Create a new string
/// @param capacity the initial capacity of the string
/// @return the created string
t_string string_new(t_usize capacity);
/// @brief Make the string able to hold at least size characters if not already
/// @param buf the string to operate on
/// @param size the minimum size of the string wanted
/// @return true if it failed, false otherwise
t_error string_reserve(t_string *buf, t_usize size);
/// @brief free a string
/// @param buf the string to free
static inline void string_free(t_string buf)
{
void mem_free(void *);
mem_free(buf.buf);
}
/// @brief Pop a character from a string
/// @param buf the string to pop from
/// @return the popped character, or '\0' if the string is empty
static inline char string_pop(t_string *buf)
{
char c;
c = '\0';
if (buf->buf && buf->len)
{
c = buf->buf[buf->len - 1];
buf->buf[buf->len - 1] = '\0';
}
return (c);
}
#endif