0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 19:58:53 +02:00

ircd::json: Add mutable_buffer print() overload.

This commit is contained in:
Jason Volk 2017-10-03 13:21:19 -07:00
parent fb498ed2f2
commit 6c04739634

View file

@ -92,6 +92,7 @@ namespace ircd::json
/// you pass to the template.
template<class... T> string_view stringify(const mutable_buffer &&mb, T&&... t);
template<class... T> size_t print(char *const &buf, const size_t &max, T&&... t);
template<class... T> size_t print(const mutable_buffer &buf, T&&... t);
template<class... T> std::string string(T&&... t);
size_t serialized(const string_view &);
@ -126,6 +127,18 @@ ircd::json::stringify(const mutable_buffer &&mb,
return stringify(mbc, std::forward<T>(t)...);
}
///
/// Convenience template using the syntax print(mutable_buffer, ...)
/// which stringifies with null termination into buffer.
///
template<class... T>
size_t
ircd::json::print(const mutable_buffer &buf,
T&&... t)
{
return print(data(buf), size(buf), std::forward<T>(t)...);
}
///
/// Convenience template using the syntax print(buf, sizeof(buf), ...)
/// which stringifies with null termination into buffer.