Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2949420011d8aef0c0fabb5aafc1bfd4a0ee2ae7
[simgrid.git] / include / xbt / strbuff.h
1 /* strbuff -- string buffers                                                */
2
3 /* Copyright (c) 2007-2011, 2013-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef XBT_STRBUFF_H
10 #define XBT_STRBUFF_H
11
12 #include "xbt/sysdep.h"
13 #include "xbt/function_types.h"
14 #include "xbt/log.h"
15 #include "xbt/str.h"
16 #include "xbt/dict.h"
17
18 SG_BEGIN_DECL()
19
20 /** @defgroup xbt_strbuff String buffers 
21  *  @ingroup XBT_adt
22  * 
23  *  This data container is very similar to the Java StringBuffer: 
24  *  that's a string to which you can add content with a lesser performance 
25  *  penalty than if you recreate a new string from scratch. Once done building 
26  *  your string, you must retrieve the content and free its container.
27  * 
28  *  @{
29  */
30
31 /** @brief Buffer data container **/
32 struct xbt_strbuff {
33   char *data;
34   int used, size;
35 };
36 typedef struct xbt_strbuff  s_xbt_strbuff_t;
37 typedef struct xbt_strbuff* xbt_strbuff_t;
38
39 XBT_PUBLIC(void) xbt_strbuff_empty(xbt_strbuff_t b);
40 XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new(void);
41 XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new_from(const char *s);
42 XBT_PUBLIC(void) xbt_strbuff_free(xbt_strbuff_t b);
43 XBT_PUBLIC(void) xbt_strbuff_free_container(xbt_strbuff_t b);
44 XBT_PUBLIC(void) xbt_strbuff_append(xbt_strbuff_t b, const char *toadd);
45 XBT_PUBLIC(void) xbt_strbuff_chomp(xbt_strbuff_t b);
46 XBT_PUBLIC(void) xbt_strbuff_trim(xbt_strbuff_t b);
47 XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns);
48
49 /** @} */
50 SG_END_DECL()
51 #endif