16 bool Label::isClear_ =
true;
17 bool Label::isMatched_ =
false;
18 std::string Label::buffer_;
39 Label::isMatched_ =
false;
42 UTIL_THROW(
"istream::fail() before reading Label");
46 if (buffer_.size() == 0) {
48 Label::isMatched_ =
false;
63 isRequired_(isRequired)
71 isRequired_(isRequired)
79 isRequired_(isRequired)
86 : string_(other.string_),
87 isRequired_(other.isRequired_)
132 Log::file() <<
"End-of-file before reading required Label"
134 Log::file() <<
"Expected: " << label.string_ << std::endl;
135 UTIL_THROW(
"EOF before reading required label");
137 Label::isMatched_ =
false;
144 Log::file() <<
"Empty required label" << std::endl;
145 Log::file() <<
"Expected: " << label.string_ << std::endl;
146 UTIL_THROW(
"Empty required label after read");
151 if (label.buffer_ == label.string_) {
153 Label::isMatched_ =
true;
155 Label::isMatched_ =
false;
156 if (label.isRequired_) {
157 Log::file() <<
"Error reading required label" << std::endl;
158 Log::file() <<
"Expected: " << label.string_ << std::endl;
159 Log::file() <<
"Scanned: " << label.buffer_ << std::endl;
A label string in a file format.
Label(bool isRequired=true)
Constructor.
std::string string() const
Return label string.
static const int LabelWidth
Width of label field in file output format.
static void read(std::istream &in)
Read a string without checking its value.
static void clear()
Clear the input buffer.
virtual ~Label()
Destructor.
bool match(std::istream &in)
Read and attempt to match next word in an input stream.
void setString(std::string string)
Set the label string.
void setIsRequired(bool isRequired)
Set the isRequired boolean flag.
bool isRequired() const
Is this the label for a required component?
static bool isClear()
Is the input buffer clear?
static std::ostream & file()
Get log ostream by reference.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.