libfswatch  1.9.3
win_error_message.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Enrico M. Crisostomo
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 3, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program. If not, see <http://www.gnu.org/licenses/>.
15  */
25 #ifndef FSW_WINDOWS_ERROR_MESSAGE_H
26 # define FSW_WINDOWS_ERROR_MESSAGE_H
27 
28 # include <string>
29 # include <windows.h>
30 
31 namespace fsw
32 {
42  {
43  public:
50  static win_error_message current();
51 
57  win_error_message(DWORD error_code);
58 
66 
72  DWORD get_error_code() const;
73 
82  std::wstring get_message() const;
83 
89  operator std::wstring() const;
90 
91  private:
92  mutable bool initialized = false;
93  mutable std::wstring msg;
94  DWORD err_code;
95  };
96 }
97 
98 #endif /* FSW_WINDOWS_ERROR_MESSAGE_H */
static win_error_message current()
Constructs an instance of this class using the last error code of the calling thread, returned by a call to GetLastError().
Main namespace of libfswatch.
Definition: event.cpp:23
std::wstring get_message() const
Gets the system-defined error message.
win_error_message()
Constructs an error message using the last error code of the calling thread, retrieved with a call to...
DWORD get_error_code() const
Gets the error code.
Helper class to get the system-defined error message for a Microsoft Windows' error code...
Definition: win_error_message.hpp:41