Line data Source code
1 : //
2 : // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
3 : //
4 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 : //
7 : // Official repository: https://github.com/cppalliance/buffers
8 : //
9 :
10 : #include <boost/buffers/any_source.hpp>
11 :
12 : namespace boost {
13 : namespace buffers {
14 :
15 7 : any_source::
16 : any_impl::
17 : ~any_impl() = default;
18 :
19 : bool
20 5 : any_source::
21 : any_impl::
22 : has_size() const noexcept
23 : {
24 5 : return false;
25 : }
26 :
27 : bool
28 6 : any_source::
29 : any_impl::
30 : has_buffers() const noexcept
31 : {
32 6 : return false;
33 : }
34 :
35 : std::size_t
36 5 : any_source::
37 : any_impl::
38 : size() const
39 : {
40 5 : detail::throw_invalid_argument();
41 : }
42 :
43 : any_const_buffers
44 6 : any_source::
45 : any_impl::
46 : data() const
47 : {
48 6 : detail::throw_invalid_argument();
49 : }
50 :
51 : //-----------------------------------------------
52 :
53 1 : any_source::
54 1 : any_source() noexcept
55 : {
56 : struct model : any_impl
57 : {
58 1 : bool has_size() const noexcept override
59 : {
60 1 : return true;
61 : }
62 :
63 1 : bool has_buffers() const noexcept override
64 : {
65 1 : return true;
66 : }
67 :
68 1 : std::size_t size() const override
69 : {
70 1 : return 0;
71 : }
72 :
73 1 : any_const_buffers data() const override
74 : {
75 1 : return {};
76 : }
77 :
78 17 : void rewind() override
79 : {
80 17 : }
81 :
82 16 : std::size_t read(
83 : void*,
84 : std::size_t,
85 : system::error_code& ec) override
86 : {
87 16 : ec = error::eof;
88 16 : return 0;
89 : }
90 : };
91 :
92 1 : static model instance;
93 1 : sp_ = { &instance, [](any_impl*) {} };
94 1 : }
95 :
96 : } // buffers
97 : } // boost
|