File indexing completed on 2025-01-18 09:29:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_REGISTERED_BUFFER_HPP
0012 #define BOOST_ASIO_REGISTERED_BUFFER_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/buffer.hpp>
0020
0021 #include <boost/asio/detail/push_options.hpp>
0022
0023 namespace boost {
0024 namespace asio {
0025 namespace detail {
0026
0027 class buffer_registration_base;
0028
0029 }
0030
0031 class const_registered_buffer;
0032
0033
0034 class registered_buffer_id
0035 {
0036 public:
0037
0038 typedef int native_handle_type;
0039
0040
0041 registered_buffer_id() noexcept
0042 : scope_(0),
0043 index_(-1)
0044 {
0045 }
0046
0047
0048 native_handle_type native_handle() const noexcept
0049 {
0050 return index_;
0051 }
0052
0053
0054 friend bool operator==(const registered_buffer_id& lhs,
0055 const registered_buffer_id& rhs) noexcept
0056 {
0057 return lhs.scope_ == rhs.scope_ && lhs.index_ == rhs.index_;
0058 }
0059
0060
0061 friend bool operator!=(const registered_buffer_id& lhs,
0062 const registered_buffer_id& rhs) noexcept
0063 {
0064 return lhs.scope_ != rhs.scope_ || lhs.index_ != rhs.index_;
0065 }
0066
0067 private:
0068 friend class detail::buffer_registration_base;
0069
0070
0071 registered_buffer_id(const void* scope, int index) noexcept
0072 : scope_(scope),
0073 index_(index)
0074 {
0075 }
0076
0077 const void* scope_;
0078 int index_;
0079 };
0080
0081
0082
0083
0084
0085 class mutable_registered_buffer
0086 {
0087 public:
0088
0089 mutable_registered_buffer() noexcept
0090 : buffer_(),
0091 id_()
0092 {
0093 }
0094
0095
0096 const mutable_buffer& buffer() const noexcept
0097 {
0098 return buffer_;
0099 }
0100
0101
0102
0103
0104
0105 void* data() const noexcept
0106 {
0107 return buffer_.data();
0108 }
0109
0110
0111
0112
0113
0114 std::size_t size() const noexcept
0115 {
0116 return buffer_.size();
0117 }
0118
0119
0120 const registered_buffer_id& id() const noexcept
0121 {
0122 return id_;
0123 }
0124
0125
0126 mutable_registered_buffer& operator+=(std::size_t n) noexcept
0127 {
0128 buffer_ += n;
0129 return *this;
0130 }
0131
0132 private:
0133 friend class detail::buffer_registration_base;
0134
0135
0136 mutable_registered_buffer(const mutable_buffer& b,
0137 const registered_buffer_id& i) noexcept
0138 : buffer_(b),
0139 id_(i)
0140 {
0141 }
0142
0143 #if !defined(GENERATING_DOCUMENTATION)
0144 friend mutable_registered_buffer buffer(
0145 const mutable_registered_buffer& b, std::size_t n) noexcept;
0146 #endif
0147
0148 mutable_buffer buffer_;
0149 registered_buffer_id id_;
0150 };
0151
0152
0153
0154
0155
0156 class const_registered_buffer
0157 {
0158 public:
0159
0160 const_registered_buffer() noexcept
0161 : buffer_(),
0162 id_()
0163 {
0164 }
0165
0166
0167 const_registered_buffer(
0168 const mutable_registered_buffer& b) noexcept
0169 : buffer_(b.buffer()),
0170 id_(b.id())
0171 {
0172 }
0173
0174
0175 const const_buffer& buffer() const noexcept
0176 {
0177 return buffer_;
0178 }
0179
0180
0181
0182
0183
0184 const void* data() const noexcept
0185 {
0186 return buffer_.data();
0187 }
0188
0189
0190
0191
0192
0193 std::size_t size() const noexcept
0194 {
0195 return buffer_.size();
0196 }
0197
0198
0199 const registered_buffer_id& id() const noexcept
0200 {
0201 return id_;
0202 }
0203
0204
0205 const_registered_buffer& operator+=(std::size_t n) noexcept
0206 {
0207 buffer_ += n;
0208 return *this;
0209 }
0210
0211 private:
0212
0213 const_registered_buffer(const const_buffer& b,
0214 const registered_buffer_id& i) noexcept
0215 : buffer_(b),
0216 id_(i)
0217 {
0218 }
0219
0220 #if !defined(GENERATING_DOCUMENTATION)
0221 friend const_registered_buffer buffer(
0222 const const_registered_buffer& b, std::size_t n) noexcept;
0223 #endif
0224
0225 const_buffer buffer_;
0226 registered_buffer_id id_;
0227 };
0228
0229
0230
0231
0232 inline const mutable_buffer* buffer_sequence_begin(
0233 const mutable_registered_buffer& b) noexcept
0234 {
0235 return &b.buffer();
0236 }
0237
0238
0239 inline const const_buffer* buffer_sequence_begin(
0240 const const_registered_buffer& b) noexcept
0241 {
0242 return &b.buffer();
0243 }
0244
0245
0246
0247
0248
0249 inline const mutable_buffer* buffer_sequence_end(
0250 const mutable_registered_buffer& b) noexcept
0251 {
0252 return &b.buffer() + 1;
0253 }
0254
0255
0256 inline const const_buffer* buffer_sequence_end(
0257 const const_registered_buffer& b) noexcept
0258 {
0259 return &b.buffer() + 1;
0260 }
0261
0262
0263
0264
0265
0266 inline mutable_registered_buffer buffer(
0267 const mutable_registered_buffer& b) noexcept
0268 {
0269 return b;
0270 }
0271
0272
0273 inline const_registered_buffer buffer(
0274 const const_registered_buffer& b) noexcept
0275 {
0276 return b;
0277 }
0278
0279
0280 inline mutable_registered_buffer buffer(
0281 const mutable_registered_buffer& b, std::size_t n) noexcept
0282 {
0283 return mutable_registered_buffer(buffer(b.buffer_, n), b.id_);
0284 }
0285
0286
0287 inline const_registered_buffer buffer(
0288 const const_registered_buffer& b, std::size_t n) noexcept
0289 {
0290 return const_registered_buffer(buffer(b.buffer_, n), b.id_);
0291 }
0292
0293
0294
0295
0296
0297
0298
0299
0300 inline mutable_registered_buffer operator+(
0301 const mutable_registered_buffer& b, std::size_t n) noexcept
0302 {
0303 mutable_registered_buffer tmp(b);
0304 tmp += n;
0305 return tmp;
0306 }
0307
0308
0309
0310
0311
0312 inline mutable_registered_buffer operator+(std::size_t n,
0313 const mutable_registered_buffer& b) noexcept
0314 {
0315 return b + n;
0316 }
0317
0318
0319
0320
0321
0322
0323 inline const_registered_buffer operator+(const const_registered_buffer& b,
0324 std::size_t n) noexcept
0325 {
0326 const_registered_buffer tmp(b);
0327 tmp += n;
0328 return tmp;
0329 }
0330
0331
0332
0333
0334
0335 inline const_registered_buffer operator+(std::size_t n,
0336 const const_registered_buffer& b) noexcept
0337 {
0338 return b + n;
0339 }
0340
0341 }
0342 }
0343
0344 #include <boost/asio/detail/pop_options.hpp>
0345
0346 #endif