OpenStructure
|
#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.
|
explicit |
create a StarParser
stream | input stream |
item_as_row | if true, data-items are first gathered (identifier as header, values as row) and then parsed like a loop (OnBeginLoop(), OnDataRow(), OnEndLoop()) |
|
explicit |
|
inlinevirtual |
Definition at line 122 of file star_parser.hh.
|
explicit |
create a StarParser
stream | input stream |
item_as_row | if true, data-items are first gathered (identifier as header, values as row) and then parsed like a loop (OnBeginLoop(), OnDataRow(), OnEndLoop()) |
|
explicit |
|
inlinevirtual |
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.
|
inline |
retrieve the line, the parser is currently working on
Definition at line 217 of file star_parser.hh.
|
inline |
retrieve the line, the parser is currently working on
Definition at line 217 of file star_parser.hh.
|
inlinevirtual |
invoked when a new data control structure is encountered
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 147 of file star_parser.hh.
|
inlinevirtual |
invoked when a new data control structure is encountered
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 147 of file star_parser.hh.
|
inlinevirtual |
called when a loop is encountered
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 129 of file star_parser.hh.
|
inlinevirtual |
called when a loop is encountered
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 129 of file star_parser.hh.
|
inlinevirtual |
invoked when a data item is encountered
Reimplemented in ChemdictParser, and ChemdictParser.
Definition at line 142 of file star_parser.hh.
|
inlinevirtual |
invoked when a data item is encountered
Reimplemented in ChemdictParser, and ChemdictParser.
Definition at line 142 of file star_parser.hh.
|
inlinevirtual |
invoked when a data row in a loop is encountered.
header | describes the row format |
columns | contains the data columns |
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 137 of file star_parser.hh.
|
inlinevirtual |
invoked when a data row in a loop is encountered.
header | describes the row format |
columns | contains the data columns |
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 137 of file star_parser.hh.
|
inlinevirtual |
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 151 of file star_parser.hh.
|
inlinevirtual |
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
Reimplemented in MMCifReader, MMCifReader, ChemdictParser, and ChemdictParser.
Definition at line 151 of file star_parser.hh.
|
inlinevirtual |
invoked when leaving a loop
OnEndLoop() is only invoked, when OnBeginLoop() returned true.
Definition at line 133 of file star_parser.hh.
|
inlinevirtual |
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 | ( | ) |
|
inline |
Definition at line 211 of file star_parser.hh.
|
inline |
Definition at line 211 of file star_parser.hh.
|
static |
|
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 |
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 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) |
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 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, 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, 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 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 |