File indexing completed on 2024-11-15 09:02:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
0012 #define BOOST_ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/limits.hpp>
0020
0021 #include <boost/asio/detail/push_options.hpp>
0022
0023 namespace boost {
0024 namespace asio {
0025 namespace detail {
0026
0027
0028 template <typename Buffer>
0029 class buffer_resize_guard
0030 {
0031 public:
0032
0033 buffer_resize_guard(Buffer& buffer)
0034 : buffer_(buffer),
0035 old_size_(buffer.size())
0036 {
0037 }
0038
0039
0040 ~buffer_resize_guard()
0041 {
0042 if (old_size_ != (std::numeric_limits<size_t>::max)())
0043 {
0044 buffer_.resize(old_size_);
0045 }
0046 }
0047
0048
0049 void commit()
0050 {
0051 old_size_ = (std::numeric_limits<size_t>::max)();
0052 }
0053
0054 private:
0055
0056 Buffer& buffer_;
0057
0058
0059 size_t old_size_;
0060 };
0061
0062 }
0063 }
0064 }
0065
0066 #include <boost/asio/detail/pop_options.hpp>
0067
0068 #endif