Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a7e7312c
Commit
a7e7312c
authored
Mar 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32/HResult: un-inline HResultCategory::message()
parent
6b83fc6b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
HResult.cxx
src/win32/HResult.cxx
+15
-0
HResult.hxx
src/win32/HResult.hxx
+1
-12
No files found.
src/win32/HResult.cxx
View file @
a7e7312c
...
...
@@ -19,9 +19,24 @@
#include "HResult.hxx"
#include <cassert>
#include <cstdarg>
#include <cstdio>
#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
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
{
...
...
src/win32/HResult.hxx
View file @
a7e7312c
...
...
@@ -22,8 +22,6 @@
#include "util/Compiler.h"
#include <cassert>
#include <cstdio>
#include <string_view>
#include <system_error>
...
...
@@ -66,16 +64,7 @@ static inline const std::error_category &hresult_category() noexcept;
class
HResultCategory
:
public
std
::
error_category
{
public
:
const
char
*
name
()
const
noexcept
override
{
return
"HRESULT"
;
}
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
::
string
message
(
int
Errcode
)
const
override
;
std
::
error_condition
default_error_condition
(
int
code
)
const
noexcept
override
{
return
std
::
error_condition
(
code
,
hresult_category
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment