TaPAS
0.2
|
Module gathering routines frequently used for the manipulation of string. More...
Go to the source code of this file.
Macros | |
#define | ccl_string_compare ((ccl_compare_func *) strcmp) |
String comparison. More... | |
#define | ccl_string_cmp strcmp |
String comparison. More... | |
Typedefs | |
typedef char * | ccl_ustring |
Alias type for strings that are stored in an internal dictionary and then can be used as identifiers and can be compared by pointers. | |
Functions | |
unsigned int | ccl_string_hash (const void *ptr) |
Hashes the string pointed by ptr. More... | |
void | ccl_string_delete (void *ptr) |
Deletion function for a string. | |
int | ccl_string_equals (const void *str1, const void *str2) |
Equality checking for strings. More... | |
char * | ccl_string_dup (const char *s) |
Duplicates the string s. More... | |
char * | ccl_string_format_new (const char *fmt,...) |
Allocates a formatted string. More... | |
char * | ccl_string_format_new_va (const char *fmt, va_list pa) |
Allocates a formatted string. More... | |
void | ccl_string_format (char **dst, size_t *size, const char *fmt,...) |
Allocates a formatted string. More... | |
void | ccl_string_format_va (char **dst, size_t *size, const char *fmt, va_list pa) |
Allocates a formatted string. More... | |
void | ccl_string_format_append (char **dst, const char *fmt,...) |
Appends a formatted string to *dst. More... | |
void | ccl_string_format_append_va (char **dst, const char *fmt, va_list pa) |
Appends a formatted string to *dst. More... | |
int | ccl_string_parse_int (const char *s) |
Interprets s as an integer value. More... | |
int | ccl_string_parse_boolean (const char *s) |
Interprets s as a Boolean value. More... | |
ccl_ustring | ccl_string_make_unique (const char *s) |
Creates a unique string from the string s. More... | |
ccl_ustring | ccl_string_make_unique_from_int (int i) |
Creates a unique string from an integer i. More... | |
Module gathering routines frequently used for the manipulation of string.
Definition in file ccl-string.h.
#define ccl_string_cmp strcmp |
#define ccl_string_compare ((ccl_compare_func *) strcmp) |
String comparison.
This function compares str1 and str2. This function returns a value less than, equal to or greater than zero if str1 is, respectively, less than, equal to or greater than str2. This function can be used where a pointer to a ccl_compare_func is required.
str1 | first string arg |
str2 | second string arg |
< | 0 if str1 < str2 |
== | 0 if str1 == str2 |
> | 0 if str1 > str2 |
Definition at line 85 of file ccl-string.h.
char* ccl_string_dup | ( | const char * | s | ) |
Duplicates the string s.
s | the string to duplicate |
int ccl_string_equals | ( | const void * | str1, |
const void * | str2 | ||
) |
Equality checking for strings.
This function checks if str1 and str2 are equal. This function can be used where a pointer to a ccl_equals_func is required.
str1 | first string arg |
str2 | second string arg |
void ccl_string_format | ( | char ** | dst, |
size_t * | size, | ||
const char * | fmt, | ||
... | |||
) |
Allocates a formatted string.
This function creates a formatted string using fmt specifications in the same way than ccl_string_format_new. The resulting string is stored in the buffer pointed by dst. The function assumes that *size bytes can be stored into *dst; if size is NULL the buffer size is assumed to be 0. If *dst has a size inferior to the number of bytes required to store the formatted string then the buffer is resized and *size is changed according to the new size. *dst can be NULL.
dst | a pointer to the string that should receive the result. |
size | a pointer to an integer that should receive the new size of the buffer pointed by *dst. This parameter can be NULL. |
fmt | the formatting string |
void ccl_string_format_append | ( | char ** | dst, |
const char * | fmt, | ||
... | |||
) |
Appends a formatted string to *dst.
This function creates a formatted string using fmt specifications in the same way than ccl_string_format_new. The resulting string is appended to the string pointed by dst. *dst can be NULL in which case it is considered as an empty string.
dst | a pointer to the string that should receive the result. |
fmt | the formatting string |
void ccl_string_format_append_va | ( | char ** | dst, |
const char * | fmt, | ||
va_list | pa | ||
) |
Appends a formatted string to *dst.
This function behaves like ccl_string_format_append but variable arguments are replaced by a va_list.
dst | a pointer to the string that should receive the result. |
fmt | the formatting string |
pa | the list of arguments |
char* ccl_string_format_new | ( | const char * | fmt, |
... | |||
) |
Allocates a formatted string.
This function allocates a new string and fills it using formatting informations contained in fmt. The syntax of fmt is the one of printf-like functions.
fmt | the formatting string |
return a formatted string.
char* ccl_string_format_new_va | ( | const char * | fmt, |
va_list | pa | ||
) |
Allocates a formatted string.
This function makes the same work than ccl_string_format_new but variable arguments are replaced by a va_list; thus it can be called by funtions that use variable arguments (i.e. ...).
fmt | the formatting string |
pa | the list of arguments |
void ccl_string_format_va | ( | char ** | dst, |
size_t * | size, | ||
const char * | fmt, | ||
va_list | pa | ||
) |
Allocates a formatted string.
This function behaves like ccl_string_format but variable arguments are replaced by a va_list.
dst | a pointer to the string that should receive the result. |
size | a pointer to an integer that should receive the new size of the buffer pointed by *dst. This parameter can be NULL. |
fmt | the formatting string |
pa | the list of arguments |
unsigned int ccl_string_hash | ( | const void * | ptr | ) |
Hashes the string pointed by ptr.
ptr | the string to hash ccl_pre ptr != NULL |
ccl_ustring ccl_string_make_unique | ( | const char * | s | ) |
Creates a unique string from the string s.
A unique string is just a string stored in an internal dictionary. All unique string can then be compared by addresses instead of the lexicographical order (e.g. using strcmp).
The function manages an internal dictionary. If the string s exists in that dictionary the function returns the pointer to the stored string; else, a copy of s is stored in the dictionary and returned.
s | the string made unique |
ccl_ustring ccl_string_make_unique_from_int | ( | int | i | ) |
Creates a unique string from an integer i.
i | the integer transformed into a unique string |
int ccl_string_parse_boolean | ( | const char * | s | ) |
Interprets s as a Boolean value.
If s is equal to one of the following strings true, enabled, TRUE, ENABLED or 1, the function returns a non-null value. If s is NULL then the function returns 0.
s | the string to parse |
int ccl_string_parse_int | ( | const char * | s | ) |
Interprets s as an integer value.
The function parses the longest prefix of s that matches the regexp of a signed integer: 0|-([0-9]+).
If s is NULL then the function returns 0.
s | the string to parse |