pwn++  0.1.4
A (toy) Windows & Linux pwn library to play with modern C++.
Formatters.hpp
1 #pragma once
2 
3 #include <sstream>
4 #include <string>
5 
6 #include "Log.hpp"
7 #include "Utils.hpp"
8 
9 using namespace pwn;
10 
16 template<>
17 struct std::formatter<std::wstring> : std::formatter<std::string>
18 {
19  auto
20  format(std::wstring const& wstr, std::format_context& ctx)
21  {
22  return std::formatter<std::string>::format(std::format("{}", Utils::StringLib::To<std::string>(wstr)), ctx);
23  }
24 };
25 
26 
32 template<>
33 struct std::formatter<Err, char> : std::formatter<std::string, char>
34 {
35  auto
36  format(Err const& err, std::format_context& ctx)
37  {
38  std::stringstream os;
39  // os << "Error("sv << err.Code << ")";
40  // if ( err.LastError )
41  // {
42  // os << " - " << Log::FormatLastError<std::string>(err.LastError);
43  // }
44  os << '\n';
45  return std::formatter<std::string, char>::format(os.str().c_str(), ctx);
46  }
47 };
Logging header: Wide string support on linux is at best flaky, so only Windows version gets both stri...
Templated return value for failure cases.
Definition: Error.hpp:162