00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __G_STRING_H__
00029 #define __G_STRING_H__
00030
00031 #include <_ansi.h>
00032 #include <glib/gtypes.h>
00033 #include <glib/gunicode.h>
00034 #include <glib/gutils.h>
00035
00036 G_BEGIN_DECLS
00037
00038 typedef struct _GString GString;
00039 typedef struct _GStringChunk GStringChunk;
00040
00041 struct _GString
00042 {
00043 gchar *str;
00044 gsize len;
00045 gsize allocated_len;
00046 };
00047
00048
00049
00050 IMPORT_C GStringChunk* g_string_chunk_new (gsize size);
00051 IMPORT_C void g_string_chunk_free (GStringChunk *chunk);
00052 IMPORT_C gchar* g_string_chunk_insert (GStringChunk *chunk,
00053 const gchar *string);
00054 IMPORT_C gchar* g_string_chunk_insert_len (GStringChunk *chunk,
00055 const gchar *string,
00056 gssize len);
00057 IMPORT_C gchar* g_string_chunk_insert_const (GStringChunk *chunk,
00058 const gchar *string);
00059
00060
00061
00062
00063 IMPORT_C GString* g_string_new (const gchar *init);
00064 IMPORT_C GString* g_string_new_len (const gchar *init,
00065 gssize len);
00066 IMPORT_C GString* g_string_sized_new (gsize dfl_size);
00067 IMPORT_C gchar* g_string_free (GString *string,
00068 gboolean free_segment);
00069 IMPORT_C gboolean g_string_equal (const GString *v,
00070 const GString *v2);
00071 IMPORT_C guint g_string_hash (const GString *str);
00072 IMPORT_C GString* g_string_assign (GString *string,
00073 const gchar *rval);
00074 IMPORT_C GString* g_string_truncate (GString *string,
00075 gsize len);
00076 IMPORT_C GString* g_string_set_size (GString *string,
00077 gsize len);
00078 IMPORT_C GString* g_string_insert_len (GString *string,
00079 gssize pos,
00080 const gchar *val,
00081 gssize len);
00082 IMPORT_C GString* g_string_append (GString *string,
00083 const gchar *val);
00084 IMPORT_C GString* g_string_append_len (GString *string,
00085 const gchar *val,
00086 gssize len);
00087 IMPORT_C GString* g_string_append_c (GString *string,
00088 gchar c);
00089 IMPORT_C GString* g_string_append_unichar (GString *string,
00090 gunichar wc);
00091 IMPORT_C GString* g_string_prepend (GString *string,
00092 const gchar *val);
00093 IMPORT_C GString* g_string_prepend_c (GString *string,
00094 gchar c);
00095 IMPORT_C GString* g_string_prepend_unichar (GString *string,
00096 gunichar wc);
00097 IMPORT_C GString* g_string_prepend_len (GString *string,
00098 const gchar *val,
00099 gssize len);
00100 IMPORT_C GString* g_string_insert (GString *string,
00101 gssize pos,
00102 const gchar *val);
00103 IMPORT_C GString* g_string_insert_c (GString *string,
00104 gssize pos,
00105 gchar c);
00106 IMPORT_C GString* g_string_insert_unichar (GString *string,
00107 gssize pos,
00108 gunichar wc);
00109 IMPORT_C GString* g_string_erase (GString *string,
00110 gssize pos,
00111 gssize len);
00112 IMPORT_C GString* g_string_ascii_down (GString *string);
00113 IMPORT_C GString* g_string_ascii_up (GString *string);
00114 IMPORT_C void g_string_printf (GString *string,
00115 const gchar *format,
00116 ...) G_GNUC_PRINTF (2, 3);
00117 IMPORT_C void g_string_append_printf (GString *string,
00118 const gchar *format,
00119 ...) G_GNUC_PRINTF (2, 3);
00120
00121
00122 #ifdef G_CAN_INLINE
00123 static inline GString*
00124 g_string_append_c_inline (GString *gstring,
00125 gchar c)
00126 {
00127 if (gstring->len + 1 < gstring->allocated_len)
00128 {
00129 gstring->str[gstring->len++] = c;
00130 gstring->str[gstring->len] = 0;
00131 }
00132 else
00133 g_string_insert_c (gstring, -1, c);
00134 return gstring;
00135 }
00136 #define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c)
00137 #endif
00138
00139
00140 #ifndef G_DISABLE_DEPRECATED
00141
00142
00143
00144
00145
00146
00147 IMPORT_C GString* g_string_down (GString *string);
00148 IMPORT_C GString* g_string_up (GString *string);
00149
00150
00151 #define g_string_sprintf g_string_printf
00152 #define g_string_sprintfa g_string_append_printf
00153
00154 #endif
00155
00156 G_END_DECLS
00157
00158 #endif
00159