Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix format.
[simgrid.git] / win32_test_app / include / TBuffer.h
1 #ifndef __BUFFER_H__
2 #define __BUFFER_H__
3
4 #include <TErrno.h>
5 #include <string.h>
6 #include <stdlib.h>
7
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;
14
15 /* Asserts that a s_Buffer is valid. */
16 #define ASSERT_VALID_Buffer(p)  ( ASSERT_NOT_NULL(p) /*&& ASSERT_NOT_NULL((p)->data)*/ )
17
18 /* The default buffer capacity (512 bytes). */
19 #define DEFAULT_Buffer_CAPACITY ((size_t)512)
20
21 /* struct s_buffet connected functions. */
22
23 /* Constructs an new buffer.
24  * If successful, the function returns a pointer to 
25  * the new buffer. Otherwise, the function returns
26  * NULL. 
27  */
28 Buffer_t Buffer_new(void);
29
30 /* Clears the buffer (this function don't destroy it,
31  * see Buffer_free function). 
32  */
33 void Buffer_clear(Buffer_t buffer);
34
35 /* Appends a string in the buffer. If successful, 
36  * the function returns true. Otherwise the function
37  * returns false.
38  */
39 bool Buffer_append(Buffer_t buffer, char *str);
40
41 /* 
42  * Removes all the linefeed from the buffer. 
43  */
44 void Buffer_chomp(Buffer_t buffer);
45
46 /* 
47  * Destroy the buffer. 
48  */
49 void Buffer_free(Buffer_t buffer);
50
51 /* 
52  * This function returns true is the buffer is empty.
53  * Otherwrise the function returns false.
54  */
55 bool Buffer_empty(Buffer_t buffer);
56
57
58
59
60 #endif                          /* #ifndef __BUFFER_H__ */