Gromacs  2022.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::MessageStringCollector Class Reference

#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
MessageStringCollectoroperator= (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.

Member Function Documentation

void gmx::MessageStringCollector::finishContext ( )

Ends a context started with startContext().

See Also
bool gmx::MessageStringCollector::isEmpty ( ) const

Returns false if any messages have been added.

false if append() has been called at least once.

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]nameShort description of the context.
See Also

The documentation for this class was generated from the following files: