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, see <http://www.gnu.org/licenses/>.
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 #ifndef __G_STRING_H__
26 #define __G_STRING_H__
28 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29 #error "Only <glib.h> can be included directly."
32 #include <glib/gtypes.h>
33 #include <glib/gunicode.h>
34 #include <glib/gbytes.h>
35 #include <glib/gutils.h> /* for G_CAN_INLINE */
39 typedef struct _GString GString;
49 GString* g_string_new (const gchar *init);
51 GString* g_string_new_len (const gchar *init,
54 GString* g_string_sized_new (gsize dfl_size);
56 gchar* g_string_free (GString *string,
57 gboolean free_segment);
58 GLIB_AVAILABLE_IN_2_34
59 GBytes* g_string_free_to_bytes (GString *string);
61 gboolean g_string_equal (const GString *v,
64 guint g_string_hash (const GString *str);
66 GString* g_string_assign (GString *string,
69 GString* g_string_truncate (GString *string,
72 GString* g_string_set_size (GString *string,
75 GString* g_string_insert_len (GString *string,
80 GString* g_string_append (GString *string,
83 GString* g_string_append_len (GString *string,
87 GString* g_string_append_c (GString *string,
90 GString* g_string_append_unichar (GString *string,
93 GString* g_string_prepend (GString *string,
96 GString* g_string_prepend_c (GString *string,
99 GString* g_string_prepend_unichar (GString *string,
101 GLIB_AVAILABLE_IN_ALL
102 GString* g_string_prepend_len (GString *string,
105 GLIB_AVAILABLE_IN_ALL
106 GString* g_string_insert (GString *string,
109 GLIB_AVAILABLE_IN_ALL
110 GString* g_string_insert_c (GString *string,
113 GLIB_AVAILABLE_IN_ALL
114 GString* g_string_insert_unichar (GString *string,
117 GLIB_AVAILABLE_IN_ALL
118 GString* g_string_overwrite (GString *string,
121 GLIB_AVAILABLE_IN_ALL
122 GString* g_string_overwrite_len (GString *string,
126 GLIB_AVAILABLE_IN_ALL
127 GString* g_string_erase (GString *string,
130 GLIB_AVAILABLE_IN_ALL
131 GString* g_string_ascii_down (GString *string);
132 GLIB_AVAILABLE_IN_ALL
133 GString* g_string_ascii_up (GString *string);
134 GLIB_AVAILABLE_IN_ALL
135 void g_string_vprintf (GString *string,
139 GLIB_AVAILABLE_IN_ALL
140 void g_string_printf (GString *string,
142 ...) G_GNUC_PRINTF (2, 3);
143 GLIB_AVAILABLE_IN_ALL
144 void g_string_append_vprintf (GString *string,
148 GLIB_AVAILABLE_IN_ALL
149 void g_string_append_printf (GString *string,
151 ...) G_GNUC_PRINTF (2, 3);
152 GLIB_AVAILABLE_IN_ALL
153 GString* g_string_append_uri_escaped (GString *string,
154 const gchar *unescaped,
155 const gchar *reserved_chars_allowed,
156 gboolean allow_utf8);
158 /* -- optimize g_strig_append_c --- */
160 static inline GString*
161 g_string_append_c_inline (GString *gstring,
164 if (gstring->len + 1 < gstring->allocated_len)
166 gstring->str[gstring->len++] = c;
167 gstring->str[gstring->len] = 0;
170 g_string_insert_c (gstring, -1, c);
173 #define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c)
174 #endif /* G_CAN_INLINE */
178 GString *g_string_down (GString *string);
180 GString *g_string_up (GString *string);
182 #ifndef G_DISABLE_DEPRECATED
183 #define g_string_sprintf g_string_printf
184 #define g_string_sprintfa g_string_append_printf
189 #endif /* __G_STRING_H__ */