0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 23:40:57 +01:00

ircd::json: Add a buffer.

This commit is contained in:
Jason Volk 2017-10-05 19:46:20 -07:00
parent 5c69d3df5a
commit 15b67799b3

View file

@ -94,6 +94,7 @@ namespace ircd::json
template<class... T> size_t print(char *const &buf, const size_t &max, 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> size_t print(const mutable_buffer &buf, T&&... t);
template<class... T> std::string string(T&&... t); template<class... T> std::string string(T&&... t);
template<size_t SIZE> struct buffer;
size_t serialized(const string_view &); size_t serialized(const string_view &);
@ -113,6 +114,18 @@ namespace ircd
using json::operator<<; using json::operator<<;
} }
template<size_t SIZE>
struct ircd::json::buffer
:string_view
{
std::array<char, SIZE> b;
template<class... T>
buffer(T&&... t)
:string_view{stringify(b, std::forward<T>(t)...)}
{}
};
/// ///
/// Convenience template for const rvalue mutable_buffers or basically /// Convenience template for const rvalue mutable_buffers or basically
/// allowing a bracket initialization of a mutable_buffer in the argument /// allowing a bracket initialization of a mutable_buffer in the argument