|
Simpatico
v1.10
|
A label string in a file format.
The operator >> for a label checks if the expected label was found. The operator << outputs the expected label.
The constructor takes a parameter isRequired that determines whether the label must be matched (isRequired == true), or if it is optional (isRequired == false). If the input value read by the >> operator does not match the expected value and isRequired is true, the >> operator will print an error message to the Log::file() and then throw an Exception. If the input value does not match and isRequired is false, the >> operator stores the input value in a string buffer, and will compare it to subsequent values until a match is found.
#include <Label.h>
Public Member Functions | |
| Label (bool isRequired=true) | |
| Constructor. More... | |
| Label (std::string string, bool isRequired=true) | |
| Constructor. More... | |
| Label (const char *string, bool isRequired=true) | |
| Constructor. More... | |
| Label (const Label &other) | |
| Copy constructor. More... | |
| virtual | ~Label () |
| Destructor. More... | |
| void | setString (std::string string) |
| Set the label string. More... | |
| bool | match (std::istream &in) |
| Read and attempt to match next word in an input stream. More... | |
| std::string | string () const |
| Return label string. More... | |
| bool | isRequired () const |
| Is this the label for a required component? More... | |
Static Public Member Functions | |
| static void | clear () |
| Reset buffer and flags to initial state. More... | |
| static bool | isClear () |
| Is the input buffer clear? More... | |
| static bool | isMatched () |
| Did the most recent attempt to match a Label succeed? More... | |
Static Public Attributes | |
| static const int | LabelWidth = 20 |
| Width of label field in file output format. More... | |
Friends | |
| std::istream & | operator>> (std::istream &in, Label label) |
| Extractor for Label. More... | |
| std::ostream & | operator<< (std::ostream &out, Label label) |
| Inserter for Label. More... | |
|
explicit |
| Util::Label::Label | ( | std::string | string, |
| bool | isRequired = true |
||
| ) |
| Util::Label::Label | ( | const char * | string, |
| bool | isRequired = true |
||
| ) |
| Util::Label::Label | ( | const Label & | other | ) |
|
static |
|
static |
Is the input buffer clear?
Definition at line 37 of file Label.cpp.
Referenced by McMd::SmpConfigIo::read(), Util::Begin::readParam(), Simp::Species::readStructure(), and McMd::SmpConfigIo::write().
|
inlinestatic |
Did the most recent attempt to match a Label succeed?
Returns true after a succesful match by operator >> or the match() function. Returns false before any attempt to match any Label, after a failed attempt with an an optional label.
Definition at line 203 of file Label.h.
Referenced by Util::Parameter::readParam().
| void Util::Label::setString | ( | std::string | string | ) |
Set the label string.
| string | label string that precedes value in file format |
Definition at line 83 of file Label.cpp.
References string().
Referenced by Util::Begin::Begin().
| bool Util::Label::match | ( | std::istream & | in | ) |
Read and attempt to match next word in an input stream.
This is a convenience function that invokes operator >> to read a word and then returns the value of Label::isMatched(). For an optional Label, this returns true upon a successful match and false otherwise. For a required label, returns true upon a successful match or throws an Exception.
Definition at line 95 of file Label.cpp.
Referenced by McMd::SmpConfigIo::read().
| std::string Util::Label::string | ( | ) | const |
Return label string.
Definition at line 89 of file Label.cpp.
Referenced by Util::Parameter::label(), setString(), and Util::Begin::writeParam().
|
inline |
Is this the label for a required component?
Definition at line 197 of file Label.h.
Referenced by Util::Begin::isRequired(), Util::Parameter::isRequired(), and Util::operator>>().
|
friend |
|
friend |
|
static |
Width of label field in file output format.
Definition at line 44 of file Label.h.
Referenced by Util::operator<<().
1.8.11