|
| template<class Sep , class Arg , class... Args> |
| size_t | c4::catsep (substr buf, Sep const &sep, Arg const &a, Args const &...more) |
| | serialize the arguments, concatenating them to the given fixed-size buffer, using a separator between each argument. More...
|
| |
| template<class... Args> |
| substr | c4::catsep_sub (substr buf, Args &&...args) |
| | like c4::catsep() but return a substr instead of a size More...
|
| |
| template<class CharOwningContainer , class Sep , class... Args> |
| void | c4::catseprs (CharOwningContainer *cont, Sep const &sep, Args const &...args) |
| | catsep+resize: like c4::catsep(), but receives a container, and resizes it as needed to contain the result. More...
|
| |
| template<class CharOwningContainer , class Sep , class... Args> |
| CharOwningContainer | c4::catseprs (Sep const &sep, Args const &...args) |
| | catsep+resize: like c4::catsep(), but create a new container with the result. More...
|
| |
| template<class CharOwningContainer , class Sep , class... Args> |
| csubstr | c4::catseprs_append (CharOwningContainer *cont, Sep const &sep, Args const &...args) |
| | catsep+resize+append: like c4::catsep(), but receives a container, and appends the arguments, resizing the container as needed to contain the result. More...
|
| |
template<class Sep , class Arg , class... Args>
| size_t c4::catsep |
( |
substr |
buf, |
|
|
Sep const & |
sep, |
|
|
Arg const & |
a, |
|
|
Args const &... |
more |
|
) |
| |
serialize the arguments, concatenating them to the given fixed-size buffer, using a separator between each argument.
The buffer size is strictly respected: no writes will occur beyond its end.
- Returns
- the number of characters needed to write all the arguments into the buffer.
- See also
- c4::catseprs() if instead of a fixed-size buffer, a resizeable container is desired
-
c4::uncatsep() for the inverse function (ie, reading instead of writing)
-
c4::cat() if no separator is needed
-
c4::format() if a format string is desired
- Note
- The arguments to format are restricted (legal because they are rvalues). This may require a workaround when arguments of type char[]/const char[] are passed repeatedly to the function. For example,
const char str[] =
"Hi! ";
It is possible to work around the problem by suppressing -Wrestrict or by using the decayed type char* or const char*, or even wrapping the argument in a csubstr(): const char str[] = "Hi! ";
Definition at line 774 of file format.hpp.
Referenced by c4::catsep_sub(), c4::catseprs(), c4::catseprs_append(), and sample_formatting().
777 buf = buf.len >= num ? buf.sub(num) :
substr{};
778 num += detail::catsep_more(buf, sep, more...);
basic_substring< char > substr
a mutable string view
size_t to_chars(substr buf, fmt::center_< T > const &align)
template<class CharOwningContainer , class Sep , class... Args>
| void c4::catseprs |
( |
CharOwningContainer * |
cont, |
|
|
Sep const & |
sep, |
|
|
Args const &... |
args |
|
) |
| |
|
inline |
catsep+resize: like c4::catsep(), but receives a container, and resizes it as needed to contain the result.
The container is overwritten. To append to the container use c4::catseprs_append().
- See also
- c4::catsep()
-
c4::catseprs_append()
- Note
- The arguments to format are restricted (legal because they are rvalues). This may require a workaround when arguments of type char[]/const char[] are passed repeatedly to the function. For example,
const char str[] =
"Hi! ";
It is possible to work around the problem by suppressing -Wrestrict or by using the decayed type char* or const char*, or even wrapping the argument in a csubstr(): const char str[] = "Hi! ";
Definition at line 1152 of file format.hpp.
Referenced by c4::catseprs(), and sample_formatting().
1154 cont->resize(cont->capacity());
1157 size_t ret =
catsep(buf, sep, args...);
substr to_substr(char(&s)[N]) noexcept
basic_substring< char > substr
a mutable string view
size_t catsep(substr buf, Sep const &sep, Arg const &a, Args const &...more)
serialize the arguments, concatenating them to the given fixed-size buffer, using a separator between...
template<class CharOwningContainer , class Sep , class... Args>
| csubstr c4::catseprs_append |
( |
CharOwningContainer * |
cont, |
|
|
Sep const & |
sep, |
|
|
Args const &... |
args |
|
) |
| |
|
inline |
catsep+resize+append: like c4::catsep(), but receives a container, and appends the arguments, resizing the container as needed to contain the result.
The buffer is appended to.
- Returns
- a csubstr of the appended part
- Note
- The arguments to format are restricted (legal because they are rvalues). This may require a workaround when arguments of type char[]/const char[] are passed repeatedly to the function. For example,
const char str[] =
"Hi! ";
It is possible to work around the problem by suppressing -Wrestrict or by using the decayed type char* or const char*, or even wrapping the argument in a csubstr(): const char str[] =
"Hi! ";
Definition at line 1220 of file format.hpp.
Referenced by sample_formatting().
1222 const size_t pos = cont->size();
1223 cont->resize(cont->capacity());
1226 size_t ret =
catsep(buf, sep, args...);
1227 cont->resize(pos + ret);
substr to_substr(char(&s)[N]) noexcept
basic_substring sub(size_t first) const noexcept
return [first,len[
csubstr to_csubstr(const char(&s)[N]) noexcept
basic_substring< char > substr
a mutable string view
basic_substring range(size_t first, size_t last=npos) const noexcept
return [first,last[.
size_t catsep(substr buf, Sep const &sep, Arg const &a, Args const &...more)
serialize the arguments, concatenating them to the given fixed-size buffer, using a separator between...