add overload to utils::print() so it can be used without FILE pointer
This commit is contained in:
@ -274,6 +274,11 @@ void utils::print(FILE *fp, const std::string &mesg)
|
||||
fputs(mesg.c_str(), fp);
|
||||
}
|
||||
|
||||
void utils::print(const std::string &mesg)
|
||||
{
|
||||
fputs(mesg.c_str(), stdout);
|
||||
}
|
||||
|
||||
void utils::fmtargs_print(FILE *fp, fmt::string_view format, fmt::format_args args)
|
||||
{
|
||||
print(fp, fmt::vformat(format, args));
|
||||
|
||||
22
src/utils.h
22
src/utils.h
@ -151,7 +151,7 @@ output are compressed to a single blank by calling :cpp:func:`strcompress()`
|
||||
|
||||
\endverbatim
|
||||
*
|
||||
* This function implements a version of fprintf() that uses {fmt} formatting
|
||||
* This function implements a version of (f)printf() that uses {fmt} formatting
|
||||
*
|
||||
* \param fp stdio FILE pointer
|
||||
* \param format format string of message to be printed
|
||||
@ -163,12 +163,32 @@ output are compressed to a single blank by calling :cpp:func:`strcompress()`
|
||||
}
|
||||
|
||||
/*! \overload
|
||||
*
|
||||
* Print to stdout without specifying the FILE pointer.
|
||||
*
|
||||
* \param mesg string with message to be printed */
|
||||
template <typename... Args> void print(const std::string &format, Args &&...args)
|
||||
{
|
||||
fmtargs_print(stdout, format, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
/*! \overload
|
||||
*
|
||||
* Print string message without format
|
||||
*
|
||||
* \param fp stdio FILE pointer
|
||||
* \param mesg string with message to be printed */
|
||||
|
||||
void print(FILE *fp, const std::string &mesg);
|
||||
|
||||
/*! \overload
|
||||
*
|
||||
* Print string message without format to stdout
|
||||
*
|
||||
* \param mesg string with message to be printed */
|
||||
|
||||
void print(const std::string &mesg);
|
||||
|
||||
/*! Return text redirecting the user to a specific paragraph in the manual
|
||||
*
|
||||
* The LAMMPS manual contains detailed explanations for errors and
|
||||
|
||||
Reference in New Issue
Block a user