A Windows error. */
| 2069 | A Windows error. |
| 2070 | */ |
| 2071 | class WindowsError : public SystemError { |
| 2072 | private: |
| 2073 | void init(int error_code, StringRef format_str, ArgList args); |
| 2074 | |
| 2075 | public: |
| 2076 | /** |
| 2077 | \rst |
| 2078 | Constructs a :cpp:class:`fmt::WindowsError` object with the description |
| 2079 | of the form "*<message>*: *<system-message>*", where *<message>* is the |
| 2080 | formatted message and *<system-message>* is the system message corresponding |
| 2081 | to the error code. |
| 2082 | *error_code* is a Windows error code as given by ``GetLastError``. |
| 2083 | \endrst |
| 2084 | */ |
| 2085 | WindowsError(int error_code, StringRef message) { |
| 2086 | init(error_code, message, ArgList()); |
| 2087 | } |
| 2088 | FMT_VARIADIC_CTOR(WindowsError, init, int, StringRef) |
| 2089 | }; |
| 2090 | |
| 2091 | // Reports a Windows error without throwing an exception. |
| 2092 | // Can be used to report errors from destructors. |
| 2093 | void report_windows_error(int error_code, StringRef message) FMT_NOEXCEPT(true); |
| 2094 | |
| 2095 | #endif |
| 2096 | |
| 2097 | enum Color { BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE }; |
| 2098 | |
| 2099 | /** |
| 2100 | Formats a string and prints it to stdout using ANSI escape sequences |
| 2101 | to specify color (experimental). |
| 2102 | Example: |
| 2103 | PrintColored(fmt::RED, "Elapsed time: {0:.2f} seconds") << 1.23; |
| 2104 | */ |
| 2105 | void print_colored(Color c, StringRef format, ArgList args); |
| 2106 | |
| 2107 | /** |
| 2108 | \rst |
| 2109 | Formats arguments and returns the result as a string. |
| 2110 | |
| 2111 | **Example**:: |
| 2112 | |
| 2113 | std::string message = format("The answer is {}", 42); |
| 2114 | \endrst |
| 2115 | */ |
| 2116 | inline std::string format(StringRef format_str, ArgList args) { |
| 2117 | MemoryWriter w; |
| 2118 | w.write(format_str, args); |
| 2119 | return w.str(); |
| 2120 | } |
| 2121 | |
| 2122 | inline std::wstring format(WStringRef format_str, ArgList args) { |
| 2123 | WMemoryWriter w; |
| 2124 | w.write(format_str, args); |
| 2125 | return w.str(); |
| 2126 | } |
| 2127 | |
| 2128 | /** |
no outgoing calls
no test coverage detected