31#ifndef CFGFILE__INPUT_STREAM_HPP__INCLUDED
32#define CFGFILE__INPUT_STREAM_HPP__INCLUDED
45static const std::size_t c_buff_size = 512;
53template<
typename Trait =
string_trait_t >
57 typename Trait::istream_t &
input )
60 , m_column_number( 1 )
65 Trait::noskipws( m_stream );
67 m_stream_size = Trait::size_of_file( m_stream );
69 if( m_stream_size < 0 )
72 Trait::fill_buf( m_stream, m_buf, c_buff_size, m_stream_pos, m_stream_size );
80 typename Trait::char_t
get()
84 m_prev_positions.push( { m_column_number, m_line_number } );
88 typename Trait::char_t
ch( 0x00 );
90 if( !m_returned_char.empty() )
92 ch = m_returned_char.top();
94 m_returned_char.pop();
96 if( is_new_line(
ch ) )
105 if( m_buf_pos == c_buff_size )
107 Trait::fill_buf( m_stream, m_buf, c_buff_size, m_stream_pos, m_stream_size );
111 ch = m_buf[ m_buf_pos ];
115 if( is_new_line(
ch ) )
124 return typename Trait::char_t( 0x00 );
130 if( !m_prev_positions.empty() )
132 const auto prev = m_prev_positions.top();
133 m_prev_positions.pop();
135 m_column_number =
prev.m_column_number;
136 m_line_number =
prev.m_line_number;
138 m_returned_char.push(
ch );
145 return m_line_number;
151 return m_column_number;
157 if( m_returned_char.empty() )
158 return ( Trait::is_at_end( m_stream ) && m_buf_pos == (
size_t) m_buf.size() );
170 bool is_new_line(
typename Trait::char_t &
ch )
176 typename Trait::char_t
next_char( 0x00 );
188 m_returned_char.push( next_char );
197 typename Trait::char_t simple_get()
199 if( !m_returned_char.empty() )
201 auto ch = m_returned_char.top();
203 m_returned_char.pop();
209 typename Trait::char_t ch( 0x00 );
211 if( m_buf_pos == c_buff_size )
213 Trait::fill_buf( m_stream, m_buf, c_buff_size, m_stream_pos, m_stream_size );
217 ch = m_buf[ m_buf_pos ];
229 typename Trait::pos_t m_column_number;
230 typename Trait::pos_t m_line_number;
234 typename Trait::istream_t & m_stream;
236 typename Trait::pos_t m_line_number;
238 typename Trait::pos_t m_column_number;
240 std::stack< position_t > m_prev_positions;
242 typename Trait::string_t m_file_name;
244 std::stack< typename Trait::char_t > m_returned_char;
246 typename Trait::buf_t m_buf;
248 std::size_t m_buf_pos;
250 typename Trait::pos_t m_stream_size;
252 typename Trait::pos_t m_stream_pos;
Exception in the library.
Definition exceptions.hpp:51
#define DISABLE_COPY(Class)
Macro for disabling copy.
Definition types.hpp:580