diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48b6a13b..807e71b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ WebSocket
API Changes:
* Refactor message and message_headers declarations
+* prepared_buffers is private
--------------------------------------------------------------------------------
diff --git a/doc/quickref.xml b/doc/quickref.xml
index 42d683a2..4c03ca51 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -165,7 +165,6 @@
error_codeerror_conditionhandler_alloc
- prepared_buffersstatic_streambufstatic_streambuf_nstatic_string
diff --git a/include/beast/core/impl/prepare_buffers.ipp b/include/beast/core/detail/prepare_buffers.hpp
similarity index 68%
rename from include/beast/core/impl/prepare_buffers.ipp
rename to include/beast/core/detail/prepare_buffers.hpp
index a1093a7a..129417e6 100644
--- a/include/beast/core/impl/prepare_buffers.ipp
+++ b/include/beast/core/detail/prepare_buffers.hpp
@@ -5,38 +5,104 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BEAST_IMPL_PREPARE_BUFFERS_IPP
-#define BEAST_IMPL_PREPARE_BUFFERS_IPP
+#ifndef BEAST_DETAIL_PREPARED_BUFFERS_HPP
+#define BEAST_DETAIL_PREPARED_BUFFERS_HPP
+#include
#include
#include
#include
#include
#include
+#include
#include
namespace beast {
+namespace detail {
+/** A buffer sequence adapter that shortens the sequence size.
+
+ The class adapts a buffer sequence to efficiently represent
+ a shorter subset of the original list of buffers starting
+ with the first byte of the original sequence.
+
+ @tparam BufferSequence The buffer sequence to adapt.
+*/
template
-void
-prepared_buffers::
-setup(std::size_t n)
+class prepared_buffers
{
- for(end_ = bs_.begin(); end_ != bs_.end(); ++end_)
+ using iter_type =
+ typename BufferSequence::const_iterator;
+
+ BufferSequence bs_;
+ iter_type back_;
+ iter_type end_;
+ std::size_t size_;
+
+ template
+ prepared_buffers(Deduced&& other,
+ std::size_t nback, std::size_t nend)
+ : bs_(std::forward(other).bs_)
+ , back_(std::next(bs_.begin(), nback))
+ , end_(std::next(bs_.begin(), nend))
+ , size_(other.size_)
{
- auto const len =
- boost::asio::buffer_size(*end_);
- if(n <= len)
- {
- size_ = n;
- back_ = end_++;
- return;
- }
- n -= len;
}
- size_ = 0;
- back_ = end_;
-}
+
+ void
+ setup(std::size_t n);
+
+public:
+ /// The type for each element in the list of buffers.
+ using value_type = typename std::conditional<
+ std::is_convertible::value_type,
+ boost::asio::mutable_buffer>::value,
+ boost::asio::mutable_buffer,
+ boost::asio::const_buffer>::type;
+
+#if GENERATING_DOCS
+ /// A bidirectional iterator type that may be used to read elements.
+ using const_iterator = implementation_defined;
+
+#else
+ class const_iterator;
+
+#endif
+
+ /// Move constructor.
+ prepared_buffers(prepared_buffers&&);
+
+ /// Copy constructor.
+ prepared_buffers(prepared_buffers const&);
+
+ /// Move assignment.
+ prepared_buffers& operator=(prepared_buffers&&);
+
+ /// Copy assignment.
+ prepared_buffers& operator=(prepared_buffers const&);
+
+ /** Construct a shortened buffer sequence.
+
+ @param n The maximum number of bytes in the wrapped
+ sequence. If this is larger than the size of passed,
+ buffers, the resulting sequence will represent the
+ entire input sequence.
+
+ @param buffers The buffer sequence to adapt. A copy of
+ the sequence will be made, but ownership of the underlying
+ memory is not transferred.
+ */
+ prepared_buffers(std::size_t n, BufferSequence const& buffers);
+
+ /// Get a bidirectional iterator to the first element.
+ const_iterator
+ begin() const;
+
+ /// Get a bidirectional iterator to one past the last element.
+ const_iterator
+ end() const;
+};
template
class prepared_buffers::const_iterator
@@ -130,6 +196,27 @@ private:
}
};
+template
+void
+prepared_buffers::
+setup(std::size_t n)
+{
+ for(end_ = bs_.begin(); end_ != bs_.end(); ++end_)
+ {
+ auto const len =
+ boost::asio::buffer_size(*end_);
+ if(n <= len)
+ {
+ size_ = n;
+ back_ = end_++;
+ return;
+ }
+ n -= len;
+ }
+ size_ = 0;
+ back_ = end_;
+}
+
template
prepared_buffers::const_iterator::
const_iterator(const_iterator&& other)
@@ -163,6 +250,8 @@ prepared_buffers::const_iterator::
operator=(const_iterator const& other) ->
const_iterator&
{
+ if(&other == this)
+ return *this;
b_ = other.b_;
it_ = other.it_;
return *this;
@@ -246,14 +335,7 @@ prepared_buffers::end() const ->
return const_iterator{*this, true};
}
-template
-inline
-prepared_buffers
-prepare_buffers(std::size_t n, BufferSequence const& buffers)
-{
- return prepared_buffers{n, buffers};
-}
-
+} // detail
} // beast
#endif
diff --git a/include/beast/core/prepare_buffer.hpp b/include/beast/core/prepare_buffer.hpp
new file mode 100644
index 00000000..315ea396
--- /dev/null
+++ b/include/beast/core/prepare_buffer.hpp
@@ -0,0 +1,68 @@
+//
+// 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)
+//
+
+#ifndef BEAST_PREPARE_BUFFER_HPP
+#define BEAST_PREPARE_BUFFER_HPP
+
+#include
+#include
+
+namespace beast {
+
+/** Return a shortened buffer.
+
+ The returned buffer points to the same memory as the
+ passed buffer, but with a size that is equal to or less
+ than the size of the original buffer.
+
+ @param n The size of the returned buffer.
+
+ @param buffer The buffer to shorten. Ownership of the
+ underlying memory is not transferred.
+
+ @return A new buffer that points to the first `n` bytes
+ of the original buffer.
+*/
+inline
+boost::asio::const_buffer
+prepare_buffer(std::size_t n,
+ boost::asio::const_buffer buffer)
+{
+ using boost::asio::buffer_cast;
+ using boost::asio::buffer_size;
+ return { buffer_cast(buffer),
+ (std::min)(n, buffer_size(buffer)) };
+}
+
+/** Return a shortened buffer.
+
+ The returned buffer points to the same memory as the
+ passed buffer, but with a size that is equal to or less
+ than the size of the original buffer.
+
+ @param n The size of the returned buffer.
+
+ @param buffer The buffer to shorten. Ownership of the
+ underlying memory is not transferred.
+
+ @return A new buffer that points to the first `n` bytes
+ of the original buffer.
+*/
+inline
+boost::asio::mutable_buffer
+prepare_buffer(std::size_t n,
+ boost::asio::mutable_buffer buffer)
+{
+ using boost::asio::buffer_cast;
+ using boost::asio::buffer_size;
+ return { buffer_cast(buffer),
+ (std::min)(n, buffer_size(buffer)) };
+}
+
+} // beast
+
+#endif
diff --git a/include/beast/core/prepare_buffers.hpp b/include/beast/core/prepare_buffers.hpp
index 736a2727..971725fe 100644
--- a/include/beast/core/prepare_buffers.hpp
+++ b/include/beast/core/prepare_buffers.hpp
@@ -8,6 +8,7 @@
#ifndef BEAST_PREPARE_BUFFERS_HPP
#define BEAST_PREPARE_BUFFERS_HPP
+#include
#include
#include
#include
@@ -18,142 +19,6 @@
namespace beast {
-/** Return a shortened buffer.
-
- The returned buffer points to the same memory as the
- passed buffer, but with a size that is equal to or less
- than the size of the original buffer.
-
- @param n The size of the returned buffer.
-
- @param buffer The buffer to shorten. Ownership of the
- underlying memory is not transferred.
-
- @return A new buffer that points to the first `n` bytes
- of the original buffer.
-*/
-inline
-boost::asio::const_buffer
-prepare_buffer(std::size_t n,
- boost::asio::const_buffer buffer)
-{
- using boost::asio::buffer_cast;
- using boost::asio::buffer_size;
- return { buffer_cast(buffer),
- (std::min)(n, buffer_size(buffer)) };
-}
-
-/** Return a shortened buffer.
-
- The returned buffer points to the same memory as the
- passed buffer, but with a size that is equal to or less
- than the size of the original buffer.
-
- @param n The size of the returned buffer.
-
- @param buffer The buffer to shorten. Ownership of the
- underlying memory is not transferred.
-
- @return A new buffer that points to the first `n` bytes
- of the original buffer.
-*/
-inline
-boost::asio::mutable_buffer
-prepare_buffer(std::size_t n,
- boost::asio::mutable_buffer buffer)
-{
- using boost::asio::buffer_cast;
- using boost::asio::buffer_size;
- return { buffer_cast(buffer),
- (std::min)(n, buffer_size(buffer)) };
-}
-
-/** A buffer sequence adapter that shortens the sequence size.
-
- The class adapts a buffer sequence to efficiently represent
- a shorter subset of the original list of buffers starting
- with the first byte of the original sequence.
-
- @tparam BufferSequence The buffer sequence to adapt.
-*/
-template
-class prepared_buffers
-{
- using iter_type =
- typename BufferSequence::const_iterator;
-
- BufferSequence bs_;
- iter_type back_;
- iter_type end_;
- std::size_t size_;
-
- template
- prepared_buffers(Deduced&& other,
- std::size_t nback, std::size_t nend)
- : bs_(std::forward(other).bs_)
- , back_(std::next(bs_.begin(), nback))
- , end_(std::next(bs_.begin(), nend))
- , size_(other.size_)
- {
- }
-
- void
- setup(std::size_t n);
-
-public:
- /// The type for each element in the list of buffers.
- using value_type = typename std::conditional<
- std::is_convertible::value_type,
- boost::asio::mutable_buffer>::value,
- boost::asio::mutable_buffer,
- boost::asio::const_buffer>::type;
-
-#if GENERATING_DOCS
- /// A bidirectional iterator type that may be used to read elements.
- using const_iterator = implementation_defined;
-
-#else
- class const_iterator;
-
-#endif
-
- /// Move constructor.
- prepared_buffers(prepared_buffers&&);
-
- /// Copy constructor.
- prepared_buffers(prepared_buffers const&);
-
- /// Move assignment.
- prepared_buffers& operator=(prepared_buffers&&);
-
- /// Copy assignment.
- prepared_buffers& operator=(prepared_buffers const&);
-
- /** Construct a shortened buffer sequence.
-
- @param n The maximum number of bytes in the wrapped
- sequence. If this is larger than the size of passed,
- buffers, the resulting sequence will represent the
- entire input sequence.
-
- @param buffers The buffer sequence to adapt. A copy of
- the sequence will be made, but ownership of the underlying
- memory is not transferred.
- */
- prepared_buffers(std::size_t n, BufferSequence const& buffers);
-
- /// Get a bidirectional iterator to the first element.
- const_iterator
- begin() const;
-
- /// Get a bidirectional iterator to one past the last element.
- const_iterator
- end() const;
-};
-
-//------------------------------------------------------------------------------
-
/** Return a shortened buffer sequence.
This function returns a new buffer sequence which adapts the
@@ -171,11 +36,17 @@ public:
memory is not transferred.
*/
template
-prepared_buffers
-prepare_buffers(std::size_t n, BufferSequence const& buffers);
+#if GENERATING_DOCS
+implementation_defined
+#else
+inline
+detail::prepared_buffers
+#endif
+prepare_buffers(std::size_t n, BufferSequence const& buffers)
+{
+ return detail::prepared_buffers(n, buffers);
+}
} // beast
-#include
-
#endif