LCOV - code coverage report
Current view: top level - libs/url/src/grammar - error.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 25 25 100.0 %
Date: 2024-02-29 20:02:55 Functions: 7 7 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             : #ifndef BOOST_URL_GRAMMAR_IMPL_ERROR_IPP
      11             : #define BOOST_URL_GRAMMAR_IMPL_ERROR_IPP
      12             : 
      13             : #include <boost/url/detail/config.hpp>
      14             : #include <boost/url/grammar/error.hpp>
      15             : 
      16             : namespace boost {
      17             : namespace urls {
      18             : namespace grammar {
      19             : 
      20             : namespace detail {
      21             : 
      22             : const char*
      23          72 : error_cat_type::
      24             : name() const noexcept
      25             : {
      26          72 :     return "boost.url.grammar";
      27             : }
      28             : 
      29             : std::string
      30          72 : error_cat_type::
      31             : message(int code) const
      32             : {
      33          72 :     return message(code, nullptr, 0);
      34             : }
      35             : 
      36             : char const*
      37          72 : error_cat_type::
      38             : message(
      39             :     int code,
      40             :     char*,
      41             :     std::size_t) const noexcept
      42             : {
      43          72 :     switch(static_cast<error>(code))
      44             :     {
      45           1 :     default:
      46           1 : case error::need_more: return "need more";
      47          14 : case error::mismatch: return "mismatch";
      48          13 : case error::invalid: return "invalid";
      49           1 : case error::end_of_range: return "end of range";
      50          42 : case error::leftover: return "leftover";
      51           1 : case error::out_of_range: return "out of range";
      52             :     }
      53             : }
      54             : 
      55             : system::error_condition
      56           6 : error_cat_type::
      57             : default_error_condition(
      58             :     int ev) const noexcept
      59             : {
      60           6 :     switch(static_cast<error>(ev))
      61             :     {
      62           2 : case error::invalid:
      63             : case error::out_of_range:
      64           2 :         return condition::fatal;
      65           4 :     default:
      66           4 :         return {ev, *this};
      67             :     }
      68             : }
      69             : 
      70             : //------------------------------------------------
      71             : 
      72             : const char*
      73           5 : condition_cat_type::
      74             : name() const noexcept
      75             : {
      76           5 :     return "boost.url.grammar";
      77             : }
      78             : 
      79             : std::string
      80           5 : condition_cat_type::
      81             : message(int code) const
      82             : {
      83           5 :     return message(code, nullptr, 0);
      84             : }
      85             : 
      86             : char const*
      87           5 : condition_cat_type::
      88             : message(
      89             :     int code, char*, std::size_t) const noexcept
      90             : {
      91             :     switch(static_cast<condition>(code))
      92             :     {
      93             :     default:
      94             :     case condition::fatal:
      95           5 :         return "fatal condition";
      96             :     }
      97             : }
      98             : 
      99             : //-----------------------------------------------
     100             : 
     101             : // msvc 14.0 has a bug that warns about inability
     102             : // to use constexpr construction here, even though
     103             : // there's no constexpr construction
     104             : #if defined(_MSC_VER) && _MSC_VER <= 1900
     105             : # pragma warning( push )
     106             : # pragma warning( disable : 4592 )
     107             : #endif
     108             : 
     109             : error_cat_type error_cat;
     110             : condition_cat_type condition_cat;
     111             : 
     112             : #if defined(_MSC_VER) && _MSC_VER <= 1900
     113             : # pragma warning( pop )
     114             : #endif
     115             : 
     116             : } // detail
     117             : 
     118             : } // grammar
     119             : } // urls
     120             : } // boost
     121             : 
     122             : #endif

Generated by: LCOV version 1.15