I've no idea here...
[gtkD.git] / src / glib / StringGChunk.d
blob06e4fa90eab7e2aceba43e7d0696076e85a48a7f
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-String-Chunks.html
26 * outPack = glib
27 * outFile = StringGChunk
28 * strct = GStringChunk
29 * realStrct=
30 * ctorStrct=
31 * clss = StringGChunk
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_string_chunk_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * structWrap:
46 * local aliases:
49 module glib.StringGChunk;
51 private import glib.glibtypes;
53 private import lib.glib;
55 private import glib.Str;
57 /**
58 * Description
59 * String chunks are used to store groups of strings.
60 * Memory is allocated in blocks, and as strings are added to the GStringChunk
61 * they are copied into the next free position in a block. When a block is
62 * full a new block is allocated.
63 * When storing a large number of strings, string chunks are more efficient
64 * than using g_strdup() since fewer calls to malloc()
65 * are needed, and less memory is wasted in memory allocation overheads.
66 * By adding strings with g_string_chunk_insert_const() it is also possible
67 * to remove duplicates.
68 * To create a new GStringChunk use g_string_chunk_new().
69 * To add strings to a GStringChunk use g_string_chunk_insert().
70 * To add strings to a GStringChunk, but without duplicating strings which are
71 * already in the GStringChunk, use g_string_chunk_insert_const().
72 * To free the entire GStringChunk use g_string_chunk_free().
73 * It is not possible to free individual strings.
75 public class StringGChunk
78 /** the main Gtk struct */
79 protected GStringChunk* gStringChunk;
82 public GStringChunk* getStringGChunkStruct()
84 return gStringChunk;
88 /** the main Gtk struct as a void* */
89 protected void* getStruct()
91 return cast(void*)gStringChunk;
94 /**
95 * Sets our main struct and passes it to the parent class
97 public this (GStringChunk* gStringChunk)
99 this.gStringChunk = gStringChunk;
107 * Creates a new GStringChunk.
108 * size:
109 * the default size of the blocks of memory which are allocated to store
110 * the strings. If a particular string is larger than this default size, a larger
111 * block of memory will be allocated for it.
112 * Returns:
113 * a new GStringChunk.
115 public this (uint size)
117 // GStringChunk* g_string_chunk_new (gsize size);
118 this(cast(GStringChunk*)g_string_chunk_new(size) );
122 * Adds a copy of string to the GStringChunk.
123 * It returns a pointer to the new copy of the string in the GStringChunk.
124 * The characters in the string can be changed, if necessary, though you
125 * should not change anything after the end of the string.
126 * Unlike g_string_chunk_insert_const(), this function does not check for
127 * duplicates. Also strings added with g_string_chunk_insert() will not be
128 * searched by g_string_chunk_insert_const() when looking for duplicates.
129 * chunk:
130 * a GStringChunk.
131 * string:
132 * the string to add.
133 * Returns:
134 * a pointer to the copy of string within the GStringChunk.
136 public char[] insert(char[] string)
138 // gchar* g_string_chunk_insert (GStringChunk *chunk, const gchar *string);
139 return Str.toString(g_string_chunk_insert(gStringChunk, Str.toStringz(string)) );
143 * Adds a copy of string to the GStringChunk, unless the same string has
144 * already been added to the GStringChunk with g_string_chunk_insert_const().
145 * This function is useful if you need to copy a large number of strings
146 * but do not want to waste space storing duplicates. But you must remember
147 * that there may be several pointers to the same string, and so any changes
148 * made to the strings should be done very carefully.
149 * Note that g_string_chunk_insert_const() will not return a pointer to a string
150 * added with g_string_chunk_insert(), even if they do match.
151 * chunk:
152 * a GStringChunk.
153 * string:
154 * the string to add.
155 * Returns:
156 * a pointer to the new or existing copy of string within the
157 * GStringChunk.
159 public char[] insertConst(char[] string)
161 // gchar* g_string_chunk_insert_const (GStringChunk *chunk, const gchar *string);
162 return Str.toString(g_string_chunk_insert_const(gStringChunk, Str.toStringz(string)) );
166 * Adds a copy of the first len bytes of string to the GStringChunk. The
167 * copy is nul-terminated.
168 * The characters in the string can be changed, if necessary, though you
169 * should not change anything after the end of the string.
170 * chunk:
171 * a GStringChunk
172 * string:
173 * bytes to insert
174 * len:
175 * number of bytes of string to insert, or -1 to insert a
176 * nul-terminated string.
177 * Returns:
178 * a pointer to the copy of string within the GStringChunk
179 * Since 2.4
181 public char[] insertLen(char[] string, int len)
183 // gchar* g_string_chunk_insert_len (GStringChunk *chunk, const gchar *string, gssize len);
184 return Str.toString(g_string_chunk_insert_len(gStringChunk, Str.toStringz(string), len) );
188 * Frees all memory allocated by the GStringChunk.
189 * After calling g_string_chunk_free() it is not safe to
190 * access any of the strings which were contained within it.
191 * chunk:
192 * a GStringChunk.
194 public void free()
196 // void g_string_chunk_free (GStringChunk *chunk);
197 g_string_chunk_free(gStringChunk);