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
18 #include "ysfx_reader.hpp"
22 //------------------------------------------------------------------------------
23 bool text_reader::read_next_line(std::string
&line
)
27 char next
= read_next_char();
31 while (next
!= '\0' && next
!= '\r' && next
!= '\n') {
33 next
= read_next_char();
37 next
= peek_next_char();
45 //------------------------------------------------------------------------------
46 char string_text_reader::read_next_char()
48 const char *ptr
= m_char_ptr
;
50 if (!ptr
|| *ptr
== '\0')
58 char string_text_reader::peek_next_char()
60 const char *ptr
= m_char_ptr
;
68 //------------------------------------------------------------------------------
69 char stdio_text_reader::read_next_char()
71 FILE *stream
= m_stream
;
76 int next
= fgetc(stream
);
80 return (unsigned char)next
;
83 char stdio_text_reader::peek_next_char()
85 FILE *stream
= m_stream
;
90 int next
= fgetc(stream
);
95 return (unsigned char)next
;