Chris@16: // boost/system/windows_error.hpp ------------------------------------------// Chris@16: Chris@16: // Copyright Beman Dawes 2007 Chris@16: Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See library home page at http://www.boost.org/libs/system Chris@16: Chris@16: #ifndef BOOST_WINDOWS_ERROR_HPP Chris@16: #define BOOST_WINDOWS_ERROR_HPP Chris@16: Chris@16: // This header is effectively empty for compiles on operating systems where Chris@16: // it is not applicable. Chris@16: Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_WINDOWS_API Chris@16: Chris@16: #include Chris@101: Chris@101: // Neither MinGW or Cygwin versions of winerror.h work if used alone, so on Chris@101: // either of those platforms include the full windows.h Chris@101: Chris@101: #if defined(__MINGW32__) || defined(__CYGWIN__) Chris@101: #include Chris@101: #else Chris@16: #include Chris@101: #endif Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace system Chris@16: { Chris@16: Chris@16: // Microsoft Windows ---------------------------------------------------// Chris@16: Chris@16: // To construct an error_code after a API error: Chris@16: // Chris@16: // error_code( ::GetLastError(), system_category() ) Chris@16: Chris@16: namespace windows_error Chris@16: { Chris@16: enum windows_error_code Chris@16: { Chris@16: success = 0, Chris@16: // These names and values are based on Windows winerror.h Chris@16: invalid_function = ERROR_INVALID_FUNCTION, Chris@16: file_not_found = ERROR_FILE_NOT_FOUND, Chris@16: path_not_found = ERROR_PATH_NOT_FOUND, Chris@16: too_many_open_files = ERROR_TOO_MANY_OPEN_FILES, Chris@16: access_denied = ERROR_ACCESS_DENIED, Chris@16: invalid_handle = ERROR_INVALID_HANDLE, Chris@16: arena_trashed = ERROR_ARENA_TRASHED, Chris@16: not_enough_memory = ERROR_NOT_ENOUGH_MEMORY, Chris@16: invalid_block = ERROR_INVALID_BLOCK, Chris@16: bad_environment = ERROR_BAD_ENVIRONMENT, Chris@16: bad_format = ERROR_BAD_FORMAT, Chris@16: invalid_access = ERROR_INVALID_ACCESS, Chris@16: outofmemory = ERROR_OUTOFMEMORY, Chris@16: invalid_drive = ERROR_INVALID_DRIVE, Chris@16: current_directory = ERROR_CURRENT_DIRECTORY, Chris@16: not_same_device = ERROR_NOT_SAME_DEVICE, Chris@16: no_more_files = ERROR_NO_MORE_FILES, Chris@16: write_protect = ERROR_WRITE_PROTECT, Chris@16: bad_unit = ERROR_BAD_UNIT, Chris@16: not_ready = ERROR_NOT_READY, Chris@16: bad_command = ERROR_BAD_COMMAND, Chris@16: crc = ERROR_CRC, Chris@16: bad_length = ERROR_BAD_LENGTH, Chris@16: seek = ERROR_SEEK, Chris@16: not_dos_disk = ERROR_NOT_DOS_DISK, Chris@16: sector_not_found = ERROR_SECTOR_NOT_FOUND, Chris@16: out_of_paper = ERROR_OUT_OF_PAPER, Chris@16: write_fault = ERROR_WRITE_FAULT, Chris@16: read_fault = ERROR_READ_FAULT, Chris@16: gen_failure = ERROR_GEN_FAILURE, Chris@16: sharing_violation = ERROR_SHARING_VIOLATION, Chris@16: lock_violation = ERROR_LOCK_VIOLATION, Chris@16: wrong_disk = ERROR_WRONG_DISK, Chris@16: sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED, Chris@16: handle_eof = ERROR_HANDLE_EOF, Chris@16: handle_disk_full= ERROR_HANDLE_DISK_FULL, Chris@16: rem_not_list = ERROR_REM_NOT_LIST, Chris@16: dup_name = ERROR_DUP_NAME, Chris@16: bad_net_path = ERROR_BAD_NETPATH, Chris@16: network_busy = ERROR_NETWORK_BUSY, Chris@16: // ... Chris@16: file_exists = ERROR_FILE_EXISTS, Chris@16: cannot_make = ERROR_CANNOT_MAKE, Chris@16: // ... Chris@16: broken_pipe = ERROR_BROKEN_PIPE, Chris@16: open_failed = ERROR_OPEN_FAILED, Chris@16: buffer_overflow = ERROR_BUFFER_OVERFLOW, Chris@16: disk_full= ERROR_DISK_FULL, Chris@16: // ... Chris@16: lock_failed = ERROR_LOCK_FAILED, Chris@16: busy = ERROR_BUSY, Chris@16: cancel_violation = ERROR_CANCEL_VIOLATION, Chris@16: already_exists = ERROR_ALREADY_EXISTS Chris@16: // ... Chris@16: Chris@16: // TODO: add more Windows errors Chris@16: }; Chris@16: Chris@16: } // namespace windows Chris@16: Chris@16: # ifndef BOOST_SYSTEM_NO_DEPRECATED Chris@16: namespace windows = windows_error; Chris@16: # endif Chris@16: Chris@16: template<> struct is_error_code_enum Chris@16: { static const bool value = true; }; Chris@16: Chris@16: namespace windows_error Chris@16: { Chris@16: inline error_code make_error_code( windows_error_code e ) Chris@16: { return error_code( e, system_category() ); } Chris@16: } Chris@16: Chris@16: } // namespace system Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_WINDOWS_API Chris@16: Chris@16: #endif // BOOST_WINDOWS_ERROR_HPP