LCOV - code coverage report
Current view: top level - libs/url/src - error.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 22 22 100.0 %
Date: 2024-03-15 19:37:08 Functions: 4 4 100.0 %

          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             : 
      11             : #include <boost/url/detail/config.hpp>
      12             : #include <boost/url/error.hpp>
      13             : #include <boost/url/grammar/error.hpp>
      14             : 
      15             : namespace boost {
      16             : namespace urls {
      17             : 
      18             : namespace detail {
      19             : 
      20             : const char*
      21          97 : error_cat_type::
      22             : name() const noexcept
      23             : {
      24          97 :     return "boost.url";
      25             : }
      26             : 
      27             : std::string
      28          98 : error_cat_type::
      29             : message(int code) const
      30             : {
      31          98 :     return message(code, nullptr, 0);
      32             : }
      33             : 
      34             : char const*
      35          98 : error_cat_type::
      36             : message(
      37             :     int code,
      38             :     char*,
      39             :     std::size_t) const noexcept
      40             : {
      41          98 :     switch(static_cast<error>(code))
      42             :     {
      43           1 : case error::success: return "success";
      44           1 : case error::illegal_null: return "illegal null";
      45           1 : case error::illegal_reserved_char: return "illegal reserved char";
      46           1 : case error::non_canonical: return "non canonical";
      47             : 
      48          19 : case error::bad_pct_hexdig: return "bad hexdig in pct-encoding";
      49          63 : case error::incomplete_encoding: return "incomplete pct-encoding";
      50           9 : case error::missing_pct_hexdig: return "missing hexdig in pct-encoding";
      51           1 : case error::no_space: return "no space";
      52           1 : case error::not_a_base: return "not a base";
      53             :     }
      54           1 :     return "";
      55             : }
      56             : 
      57             : system::error_condition
      58           9 : error_cat_type::
      59             : default_error_condition(
      60             :     int ev) const noexcept
      61             : {
      62           9 :     switch(static_cast<error>(ev))
      63             :     {
      64           6 :     default:
      65           6 :         return {ev, *this};
      66             : 
      67           3 : case error::bad_pct_hexdig:
      68             : case error::incomplete_encoding:
      69             : case error::missing_pct_hexdig:
      70           3 :         return grammar::condition::fatal;
      71             :     }
      72             : }
      73             : 
      74             : //-----------------------------------------------
      75             : 
      76             : // msvc 14.0 has a bug that warns about inability
      77             : // to use constexpr construction here, even though
      78             : // there's no constexpr construction
      79             : #if defined(_MSC_VER) && _MSC_VER <= 1900
      80             : # pragma warning( push )
      81             : # pragma warning( disable : 4592 )
      82             : #endif
      83             : 
      84             : error_cat_type error_cat;
      85             : 
      86             : #if defined(_MSC_VER) && _MSC_VER <= 1900
      87             : # pragma warning( pop )
      88             : #endif
      89             : 
      90             : } // detail
      91             : 
      92             : } // urls
      93             : } // boost
      94             : 

Generated by: LCOV version 1.15