Add streambuf write():

This function performs serialization of a variable list of arguments
to a streambuf. It accepts a wide variety of argument types, using
boost::asio::buffer and boost::lexical_cast where possible.
This commit is contained in:
Vinnie Falco
2016-04-26 06:22:58 -04:00
parent 7cfdab936c
commit 4cfa1d5cd3
11 changed files with 271 additions and 98 deletions

35
test/write_streambuf.cpp Normal file
View File

@@ -0,0 +1,35 @@
//
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Test that header file is self-contained.
#include <beast/write_streambuf.hpp>
#include <beast/streambuf.hpp>
#include <beast/detail/unit_test/suite.hpp>
namespace beast {
class write_streambuf_test : public beast::detail::unit_test::suite
{
public:
void run() override
{
streambuf sb;
std::string s;
write(sb, boost::asio::const_buffer{"", 0});
write(sb, boost::asio::mutable_buffer{nullptr, 0});
write(sb, boost::asio::null_buffers{});
write(sb, boost::asio::const_buffers_1{"", 0});
write(sb, boost::asio::mutable_buffers_1{nullptr, 0});
write(sb, s);
write(sb, 23);
pass();
}
};
BEAST_DEFINE_TESTSUITE(write_streambuf,core,beast);
} // beast