Warn if p == NULL && max != 0. (#110087)
[platform/upstream/glib.git] / glib / gstring.h
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /*
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/. 
25  */
26
27 #ifndef __G_STRING_H__
28 #define __G_STRING_H__
29
30 #include <glib/gtypes.h>
31 #include <glib/gunicode.h>
32
33 G_BEGIN_DECLS
34
35 typedef struct _GString         GString;
36 typedef struct _GStringChunk    GStringChunk;
37
38 struct _GString
39 {
40   gchar  *str;
41   gsize len;    
42   gsize allocated_len;
43 };
44
45 /* String Chunks
46  */
47 GStringChunk* g_string_chunk_new           (gsize size);  
48 void          g_string_chunk_free          (GStringChunk *chunk);
49 gchar*        g_string_chunk_insert        (GStringChunk *chunk,
50                                             const gchar  *string);
51 gchar*        g_string_chunk_insert_len    (GStringChunk *chunk,
52                                             const gchar  *string,
53                                             gssize        len);
54 gchar*        g_string_chunk_insert_const  (GStringChunk *chunk,
55                                             const gchar  *string);
56
57
58 /* Strings
59  */
60 GString*     g_string_new               (const gchar     *init);
61 GString*     g_string_new_len           (const gchar     *init,
62                                          gssize           len);   
63 GString*     g_string_sized_new         (gsize            dfl_size);  
64 gchar*       g_string_free              (GString         *string,
65                                          gboolean         free_segment);
66 gboolean     g_string_equal             (const GString   *v,
67                                          const GString   *v2);
68 guint        g_string_hash              (const GString   *str);
69 GString*     g_string_assign            (GString         *string,
70                                          const gchar     *rval);
71 GString*     g_string_truncate          (GString         *string,
72                                          gsize            len);    
73 GString*     g_string_set_size          (GString         *string,
74                                          gsize            len);
75 GString*     g_string_insert_len        (GString         *string,
76                                          gssize           pos,   
77                                          const gchar     *val,
78                                          gssize           len);  
79 GString*     g_string_append            (GString         *string,
80                                          const gchar     *val);
81 GString*     g_string_append_len        (GString         *string,
82                                          const gchar     *val,
83                                          gssize           len);  
84 GString*     g_string_append_c          (GString         *string,
85                                          gchar            c);
86 GString*     g_string_append_unichar    (GString         *string,
87                                          gunichar         wc);
88 GString*     g_string_prepend           (GString         *string,
89                                          const gchar     *val);
90 GString*     g_string_prepend_c         (GString         *string,
91                                          gchar            c);
92 GString*     g_string_prepend_unichar   (GString         *string,
93                                          gunichar         wc);
94 GString*     g_string_prepend_len       (GString         *string,
95                                          const gchar     *val,
96                                          gssize           len);  
97 GString*     g_string_insert            (GString         *string,
98                                          gssize           pos,    
99                                          const gchar     *val);
100 GString*     g_string_insert_c          (GString         *string,
101                                          gssize           pos,    
102                                          gchar            c);
103 GString*     g_string_insert_unichar    (GString         *string,
104                                          gssize           pos,    
105                                          gunichar         wc);
106 GString*     g_string_erase             (GString         *string,
107                                          gssize           pos,
108                                          gssize           len);
109 GString*     g_string_ascii_down        (GString         *string);
110 GString*     g_string_ascii_up          (GString         *string);
111 void         g_string_printf            (GString         *string,
112                                          const gchar     *format,
113                                          ...) G_GNUC_PRINTF (2, 3);
114 void         g_string_append_printf     (GString         *string,
115                                          const gchar     *format,
116                                          ...) G_GNUC_PRINTF (2, 3);
117
118 #ifndef G_DISABLE_DEPRECATED
119
120 /* The following two functions are deprecated and will be removed in
121  * the next major release. They use the locale-specific tolower and
122  * toupper, which is almost never the right thing.
123  */
124
125 GString*     g_string_down              (GString         *string);
126 GString*     g_string_up                (GString         *string);
127
128 /* These aliases are included for compatibility. */
129 #define g_string_sprintf        g_string_printf
130 #define g_string_sprintfa       g_string_append_printf
131
132 #endif /* G_DISABLE_DEPRECATED */
133
134 G_END_DECLS
135
136 #endif /* __G_STRING_H__ */
137