add vararg versions of Error::all() and Error::one() plus unit tests

This commit is contained in:
Axel Kohlmeyer
2021-04-25 19:04:49 -04:00
parent 60c2d8ea5b
commit 4e25204296
3 changed files with 89 additions and 3 deletions

View File

@ -32,6 +32,17 @@ class Error : protected Pointers {
[[ noreturn ]] void all(const std::string &, int, const std::string &);
[[ noreturn ]] void one(const std::string &, int, const std::string &);
template <typename S, typename... Args>
[[ noreturn ]] void all(const std::string &file, int line, const S &format,
Args&&... args) {
_all(file, line, format, fmt::make_args_checked<Args...>(format, args...));
}
template <typename S, typename... Args>
[[ noreturn ]] void one(const std::string &file, int line, const S &format,
Args&&... args) {
_one(file, line, format, fmt::make_args_checked<Args...>(format, args...));
}
void warning(const std::string &, int, const std::string &, int = 1);
void message(const std::string &, int, const std::string &, int = 1);
[[ noreturn ]] void done(int = 0); // 1 would be fully backwards compatible
@ -44,6 +55,12 @@ class Error : protected Pointers {
private:
std::string last_error_message;
ErrorType last_error_type;
// internal versions that accept explicit fmtlib arguments
[[ noreturn ]] void _all(const std::string &, int, fmt::string_view,
fmt::format_args args);
[[ noreturn ]] void _one(const std::string &, int, fmt::string_view,
fmt::format_args args);
#endif
};