1 // Copyright 2021 Jean Pierre Cimalando
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // SPDX-License-Identifier: Apache-2.0
28 virtual ~text_reader() = default;
29 virtual char read_next_char() = 0;
30 virtual char peek_next_char() = 0;
31 bool read_next_line(std::string
&line
);
34 //------------------------------------------------------------------------------
35 class string_text_reader
: public text_reader
38 explicit string_text_reader(const char *text
) : m_char_ptr(text
) {}
39 char read_next_char() override
;
40 char peek_next_char() override
;
42 const char *m_char_ptr
= nullptr;
45 //------------------------------------------------------------------------------
46 class stdio_text_reader
: public text_reader
49 explicit stdio_text_reader(FILE *stream
) : m_stream(stream
) {}
50 char read_next_char() override
;
51 char peek_next_char() override
;
53 FILE *m_stream
= nullptr;