17 #ifndef ERROR_HANDLER_HPP_
18 #define ERROR_HANDLER_HPP_
29 template <
typename Iterator>
32 template <
typename,
typename,
typename>
38 template <
typename Message,
typename What>
42 Iterator err_pos)
const
45 Iterator line_start =
get_pos(err_pos, line);
48 std::cout << message << what <<
" line " << line <<
':' <<
std::endl;
50 for (; line_start != err_pos; ++line_start)
56 std::cout <<
"Unexpected end of file. ";
57 std::cout << message << what <<
" line " << line <<
std::endl;
61 Iterator
get_pos(Iterator err_pos,
int& line)
const
65 Iterator line_start =
first;
69 if (i != err_pos && *i ==
'\r')
74 if (i != err_pos && *i ==
'\n')
91 while (i !=
last && (*i !=
'\r' && *i !=
'\n'))
93 return std::string(err_pos, i);
Inform & endl(Inform &inf)
void operator()(Message const &message, What const &what, Iterator err_pos) const
std::vector< Iterator > iters
std::string get_line(Iterator err_pos) const
Iterator get_pos(Iterator err_pos, int &line) const
error_handler(Iterator first, Iterator last)