
Go to the source code of this file.
Functions | |
| char * | gk_strchr_replace (char *str, char *fromlist, char *tolist) |
| Replaces certain characters in a string. | |
| int | gk_strstr_replace (char *str, char *pattern, char *replacement, char *options, char **new_str) |
| Regex-based search-and-replace function. | |
| char * | gk_strtprune (char *str, char *rmlist) |
| Prunes characters from the end of the string. | |
| char * | gk_strhprune (char *str, char *rmlist) |
| Prunes characters from the beginning of the string. | |
| char * | gk_strtoupper (char *str) |
| Converts a string to upper case. | |
| char * | gk_strtolower (char *str) |
| Converts a string to lower case. | |
| char * | gk_strdup (char *orgstr) |
| Duplicates a string. | |
| int | gk_strcasecmp (char *s1, char *s2) |
| Case insensitive string comparison. | |
| int | gk_strrcmp (char *s1, char *s2) |
| Compare two strings in revere order. | |
| char * | gk_time2str (time_t time) |
| Converts a time_t time into a string. | |
| time_t | gk_str2time (char *str) |
| Converts a date/time string into its equivalent time_t value. | |
| int | gk_GetStringID (gk_StringMap_t *strmap, char *key) |
Various functions for manipulating strings. Some of these functions provide new functionality, whereas others are drop-in replacements of standard functions (but with enhanced functionality).
Definition in file string.c.
| char* gk_strchr_replace | ( | char * | str, | |
| char * | fromlist, | |||
| char * | tolist | |||
| ) |
Replaces certain characters in a string.
This function takes a string and replaces all the characters in the fromlist with the corresponding characters from the tolist. That is, each occurence of fromlist[i] is replaced by tolist[i]. If the tolist is shorter than fromlist, then the corresponding characters are deleted. The modifications on str are done in place. It tries to provide a functionality similar to Perl's tr// function.
| str | is the string whose characters will be replaced. | |
| fromlist | is the set of characters to be replaced. | |
| tolist | is the set of replacement characters . |
str itself. Definition at line 40 of file string.c.
Referenced by ReadTPwgts().

| int gk_strstr_replace | ( | char * | str, | |
| char * | pattern, | |||
| char * | replacement, | |||
| char * | options, | |||
| char ** | new_str | |||
| ) |
Regex-based search-and-replace function.
This function is a C implementation of Perl's s// regular-expression based substitution function.
| str | is the input string on which the operation will be performed. | |
| pattern | is the regular expression for the pattern to be matched for substitution. | |
| replacement | is the replacement string, in which the possible captured pattern substrings are referred to as $1, $2, ..., $9. The entire matched pattern is refered to as $0. | |
| options | is a string specified options for the substitution operation. Currently the "i" (case insensitive) and "g" (global substitution) are supported. | |
| new_str | is a reference to a pointer that will store a pointer to the newly created string that results from the substitutions. This string is allocated via gk_malloc() and needs to be freed using gk_free(). The string is returned even if no substitutions were performed. |
newstr, which also needs to be freed afterwards. Definition at line 97 of file string.c.
References gk_free(), gk_idx_t, gk_realloc(), gk_strdup(), int, len, offset, REG_ESPACE, REG_NOMATCH, regcomp(), regerror(), regexec(), regfree(), regmatch_t::rm_eo, and regmatch_t::rm_so.
Referenced by test_strstr_replace().


| char* gk_strtprune | ( | char * | str, | |
| char * | rmlist | |||
| ) |
Prunes characters from the end of the string.
This function removes any trailing characters that are included in the rmlist. The trimming stops at the last character (i.e., first character from the end) that is not in rmlist. This function can be used to removed trailing spaces, newlines, etc. This is a distructive operation as it modifies the string.
| str | is the string that will be trimmed. | |
| rmlist | contains the set of characters that will be removed. |
str itself. Definition at line 257 of file string.c.
Referenced by gk_readfile(), and main().

| char* gk_strhprune | ( | char * | str, | |
| char * | rmlist | |||
| ) |
Prunes characters from the beginning of the string.
This function removes any starting characters that are included in the rmlist. The trimming stops at the first character that is not in rmlist. This function can be used to removed leading spaces, tabs, etc. This is a distructive operation as it modifies the string.
| str | is the string that will be trimmed. | |
| rmlist | contains the set of characters that will be removed. |
str itself. | char* gk_strtoupper | ( | char * | str | ) |
Converts a string to upper case.
This function converts a string to upper case. This operation modifies the string itself.
| str | is the string whose case will be changed. |
str itself. Definition at line 331 of file string.c.
Referenced by gk_seq_ReadGKMODPSSM().

| char* gk_strtolower | ( | char * | str | ) |
Converts a string to lower case.
This function converts a string to lower case. This operation modifies the string itself.
| str | is the string whose case will be changed. |
str itself. | char* gk_strdup | ( | char * | orgstr | ) |
Duplicates a string.
This function is a replacement for C's standard strdup() function. The key differences between the two are that gk_strdup():
The string that is returned must be freed by gk_free().
| orgstr | is the string that will be duplicated. |
Definition at line 375 of file string.c.
References gk_malloc(), and len.
Referenced by getpathname(), gk_getbasename(), gk_getextname(), gk_getfilename(), gk_readfile(), gk_readpdbfile(), gk_strstr_replace(), gk_strtokenize(), main(), parse_cmdline(), and test_skvsort().


| int gk_strcasecmp | ( | char * | s1, | |
| char * | s2 | |||
| ) |
Case insensitive string comparison.
This function compares two strings for equality by ignoring the case of the strings.
| s1 | is the first string to be compared. | |
| s2 | is the second string to be compared. |
| 1 | if the strings are identical, | |
| 0 | otherwise. |
Definition at line 408 of file string.c.
Referenced by gk_GetStringID().

| int gk_strrcmp | ( | char * | s1, | |
| char * | s2 | |||
| ) |
Compare two strings in revere order.
This function is similar to strcmp but it performs the comparison as if the two strings were reversed.
| s1 | is the first string to be compared. | |
| s2 | is the second string to be compared. |
| -1,0,1,if | the s1 < s2, s1 == s2, or s1 > s2. |
| char* gk_time2str | ( | time_t | time | ) |
Converts a time_t time into a string.
This function takes a time_t-specified time and returns a string-formated representation of the corresponding time. The format of the string is mm/dd/yyyy hh:mm:ss, in which the hours are in military time.
| time | is the time to be converted. |
| time_t gk_str2time | ( | char * | str | ) |
Converts a date/time string into its equivalent time_t value.
This function takes date and/or time specification and converts it in the equivalent time_t representation. The conversion is done using the strptime() function. The format that gk_str2time() understands is mm/dd/yyyy hh:mm:ss, in which the hours are in military time.
| str | is the date/time string to be converted. |
| int gk_GetStringID | ( | gk_StringMap_t * | strmap, | |
| char * | key | |||
| ) |
Definition at line 524 of file string.c.
References gk_strcasecmp(), gk_StringMap_t::id, name, and gk_StringMap_t::name.
Referenced by parse_cmdline().


1.5.5