docs/Writerside/topics/string.h.md

changeset 1671
cf19b7820ff0
parent 1668
3ffdfe1776b4
equal deleted inserted replaced
1670:56f55f2f70c0 1671:cf19b7820ff0
266 CxStrtokCtx cx_strtok(AnyStr str, AnyStr delim, size_t limit); 266 CxStrtokCtx cx_strtok(AnyStr str, AnyStr delim, size_t limit);
267 267
268 void cx_strtok_delim(CxStrtokCtx *ctx, 268 void cx_strtok_delim(CxStrtokCtx *ctx,
269 const cxstring *delim, size_t count); 269 const cxstring *delim, size_t count);
270 270
271 bool cx_strtok_next(CxStrtokCtx *ctx, cxstring *token); 271 bool cx_strtok_next(CxStrtokCtx *ctx, UcxStr* token);
272
273 bool cx_strtok_next_m(CxStrtokCtx *ctx, cxmutstr *token);
274 ``` 272 ```
275 273
276 You can tokenize a string by creating a _tokenization_ context with `cx_strtok()`, 274 You can tokenize a string by creating a _tokenization_ context with `cx_strtok()`,
277 and calling `cx_strtok_next()` or `cx_strtok_next_m()` as long as they return `true`. 275 and calling `cx_strtok_next()` as long as it returns `true`.
278 276
279 The tokenization context is initialized with the string `str` to tokenize, 277 The tokenization context is initialized with the string `str` to tokenize,
280 one delimiter `delim`, and a `limit` for the maximum number of tokens. 278 one delimiter `delim`, and a `limit` for the maximum number of tokens.
281 When `limit` is reached, the remaining part of `str` is returned as one single token. 279 When `limit` is reached, the remaining part of `str` is returned as one single token.
282 280
283 You can add additional delimiters to the context by calling `cx_strtok_delim()`, and 281 You can add additional delimiters to the context by calling `cx_strtok_delim()`, and
284 specifying an array of delimiters to use. 282 specifying an array of delimiters to use.
285 283
286 > Regardless of how the context was initialized, you can use either `cx_strtok_next()` 284 > Regardless of how the context was initialized, you can use `cx_strtok_next()`
287 > or `cx_strtok_next_m()` to retrieve the tokens. However, keep in mind that modifying 285 > with pointers to `cxstring` or `cxmutstr`. However, keep in mind that modifying
288 > characters in a token returned by `cx_strtok_next_m()` has only defined behavior, when the 286 > characters in a `cxmutstr` has only defined behavior, when the
289 > underlying `str` is a `cxmutstr`. 287 > underlying `str` is also a `cxmutstr` that was not initalized with constant memory.
290 288
291 ### Example 289 ### Example
292 290
293 ```C 291 ```C
294 #include <cx/string.h> 292 #include <cx/string.h>

mercurial