/ gwstringbuffer.h / Functions / Description

Functions



gw_string_buffer_new

Creates a new string buffer
GWStringBuffer * gw_string_buffer_new ( void);
This function constructs a string buffer with no characters in it and an initial capacity of 0 characters.

Result: A pointer to the string buffer structure. Returns NULL when an error occured..


gw_string_buffer_new_from_str

Creates a new string buffer from a string
GWStringBuffer * gw_string_buffer_new_from_str ( const gchar *str);
This function constructs a string buffer from the specified string. So that it represents the same sequence of characters as the string argument; in other words, the initial contents of the string buffer is a copy of the argument string. The initial capacity of the string buffer is 0 plus the length of the string argument.

Parameters
str the initial contents of the string buffer

Result: A pointer to the string buffer structure. Returns NULL when an error occured..


gw_string_buffer_resize

Resizes the new string buffer capacity
gulong gw_string_buffer_resize ( GWStringBuffer *p, gulong newsize);
This function resizes the string buffer capacity. It only can increase the string buffer capacity and not decrease it. So the the new size must bigger than the actual string buffer capacity.

Result: The new string buffer capacity.
Returns 0 when the new size is smaller than the string capacity or when an error occured..


gw_string_buffer_delete

Deletes the characters in a substring of the string buffer
gulong gw_string_buffer_delete ( GWStringBuffer *p, gulong start, gulong end);
This function removes the characters in a substring of this string buffer. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the string buffer if no such character exists. If start is equal to end, no changes are made.

Parameters
p the string buffer to removes somes characters
start the strat of the substring to remove (inclusive)
end the end of the substring to remove (exclusive)

Result: The number of deleted characters.
Returns 0 if the start is negative, greater than the string buffer length or greater than end; or when an error occured..


gw_string_buffer_delete_all

Deletes all the characters of the string buffer
gulong gw_string_buffer_delete_all ( GWStringBuffer *p);
This function removes all the characters of this string buffer.

Parameters
p the string buffer to removes somes characters

Result: The number of deleted characters.
Returns 0 when an error occured..


gw_string_buffer_set_str

Sets the given string to the string buffer
void gw_string_buffer_set_str ( GWStringBuffer *p, gchar *str, gulong len);
This function set the given string the the string buffer

Parameters
p the string buffer to sets the given string
str the string to set
len the length of the given string


gw_string_buffer_append_str

Appends the given string to this string buffer.
void gw_string_buffer_append_str ( GWStringBuffer *p, gchar *str, gulong len);
This function appends the given string to this string buffer. The characters of the string argument are appended, in order, to the contents of this string buffer, increasing the length of this string buffer by the length of the third argument. If str is NULL, no string is appended to the string buffer.

Parameters
p the string buffer to append the given string
str the string to append
len the length of the given string, this is the number of characters to append


gw_string_buffer_insert_str

Inserts the given string into this string buffer at the specified index position.
void gw_string_buffer_insert_str ( GWStringBuffer *p, gchar *str, gulong start, gulong len);
This function inserts the given string into this string buffer at the specified index position.
The characters of the string argument are inserted, in order, into the string buffer at the indicated offset, moving up any characters originally above that position and increasing the length of this string buffer by the length of the fourth argument. If str is NULL, no string is inserted to the string buffer.

Parameters
p the string buffer to insert the given string
str the string to insert
start the index where the string will be inserted. This argument must be greater than or equal to 0, and less than or equal to the length of this string buffer
len the length of the given string, this is the number of characters to insert


gw_string_buffer_replace_str

void gw_string_buffer_replace_str ( GWStringBuffer *p, gchar *str, gulong start, gulong end);
This function replaces by the given string the substring of the string buffer at the given position with the given length.
The characters of the string argument are used, in order, into the string buffer at the indicated offset, replacing any characters originall at this position.
If the string buffer capacity is less than the sum of the start argument and the len argument, the string buffer size is increased.

Parameters
p the string buffer where a substring must to be replaced.
str the string which must replace the substring.
start the index in the string buffer where the substring starts. This argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.
len the length of the given string, this is the number of characters to replace.


gw_string_buffer_replace_chr

void gw_string_buffer_replace_chr ( GWStringBuffer *p, gchar chr, gulong index);
This function replaces a specified character in the string buffer by the given character at the given position.


Parameters
p the string buffer where a character must to be replaced.
chr the character which must replace the specified character.
index the index in the string buffer where the specified character to replace is located. This argument must be greater than or equal to 0, and less than or equal to the length of this string buffer.


gw_string_buffer_get_str

Returns the internal string.
gchar * gw_string_buffer_get_str ( GWStringBuffer *p);
This function returns the internal string. This one is the string representation of the given string buffer.

Parameters
p the string buffer to get the string form.

Result: the string form of the string buffer otherwize returns NULL if an error was occured or if the string buffer is empty..


gw_string_buffer_get_size

Returns the string buffer size.
gulong gw_string_buffer_get_size ( GWStringBuffer *p);
this function returns the string buffer size. This size correspond with the string buffer capacity.

Parameters
p the string buffer to get the size.

Result: the string buffer capacity or 0 an error was occured..


gw_string_buffer_free

Frees the given string buffer.
void gw_string_buffer_free ( GWStringBuffer *p);
This function frees the given string buffer. If this string buffer contains an internal buffer, this buffer will be freed too.

Parameters
p the string buffer to free.