string tokenizer More...
Typedefs | |
typedef typedefCGUL_BEGIN_C struct cgul_strtok * | cgul_strtok_t |
Functions | |
CGUL_EXPORT cgul_strtok_t | cgul_strtok__new (cgul_exception_t *cex) |
CGUL_EXPORT void | cgul_strtok__delete (cgul_strtok_t tok) |
CGUL_EXPORT void | cgul_strtok__set_value (cgul_exception_t *cex, cgul_strtok_t tok, const char *value) |
CGUL_EXPORT const char * | cgul_strtok__get_next (cgul_exception_t *cex, cgul_strtok_t tok, const char *separators, int allow_empty_tokens) |
CGUL_EXPORT char | cgul_strtok__get_separator (cgul_exception_t *cex, cgul_strtok_t tok) |
CGUL_EXPORT size_t | cgul_strtok__get_start (cgul_exception_t *cex, cgul_strtok_t tok) |
CGUL_EXPORT size_t | cgul_strtok__get_end (cgul_exception_t *cex, cgul_strtok_t tok) |
String tokenizer designed to replace strtok()
.
typedef typedefCGUL_BEGIN_C struct cgul_strtok* cgul_strtok_t |
Opaque pointer to a cgul_strtok
instance.
CGUL_EXPORT cgul_strtok_t cgul_strtok__new | ( | cgul_exception_t * | cex | ) |
Create a new cgul_strtok
instance. The caller is responsible for caling cgul_strtok__delete()
on the pointer returned. If memory allocation fails, NULL
is returned, and an exception is thrown.
[in,out] | cex | c-style exception |
cgul_strtok
instance Referenced by cgul_strtok_cxx::cgul_strtok_cxx().
CGUL_EXPORT void cgul_strtok__delete | ( | cgul_strtok_t | tok | ) |
Delete the cgul_strtok
object in tok
. The client must not use tok
after calling this method.
[in] | tok | cgul_strtok instance |
Referenced by cgul_strtok_cxx::set_obj(), and cgul_strtok_cxx::~cgul_strtok_cxx().
CGUL_EXPORT void cgul_strtok__set_value | ( | cgul_exception_t * | cex, |
cgul_strtok_t | tok, | ||
const char * | value | ||
) |
Set the value to tokenize. This method makes an internal copy of value
out of which tokens will be returned.
[in,out] | cex | c-style exception |
[in] | tok | cgul_strtok instance |
[in] | value | value to tokenize |
Referenced by cgul_strtok_cxx::set_value().
CGUL_EXPORT const char* cgul_strtok__get_next | ( | cgul_exception_t * | cex, |
cgul_strtok_t | tok, | ||
const char * | separators, | ||
int | allow_empty_tokens | ||
) |
Get the next token that is delimited by the current list of separators
. The list of separators can change each time this method is called. If all the tokens have been consumed, NULL
is returned.
If allow_empty_tokens
is true, this method will return empty tokens when two consecutive separators are encountered including the case where a separator immediately precedes the end of string. If allow_empty_tokens
is false, consecutive separators will be telescoped into one, and all tokens returned will be non-empty.
The pointer returned is owned by tok
and must not be freed by the client.
[in] | cex | c-style exception |
[in] | tok | cgul_strtok instance |
[in] | separators | list of separators that delimit tokens |
[in] | allow_empty_tokens | whether to allow returning empty tokens |
Referenced by cgul_strtok_cxx::get_next().
CGUL_EXPORT char cgul_strtok__get_separator | ( | cgul_exception_t * | cex, |
cgul_strtok_t | tok | ||
) |
Get the trailing separator for the current token. This value can be NUL if the current token terminated because it reached the end of the string.
[in] | cex | c-style exception |
[in] | tok | cgul_strtok instance |
Referenced by cgul_strtok_cxx::get_separator().
CGUL_EXPORT size_t cgul_strtok__get_start | ( | cgul_exception_t * | cex, |
cgul_strtok_t | tok | ||
) |
Get the starting index for the current token.
[in] | cex | c-style exception |
[in] | tok | cgul_strtok instance |
Referenced by cgul_strtok_cxx::get_start().
CGUL_EXPORT size_t cgul_strtok__get_end | ( | cgul_exception_t * | cex, |
cgul_strtok_t | tok | ||
) |
Get the ending index for the current token. The value returned is actually one beyond the end of the current token. So in effect, the value returned is the index of the trailing separator for the current token.
[in] | cex | c-style exception |
[in] | tok | cgul_strtok instance |
Referenced by cgul_strtok_cxx::get_end().