Lines Matching +full:buffer +full:- +full:from
2 // buffer.hpp
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
48 /// Holds a buffer that can be modified.
50 * The mutable_buffer class provides a safe representation of a buffer that can
54 * @par Accessing Buffer Contents
56 * The contents of a buffer may be accessed using the @ref buffer_size
70 /// Construct an empty buffer.
77 /// Construct a buffer to represent a given memory range.
110 /// Adapts a single modifiable buffer so that it meets the requirements of the
119 /// A random-access iterator type that may be used to read elements.
128 /// Construct to represent a single modifiable buffer.
134 /// Get a random-access iterator to the first element.
140 /// Get a random-access iterator for one past the last element.
147 /// Holds a buffer that cannot be modified.
149 * The const_buffer class provides a safe representation of a buffer that cannot
153 * @par Accessing Buffer Contents
155 * The contents of a buffer may be accessed using the @ref buffer_size
169 /// Construct an empty buffer.
176 /// Construct a buffer to represent a given memory range.
183 /// Construct a non-modifiable buffer from a modifiable one.
216 /// Adapts a single non-modifiable buffer so that it meets the requirements of
225 /// A random-access iterator type that may be used to read elements.
234 /// Construct to represent a single non-modifiable buffer.
240 /// Get a random-access iterator to the first element.
246 /// Get a random-access iterator for one past the last element.
254 /// concepts to represent a null buffer sequence.
261 /// A random-access iterator type that may be used to read elements.
264 /// Get a random-access iterator to the first element.
270 /// Get a random-access iterator for one past the last element.
283 * bytes in a buffer or buffer sequence.
287 /// Get the number of bytes in a modifiable buffer.
293 /// Get the number of bytes in a modifiable buffer.
299 /// Get the number of bytes in a non-modifiable buffer.
305 /// Get the number of bytes in a non-modifiable buffer.
311 /// Get the total number of bytes in a buffer sequence.
334 * the underlying memory region associated with a buffer.
338 * To access the memory of a non-modifiable buffer, use:
343 * To access the memory of a modifiable buffer, use:
353 /// Cast a non-modifiable buffer to a specified pointer to POD type.
360 /// Cast a non-modifiable buffer to a specified pointer to POD type.
369 /// Create a new modifiable buffer that is offset from the start of another.
378 std::size_t new_size = buffer_size(b) - start; in operator +()
383 /// Create a new modifiable buffer that is offset from the start of another.
392 std::size_t new_size = buffer_size(b) - start; in operator +()
397 /// Create a new non-modifiable buffer that is offset from the start of another.
406 std::size_t new_size = buffer_size(b) - start; in operator +()
411 /// Create a new non-modifiable buffer that is offset from the start of another.
420 std::size_t new_size = buffer_size(b) - start; in operator +()
426 /** @defgroup buffer asio::buffer
428 * @brief The asio::buffer function is used to create a buffer object to
432 * A buffer object represents a contiguous region of memory as a 2-tuple
436 * (non-modifiable) region of memory. These two forms correspond to the classes
441 * The simplest use case involves reading or writing a single buffer of a
444 * @code sock.send(asio::buffer(data, size)); @endcode
446 * In the above example, the return value of asio::buffer meets the
448 * passed to the socket's write function. A buffer created for modifiable
451 * An individual buffer may be created from a builtin array, std::vector,
452 * std::array or boost::array of POD elements. This helps prevent buffer
453 * overruns by automatically determining the size of the buffer:
456 * size_t bytes_transferred = sock.receive(asio::buffer(d1));
459 * bytes_transferred = sock.receive(asio::buffer(d2));
462 * bytes_transferred = sock.receive(asio::buffer(d3));
465 * bytes_transferred = sock.receive(asio::buffer(d4)); @endcode
469 * a buffer. The buffer size is determined using the vector's <tt>size()</tt>
472 * @par Accessing Buffer Contents
474 * The contents of a buffer may be accessed using the @ref buffer_size and
488 * For convenience, the @ref buffer_size function also works on buffer
493 * @par Buffer Copying
496 * individual buffers and buffer sequences.
504 * asio::buffer_copy(asio::buffer(data), buffers); @endcode
509 * @par Buffer Invalidation
511 * A buffer object does not have any ownership of the memory it refers to. It
514 * is no longer available, the buffer is said to have been invalidated.
516 * For the asio::buffer overloads that accept an argument of type
517 * std::vector, the buffer objects returned are invalidated by any vector
521 * For the asio::buffer overloads that accept an argument of type
522 * std::basic_string, the buffer objects returned are invalidated according to
526 * @par Buffer Arithmetic
528 * Buffer objects may be manipulated using simple arithmetic in a safe way
529 * which helps prevent buffer overruns. Consider an array initialised as
534 * A buffer object @c b1 created using:
536 * @code b1 = asio::buffer(a); @endcode
539 * optional second argument to the asio::buffer function may be used to
540 * limit the size, in bytes, of the buffer:
542 * @code b2 = asio::buffer(a, 3); @endcode
545 * size argument exceeds the actual size of the array, the size of the buffer
548 * An offset may be applied to an existing buffer to create a new one:
553 * exceeds the size of the existing buffer, the newly created buffer will be
556 * Both an offset and size may be specified to create a buffer that corresponds
557 * to a specific range of bytes within an existing buffer:
559 * @code b4 = asio::buffer(b1 + 1, 3); @endcode
563 * @par Buffers and Scatter-Gather I/O
565 * To read or write using multiple buffers (i.e. scatter-gather I/O), multiple
566 * buffer objects may be assigned into a container that supports the
575 * asio::buffer(d1),
576 * asio::buffer(d2),
577 * asio::buffer(d3) };
581 * bufs2.push_back(asio::buffer(d1));
582 * bufs2.push_back(asio::buffer(d2));
583 * bufs2.push_back(asio::buffer(d3));
588 /// Create a new modifiable buffer from an existing buffer.
592 inline mutable_buffers_1 buffer(const mutable_buffer& b) in buffer() function
597 /// Create a new modifiable buffer from an existing buffer.
604 inline mutable_buffers_1 buffer(const mutable_buffer& b, in buffer() function
614 /// Create a new non-modifiable buffer from an existing buffer.
618 inline const_buffers_1 buffer(const const_buffer& b) in buffer() function
623 /// Create a new non-modifiable buffer from an existing buffer.
630 inline const_buffers_1 buffer(const const_buffer& b, in buffer() function
640 /// Create a new modifiable buffer that represents the given memory range.
644 inline mutable_buffers_1 buffer(void* data, std::size_t size_in_bytes) in buffer() function
649 /// Create a new non-modifiable buffer that represents the given memory range.
653 inline const_buffers_1 buffer(const void* data, in buffer() function
659 /// Create a new modifiable buffer that represents the given POD array.
667 inline mutable_buffers_1 buffer(PodType (&data)[N]) in buffer() function
672 /// Create a new modifiable buffer that represents the given POD array.
680 inline mutable_buffers_1 buffer(PodType (&data)[N], in buffer() function
689 /// Create a new non-modifiable buffer that represents the given POD array.
697 inline const_buffers_1 buffer(const PodType (&data)[N]) in buffer() function
702 /// Create a new non-modifiable buffer that represents the given POD array.
710 inline const_buffers_1 buffer(const PodType (&data)[N], in buffer() function
723 // unspecified buffer(boost::array<PodType, N>& array ...);
727 // unspecified buffer(boost::array<const PodType, N>& array ...);
730 // class that contains typedefs for the appropriate buffer and container
731 // classes, based on whether PodType is const or non-const.
762 buffer(boost::array<PodType, N>& data) in buffer() function
774 buffer(boost::array<PodType, N>& data, std::size_t max_size_in_bytes) in buffer() function
788 /// Create a new modifiable buffer that represents the given POD array.
796 inline mutable_buffers_1 buffer(boost::array<PodType, N>& data) in buffer() function
802 /// Create a new modifiable buffer that represents the given POD array.
810 inline mutable_buffers_1 buffer(boost::array<PodType, N>& data, in buffer() function
819 /// Create a new non-modifiable buffer that represents the given POD array.
827 inline const_buffers_1 buffer(boost::array<const PodType, N>& data) in buffer() function
833 /// Create a new non-modifiable buffer that represents the given POD array.
841 inline const_buffers_1 buffer(boost::array<const PodType, N>& data, in buffer() function
852 /// Create a new non-modifiable buffer that represents the given POD array.
860 inline const_buffers_1 buffer(const boost::array<PodType, N>& data) in buffer() function
866 /// Create a new non-modifiable buffer that represents the given POD array.
874 inline const_buffers_1 buffer(const boost::array<PodType, N>& data, in buffer() function
884 /// Create a new modifiable buffer that represents the given POD array.
892 inline mutable_buffers_1 buffer(std::array<PodType, N>& data) in buffer() function
898 /// Create a new modifiable buffer that represents the given POD array.
906 inline mutable_buffers_1 buffer(std::array<PodType, N>& data, in buffer() function
915 /// Create a new non-modifiable buffer that represents the given POD array.
923 inline const_buffers_1 buffer(std::array<const PodType, N>& data) in buffer() function
929 /// Create a new non-modifiable buffer that represents the given POD array.
937 inline const_buffers_1 buffer(std::array<const PodType, N>& data, in buffer() function
946 /// Create a new non-modifiable buffer that represents the given POD array.
954 inline const_buffers_1 buffer(const std::array<PodType, N>& data) in buffer() function
960 /// Create a new non-modifiable buffer that represents the given POD array.
968 inline const_buffers_1 buffer(const std::array<PodType, N>& data, in buffer() function
978 /// Create a new modifiable buffer that represents the given POD vector.
985 * @note The buffer is invalidated by any vector operation that would also
989 inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data) in buffer() function
996 /// Create a new modifiable buffer that represents the given POD vector.
1003 * @note The buffer is invalidated by any vector operation that would also
1007 inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data, in buffer() function
1017 /// Create a new non-modifiable buffer that represents the given POD vector.
1024 * @note The buffer is invalidated by any vector operation that would also
1028 inline const_buffers_1 buffer( in buffer() function
1036 /// Create a new non-modifiable buffer that represents the given POD vector.
1043 * @note The buffer is invalidated by any vector operation that would also
1047 inline const_buffers_1 buffer( in buffer() function
1057 /// Create a new non-modifiable buffer that represents the given string.
1061 * @note The buffer is invalidated by any non-const operation called on the
1065 inline const_buffers_1 buffer( in buffer() function
1072 /// Create a new non-modifiable buffer that represents the given string.
1079 * @note The buffer is invalidated by any non-const operation called on the
1083 inline const_buffers_1 buffer( in buffer() function
1098 * @brief The asio::buffer_copy function is used to copy bytes from a
1099 * source buffer (or buffer sequence) to a target buffer (or buffer sequence).
1103 * @li A 2-argument form: @c buffer_copy(target, source)
1105 * @li A 3-argument form: @c buffer_copy(target, source, max_bytes_to_copy)
1116 * This prevents buffer overflow, regardless of the buffer sizes used in the
1124 /// Copies bytes from a source buffer to a target buffer.
1126 * @param target A modifiable buffer representing the memory region to which
1129 * @param source A non-modifiable buffer representing the memory region from
1154 /// Copies bytes from a source buffer to a target buffer.
1156 * @param target A modifiable buffer representing the memory region to which
1159 * @param source A non-modifiable buffer representing the memory region from
1179 /// Copies bytes from a source buffer to a target buffer.
1181 * @param target A modifiable buffer representing the memory region to which
1184 * @param source A modifiable buffer representing the memory region from which
1185 * the bytes will be copied. The contents of the source buffer will not be
1205 /// Copies bytes from a source buffer to a target buffer.
1207 * @param target A modifiable buffer representing the memory region to which
1210 * @param source A modifiable buffer representing the memory region from which
1211 * the bytes will be copied. The contents of the source buffer will not be
1231 /// Copies bytes from a source buffer sequence to a target buffer.
1233 * @param target A modifiable buffer representing the memory region to which
1236 * @param source A non-modifiable buffer sequence representing the memory
1237 * regions from which the bytes will be copied.
1271 /// Copies bytes from a source buffer to a target buffer.
1273 * @param target A modifiable buffer representing the memory region to which
1276 * @param source A non-modifiable buffer representing the memory region from
1296 /// Copies bytes from a source buffer to a target buffer.
1298 * @param target A modifiable buffer representing the memory region to which
1301 * @param source A non-modifiable buffer representing the memory region from
1322 /// Copies bytes from a source buffer to a target buffer.
1324 * @param target A modifiable buffer representing the memory region to which
1327 * @param source A modifiable buffer representing the memory region from which
1328 * the bytes will be copied. The contents of the source buffer will not be
1349 /// Copies bytes from a source buffer to a target buffer.
1351 * @param target A modifiable buffer representing the memory region to which
1354 * @param source A modifiable buffer representing the memory region from which
1355 * the bytes will be copied. The contents of the source buffer will not be
1376 /// Copies bytes from a source buffer sequence to a target buffer.
1378 * @param target A modifiable buffer representing the memory region to which
1381 * @param source A non-modifiable buffer sequence representing the memory
1382 * regions from which the bytes will be copied.
1402 /// Copies bytes from a source buffer to a target buffer sequence.
1404 * @param target A modifiable buffer sequence representing the memory regions to
1407 * @param source A non-modifiable buffer representing the memory region from
1442 /// Copies bytes from a source buffer to a target buffer sequence.
1444 * @param target A modifiable buffer sequence representing the memory regions to
1447 * @param source A non-modifiable buffer representing the memory region from
1468 /// Copies bytes from a source buffer to a target buffer sequence.
1470 * @param target A modifiable buffer sequence representing the memory regions to
1473 * @param source A modifiable buffer representing the memory region from which
1474 * the bytes will be copied. The contents of the source buffer will not be
1495 /// Copies bytes from a source buffer to a target buffer sequence.
1497 * @param target A modifiable buffer sequence representing the memory regions to
1500 * @param source A modifiable buffer representing the memory region from which
1501 * the bytes will be copied. The contents of the source buffer will not be
1522 /// Copies bytes from a source buffer sequence to a target buffer sequence.
1524 * @param target A modifiable buffer sequence representing the memory regions to
1527 * @param source A non-modifiable buffer sequence representing the memory
1528 * regions from which the bytes will be copied.
1586 /// Copies a limited number of bytes from a source buffer to a target buffer.
1588 * @param target A modifiable buffer representing the memory region to which
1591 * @param source A non-modifiable buffer representing the memory region from
1612 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1615 /// Copies a limited number of bytes from a source buffer to a target buffer.
1617 * @param target A modifiable buffer representing the memory region to which
1620 * @param source A non-modifiable buffer representing the memory region from
1641 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1644 /// Copies a limited number of bytes from a source buffer to a target buffer.
1646 * @param target A modifiable buffer representing the memory region to which
1649 * @param source A modifiable buffer representing the memory region from which
1650 * the bytes will be copied. The contents of the source buffer will not be
1671 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1674 /// Copies a limited number of bytes from a source buffer to a target buffer.
1676 * @param target A modifiable buffer representing the memory region to which
1679 * @param source A modifiable buffer representing the memory region from which
1680 * the bytes will be copied. The contents of the source buffer will not be
1701 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1704 /// Copies a limited number of bytes from a source buffer sequence to a target
1705 /// buffer.
1707 * @param target A modifiable buffer representing the memory region to which
1710 * @param source A non-modifiable buffer sequence representing the memory
1711 * regions from which the bytes will be copied.
1732 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1735 /// Copies a limited number of bytes from a source buffer to a target buffer.
1737 * @param target A modifiable buffer representing the memory region to which
1740 * @param source A non-modifiable buffer representing the memory region from
1761 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1764 /// Copies a limited number of bytes from a source buffer to a target buffer.
1766 * @param target A modifiable buffer representing the memory region to which
1769 * @param source A non-modifiable buffer representing the memory region from
1790 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1793 /// Copies a limited number of bytes from a source buffer to a target buffer.
1795 * @param target A modifiable buffer representing the memory region to which
1798 * @param source A modifiable buffer representing the memory region from which
1799 * the bytes will be copied. The contents of the source buffer will not be
1820 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1823 /// Copies a limited number of bytes from a source buffer to a target buffer.
1825 * @param target A modifiable buffer representing the memory region to which
1828 * @param source A modifiable buffer representing the memory region from which
1829 * the bytes will be copied. The contents of the source buffer will not be
1850 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1853 /// Copies a limited number of bytes from a source buffer sequence to a target
1854 /// buffer.
1856 * @param target A modifiable buffer representing the memory region to which
1859 * @param source A non-modifiable buffer sequence representing the memory
1860 * regions from which the bytes will be copied.
1881 return buffer_copy(buffer(target, max_bytes_to_copy), source); in buffer_copy()
1884 /// Copies a limited number of bytes from a source buffer to a target buffer
1887 * @param target A modifiable buffer sequence representing the memory regions to
1890 * @param source A non-modifiable buffer representing the memory region from
1912 return buffer_copy(target, buffer(source, max_bytes_to_copy)); in buffer_copy()
1915 /// Copies a limited number of bytes from a source buffer to a target buffer
1918 * @param target A modifiable buffer sequence representing the memory regions to
1921 * @param source A non-modifiable buffer representing the memory region from
1943 return buffer_copy(target, buffer(source, max_bytes_to_copy)); in buffer_copy()
1946 /// Copies a limited number of bytes from a source buffer to a target buffer
1949 * @param target A modifiable buffer sequence representing the memory regions to
1952 * @param source A modifiable buffer representing the memory region from which
1953 * the bytes will be copied. The contents of the source buffer will not be
1975 return buffer_copy(target, buffer(source, max_bytes_to_copy)); in buffer_copy()
1978 /// Copies a limited number of bytes from a source buffer to a target buffer
1981 * @param target A modifiable buffer sequence representing the memory regions to
1984 * @param source A modifiable buffer representing the memory region from which
1985 * the bytes will be copied. The contents of the source buffer will not be
2007 return buffer_copy(target, buffer(source, max_bytes_to_copy)); in buffer_copy()
2010 /// Copies a limited number of bytes from a source buffer sequence to a target
2011 /// buffer sequence.
2013 * @param target A modifiable buffer sequence representing the memory regions to
2016 * @param source A non-modifiable buffer sequence representing the memory
2017 * regions from which the bytes will be copied.
2058 source_buffer, max_bytes_to_copy - total_bytes_copied); in buffer_copy()