|
char * axl_stream_get_until_zero |
( |
axlStream * |
stream, |
|
|
char * |
valid_chars, |
|
|
int * |
chunk_matched, |
|
|
bool |
accept_terminator, |
|
|
int |
chunk_num, |
|
|
|
... | |
|
) |
| | |
Allows to get the next string until the separators provided are found or the end of the stream memory is reached.
axlStream type was designed to support parsing xml documents. This documents have elements that allows to now where the input has finished. Howerver, axlStream abstraction has showed to be powerful enough to be usable to parse other kinds of elements that don't have lexical terminators to let the user to provide that chunk to be matched.
In those cases, this function allows to perform the same function as axl_stream_get_until but also checking, and using, as terminator the end of the stream.
This allows to parse expressions like: int chunk_matched;
axlStream * stream;
char * string;
stream = axl_stream_new ("array.value", -1, NULL, -1, &error);
string = axl_stream_get_until_zero (stream, NULL, &chunk_matched,
false, 2, "[", ".", NULL);
string = axl_stream_get_until_zero (stream, NULL, &chunk_matched,
false, 2, "[", ".", NULL);
- Parameters:
-
| stream | The stream were the chunk will be extracted. |
| valid_chars | The valid set of characters, to validate content to be returned. Currently this is not implemented, so, you can provide a NULL value. |
| chunk_matched | An optional pointer to an integer to notify the chunk matched by the function. Chunk matching notification starts from 0 up to number of chunks to match - 1. If the end of the stream is reached while searching for the content to match, chunk_matched is configured to -2. |
| accept_terminator | While calling to this function, the terminator detected to stop the operation could also be accepted by the stream, making it not necessary to accept the terminator once the function have ended. However, this could be a problem while performing peeking code. You can provide a FALSE value to make the function to not accept the terminator found as to be consumed. |
| chunk_num | The number of chunks to be checked as a valid terminators. |
- Returns:
- The chunk recognizied, not including the terminator that have made this operation to stop. Rembember to check the chunk_matched variable to be equal to -2. This will mean that the string returned doesn't match any terminator provided because end of the stream was reached while looking for them.
|