1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
27 #ifndef __G_STRING_H__
28 #define __G_STRING_H__
30 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31 #error "Only <glib.h> can be included directly."
34 #include <glib/gtypes.h>
35 #include <glib/gunicode.h>
36 #include <glib/gbytes.h>
37 #include <glib/gutils.h> /* for G_CAN_INLINE */
41 typedef struct _GString GString
;
51 GString
* g_string_new (const gchar
*init
);
53 GString
* g_string_new_len (const gchar
*init
,
56 GString
* g_string_sized_new (gsize dfl_size
);
58 gchar
* g_string_free (GString
*string
,
59 gboolean free_segment
);
60 GLIB_AVAILABLE_IN_2_34
61 GBytes
* g_string_free_to_bytes (GString
*string
);
63 gboolean
g_string_equal (const GString
*v
,
66 guint
g_string_hash (const GString
*str
);
68 GString
* g_string_assign (GString
*string
,
71 GString
* g_string_truncate (GString
*string
,
74 GString
* g_string_set_size (GString
*string
,
77 GString
* g_string_insert_len (GString
*string
,
82 GString
* g_string_append (GString
*string
,
85 GString
* g_string_append_len (GString
*string
,
89 GString
* g_string_append_c (GString
*string
,
92 GString
* g_string_append_unichar (GString
*string
,
95 GString
* g_string_prepend (GString
*string
,
98 GString
* g_string_prepend_c (GString
*string
,
100 GLIB_AVAILABLE_IN_ALL
101 GString
* g_string_prepend_unichar (GString
*string
,
103 GLIB_AVAILABLE_IN_ALL
104 GString
* g_string_prepend_len (GString
*string
,
107 GLIB_AVAILABLE_IN_ALL
108 GString
* g_string_insert (GString
*string
,
111 GLIB_AVAILABLE_IN_ALL
112 GString
* g_string_insert_c (GString
*string
,
115 GLIB_AVAILABLE_IN_ALL
116 GString
* g_string_insert_unichar (GString
*string
,
119 GLIB_AVAILABLE_IN_ALL
120 GString
* g_string_overwrite (GString
*string
,
123 GLIB_AVAILABLE_IN_ALL
124 GString
* g_string_overwrite_len (GString
*string
,
128 GLIB_AVAILABLE_IN_ALL
129 GString
* g_string_erase (GString
*string
,
132 GLIB_AVAILABLE_IN_ALL
133 GString
* g_string_ascii_down (GString
*string
);
134 GLIB_AVAILABLE_IN_ALL
135 GString
* g_string_ascii_up (GString
*string
);
136 GLIB_AVAILABLE_IN_ALL
137 void g_string_vprintf (GString
*string
,
141 GLIB_AVAILABLE_IN_ALL
142 void g_string_printf (GString
*string
,
144 ...) G_GNUC_PRINTF (2, 3);
145 GLIB_AVAILABLE_IN_ALL
146 void g_string_append_vprintf (GString
*string
,
150 GLIB_AVAILABLE_IN_ALL
151 void g_string_append_printf (GString
*string
,
153 ...) G_GNUC_PRINTF (2, 3);
154 GLIB_AVAILABLE_IN_ALL
155 GString
* g_string_append_uri_escaped (GString
*string
,
156 const gchar
*unescaped
,
157 const gchar
*reserved_chars_allowed
,
158 gboolean allow_utf8
);
160 /* -- optimize g_strig_append_c --- */
162 static inline GString
*
163 g_string_append_c_inline (GString
*gstring
,
166 if (gstring
->len
+ 1 < gstring
->allocated_len
)
168 gstring
->str
[gstring
->len
++] = c
;
169 gstring
->str
[gstring
->len
] = 0;
172 g_string_insert_c (gstring
, -1, c
);
175 #define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c)
176 #endif /* G_CAN_INLINE */
180 GString
*g_string_down (GString
*string
);
182 GString
*g_string_up (GString
*string
);
184 #ifndef G_DISABLE_DEPRECATED
185 #define g_string_sprintf g_string_printf
186 #define g_string_sprintfa g_string_append_printf
191 #endif /* __G_STRING_H__ */