2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BEAST_WRITE_DYNABUF_HPP
9 #define BEAST_WRITE_DYNABUF_HPP
11 #include <beast/config.hpp>
12 #include <beast/core/buffer_concepts.hpp>
13 #include <beast/core/detail/write_dynabuf.hpp>
14 #include <type_traits>
19 /** Write to a @b `DynamicBuffer`.
21 This function appends the serialized representation of each provided
22 argument into the dynamic buffer. It is capable of converting the
23 following types of arguments:
25 @li `boost::asio::const_buffer`
27 @li `boost::asio::mutable_buffer`
29 @li A type meeting the requirements of @b `ConvertibleToConstBuffer`
31 @li A type meeting the requirements of @b `ConstBufferSequence`
33 @li A type meeting the requirements of @b `MutableBufferSequence`
35 For all types not listed above, the function will invoke
36 `boost::lexical_cast` on the argument in an attempt to convert to
37 a string, which is then appended to the dynamic buffer.
39 When this function serializes numbers, it converts them to
40 their text representation as if by a call to `std::to_string`.
42 @param dynabuf The dynamic buffer to write to.
44 @param args A list of one or more arguments to write.
46 @throws unspecified Any exceptions thrown by `boost::lexical_cast`.
48 @note This function participates in overload resolution only if
49 the `dynabuf` parameter meets the requirements of @b `DynamicBuffer`.
51 template<class DynamicBuffer, class... Args>
55 typename std::enable_if<is_DynamicBuffer<DynamicBuffer>::value>::type
57 write(DynamicBuffer& dynabuf, Args const&... args)
59 detail::write_dynabuf(dynabuf, args...);