Coverage Report

Created: 2025-06-13 06:46

/src/Fast-DDS/thirdparty/taocpp-pegtl/pegtl/internal/istream_reader.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_ISTREAM_READER_HPP
5
#define TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP
6
7
#include <istream>
8
9
#include "../config.hpp"
10
#include "../input_error.hpp"
11
12
namespace tao
13
{
14
   namespace TAO_PEGTL_NAMESPACE
15
   {
16
      namespace internal
17
      {
18
         struct istream_reader
19
         {
20
            explicit istream_reader( std::istream& s ) noexcept
21
               : m_istream( s )
22
0
            {
23
0
            }
24
25
            std::size_t operator()( char* buffer, const std::size_t length )
26
0
            {
27
0
               m_istream.read( buffer, std::streamsize( length ) );
28
0
29
0
               if( const auto r = m_istream.gcount() ) {
30
0
                  return std::size_t( r );
31
0
               }
32
0
               if( m_istream.eof() ) {
33
0
                  return 0;
34
0
               }
35
0
               TAO_PEGTL_THROW_INPUT_ERROR( "error in istream.read()" );
36
0
            }
37
38
            std::istream& m_istream;
39
         };
40
41
      }  // namespace internal
42
43
   }  // namespace TAO_PEGTL_NAMESPACE
44
45
}  // namespace tao
46
47
#endif