#include <string.h>
#include <glib.h>
Go to the source code of this file.
Data Structures | |
| struct | StringList |
| StringList is a structure that stores a list of constant strings. More... | |
Functions | |
| StringList * | stringList_new () |
| Create a new StringList instance. | |
| StringList * | stringList_sized_new (size_t chunk_size, size_t element_count, size_t const_count) |
| Create a new StringList instance with given sizes. | |
| void | stringList_clear (StringList *sList) |
| Clear all content of Stringlist. | |
| int | stringList_find_string (StringList *sList, const char *str) |
| Find a string in StringList. | |
| char ** | stringList_to_charPointerPointer (StringList *sList) |
| Return a char pointer pointer (char **) which points to the list of strings. | |
| const char * | stringList_index (StringList *sList, guint index) |
| Return the string at the given index. | |
| guint | stringList_insert (StringList *sList, const char *str) |
| Insert a string to StringList. | |
| guint | stringList_insert_const (StringList *sList, const char *str) |
| Insert a constant string to StringList. | |
| void | stringList_free (StringList *sList) |
| Free the StringList instance. | |
| char * | initString (char *str) |
| Initialize the string by setting the first char to 0x0. | |
| gboolean | isEmptyString (const char *str) |
| Check whether the string is NULL or have 0 length. | |
| void | string_trim (char *str) |
| Trim the leading and trailing whitespace of the string. | |
| char * | subString (char *buf, const char *str, int beginIndex, int length) |
| Returns a substring of the given string. | |
| char * | ucs4_to_utf8 (gunichar ucs4_code) |
| Convert UCS-4 to UTF-8 string. | |
| gunichar * | utf8_to_ucs4 (const char *utf8_str) |
| Convert UTF-8 string to UCS-4 (gunichar). | |
| char * | utf8_concat_ucs4 (char *utf8_str, gunichar ucs4_code) |
| Concatenate a UCS-4 (gunichar) to an UTF-8 string. | |
| int | strcmp_unsigned_signed (const unsigned char *str1, const char *str2) |
| Compare between signed and unsigned char arrays. | |
| unsigned char * | signedStr_to_unsignedStr (const char *str) |
| Convert the signed char string to a new allocated unsigned char string. | |
| unsigned char * | signedStr_to_unsignedStr_buffer (unsigned char *resultBuf, const char *str) |
| Convert the signed char string to the unsigned char string buffer. | |
| char * | unsignedStr_to_signedStr (const unsigned char *str) |
| Convert the unsigned char string to a new allocated signed char string. | |
| char * | unsignedStr_to_signedStr_buffer (char *resultBuf, const unsigned char *str) |
| Convert the unsigned char string to the signed char string buffer. | |
| char* initString | ( | char * | str | ) |
If str is NULL, then an char array with MAX_STRING_BUFFER_SIZE will be assined.
| str | String to be initialize, NULL for allocate a new string.. |
| gboolean isEmptyString | ( | const char * | str | ) |
| str | String to be check. |
| unsigned char* signedStr_to_unsignedStr | ( | const char * | str | ) |
| str | Signed char string. |
| unsigned char* signedStr_to_unsignedStr_buffer | ( | unsigned char * | resultBuf, | |
| const char * | str | |||
| ) |
| resultBuf | The buffer that stored the conversion result. | |
| str | Signed char string. |
| int strcmp_unsigned_signed | ( | const unsigned char * | str1, | |
| const char * | str2 | |||
| ) |
It behaves like strcmp() except the comparison is between a unsigned string (char array) and signed string. Mainly for GCC 4.3
| str1 | Unsigned string to be compared. | |
| str2 | Signed string to be compared. |
| void string_trim | ( | char * | str | ) |
Note the content of str might be changed. Use strdup() or g_strdup() to backup.
| str | String to be trim. |
| void stringList_clear | ( | StringList * | sList | ) |
| sList | The StringList to be processed. |
| int stringList_find_string | ( | StringList * | sList, | |
| const char * | str | |||
| ) |
If found, this function returns the index of the string from 0, otherwise returns -1.
| sList | The StringList to be processed. | |
| str | The character to be found. |
| void stringList_free | ( | StringList * | sList | ) |
Note that this function assumes the sList is not NULL. Use if (sList) stringList_free(sList); to tolerate the NULL parameter.
| sList | The StringList to be processed. |
| const char* stringList_index | ( | StringList * | sList, | |
| guint | index | |||
| ) |
| sList | The StringList to be processed. | |
| index | The given index. |
| guint stringList_insert | ( | StringList * | sList, | |
| const char * | str | |||
| ) |
This functions copies the str to the string list. It behaves like g_string_chunk_insert(), that is, it does not check for the duplicates. However, it returns the index instead of char pointer of inserted string.
The difference between this function and stringList_insert_const() is that each inserted identical string will have it own spaces.
| sList | The StringList to be processed. | |
| str | String to be inserted, can be NULL. |
| guint stringList_insert_const | ( | StringList * | sList, | |
| const char * | str | |||
| ) |
This functions copies the str to the string list. It behaves like g_string_chunk_insert_const(), that is, it checks for the duplicates. However, it returns the index instead of char pointer of inserted string.
The difference between this function and stringList_insert() is that each inserted identical string will share the same space.
| sList | The StringList to be processed. | |
| str | String to be inserted. |
| StringList* stringList_new | ( | ) |
| StringList* stringList_sized_new | ( | size_t | chunk_size, | |
| size_t | element_count, | |||
| size_t | const_count | |||
| ) |
This function allocate space for a StringList with given size, thus avoid frequent reallocation.
| chunk_size | Size in bytes required for string storage. | |
| element_count | Number of strings. | |
| const_count | Number of constant strings (strings without duplication). |
| char** stringList_to_charPointerPointer | ( | StringList * | sList | ) |
This function returns a char** which points to the places that strings are stored. The pointer directly points to content in StringList instance, so the returned pointer should not be free.
Use the stringList_free to free instead.
| sList | The StringList to be processed. |
| char* subString | ( | char * | buf, | |
| const char * | str, | |||
| int | beginIndex, | |||
| int | length | |||
| ) |
The substring begins at the specified beginIndex and end after length bytes. The index starts from zero.
| buf | buffer that stores the result. | |
| str | String to be process | |
| beginIndex | the beginning index, inclusive. | |
| length | total bytes to copy. |
| char* ucs4_to_utf8 | ( | gunichar | ucs4_code | ) |
| ucs4_code | the UCS-4 to be converted. |
| char* unsignedStr_to_signedStr | ( | const unsigned char * | str | ) |
| str | Unsigned char string. |
| char* unsignedStr_to_signedStr_buffer | ( | char * | resultBuf, | |
| const unsigned char * | str | |||
| ) |
| resultBuf | The buffer that stored the conversion result. | |
| str | Unsigned char string. |
| char* utf8_concat_ucs4 | ( | char * | utf8_str, | |
| gunichar | ucs4_code | |||
| ) |
| utf8_str | the UTF-8 string. | |
| ucs4_code | the UCS-4 to be appended. |
| gunichar* utf8_to_ucs4 | ( | const char * | utf8_str | ) |
| utf8_str | the UTF-8 string to be converted. |
1.5.6