LCOV - code coverage report
Current view: top level - url/impl - scheme.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 52 52
Test Date: 2026-02-13 15:53:22 Functions: 100.0 % 1 1

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
       4              : //
       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)
       7              : //
       8              : // Official repository: https://github.com/boostorg/url
       9              : //
      10              : 
      11              : #ifndef BOOST_URL_IMPL_SCHEME_HPP
      12              : #define BOOST_URL_IMPL_SCHEME_HPP
      13              : 
      14              : #include <boost/url/detail/config.hpp>
      15              : 
      16              : #include <boost/url/grammar/ci_string.hpp>
      17              : 
      18              : namespace boost {
      19              : namespace urls {
      20              : 
      21              : inline BOOST_URL_CXX20_CONSTEXPR
      22              : scheme
      23         5317 : string_to_scheme(
      24              :     core::string_view s) noexcept
      25              : {
      26              :     using grammar::to_lower;
      27         5317 :     switch(s.size())
      28              :     {
      29            2 :     case 0: // none
      30            2 :         return scheme::none;
      31              : 
      32          312 :     case 2: // ws
      33          453 :         if( to_lower(s[0]) == 'w' &&
      34          141 :             to_lower(s[1]) == 's')
      35          139 :             return scheme::ws;
      36          173 :         break;
      37              : 
      38          180 :     case 3:
      39          180 :         switch(to_lower(s[0]))
      40              :         {
      41           51 :         case 'w': // wss
      42           96 :             if( to_lower(s[1]) == 's' &&
      43           45 :                 to_lower(s[2]) == 's')
      44           43 :                 return scheme::wss;
      45            8 :             break;
      46              : 
      47           78 :         case 'f': // ftp
      48          115 :             if( to_lower(s[1]) == 't' &&
      49           37 :                 to_lower(s[2]) == 'p')
      50           36 :                 return scheme::ftp;
      51           42 :             break;
      52              : 
      53           51 :         default:
      54           51 :             break;
      55              :         }
      56          101 :         break;
      57              : 
      58         2361 :     case 4:
      59         2361 :         switch(to_lower(s[0]))
      60              :         {
      61          361 :         case 'f': // file
      62          710 :             if( to_lower(s[1]) == 'i' &&
      63          710 :                 to_lower(s[2]) == 'l' &&
      64          348 :                 to_lower(s[3]) == 'e')
      65          347 :                 return scheme::file;
      66           14 :             break;
      67              : 
      68         1852 :         case 'h': // http
      69         3702 :             if( to_lower(s[1]) == 't' &&
      70         3702 :                 to_lower(s[2]) == 't' &&
      71         1849 :                 to_lower(s[3]) == 'p')
      72         1849 :                 return scheme::http;
      73            3 :             break;
      74              : 
      75          148 :         default:
      76          148 :             break;
      77              :         }
      78          165 :         break;
      79              : 
      80         1465 :     case 5: // https
      81         2023 :         if( to_lower(s[0]) == 'h' &&
      82         1115 :             to_lower(s[1]) == 't' &&
      83         1113 :             to_lower(s[2]) == 't' &&
      84         2579 :             to_lower(s[3]) == 'p' &&
      85          555 :             to_lower(s[4]) == 's')
      86          548 :             return scheme::https;
      87          917 :         break;
      88              : 
      89          997 :     default:
      90          997 :         break;
      91              :     }
      92         2353 :     return scheme::unknown;
      93              : }
      94              : 
      95              : } // urls
      96              : } // boost
      97              : 
      98              : #endif
        

Generated by: LCOV version 2.3