win32/HResult: un-inline HResultCategory::message()
This commit is contained in:
@@ -19,9 +19,24 @@
|
|||||||
|
|
||||||
#include "HResult.hxx"
|
#include "HResult.hxx"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
std::string
|
||||||
|
HResultCategory::message(int Errcode) const
|
||||||
|
{
|
||||||
|
const auto msg = HRESULTToString(Errcode);
|
||||||
|
if (!msg.empty())
|
||||||
|
return std::string(msg);
|
||||||
|
|
||||||
|
char buffer[11]; // "0x12345678\0"
|
||||||
|
int size = snprintf(buffer, sizeof(buffer), "0x%1x", Errcode);
|
||||||
|
assert(2 <= size && size <= 10);
|
||||||
|
return std::string(buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
std::system_error
|
std::system_error
|
||||||
FormatHResultError(HRESULT result, const char *fmt, ...) noexcept
|
FormatHResultError(HRESULT result, const char *fmt, ...) noexcept
|
||||||
{
|
{
|
||||||
|
@@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
#include "util/Compiler.h"
|
#include "util/Compiler.h"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
@@ -66,16 +64,7 @@ static inline const std::error_category &hresult_category() noexcept;
|
|||||||
class HResultCategory : public std::error_category {
|
class HResultCategory : public std::error_category {
|
||||||
public:
|
public:
|
||||||
const char *name() const noexcept override { return "HRESULT"; }
|
const char *name() const noexcept override { return "HRESULT"; }
|
||||||
std::string message(int Errcode) const override {
|
std::string message(int Errcode) const override;
|
||||||
const auto msg = HRESULTToString(Errcode);
|
|
||||||
if (!msg.empty()) {
|
|
||||||
return std::string(msg);
|
|
||||||
}
|
|
||||||
char buffer[11]; // "0x12345678\0"
|
|
||||||
int size = snprintf(buffer, sizeof(buffer), "0x%1x", Errcode);
|
|
||||||
assert(2 <= size && size <= 10);
|
|
||||||
return std::string(buffer, size);
|
|
||||||
}
|
|
||||||
std::error_condition default_error_condition(int code) const noexcept override {
|
std::error_condition default_error_condition(int code) const noexcept override {
|
||||||
return std::error_condition(code, hresult_category());
|
return std::error_condition(code, hresult_category());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user