Gromacs
2024.4
|
#include <gromacs/utility/include/gromacs/utility/message_string_collector.h>
Helper class for collecting message strings, optionally with context.
After strings have been collected, they can be formatted into one long string for, e.g., printing out or for including in an exception.
Public Member Functions | |
MessageStringCollector (MessageStringCollector &&) noexcept | |
MessageStringCollector & | operator= (MessageStringCollector &&) noexcept |
void | startContext (const char *name) |
Starts a context for messages. More... | |
void | startContext (const std::string &name) |
Convenience wrapper for startContext(const char *). | |
void | append (const char *message) |
Adds a new message. | |
void | append (const std::string &message) |
Adds a new message. | |
void | appendIf (bool condition, const char *message) |
Adds a new message if the condition is satisfied.. | |
void | appendIf (bool condition, const std::string &message) |
Adds a new message if the condition is satisfied. | |
void | finishContext () |
Ends a context started with startContext(). More... | |
void | clear () |
Clears all collected messages. | |
bool | isEmpty () const |
Returns false if any messages have been added. More... | |
std::string | toString () const |
Returns all collected messages as one string. | |
void gmx::MessageStringCollector::finishContext | ( | ) |
Ends a context started with startContext().
bool gmx::MessageStringCollector::isEmpty | ( | ) | const |
Returns false if any messages have been added.
The return value is identical to toString().empty()
. Calls to startContext() or finishContext() do not affect the return value of this function.
void gmx::MessageStringCollector::startContext | ( | const char * | name | ) |
Starts a context for messages.
[in] | name | Short description of the context. |