7 #ifndef PARSER_LINE_HPP_ 8 #define PARSER_LINE_HPP_ 12 #include "boost/assert.hpp" 13 #include "boost/foreach.hpp" 19 namespace vdj_pipe{
namespace detail{
27 typedef boost::error_info<struct errinfo_line_n_, int> line_t;
30 int line_num()
const {
return line_;}
31 bool has_next()
const {
return fis_.good();}
35 : fis_(fi), str_(), line_(1)
37 if( ! fis_.good() ) BOOST_THROW_EXCEPTION(
39 << Err::msg_t(
"error reading")
40 << Err::str1_t(sanitize(fi.path()))
45 : fis_(is, compr), str_(), line_(1)
47 if( ! fis_.good() ) BOOST_THROW_EXCEPTION(
49 << Err::msg_t(
"error reading")
54 fis_.istream().ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
60 while(fis_.istream() && fis_.istream().peek() != tag) skip_line();
63 const boost::string_ref get_id(
const char tag) {
66 for(; n != str_.length() && str_[n] !=
' ' && str_[n] !=
'\t'; ++n){}
67 return boost::string_ref(str_.data(), n);
70 void set_meta(
Seq_meta& sm,
const char tag) {
73 for(; n != str_.size() && str_[n] !=
' ' && str_[n] !=
'\t'; ++n){}
74 sm.
id_ = str_.substr(0, n);
75 for(; n != str_.size() && (str_[n] ==
' ' || str_[n] ==
'\t'); ++n){}
76 sm.
comm_ = str_.substr(n);
79 const boost::string_ref get_defstr(
const char tag) {
80 if( ! fis_.istream() || fis_.istream().peek() != tag ) BOOST_THROW_EXCEPTION(
82 << Err::msg_t(
"parsing error")
86 getline(fis_.istream(), str_);
91 std::string get_sequence(
const char tag) {
93 while( fis_.istream().peek() != tag && getline(fis_.istream(), str_) ) {
95 BOOST_FOREACH(
const char c, str_) {
96 if( std::isalpha(c) ) seq.push_back(c);
108 if( ! fis_.good() ) BOOST_THROW_EXCEPTION(
110 << Err::msg_t(
"error reading")
Definition: file_stream.hpp:82
void seek_line(const char tag)
Definition: parser_line.hpp:59
Compression
File compression types.
Definition: file_properties.hpp:19
Definition: parser_line.hpp:26
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: exception.hpp:23
Basic line-based parser; use to derive other parsers.
Definition: parser_line.hpp:23