docs/Writerside/topics/strings.md

changeset 1424
563033aa998c
parent 1209
4a72c47226f4
equal deleted inserted replaced
1423:9a72258446cd 1424:563033aa998c
2 2
3 For an improved experience when working with strings, 3 For an improved experience when working with strings,
4 UCX provides an API to work with structures that store a [string](string.h.md) together with its length, 4 UCX provides an API to work with structures that store a [string](string.h.md) together with its length,
5 as well as a more sophisticated [buffer](buffer.h.md) API for working with text of dynamic or unknown length. 5 as well as a more sophisticated [buffer](buffer.h.md) API for working with text of dynamic or unknown length.
6 6
7 Additionally, UCX offers several advanced [printf-like functions](printf.h.md) that also allow the convenient work 7 Additionally, UCX offers several advanced [printf-like functions](printf.h.md) that also allow convenient work
8 with strings of unknown length. 8 with strings of unknown length.
9 For example, one the more advanced functions is `cx_sprintf_sa()` which lets you format a string into an existing 9 For example, one the more advanced functions is `cx_sprintf_sa()` which lets you format a string into an existing
10 pre-allocated buffer (e.g. on the stack) and automatically switches to a fresh buffer allocated by a custom allocator 10 pre-allocated buffer (e.g. on the stack) and automatically switches to a fresh buffer allocated by a custom allocator
11 when the existing buffer is not large enough. 11 when the existing buffer is not large enough.
12 12
13 The string API is designed to work with _both_ mutable and constant strings. 13 The string API is designed to work with _both_ mutable and constant strings.
14 The possibility to work with constant strings is especially important, when you want to work with string literals 14 The possibility to work with constant strings is especially important when you want to work with string literals
15 without copying them into a separate memory region - e.g. when you want to obtain a substring. 15 without copying them into a separate memory region - e.g., when you want to get a substring.
16 16
17 By default, UCX assumes strings are constant and stores them in a structure of type `cxstring`. 17 By default, UCX assumes strings are constant and stores them in a structure of type `cxstring`.
18 Mutable strings are stored in a separate structure called `cxmutstr`. 18 Mutable strings are stored in a separate structure called `cxmutstr`.
19 You can conveniently convert any UCX string to a `cxstring` by using `cx_strcast()`. 19 You can conveniently convert any UCX string to a `cxstring` by using `cx_strcast()`.
20 Several macros throughout UCX already do that for you. 20 Several macros throughout UCX already do that for you.

mercurial