1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module glib.gstring;
7 
8 import glib.gtypes;
9 import glib.gunicode;
10 import glib.garray;
11 import glib.gutils;
12 
13 import core.stdc.stdarg;
14 
15 struct GString
16 {
17   gchar  *str;
18   gsize len;
19   gsize allocated_len;
20 }
21 
22 
23 /* -- optimize g_strig_append_c --- */
24 GString *g_string_append_c_inline (GString *gstr, gchar c)
25 {
26     if (gstr.len+1 < gstr.allocated_len)
27     {
28         gstr.str[gstr.len++] = c;
29         gstr.str[gstr.len] = 0;
30     }
31     else {
32         g_string_insert_c(gstr, -1, c);
33     }
34     return gstr;
35 }
36 
37 
38 
39 
40 extern (C) {
41 
42 
43     GString*     g_string_new               (const(gchar)     *init);
44 
45     GString*     g_string_new_len           (const(gchar)     *init,
46                                              gssize           len);
47 
48     GString*     g_string_sized_new         (gsize            dfl_size);
49 
50     gchar*       g_string_free              (GString         *str,
51                                              gboolean         free_segment);
52 
53     GBytes*      g_string_free_to_bytes     (GString         *str);
54 
55     gboolean     g_string_equal             (const(GString)   *v,
56                                              const(GString)   *v2);
57 
58     guint        g_string_hash              (const(GString)   *str);
59 
60     GString*     g_string_assign            (GString         *str,
61                                              const(gchar)     *rval);
62 
63     GString*     g_string_truncate          (GString         *str,
64                                              gsize            len);
65 
66     GString*     g_string_set_size          (GString         *str,
67                                              gsize            len);
68 
69     GString*     g_string_insert_len        (GString         *str,
70                                              gssize           pos,
71                                              const(gchar)     *val,
72                                              gssize           len);
73 
74     GString*     g_string_append            (GString         *str,
75                                              const(gchar)     *val);
76 
77     GString*     g_string_append_len        (GString         *str,
78                                              const(gchar)     *val,
79                                              gssize           len);
80 
81     GString*     g_string_append_c          (GString         *str,
82                                              gchar            c);
83 
84     GString*     g_string_append_unichar    (GString         *str,
85                                              gunichar         wc);
86 
87     GString*     g_string_prepend           (GString         *str,
88                                              const(gchar)     *val);
89 
90     GString*     g_string_prepend_c         (GString         *str,
91                                              gchar            c);
92 
93     GString*     g_string_prepend_unichar   (GString         *str,
94                                              gunichar         wc);
95 
96     GString*     g_string_prepend_len       (GString         *str,
97                                              const(gchar)     *val,
98                                              gssize           len);
99 
100     GString*     g_string_insert            (GString         *str,
101                                              gssize           pos,
102                                              const(gchar)     *val);
103 
104     GString*     g_string_insert_c          (GString         *str,
105                                              gssize           pos,
106                                              gchar            c);
107 
108     GString*     g_string_insert_unichar    (GString         *str,
109                                              gssize           pos,
110                                              gunichar         wc);
111 
112     GString*     g_string_overwrite         (GString         *str,
113                                              gsize            pos,
114                                              const(gchar)     *val);
115 
116     GString*     g_string_overwrite_len     (GString         *str,
117                                              gsize            pos,
118                                              const(gchar)     *val,
119                                              gssize           len);
120 
121     GString*     g_string_erase             (GString         *str,
122                                              gssize           pos,
123                                              gssize           len);
124 
125     GString*     g_string_ascii_down        (GString         *str);
126 
127     GString*     g_string_ascii_up          (GString         *str);
128 
129     void         g_string_vprintf           (GString         *str,
130                                              const(gchar)     *format,
131                                              va_list          args);
132 
133     void         g_string_printf            (GString         *str,
134                                              const(gchar)     *format,
135                                              ...);
136 
137     void         g_string_append_vprintf    (GString         *str,
138                                              const(gchar)     *format,
139                                              va_list          args);
140 
141     void         g_string_append_printf     (GString         *str,
142                                              const(gchar)     *format,
143                                              ...);
144 
145     GString*     g_string_append_uri_escaped (GString         *str,
146                                               const(gchar)     *unescaped,
147                                               const(gchar)     *reserved_chars_allowed,
148                                               gboolean         allow_utf8);
149 
150     deprecated
151     GString *g_string_down (GString *string);
152     deprecated
153     GString *g_string_up   (GString *string);
154 
155 }
156