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

#include <gromacs/utility/message_string_collector.h>


Convenience class for creating a message context.

This class provides a RAII-style interface to the MessageStringCollector::startContext() and MessageStringCollector::finishContext() methods: finishContext() is called upon destruction of the object. This avoids the need to call MessageStringCollector::finishContext() on every possible exit point.

Example usage:

bool function(::gmx::MessageStringCollector *errors)
::gmx::MessageStringContext errcontext(errors, "In function()");
bool bOk = function2(errors);
bOk = function3(errors) && bOk;
// <more processing>
return bOk;
See Also

Public Member Functions

 MessageStringContext (MessageStringCollector *collector, const char *name)
 Adds a context for the given object.
 MessageStringContext (MessageStringCollector *collector, const std::string &name)
 Adds a context for the given object.
 ~MessageStringContext ()
 Calls MessageStringCollector::finishContext() on the wrapped object.

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