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 % 13 13
Test Date: 2025-12-23 17:59:40 Functions: 100.0 % 5 5

            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              : namespace implementation_defined {
      21              : struct quoted_token_rule_t;
      22              : } // implementation_defined
      23              : 
      24              : /** A view into a quoted string token, which may
      25              :     contain escape sequences.
      26              : 
      27              :     @see
      28              :         @ref quoted_token_view.
      29              : */
      30              : class quoted_token_view final
      31              :     : public grammar::string_view_base
      32              : {
      33              :     std::size_t n_ = 0;
      34              : 
      35              :     friend struct implementation_defined::quoted_token_rule_t;
      36              : 
      37              :     // unquoted
      38              :     explicit
      39           28 :     quoted_token_view(
      40              :         core::string_view s) noexcept
      41           28 :         : string_view_base(s)
      42           28 :         , n_(s.size())
      43              :     {
      44           28 :     }
      45              : 
      46              :     // maybe quoted
      47            9 :     quoted_token_view(
      48              :         core::string_view s,
      49              :         std::size_t n) noexcept
      50            9 :         : string_view_base(s)
      51            9 :         , n_(n)
      52              :     {
      53            9 :     }
      54              : 
      55              : public:
      56           11 :     quoted_token_view() = default;
      57              : 
      58              :     quoted_token_view(
      59              :         quoted_token_view const&) noexcept = default;
      60              : 
      61              :     quoted_token_view& operator=(
      62              :         quoted_token_view const&) noexcept = default;
      63              : 
      64              :     /** Return true if the token contains escape
      65              :         sequences.
      66              : 
      67              :         @par Complexity
      68              :         Constant.
      69              : 
      70              :         @Return true if the token contains
      71              :         escape sequences.
      72              :     */
      73              :     bool
      74            1 :     has_escapes() const noexcept
      75              :     {
      76            1 :         return n_ != s_.size();
      77              :     }
      78              : 
      79              :     /** Return the size of the unescaped content.
      80              : 
      81              :         @par Complexity
      82              :         Constant.
      83              : 
      84              :          @return Size of the unescaped string content.
      85              :     */
      86              :     std::size_t
      87            7 :     unescaped_size() const noexcept
      88              :     {
      89            7 :         return n_;
      90              :     }
      91              : };
      92              : 
      93              : } // http_proto
      94              : } // boost
      95              : 
      96              : #endif
        

Generated by: LCOV version 2.1