docs: Fix GApplicationCommandLine typo
[glib.git] / glib / gstring.h
blob079734343004b1e7dba8cc50fb82be937fa9d053
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 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
28 #error "Only <glib.h> can be included directly."
29 #endif
31 #ifndef __G_STRING_H__
32 #define __G_STRING_H__
34 #include <glib/gtypes.h>
35 #include <glib/gunicode.h>
36 #include <glib/gutils.h> /* for G_CAN_INLINE */
38 G_BEGIN_DECLS
40 typedef struct _GString GString;
42 struct _GString
44 gchar *str;
45 gsize len;
46 gsize allocated_len;
49 GString* g_string_new (const gchar *init);
50 GString* g_string_new_len (const gchar *init,
51 gssize len);
52 GString* g_string_sized_new (gsize dfl_size);
53 gchar* g_string_free (GString *string,
54 gboolean free_segment);
55 gboolean g_string_equal (const GString *v,
56 const GString *v2);
57 guint g_string_hash (const GString *str);
58 GString* g_string_assign (GString *string,
59 const gchar *rval);
60 GString* g_string_truncate (GString *string,
61 gsize len);
62 GString* g_string_set_size (GString *string,
63 gsize len);
64 GString* g_string_insert_len (GString *string,
65 gssize pos,
66 const gchar *val,
67 gssize len);
68 GString* g_string_append (GString *string,
69 const gchar *val);
70 GString* g_string_append_len (GString *string,
71 const gchar *val,
72 gssize len);
73 GString* g_string_append_c (GString *string,
74 gchar c);
75 GString* g_string_append_unichar (GString *string,
76 gunichar wc);
77 GString* g_string_prepend (GString *string,
78 const gchar *val);
79 GString* g_string_prepend_c (GString *string,
80 gchar c);
81 GString* g_string_prepend_unichar (GString *string,
82 gunichar wc);
83 GString* g_string_prepend_len (GString *string,
84 const gchar *val,
85 gssize len);
86 GString* g_string_insert (GString *string,
87 gssize pos,
88 const gchar *val);
89 GString* g_string_insert_c (GString *string,
90 gssize pos,
91 gchar c);
92 GString* g_string_insert_unichar (GString *string,
93 gssize pos,
94 gunichar wc);
95 GString* g_string_overwrite (GString *string,
96 gsize pos,
97 const gchar *val);
98 GString* g_string_overwrite_len (GString *string,
99 gsize pos,
100 const gchar *val,
101 gssize len);
102 GString* g_string_erase (GString *string,
103 gssize pos,
104 gssize len);
105 GString* g_string_ascii_down (GString *string);
106 GString* g_string_ascii_up (GString *string);
107 void g_string_vprintf (GString *string,
108 const gchar *format,
109 va_list args);
110 void g_string_printf (GString *string,
111 const gchar *format,
112 ...) G_GNUC_PRINTF (2, 3);
113 void g_string_append_vprintf (GString *string,
114 const gchar *format,
115 va_list args);
116 void g_string_append_printf (GString *string,
117 const gchar *format,
118 ...) G_GNUC_PRINTF (2, 3);
119 GString* g_string_append_uri_escaped (GString *string,
120 const gchar *unescaped,
121 const gchar *reserved_chars_allowed,
122 gboolean allow_utf8);
124 /* -- optimize g_strig_append_c --- */
125 #ifdef G_CAN_INLINE
126 static inline GString*
127 g_string_append_c_inline (GString *gstring,
128 gchar c)
130 if (gstring->len + 1 < gstring->allocated_len)
132 gstring->str[gstring->len++] = c;
133 gstring->str[gstring->len] = 0;
135 else
136 g_string_insert_c (gstring, -1, c);
137 return gstring;
139 #define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c)
140 #endif /* G_CAN_INLINE */
143 GLIB_DEPRECATED
144 GString *g_string_down (GString *string);
145 GLIB_DEPRECATED
146 GString *g_string_up (GString *string);
148 #ifndef G_DISABLE_DEPRECATED
149 #define g_string_sprintf g_string_printf
150 #define g_string_sprintfa g_string_append_printf
151 #endif
153 G_END_DECLS
155 #endif /* __G_STRING_H__ */