Logo AND Algorithmique Numérique Distribuée

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