LCOV - code coverage report
Current view: top level - url/impl - static_url.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 22 22
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 4 4

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

Generated by: LCOV version 2.3