parser for the STAR file format More...
#include <star_parser.hh>
Inherited by ChemdictParser, ChemdictParser, MMCifReader, and MMCifReader.
Public Member Functions | |
StarParser (std::istream &stream, bool items_as_row=false) | |
StarParser (const String &filename, bool items_as_row=false) | |
virtual | ~StarParser () |
virtual bool | OnBeginLoop (const StarLoopDesc &header) |
virtual void | OnEndLoop () |
virtual void | OnDataRow (const StarLoopDesc &header, const std::vector< StringRef > &columns) |
virtual void | OnDataItem (const StarDataItem &item) |
virtual bool | OnBeginData (const StringRef &data_name) |
virtual void | OnEndData () |
Real | TryGetReal (const StringRef &data, const String &name) const |
float | TryGetFloat (const StringRef &data, const String &name) const |
std::pair< bool, float > | TryGetFloat (const StringRef &data, const String &name, bool may_fail) const |
int | TryGetInt (const StringRef &data, const String &name) const |
std::pair< bool, int > | TryGetInt (const StringRef &data, const String &name, bool may_fail) const |
bool | TryGetBool (const StringRef &data, const String &name) const |
String | FormatDiagnostic (StarDiagType type, const String &message, int line=-1) const |
void | SetFilename (const String &filename) |
int | GetCurrentLinenum () const |
void | Parse () |
StarParser (std::istream &stream, bool items_as_row=false) | |
StarParser (const String &filename, bool items_as_row=false) | |
virtual | ~StarParser () |
virtual bool | OnBeginLoop (const StarLoopDesc &header) |
virtual void | OnEndLoop () |
virtual void | OnDataRow (const StarLoopDesc &header, const std::vector< StringRef > &columns) |
virtual void | OnDataItem (const StarDataItem &item) |
virtual bool | OnBeginData (const StringRef &data_name) |
virtual void | OnEndData () |
Real | TryGetReal (const StringRef &data, const String &name) const |
float | TryGetFloat (const StringRef &data, const String &name) const |
std::pair< bool, float > | TryGetFloat (const StringRef &data, const String &name, bool may_fail) const |
int | TryGetInt (const StringRef &data, const String &name) const |
std::pair< bool, int > | TryGetInt (const StringRef &data, const String &name, bool may_fail) const |
bool | TryGetBool (const StringRef &data, const String &name) const |
String | FormatDiagnostic (StarDiagType type, const String &message, int line=-1) const |
void | SetFilename (const String &filename) |
int | GetCurrentLinenum () const |
void | Parse () |
Static Public Member Functions | |
static bool | SplitLine (const StringRef &line, std::vector< StringRef > &parts, bool clear=true) |
static bool | SplitLine (const StringRef &line, std::vector< StringRef > &parts, bool clear=true) |
parser for the STAR file format
In essence, STAR files are structured text files. A few simple control structures control the interpretation of the content.
Definition at line 112 of file star_parser.hh.
StarParser | ( | std::istream & | stream, | |
bool | items_as_row = false | |||
) | [explicit] |
create a StarParser
stream | input stream | |
items_as_row | if true, data-items are first gathered (identifier as header, values as row) and then parsed like a loop (OnBeginLoop(), OnDataRow(), OnEndLoop()) |
StarParser | ( | const String & | filename, | |
bool | items_as_row = false | |||
) | [explicit] |
virtual ~StarParser | ( | ) | [inline, virtual] |
Definition at line 122 of file star_parser.hh.
StarParser | ( | std::istream & | stream, | |
bool | items_as_row = false | |||
) | [explicit] |
create a StarParser
stream | input stream | |
items_as_row | if true, data-items are first gathered (identifier as header, values as row) and then parsed like a loop (OnBeginLoop(), OnDataRow(), OnEndLoop()) |
StarParser | ( | const String & | filename, | |
bool | items_as_row = false | |||
) | [explicit] |
virtual ~StarParser | ( | ) | [inline, virtual] |
Definition at line 122 of file star_parser.hh.
String FormatDiagnostic | ( | StarDiagType | type, | |
const String & | message, | |||
int | line = -1 | |||
) | const |
format diagnostic and returns it as a string.
String FormatDiagnostic | ( | StarDiagType | type, | |
const String & | message, | |||
int | line = -1 | |||
) | const |
format diagnostic and returns it as a string.
int GetCurrentLinenum | ( | ) | const [inline] |
retrieve the line, the parser is currently working on
Definition at line 217 of file star_parser.hh.
int GetCurrentLinenum | ( | ) | const [inline] |
retrieve the line, the parser is currently working on
Definition at line 217 of file star_parser.hh.
virtual bool OnBeginData | ( | const StringRef & | data_name | ) | [inline, virtual] |
invoked when a new data control structure is encountered
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 147 of file star_parser.hh.
virtual bool OnBeginData | ( | const StringRef & | data_name | ) | [inline, virtual] |
invoked when a new data control structure is encountered
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 147 of file star_parser.hh.
virtual bool OnBeginLoop | ( | const StarLoopDesc & | header | ) | [inline, virtual] |
called when a loop is encountered
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 129 of file star_parser.hh.
virtual bool OnBeginLoop | ( | const StarLoopDesc & | header | ) | [inline, virtual] |
called when a loop is encountered
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 129 of file star_parser.hh.
virtual void OnDataItem | ( | const StarDataItem & | item | ) | [inline, virtual] |
invoked when a data item is encountered
Reimplemented in ChemdictParser, and ChemdictParser.
Definition at line 142 of file star_parser.hh.
virtual void OnDataItem | ( | const StarDataItem & | item | ) | [inline, virtual] |
invoked when a data item is encountered
Reimplemented in ChemdictParser, and ChemdictParser.
Definition at line 142 of file star_parser.hh.
virtual void OnDataRow | ( | const StarLoopDesc & | header, | |
const std::vector< StringRef > & | columns | |||
) | [inline, virtual] |
invoked when a data row in a loop is encountered.
header | describes the row format | |
columns | contains the data columns |
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 137 of file star_parser.hh.
virtual void OnDataRow | ( | const StarLoopDesc & | header, | |
const std::vector< StringRef > & | columns | |||
) | [inline, virtual] |
invoked when a data row in a loop is encountered.
header | describes the row format | |
columns | contains the data columns |
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 137 of file star_parser.hh.
virtual void OnEndData | ( | ) | [inline, virtual] |
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 151 of file star_parser.hh.
virtual void OnEndData | ( | ) | [inline, virtual] |
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
Reimplemented in ChemdictParser, MMCifReader, ChemdictParser, and MMCifReader.
Definition at line 151 of file star_parser.hh.
virtual void OnEndLoop | ( | ) | [inline, virtual] |
invoked when leaving a loop
OnEndLoop() is only invoked, when OnBeginLoop() returned true.
Definition at line 133 of file star_parser.hh.
virtual void OnEndLoop | ( | ) | [inline, virtual] |
invoked when leaving a loop
OnEndLoop() is only invoked, when OnBeginLoop() returned true.
Definition at line 133 of file star_parser.hh.
void Parse | ( | ) |
void Parse | ( | ) |
void SetFilename | ( | const String & | filename | ) | [inline] |
Definition at line 211 of file star_parser.hh.
void SetFilename | ( | const String & | filename | ) | [inline] |
Definition at line 211 of file star_parser.hh.
static bool SplitLine | ( | const StringRef & | line, | |
std::vector< StringRef > & | parts, | |||
bool | clear = true | |||
) | [static] |
static bool SplitLine | ( | const StringRef & | line, | |
std::vector< StringRef > & | parts, | |||
bool | clear = true | |||
) | [static] |
try to convert a value to bool, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
try to convert a value to bool, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
std::pair<bool, float> TryGetFloat | ( | const StringRef & | data, | |
const String & | name, | |||
bool | may_fail | |||
) | const |
try to convert a value to float, on failure raise an exception.
data | value to be converted | |
name | to be included in the message | |
may_fail | decides if an exception is raised (false) or not (true) |
try to convert a value to float, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
std::pair<bool, float> TryGetFloat | ( | const StringRef & | data, | |
const String & | name, | |||
bool | may_fail | |||
) | const |
try to convert a value to float, on failure raise an exception.
data | value to be converted | |
name | to be included in the message | |
may_fail | decides if an exception is raised (false) or not (true) |
try to convert a value to float, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
try to convert a value to integer, exception can be turned off.
data | value to be converted | |
name | to be included in the message | |
may_fail | decides if an exception is raised (false) or not (true) |
try to convert a value to integer, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
try to convert a value to integer, exception can be turned off.
data | value to be converted | |
name | to be included in the message | |
may_fail | decides if an exception is raised (false) or not (true) |
try to convert a value to integer, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
try to convert a value to Real, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |
try to convert a value to Real, on failure raise an exception.
data | value to be converted | |
name | to be included in the message |