qLibc
|
String APIs. More...
Go to the source code of this file.
Functions | |
char * | qstrtrim (char *str) |
Remove white spaces(including CR, LF) from head and tail of the string. | |
char * | qstrtrim_head (char *str) |
Remove heading white spaces of the string. | |
char * | qstrtrim_tail (char *str) |
Remove tailing white spaces(including CR, LF) of the string. | |
char * | qstrunchar (char *str, char head, char tail) |
Remove character from head and tail of the string. | |
char * | qstrreplace (const char *mode, char *srcstr, const char *tokstr, const char *word) |
Replace string or tokens as word from source string with given mode. | |
char * | qstrcpy (char *dst, size_t size, const char *src) |
Copy src string to dst. | |
char * | qstrncpy (char *dst, size_t size, const char *src, size_t nbytes) |
Copy src string to dst no more than n bytes. | |
char * | qstrdupf (const char *format,...) |
Duplicate a formatted string. | |
char * | qstrdup_between (const char *str, const char *start, const char *end) |
Duplicate a substing set. | |
void * | qmemdup (const void *data, size_t size) |
Duplicate a copy of memory data. | |
char * | qstrcatf (char *str, const char *format,...) |
Append formatted string to the end of the source str. | |
char * | qstrgets (char *buf, size_t size, char **offset) |
Get one line from the string offset. | |
char * | qstrrev (char *str) |
Reverse the order of characters in the string. | |
char * | qstrupper (char *str) |
Convert character to bigger character. | |
char * | qstrlower (char *str) |
Convert character to lower character. | |
char * | qstrtok (char *str, const char *delimiters, char *retstop, int *offset) |
Split string into tokens. | |
qlist_t * | qstrtokenizer (const char *str, const char *delimiters) |
String Tokenizer. | |
char * | qstrunique (const char *seed) |
Generate unique id. | |
char * | qstr_comma_number (int number) |
Convert integer to comma string. | |
bool | qstrtest (int(*testfunc)(int), const char *str) |
Test for an alpha-numeric string. | |
bool | qstr_is_email (const char *email) |
Test for an email-address formatted string. | |
bool | qstr_is_ip4addr (const char *str) |
Test for an IPv4 address string. | |
char * | qstr_conv_encoding (const char *str, const char *fromcode, const char *tocode, float mag) |
Convert character encoding. | |
String APIs.
Definition in file qstring.c.
char * qstrtrim | ( | char * | str | ) |
char * qstrtrim_head | ( | char * | str | ) |
char * qstrtrim_tail | ( | char * | str | ) |
char * qstrunchar | ( | char * | str, |
char | head, | ||
char | tail | ||
) |
Remove character from head and tail of the string.
str | source string |
head | heading character |
tail | tailing character |
char * qstrreplace | ( | const char * | mode, |
char * | srcstr, | ||
const char * | tokstr, | ||
const char * | word | ||
) |
Replace string or tokens as word from source string with given mode.
mode | replacing mode |
srcstr | source string |
tokstr | token or string |
word | target word to be replaced |
When 't' is given each character of the token string(third argument) will be compared with source string individually. If matched one is found. the character will be replaced with given work.
If 's' is given instead of 't'. Token string will be analyzed only one chunk word. So the replacement will be occured when the case of whole word matched.
Second character is used to decide returning memory type and can be 'n' or 'r' which are stand on [n]ew and [r]eplace.
When 'n' is given the result will be placed into new array so you should free the return string after using. Instead of this, you can also use 'r' character to modify source string directly. In this case, given source string should have enough space. Be sure that untouchable value can not be used for source string.
So there are four associatable modes such like below.
Mode "tn" : [t]oken replacing & putting the result into [n]ew array. Mode "tr" : [t]oken replacing & [r]eplace source string directly. Mode "sn" : [s]tring replacing & putting the result into [n]ew array. Mode "sr" : [s]tring replacing & [r]eplace source string directly.
char * qstrcpy | ( | char * | dst, |
size_t | size, | ||
const char * | src | ||
) |
Copy src string to dst.
The dst string array will be always terminated by NULL character. Also allows overlap between src and dst.
dst | a pointer of the string to be copied |
size | the size of dst character arrary |
src | a pointer of source string |
char * qstrncpy | ( | char * | dst, |
size_t | size, | ||
const char * | src, | ||
size_t | nbytes | ||
) |
Copy src string to dst no more than n bytes.
The dst string array will be always terminated by NULL character. Also allows overlap between src and dst.
dst | a pointer of the string to be copied |
size | the size of dst character arrary |
src | a pointer of source string |
nbytes | number of bytes to copy |
char * qstrdupf | ( | const char * | format, |
... | |||
) |
char * qstrdup_between | ( | const char * | str, |
const char * | start, | ||
const char * | end | ||
) |
void * qmemdup | ( | const void * | data, |
size_t | size | ||
) |
char * qstrcatf | ( | char * | str, |
const char * | format, | ||
... | |||
) |
char * qstrgets | ( | char * | buf, |
size_t | size, | ||
char ** | offset | ||
) |
Get one line from the string offset.
buf | buffer pointer |
size | buffer size |
offset | a offset pointer which point source string |
char * qstrrev | ( | char * | str | ) |
char * qstrupper | ( | char * | str | ) |
char * qstrlower | ( | char * | str | ) |
char * qstrtok | ( | char * | str, |
const char * | delimiters, | ||
char * | retstop, | ||
int * | offset | ||
) |
Split string into tokens.
str | source string |
delimiters | string that specifies a set of delimiters that may surround the token being extracted |
retstop | stop delimiter character will be stored. it can be NULL if you don't want to know. |
offset | integer pointer used for store last position. (must be reset to 0) |
qlist_t * qstrtokenizer | ( | const char * | str, |
const char * | delimiters | ||
) |
String Tokenizer.
str | source string |
delimiters | string that specifies a set of delimiters that may surround the token being extracted |
char * qstrunique | ( | const char * | seed | ) |
Generate unique id.
seed | additional seed string. this can be NULL |
char * qstr_comma_number | ( | int | number | ) |
bool qstrtest | ( | int(*)(int) | testfunc, |
const char * | str | ||
) |
Test for an alpha-numeric string.
testfunc | test function for individual character |
str | a pointer of string |
bool qstr_is_email | ( | const char * | ) |
bool qstr_is_ip4addr | ( | const char * | str | ) |
Test for an IPv4 address string.
url | IPv4 address string |
char * qstr_conv_encoding | ( | const char * | str, |
const char * | fromcode, | ||
const char * | tocode, | ||
float | mag | ||
) |
Convert character encoding.
str | additional seed string. this can be NULL |
fromcode | encoding type of str |
tocode | encoding to convert |
mag | magnification between fromcode and tocode |