/usr/include/pegtl/input.hh is in pegtl-dev 1.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | // Copyright (c) 2014-2016 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/ColinH/PEGTL/
#ifndef PEGTL_INPUT_HH
#define PEGTL_INPUT_HH
#include <string>
#include <cstddef>
#include "internal/input_data.hh"
#include "internal/input_mark.hh"
namespace pegtl
{
class input
{
public:
explicit
input( const internal::input_data & data )
: m_data( data )
{ }
input( const internal::input_data & data, const internal::input_mark & mark )
: m_data( mark.m_line, mark.m_column, mark.m_begin, data.begin, data.source, data.from )
{ }
input( const std::size_t line, const std::size_t column, const char * begin, const char * end, const char * source, const input * from = nullptr )
: m_data( line, column, begin, end, source, from ? ( & from->m_data ) : nullptr )
{ }
bool empty() const
{
return m_data.begin == m_data.end;
}
std::size_t size() const
{
return m_data.end - m_data.begin;
}
const char * begin() const
{
return m_data.begin;
}
const char * end() const
{
return m_data.end;
}
std::size_t line() const
{
return m_data.line;
}
std::size_t column() const
{
return m_data.column;
}
const char * source() const
{
return m_data.source;
}
std::string string() const
{
return std::string( m_data.begin, m_data.end );
}
char peek_char( const std::size_t offset = 0 ) const
{
return m_data.begin[ offset ];
}
unsigned char peek_byte( const std::size_t offset = 0 ) const
{
return static_cast< unsigned char >( peek_char( offset ) );
}
void bump( const std::size_t count = 1 )
{
for ( std::size_t i = 0; i < count; ++i ) {
bump_unsafe();
}
}
void bump_in_line( const std::size_t count = 1 )
{
m_data.begin += count;
m_data.column += count;
}
void bump_next_line( const std::size_t count = 1 )
{
++m_data.line;
m_data.begin += count;
m_data.column = 0;
}
internal::input_mark mark()
{
return internal::input_mark( m_data );
}
const internal::input_data & data() const
{
return m_data;
}
private:
internal::input_data m_data;
void bump_unsafe()
{
switch ( * m_data.begin ) {
case '\n':
++m_data.line;
m_data.column = 0;
break;
default:
++m_data.column;
break;
}
++m_data.begin;
}
};
} // pegtl
#endif
|