AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface

◆ MessageUserF()

template<typename... Args>
void drama::MessageHandler::MessageUserF ( const fmt::format_string< Args... >  fmt,
Args &&...  args 
)
inlineinherited

Use DRAMA to send a message to the user - format using fmt::format.

The fmt::format library (see https://fmt.dev/) is a modern C++ formatting library inspired by python's formatting facilities, providing python fmt style formatting with C++ type safety. This interface to MessageUser() uses this approach to formatting.

For example:

MessageUserF("Don't {}!", "panic");

The message would be of the form:

<task>:Don't panic!

Formatting specifications are available to set width, white space, number of decimal points etc. If you include "drama/fmt/chrono.h", you can format C++ time variables (from the chrono library).

You can also generate formatting for your own types, see https://fmt.dev/11.0/api/#formatting-user-defined-types for details

References for the format strings:

Note
When reading fmt::dev, remember that in DRAMA applications, you include "drama/fmt/format.h" etc, rather then just "fmt/format.h".
From C++17, the C++ STL includes a near clone of "fmt::format" as "std::format", but with some features not available until C++20. DRAMA makes the "fmt::format" library available so that it is available from C++11 on-wards. If you don't need to use chrono or create your own formatters, then there will not be any issues when DRAMA at some point in the future moves to using std::format.
This approach has been applied to all DRAMA methods that take formatting strings and the older methods have been marked as depreciated. You can turn off the depreciation warnings by defining the macro D2_NO_FMT_DEPRECATION_ALERTS, but if you do this, please remember to come back and deal with the issues. You could define that in your include file and then have this in at least one file.
#ifdef D2_NO_FMT_DEPRECATION_ALERTS
#pragma GCC warning "Remember to disable D2_NO_FMT_DEPRECATION_ALERTS and resolve depreciated interfaces"
#endif
This will produce a message in both CLang (Mac) and GCC, and if you have it in only one file, it won't hide other warnings.
See also
MessageUser() for non-formatted output.
SdsListToUser() for output of an SDS structure
MessageUserStreamBuf to implement a stream buffer that outputs using MessageUser().
Parameters
fmtThe string for formatting. See fmt::format/stdformat for details.
argsArguments to the format. See fmt::format/stdformat for details.
Template Parameters
Args...the remaining argument types.
Examples
dramahello.cpp.

References drama::CreateRunDramaTask(), and drama::MessageHandler::MessageUser().