glib.StringG.StringG Class Reference

List of all members.

Detailed Description

Description A GString is similar to a standard C string, except that it grows automatically as text is appended or inserted.

Also, it stores the length of the string, so can be used for binary data with embedded nul bytes.


Public Member Functions

GStringgetStringGStruct ()
 this (GString *gString)
 Sets our main struct and passes it to the parent class.
 this (char[] init)
 Creates a new GString, initialized with the given string.
 this (char[] init, int len)
 Creates a new GString with len bytes of the init buffer.
StringG assign (char[] rval)
 Copies the bytes from a string into a GString, destroying any previous contents.
void printf (char[] format,...)
 Writes a formatted string into a GString.
void appendPrintf (char[] format,...)
 Appends a formatted string onto the end of a GString.
StringG append (char[] val)
 Adds a string onto the end of a GString, expanding it if necessary.
StringG appendC (char c)
 Adds a byte onto the end of a GString, expanding it if necessary.
StringG appendUnichar (gunichar wc)
 Converts a Unicode character into UTF-8, and appends it to the string.
StringG appendLen (char[] val, int len)
 Appends len bytes of val to string.
StringG prepend (char[] val)
 Adds a string on to the start of a GString, expanding it if necessary.
StringG prependC (char c)
 Adds a byte onto the start of a GString, expanding it if necessary.
StringG prependUnichar (gunichar wc)
 Converts a Unicode character into UTF-8, and prepends it to the string.
StringG prependLen (char[] val, int len)
 Prepends len bytes of val to string.
StringG insert (int pos, char[] val)
 Inserts a copy of a string into a GString, expanding it if necessary.
StringG insertC (int pos, char c)
 Inserts a byte into a GString, expanding it if necessary.
StringG insertUnichar (int pos, gunichar wc)
 Converts a Unicode character into UTF-8, and insert it into the string at the given position.
StringG insertLen (int pos, char[] val, int len)
 Inserts len bytes of val into string at pos.
StringG erase (int pos, int len)
 Removes len bytes from a GString, starting at position pos.
StringG truncate (uint len)
 Cuts off the end of the GString, leaving the first len bytes.
StringG setSize (uint len)
 Sets the length of a GString.
char[] free (int freeSegment)
 Frees the memory allocated for the GString.
StringG up ()
 Warning g_string_up has been deprecated since version 2.2 and should not be used in newly-written code.
StringG down ()
 Warning g_string_down has been deprecated since version 2.2 and should not be used in newly-written code.
uint hash ()
 Creates a hash code for str; for use with GHashTable.
int equal (StringG v2)
 Compares two strings for equality, returning TRUE if they are equal.

Static Public Member Functions

static StringG sizedNew (uint dflSize)
 Creates a new GString, with enough space for dfl_size bytes.

Protected Member Functions

void * getStruct ()
 the main Gtk struct as a void*

Protected Attributes

GStringgString
 the main Gtk struct


Constructor & Destructor Documentation

glib.StringG.StringG.this ( GString gString  ) 

Sets our main struct and passes it to the parent class.

glib.StringG.StringG.this ( char[]  init  ) 

Creates a new GString, initialized with the given string.

init: the initial text to copy into the string. Returns: the new GString.

glib.StringG.StringG.this ( char[]  init,
int  len 
)

Creates a new GString with len bytes of the init buffer.

Because a length is provided, init need not be nul-terminated, and can contain embedded nul bytes. Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that init has at least len addressable bytes. init: initial contents of string. len: length of init to use. Returns: a new GString.


Member Function Documentation

StringG glib.StringG.StringG.append ( char[]  val  ) 

Adds a string onto the end of a GString, expanding it if necessary.

string: a GString. val: the string to append onto the end of the GString. Returns: the GString.

StringG glib.StringG.StringG.appendC ( char  c  ) 

Adds a byte onto the end of a GString, expanding it if necessary.

string: a GString. c: the byte to append onto the end of the GString. Returns: the GString.

StringG glib.StringG.StringG.appendLen ( char[]  val,
int  len 
)

Appends len bytes of val to string.

Because len is provided, val may contain embedded nuls and need not be nul-terminated. Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that val has at least len addressable bytes. string: a GString val: bytes to append len: number of bytes of val to use. Returns: the GString

void glib.StringG.StringG.appendPrintf ( char[]  format,
  ... 
)

Appends a formatted string onto the end of a GString.

This function is is similar to g_string_printf() except that the text is appended to the GString. string: a GString. format: the string format. See the printf() documentation. ...: the parameters to insert into the format string.

StringG glib.StringG.StringG.appendUnichar ( gunichar  wc  ) 

Converts a Unicode character into UTF-8, and appends it to the string.

string: a GString wc: a Unicode character Returns: string

StringG glib.StringG.StringG.assign ( char[]  rval  ) 

Copies the bytes from a string into a GString, destroying any previous contents.

It is rather like the standard strcpy() function, except that you do not have to worry about having enough space to copy the string. string: the destination GString. Its current contents are destroyed. rval: the string to copy into string Returns: the destination GString.

StringG glib.StringG.StringG.down (  ) 

Warning 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, which is almost never the right thing. Use g_string_ascii_down() or g_utf8_strdown() instead. Converts a GString to lowercase. string: a GString Returns: the GString.

int glib.StringG.StringG.equal ( StringG  v2  ) 

Compares two strings for equality, returning TRUE if they are equal.

For use with GHashTable. Compares two strings for equality, returning TRUE if they are equal. For use with GHashTable. v: a GString v2: another GString Returns: TRUE if they strings are the same length and contain the same bytes.

StringG glib.StringG.StringG.erase ( int  pos,
int  len 
)

Removes len bytes from a GString, starting at position pos.

The rest of the GString is shifted down to fill the gap. string: a GString pos: the position of the content to remove len: the number of bytes to remove, or -1 to remove all following bytes Returns: the GString

char [] glib.StringG.StringG.free ( int  freeSegment  ) 

Frees the memory allocated for the GString.

If free_segment is TRUE it also frees the character data. string: a GString free_segment: if TRUE the actual character data is freed as well Returns: the character data of string (i.e. NULL if free_segment is TRUE)

GString* glib.StringG.StringG.getStringGStruct (  ) 

void* glib.StringG.StringG.getStruct (  )  [protected]

the main Gtk struct as a void*

uint glib.StringG.StringG.hash (  ) 

Creates a hash code for str; for use with GHashTable.

str: a string to hash Returns: hash code for str

StringG glib.StringG.StringG.insert ( int  pos,
char[]  val 
)

Inserts a copy of a string into a GString, expanding it if necessary.

string: a GString pos: the position to insert the copy of the string val: the string to insert Returns: the GString

StringG glib.StringG.StringG.insertC ( int  pos,
char  c 
)

Inserts a byte into a GString, expanding it if necessary.

string: a GString pos: the position to insert the byte c: the byte to insert Returns: the GString

StringG glib.StringG.StringG.insertLen ( int  pos,
char[]  val,
int  len 
)

Inserts len bytes of val into string at pos.

Because len is provided, val may contain embedded nuls and need not be nul-terminated. If pos is -1, bytes are inserted at the end of the string. Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that val has at least len addressable bytes. string: a GString pos: position in string where insertion should happen, or -1 for at the end val: bytes to insert len: number of bytes of val to insert Returns: the GString

StringG glib.StringG.StringG.insertUnichar ( int  pos,
gunichar  wc 
)

Converts a Unicode character into UTF-8, and insert it into the string at the given position.

string: a GString pos: the position at which to insert character, or -1 to append at the end of the string. wc: a Unicode character Returns: string

StringG glib.StringG.StringG.prepend ( char[]  val  ) 

Adds a string on to the start of a GString, expanding it if necessary.

string: a GString val: the string to prepend on the start of the GString Returns: the GString

StringG glib.StringG.StringG.prependC ( char  c  ) 

Adds a byte onto the start of a GString, expanding it if necessary.

string: a GString c: the byte to prepend on the start of the GString Returns: the GString

StringG glib.StringG.StringG.prependLen ( char[]  val,
int  len 
)

Prepends len bytes of val to string.

Because len is provided, val may contain embedded nuls and need not be nul-terminated. Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that val has at least len addressable bytes. string: a GString val: bytes to prepend len: number of bytes in val to prepend Returns: the GString passed in

StringG glib.StringG.StringG.prependUnichar ( gunichar  wc  ) 

Converts a Unicode character into UTF-8, and prepends it to the string.

string: a GString. wc: a Unicode character. Returns: string.

void glib.StringG.StringG.printf ( char[]  format,
  ... 
)

Writes a formatted string into a GString.

This is similar to the standard sprintf() function, except that the GString buffer automatically expands to contain the results. The previous contents of the GString are destroyed. string: a GString. format: the string format. See the printf() documentation. ...: the parameters to insert into the format string.

StringG glib.StringG.StringG.setSize ( uint  len  ) 

Sets the length of a GString.

If the length is less than the current length, the string will be truncated. If the length is greater than the current length, the contents of the newly added area are undefined. (However, as always, string->str[string->len] will be a nul byte.) string: a GString len: the new length Returns: string

static StringG glib.StringG.StringG.sizedNew ( uint  dflSize  )  [static]

Creates a new GString, with enough space for dfl_size bytes.

This is useful if you are going to add a lot of text to the string and don't want it to be reallocated too often. dfl_size: the default size of the space allocated to hold the string. Returns: the new GString.

StringG glib.StringG.StringG.truncate ( uint  len  ) 

Cuts off the end of the GString, leaving the first len bytes.

string: a GString len: the new size of the GString Returns: the GString

StringG glib.StringG.StringG.up (  ) 

Warning 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, which is almost never the right thing. Use g_string_ascii_up() or g_utf8_strup() instead. Converts a GString to uppercase. string: a GString Returns: the GString


Member Data Documentation

GString* glib.StringG.StringG.gString [protected]

the main Gtk struct


SourceForge.net Logo DSource.org Logo digitalmars.com Logo