8 /* struct s_Buffer declaration. */
9 typedef struct s_Buffer {
10 char *data; /* the buffer data. */
11 size_t size; /* the buffer size (in bytes). */
12 size_t capacity; /* the buffer capacity (in bytes). */
13 } s_Buffer_t, *Buffer_t;
15 /* Asserts that a s_Buffer is valid. */
16 #define ASSERT_VALID_Buffer(p) ( ASSERT_NOT_NULL(p) /*&& ASSERT_NOT_NULL((p)->data)*/ )
18 /* The default buffer capacity (512 bytes). */
19 #define DEFAULT_Buffer_CAPACITY ((size_t)512)
21 /* struct s_buffet connected functions. */
23 /* Constructs an new buffer.
24 * If successful, the function returns a pointer to
25 * the new buffer. Otherwise, the function returns
28 Buffer_t Buffer_new(void);
30 /* Clears the buffer (this function don't destroy it,
31 * see Buffer_free function).
33 void Buffer_clear(Buffer_t buffer);
35 /* Appends a string in the buffer. If successful,
36 * the function returns true. Otherwise the function
39 bool Buffer_append(Buffer_t buffer, char *str);
42 * Removes all the linefeed from the buffer.
44 void Buffer_chomp(Buffer_t buffer);
49 void Buffer_free(Buffer_t buffer);
52 * This function returns true is the buffer is empty.
53 * Otherwrise the function returns false.
55 bool Buffer_empty(Buffer_t buffer);
60 #endif /* #ifndef __BUFFER_H__ */