aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/StringFormat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Utilities/StringFormat.h')
-rw-r--r--src/common/Utilities/StringFormat.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h
index da1615575a4..1de56097851 100644
--- a/src/common/Utilities/StringFormat.h
+++ b/src/common/Utilities/StringFormat.h
@@ -23,16 +23,16 @@
namespace Trinity
{
/// Default TC string format function.
- template<typename Format, typename... Args>
- inline std::string StringFormat(Format&& fmt, Args&&... args)
+ template<typename... Args>
+ std::string StringFormat(std::string_view fmt, Args&&... args)
{
try
{
- return fmt::sprintf(std::forward<Format>(fmt), std::forward<Args>(args)...);
+ return fmt::sprintf(fmt, std::forward<Args>(args)...);
}
- catch (const fmt::format_error& formatError)
+ catch (fmt::format_error const& formatError)
{
- std::string error = "An error occurred formatting string \"" + std::string(fmt) + "\" : " + std::string(formatError.what());
+ std::string error = "An error occurred formatting string \"" + std::string(fmt) + "\" : " + formatError.what();
return error;
}
}
@@ -48,6 +48,12 @@ namespace Trinity
{
return fmt.empty();
}
+
+ /// Returns true if the given std::string_view is empty.
+ inline bool IsFormatEmptyOrNull(std::string_view const& fmt)
+ {
+ return fmt.empty();
+ }
}
#endif