2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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-Strings.html
46 * - GString* -> StringG
57 import tango
.io
.Stdout
; // use the tango loging?
61 private import gtkc
.glibtypes
;
63 private import gtkc
.glib
;
66 private import glib
.Str
;
73 * A GString is similar to a standard C string, except that it grows automatically
74 * as text is appended or inserted. Also, it stores the length of the string, so
75 * can be used for binary data with embedded nul bytes.
80 /** the main Gtk struct */
81 protected GString
* gString
;
84 public GString
* getStringGStruct()
90 /** the main Gtk struct as a void* */
91 protected void* getStruct()
93 return cast(void*)gString
;
97 * Sets our main struct and passes it to the parent class
99 public this (GString
* gString
)
103 if ( gString
is null )
108 Stdout("struct gString is null on constructor").newline
;
112 printf("struct gString is null on constructor");
119 assert(gString
!is null, "struct gString is null on constructor");
121 this.gString
= gString
;
129 * Creates a new GString, initialized with the given string.
131 * the initial text to copy into the string.
135 public this (char[] init
)
137 // GString* g_string_new (const gchar *init);
138 this(cast(GString
*)g_string_new(Str
.toStringz(init
)) );
142 * Creates a new GString with len bytes of the
143 * init buffer. Because a length is provided, init
144 * need not be nul-terminated, and can contain embedded
146 * Since this function does not stop at nul bytes, it is the caller's
147 * responsibility to ensure that init has at least len addressable bytes.
149 * initial contents of string.
151 * length of init to use.
155 public this (char[] init
, int len
)
157 // GString* g_string_new_len (const gchar *init, gssize len);
158 this(cast(GString
*)g_string_new_len(Str
.toStringz(init
), len
) );
162 * Creates a new GString, with enough space for dfl_size
163 * bytes. This is useful if you are going to add a lot of
164 * text to the string and don't want it to be reallocated
167 * the default size of the space allocated to
172 public static StringG
sizedNew(uint dflSize
)
174 // GString* g_string_sized_new (gsize dfl_size);
175 return new StringG( g_string_sized_new(dflSize
) );
179 * Copies the bytes from a string into a GString,
180 * destroying any previous contents. It is rather like
181 * the standard strcpy() function, except that you do not
182 * have to worry about having enough space to copy the string.
184 * the destination GString. Its current contents
187 * the string to copy into string
189 * the destination GString.
191 public StringG
assign(char[] rval
)
193 // GString* g_string_assign (GString *string, const gchar *rval);
194 return new StringG( g_string_assign(gString
, Str
.toStringz(rval
)) );
200 * Writes a formatted string into a GString.
201 * This is similar to the standard sprintf() function,
202 * except that the GString buffer automatically expands
203 * to contain the results. The previous contents of the
204 * GString are destroyed.
208 * the string format. See the printf() documentation.
210 * the parameters to insert into the format string.
212 public void printf(char[] format
, ... )
214 // void g_string_printf (GString *string, const gchar *format, ...);
215 g_string_printf(gString
, Str
.toStringz(format
));
219 * Appends a formatted string onto the end of a GString.
220 * This function is is similar to g_string_printf() except
221 * that the text is appended to the GString.
225 * the string format. See the printf() documentation.
227 * the parameters to insert into the format string.
229 public void appendPrintf(char[] format
, ... )
231 // void g_string_append_printf (GString *string, const gchar *format, ...);
232 g_string_append_printf(gString
, Str
.toStringz(format
));
236 * Adds a string onto the end of a GString, expanding it if necessary.
240 * the string to append onto the end of the GString.
244 public StringG
append(char[] val
)
246 // GString* g_string_append (GString *string, const gchar *val);
247 return new StringG( g_string_append(gString
, Str
.toStringz(val
)) );
251 * Adds a byte onto the end of a GString, expanding it if necessary.
255 * the byte to append onto the end of the GString.
259 public StringG
appendC(char c
)
261 // GString* g_string_append_c (GString *string, gchar c);
262 return new StringG( g_string_append_c(gString
, c
) );
266 * Converts a Unicode character into UTF-8, and appends it
271 * a Unicode character
275 public StringG
appendUnichar(gunichar wc
)
277 // GString* g_string_append_unichar (GString *string, gunichar wc);
278 return new StringG( g_string_append_unichar(gString
, wc
) );
282 * Appends len bytes of val to string.
283 * Because len is provided, val may contain
284 * embedded nuls and need not be nul-terminated.
285 * Since this function does not stop at nul bytes, it is the caller's
286 * responsibility to ensure that val has at least len addressable bytes.
292 * number of bytes of val to use.
296 public StringG
appendLen(char[] val
, int len
)
298 // GString* g_string_append_len (GString *string, const gchar *val, gssize len);
299 return new StringG( g_string_append_len(gString
, Str
.toStringz(val
), len
) );
303 * Adds a string on to the start of a GString,
304 * expanding it if necessary.
308 * the string to prepend on the start of the GString
312 public StringG
prepend(char[] val
)
314 // GString* g_string_prepend (GString *string, const gchar *val);
315 return new StringG( g_string_prepend(gString
, Str
.toStringz(val
)) );
319 * Adds a byte onto the start of a GString,
320 * expanding it if necessary.
324 * the byte to prepend on the start of the GString
328 public StringG
prependC(char c
)
330 // GString* g_string_prepend_c (GString *string, gchar c);
331 return new StringG( g_string_prepend_c(gString
, c
) );
335 * Converts a Unicode character into UTF-8, and prepends it
340 * a Unicode character.
344 public StringG
prependUnichar(gunichar wc
)
346 // GString* g_string_prepend_unichar (GString *string, gunichar wc);
347 return new StringG( g_string_prepend_unichar(gString
, wc
) );
351 * Prepends len bytes of val to string.
352 * Because len is provided, val may contain
353 * embedded nuls and need not be nul-terminated.
354 * Since this function does not stop at nul bytes, it is the caller's
355 * responsibility to ensure that val has at least len addressable bytes.
361 * number of bytes in val to prepend
363 * the GString passed in
365 public StringG
prependLen(char[] val
, int len
)
367 // GString* g_string_prepend_len (GString *string, const gchar *val, gssize len);
368 return new StringG( g_string_prepend_len(gString
, Str
.toStringz(val
), len
) );
372 * Inserts a copy of a string into a GString,
373 * expanding it if necessary.
377 * the position to insert the copy of the string
379 * the string to insert
383 public StringG
insert(int pos
, char[] val
)
385 // GString* g_string_insert (GString *string, gssize pos, const gchar *val);
386 return new StringG( g_string_insert(gString
, pos
, Str
.toStringz(val
)) );
390 * Inserts a byte into a GString, expanding it if necessary.
394 * the position to insert the byte
400 public StringG
insertC(int pos
, char c
)
402 // GString* g_string_insert_c (GString *string, gssize pos, gchar c);
403 return new StringG( g_string_insert_c(gString
, pos
, c
) );
407 * Converts a Unicode character into UTF-8, and insert it
408 * into the string at the given position.
412 * the position at which to insert character, or -1 to
413 * append at the end of the string.
415 * a Unicode character
419 public StringG
insertUnichar(int pos
, gunichar wc
)
421 // GString* g_string_insert_unichar (GString *string, gssize pos, gunichar wc);
422 return new StringG( g_string_insert_unichar(gString
, pos
, wc
) );
426 * Inserts len bytes of val into string at pos.
427 * Because len is provided, val may contain embedded
428 * nuls and need not be nul-terminated. If pos is -1,
429 * bytes are inserted at the end of the string.
430 * Since this function does not stop at nul bytes, it is the caller's
431 * responsibility to ensure that val has at least len addressable bytes.
435 * position in string where insertion should
436 * happen, or -1 for at the end
440 * number of bytes of val to insert
444 public StringG
insertLen(int pos
, char[] val
, int len
)
446 // GString* g_string_insert_len (GString *string, gssize pos, const gchar *val, gssize len);
447 return new StringG( g_string_insert_len(gString
, pos
, Str
.toStringz(val
), len
) );
451 * Removes len bytes from a GString, starting at position pos.
452 * The rest of the GString is shifted down to fill the gap.
456 * the position of the content to remove
458 * the number of bytes to remove, or -1 to remove all
463 public StringG
erase(int pos
, int len
)
465 // GString* g_string_erase (GString *string, gssize pos, gssize len);
466 return new StringG( g_string_erase(gString
, pos
, len
) );
470 * Cuts off the end of the GString, leaving the first len bytes.
474 * the new size of the GString
478 public StringG
truncate(uint len
)
480 // GString* g_string_truncate (GString *string, gsize len);
481 return new StringG( g_string_truncate(gString
, len
) );
485 * Sets the length of a GString. If the length is less than
486 * the current length, the string will be truncated. If the
487 * length is greater than the current length, the contents
488 * of the newly added area are undefined. (However, as
489 * always, string->str[string->len] will be a nul byte.)
497 public StringG
setSize(uint len
)
499 // GString* g_string_set_size (GString *string, gsize len);
500 return new StringG( g_string_set_size(gString
, len
) );
504 * Frees the memory allocated for the GString.
505 * If free_segment is TRUE it also frees the character data.
509 * if TRUE the actual character data is freed as well
511 * the character data of string
512 * (i.e. NULL if free_segment is TRUE)
514 public char[] free(int freeSegment
)
516 // gchar* g_string_free (GString *string, gboolean free_segment);
517 return Str
.toString(g_string_free(gString
, freeSegment
) );
522 * g_string_up has been deprecated since version 2.2 and should not be used in newly-written code. This function uses the locale-specific toupper() function,
523 * which is almost never the right thing. Use g_string_ascii_up() or
524 * g_utf8_strup() instead.
525 * Converts a GString to uppercase.
533 // GString* g_string_up (GString *string);
534 return new StringG( g_string_up(gString
) );
539 * g_string_down has been deprecated since version 2.2 and should not be used in newly-written code. This function uses the locale-specific tolower() function,
540 * which is almost never the right thing. Use g_string_ascii_down() or
541 * g_utf8_strdown() instead.
542 * Converts a GString to lowercase.
548 public StringG
down()
550 // GString* g_string_down (GString *string);
551 return new StringG( g_string_down(gString
) );
555 * Creates a hash code for str; for use with GHashTable.
563 // guint g_string_hash (const GString *str);
564 return g_string_hash(gString
);
568 * Compares two strings for equality, returning TRUE if they are equal.
569 * For use with GHashTable.
570 * Compares two strings for equality, returning TRUE if they are equal.
571 * For use with GHashTable.
577 * TRUE if they strings are the same
578 * length and contain the same bytes.
580 public int equal(StringG v2
)
582 // gboolean g_string_equal (const GString *v, const GString *v2);
583 return g_string_equal(gString
, (v2
is null) ?
null : v2
.getStringGStruct());