100.00% Lines (20/20)
100.00% Functions (4/4)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/boostorg/url | 8 | // Official repository: https://github.com/boostorg/url | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_URL_IMPL_URL_VIEW_HPP | 11 | #ifndef BOOST_URL_IMPL_URL_VIEW_HPP | |||||
| 12 | #define BOOST_URL_IMPL_URL_VIEW_HPP | 12 | #define BOOST_URL_IMPL_URL_VIEW_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/parse.hpp> | 14 | #include <boost/url/parse.hpp> | |||||
| 15 | #include <boost/url/detail/over_allocator.hpp> | 15 | #include <boost/url/detail/over_allocator.hpp> | |||||
| 16 | #include <cstring> | 16 | #include <cstring> | |||||
| 17 | #include <memory> | 17 | #include <memory> | |||||
| 18 | 18 | |||||||
| 19 | namespace boost { | 19 | namespace boost { | |||||
| 20 | namespace urls { | 20 | namespace urls { | |||||
| 21 | 21 | |||||||
| 22 | //------------------------------------------------ | 22 | //------------------------------------------------ | |||||
| 23 | // | 23 | // | |||||
| 24 | // url_view | 24 | // url_view | |||||
| 25 | // | 25 | // | |||||
| 26 | //------------------------------------------------ | 26 | //------------------------------------------------ | |||||
| 27 | 27 | |||||||
| 28 | inline | 28 | inline | |||||
| HITCBC | 29 | 388 | url_view:: | 29 | 388 | url_view:: | ||
| HITCBC | 30 | 388 | url_view(core::string_view s) | 30 | 388 | url_view(core::string_view s) | ||
| HITCBC | 31 | 388 | : url_view(parse_uri_reference(s | 31 | 388 | : url_view(parse_uri_reference(s | ||
| HITCBC | 32 | 388 | ).value(BOOST_URL_POS)) | 32 | 388 | ).value(BOOST_URL_POS)) | ||
| 33 | { | 33 | { | |||||
| HITCBC | 34 | 387 | } | 34 | 387 | } | ||
| 35 | 35 | |||||||
| 36 | //------------------------------------------------ | 36 | //------------------------------------------------ | |||||
| 37 | // | 37 | // | |||||
| 38 | // url_view_base::persist | 38 | // url_view_base::persist | |||||
| 39 | // | 39 | // | |||||
| 40 | //------------------------------------------------ | 40 | //------------------------------------------------ | |||||
| 41 | 41 | |||||||
| 42 | struct url_view_base::shared_impl | 42 | struct url_view_base::shared_impl | |||||
| 43 | : url_view | 43 | : url_view | |||||
| 44 | { | 44 | { | |||||
| 45 | virtual | 45 | virtual | |||||
| HITCBC | 46 | 4 | ~shared_impl() | 46 | 4 | ~shared_impl() | ||
| HITCBC | 47 | 4 | { | 47 | 4 | { | ||
| HITCBC | 48 | 4 | } | 48 | 4 | } | ||
| 49 | 49 | |||||||
| HITCBC | 50 | 4 | shared_impl( | 50 | 4 | shared_impl( | ||
| 51 | url_view const& u) noexcept | 51 | url_view const& u) noexcept | |||||
| HITCBC | 52 | 4 | : url_view(u) | 52 | 4 | : url_view(u) | ||
| 53 | { | 53 | { | |||||
| HITCBC | 54 | 4 | impl_.cs_ = reinterpret_cast< | 54 | 4 | impl_.cs_ = reinterpret_cast< | ||
| 55 | char const*>(this + 1); | 55 | char const*>(this + 1); | |||||
| HITCBC | 56 | 4 | } | 56 | 4 | } | ||
| 57 | }; | 57 | }; | |||||
| 58 | 58 | |||||||
| 59 | inline | 59 | inline | |||||
| 60 | std::shared_ptr<url_view const> | 60 | std::shared_ptr<url_view const> | |||||
| HITCBC | 61 | 4 | url_view_base:: | 61 | 4 | url_view_base:: | ||
| 62 | persist() const | 62 | persist() const | |||||
| 63 | { | 63 | { | |||||
| 64 | using T = shared_impl; | 64 | using T = shared_impl; | |||||
| 65 | using Alloc = std::allocator<char>; | 65 | using Alloc = std::allocator<char>; | |||||
| 66 | Alloc a; | 66 | Alloc a; | |||||
| 67 | auto p = std::allocate_shared<T>( | 67 | auto p = std::allocate_shared<T>( | |||||
| HITCBC | 68 | 8 | detail::over_allocator<T, Alloc>( | 68 | 8 | detail::over_allocator<T, Alloc>( | ||
| HITCBC | 69 | 8 | size(), a), url_view(impl())); | 69 | 8 | size(), a), url_view(impl())); | ||
| HITCBC | 70 | 4 | if(size()) | 70 | 4 | if(size()) | ||
| HITCBC | 71 | 3 | std::memcpy( | 71 | 3 | std::memcpy( | ||
| 72 | reinterpret_cast<char*>( | 72 | reinterpret_cast<char*>( | |||||
| HITCBC | 73 | 3 | p.get() + 1), data(), size()); | 73 | 3 | p.get() + 1), data(), size()); | ||
| HITCBC | 74 | 8 | return p; | 74 | 8 | return p; | ||
| HITCBC | 75 | 4 | } | 75 | 4 | } | ||
| 76 | 76 | |||||||
| 77 | } // urls | 77 | } // urls | |||||
| 78 | } // boost | 78 | } // boost | |||||
| 79 | 79 | |||||||
| 80 | #endif | 80 | #endif | |||||