Project:DUI

Class List Class Hierarchy
Summary: Ctors Methods Mixins

Module dglib.StringG

Class StringG

Implemented interfaces:


public class

StringG



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.

Constructor Summary
(GString* gString)
          Creates a StringG from a GtkStringG
(String init)
          Creates a new GString, initialized with the given string.
(String init, gssize len)
          Creates a new GString with len bytes of the init buffer.
(gsize dfl_size)
          Creates a new GString, with enough space for dflSize characters.

Methods Summary
public GString* getG()
          
StringG assign(String rval)
          Copies the characters from a string into a GString, destroying any previous contents.
void printf(String format, ... )
          Writes a formatted string into a GString.
void appendPrintf(String format, ... )
          Appends a formatted string onto the end of a GString.
StringG append(String val)
          Adds a string onto the end of a GString, expanding it if necessary.
StringG appendC(gchar c)
          Adds a character 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(String val, gssize len)
          Appends len bytes of val to string.
StringG prepend(String val)
          Adds a string on to the start of a GString, expanding it if necessary.
StringG prependC(gchar c)
          Adds a character 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(String val, gssize len)
          Prepends len bytes of val to string.
StringG insert(gssize pos, String val)
          Inserts a copy of a string into a GString, expanding it if necessary.
StringG insertC(gssize pos, gchar c)
          Inserts a character into a GString, expanding it if necessary.
StringG insertUnichar(gssize pos, gunichar wc)
          Converts a Unicode character into UTF-8, and insert it into the string at the given position.
StringG insertLen(gssize pos, String val, gssize len)
          Inserts len bytes of val into string at pos.
StringG erase(gssize pos, gssize len)
          Removes len characters from a GString, starting at position pos.
StringG truncate(gsize len)
          Cuts off the end of the GString, leaving the first len characters.
StringG setSize(gsize len)
          Sets the length of a GString.
String free(bit free_segment)
          Frees the memory allocated for the GString.
StringG up()
          Warning
gStringUp is deprecated and should not be used in newly-written code.
StringG down()
          Warning
gStringDown is deprecated and should not be used in newly-written code.
guint hash()
          Creates a hash code for str; for use with GHashTable.
bit equal(StringG v2)
          Compares two strings for equality, returning TRUE if they are equal.


getG

public GString* getG()



ctor(StringG)(GString* gString)
Creates a StringG from a GtkStringG

Parameters:
*gtkWidget - the gtk struct address pointer

Returns:



ctor(StringG)(String init)
Creates a new GString, initialized with the given string.

Parameters:
init - the initial text to copy into the string.

Returns:
the new GString.



ctor(StringG)(String init, gssize 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.

Parameters:
init - initial contents of string.
len - length of init to use.

Returns:
a new GString.



ctor(StringG)(gsize dfl_size)
Creates a new GString, with enough space for dflSize characters.
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.

Parameters:
dflSize - the default size of the space allocated to hold the string.

Returns:
the new GString.

assign

StringG assign(String rval)
Copies the characters 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.

Parameters:
string - the destination GString. Its current contents are destroyed.
rval -

Returns:
the destination GString.

printf

void printf(String 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.

Parameters:
string - a GString.
format - the string format. See the printf() documentation.
... - the parameters to insert into the format string.

appendPrintf

void appendPrintf(String format, ... )
Appends a formatted string onto the end of a GString.
This function is is similar to gStringPrintf() except that the text is appended to the GString.

Parameters:
string - a GString.
format - the string format. See the printf() documentation.
... - the parameters to insert into the format string.

append

StringG append(String val)
Adds a string onto the end of a GString, expanding it if necessary.

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

Returns:
the GString.

appendC

StringG appendC(gchar c)
Adds a character onto the end of a GString, expanding it if necessary.

Parameters:
string - a GString.
c - the character to append onto the end of the GString.

Returns:
the GString.

appendUnichar

StringG appendUnichar(gunichar wc)
Converts a Unicode character into UTF-8, and appends it to the string.

Parameters:
string - a GString
wc - a Unicode character

Returns:
string

appendLen

StringG appendLen(String val, gssize len)
Appends len bytes of val to string.
Because len is provided, val may contain embedded nuls and need not be nul-terminated.

Parameters:
string - a GString.
val - bytes to append.
len - number of bytes of val to use.

Returns:
the GString.

prepend

StringG prepend(String val)
Adds a string on to the start of a GString, expanding it if necessary.

Parameters:
string - a GString.
val - the string to prepend on the start of the GString.

Returns:
the GString.

prependC

StringG prependC(gchar c)
Adds a character onto the start of a GString, expanding it if necessary.

Parameters:
string - a GString.
c - the character to prepend on the start of the GString.

Returns:
the GString.

prependUnichar

StringG prependUnichar(gunichar wc)
Converts a Unicode character into UTF-8, and prepends it to the string.

Parameters:
string - a GString.
wc - a Unicode character.

Returns:
string.

prependLen

StringG prependLen(String val, gssize len)
Prepends len bytes of val to string.
Because len is provided, val may contain embedded nuls and need not be nul-terminated.

Parameters:
string - a GString.
val - bytes to prepend.
len - number of bytes in val to prepend.

Returns:
the GString passed in.

insert

StringG insert(gssize pos, String val)
Inserts a copy of a string into a GString, expanding it if necessary.

Parameters:
string - a GString.
pos - the position to insert the copy of the string.
val - the string to insert.

Returns:
the GString.

insertC

StringG insertC(gssize pos, gchar c)
Inserts a character into a GString, expanding it if necessary.

Parameters:
string - a GString.
pos - the position to insert the character.
c - the character to insert.

Returns:
the GString.

insertUnichar

StringG insertUnichar(gssize pos, gunichar wc)
Converts a Unicode character into UTF-8, and insert it into the string at the given position.

Parameters:
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

insertLen

StringG insertLen(gssize pos, String val, gssize 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.

Parameters:
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.

erase

StringG erase(gssize pos, gssize len)
Removes len characters from a GString, starting at position pos.
The rest of the GString is shifted down to fill the gap.

Parameters:
string - a GString.
pos - the position of the characters to remove.
len - the number of characters to remove, or -1 to remove all following characters.

Returns:
the GString.

truncate

StringG truncate(gsize len)
Cuts off the end of the GString, leaving the first len characters.

Parameters:
string - a GString.
len - the new size of the GString.

Returns:
the GString.

setSize

StringG setSize(gsize 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.)

Parameters:
string - a GString
len - the new length

Returns:
string

free

String free(bit free_segment)
Frees the memory allocated for the GString.
If freeSegment is TRUE it also frees the character data.

Parameters:
string - a GString.
freeSegment - if TRUE the actual character data is freed as well.

Returns:
the character data of string (i.e. NULL if freeSegment is TRUE)

up

StringG up()
Warning
gStringUp is deprecated 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 gStringAsciiUp() or gUtf8Strup() instead.
Converts a GString to uppercase.

Parameters:
string - a GString

Returns:
the GString

down

StringG down()
Warning
gStringDown is deprecated 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 gStringAsciiDown() or gUtf8Strdown() instead.
Converts a GString to lowercase.

Parameters:
string - a GString

Returns:
the GString.

hash

guint hash()
Creates a hash code for str; for use with GHashTable.

Parameters:
str - a string to hash.

Returns:
hash code for str.

equal

bit equal(StringG v2)
Compares two strings for equality, returning TRUE if they are equal.
For use with GHashTable.

Parameters:
v - a GString.
v2 - another GString.

Returns:
TRUE if they strings are the same length and contain the same bytes