2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vcpkg_Strings.h"
|
2017-03-14 08:14:00 +08:00
|
|
|
#include "LineInfo.h"
|
2017-03-14 07:04:29 +08:00
|
|
|
|
2017-01-06 04:47:08 +08:00
|
|
|
namespace vcpkg::Checks
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-01 08:19:03 +08:00
|
|
|
[[noreturn]]
|
|
|
|
void unreachable(const LineInfo& line_info);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-04-01 08:19:03 +08:00
|
|
|
[[noreturn]]
|
|
|
|
void exit_with_code(const LineInfo& line_info, const int exit_code);
|
2017-03-23 08:08:59 +08:00
|
|
|
|
2017-04-01 08:19:03 +08:00
|
|
|
[[noreturn]]
|
|
|
|
inline void exit_fail(const LineInfo& line_info)
|
2017-03-23 08:08:59 +08:00
|
|
|
{
|
2017-03-23 08:19:30 +08:00
|
|
|
exit_with_code(line_info, EXIT_FAILURE);
|
2017-03-23 08:08:59 +08:00
|
|
|
}
|
|
|
|
|
2017-04-01 08:19:03 +08:00
|
|
|
[[noreturn]]
|
|
|
|
inline void exit_success(const LineInfo& line_info)
|
2017-03-23 08:08:59 +08:00
|
|
|
{
|
2017-03-23 08:19:30 +08:00
|
|
|
exit_with_code(line_info, EXIT_SUCCESS);
|
2017-03-23 08:08:59 +08:00
|
|
|
}
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
// Part of the reason these exist is to not include extra headers in this one to avoid circular #includes.
|
2017-04-01 08:19:03 +08:00
|
|
|
[[noreturn]]
|
|
|
|
void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-03-29 03:52:04 +08:00
|
|
|
template <class Arg1, class...Args>
|
2017-04-01 08:19:03 +08:00
|
|
|
[[noreturn]]
|
|
|
|
void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-03-29 03:54:18 +08:00
|
|
|
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...));
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
2017-03-14 08:38:04 +08:00
|
|
|
void check_exit(const LineInfo& line_info, bool expression);
|
2017-02-11 08:51:36 +08:00
|
|
|
|
2017-03-29 03:52:04 +08:00
|
|
|
void check_exit(const LineInfo& line_info, bool expression, const cstring_view errorMessage);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-03-29 03:52:04 +08:00
|
|
|
template <class Arg1, class...Args>
|
|
|
|
void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
if (!expression)
|
|
|
|
{
|
|
|
|
// Only create the string if the expression is false
|
2017-03-29 03:54:18 +08:00
|
|
|
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...));
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
}
|
2017-01-06 04:47:08 +08:00
|
|
|
}
|