GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/impl/context.ipp
Date: 2023-12-22 17:54:30
Exec Total Coverage
Lines: 17 18 94.4%
Functions: 4 4 100.0%
Branches: 4 6 66.7%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.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/http_proto
8 //
9
10 #ifndef BOOST_HTTP_PROTO_IMPL_CONTEXT_IPP
11 #define BOOST_HTTP_PROTO_IMPL_CONTEXT_IPP
12
13 #include <boost/http_proto/context.hpp>
14 #include <boost/http_proto/detail/except.hpp>
15 //#include <boost/unordered_map.hpp> // doesn't support heterogenous lookup yet
16 #include <unordered_map>
17
18 namespace boost {
19 namespace http_proto {
20
21 struct context::data
22 {
23 // Installed services
24 std::unordered_map<
25 detail::type_index,
26 std::unique_ptr<service>,
27 detail::type_index_hasher
28 > services;
29 };
30
31 //------------------------------------------------
32
33 33 context::
34 33 ~context()
35 {
36 33 }
37
38 33 context::
39 33 context()
40 33 : p_(new data)
41 {
42 33 }
43
44 //------------------------------------------------
45
46 auto
47 824 context::
48 find_service_impl(
49 detail::type_index id) const noexcept ->
50 service*
51 {
52 824 auto it = p_->services.find(id);
53
2/2
✓ Branch 3 taken 792 times.
✓ Branch 4 taken 32 times.
824 if(it != p_->services.end())
54 792 return it->second.get();
55 32 return nullptr;
56 }
57
58 auto
59 32 context::
60 make_service_impl(
61 detail::type_index id,
62 std::unique_ptr<service> sp) ->
63 service&
64 {
65 auto const result =
66 32 p_->services.emplace(
67
1/2
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 id, std::move(sp));
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(! result.second)
69 {
70 // already exists
71 detail::throw_out_of_range();
72 }
73 64 return *result.first->second;
74 }
75
76 } // http_proto
77 } // boost
78
79 #endif
80