Skip to content

Commit e02aadd

Browse files
jgautier-anssifabienfl-orc
authored andcommittedMay 5, 2023
OrcLib: WofAlgorithm: add ToWString
1 parent bafeda0 commit e02aadd

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed
 

‎src/OrcLib/Filesystem/Ntfs/Compression/WofAlgorithm.cpp

+33-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@ using namespace Orc;
1717

1818
namespace {
1919

20-
constexpr std::string_view kUnknown = "<Unknown>";
21-
constexpr std::string_view kXpress4k = "xpress4k";
22-
constexpr std::string_view kXpress8k = "xpress8k";
23-
constexpr std::string_view kXpress16k = "xpress16k";
24-
constexpr std::string_view kLzx = "lzx";
20+
using namespace std::string_view_literals;
21+
22+
constexpr auto kUnknown = "<Unknown>"sv;
23+
constexpr auto kXpress4k = "xpress4k"sv;
24+
constexpr auto kXpress8k = "xpress8k"sv;
25+
constexpr auto kXpress16k = "xpress16k"sv;
26+
constexpr auto kLzx = "lzx"sv;
27+
28+
constexpr auto kUnknownW = L"<Unknown>"sv;
29+
constexpr auto kXpress4kW = L"xpress4k"sv;
30+
constexpr auto kXpress8kW = L"xpress8k"sv;
31+
constexpr auto kXpress16kW = L"xpress16k"sv;
32+
constexpr auto kLzxW = L"lzx"sv;
2533

2634
WofAlgorithm ToWofAlgorithmXpress(uint64_t chunkSize, std::error_code& ec)
2735
{
@@ -47,6 +55,7 @@ WofAlgorithm ToWofAlgorithmXpress(uint64_t chunkSize, std::error_code& ec)
4755
} // namespace
4856

4957
namespace Orc {
58+
namespace Ntfs {
5059

5160
std::string_view ToString(Ntfs::WofAlgorithm algorithm)
5261
{
@@ -68,7 +77,25 @@ std::string_view ToString(Ntfs::WofAlgorithm algorithm)
6877

6978
return kUnknown;
7079
}
71-
namespace Ntfs {
80+
81+
std::wstring_view ToWString(WofAlgorithm algorithm)
82+
{
83+
switch (algorithm)
84+
{
85+
case WofAlgorithm::kUnknown:
86+
return kUnknownW;
87+
case WofAlgorithm::kXpress4k:
88+
return kXpress4kW;
89+
case WofAlgorithm::kXpress8k:
90+
return kXpress8kW;
91+
case WofAlgorithm::kXpress16k:
92+
return kXpress16kW;
93+
case WofAlgorithm::kLzx:
94+
return kLzxW;
95+
}
96+
97+
return kUnknownW;
98+
}
7299

73100
WofAlgorithm ToWofAlgorithm(const std::string& algorithm, std::error_code& ec)
74101
{

‎src/OrcLib/Filesystem/Ntfs/Compression/WofAlgorithm.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ enum class WofAlgorithm
3030
kXpress16k = 3
3131
};
3232

33+
std::string_view ToString(WofAlgorithm algorithm);
34+
std::wstring_view ToWString(WofAlgorithm algorithm);
35+
3336
WofAlgorithm ToWofAlgorithm(const std::string& algorithm, std::error_code& ec);
3437

3538
NtAlgorithm ToNtAlgorithm(WofAlgorithm algorithm);
@@ -42,6 +45,4 @@ WofAlgorithm ToWofAlgorithm(WimlibAlgorithm algorithm, uint64_t chunkSize, std::
4245

4346
} // namespace Ntfs
4447

45-
std::string_view ToString(Ntfs::WofAlgorithm algorithm);
46-
4748
} // namespace Orc

0 commit comments

Comments
 (0)
Please sign in to comment.