100.00% Lines (22/22) 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   // 3   //
4   // Distributed under the Boost Software License, Version 1.0. (See accompanying 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) 5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6   // 6   //
7   // Official repository: https://github.com/boostorg/url 7   // Official repository: https://github.com/boostorg/url
8   // 8   //
9   9  
10   #ifndef BOOST_URL_IMPL_STATIC_URL_HPP 10   #ifndef BOOST_URL_IMPL_STATIC_URL_HPP
11   #define BOOST_URL_IMPL_STATIC_URL_HPP 11   #define BOOST_URL_IMPL_STATIC_URL_HPP
12   12  
13   #include <boost/url/detail/except.hpp> 13   #include <boost/url/detail/except.hpp>
14   #include <boost/assert.hpp> 14   #include <boost/assert.hpp>
15   15  
16   namespace boost { 16   namespace boost {
17   namespace urls { 17   namespace urls {
18   18  
19   inline 19   inline
HITCBC 20   39 static_url_base:: 20   39 static_url_base::
21   static_url_base( 21   static_url_base(
22   char* buf, 22   char* buf,
HITCBC 23   39 std::size_t cap) noexcept 23   39 std::size_t cap) noexcept
24   { 24   {
HITCBC 25   39 s_ = buf; 25   39 s_ = buf;
HITCBC 26   39 cap_ = cap; 26   39 cap_ = cap;
HITCBC 27   39 s_[0] = '\0'; 27   39 s_[0] = '\0';
HITCBC 28   39 impl_.cs_ = s_; 28   39 impl_.cs_ = s_;
HITCBC 29   39 } 29   39 }
30   30  
31   inline 31   inline
HITCBC 32   18 static_url_base:: 32   18 static_url_base::
33   static_url_base( 33   static_url_base(
34   char* buf, 34   char* buf,
35   std::size_t cap, 35   std::size_t cap,
HITCBC 36   18 core::string_view s) 36   18 core::string_view s)
HITCBC 37   18 : static_url_base(buf, cap) 37   18 : static_url_base(buf, cap)
38   { 38   {
HITCBC 39   37 copy(parse_uri_reference(s 39   37 copy(parse_uri_reference(s
HITCBC 40   21 ).value(BOOST_URL_POS)); 40   21 ).value(BOOST_URL_POS));
HITCBC 41   18 } 41   18 }
42   42  
43   inline 43   inline
44   void 44   void
HITCBC 45   1 static_url_base:: 45   1 static_url_base::
46   clear_impl() noexcept 46   clear_impl() noexcept
47   { 47   {
HITCBC 48   1 impl_ = {from::url}; 48   1 impl_ = {from::url};
HITCBC 49   1 s_[0] = '\0'; 49   1 s_[0] = '\0';
HITCBC 50   1 impl_.cs_ = s_; 50   1 impl_.cs_ = s_;
HITCBC 51   1 } 51   1 }
52   52  
53   inline 53   inline
54   void 54   void
HITCBC 55   55 static_url_base:: 55   55 static_url_base::
56   reserve_impl( 56   reserve_impl(
57   std::size_t n, 57   std::size_t n,
58   op_t&) 58   op_t&)
59   { 59   {
HITCBC 60   55 if(n <= cap_) 60   55 if(n <= cap_)
HITCBC 61   51 return; 61   51 return;
HITCBC 62   4 detail::throw_length_error(); 62   4 detail::throw_length_error();
63   } 63   }
64   64  
65   //---------------------------------------------------------- 65   //----------------------------------------------------------
66   66  
67   // LCOV_EXCL_START 67   // LCOV_EXCL_START
68   inline 68   inline
69   void 69   void
70   static_url_base:: 70   static_url_base::
71   cleanup(op_t&) 71   cleanup(op_t&)
72   { 72   {
73   /* 73   /*
74   * The cleanup function is a blank 74   * The cleanup function is a blank
75   * override as it's unreachable 75   * override as it's unreachable
76   * for static_url_base. 76   * for static_url_base.
77   * 77   *
78   * `u.cleanup()` is called by `op_t` when 78   * `u.cleanup()` is called by `op_t` when
79   * the `op_t::old` string is being replaced. 79   * the `op_t::old` string is being replaced.
80   * This never happens for `static_url_base` 80   * This never happens for `static_url_base`
81   * because it always uses the same buffer. 81   * because it always uses the same buffer.
82   * 82   *
83   * `url::reserve_impl` is the only function 83   * `url::reserve_impl` is the only function
84   * that sets the `op_t::old` string but 84   * that sets the `op_t::old` string but
85   * `static_url_base::reserve_impl` does 85   * `static_url_base::reserve_impl` does
86   * not touch `op_t::old`. 86   * not touch `op_t::old`.
87   */ 87   */
88   } 88   }
89   // LCOV_EXCL_STOP 89   // LCOV_EXCL_STOP
90   90  
91   } // urls 91   } // urls
92   } // boost 92   } // boost
93   93  
94   #endif 94   #endif