From bf263810b0a47a68fae0681e6e6d2229a488c069 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 15:11:33 +0200 Subject: Added Dynamic string struct (no test, no doc) --- include/libft_dstr.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/libft_dstr.h (limited to 'include/libft_dstr.h') diff --git a/include/libft_dstr.h b/include/libft_dstr.h new file mode 100644 index 0000000..13cb4e3 --- /dev/null +++ b/include/libft_dstr.h @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dstr.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 10:39:51 by charles #+# #+# */ +/* Updated: 2020/04/03 15:10:54 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DSTR_H +# define LIBFT_DSTR_H + +# include +# include "libft_def.h" +# include "libft_str.h" +# include "libft_mem.h" + +typedef struct s_ftdstr +{ + char *str; + size_t length; + size_t capacity; +} t_ftdstr; + +t_ftdstr *ft_dstrnew(char *from); +void ft_dstrdestroy(t_ftdstr *dstr); +t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); +char *ft_dstrunwrap(t_ftdstr *dstr); +t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); +// t_ftdstr *ft_dstrreplace(t_ftdstr *dstr, char *from, char *to); + +#endif -- cgit From 42316d8393d32bd88fb8e0cba6825185f78dacd0 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 21:28:21 +0200 Subject: Added test and doc for dynamic string --- include/libft_dstr.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/libft_dstr.h') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index 13cb4e3..11bf2f4 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/03 15:10:54 by charles ### ########.fr */ +/* Updated: 2020/04/04 21:18:48 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,13 @@ # include "libft_str.h" # include "libft_mem.h" +/* +** \brief Dynamic string struct +** \param str Underlying null-terminated character array +** \param length Number of character (not including the '\0') +** \param capacity Maximum length - 1 of the current string +*/ + typedef struct s_ftdstr { char *str; @@ -30,6 +37,6 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -// t_ftdstr *ft_dstrreplace(t_ftdstr *dstr, char *from, char *to); +// t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, size_t start, size_t end); #endif -- cgit From 65cf641e9533b190db870d0cc46f2f852239ebf6 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 23:36:19 +0200 Subject: Added test for ft_strsjoin, ft_strsjoinf, ft_vecpush_safe, Added doc for algo functions, tested functions --- include/libft_dstr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/libft_dstr.h') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index 11bf2f4..fbe69db 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/04 21:18:48 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:33:27 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,7 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -// t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, size_t start, size_t end); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, + size_t start, size_t end); #endif -- cgit From 944a236443bacf531085b346d06907b24e3739b1 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 5 Apr 2020 01:11:50 +0200 Subject: Added ft_dstrerase, ft_dstrsubstitute --- include/libft_dstr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/libft_dstr.h') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index fbe69db..732e475 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/04 23:33:27 by charles ### ########.fr */ +/* Updated: 2020/04/05 00:37:05 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,8 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, +void ft_dstrerase(t_ftdstr *dstr, size_t start, size_t len); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *replacement, size_t start, size_t end); #endif -- cgit