aboutsummaryrefslogtreecommitdiff
path: root/include/libft_dstr.h
blob: fbe69dbc4049c26a12e4c09c2e7025a4d3724bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   libft_dstr.h                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/03 10:39:51 by charles           #+#    #+#             */
/*   Updated: 2020/04/04 23:33:27 by charles          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef LIBFT_DSTR_H
# define LIBFT_DSTR_H

# include <stdlib.h>
# include "libft_def.h"
# 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;
	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_dstrsubstitute(t_ftdstr *dstr, char *sub,
									size_t start, size_t end);

#endif