Next: , Previous: Ferret Booleans, Up: Ferret C Libraries


3.4 Ferret Strings

String processing is a very important task in any interactive tool. Definitely, Ferret should support more than the traditional (and english-like languages oriented) ASCII character set. These multilingual functionality should also be portable. The obvious alternative is to use the ISO/IEC 10640 standard, also known as the Unicode standard. Altought there exist several implementations of Unicode, Ferret uses the implementation found on the Tcl library. In that way, both Tcl and C Ferret components can share string data without many conversions.

Since the use by Ferret of the Unicode facilities implemented on the Tcl library could change some day, all other Ferret components access such facilities via an abstract data type: ferret_string_t.

— Data Type: ferret_string_t

This abstract data type implement a variable-size multilingual string, to be used on all Ferret components that manage strings.

This data type is composed by the following fields:

Tcl_DString *tcl_string
A Tcl string as implemented by the Tcl library.

— Data Type: ferret_string_list_t

This abstract data type implement a multipurpose list of ferret strings.

This data type is composed by the following fields:

struct _ferret_string_list_t *next
Link to the next ferret string into the list.

— Function: ferret_bool_t ferret_string_equal_p (fstring1, fstring2)

Determine if two ferret string have the same content.

Returns a ferret boolean.

— Function: ferret_bool_t ferret_string_value_equal_p (fstring, string)

Determine if the ferret string fstring has a copy of string as its internal content.

— Function: ferret_string_t ferret_string_new (void)

Create a new ferret string.

Returns an empty newly created ferret string.

— Function: void ferret_string_free (fstring)

Destroy a ferret string, freeing used memory.

fstring should be a properly initialized ferret string.

— Function: int ferret_string_length (fstring)

Return the length, in characters, of fstring

— Function: char *ferret_string_value (fstring)

Return the characters string contained on fstring.

— Function: void ferret_string_truncate (fstring, newlength)

Truncate fstring to newlength.

— Function: ferret_string_t ferret_string_dup (fstring)

Make a copy of fstring and return it as a new ferret string.

— Function: void ferret_string_set_value (fstring, string)

Set string as the new content of fstring, destroying any previous contents.

— Function: ferret_bool_t ferret_string_match (fstring, pattern, nocase)

Try to match the ferret string pattern in fstring, and return a boolean value indicating the result of the matching process.

If the ferret boolean nocase is TRUE, then the matching process is case-insensitive.

— Function: void ferret_string_append (fstring1, fstring2, length)

Append the length prefix of fstring2 to fstring1.

— Function: void ferret_string_append_string (fstring, string, length)

Append the length prefix of string (a C string) to fstring.

— Function: ferret_string_append_integer (fstring, number, length)

Append the length prefix of the number string representation to fstring.

— Function: ferret_string_list_t ferret_string_list_new (void)

Create and return a new empty ferret string list.

— Function: ferret_bool_t ferret_string_list_empty_p (fslist)

Return a boolean value indicating if fslist is empty.

— Function: void ferret_string_list_append (fslist, fstring)

Insert fstring at the end of fslist.

— Function: void ferret_string_list_append_string (fslist, string)

Append a new ferret string with a copy of string (a C string) as its value to fslist.

— Function: int ferret_string_list_length (fslist)

Return the length of fslist.

— Function: ferret_string_t ferret_string_list_get (fslist, index)

Return a pointer to the indexth element of fslist.

— Function: void ferret_string_list_set_string (fslist, index, string)

Replace the contents of the indexth ferret string contained on fslist with string (a C string).

— Function: void ferret_string_list_set (fslist, index, fstring)

Replace the indexth string contained into fslist with fstring.

— Function: int ferret_string_list_search (fslist, fstring)

Search into fslist for fstring.

If the string is found, return the index of the string into the list. Else, return -1.

— Function: int ferret_string_list_search_string (fslist, string)

Search into fslist for a ferret string with string (a C string) as its value.

If the string is found, return the index of the string into the list. Else, return -1.

— Function: void ferret_string_list_free (fslist)

Destroy fslist and free the used memory.

— Function: ferret_string_list_t ferret_string_list_dup (fslist)

Build a copy of fslist and return it.