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 |
Real | GetRealOrDefault (const StringRef &data, const String &name, Real alt, bool(*is_default)(StringRef)) 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 |
Real | GetRealOrDefault (const StringRef &data, const String &name, Real alt, bool(*is_default)(StringRef)) 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 114 of file star_parser.hh.
|
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()) |
|
explicit |
|
inlinevirtual |
Definition at line 124 of file star_parser.hh.
|
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()) |
|
explicit |
|
inlinevirtual |
Definition at line 124 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 232 of file star_parser.hh.
|
inline |
retrieve the line, the parser is currently working on
Definition at line 232 of file star_parser.hh.
Real GetRealOrDefault | ( | const StringRef & | data, |
const String & | name, | ||
Real | alt, | ||
bool(*)(StringRef) | is_default | ||
) | const |
try to convert a value to Real, on failure return default value.
data | value to be converted |
name | to be included in the message |
alt | value |
is_default | a function to check if data is a default value. |
Real GetRealOrDefault | ( | const StringRef & | data, |
const String & | name, | ||
Real | alt, | ||
bool(*)(StringRef) | is_default | ||
) | const |
try to convert a value to Real, on failure return default value.
data | value to be converted |
name | to be included in the message |
alt | value |
is_default | a function to check if data is a default value. |
|
inlinevirtual |
invoked when a new data control structure is encountered
Reimplemented in MMCifReader, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 149 of file star_parser.hh.
|
inlinevirtual |
invoked when a new data control structure is encountered
Reimplemented in MMCifReader, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 149 of file star_parser.hh.
|
inlinevirtual |
called when a loop is encountered
Reimplemented in MMCifReader, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 131 of file star_parser.hh.
|
inlinevirtual |
called when a loop is encountered
Reimplemented in MMCifReader, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 131 of file star_parser.hh.
|
inlinevirtual |
invoked when a data item is encountered
Reimplemented in ChemdictParser, and ChemdictParser.
Definition at line 144 of file star_parser.hh.
|
inlinevirtual |
invoked when a data item is encountered
Reimplemented in ChemdictParser, and ChemdictParser.
Definition at line 144 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, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 139 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, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 139 of file star_parser.hh.
|
inlinevirtual |
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
Reimplemented in MMCifReader, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 153 of file star_parser.hh.
|
inlinevirtual |
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
Reimplemented in MMCifReader, ChemdictParser, MMCifReader, and ChemdictParser.
Definition at line 153 of file star_parser.hh.
|
inlinevirtual |
invoked when leaving a loop
OnEndLoop() is only invoked, when OnBeginLoop() returned true.
Definition at line 135 of file star_parser.hh.
|
inlinevirtual |
invoked when leaving a loop
OnEndLoop() is only invoked, when OnBeginLoop() returned true.
Definition at line 135 of file star_parser.hh.
void Parse | ( | ) |
void Parse | ( | ) |
|
inline |
Definition at line 226 of file star_parser.hh.
|
inline |
Definition at line 226 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 |