LCOV - code coverage report
Current view: top level - boost/http_proto/rfc/quoted_token_view.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 12 12
Test Date: 2024-07-03 18:58:30 Functions: 100.0 % 2 2

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2021 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_RFC_QUOTED_TOKEN_VIEW_HPP
      11              : #define BOOST_HTTP_PROTO_RFC_QUOTED_TOKEN_VIEW_HPP
      12              : 
      13              : #include <boost/http_proto/detail/config.hpp>
      14              : #include <boost/url/grammar/string_view_base.hpp>
      15              : #include <boost/core/detail/string_view.hpp>
      16              : 
      17              : namespace boost {
      18              : namespace http_proto {
      19              : 
      20              : class quoted_token_view
      21              :     : public grammar::string_view_base
      22              : {
      23              :     std::size_t n_ = 0;
      24              : 
      25              :     friend struct quoted_token_rule_t;
      26              : 
      27              :     // unquoted
      28              :     explicit
      29           15 :     quoted_token_view(
      30              :         core::string_view s) noexcept
      31           15 :         : string_view_base(s)
      32           15 :         , n_(s.size())
      33              :     {
      34           15 :     }
      35              : 
      36              :     // maybe quoted
      37            6 :     quoted_token_view(
      38              :         core::string_view s,
      39              :         std::size_t n) noexcept
      40            6 :         : string_view_base(s)
      41            6 :         , n_(n)
      42              :     {
      43            6 :         BOOST_ASSERT(s.size() >= 2);
      44            6 :         BOOST_ASSERT(s.front() == '\"');
      45            6 :         BOOST_ASSERT(s.back() == '\"');
      46            6 :         BOOST_ASSERT(n_ <= s_.size() - 2);
      47            6 :     }
      48              : 
      49              : public:
      50              :     quoted_token_view() = default;
      51              : 
      52              :     quoted_token_view(
      53              :         quoted_token_view const&) noexcept = default;
      54              : 
      55              :     quoted_token_view& operator=(
      56              :         quoted_token_view const&) noexcept = default;
      57              : 
      58              :     bool
      59              :     has_escapes() const noexcept
      60              :     {
      61              :         return n_ != s_.size();
      62              :     }
      63              : 
      64              :     std::size_t
      65              :     unescaped_size() const noexcept
      66              :     {
      67              :         return n_;
      68              :     }
      69              : };
      70              : 
      71              : } // http_proto
      72              : } // boost
      73              : 
      74              : #endif
        

Generated by: LCOV version 2.1