8 /* struct s_Buffer declaration. */
9 typedef struct s_Buffer
11 char* data; /* the buffer data. */
12 size_t size; /* the buffer size (in bytes). */
13 size_t capacity; /* the buffer capacity (in bytes). */
14 }s_Buffer_t,* Buffer_t;
16 /* Asserts that a s_Buffer is valid. */
17 #define ASSERT_VALID_Buffer(p) ( ASSERT_NOT_NULL((p)) /*&& ASSERT_NOT_NULL((p)->data)*/ )
19 /* The default buffer capacity (512 bytes). */
20 #define DEFAULT_Buffer_CAPACITY ((size_t)512)
22 /* struct s_buffet connected functions. */
24 /* Constructs an new buffer.
25 * If successful, the function returns a pointer to
26 * the new buffer. Otherwise, the function returns
29 Buffer_t Buffer_new(void);
31 /* Clears the buffer (this function don't destroy it,
32 * see Buffer_free function).
34 void Buffer_clear(Buffer_t buffer);
36 /* Appends a string in the buffer. If successful,
37 * the function returns true. Otherwise the function
40 bool Buffer_append(Buffer_t buffer,char* str);
43 * Removes all the linefeed from the buffer.
45 void Buffer_chomp(Buffer_t buffer);
50 void Buffer_free(Buffer_t buffer);
53 * This function returns true is the buffer is empty.
54 * Otherwrise the function returns false.
56 bool Buffer_empty(Buffer_t buffer);
61 #endif /* #ifndef __BUFFER_H__ */