mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 13:13:34 +08:00
Use cstring_view in all functions in Checks::
This commit is contained in:
parent
ddf40ccdd3
commit
780ef97d1b
@ -20,45 +20,45 @@ namespace vcpkg::Checks
|
||||
}
|
||||
|
||||
// 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 LineInfo& line_info, const char* errorMessage);
|
||||
_declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
|
||||
|
||||
template <class...Args>
|
||||
_declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
||||
template <class Arg1, class...Args>
|
||||
_declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
|
||||
{
|
||||
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
||||
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
|
||||
}
|
||||
|
||||
_declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage);
|
||||
_declspec(noreturn) void throw_with_message(const LineInfo& line_info, const cstring_view errorMessage);
|
||||
|
||||
template <class...Args>
|
||||
_declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
||||
template <class Arg1, class...Args>
|
||||
_declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
|
||||
{
|
||||
throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
||||
throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
|
||||
}
|
||||
|
||||
void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage);
|
||||
void check_throw(const LineInfo& line_info, bool expression, const cstring_view errorMessage);
|
||||
|
||||
template <class...Args>
|
||||
void check_throw(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
||||
template <class Arg1, class...Args>
|
||||
void check_throw(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
// Only create the string if the expression is false
|
||||
throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
||||
throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void check_exit(const LineInfo& line_info, bool expression);
|
||||
|
||||
void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage);
|
||||
void check_exit(const LineInfo& line_info, bool expression, const cstring_view errorMessage);
|
||||
|
||||
template <class...Args>
|
||||
void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs)
|
||||
template <class Arg1, class...Args>
|
||||
void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
// Only create the string if the expression is false
|
||||
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
|
||||
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,19 +30,19 @@ namespace vcpkg::Checks
|
||||
::exit(exit_code);
|
||||
}
|
||||
|
||||
__declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage)
|
||||
__declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage)
|
||||
{
|
||||
System::println(System::color::error, errorMessage);
|
||||
exit_fail(line_info);
|
||||
}
|
||||
|
||||
__declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage)
|
||||
__declspec(noreturn) void throw_with_message(const LineInfo& line_info, const cstring_view errorMessage)
|
||||
{
|
||||
print_line_info_if_debug(line_info);
|
||||
throw std::runtime_error(errorMessage);
|
||||
}
|
||||
|
||||
void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage)
|
||||
void check_throw(const LineInfo& line_info, bool expression, const cstring_view errorMessage)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
@ -58,7 +58,7 @@ namespace vcpkg::Checks
|
||||
}
|
||||
}
|
||||
|
||||
void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage)
|
||||
void check_exit(const LineInfo& line_info, bool expression, const cstring_view errorMessage)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user