10#include <util/mpi/MpiSendRecv.h>
19 bool Label::isClear_ =
true;
20 bool Label::isMatched_ =
false;
21 std::string Label::buffer_;
42 Label::isMatched_ =
false;
45 UTIL_THROW(
"istream::fail() before reading Label");
49 if (buffer_.size() == 0) {
51 Label::isMatched_ =
false;
63 void Label::bcast(MPI::Intracomm& communicator)
65 Util::bcast<std::string>(communicator, buffer_, 0);
66 isClear_ = buffer_.empty();
100 : string_(other.string_),
101 isRequired_(other.isRequired_)
149 if (Label::isClear_ && in.eof()) {
151 Log::file() <<
"End-of-file before reading required Label"
153 Log::file() <<
"Expected: " << label.string_ << std::endl;
154 UTIL_THROW(
"EOF before reading required label");
156 Label::isMatched_ =
false;
163 Log::file() <<
"Empty required label" << std::endl;
164 Log::file() <<
"Expected: " << label.string_ << std::endl;
165 UTIL_THROW(
"Empty required label after read");
170 if (label.buffer_ == label.string_) {
172 Label::isMatched_ =
true;
174 Label::isMatched_ =
false;
175 if (label.isRequired_) {
176 Log::file() <<
"Error reading required label" << std::endl;
177 Log::file() <<
"Expected: " << label.string_ << std::endl;
178 Log::file() <<
"Scanned: " << label.buffer_ << std::endl;
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.