Coverage Report

Created: 2025-06-13 06:46

/src/Fast-DDS/thirdparty/taocpp-pegtl/pegtl/internal/action_input.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2016-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_ACTION_INPUT_HPP
5
#define TAO_PEGTL_INTERNAL_ACTION_INPUT_HPP
6
7
#include <cstddef>
8
#include <cstdint>
9
#include <string>
10
11
#include "iterator.hpp"
12
13
#include "../config.hpp"
14
#include "../position.hpp"
15
16
namespace tao
17
{
18
   namespace TAO_PEGTL_NAMESPACE
19
   {
20
      namespace internal
21
      {
22
         inline const char* begin_c_ptr( const char* p ) noexcept
23
0
         {
24
0
            return p;
25
0
         }
26
27
         inline const char* begin_c_ptr( const iterator& it ) noexcept
28
0
         {
29
0
            return it.data;
30
0
         }
31
32
         template< typename Input >
33
         class action_input
34
         {
35
         public:
36
            using input_t = Input;
37
            using iterator_t = typename Input::iterator_t;
38
39
            action_input( const iterator_t& in_begin, const Input& in_input ) noexcept
40
0
               : m_begin( in_begin ),
41
0
                 m_input( in_input )
42
0
            {
43
0
            }
44
45
            action_input( const action_input& ) = delete;
46
            action_input( action_input&& ) = delete;
47
48
            ~action_input() = default;
49
50
            action_input& operator=( const action_input& ) = delete;
51
            action_input& operator=( action_input&& ) = delete;
52
53
            const iterator_t& iterator() const noexcept
54
0
            {
55
0
               return m_begin;
56
0
            }
57
58
            const Input& input() const noexcept
59
0
            {
60
0
               return m_input;
61
0
            }
62
63
            const char* begin() const noexcept
64
0
            {
65
0
               return begin_c_ptr( iterator() );
66
0
            }
67
68
            const char* end() const noexcept
69
0
            {
70
0
               return input().current();
71
0
            }
72
73
            bool empty() const noexcept
74
            {
75
               return begin() == end();
76
            }
77
78
            std::size_t size() const noexcept
79
            {
80
               return std::size_t( end() - begin() );
81
            }
82
83
            std::string string() const
84
0
            {
85
0
               return std::string( begin(), end() );
86
0
            }
87
88
            char peek_char( const std::size_t offset = 0 ) const noexcept
89
            {
90
               return begin()[ offset ];
91
            }
92
93
            std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept
94
            {
95
               return static_cast< std::uint8_t >( peek_char( offset ) );
96
            }
97
98
            // Compatibility, remove with 3.0.0
99
            std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept
100
            {
101
               return static_cast< std::uint8_t >( peek_char( offset ) );
102
            }
103
104
            TAO_PEGTL_NAMESPACE::position position() const
105
            {
106
               return input().position( iterator() );  // NOTE: Not efficient with lazy inputs.
107
            }
108
109
         protected:
110
            const iterator_t m_begin;
111
            const Input& m_input;
112
         };
113
114
      }  // namespace internal
115
116
   }  // namespace TAO_PEGTL_NAMESPACE
117
118
}  // namespace tao
119
120
#endif