![]() |
MySQL 9.6.0
Source Code Documentation
|
Wrappers around output buffers for string-producing functions, enabling a single string producer to accept multiple string representations and allocation policies. More...
Namespaces | |
| namespace | mysql |
| namespace | mysql::strconv |
| namespace | mysql::strconv::detail |
Wrappers around output buffers for string-producing functions, enabling a single string producer to accept multiple string representations and allocation policies.
Anyone that defines a string-producing function usually has to make several decisions, and this framework makes it easy to support all variants without duplicating/repeating code:
char, unsigned char, or std::byte? Which integer type is used for the length?If the string producer will only be used in code that follows one defined convention, the API can just use that. Otherwise, in more heterogeneous environments, use this library as follows:
Out_str & as out-parameter: out_str_* functions, which return a wrapper around the output parameters. For example: _growable, _fixed can be combined with all string representations (std::string, begin+end, or begin+length). Raw pointer representations can be either null-terminated or not (the _z/_nz suffixes); optionally take a Memory_resource parameter; use char, unsigned char, or std::byte for the character type; and their sizes can be any integer type.produce may use the function out_str_write. out_str_write takes an invocable as argument; the invocable is what actually generates the string, and out_str_write performs the allocation (and checking for out-of-memory errors), and writes the null-termination byte if required.