21 #include <boost/tokenizer.hpp>
61 typedef boost::escaped_list_separator<char> Separator;
62 typedef boost::tokenizer<Separator> BT;
67 DECLARE_EXCEPTION( ExcMissingToken, <<
"Missing token, file: " << EI_File::qval <<
", line: " << EI_Line::qval <<
", position: " << EI_Pos::qval <<
".\n" );
68 DECLARE_EXCEPTION( ExcCannotRead, <<
"Can not read from stream, file: " << EI_File::qval <<
", line: " << EI_Line::qval <<
".\n" );
80 std::streampos file_position_;
81 unsigned int line_counter_;
82 unsigned int line_position_;
86 file_position_(0), line_counter_(0), line_position_(0) {}
89 Position(std::streampos file_pos,
unsigned int line,
unsigned int line_pos):
90 file_position_(file_pos), line_counter_(line), line_position_(line_pos) {}
101 Tokenizer(
const FilePath &fp, Separator separator = Separator(
"\\",
" \t",
"\"") );
112 Tokenizer( std::istream &in, Separator separator = Separator(
"\\",
" \t",
"\"") );
119 void set_comment_pattern(
const std::string &pattern);
131 bool skip_to(
const std::string &pattern,
const std::string &end_search_pattern=
"");
144 bool next_line(
bool assert_for_remaining_tokens=
true);
154 inline BT::iterator & operator ++() {
155 if (! eol()) {position_.line_position_++; ++tok_;}
157 while (! eol() && (*tok_).size()==0 ) {position_.line_position_++; ++tok_;}
164 inline bool eol()
const
165 {
return tok_ == line_tokenizer_.end(); }
170 inline bool eof()
const
171 {
return in_->eof(); }
176 inline unsigned int pos()
const
177 {
return position_.line_position_;}
183 inline unsigned int line_num()
const
184 {
return position_.line_counter_;}
189 inline const std::string &f_name()
const
195 std::string position_msg()
const;
200 inline const std::string &line()
const
206 const Tokenizer::Position get_position();
214 void set_position(
const Tokenizer::Position pos);
223 void set_tokenizer();
231 std::ifstream *own_stream_;
237 std::string comment_pattern_;
245 Separator separator_;
Dedicated class for storing path to input and output files.
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
#define TYPEDEF_ERR_INFO(EI_Type, Type)
Macro to simplify declaration of error_info types.
UnitSI operator*(const UnitSI &a, const UnitSI &b)
Product of two units.