LCOV - code coverage report
Current view: top level - opt/homebrew/include/boost/test/utils/runtime - errors.hpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 37 0.0 %
Date: 2026-06-25 07:23:43 Functions: 0 192 0.0 %

          Line data    Source code
       1             : //  (C) Copyright Gennadiy Rozental 2001.
       2             : //  Distributed under the Boost Software License, Version 1.0.
       3             : //  (See accompanying file LICENSE_1_0.txt or copy at
       4             : //  http://www.boost.org/LICENSE_1_0.txt)
       5             : 
       6             : //  See http://www.boost.org/libs/test for the library home page.
       7             : //
       8             : //  File        : $RCSfile$
       9             : //
      10             : //  Version     : $Revision$
      11             : //
      12             : //  Description : defines runtime parameters setup error
      13             : // ***************************************************************************
      14             : 
      15             : #ifndef BOOST_TEST_UTILS_RUNTIME_INIT_ERROR_HPP
      16             : #define BOOST_TEST_UTILS_RUNTIME_INIT_ERROR_HPP
      17             : 
      18             : // Boost.Test Runtime parameters
      19             : #include <boost/test/utils/runtime/fwd.hpp>
      20             : 
      21             : // Boost.Test
      22             : #include <boost/test/utils/string_cast.hpp>
      23             : 
      24             : // Boost.Test
      25             : #include <boost/config.hpp>
      26             : 
      27             : // STL
      28             : #include <exception>
      29             : #include <vector>
      30             : 
      31             : #include <boost/test/detail/suppress_warnings.hpp>
      32             : 
      33             : namespace boost {
      34             : namespace runtime {
      35             : 
      36             : // ************************************************************************** //
      37             : // **************             runtime::param_error             ************** //
      38             : // ************************************************************************** //
      39             : 
      40           0 : class BOOST_SYMBOL_VISIBLE param_error : public std::exception {
      41             : public:
      42           0 :     BOOST_TEST_DEFAULTED_FUNCTION(~param_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE, {})
      43             : 
      44           0 :     const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
      45             :     {
      46           0 :         return msg.c_str();
      47             :     }
      48             : 
      49             :     cstring     param_name;
      50             :     std::string msg;
      51             : 
      52             : protected:
      53           0 :     explicit    param_error( cstring param_name_ ) : param_name( param_name_) {}
      54             : };
      55             : 
      56             : //____________________________________________________________________________//
      57             : 
      58             : class BOOST_SYMBOL_VISIBLE init_error : public param_error {
      59             : protected:
      60           0 :     explicit    init_error( cstring param_name ) : param_error( param_name ) {}
      61           0 :     BOOST_TEST_DEFAULTED_FUNCTION(~init_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE, {})
      62             : };
      63             : 
      64             : class BOOST_SYMBOL_VISIBLE input_error : public param_error {
      65             : protected:
      66           0 :     explicit    input_error( cstring param_name ) : param_error( param_name ) {}
      67           0 :     BOOST_TEST_DEFAULTED_FUNCTION(~input_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE, {})
      68             : };
      69             : 
      70             : //____________________________________________________________________________//
      71             : 
      72             : template<typename Derived, typename Base>
      73             : class BOOST_SYMBOL_VISIBLE specific_param_error : public Base {
      74             : protected:
      75           0 :     explicit    specific_param_error( cstring param_name ) : Base( param_name ) {}
      76           0 :     BOOST_TEST_DEFAULTED_FUNCTION(~specific_param_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE, {})
      77             : 
      78             : public:
      79             : 
      80             : //____________________________________________________________________________//
      81             : 
      82             : #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
      83             :     !defined(BOOST_NO_CXX11_REF_QUALIFIERS)
      84             : 
      85           0 :     Derived operator<<(char const* val) &&
      86             :     {
      87           0 :         this->msg.append( val );
      88             : 
      89           0 :         return static_cast<Derived&&>(*this);
      90             :     }
      91             : 
      92             :     //____________________________________________________________________________//
      93             : 
      94             :     template<typename T>
      95           0 :     Derived operator<<(T const& val) &&
      96             :     {
      97           0 :         this->msg.append( unit_test::utils::string_cast( val ) );
      98             : 
      99           0 :         return static_cast<Derived&&>(*this);
     100           0 :     }
     101             : 
     102             :     //____________________________________________________________________________//
     103             : 
     104             : #else
     105             : 
     106             :     Derived const& operator<<(char const* val) const
     107             :     {
     108             :         const_cast<specific_param_error<Derived, Base>&>(*this).msg.append( val );
     109             : 
     110             :         return static_cast<Derived const&>(*this);
     111             :     }
     112             : 
     113             :     //____________________________________________________________________________//
     114             : 
     115             :     template<typename T>
     116             :     Derived const& operator<<(T const& val) const
     117             :     {
     118             :         const_cast<specific_param_error<Derived, Base>&>(*this).msg.append( unit_test::utils::string_cast( val ) );
     119             : 
     120             :         return static_cast<Derived const&>(*this);
     121             :     }
     122             : 
     123             :     //____________________________________________________________________________//
     124             : 
     125             : #endif
     126             : 
     127             : };
     128             : 
     129             : 
     130             : 
     131             : // ************************************************************************** //
     132             : // **************           specific exception types           ************** //
     133             : // ************************************************************************** //
     134             : 
     135             : #define SPECIFIC_EX_TYPE( type, base )                  \
     136             : class BOOST_SYMBOL_VISIBLE type : public specific_param_error<type,base> {   \
     137             : public:                                                 \
     138             :     explicit type( cstring param_name = cstring() )     \
     139             :     : specific_param_error<type,base>( param_name )     \
     140             :     {}                                                  \
     141             : }                                                       \
     142             : /**/
     143             : 
     144           0 : SPECIFIC_EX_TYPE( invalid_cla_id, init_error );
     145           0 : SPECIFIC_EX_TYPE( duplicate_param, init_error );
     146           0 : SPECIFIC_EX_TYPE( conflicting_param, init_error );
     147             : SPECIFIC_EX_TYPE( unknown_param, init_error );
     148           0 : SPECIFIC_EX_TYPE( access_to_missing_argument, init_error );
     149           0 : SPECIFIC_EX_TYPE( arg_type_mismatch, init_error );
     150           0 : SPECIFIC_EX_TYPE( invalid_param_spec, init_error );
     151             : 
     152           0 : SPECIFIC_EX_TYPE( format_error, input_error );
     153           0 : SPECIFIC_EX_TYPE( duplicate_arg, input_error );
     154           0 : SPECIFIC_EX_TYPE( missing_req_arg, input_error );
     155             : 
     156             : #undef SPECIFIC_EX_TYPE
     157             : 
     158           0 : class BOOST_SYMBOL_VISIBLE ambiguous_param : public specific_param_error<ambiguous_param, input_error> {
     159             : public:
     160             : #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
     161           0 :     explicit    ambiguous_param( std::vector<cstring>&& amb_candidates )
     162           0 :     : specific_param_error<ambiguous_param,input_error>( "" )
     163           0 :     , m_amb_candidates( std::move( amb_candidates ) ) {}
     164             : #else
     165             :     explicit    ambiguous_param( std::vector<cstring> const& amb_candidates )
     166             :     : specific_param_error<ambiguous_param,input_error>( "" )
     167             :     , m_amb_candidates( amb_candidates ) {}
     168             : #endif
     169           0 :     BOOST_TEST_DEFAULTED_FUNCTION(~ambiguous_param() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE, {})
     170             : 
     171             :     std::vector<cstring> m_amb_candidates;
     172             : };
     173             : 
     174           0 : class BOOST_SYMBOL_VISIBLE unrecognized_param : public specific_param_error<unrecognized_param, input_error> {
     175             : public:
     176             : #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
     177           0 :     explicit    unrecognized_param( std::vector<cstring>&& type_candidates )
     178           0 :     : specific_param_error<unrecognized_param,input_error>( "" )
     179           0 :     , m_typo_candidates( std::move( type_candidates ) ) {}
     180             : #else
     181             :     explicit    unrecognized_param( std::vector<cstring> const& type_candidates )
     182             :     : specific_param_error<unrecognized_param,input_error>( "" )
     183             :     , m_typo_candidates( type_candidates ) {}
     184             : #endif
     185           0 :     BOOST_TEST_DEFAULTED_FUNCTION(~unrecognized_param(), BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {})
     186             : 
     187             :     std::vector<cstring> m_typo_candidates;
     188             : };
     189             : 
     190             : } // namespace runtime
     191             : } // namespace boost
     192             : 
     193             : #include <boost/test/detail/enable_warnings.hpp>
     194             : 
     195             : #endif // BOOST_TEST_UTILS_RUNTIME_INIT_ERROR_HPP

Generated by: LCOV version 1.16