99#include < memory>
1010
1111#include " config.hpp"
12- #include " count_data.hpp"
1312#include " eol.hpp"
13+ #include " memory_input.hpp"
14+ #include " position.hpp"
15+ #include " tracking_mode.hpp"
16+
1417#include " internal/action_input.hpp"
1518#include " internal/bump_impl.hpp"
16- #include " internal/input_mark .hpp"
17- #include " position_info .hpp"
19+ #include " internal/iterator .hpp"
20+ #include " internal/marker .hpp"
1821
1922namespace tao
2023{
2124 namespace TAOCPP_JSON_PEGTL_NAMESPACE
2225 {
23- template < typename Eol >
24- class basic_memory_input ;
25-
26- template < typename Eol, typename Reader >
27- class basic_buffer_input
26+ template < typename Reader, typename Eol = lf_crlf_eol >
27+ class buffer_input
2828 {
2929 public:
30- using eol_t = Eol;
3130 using reader_t = Reader;
32- using action_t = internal::basic_action_input< Eol >;
33- using memory_t = basic_memory_input< Eol >;
31+ using eol_t = Eol;
32+
33+ using memory_t = memory_input< Eol >;
34+ using action_t = internal::action_input< Eol, tracking_mode::IMMEDIATE >;
3435
3536 template < typename ... As >
36- basic_buffer_input ( const char * in_source, const std::size_t maximum, As&&... as )
37+ buffer_input ( const char * in_source, const std::size_t maximum, As&&... as )
3738 : m_reader( std::forward< As >( as )... ),
3839 m_maximum ( maximum ),
3940 m_buffer( new char [ maximum ] ),
@@ -43,8 +44,14 @@ namespace tao
4344 {
4445 }
4546
46- basic_buffer_input ( const basic_buffer_input& ) = delete;
47- void operator =( const basic_buffer_input& ) = delete ;
47+ template < typename ... As >
48+ buffer_input ( const std::string& in_source, As&&... as )
49+ : buffer_input( in_source.c_str(), std::forward< As >( as )... )
50+ {
51+ }
52+
53+ buffer_input ( const buffer_input& ) = delete;
54+ void operator =( const buffer_input& ) = delete ;
4855
4956 bool empty ()
5057 {
@@ -58,7 +65,7 @@ namespace tao
5865 return std::size_t ( m_end - m_data.data );
5966 }
6067
61- const char * begin () const
68+ const char * begin () const noexcept
6269 {
6370 return m_data.data ;
6471 }
@@ -69,52 +76,52 @@ namespace tao
6976 return m_end;
7077 }
7178
72- std::size_t byte () const
79+ std::size_t byte () const noexcept
7380 {
7481 return m_data.byte ;
7582 }
7683
77- std::size_t line () const
84+ std::size_t line () const noexcept
7885 {
7986 return m_data.line ;
8087 }
8188
82- std::size_t byte_in_line () const
89+ std::size_t byte_in_line () const noexcept
8390 {
8491 return m_data.byte_in_line ;
8592 }
8693
87- const char * source () const
94+ const char * source () const noexcept
8895 {
8996 return m_source;
9097 }
9198
92- char peek_char ( const std::size_t offset = 0 ) const
99+ char peek_char ( const std::size_t offset = 0 ) const noexcept
93100 {
94101 return m_data.data [ offset ];
95102 }
96103
97- unsigned char peek_byte ( const std::size_t offset = 0 ) const
104+ unsigned char peek_byte ( const std::size_t offset = 0 ) const noexcept
98105 {
99106 return static_cast < unsigned char >( peek_char ( offset ) );
100107 }
101108
102- void bump ( const std::size_t in_count = 1 )
109+ void bump ( const std::size_t in_count = 1 ) noexcept
103110 {
104111 internal::bump ( m_data, in_count, Eol::ch );
105112 }
106113
107- void bump_in_this_line ( const std::size_t in_count = 1 )
114+ void bump_in_this_line ( const std::size_t in_count = 1 ) noexcept
108115 {
109116 internal::bump_in_this_line ( m_data, in_count );
110117 }
111118
112- void bump_to_next_line ( const std::size_t in_count = 1 )
119+ void bump_to_next_line ( const std::size_t in_count = 1 ) noexcept
113120 {
114121 internal::bump_to_next_line ( m_data, in_count );
115122 }
116123
117- void discard ()
124+ void discard () noexcept
118125 {
119126 const auto s = m_end - m_data.data ;
120127 std::memmove ( m_buffer.get (), m_data.data , s );
@@ -137,17 +144,17 @@ namespace tao
137144 }
138145
139146 template < rewind_mode M >
140- internal::input_mark< M > mark ()
147+ internal::marker< internal::iterator, M > mark () noexcept
141148 {
142- return internal::input_mark< M >( m_data );
149+ return internal::marker< internal::iterator, M >( m_data );
143150 }
144151
145- position_info position () const
152+ TAOCPP_JSON_PEGTL_NAMESPACE::position position () const noexcept
146153 {
147- return position_info ( m_data, m_source );
154+ return TAOCPP_JSON_PEGTL_NAMESPACE::position ( m_data, m_source );
148155 }
149156
150- const count_data& count () const
157+ const internal::iterator& iterator () const noexcept
151158 {
152159 return m_data;
153160 }
@@ -156,14 +163,11 @@ namespace tao
156163 Reader m_reader;
157164 std::size_t m_maximum;
158165 std::unique_ptr< char [] > m_buffer;
159- count_data m_data;
166+ internal::iterator m_data;
160167 const char * m_end;
161- const char * m_source;
168+ const char * const m_source;
162169 };
163170
164- template < typename Reader >
165- using buffer_input = basic_buffer_input< lf_crlf_eol, Reader >;
166-
167171 } // namespace TAOCPP_JSON_PEGTL_NAMESPACE
168172
169173} // namespace tao
0 commit comments