Base class of parser objects. Linereader objects process one line at a time, and change their internal state according to what they find in it. Parsing a complete data file involves reading it in line-by-line and submitting each line to a parser object for the appropriate format. Upon successful parsing the parser object stores the coordinate information plus additional data that can be read out and used to construct the appropriate region object.
More...
#include "linereader.hh"
|
| Linereader (const std::string &commentchars="#") |
|
Status | parse (const std::string &line) |
|
virtual bool | read_into (Region ®ion) const =0 |
|
Status | status () const |
|
const std::string & | comment () const |
|
size_t | fieldcnt () const |
|
const std::string & | error_msg () const |
|
const std::string & | chrom () const |
|
unsigned int | first () const |
|
unsigned int | last () const |
|
char | strand () const |
|
const std::string & | name () const |
|
|
static bool | empty_white (const std::string &str) |
| Returns /true/ if /str/ is empty or contains whitespace characters only.
|
|
static unsigned int | str_to_uint (std::string &str) throw (Exception) |
|
|
Status | _status |
| the status after parsing
|
|
size_t | _fieldcnt |
| how many column fields have been seen
|
|
std::string | _comment |
| store a comment line
|
|
std::string | _err |
| stores parsing error messages
|
|
std::string | _chrom |
|
std::string | _name |
|
unsigned int | _first |
|
unsigned int | _last |
|
char | _strand |
|
Base class of parser objects. Linereader objects process one line at a time, and change their internal state according to what they find in it. Parsing a complete data file involves reading it in line-by-line and submitting each line to a parser object for the appropriate format. Upon successful parsing the parser object stores the coordinate information plus additional data that can be read out and used to construct the appropriate region object.
Symbolic constants to signify the result of a parsing operation.
Enumerator |
---|
CLEAN |
state after reset (all bits off)
|
ERROR |
could not parse line
|
EMPTY |
empty line (whitespace only) was seen
|
COMMENT |
comment line was seen
|
DATA |
data line parsed successfully
|
multovl::io::Linereader::Linereader |
( |
const std::string & |
commentchars = "#" | ) |
|
|
explicit |
Sets up a Linereader object.
- Parameters
-
commentchars | the character(s) that signify the beginning of a comment |
const std::string& multovl::io::Linereader::comment |
( |
| ) |
const |
|
inline |
- Returns
- a comment line stripped of all leading whitespace and comment characters or the empty std::string if the parsed line was not a comment
const std::string& multovl::io::Linereader::error_msg |
( |
| ) |
const |
|
inline |
- Returns
- contains parse error messages, empty std::string if the status is not ERROR.
size_t multovl::io::Linereader::fieldcnt |
( |
| ) |
const |
|
inline |
- Returns
- the number of fields seen in the parsed line. Makes sense only if the return status is DATA.
Status multovl::io::Linereader::parse |
( |
const std::string & |
line | ) |
|
Parses a line into the calling object from /line/.
- Returns
- the status of the parsing operation.
virtual void multovl::io::Linereader::parse_data |
( |
const std::string & |
line | ) |
|
|
protectedpure virtual |
virtual bool multovl::io::Linereader::read_into |
( |
Region & |
region | ) |
const |
|
pure virtual |
Updates the contents of a region with what has been parsed. Does nothing if the calling object is not in the DATA state.
Implemented in multovl::io::BedLinereader.
virtual void multovl::io::Linereader::reset |
( |
| ) |
|
|
protectedvirtual |
Prepares the calling object for parsing by resetting all fields. This method must be invoked by the parse(...) method.
Reimplemented in multovl::io::BedLinereader.
void multovl::io::Linereader::set_statusflag |
( |
Status |
flag | ) |
|
|
inlineprotected |
Sets the given status flag by bitwise OR-ing it with the _status field.
- Parameters
-
flag | one or more of the Status enum-s, OR-ed together |
Status multovl::io::Linereader::status |
( |
| ) |
const |
|
inline |
- Returns
- the status after the last parsing operation.
static unsigned int multovl::io::Linereader::str_to_uint |
( |
std::string & |
str | ) |
|
throw | ( | Exception |
| ) | | |
|
staticprotected |
The documentation for this class was generated from the following file: