Coverage Report

Created: 2025-06-13 06:46

/src/Fast-DDS/thirdparty/taocpp-pegtl/pegtl/internal/istring.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey
2
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4
#ifndef TAO_PEGTL_INTERNAL_ISTRING_HPP
5
#define TAO_PEGTL_INTERNAL_ISTRING_HPP
6
7
#include <type_traits>
8
9
#include "../config.hpp"
10
11
#include "bump_help.hpp"
12
#include "result_on_found.hpp"
13
#include "skip_control.hpp"
14
#include "trivial.hpp"
15
16
#include "../analysis/counted.hpp"
17
18
namespace tao
19
{
20
   namespace TAO_PEGTL_NAMESPACE
21
   {
22
      namespace internal
23
      {
24
         template< char C >
25
         using is_alpha = std::integral_constant< bool, ( ( 'a' <= C ) && ( C <= 'z' ) ) || ( ( 'A' <= C ) && ( C <= 'Z' ) ) >;
26
27
         template< char C, bool A = is_alpha< C >::value >
28
         struct ichar_equal;
29
30
         template< char C >
31
         struct ichar_equal< C, true >
32
         {
33
            static bool match( const char c ) noexcept
34
            {
35
               return ( C | 0x20 ) == ( c | 0x20 );
36
            }
37
         };
38
39
         template< char C >
40
         struct ichar_equal< C, false >
41
         {
42
            static bool match( const char c ) noexcept
43
            {
44
               return c == C;
45
            }
46
         };
47
48
         template< char... Cs >
49
         struct istring_equal;
50
51
         template<>
52
         struct istring_equal<>
53
         {
54
            static bool match( const char* /*unused*/ ) noexcept
55
0
            {
56
0
               return true;
57
0
            }
58
         };
59
60
         template< char C, char... Cs >
61
         struct istring_equal< C, Cs... >
62
         {
63
            static bool match( const char* r ) noexcept
64
            {
65
               return ichar_equal< C >::match( *r ) && istring_equal< Cs... >::match( r + 1 );
66
            }
67
         };
68
69
         template< char... Cs >
70
         struct istring;
71
72
         template<>
73
         struct istring<>
74
            : trivial< true >
75
         {
76
         };
77
78
         template< char... Cs >
79
         struct istring
80
         {
81
            using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >;
82
83
            template< typename Input >
84
            static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) )
85
            {
86
               if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) {
87
                  if( istring_equal< Cs... >::match( in.current() ) ) {
88
                     bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) );
89
                     return true;
90
                  }
91
               }
92
               return false;
93
            }
94
         };
95
96
         template< char... Cs >
97
         struct skip_control< istring< Cs... > > : std::true_type
98
         {
99
         };
100
101
      }  // namespace internal
102
103
   }  // namespace TAO_PEGTL_NAMESPACE
104
105
}  // namespace tao
106
107
#endif