|
libcmutils 0.6.5
Multi-platform C99 utility library
|
Data Structures | |
| struct | CMUTIL_String |
| Multifunctional string type. More... | |
| struct | CMUTIL_StringArray |
| Dynamic array of string objects. More... | |
| struct | CMUTIL_ByteBuffer |
| Manipulation of bytes. More... | |
| struct | CMUTIL_CSConv |
| Character set conversion object. More... | |
Macros | |
| #define | CMUTIL_StringCreate() CMUTIL_StringCreateEx(CMUTIL_STRING_DEFAULT, NULL) |
| Creates a string object. | |
| #define | CMUTIL_STRINGARRAY_DEFAULT 32 |
| #define | CMUTIL_StringArrayCreate() CMUTIL_StringArrayCreateEx(CMUTIL_STRINGARRAY_DEFAULT) |
| #define | CMUTIL_StringArrayCreateWith(s, ...) CMUTIL_StringArrayCreateWithEx(s, __VA_ARGS__, NULL) |
| Create a new CMUTIL_StringArray object with initial elements. | |
| #define | CMUTIL_BYTEBUFFER_DEFAULT 32 |
| #define | CMUTIL_ByteBufferCreate() CMUTIL_ByteBufferCreateEx(CMUTIL_BYTEBUFFER_DEFAULT) |
Functions | |
| CMUTIL_String * | CMUTIL_StringCreateEx (size_t initcapacity, const char *initcontent) |
| Creates a string object with initial capacity and content. | |
| CMUTIL_StringArray * | CMUTIL_StringArrayCreateEx (size_t initcapacity) |
| CMUTIL_StringArray * | CMUTIL_StringArrayCreateWithEx (const char *str,...) |
| Create a new CMUTIL_StringArray object with initial elements. | |
| char * | CMUTIL_StrRTrim (char *inp) |
| Trim the right side of a c-style string. | |
| char * | CMUTIL_StrLTrim (char *inp) |
| Trim the left side of a c-style string. | |
| char * | CMUTIL_StrTrim (char *inp) |
| Trim the both side of a c-style string. | |
| const char * | CMUTIL_StrNextToken (char *dest, size_t buflen, const char *src, const char *delims) |
| Get the next token from src. | |
| const char * | CMUTIL_StrSkipSpaces (const char *src, const char *spaces) |
| Skip leading spaces. | |
| CMUTIL_StringArray * | CMUTIL_StringSplit (const char *haystack, const char *needle) |
Split the haystack string using the needle. | |
| int | CMUTIL_StringHexToBytes (uint8_t *dest, const char *src, int len) |
| Convert hex encoded string to bytes. | |
| CMUTIL_ByteBuffer * | CMUTIL_ByteBufferCreateEx (size_t initcapacity) |
| Creates CMUTIL_ByteBuffer object with initial capacity. | |
| CMUTIL_CSConv * | CMUTIL_CSConvCreate (const char *fromcs, const char *tocs) |
| Create a character set conversion object. | |
| #define CMUTIL_StringCreate | ( | ) | CMUTIL_StringCreateEx(CMUTIL_STRING_DEFAULT, NULL) |
Creates a string object.
| #define CMUTIL_STRINGARRAY_DEFAULT 32 |
Default initial size of CMUTIL_String object.
| #define CMUTIL_StringArrayCreate | ( | ) | CMUTIL_StringArrayCreateEx(CMUTIL_STRINGARRAY_DEFAULT) |
Creates a new CMUTIL_String object.
| #define CMUTIL_StringArrayCreateWith | ( | s, | |
| ... | |||
| ) | CMUTIL_StringArrayCreateWithEx(s, __VA_ARGS__, NULL) |
Create a new CMUTIL_StringArray object with initial elements.
A convenient function to create a CMUTIL_StringArray with initial elements without the last NULL.
| s | The first initial element of the array. |
| ... | Additional initial elements. |
| #define CMUTIL_BYTEBUFFER_DEFAULT 32 |
Default bytebuffer initial capacity.
| #define CMUTIL_ByteBufferCreate | ( | ) | CMUTIL_ByteBufferCreateEx(CMUTIL_BYTEBUFFER_DEFAULT) |
Creates CMUTIL_ByteBuffer object with the default parameter.
| CMUTIL_String * CMUTIL_StringCreateEx | ( | size_t | initcapacity, |
| const char * | initcontent | ||
| ) |
Creates a string object with initial capacity and content.
| initcapacity | Initial capacity of this string object. |
| initcontent | Initial content of this string object. |
| CMUTIL_StringArray * CMUTIL_StringArrayCreateEx | ( | size_t | initcapacity | ) |
Creates a new CMUTIL_String object with initial capacity.
| initcapacity | Initial capacity of the new CMUTIL_String object. |
| CMUTIL_StringArray * CMUTIL_StringArrayCreateWithEx | ( | const char * | str, |
| ... | |||
| ) |
Create a new CMUTIL_StringArray object with initial elements.
| str | The first initial element of the array. |
| ... | Additional initial elements, the last element must be NULL. |
| char * CMUTIL_StrRTrim | ( | char * | inp | ) |
Trim the right side of a c-style string.
Trailing space characters (space, tab, line-feed, carriage-return) are removed from the input string. Input string must be null-terminated, and its contents could be changed after this function call. The result string reference is pointing to the original input string.
| inp | Input string to be trimmed. |
| char * CMUTIL_StrLTrim | ( | char * | inp | ) |
Trim the left side of a c-style string.
Leading space characters (space, tab, line-feed, carriage-return) are removed from the input string. Input string must be null-terminated, and its contents could be changed after this function call. The result string reference is pointing to the original input string.
| inp | Input string to be trimmed. |
| char * CMUTIL_StrTrim | ( | char * | inp | ) |
Trim the both side of a c-style string.
Leading and trailing space characters (space, tab, line-feed, carriage-return) are removed from the input string. Input string must be null-terminated, and its contents could be changed after this function call. The result string reference is pointing to the original input string.
| inp | Input string to be trimmed. |
| const char * CMUTIL_StrNextToken | ( | char * | dest, |
| size_t | buflen, | ||
| const char * | src, | ||
| const char * | delims | ||
| ) |
Get the next token from src.
If buflen is less than the length of the next token, the token will be split into multiple tokens.
| dest | The next token will be stored in here. |
| buflen | Maximum length of dest. |
| src | The source string to get the next token. |
| delims | Delimiters to determine token. |
| const char * CMUTIL_StrSkipSpaces | ( | const char * | src, |
| const char * | spaces | ||
| ) |
Skip leading spaces.
Remove any leading space characters, custom spaces can be supplied.
| src | Source string. |
| spaces | Any characters in here will be regards to space. |
src after leading spaces. | CMUTIL_StringArray * CMUTIL_StringSplit | ( | const char * | haystack, |
| const char * | needle | ||
| ) |
Split the haystack string using the needle.
Any occurrence of the needle in the haystack will cause a split.
| haystack | Source string. |
| needle | Split delimiter. |
CMUTIL_StringArray form. | int CMUTIL_StringHexToBytes | ( | uint8_t * | dest, |
| const char * | src, | ||
| int | len | ||
| ) |
Convert hex encoded string to bytes.
If len is an odd number, pad a '0' at the beginning.
| dest | Byte array where result bytes will be stored in. |
| src | Hex encoded source string. |
| len | The number of characters to be converted from the source string. |
| CMUTIL_ByteBuffer * CMUTIL_ByteBufferCreateEx | ( | size_t | initcapacity | ) |
Creates CMUTIL_ByteBuffer object with initial capacity.
| initcapacity | Initial capacity of this bytebuffer. |
| CMUTIL_CSConv * CMUTIL_CSConvCreate | ( | const char * | fromcs, |
| const char * | tocs | ||
| ) |
Create a character set conversion object.
| fromcs | The source character set name. |
| tocs | The target character set name. |