Skip to content

Commit

Permalink
Rename buffer to make_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtum committed Mar 23, 2024
1 parent 3b61384 commit 17b125d
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 47 deletions.
4 changes: 2 additions & 2 deletions doc/qbk/quickref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<member><link linkend="buffers.ref.boost__buffers__const_buffer">const_buffer</link></member>
<member><link linkend="buffers.ref.boost__buffers__const_buffer_pair">const_buffer_pair</link></member>
<member><link linkend="buffers.ref.boost__buffers__const_buffer_span">const_buffer_span</link></member>
<member><link linkend="buffers.ref.boost__buffers__const_buffer_subspan">const_buffer_span</link></member>
<member><link linkend="buffers.ref.boost__buffers__const_buffer_subspan">const_buffer_subspan</link></member>
<member><link linkend="buffers.ref.boost__buffers__flat_buffer">flat_buffer</link></member>
<member><link linkend="buffers.ref.boost__buffers__mutable_buffer">mutable_buffer</link></member>
<member><link linkend="buffers.ref.boost__buffers__mutable_buffer_pair">mutable_buffer_pair</link></member>
Expand All @@ -40,11 +40,11 @@
<bridgehead renderas="sect3">Functions</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="buffers.ref.boost__buffers__begin">begin</link></member>
<member><link linkend="buffers.ref.boost__buffers__buffer">buffer</link></member>
<member><link linkend="buffers.ref.boost__buffers__buffer_copy">buffer_copy</link></member>
<member><link linkend="buffers.ref.boost__buffers__buffer_size">buffer_size</link></member>
<member><link linkend="buffers.ref.boost__buffers__end">end</link></member>
<member><link linkend="buffers.ref.boost__buffers__front">front</link></member>
<member><link linkend="buffers.ref.boost__buffers__make_buffer">make_buffer</link></member>
<member><link linkend="buffers.ref.boost__buffers__prefix">prefix</link></member>
<member><link linkend="buffers.ref.boost__buffers__range">range</link></member>
<member><link linkend="buffers.ref.boost__buffers__sans_prefix">sans_prefix</link></member>
Expand Down
2 changes: 1 addition & 1 deletion doc/xsl/custom-overrides.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</xsl:if>
</xsl:template>

<xsl:template mode="convenience-header" match="@file[contains(., 'boost/buffers')]">url.hpp</xsl:template>
<xsl:template mode="convenience-header" match="@file[contains(., 'boost/buffers')]">buffers.hpp</xsl:template>
<xsl:template mode="convenience-header" match="@file"/>

<xsl:variable name="emphasized-template-parameter-types" select="
Expand Down
2 changes: 1 addition & 1 deletion include/boost/buffers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define BOOST_BUFFERS_HPP

#include <boost/buffers/algorithm.hpp>
#include <boost/buffers/buffer.hpp>
#include <boost/buffers/buffer_copy.hpp>
#include <boost/buffers/buffer_size.hpp>
#include <boost/buffers/circular_buffer.hpp>
Expand All @@ -20,6 +19,7 @@
#include <boost/buffers/const_buffer_span.hpp>
#include <boost/buffers/const_buffer_subspan.hpp>
#include <boost/buffers/flat_buffer.hpp>
#include <boost/buffers/make_buffer.hpp>
#include <boost/buffers/mutable_buffer.hpp>
#include <boost/buffers/mutable_buffer_pair.hpp>
#include <boost/buffers/mutable_buffer_span.hpp>
Expand Down
1 change: 0 additions & 1 deletion include/boost/buffers/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <boost/buffers/range.hpp>
#include <boost/buffers/tag_invoke.hpp>
#include <boost/buffers/type_traits.hpp>
#include <memory>

namespace boost {
namespace buffers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// Official repository: https://github.com/cppalliance/buffers
//

#ifndef BOOST_BUFFERS_BUFFER_HPP
#define BOOST_BUFFERS_BUFFER_HPP
#ifndef BOOST_BUFFERS_MAKE_BUFFER_HPP
#define BOOST_BUFFERS_MAKE_BUFFER_HPP

#include <boost/buffers/detail/config.hpp>
#include <boost/buffers/const_buffer.hpp>
Expand All @@ -23,7 +23,7 @@ namespace buffers {
*/
inline
mutable_buffer
buffer(
make_buffer(
mutable_buffer const& b) noexcept
{
return b;
Expand All @@ -33,7 +33,7 @@ buffer(
*/
inline
mutable_buffer
buffer(
make_buffer(
void* data,
std::size_t size) noexcept
{
Expand All @@ -44,7 +44,7 @@ buffer(
*/
inline
const_buffer
buffer(
make_buffer(
const_buffer const& b) noexcept
{
return b;
Expand All @@ -54,7 +54,7 @@ buffer(
*/
inline
const_buffer
buffer(
make_buffer(
void const* data,
std::size_t size) noexcept
{
Expand All @@ -71,7 +71,7 @@ template<
#endif
>
mutable_buffer
buffer(
make_buffer(
T (&data)[N]) noexcept
{
return mutable_buffer(
Expand All @@ -88,7 +88,7 @@ template<
#endif
>
const_buffer
buffer(
make_buffer(
T const (&data)[N]) noexcept
{
return const_buffer(
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ set(PFILES
test_helpers.hpp
algorithm.cpp
any_dynamic_buffer.cpp
buffer.cpp
buffer_copy.cpp
buffer_size.cpp
buffers.cpp
Expand All @@ -28,6 +27,7 @@ set(PFILES
const_buffer_span.cpp
const_buffer_subspan.cpp
flat_buffer.cpp
make_buffer.cpp
mutable_buffer.cpp
mutable_buffer_pair.cpp
mutable_buffer_span.cpp
Expand Down
2 changes: 1 addition & 1 deletion test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ project
local SOURCES =
algorithm.cpp
any_dynamic_buffer.cpp
buffer.cpp
buffer_copy.cpp
buffer_size.cpp
buffers.cpp
Expand All @@ -31,6 +30,7 @@ local SOURCES =
const_buffer_span.cpp
const_buffer_subspan.cpp
flat_buffer.cpp
make_buffer.cpp
mutable_buffer.cpp
mutable_buffer_pair.cpp
mutable_buffer_span.cpp
Expand Down
6 changes: 3 additions & 3 deletions test/any_dynamic_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct any_dynamic_buffer_test
db.consume(i - 1);
db.commit(buffer_copy(
db.prepare(j),
buffer(
make_buffer(
pat.data(),
pat.size())));
db.consume(1);
Expand All @@ -55,13 +55,13 @@ struct any_dynamic_buffer_test
{
db.commit(buffer_copy(
db.prepare(j),
buffer(
make_buffer(
pat.data(),
pat.size())));
}
db.commit(buffer_copy(
db.prepare(pat.size() - j),
buffer(
make_buffer(
pat.data() + j,
pat.size() - j)));
BOOST_TEST_EQ(test_to_string(
Expand Down
14 changes: 7 additions & 7 deletions test/circular_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct circular_buffer_test
// circular_buffer const&)
{
circular_buffer cb0(
buffer(&pat[0], pat.size()));
make_buffer(&pat[0], pat.size()));
circular_buffer cb1(cb0);
BOOST_TEST_EQ(cb1.size(), cb0.size());
BOOST_TEST_EQ(cb1.capacity(), cb0.capacity());
Expand All @@ -83,7 +83,7 @@ struct circular_buffer_test
// circular_buffer const&)
{
circular_buffer cb0(
buffer(&pat[0], pat.size()));
make_buffer(&pat[0], pat.size()));
circular_buffer cb1;
cb1 = cb0;
BOOST_TEST_EQ(cb1.size(), cb0.size());
Expand All @@ -93,7 +93,7 @@ struct circular_buffer_test

// prepare(std::size_t)
{
circular_buffer cb(buffer(
circular_buffer cb(make_buffer(
&pat[0], pat.size()));
BOOST_TEST_THROWS(
cb.prepare(cb.capacity() + 1),
Expand All @@ -102,7 +102,7 @@ struct circular_buffer_test

// commit(std::size_t)
{
circular_buffer cb(buffer(
circular_buffer cb(make_buffer(
&pat[0], pat.size()));
auto n = pat.size() / 2;
cb.prepare(pat.size());
Expand Down Expand Up @@ -141,7 +141,7 @@ struct circular_buffer_test
bs.consume(i - 1);
bs.commit(buffer_copy(
bs.prepare(j),
buffer(
make_buffer(
pat.data(),
pat.size())));
bs.consume(1);
Expand All @@ -150,7 +150,7 @@ struct circular_buffer_test
{
bs.commit(buffer_copy(
bs.prepare(j),
buffer(
make_buffer(
pat.data(),
pat.size())));
BOOST_TEST_EQ(
Expand All @@ -159,7 +159,7 @@ struct circular_buffer_test
}
bs.commit(buffer_copy(
bs.prepare(pat.size() - j),
buffer(
make_buffer(
pat.data() + j,
pat.size() - j)));
BOOST_TEST_EQ(test_to_string(
Expand Down
4 changes: 2 additions & 2 deletions test/flat_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ struct flat_buffer_test
flat_buffer fb(&s[0], s.size());
fb.commit(buffer_copy(
fb.prepare(i),
buffer(&pat[0], i)));
make_buffer(&pat[0], i)));
fb.commit(buffer_copy(
fb.prepare(pat.size() - i),
buffer(&pat[i], pat.size() - i)));
make_buffer(&pat[i], pat.size() - i)));
BOOST_TEST_EQ(test_to_string(
fb.data()), pat);
fb.consume(i);
Expand Down
32 changes: 16 additions & 16 deletions test/buffer.cpp → test/make_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,62 @@
//

// Test that header file is self-contained.
#include <boost/buffers/buffer.hpp>
#include <boost/buffers/make_buffer.hpp>

#include "test_suite.hpp"

namespace boost {
namespace buffers {

struct buffer_test
struct make_buffer_test
{
void
testBuffer()
{
char buf[3]{};
char const* cbuf = buf;

// buffer(mutable_buffer)
// make_buffer(mutable_buffer)
{
mutable_buffer b(buf, 3);
auto b1 = buffer(b);
auto b1 = make_buffer(b);
BOOST_TEST_EQ(b1.data(), b.data());
BOOST_TEST_EQ(b1.size(), b.size());
}

// buffer(void*, std::size_t)
// make_buffer(void*, std::size_t)
{
auto b = buffer(buf, 3);
auto b = make_buffer(buf, 3);
BOOST_TEST_EQ(b.data(), buf);
BOOST_TEST_EQ(b.size(), 3);
}

// buffer(const_buffer)
// make_buffer(const_buffer)
{
const_buffer b(cbuf, 3);
auto b1 = buffer(b);
auto b1 = make_buffer(b);
BOOST_TEST_EQ(b1.data(), b.data());
BOOST_TEST_EQ(b1.size(), b.size());
}

// buffer(void const*, std::size_t)
// make_buffer(void const*, std::size_t)
{
auto b = buffer(cbuf, 3);
auto b = make_buffer(cbuf, 3);
BOOST_TEST_EQ(b.data(), cbuf);
BOOST_TEST_EQ(b.size(), 3);
}

// buffer(T(&)[N])
// make_buffer(T(&)[N])
{
mutable_buffer b = buffer(buf);
mutable_buffer b = make_buffer(buf);
BOOST_TEST_EQ(b.data(), buf);
BOOST_TEST_EQ(b.size(), 3);
}

// buffer(T const(&)[N])
// make_buffer(T const(&)[N])
{
char const cbuf3[3]{};
const_buffer b = buffer(cbuf3);
const_buffer b = make_buffer(cbuf3);
BOOST_TEST_EQ(b.data(), cbuf3);
BOOST_TEST_EQ(b.size(), 3);
}
Expand All @@ -77,8 +77,8 @@ struct buffer_test
};

TEST_SUITE(
buffer_test,
"boost.buffers.buffer");
make_buffer_test,
"boost.buffers.make_buffer");

} // buffers
} // boost
4 changes: 2 additions & 2 deletions test/string_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct string_buffer_test
string_buffer b1(std::move(b0));
auto n = buffer_copy(
b1.prepare(5),
buffer("12345", 5));
make_buffer("12345", 5));
BOOST_TEST_EQ(n, 5);
b1.commit(5);
}
Expand Down Expand Up @@ -129,7 +129,7 @@ struct string_buffer_test
string_buffer b(&s);
auto n = buffer_copy(
b.prepare(5),
buffer("12345", 5));
make_buffer("12345", 5));
BOOST_TEST_EQ(n, 5);
b.commit(3);
BOOST_TEST_EQ(b.size(), 3);
Expand Down
4 changes: 2 additions & 2 deletions test/test_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#define BOOST_BUFFERS_TEST_HELPERS_HPP

#include <boost/buffers/algorithm.hpp>
#include <boost/buffers/buffer.hpp>
#include <boost/buffers/buffer_copy.hpp>
#include <boost/buffers/buffer_size.hpp>
#include <boost/buffers/make_buffer.hpp>
#include <boost/buffers/range.hpp>
#include <string>
#include "test_suite.hpp"
Expand All @@ -37,7 +37,7 @@ test_to_string(Buffers const& bs)
std::string s(
buffer_size(bs), 0);
s.resize(buffer_copy(
buffer(&s[0], s.size()),
make_buffer(&s[0], s.size()),
bs));
return s;
}
Expand Down

0 comments on commit 17b125d

Please sign in to comment.