11 #ifndef ASIO_BUFFER_HPP 12 #define ASIO_BUFFER_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 25 #include "asio/detail/array_fwd.hpp" 26 #include "asio/detail/memory.hpp" 27 #include "asio/detail/string_view.hpp" 28 #include "asio/detail/throw_exception.hpp" 29 #include "asio/detail/type_traits.hpp" 31 #if defined(ASIO_MSVC) && (ASIO_MSVC >= 1700) 32 # if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0) 33 # if !defined(ASIO_DISABLE_BUFFER_DEBUGGING) 34 # define ASIO_ENABLE_BUFFER_DEBUGGING 35 # endif // !defined(ASIO_DISABLE_BUFFER_DEBUGGING) 36 # endif // defined(_HAS_ITERATOR_DEBUGGING) 37 #endif // defined(ASIO_MSVC) && (ASIO_MSVC >= 1700) 40 # if defined(_GLIBCXX_DEBUG) 41 # if !defined(ASIO_DISABLE_BUFFER_DEBUGGING) 42 # define ASIO_ENABLE_BUFFER_DEBUGGING 43 # endif // !defined(ASIO_DISABLE_BUFFER_DEBUGGING) 44 # endif // defined(_GLIBCXX_DEBUG) 45 #endif // defined(__GNUC__) 47 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 48 # include "asio/detail/functional.hpp" 49 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 51 #if defined(ASIO_HAS_BOOST_WORKAROUND) 52 # include <boost/detail/workaround.hpp> 53 # if !defined(__clang__) 54 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) 55 # define ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND 56 # endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) 57 # elif BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) 58 # define ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND 59 # endif // BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) 60 #endif // defined(ASIO_HAS_BOOST_WORKAROUND) 62 #if defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) 63 # include "asio/detail/type_traits.hpp" 64 #endif // defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) 66 #include "asio/detail/push_options.hpp" 109 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 111 asio::detail::function<
void()> debug_check)
114 debug_check_(debug_check)
118 const asio::detail::function<void()>& get_debug_check()
const 122 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 125 void*
data() const ASIO_NOEXCEPT
127 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 128 if (size_ && debug_check_)
130 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 135 std::size_t
size() const ASIO_NOEXCEPT
143 std::size_t offset = n < size_ ? n : size_;
144 data_ =
static_cast<char*
>(data_) + offset;
153 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 154 asio::detail::function<void()> debug_check_;
155 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 158 #if !defined(ASIO_NO_DEPRECATED) 178 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 180 asio::detail::function<
void()> debug_check)
184 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 193 const_iterator
begin() const ASIO_NOEXCEPT
199 const_iterator
end() const ASIO_NOEXCEPT
205 #endif // !defined(ASIO_NO_DEPRECATED) 247 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
248 , debug_check_(b.get_debug_check())
253 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 255 asio::detail::function<
void()> debug_check)
258 debug_check_(debug_check)
262 const asio::detail::function<void()>& get_debug_check()
const 266 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 269 const void*
data() const ASIO_NOEXCEPT
271 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 272 if (size_ && debug_check_)
274 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 279 std::size_t
size() const ASIO_NOEXCEPT
287 std::size_t offset = n < size_ ? n : size_;
288 data_ =
static_cast<const char*
>(data_) + offset;
297 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 298 asio::detail::function<void()> debug_check_;
299 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 302 #if !defined(ASIO_NO_DEPRECATED) 322 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 324 asio::detail::function<
void()> debug_check)
328 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 337 const_iterator
begin() const ASIO_NOEXCEPT
343 const_iterator
end() const ASIO_NOEXCEPT
349 #endif // !defined(ASIO_NO_DEPRECATED) 364 const_iterator
begin() const ASIO_NOEXCEPT
370 const_iterator
end() const ASIO_NOEXCEPT
387 template <
typename MutableBuffer>
390 is_convertible<const MutableBuffer*, const mutable_buffer*>::value
391 >::type* = 0) ASIO_NOEXCEPT
397 template <
typename ConstBuffer>
400 is_convertible<const ConstBuffer*, const const_buffer*>::value
401 >::type* = 0) ASIO_NOEXCEPT
403 return static_cast<const const_buffer*
>(detail::addressof(b));
406 #if defined(ASIO_HAS_DECLTYPE) || defined(GENERATING_DOCUMENTATION) 409 template <
typename C>
412 !is_convertible<const C*, const mutable_buffer*>::value
413 && !is_convertible<const C*, const const_buffer*>::value
414 >::type* = 0) ASIO_NOEXCEPT -> decltype(c.begin())
420 template <
typename C>
423 !is_convertible<const C*, const mutable_buffer*>::value
424 && !is_convertible<const C*, const const_buffer*>::value
425 >::type* = 0) ASIO_NOEXCEPT -> decltype(c.begin())
430 #else // defined(ASIO_HAS_DECLTYPE) || defined(GENERATING_DOCUMENTATION) 432 template <
typename C>
435 !is_convertible<const C*, const mutable_buffer*>::value
436 && !is_convertible<const C*, const const_buffer*>::value
437 >::type* = 0) ASIO_NOEXCEPT
442 template <
typename C>
445 !is_convertible<const C*, const mutable_buffer*>::value
446 && !is_convertible<const C*, const const_buffer*>::value
447 >::type* = 0) ASIO_NOEXCEPT
452 #endif // defined(ASIO_HAS_DECLTYPE) || defined(GENERATING_DOCUMENTATION) 464 template <
typename MutableBuffer>
467 is_convertible<const MutableBuffer*, const mutable_buffer*>::value
468 >::type* = 0) ASIO_NOEXCEPT
470 return static_cast<const mutable_buffer*
>(detail::addressof(b)) + 1;
474 template <
typename ConstBuffer>
477 is_convertible<const ConstBuffer*, const const_buffer*>::value
478 >::type* = 0) ASIO_NOEXCEPT
480 return static_cast<const const_buffer*
>(detail::addressof(b)) + 1;
483 #if defined(ASIO_HAS_DECLTYPE) || defined(GENERATING_DOCUMENTATION) 486 template <
typename C>
489 !is_convertible<const C*, const mutable_buffer*>::value
490 && !is_convertible<const C*, const const_buffer*>::value
491 >::type* = 0) ASIO_NOEXCEPT -> decltype(c.end())
497 template <
typename C>
500 !is_convertible<const C*, const mutable_buffer*>::value
501 && !is_convertible<const C*, const const_buffer*>::value
502 >::type* = 0) ASIO_NOEXCEPT -> decltype(c.end())
507 #else // defined(ASIO_HAS_DECLTYPE) || defined(GENERATING_DOCUMENTATION) 509 template <
typename C>
512 !is_convertible<const C*, const mutable_buffer*>::value
513 && !is_convertible<const C*, const const_buffer*>::value
514 >::type* = 0) ASIO_NOEXCEPT
519 template <
typename C>
522 !is_convertible<const C*, const mutable_buffer*>::value
523 && !is_convertible<const C*, const const_buffer*>::value
524 >::type* = 0) ASIO_NOEXCEPT
529 #endif // defined(ASIO_HAS_DECLTYPE) || defined(GENERATING_DOCUMENTATION) 540 template <
typename BufferSequence>
543 is_same<BufferSequence, mutable_buffer>::value
544 #if !defined(ASIO_NO_DEPRECATED)
545 || is_same<BufferSequence, mutable_buffers_1>::value
546 || is_same<BufferSequence, const_buffers_1>::value
548 || is_same<BufferSequence, const_buffer>::value,
549 one_buffer, multiple_buffers>::type {};
551 template <
typename Iterator>
553 Iterator begin, Iterator) ASIO_NOEXCEPT
558 template <
typename Iterator>
560 Iterator begin, Iterator end) ASIO_NOEXCEPT
562 std::size_t total_buffer_size = 0;
564 Iterator iter = begin;
565 for (; iter != end; ++iter)
568 total_buffer_size += b.
size();
571 return total_buffer_size;
594 template <
typename BufferSequence>
595 inline std::size_t buffer_size(
const BufferSequence& b) ASIO_NOEXCEPT
597 return detail::buffer_size(
599 asio::buffer_sequence_begin(b),
600 asio::buffer_sequence_end(b));
603 #if !defined(ASIO_NO_DEPRECATED) 629 template <
typename Po
interToPodType>
632 return static_cast<PointerToPodType
>(b.data());
636 template <
typename Po
interToPodType>
639 return static_cast<PointerToPodType
>(b.data());
644 #endif // !defined(ASIO_NO_DEPRECATED) 651 std::size_t n) ASIO_NOEXCEPT
653 std::size_t offset = n < b.size() ? n : b.size();
654 char* new_data =
static_cast<char*
>(b.data()) + offset;
655 std::size_t new_size = b.size() - offset;
657 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
658 , b.get_debug_check()
659 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 678 std::size_t n) ASIO_NOEXCEPT
680 std::size_t offset = n < b.size() ? n : b.size();
681 const char* new_data =
static_cast<const char*
>(b.data()) + offset;
682 std::size_t new_size = b.size() - offset;
684 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
685 , b.get_debug_check()
686 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 700 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 703 template <
typename Iterator>
704 class buffer_debug_check
707 buffer_debug_check(Iterator iter)
712 ~buffer_debug_check()
714 #if defined(ASIO_MSVC) && (ASIO_MSVC == 1400) 719 #endif // defined(ASIO_MSVC) && (ASIO_MSVC == 1400) 732 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 897 #if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) 898 # define ASIO_MUTABLE_BUFFER mutable_buffer 899 # define ASIO_CONST_BUFFER const_buffer 900 #else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) 901 # define ASIO_MUTABLE_BUFFER mutable_buffers_1 902 # define ASIO_CONST_BUFFER const_buffers_1 903 #endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) 912 return ASIO_MUTABLE_BUFFER(b);
923 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
925 return ASIO_MUTABLE_BUFFER(
927 b.size() < max_size_in_bytes
928 ? b.size() : max_size_in_bytes
929 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 930 , b.get_debug_check()
931 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 942 return ASIO_CONST_BUFFER(b);
953 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
955 return ASIO_CONST_BUFFER(b.data(),
956 b.size() < max_size_in_bytes
957 ? b.size() : max_size_in_bytes
958 #if defined(ASIO_ENABLE_BUFFER_DEBUGGING) 959 , b.get_debug_check()
960 #endif // ASIO_ENABLE_BUFFER_DEBUGGING 968 inline ASIO_MUTABLE_BUFFER
buffer(
void* data,
969 std::size_t size_in_bytes) ASIO_NOEXCEPT
971 return ASIO_MUTABLE_BUFFER(data, size_in_bytes);
978 inline ASIO_CONST_BUFFER
buffer(
const void* data,
979 std::size_t size_in_bytes) ASIO_NOEXCEPT
981 return ASIO_CONST_BUFFER(data, size_in_bytes);
991 template <
typename PodType, std::
size_t N>
992 inline ASIO_MUTABLE_BUFFER
buffer(PodType (&data)[N]) ASIO_NOEXCEPT
994 return ASIO_MUTABLE_BUFFER(data, N *
sizeof(PodType));
1004 template <
typename PodType, std::
size_t N>
1005 inline ASIO_MUTABLE_BUFFER
buffer(PodType (&data)[N],
1006 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1008 return ASIO_MUTABLE_BUFFER(data,
1009 N *
sizeof(PodType) < max_size_in_bytes
1010 ? N *
sizeof(PodType) : max_size_in_bytes);
1020 template <
typename PodType, std::
size_t N>
1022 const PodType (&data)[N]) ASIO_NOEXCEPT
1024 return ASIO_CONST_BUFFER(data, N *
sizeof(PodType));
1034 template <
typename PodType, std::
size_t N>
1035 inline ASIO_CONST_BUFFER
buffer(
const PodType (&data)[N],
1036 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1038 return ASIO_CONST_BUFFER(data,
1039 N *
sizeof(PodType) < max_size_in_bytes
1040 ? N *
sizeof(PodType) : max_size_in_bytes);
1043 #if defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) 1059 template <
bool IsConst>
1060 struct buffer_types_base;
1063 struct buffer_types_base<false>
1066 typedef ASIO_MUTABLE_BUFFER container_type;
1070 struct buffer_types_base<true>
1073 typedef ASIO_CONST_BUFFER container_type;
1076 template <
typename PodType>
1078 :
public buffer_types_base<is_const<PodType>::value>
1084 template <
typename PodType, std::
size_t N>
1085 inline typename detail::buffer_types<PodType>::container_type
1088 typedef typename asio::detail::buffer_types<PodType>::buffer_type
1090 typedef typename asio::detail::buffer_types<PodType>::container_type
1092 return container_type(
1093 buffer_type(data.c_array(), data.size() *
sizeof(PodType)));
1096 template <
typename PodType, std::
size_t N>
1097 inline typename detail::buffer_types<PodType>::container_type
1099 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1101 typedef typename asio::detail::buffer_types<PodType>::buffer_type
1103 typedef typename asio::detail::buffer_types<PodType>::container_type
1105 return container_type(
1106 buffer_type(data.c_array(),
1107 data.size() *
sizeof(PodType) < max_size_in_bytes
1108 ? data.size() *
sizeof(PodType) : max_size_in_bytes));
1111 #else // defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) 1120 template <
typename PodType, std::
size_t N>
1124 return ASIO_MUTABLE_BUFFER(
1125 data.c_array(), data.size() *
sizeof(PodType));
1135 template <
typename PodType, std::
size_t N>
1137 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1139 return ASIO_MUTABLE_BUFFER(data.c_array(),
1140 data.size() *
sizeof(PodType) < max_size_in_bytes
1141 ? data.size() *
sizeof(PodType) : max_size_in_bytes);
1151 template <
typename PodType, std::
size_t N>
1155 return ASIO_CONST_BUFFER(data.data(), data.size() *
sizeof(PodType));
1165 template <
typename PodType, std::
size_t N>
1167 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1169 return ASIO_CONST_BUFFER(data.data(),
1170 data.size() *
sizeof(PodType) < max_size_in_bytes
1171 ? data.size() *
sizeof(PodType) : max_size_in_bytes);
1174 #endif // defined(ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND) 1183 template <
typename PodType, std::
size_t N>
1184 inline ASIO_CONST_BUFFER
buffer(
1187 return ASIO_CONST_BUFFER(data.data(), data.size() *
sizeof(PodType));
1197 template <
typename PodType, std::
size_t N>
1199 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1201 return ASIO_CONST_BUFFER(data.data(),
1202 data.size() *
sizeof(PodType) < max_size_in_bytes
1203 ? data.size() *
sizeof(PodType) : max_size_in_bytes);
1206 #if defined(ASIO_HAS_STD_ARRAY) || defined(GENERATING_DOCUMENTATION) 1215 template <
typename PodType, std::
size_t N>
1216 inline ASIO_MUTABLE_BUFFER
buffer(
1217 std::array<PodType, N>& data) ASIO_NOEXCEPT
1219 return ASIO_MUTABLE_BUFFER(data.data(), data.size() *
sizeof(PodType));
1229 template <
typename PodType, std::
size_t N>
1230 inline ASIO_MUTABLE_BUFFER
buffer(std::array<PodType, N>& data,
1231 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1233 return ASIO_MUTABLE_BUFFER(data.data(),
1234 data.size() *
sizeof(PodType) < max_size_in_bytes
1235 ? data.size() *
sizeof(PodType) : max_size_in_bytes);
1245 template <
typename PodType, std::
size_t N>
1246 inline ASIO_CONST_BUFFER
buffer(
1247 std::array<const PodType, N>& data) ASIO_NOEXCEPT
1249 return ASIO_CONST_BUFFER(data.data(), data.size() *
sizeof(PodType));
1259 template <
typename PodType, std::
size_t N>
1260 inline ASIO_CONST_BUFFER
buffer(std::array<const PodType, N>& data,
1261 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1263 return ASIO_CONST_BUFFER(data.data(),
1264 data.size() *
sizeof(PodType) < max_size_in_bytes
1265 ? data.size() *
sizeof(PodType) : max_size_in_bytes);
1275 template <
typename PodType, std::
size_t N>
1276 inline ASIO_CONST_BUFFER
buffer(
1277 const std::array<PodType, N>& data) ASIO_NOEXCEPT
1279 return ASIO_CONST_BUFFER(data.data(), data.size() *
sizeof(PodType));
1289 template <
typename PodType, std::
size_t N>
1290 inline ASIO_CONST_BUFFER
buffer(
const std::array<PodType, N>& data,
1291 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1293 return ASIO_CONST_BUFFER(data.data(),
1294 data.size() *
sizeof(PodType) < max_size_in_bytes
1295 ? data.size() *
sizeof(PodType) : max_size_in_bytes);
1298 #endif // defined(ASIO_HAS_STD_ARRAY) || defined(GENERATING_DOCUMENTATION) 1310 template <
typename PodType,
typename Allocator>
1312 std::vector<PodType, Allocator>& data) ASIO_NOEXCEPT
1314 return ASIO_MUTABLE_BUFFER(
1315 data.size() ? &data[0] : 0, data.size() *
sizeof(PodType)
1316 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1317 , detail::buffer_debug_check<
1318 typename std::vector<PodType, Allocator>::iterator
1334 template <
typename PodType,
typename Allocator>
1335 inline ASIO_MUTABLE_BUFFER
buffer(std::vector<PodType, Allocator>& data,
1336 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1338 return ASIO_MUTABLE_BUFFER(data.size() ? &data[0] : 0,
1339 data.size() *
sizeof(PodType) < max_size_in_bytes
1340 ? data.size() *
sizeof(PodType) : max_size_in_bytes
1341 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1342 , detail::buffer_debug_check<
1343 typename std::vector<PodType, Allocator>::iterator
1359 template <
typename PodType,
typename Allocator>
1361 const std::vector<PodType, Allocator>& data) ASIO_NOEXCEPT
1363 return ASIO_CONST_BUFFER(
1364 data.size() ? &data[0] : 0, data.size() *
sizeof(PodType)
1365 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1366 , detail::buffer_debug_check<
1367 typename std::vector<PodType, Allocator>::const_iterator
1383 template <
typename PodType,
typename Allocator>
1385 const std::vector<PodType, Allocator>& data,
1386 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1388 return ASIO_CONST_BUFFER(data.size() ? &data[0] : 0,
1389 data.size() *
sizeof(PodType) < max_size_in_bytes
1390 ? data.size() *
sizeof(PodType) : max_size_in_bytes
1391 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1392 , detail::buffer_debug_check<
1393 typename std::vector<PodType, Allocator>::const_iterator
1407 template <
typename Elem,
typename Traits,
typename Allocator>
1409 std::basic_string<Elem, Traits, Allocator>& data) ASIO_NOEXCEPT
1411 return ASIO_MUTABLE_BUFFER(data.size() ? &data[0] : 0,
1412 data.size() *
sizeof(Elem)
1413 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1414 , detail::buffer_debug_check<
1415 typename std::basic_string<Elem, Traits, Allocator>::iterator
1431 template <
typename Elem,
typename Traits,
typename Allocator>
1433 std::basic_string<Elem, Traits, Allocator>& data,
1434 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1436 return ASIO_MUTABLE_BUFFER(data.size() ? &data[0] : 0,
1437 data.size() *
sizeof(Elem) < max_size_in_bytes
1438 ? data.size() *
sizeof(Elem) : max_size_in_bytes
1439 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1440 , detail::buffer_debug_check<
1441 typename std::basic_string<Elem, Traits, Allocator>::iterator
1454 template <
typename Elem,
typename Traits,
typename Allocator>
1456 const std::basic_string<Elem, Traits, Allocator>& data) ASIO_NOEXCEPT
1458 return ASIO_CONST_BUFFER(data.data(), data.size() *
sizeof(Elem)
1459 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1460 , detail::buffer_debug_check<
1461 typename std::basic_string<Elem, Traits, Allocator>::const_iterator
1477 template <
typename Elem,
typename Traits,
typename Allocator>
1479 const std::basic_string<Elem, Traits, Allocator>& data,
1480 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1482 return ASIO_CONST_BUFFER(data.data(),
1483 data.size() *
sizeof(Elem) < max_size_in_bytes
1484 ? data.size() *
sizeof(Elem) : max_size_in_bytes
1485 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1486 , detail::buffer_debug_check<
1487 typename std::basic_string<Elem, Traits, Allocator>::const_iterator
1493 #if defined(ASIO_HAS_STRING_VIEW) \ 1494 || defined(GENERATING_DOCUMENTATION) 1501 template <
typename Elem,
typename Traits>
1502 inline ASIO_CONST_BUFFER
buffer(
1505 return ASIO_CONST_BUFFER(data.
size() ? &data[0] : 0,
1506 data.
size() *
sizeof(Elem)
1507 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1508 , detail::buffer_debug_check<
1509 typename basic_string_view<Elem, Traits>::iterator
1522 template <
typename Elem,
typename Traits>
1523 inline ASIO_CONST_BUFFER
buffer(
1525 std::size_t max_size_in_bytes) ASIO_NOEXCEPT
1527 return ASIO_CONST_BUFFER(data.
size() ? &data[0] : 0,
1528 data.
size() *
sizeof(Elem) < max_size_in_bytes
1529 ? data.
size() *
sizeof(Elem) : max_size_in_bytes
1530 #
if defined(ASIO_ENABLE_BUFFER_DEBUGGING)
1531 , detail::buffer_debug_check<
1532 typename basic_string_view<Elem, Traits>::iterator
1538 #endif // defined(ASIO_HAS_STRING_VIEW) 1547 template <
typename Elem,
typename Traits,
typename Allocator>
1572 std::size_t maximum_size =
1573 (std::numeric_limits<std::size_t>::max)()) ASIO_NOEXCEPT
1575 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1576 size_((std::numeric_limits<std::size_t>::max)()),
1577 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1578 max_size_(maximum_size)
1584 : string_(other.string_),
1585 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1587 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1588 max_size_(other.max_size_)
1592 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 1595 : string_(other.string_),
1596 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1598 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1599 max_size_(other.max_size_)
1602 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 1611 std::size_t
size() const ASIO_NOEXCEPT
1613 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1614 if (size_ != (std::numeric_limits<std::size_t>::max)())
1616 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1617 return (std::min)(string_.size(), max_size());
1637 return (std::min)(string_.capacity(), max_size());
1640 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1651 const_buffers_type
data() const ASIO_NOEXCEPT
1653 return const_buffers_type(
asio::buffer(string_, size_));
1655 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1672 mutable_buffers_type
data(std::size_t pos, std::size_t n) ASIO_NOEXCEPT
1690 const_buffers_type
data(std::size_t pos,
1691 std::size_t n)
const ASIO_NOEXCEPT
1697 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1716 if (
size() > max_size() || max_size() -
size() < n)
1718 std::length_error ex(
"dynamic_string_buffer too long");
1719 asio::detail::throw_exception(ex);
1722 if (size_ == (std::numeric_limits<std::size_t>::max)())
1723 size_ = string_.size();
1725 string_.resize(size_ + n);
1745 size_ += (std::min)(n, string_.size() - size_);
1746 string_.resize(size_);
1748 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1759 if (
size() > max_size() || max_size() -
size() < n)
1761 std::length_error ex(
"dynamic_string_buffer too long");
1762 asio::detail::throw_exception(ex);
1765 string_.resize(
size() + n);
1777 string_.resize(n >
size() ? 0 :
size() - n);
1794 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1795 if (size_ != (std::numeric_limits<std::size_t>::max)())
1797 std::size_t consume_length = (std::min)(n, size_);
1798 string_.erase(0, consume_length);
1799 size_ -= consume_length;
1802 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1803 string_.erase(0, n);
1807 std::basic_string<Elem, Traits, Allocator>& string_;
1808 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1810 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1811 const std::size_t max_size_;
1818 template <
typename Elem,
typename Allocator>
1824 typedef ASIO_CONST_BUFFER const_buffers_type;
1828 typedef ASIO_MUTABLE_BUFFER mutable_buffers_type;
1840 std::size_t maximum_size =
1841 (std::numeric_limits<std::size_t>::max)()) ASIO_NOEXCEPT
1843 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1844 size_((std::numeric_limits<std::size_t>::max)()),
1845 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1846 max_size_(maximum_size)
1852 : vector_(other.vector_),
1853 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1855 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1856 max_size_(other.max_size_)
1860 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 1863 : vector_(other.vector_),
1864 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1866 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1867 max_size_(other.max_size_)
1870 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 1879 std::size_t
size() const ASIO_NOEXCEPT
1881 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1882 if (size_ != (std::numeric_limits<std::size_t>::max)())
1884 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1885 return (std::min)(vector_.size(), max_size());
1909 return (std::min)(vector_.capacity(), max_size());
1912 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1924 const_buffers_type
data() const ASIO_NOEXCEPT
1926 return const_buffers_type(
asio::buffer(vector_, size_));
1928 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1945 mutable_buffers_type
data(std::size_t pos, std::size_t n) ASIO_NOEXCEPT
1963 const_buffers_type
data(std::size_t pos,
1964 std::size_t n)
const ASIO_NOEXCEPT
1970 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 1989 if (size () > max_size() || max_size() -
size() < n)
1991 std::length_error ex(
"dynamic_vector_buffer too long");
1992 asio::detail::throw_exception(ex);
1995 if (size_ == (std::numeric_limits<std::size_t>::max)())
1996 size_ = vector_.size();
1998 vector_.resize(size_ + n);
2018 size_ += (std::min)(n, vector_.size() - size_);
2019 vector_.resize(size_);
2021 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2032 if (
size() > max_size() || max_size() -
size() < n)
2034 std::length_error ex(
"dynamic_vector_buffer too long");
2035 asio::detail::throw_exception(ex);
2038 vector_.resize(
size() + n);
2050 vector_.resize(n >
size() ? 0 :
size() - n);
2067 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2068 if (size_ != (std::numeric_limits<std::size_t>::max)())
2070 std::size_t consume_length = (std::min)(n, size_);
2071 vector_.erase(vector_.begin(), vector_.begin() + consume_length);
2072 size_ -= consume_length;
2075 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2076 vector_.erase(vector_.begin(), vector_.begin() + (std::min)(
size(), n));
2080 std::vector<Elem, Allocator>& vector_;
2081 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2083 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2084 const std::size_t max_size_;
2098 template <
typename Elem,
typename Traits,
typename Allocator>
2100 std::basic_string<Elem, Traits, Allocator>& data) ASIO_NOEXCEPT
2110 template <
typename Elem,
typename Traits,
typename Allocator>
2112 std::basic_string<Elem, Traits, Allocator>& data,
2113 std::size_t max_size) ASIO_NOEXCEPT
2122 template <
typename Elem,
typename Allocator>
2124 std::vector<Elem, Allocator>& data) ASIO_NOEXCEPT
2133 template <
typename Elem,
typename Allocator>
2135 std::vector<Elem, Allocator>& data,
2136 std::size_t max_size) ASIO_NOEXCEPT
2176 using namespace std;
2177 std::size_t target_size = target.
size();
2178 std::size_t source_size = source.
size();
2179 std::size_t n = target_size < source_size ? target_size : source_size;
2181 memcpy(target.
data(), source.
data(), n);
2185 template <
typename TargetIterator,
typename SourceIterator>
2186 inline std::size_t
buffer_copy(one_buffer, one_buffer,
2187 TargetIterator target_begin, TargetIterator,
2188 SourceIterator source_begin, SourceIterator) ASIO_NOEXCEPT
2190 return (buffer_copy_1)(*target_begin, *source_begin);
2193 template <
typename TargetIterator,
typename SourceIterator>
2194 inline std::size_t
buffer_copy(one_buffer, one_buffer,
2195 TargetIterator target_begin, TargetIterator,
2196 SourceIterator source_begin, SourceIterator,
2197 std::size_t max_bytes_to_copy) ASIO_NOEXCEPT
2199 return (buffer_copy_1)(*target_begin,
2203 template <
typename TargetIterator,
typename SourceIterator>
2204 std::size_t
buffer_copy(one_buffer, multiple_buffers,
2205 TargetIterator target_begin, TargetIterator,
2206 SourceIterator source_begin, SourceIterator source_end,
2207 std::size_t max_bytes_to_copy
2208 = (std::numeric_limits<std::size_t>::max)()) ASIO_NOEXCEPT
2210 std::size_t total_bytes_copied = 0;
2211 SourceIterator source_iter = source_begin;
2215 target_buffer.
size() && source_iter != source_end; ++source_iter)
2218 std::size_t bytes_copied = (buffer_copy_1)(target_buffer, source_buffer);
2219 total_bytes_copied += bytes_copied;
2220 target_buffer += bytes_copied;
2223 return total_bytes_copied;
2226 template <
typename TargetIterator,
typename SourceIterator>
2227 std::size_t
buffer_copy(multiple_buffers, one_buffer,
2228 TargetIterator target_begin, TargetIterator target_end,
2229 SourceIterator source_begin, SourceIterator,
2230 std::size_t max_bytes_to_copy
2231 = (std::numeric_limits<std::size_t>::max)()) ASIO_NOEXCEPT
2233 std::size_t total_bytes_copied = 0;
2234 TargetIterator target_iter = target_begin;
2238 source_buffer.
size() && target_iter != target_end; ++target_iter)
2241 std::size_t bytes_copied = (buffer_copy_1)(target_buffer, source_buffer);
2242 total_bytes_copied += bytes_copied;
2243 source_buffer += bytes_copied;
2246 return total_bytes_copied;
2249 template <
typename TargetIterator,
typename SourceIterator>
2250 std::size_t
buffer_copy(multiple_buffers, multiple_buffers,
2251 TargetIterator target_begin, TargetIterator target_end,
2252 SourceIterator source_begin, SourceIterator source_end) ASIO_NOEXCEPT
2254 std::size_t total_bytes_copied = 0;
2256 TargetIterator target_iter = target_begin;
2257 std::size_t target_buffer_offset = 0;
2259 SourceIterator source_iter = source_begin;
2260 std::size_t source_buffer_offset = 0;
2262 while (target_iter != target_end && source_iter != source_end)
2270 std::size_t bytes_copied = (buffer_copy_1)(target_buffer, source_buffer);
2271 total_bytes_copied += bytes_copied;
2273 if (bytes_copied == target_buffer.
size())
2276 target_buffer_offset = 0;
2279 target_buffer_offset += bytes_copied;
2281 if (bytes_copied == source_buffer.
size())
2284 source_buffer_offset = 0;
2287 source_buffer_offset += bytes_copied;
2290 return total_bytes_copied;
2293 template <
typename TargetIterator,
typename SourceIterator>
2294 std::size_t
buffer_copy(multiple_buffers, multiple_buffers,
2295 TargetIterator target_begin, TargetIterator target_end,
2296 SourceIterator source_begin, SourceIterator source_end,
2297 std::size_t max_bytes_to_copy) ASIO_NOEXCEPT
2299 std::size_t total_bytes_copied = 0;
2301 TargetIterator target_iter = target_begin;
2302 std::size_t target_buffer_offset = 0;
2304 SourceIterator source_iter = source_begin;
2305 std::size_t source_buffer_offset = 0;
2307 while (total_bytes_copied != max_bytes_to_copy
2308 && target_iter != target_end && source_iter != source_end)
2316 std::size_t bytes_copied = (buffer_copy_1)(
2318 max_bytes_to_copy - total_bytes_copied));
2319 total_bytes_copied += bytes_copied;
2321 if (bytes_copied == target_buffer.
size())
2324 target_buffer_offset = 0;
2327 target_buffer_offset += bytes_copied;
2329 if (bytes_copied == source_buffer.
size())
2332 source_buffer_offset = 0;
2335 source_buffer_offset += bytes_copied;
2338 return total_bytes_copied;
2362 template <
typename MutableBufferSequence,
typename ConstBufferSequence>
2364 const ConstBufferSequence& source) ASIO_NOEXCEPT
2369 asio::buffer_sequence_begin(target),
2370 asio::buffer_sequence_end(target),
2371 asio::buffer_sequence_begin(source),
2372 asio::buffer_sequence_end(source));
2399 template <
typename MutableBufferSequence,
typename ConstBufferSequence>
2401 const ConstBufferSequence& source,
2402 std::size_t max_bytes_to_copy) ASIO_NOEXCEPT
2407 asio::buffer_sequence_begin(target),
2408 asio::buffer_sequence_end(target),
2409 asio::buffer_sequence_begin(source),
2410 asio::buffer_sequence_end(source), max_bytes_to_copy);
2417 #include "asio/detail/pop_options.hpp" 2418 #include "asio/detail/is_buffer_sequence.hpp" 2419 #include "asio/detail/push_options.hpp" 2425 template <
typename T>
2427 #if defined(GENERATING_DOCUMENTATION)
2428 : integral_constant<bool, automatically_determined>
2429 #else // defined(GENERATING_DOCUMENTATION) 2431 #endif // defined(GENERATING_DOCUMENTATION) 2437 template <
typename T>
2439 #if defined(GENERATING_DOCUMENTATION)
2440 : integral_constant<bool, automatically_determined>
2441 #else // defined(GENERATING_DOCUMENTATION) 2443 #endif // defined(GENERATING_DOCUMENTATION) 2447 #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2448 template <
typename T>
2452 #if defined(GENERATING_DOCUMENTATION)
2453 : integral_constant<bool, automatically_determined>
2454 #else // defined(GENERATING_DOCUMENTATION) 2456 #endif // defined(GENERATING_DOCUMENTATION) 2459 #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2463 template <
typename T>
2465 #if defined(GENERATING_DOCUMENTATION)
2466 : integral_constant<bool, automatically_determined>
2467 #else // defined(GENERATING_DOCUMENTATION) 2469 #endif // defined(GENERATING_DOCUMENTATION) 2480 template <
typename T>
2482 #if defined(GENERATING_DOCUMENTATION)
2483 : integral_constant<bool, automatically_determined>
2484 #elif defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2486 #else // defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2488 #endif // defined(ASIO_NO_DYNAMIC_BUFFER_V1) 2494 #include "asio/detail/pop_options.hpp" 2496 #endif // ASIO_BUFFER_HPP const_iterator begin() const ASIO_NOEXCEPT
Get a random-access iterator to the first element.
Definition: buffer.hpp:337
dynamic_vector_buffer(std::vector< Elem, Allocator > &v, std::size_t maximum_size=(std::numeric_limits< std::size_t >::max)()) ASIO_NOEXCEPT
Construct a dynamic buffer from a vector.
Definition: buffer.hpp:1839
const_buffer operator+(const const_buffer &b, std::size_t n) ASIO_NOEXCEPT
Create a new non-modifiable buffer that is offset from the start of another.
Definition: buffer.hpp:677
const_iterator end() const ASIO_NOEXCEPT
Get a random-access iterator for one past the last element.
Definition: buffer.hpp:199
void commit(std::size_t n)
DynamicBuffer_v1: Move bytes from the output sequence to the input sequence.
Definition: buffer.hpp:1743
const_buffer() ASIO_NOEXCEPT
Construct an empty buffer.
Definition: buffer.hpp:230
mutable_buffer() ASIO_NOEXCEPT
Construct an empty buffer.
Definition: buffer.hpp:96
mutable_buffers_1(const mutable_buffer &b) ASIO_NOEXCEPT
Construct to represent a single modifiable buffer.
Definition: buffer.hpp:187
Definition: buffer.hpp:537
void consume(std::size_t n)
DynamicBuffer_v1: Remove characters from the input sequence.
Definition: buffer.hpp:2065
const_iterator begin() const ASIO_NOEXCEPT
Get a random-access iterator to the first element.
Definition: buffer.hpp:364
const void * data() const ASIO_NOEXCEPT
Get a pointer to the beginning of the memory range.
Definition: buffer.hpp:269
Holds a buffer that cannot be modified.
Definition: buffer.hpp:226
Definition: buffer.hpp:541
mutable_buffers_type prepare(std::size_t n)
DynamicBuffer_v1: Get a list of buffers that represents the output sequence, with the given size...
Definition: buffer.hpp:1987
Definition: blocking.hpp:208
mutable_buffer & operator+=(std::size_t n) ASIO_NOEXCEPT
Move the start of the buffer by the specified number of bytes.
Definition: buffer.hpp:141
const_buffers_type data(std::size_t pos, std::size_t n) const ASIO_NOEXCEPT
DynamicBuffer_v2: Get a sequence of buffers that represents the underlying memory.
Definition: buffer.hpp:1963
const_buffers_1(const const_buffer &b) ASIO_NOEXCEPT
Construct to represent a single non-modifiable buffer.
Definition: buffer.hpp:331
Trait to determine whether a type satisfies the DynamicBuffer requirements.
Definition: buffer.hpp:2481
mutable_buffers_1(void *data, std::size_t size) ASIO_NOEXCEPT
Construct to represent a given memory range.
Definition: buffer.hpp:173
mutable_buffer value_type
The type for each element in the list of buffers.
Definition: buffer.hpp:167
const_buffer(const mutable_buffer &b) ASIO_NOEXCEPT
Construct a non-modifiable buffer from a modifiable one.
Definition: buffer.hpp:244
mutable_buffer operator+(std::size_t n, const mutable_buffer &b) ASIO_NOEXCEPT
Create a new modifiable buffer that is offset from the start of another.
Definition: buffer.hpp:667
Definition: awaitable.hpp:421
const_iterator begin() const ASIO_NOEXCEPT
Get a random-access iterator to the first element.
Definition: buffer.hpp:193
dynamic_vector_buffer< Elem, Allocator > dynamic_buffer(std::vector< Elem, Allocator > &data, std::size_t max_size) ASIO_NOEXCEPT
Create a new dynamic buffer that represents the given vector.
Definition: buffer.hpp:2134
std::size_t capacity() const ASIO_NOEXCEPT
Get the maximum size that the buffer may grow to without triggering reallocation. ...
Definition: buffer.hpp:1907
const_buffers_1(const void *data, std::size_t size) ASIO_NOEXCEPT
Construct to represent a given memory range.
Definition: buffer.hpp:317
const_buffer value_type
The type for each element in the list of buffers.
Definition: buffer.hpp:311
void shrink(std::size_t n)
DynamicBuffer_v2: Shrink the underlying memory by the specified number of bytes.
Definition: buffer.hpp:1775
const_buffers_type data() const ASIO_NOEXCEPT
DynamicBuffer_v1: Get a list of buffers that represents the input sequence.
Definition: buffer.hpp:1651
ASIO_CONST_BUFFER buffer(const std::basic_string< Elem, Traits, Allocator > &data, std::size_t max_size_in_bytes) ASIO_NOEXCEPT
Create a new non-modifiable buffer that represents the given string.
Definition: buffer.hpp:1478
mutable_buffer operator+(const mutable_buffer &b, std::size_t n) ASIO_NOEXCEPT
Create a new modifiable buffer that is offset from the start of another.
Definition: buffer.hpp:650
std::size_t capacity() const ASIO_NOEXCEPT
Get the maximum size that the buffer may grow to without triggering reallocation. ...
Definition: buffer.hpp:1635
std::size_t max_size() const ASIO_NOEXCEPT
Get the maximum size of the dynamic buffer.
Definition: buffer.hpp:1894
const mutable_buffer * const_iterator
A random-access iterator type that may be used to read elements.
Definition: buffer.hpp:361
const_iterator end() const ASIO_NOEXCEPT
Get a random-access iterator for one past the last element.
Definition: buffer.hpp:370
Adapt a vector to the DynamicBuffer requirements.
Definition: buffer.hpp:1819
(Deprecated: Use const_buffer.) Adapts a single non-modifiable buffer so that it meets the requiremen...
Definition: buffer.hpp:306
PointerToPodType buffer_cast(const const_buffer &b) ASIO_NOEXCEPT
Cast a non-modifiable buffer to a specified pointer to POD type.
Definition: buffer.hpp:637
std::size_t size() const ASIO_NOEXCEPT
Get the size of the memory range.
Definition: buffer.hpp:279
const_buffer operator+(std::size_t n, const const_buffer &b) ASIO_NOEXCEPT
Create a new non-modifiable buffer that is offset from the start of another.
Definition: buffer.hpp:694
mutable_buffers_type data(std::size_t pos, std::size_t n) ASIO_NOEXCEPT
DynamicBuffer_v2: Get a sequence of buffers that represents the underlying memory.
Definition: buffer.hpp:1945
void grow(std::size_t n)
DynamicBuffer_v2: Grow the underlying memory by the specified number of bytes.
Definition: buffer.hpp:1757
An implementation of std::basic_string_view for pre-C++17.
Definition: core.h:355
std::size_t buffer_copy(const MutableBufferSequence &target, const ConstBufferSequence &source, std::size_t max_bytes_to_copy) ASIO_NOEXCEPT
Copies a limited number of bytes from a source buffer sequence to a target buffer sequence...
Definition: buffer.hpp:2400
dynamic_vector_buffer(const dynamic_vector_buffer &other) ASIO_NOEXCEPT
DynamicBuffer_v2: Copy construct a dynamic buffer.
Definition: buffer.hpp:1851
Definition: is_buffer_sequence.hpp:300
Adapt a basic_string to the DynamicBuffer requirements.
Definition: buffer.hpp:1548
Definition: type_traits.hpp:97
void grow(std::size_t n)
DynamicBuffer_v2: Grow the underlying memory by the specified number of bytes.
Definition: buffer.hpp:2030
Trait to determine whether a type satisfies the MutableBufferSequence requirements.
Definition: buffer.hpp:2426
dynamic_string_buffer(std::basic_string< Elem, Traits, Allocator > &s, std::size_t maximum_size=(std::numeric_limits< std::size_t >::max)()) ASIO_NOEXCEPT
Construct a dynamic buffer from a string.
Definition: buffer.hpp:1571
void commit(std::size_t n)
DynamicBuffer_v1: Move bytes from the output sequence to the input sequence.
Definition: buffer.hpp:2016
Holds a buffer that can be modified.
Definition: buffer.hpp:92
void consume(std::size_t n)
DynamicBuffer_v1: Remove characters from the input sequence.
Definition: buffer.hpp:1792
const_iterator end() const ASIO_NOEXCEPT
Get a random-access iterator for one past the last element.
Definition: buffer.hpp:343
ASIO_MUTABLE_BUFFER mutable_buffers_type
The type used to represent a sequence of mutable buffers that refers to the underlying memory...
Definition: buffer.hpp:1557
mutable_buffer(void *data, std::size_t size) ASIO_NOEXCEPT
Construct a buffer to represent a given memory range.
Definition: buffer.hpp:103
const_buffers_type data() const ASIO_NOEXCEPT
DynamicBuffer_v1: Get a list of buffers that represents the input sequence.
Definition: buffer.hpp:1924
dynamic_string_buffer(const dynamic_string_buffer &other) ASIO_NOEXCEPT
DynamicBuffer_v2: Copy construct a dynamic buffer.
Definition: buffer.hpp:1583
Definition: is_buffer_sequence.hpp:277
std::size_t size() const ASIO_NOEXCEPT
DynamicBuffer_v1: Get the size of the input sequence.
Definition: buffer.hpp:1879
Trait to determine whether a type satisfies the DynamicBuffer_v2 requirements.
Definition: buffer.hpp:2464
const_buffers_type data(std::size_t pos, std::size_t n) const ASIO_NOEXCEPT
DynamicBuffer_v2: Get a sequence of buffers that represents the underlying memory.
Definition: buffer.hpp:1690
mutable_buffer value_type
The type for each element in the list of buffers.
Definition: buffer.hpp:358
Definition: is_buffer_sequence.hpp:230
mutable_buffers_type prepare(std::size_t n)
DynamicBuffer_v1: Get a list of buffers that represents the output sequence, with the given size...
Definition: buffer.hpp:1714
(Deprecated: Use the socket/descriptor wait() and async_wait() member functions.) An implementation o...
Definition: buffer.hpp:354
const mutable_buffer * buffer_sequence_begin(const MutableBuffer &b, typename enable_if< is_convertible< const MutableBuffer *, const mutable_buffer *>::value >::type *=0) ASIO_NOEXCEPT
Get an iterator to the first element in a buffer sequence.
Definition: buffer.hpp:388
void * data() const ASIO_NOEXCEPT
Get a pointer to the beginning of the memory range.
Definition: buffer.hpp:125
Trait to determine whether a type satisfies the ConstBufferSequence requirements. ...
Definition: buffer.hpp:2438
std::size_t size() const ASIO_NOEXCEPT
Get the size of the memory range.
Definition: buffer.hpp:135
const mutable_buffer * buffer_sequence_end(const MutableBuffer &b, typename enable_if< is_convertible< const MutableBuffer *, const mutable_buffer *>::value >::type *=0) ASIO_NOEXCEPT
Get an iterator to one past the end element in a buffer sequence.
Definition: buffer.hpp:465
ASIO_CONST_BUFFER const_buffers_type
The type used to represent a sequence of constant buffers that refers to the underlying memory...
Definition: buffer.hpp:1553
void shrink(std::size_t n)
DynamicBuffer_v2: Shrink the underlying memory by the specified number of bytes.
Definition: buffer.hpp:2048
std::size_t size() const ASIO_NOEXCEPT
DynamicBuffer_v1: Get the size of the input sequence.
Definition: buffer.hpp:1611
const mutable_buffer * const_iterator
A random-access iterator type that may be used to read elements.
Definition: buffer.hpp:170
const const_buffer * const_iterator
A random-access iterator type that may be used to read elements.
Definition: buffer.hpp:314
mutable_buffers_type data(std::size_t pos, std::size_t n) ASIO_NOEXCEPT
DynamicBuffer_v2: Get a sequence of buffers that represents the underlying memory.
Definition: buffer.hpp:1672
Definition: any_io_executor.hpp:28
std::size_t max_size() const ASIO_NOEXCEPT
Get the maximum size of the dynamic buffer.
Definition: buffer.hpp:1624
(Deprecated: Use mutable_buffer.) Adapts a single modifiable buffer so that it meets the requirements...
Definition: buffer.hpp:162
Definition: buffer.hpp:536
Trait to determine whether a type satisfies the DynamicBuffer_v1 requirements.
Definition: buffer.hpp:2451
Definition: array_fwd.hpp:23
const_buffer & operator+=(std::size_t n) ASIO_NOEXCEPT
Move the start of the buffer by the specified number of bytes.
Definition: buffer.hpp:285
const_buffer(const void *data, std::size_t size) ASIO_NOEXCEPT
Construct a buffer to represent a given memory range.
Definition: buffer.hpp:237
constexpr size_t size() const
Returns the string size.
Definition: core.h:399