2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vcpkg_Strings.h"
|
|
|
|
|
|
|
|
namespace vcpkg {namespace Checks
|
|
|
|
{
|
|
|
|
__declspec(noreturn) void unreachable();
|
|
|
|
|
|
|
|
// Part of the reason these exist is to not include extra headers in this one to avoid circular #includes.
|
|
|
|
_declspec(noreturn) void exit_with_message(const char* errorMessage);
|
|
|
|
|
|
|
|
template <class...Args>
|
|
|
|
_declspec(noreturn) void exit_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
|
|
|
{
|
|
|
|
exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
_declspec(noreturn) void throw_with_message(const char* errorMessage);
|
|
|
|
|
|
|
|
template <class...Args>
|
|
|
|
_declspec(noreturn) void throw_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
|
|
|
{
|
2016-10-15 04:28:44 +08:00
|
|
|
throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void check_throw(bool expression, const char* errorMessage);
|
|
|
|
|
|
|
|
template <class...Args>
|
|
|
|
void check_throw(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
|
|
|
{
|
|
|
|
if (!expression)
|
|
|
|
{
|
|
|
|
// Only create the string if the expression is false
|
|
|
|
throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void check_exit(bool expression, const char* errorMessage);
|
|
|
|
|
|
|
|
template <class...Args>
|
|
|
|
void check_exit(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
|
|
|
{
|
|
|
|
if (!expression)
|
|
|
|
{
|
|
|
|
// Only create the string if the expression is false
|
|
|
|
exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|