mirror of
https://github.com/boostorg/system.git
synced 2026-06-16 17:02:39 +02:00
Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e1ae5bc7a | |||
| 7236be0c58 | |||
| 776834b723 | |||
| 7d6da0ad91 | |||
| 999cf08bf5 | |||
| 96418c1531 | |||
| 717867cf4e | |||
| 7e2a02b16d | |||
| b7e3be2798 | |||
| e919caa2b4 | |||
| b951517625 | |||
| ff18f28684 | |||
| 96321beb88 | |||
| 313982fa52 | |||
| cc2b081a9e | |||
| a93572ab16 | |||
| cc49bc4457 | |||
| 6bc7edbfa8 | |||
| c345b86b0a | |||
| 13bac420ab | |||
| abc94afdb2 | |||
| 867ac5b446 | |||
| d50db54c44 | |||
| 72ea1ef846 | |||
| d581eb203e | |||
| 3047581c75 | |||
| ddd679e6d7 | |||
| 4ec6c99148 | |||
| 7b56fd9acf | |||
| b6a447cdde | |||
| 83019b5822 | |||
| 8220aa5700 | |||
| f00c76a3fc | |||
| 73bf30ae04 | |||
| 63ac7fb9bc | |||
| feb545a919 | |||
| 00b30343b9 | |||
| c91dbc8249 | |||
| 00d85d8d37 | |||
| 5d3365717e | |||
| 6942dc454b | |||
| 7ba160e443 | |||
| d9bfbfc4d4 | |||
| 90cb8254df | |||
| 4d1486dec9 | |||
| 97665bf539 | |||
| 6d82346e0b | |||
| 673dd13eaa | |||
| ca525cd7b2 | |||
| 9fb5bbd448 | |||
| 31152834ac | |||
| 455946faac | |||
| 08370c9158 | |||
| c556aba559 | |||
| ecc4ddd87c | |||
| f67827eee3 | |||
| c08b8a94ea | |||
| 835e5de228 | |||
| dc2ad73e30 | |||
| 32a6c13533 |
+117
-105
@@ -6,6 +6,8 @@ language: cpp
|
|||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
dist: xenial
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
@@ -116,12 +118,33 @@ matrix:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: g++-8
|
compiler: g++-9
|
||||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- g++-8
|
- g++-9
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
dist: bionic
|
||||||
|
compiler: g++-10
|
||||||
|
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- g++-10
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: g++-9
|
||||||
|
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- g++-9
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
@@ -130,6 +153,7 @@ matrix:
|
|||||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
compiler: /usr/bin/clang++
|
compiler: /usr/bin/clang++
|
||||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||||
addons:
|
addons:
|
||||||
@@ -138,6 +162,7 @@ matrix:
|
|||||||
- clang-3.3
|
- clang-3.3
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
compiler: /usr/bin/clang++
|
compiler: /usr/bin/clang++
|
||||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||||
addons:
|
addons:
|
||||||
@@ -146,16 +171,15 @@ matrix:
|
|||||||
- clang-3.4
|
- clang-3.4
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
compiler: clang++-3.5
|
compiler: clang++-3.5
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- clang-3.5
|
- clang-3.5
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.5
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-3.6
|
compiler: clang++-3.6
|
||||||
@@ -166,19 +190,6 @@ matrix:
|
|||||||
- clang-3.6
|
- clang-3.6
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.6
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.6
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.6
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.6
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-3.7
|
compiler: clang++-3.7
|
||||||
@@ -189,19 +200,6 @@ matrix:
|
|||||||
- clang-3.7
|
- clang-3.7
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.7
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.7
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.7
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-3.8
|
compiler: clang++-3.8
|
||||||
@@ -212,19 +210,6 @@ matrix:
|
|||||||
- clang-3.8
|
- clang-3.8
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.8
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.8
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.8
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.8
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-3.9
|
compiler: clang++-3.9
|
||||||
@@ -235,19 +220,6 @@ matrix:
|
|||||||
- clang-3.9
|
- clang-3.9
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.9
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.9
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.9
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.9
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-4.0
|
compiler: clang++-4.0
|
||||||
@@ -258,19 +230,6 @@ matrix:
|
|||||||
- clang-4.0
|
- clang-4.0
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty-4.0
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-4.0
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-4.0
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-trusty-4.0
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-5.0
|
compiler: clang++-5.0
|
||||||
@@ -281,19 +240,6 @@ matrix:
|
|||||||
- clang-5.0
|
- clang-5.0
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty-5.0
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-5.0
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-5.0
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-trusty-5.0
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-6.0
|
compiler: clang++-6.0
|
||||||
@@ -304,19 +250,6 @@ matrix:
|
|||||||
- clang-6.0
|
- clang-6.0
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty-6.0
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-6.0
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-6.0
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-trusty-6.0
|
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-7
|
compiler: clang++-7
|
||||||
@@ -327,21 +260,59 @@ matrix:
|
|||||||
- clang-7
|
- clang-7
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty-7
|
- llvm-toolchain-xenial-7
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang++-6.0
|
compiler: clang++-8
|
||||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- clang-6.0
|
- clang-8
|
||||||
- libstdc++-5-dev
|
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty-6.0
|
- llvm-toolchain-xenial-8
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
|
compiler: clang++-9
|
||||||
|
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- clang-9
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
|
||||||
|
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: clang++-10
|
||||||
|
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- clang-10
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||||
|
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
|
compiler: clang++-10
|
||||||
|
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- clang-10
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||||
|
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
compiler: clang++-libc++
|
compiler: clang++-libc++
|
||||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||||
addons:
|
addons:
|
||||||
@@ -350,6 +321,7 @@ matrix:
|
|||||||
- libc++-dev
|
- libc++-dev
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
compiler: clang++-libc++
|
compiler: clang++-libc++
|
||||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||||
addons:
|
addons:
|
||||||
@@ -361,15 +333,55 @@ matrix:
|
|||||||
compiler: clang++
|
compiler: clang++
|
||||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||||
|
|
||||||
|
- os: osx
|
||||||
|
compiler: clang++
|
||||||
|
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||||
|
|
||||||
|
- os: freebsd
|
||||||
|
compiler: clang++
|
||||||
|
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: g++
|
env: CMAKE=1
|
||||||
env: CMAKE_SUBDIR_TEST=1
|
|
||||||
script:
|
script:
|
||||||
- cd libs/system/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
- mkdir __build__ && cd __build__
|
||||||
|
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
|
||||||
|
- ctest --output-on-failure -R boost_system
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env: CMAKE=1 BUILD_SHARED_LIBS=ON
|
||||||
|
script:
|
||||||
|
- mkdir __build__ && cd __build__
|
||||||
|
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBUILD_SHARED_LIBS=ON -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
|
||||||
|
- ctest --output-on-failure -R boost_system
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env: CMAKE_SUBDIR_TEST=1
|
||||||
|
install:
|
||||||
|
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
|
||||||
|
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
|
||||||
|
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
|
||||||
|
- git clone -b $BOOST_BRANCH https://github.com/boostorg/predef.git ../predef
|
||||||
|
- git clone -b $BOOST_BRANCH https://github.com/boostorg/winapi.git ../winapi
|
||||||
|
script:
|
||||||
|
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||||
- cmake ..
|
- cmake ..
|
||||||
- cmake --build .
|
- cmake --build .
|
||||||
- cmake --build . --target check
|
- cmake --build . --target check
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env: CMAKE_INSTALL=1
|
||||||
|
script:
|
||||||
|
- pip install --user cmake
|
||||||
|
- mkdir __build__ && cd __build__
|
||||||
|
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="system;core" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||||
|
- cmake --build . --target install
|
||||||
|
- cd ../libs/system/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||||
|
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||||
|
- cmake --build .
|
||||||
|
- cmake --build . --target check
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||||
- cd ..
|
- cd ..
|
||||||
|
|||||||
+12
-8
@@ -1,12 +1,10 @@
|
|||||||
# Copyright 2018 Mike Dev
|
# Copyright 2018-2020 Peter Dimov
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
# Partial (add_subdirectory only) and experimental CMake support
|
cmake_minimum_required(VERSION 3.5...3.16)
|
||||||
# Subject to change; please do not rely on the contents of this file yet
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
project(BoostSystem LANGUAGES CXX)
|
|
||||||
|
|
||||||
add_library(boost_system INTERFACE)
|
add_library(boost_system INTERFACE)
|
||||||
add_library(Boost::system ALIAS boost_system)
|
add_library(Boost::system ALIAS boost_system)
|
||||||
@@ -14,7 +12,13 @@ add_library(Boost::system ALIAS boost_system)
|
|||||||
target_include_directories(boost_system INTERFACE include)
|
target_include_directories(boost_system INTERFACE include)
|
||||||
|
|
||||||
target_link_libraries(boost_system
|
target_link_libraries(boost_system
|
||||||
INTERFACE
|
INTERFACE
|
||||||
Boost::config
|
Boost::config
|
||||||
Boost::winapi
|
Boost::winapi
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ environment:
|
|||||||
TOOLSET: msvc-14.1
|
TOOLSET: msvc-14.1
|
||||||
CXXSTD: 14,17
|
CXXSTD: 14,17
|
||||||
ADDRMD: 32,64
|
ADDRMD: 32,64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
TOOLSET: clang-win
|
||||||
|
CXXSTD: 14,17
|
||||||
|
ADDRMD: 64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
TOOLSET: msvc-14.2
|
||||||
|
CXXSTD: 14,17
|
||||||
|
ADDRMD: 32,64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
ADDPATH: C:\cygwin\bin;
|
ADDPATH: C:\cygwin\bin;
|
||||||
TOOLSET: gcc
|
TOOLSET: gcc
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<style>
|
<style>
|
||||||
|
|
||||||
*:not(pre)>code { background: none; color: #600000; }
|
*:not(pre)>code { background: none; color: #600000; }
|
||||||
|
:not(pre):not([class^=L])>code { background: none; color: #600000; }
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ http://www.boost.org/LICENSE_1_0.txt
|
|||||||
////
|
////
|
||||||
|
|
||||||
[#changes]
|
[#changes]
|
||||||
# Release History
|
# Revision History
|
||||||
:idprefix:
|
:idprefix:
|
||||||
|
|
||||||
|
## Changes in Boost 1.74
|
||||||
|
|
||||||
|
* `operator bool()` now returns `failed()` instead of `value() != 0`.
|
||||||
|
|
||||||
## Changes in Boost 1.69
|
## Changes in Boost 1.69
|
||||||
|
|
||||||
* Boost.System is now header-only. A stub library is still built for
|
* Boost.System is now header-only. A stub library is still built for
|
||||||
|
|||||||
@@ -568,7 +568,8 @@ constexpr void clear() noexcept;
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Ensures: :: `val_ == 0`; `*cat_ == system_category()`.
|
Ensures: ::
|
||||||
|
`val_ == 0`; `*cat_ == system_category()`.
|
||||||
|
|
||||||
#### Observers
|
#### Observers
|
||||||
|
|
||||||
@@ -626,7 +627,7 @@ constexpr explicit operator bool() const noexcept;
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Returns: :: `val_ != 0`.
|
Returns: :: `failed()`.
|
||||||
|
|
||||||
```
|
```
|
||||||
operator std::error_code() const;
|
operator std::error_code() const;
|
||||||
@@ -634,7 +635,8 @@ operator std::error_code() const;
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Returns: :: `std::error_code( val_, *cat_ )`.
|
Returns: ::
|
||||||
|
`std::error_code( val_, *cat_ )`.
|
||||||
|
|
||||||
### Class error_condition
|
### Class error_condition
|
||||||
|
|
||||||
@@ -711,7 +713,8 @@ template <class ErrorConditionEnum>
|
|||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Ensures: :: `*this == make_error_condition( e )`.
|
Ensures: :: `*this == make_error_condition( e )`.
|
||||||
Remarks: :: This constructor is only enabled when `is_error_condition_enum<ErrorConditionEnum>::value` is `true`.
|
Remarks: ::
|
||||||
|
This constructor is only enabled when `is_error_condition_enum<ErrorConditionEnum>::value` is `true`.
|
||||||
|
|
||||||
#### Modifiers
|
#### Modifiers
|
||||||
|
|
||||||
@@ -739,7 +742,8 @@ constexpr void clear() noexcept;
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Ensures: :: `val_ == 0`; `*cat_ == generic_category()`.
|
Ensures: ::
|
||||||
|
`val_ == 0`; `*cat_ == generic_category()`.
|
||||||
|
|
||||||
#### Observers
|
#### Observers
|
||||||
|
|
||||||
@@ -789,7 +793,7 @@ constexpr explicit operator bool() const noexcept;
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Returns: :: `val_ != 0`.
|
Returns: :: `failed()`.
|
||||||
|
|
||||||
```
|
```
|
||||||
operator std::error_condition() const;
|
operator std::error_condition() const;
|
||||||
@@ -797,7 +801,8 @@ operator std::error_condition() const;
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Returns: :: `std::error_condition( val_, *cat_ )`.
|
Returns: ::
|
||||||
|
`std::error_condition( val_, *cat_ )`.
|
||||||
|
|
||||||
### Nonmember functions
|
### Nonmember functions
|
||||||
|
|
||||||
@@ -882,7 +887,8 @@ std::size_t hash_value( const error_code & ec );
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Returns: :: A hash value representing `ec`.
|
Returns: ::
|
||||||
|
A hash value representing `ec`.
|
||||||
|
|
||||||
## <boost/system/system_error.hpp>
|
## <boost/system/system_error.hpp>
|
||||||
|
|
||||||
@@ -941,7 +947,8 @@ system_error( int ev, const error_category & ecat );
|
|||||||
[none]
|
[none]
|
||||||
* {blank}
|
* {blank}
|
||||||
+
|
+
|
||||||
Ensures: :: `code() == error_code( ev, ecat )`.
|
Ensures: ::
|
||||||
|
`code() == error_code( ev, ecat )`.
|
||||||
|
|
||||||
#### Observers
|
#### Observers
|
||||||
|
|
||||||
|
|||||||
+4
-320
@@ -7,325 +7,9 @@
|
|||||||
|
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
#ifndef BOOST_SYSTEM_CERRNO_HPP
|
#ifndef BOOST_CERRNO_HPP_INCLUDED
|
||||||
#define BOOST_SYSTEM_CERRNO_HPP
|
#define BOOST_CERRNO_HPP_INCLUDED
|
||||||
|
|
||||||
#include <cerrno>
|
#include <boost/system/detail/cerrno.hpp>
|
||||||
|
|
||||||
// supply errno values likely to be missing, particularly on Windows
|
#endif // #ifndef BOOST_CERRNO_HPP_INCLUDED
|
||||||
|
|
||||||
#ifndef EAFNOSUPPORT
|
|
||||||
#define EAFNOSUPPORT 9901
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EADDRINUSE
|
|
||||||
#define EADDRINUSE 9902
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EADDRNOTAVAIL
|
|
||||||
#define EADDRNOTAVAIL 9903
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EISCONN
|
|
||||||
#define EISCONN 9904
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EBADMSG
|
|
||||||
#define EBADMSG 9905
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ECONNABORTED
|
|
||||||
#define ECONNABORTED 9906
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EALREADY
|
|
||||||
#define EALREADY 9907
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ECONNREFUSED
|
|
||||||
#define ECONNREFUSED 9908
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ECONNRESET
|
|
||||||
#define ECONNRESET 9909
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EDESTADDRREQ
|
|
||||||
#define EDESTADDRREQ 9910
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EHOSTUNREACH
|
|
||||||
#define EHOSTUNREACH 9911
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EIDRM
|
|
||||||
#define EIDRM 9912
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EMSGSIZE
|
|
||||||
#define EMSGSIZE 9913
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENETDOWN
|
|
||||||
#define ENETDOWN 9914
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENETRESET
|
|
||||||
#define ENETRESET 9915
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENETUNREACH
|
|
||||||
#define ENETUNREACH 9916
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOBUFS
|
|
||||||
#define ENOBUFS 9917
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOLINK
|
|
||||||
#define ENOLINK 9918
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENODATA
|
|
||||||
#define ENODATA 9919
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOMSG
|
|
||||||
#define ENOMSG 9920
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOPROTOOPT
|
|
||||||
#define ENOPROTOOPT 9921
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOSR
|
|
||||||
#define ENOSR 9922
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTSOCK
|
|
||||||
#define ENOTSOCK 9923
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOSTR
|
|
||||||
#define ENOSTR 9924
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTCONN
|
|
||||||
#define ENOTCONN 9925
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTSUP
|
|
||||||
#define ENOTSUP 9926
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ECANCELED
|
|
||||||
#define ECANCELED 9927
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EINPROGRESS
|
|
||||||
#define EINPROGRESS 9928
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EOPNOTSUPP
|
|
||||||
#define EOPNOTSUPP 9929
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EWOULDBLOCK
|
|
||||||
#define EWOULDBLOCK 9930
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EOWNERDEAD
|
|
||||||
#define EOWNERDEAD 9931
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EPROTO
|
|
||||||
#define EPROTO 9932
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EPROTONOSUPPORT
|
|
||||||
#define EPROTONOSUPPORT 9933
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTRECOVERABLE
|
|
||||||
#define ENOTRECOVERABLE 9934
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ETIME
|
|
||||||
#define ETIME 9935
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ETXTBSY
|
|
||||||
#define ETXTBSY 9936
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ETIMEDOUT
|
|
||||||
#define ETIMEDOUT 9938
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ELOOP
|
|
||||||
#define ELOOP 9939
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EOVERFLOW
|
|
||||||
#define EOVERFLOW 9940
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EPROTOTYPE
|
|
||||||
#define EPROTOTYPE 9941
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOSYS
|
|
||||||
#define ENOSYS 9942
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EINVAL
|
|
||||||
#define EINVAL 9943
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ERANGE
|
|
||||||
#define ERANGE 9944
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EILSEQ
|
|
||||||
#define EILSEQ 9945
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Windows Mobile doesn't appear to define these:
|
|
||||||
|
|
||||||
#ifndef E2BIG
|
|
||||||
#define E2BIG 9946
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EDOM
|
|
||||||
#define EDOM 9947
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EFAULT
|
|
||||||
#define EFAULT 9948
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EBADF
|
|
||||||
#define EBADF 9949
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EPIPE
|
|
||||||
#define EPIPE 9950
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EXDEV
|
|
||||||
#define EXDEV 9951
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EBUSY
|
|
||||||
#define EBUSY 9952
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTEMPTY
|
|
||||||
#define ENOTEMPTY 9953
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOEXEC
|
|
||||||
#define ENOEXEC 9954
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EEXIST
|
|
||||||
#define EEXIST 9955
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EFBIG
|
|
||||||
#define EFBIG 9956
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENAMETOOLONG
|
|
||||||
#define ENAMETOOLONG 9957
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTTY
|
|
||||||
#define ENOTTY 9958
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EINTR
|
|
||||||
#define EINTR 9959
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ESPIPE
|
|
||||||
#define ESPIPE 9960
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EIO
|
|
||||||
#define EIO 9961
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EISDIR
|
|
||||||
#define EISDIR 9962
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ECHILD
|
|
||||||
#define ECHILD 9963
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOLCK
|
|
||||||
#define ENOLCK 9964
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOSPC
|
|
||||||
#define ENOSPC 9965
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENXIO
|
|
||||||
#define ENXIO 9966
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENODEV
|
|
||||||
#define ENODEV 9967
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOENT
|
|
||||||
#define ENOENT 9968
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ESRCH
|
|
||||||
#define ESRCH 9969
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOTDIR
|
|
||||||
#define ENOTDIR 9970
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENOMEM
|
|
||||||
#define ENOMEM 9971
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EPERM
|
|
||||||
#define EPERM 9972
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EACCES
|
|
||||||
#define EACCES 9973
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EROFS
|
|
||||||
#define EROFS 9974
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EDEADLK
|
|
||||||
#define EDEADLK 9975
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EAGAIN
|
|
||||||
#define EAGAIN 9976
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENFILE
|
|
||||||
#define ENFILE 9977
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EMFILE
|
|
||||||
#define EMFILE 9978
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EMLINK
|
|
||||||
#define EMLINK 9979
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // include guard
|
|
||||||
|
|||||||
@@ -0,0 +1,329 @@
|
|||||||
|
// Copyright Beman Dawes 2005.
|
||||||
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#ifndef BOOST_SYSTEM_DETAIL_CERRNO_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_CERRNO_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
// supply errno values likely to be missing, particularly on Windows
|
||||||
|
|
||||||
|
#ifndef EAFNOSUPPORT
|
||||||
|
#define EAFNOSUPPORT 9901
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EADDRINUSE
|
||||||
|
#define EADDRINUSE 9902
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EADDRNOTAVAIL
|
||||||
|
#define EADDRNOTAVAIL 9903
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EISCONN
|
||||||
|
#define EISCONN 9904
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EBADMSG
|
||||||
|
#define EBADMSG 9905
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ECONNABORTED
|
||||||
|
#define ECONNABORTED 9906
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EALREADY
|
||||||
|
#define EALREADY 9907
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ECONNREFUSED
|
||||||
|
#define ECONNREFUSED 9908
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ECONNRESET
|
||||||
|
#define ECONNRESET 9909
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EDESTADDRREQ
|
||||||
|
#define EDESTADDRREQ 9910
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EHOSTUNREACH
|
||||||
|
#define EHOSTUNREACH 9911
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EIDRM
|
||||||
|
#define EIDRM 9912
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EMSGSIZE
|
||||||
|
#define EMSGSIZE 9913
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENETDOWN
|
||||||
|
#define ENETDOWN 9914
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENETRESET
|
||||||
|
#define ENETRESET 9915
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENETUNREACH
|
||||||
|
#define ENETUNREACH 9916
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOBUFS
|
||||||
|
#define ENOBUFS 9917
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOLINK
|
||||||
|
#define ENOLINK 9918
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENODATA
|
||||||
|
#define ENODATA 9919
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOMSG
|
||||||
|
#define ENOMSG 9920
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOPROTOOPT
|
||||||
|
#define ENOPROTOOPT 9921
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOSR
|
||||||
|
#define ENOSR 9922
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTSOCK
|
||||||
|
#define ENOTSOCK 9923
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOSTR
|
||||||
|
#define ENOSTR 9924
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTCONN
|
||||||
|
#define ENOTCONN 9925
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTSUP
|
||||||
|
#define ENOTSUP 9926
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ECANCELED
|
||||||
|
#define ECANCELED 9927
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EINPROGRESS
|
||||||
|
#define EINPROGRESS 9928
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EOPNOTSUPP
|
||||||
|
#define EOPNOTSUPP 9929
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EWOULDBLOCK
|
||||||
|
#define EWOULDBLOCK 9930
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EOWNERDEAD
|
||||||
|
#define EOWNERDEAD 9931
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPROTO
|
||||||
|
#define EPROTO 9932
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPROTONOSUPPORT
|
||||||
|
#define EPROTONOSUPPORT 9933
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTRECOVERABLE
|
||||||
|
#define ENOTRECOVERABLE 9934
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ETIME
|
||||||
|
#define ETIME 9935
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ETXTBSY
|
||||||
|
#define ETXTBSY 9936
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ETIMEDOUT
|
||||||
|
#define ETIMEDOUT 9938
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ELOOP
|
||||||
|
#define ELOOP 9939
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EOVERFLOW
|
||||||
|
#define EOVERFLOW 9940
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPROTOTYPE
|
||||||
|
#define EPROTOTYPE 9941
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOSYS
|
||||||
|
#define ENOSYS 9942
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EINVAL
|
||||||
|
#define EINVAL 9943
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ERANGE
|
||||||
|
#define ERANGE 9944
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EILSEQ
|
||||||
|
#define EILSEQ 9945
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Windows Mobile doesn't appear to define these:
|
||||||
|
|
||||||
|
#ifndef E2BIG
|
||||||
|
#define E2BIG 9946
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EDOM
|
||||||
|
#define EDOM 9947
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EFAULT
|
||||||
|
#define EFAULT 9948
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EBADF
|
||||||
|
#define EBADF 9949
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPIPE
|
||||||
|
#define EPIPE 9950
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EXDEV
|
||||||
|
#define EXDEV 9951
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EBUSY
|
||||||
|
#define EBUSY 9952
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTEMPTY
|
||||||
|
#define ENOTEMPTY 9953
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOEXEC
|
||||||
|
#define ENOEXEC 9954
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EEXIST
|
||||||
|
#define EEXIST 9955
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EFBIG
|
||||||
|
#define EFBIG 9956
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENAMETOOLONG
|
||||||
|
#define ENAMETOOLONG 9957
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTTY
|
||||||
|
#define ENOTTY 9958
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EINTR
|
||||||
|
#define EINTR 9959
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ESPIPE
|
||||||
|
#define ESPIPE 9960
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EIO
|
||||||
|
#define EIO 9961
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EISDIR
|
||||||
|
#define EISDIR 9962
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ECHILD
|
||||||
|
#define ECHILD 9963
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOLCK
|
||||||
|
#define ENOLCK 9964
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOSPC
|
||||||
|
#define ENOSPC 9965
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENXIO
|
||||||
|
#define ENXIO 9966
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENODEV
|
||||||
|
#define ENODEV 9967
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOENT
|
||||||
|
#define ENOENT 9968
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ESRCH
|
||||||
|
#define ESRCH 9969
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTDIR
|
||||||
|
#define ENOTDIR 9970
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOMEM
|
||||||
|
#define ENOMEM 9971
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EPERM
|
||||||
|
#define EPERM 9972
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EACCES
|
||||||
|
#define EACCES 9973
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EROFS
|
||||||
|
#define EROFS 9974
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EDEADLK
|
||||||
|
#define EDEADLK 9975
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EAGAIN
|
||||||
|
#define EAGAIN 9976
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENFILE
|
||||||
|
#define ENFILE 9977
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EMFILE
|
||||||
|
#define EMFILE 9978
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EMLINK
|
||||||
|
#define EMLINK 9979
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_CERRNO_HPP_INCLUDED
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<bool C, class T = void> struct enable_if
|
||||||
|
{
|
||||||
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T> struct enable_if<false, T>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018, 2020
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/is_error_condition_enum.hpp>
|
||||||
|
#include <boost/system/detail/cerrno.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace errc
|
||||||
|
{
|
||||||
|
|
||||||
|
enum errc_t
|
||||||
|
{
|
||||||
|
success = 0,
|
||||||
|
address_family_not_supported = EAFNOSUPPORT,
|
||||||
|
address_in_use = EADDRINUSE,
|
||||||
|
address_not_available = EADDRNOTAVAIL,
|
||||||
|
already_connected = EISCONN,
|
||||||
|
argument_list_too_long = E2BIG,
|
||||||
|
argument_out_of_domain = EDOM,
|
||||||
|
bad_address = EFAULT,
|
||||||
|
bad_file_descriptor = EBADF,
|
||||||
|
bad_message = EBADMSG,
|
||||||
|
broken_pipe = EPIPE,
|
||||||
|
connection_aborted = ECONNABORTED,
|
||||||
|
connection_already_in_progress = EALREADY,
|
||||||
|
connection_refused = ECONNREFUSED,
|
||||||
|
connection_reset = ECONNRESET,
|
||||||
|
cross_device_link = EXDEV,
|
||||||
|
destination_address_required = EDESTADDRREQ,
|
||||||
|
device_or_resource_busy = EBUSY,
|
||||||
|
directory_not_empty = ENOTEMPTY,
|
||||||
|
executable_format_error = ENOEXEC,
|
||||||
|
file_exists = EEXIST,
|
||||||
|
file_too_large = EFBIG,
|
||||||
|
filename_too_long = ENAMETOOLONG,
|
||||||
|
function_not_supported = ENOSYS,
|
||||||
|
host_unreachable = EHOSTUNREACH,
|
||||||
|
identifier_removed = EIDRM,
|
||||||
|
illegal_byte_sequence = EILSEQ,
|
||||||
|
inappropriate_io_control_operation = ENOTTY,
|
||||||
|
interrupted = EINTR,
|
||||||
|
invalid_argument = EINVAL,
|
||||||
|
invalid_seek = ESPIPE,
|
||||||
|
io_error = EIO,
|
||||||
|
is_a_directory = EISDIR,
|
||||||
|
message_size = EMSGSIZE,
|
||||||
|
network_down = ENETDOWN,
|
||||||
|
network_reset = ENETRESET,
|
||||||
|
network_unreachable = ENETUNREACH,
|
||||||
|
no_buffer_space = ENOBUFS,
|
||||||
|
no_child_process = ECHILD,
|
||||||
|
no_link = ENOLINK,
|
||||||
|
no_lock_available = ENOLCK,
|
||||||
|
no_message_available = ENODATA,
|
||||||
|
no_message = ENOMSG,
|
||||||
|
no_protocol_option = ENOPROTOOPT,
|
||||||
|
no_space_on_device = ENOSPC,
|
||||||
|
no_stream_resources = ENOSR,
|
||||||
|
no_such_device_or_address = ENXIO,
|
||||||
|
no_such_device = ENODEV,
|
||||||
|
no_such_file_or_directory = ENOENT,
|
||||||
|
no_such_process = ESRCH,
|
||||||
|
not_a_directory = ENOTDIR,
|
||||||
|
not_a_socket = ENOTSOCK,
|
||||||
|
not_a_stream = ENOSTR,
|
||||||
|
not_connected = ENOTCONN,
|
||||||
|
not_enough_memory = ENOMEM,
|
||||||
|
not_supported = ENOTSUP,
|
||||||
|
operation_canceled = ECANCELED,
|
||||||
|
operation_in_progress = EINPROGRESS,
|
||||||
|
operation_not_permitted = EPERM,
|
||||||
|
operation_not_supported = EOPNOTSUPP,
|
||||||
|
operation_would_block = EWOULDBLOCK,
|
||||||
|
owner_dead = EOWNERDEAD,
|
||||||
|
permission_denied = EACCES,
|
||||||
|
protocol_error = EPROTO,
|
||||||
|
protocol_not_supported = EPROTONOSUPPORT,
|
||||||
|
read_only_file_system = EROFS,
|
||||||
|
resource_deadlock_would_occur = EDEADLK,
|
||||||
|
resource_unavailable_try_again = EAGAIN,
|
||||||
|
result_out_of_range = ERANGE,
|
||||||
|
state_not_recoverable = ENOTRECOVERABLE,
|
||||||
|
stream_timeout = ETIME,
|
||||||
|
text_file_busy = ETXTBSY,
|
||||||
|
timed_out = ETIMEDOUT,
|
||||||
|
too_many_files_open_in_system = ENFILE,
|
||||||
|
too_many_files_open = EMFILE,
|
||||||
|
too_many_links = EMLINK,
|
||||||
|
too_many_symbolic_link_levels = ELOOP,
|
||||||
|
value_too_large = EOVERFLOW,
|
||||||
|
wrong_protocol_type = EPROTOTYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace errc
|
||||||
|
|
||||||
|
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||||
|
|
||||||
|
namespace posix = errc;
|
||||||
|
namespace posix_error = errc;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<> struct is_error_condition_enum<errc::errc_t>
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
|
||||||
@@ -0,0 +1,189 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
# include <system_error>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
class error_category;
|
||||||
|
class error_code;
|
||||||
|
class error_condition;
|
||||||
|
|
||||||
|
std::size_t hash_value( error_code const & ec );
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool failed_impl( int ev, error_category const & cat );
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
|
std::error_category const & to_std_category( error_category const & cat );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class BOOST_SYMBOL_VISIBLE error_category
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend std::size_t hash_value( error_code const & ec );
|
||||||
|
friend BOOST_SYSTEM_CONSTEXPR bool detail::failed_impl( int ev, error_category const & cat );
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
friend std::error_category const & detail::to_std_category( error_category const & cat );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||||
|
public:
|
||||||
|
|
||||||
|
error_category( error_category const & ) = delete;
|
||||||
|
error_category& operator=( error_category const & ) = delete;
|
||||||
|
|
||||||
|
#else
|
||||||
|
private:
|
||||||
|
|
||||||
|
error_category( error_category const & );
|
||||||
|
error_category& operator=( error_category const & );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
boost::ulong_long_type id_;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
||||||
|
|
||||||
|
~error_category() = default;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// We'd like to make the destructor protected, to make code that deletes
|
||||||
|
// an error_category* not compile; unfortunately, doing the below makes
|
||||||
|
// the destructor user-provided and hence breaks use after main, as the
|
||||||
|
// categories may get destroyed before code that uses them
|
||||||
|
|
||||||
|
// ~error_category() {}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual const char * name() const BOOST_NOEXCEPT = 0;
|
||||||
|
|
||||||
|
virtual error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
|
||||||
|
virtual bool equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT;
|
||||||
|
virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT;
|
||||||
|
|
||||||
|
virtual std::string message( int ev ) const = 0;
|
||||||
|
virtual char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
|
||||||
|
|
||||||
|
virtual bool failed( int ev ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return ev != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return rhs.id_ == 0? this == &rhs: id_ == rhs.id_;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return !( *this == rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
if( id_ < rhs.id_ )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( id_ > rhs.id_ )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( rhs.id_ != 0 )
|
||||||
|
{
|
||||||
|
return false; // equal
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::less<error_category const *>()( this, &rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
|
operator std::error_category const & () const;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D;
|
||||||
|
static const boost::ulong_long_type system_category_id = ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B;
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
|
||||||
|
{
|
||||||
|
if( cat.id_ == system_category_id || cat.id_ == generic_category_id )
|
||||||
|
{
|
||||||
|
return ev != 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return cat.failed( ev );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
|
#include <boost/system/detail/error_code.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
// error_category default implementation
|
||||||
|
|
||||||
|
inline error_condition error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return error_condition( ev, *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool error_category::equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return default_error_condition( code ) == condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool error_category::equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return *this == code.category() && code.value() == condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
if( len == 0 )
|
||||||
|
{
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( len == 1 )
|
||||||
|
{
|
||||||
|
buffer[0] = 0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||||
|
try
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
std::string m = this->message( ev );
|
||||||
|
|
||||||
|
# if defined( BOOST_MSVC )
|
||||||
|
# pragma warning( push )
|
||||||
|
# pragma warning( disable: 4996 )
|
||||||
|
# elif defined(__clang__) && defined(__has_warning)
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# if __has_warning("-Wdeprecated-declarations")
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
std::strncpy( buffer, m.c_str(), len - 1 );
|
||||||
|
buffer[ len-1 ] = 0;
|
||||||
|
|
||||||
|
# if defined( BOOST_MSVC )
|
||||||
|
# pragma warning( pop )
|
||||||
|
# elif defined(__clang__) && defined(__has_warning)
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
return "Message text unavailable";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
// interoperability with std::error_code, std::error_condition
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
|
#include <boost/system/detail/to_std_category.hpp>
|
||||||
|
|
||||||
|
inline boost::system::error_category::operator std::error_category const & () const
|
||||||
|
{
|
||||||
|
return boost::system::detail::to_std_category( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
|
#include <boost/system/detail/system_category.hpp>
|
||||||
|
#include <boost/system/detail/enable_if.hpp>
|
||||||
|
#include <boost/system/is_error_code_enum.hpp>
|
||||||
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
// class error_code
|
||||||
|
|
||||||
|
// We want error_code to be a value type that can be copied without slicing
|
||||||
|
// and without requiring heap allocation, but we also want it to have
|
||||||
|
// polymorphic behavior based on the error category. This is achieved by
|
||||||
|
// abstract base class error_category supplying the polymorphic behavior,
|
||||||
|
// and error_code containing a pointer to an object of a type derived
|
||||||
|
// from error_category.
|
||||||
|
|
||||||
|
class error_code
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
int val_;
|
||||||
|
bool failed_;
|
||||||
|
const error_category * cat_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// constructors:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
|
||||||
|
val_( 0 ), failed_( false ), cat_( &system_category() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||||
|
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
|
||||||
|
typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type* = 0 ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
*this = make_error_code( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
// modifiers:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
val_ = val;
|
||||||
|
failed_ = detail::failed_impl( val, cat );
|
||||||
|
cat_ = &cat;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ErrorCodeEnum>
|
||||||
|
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type &
|
||||||
|
operator=( ErrorCodeEnum val ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
*this = make_error_code( val );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
val_ = 0;
|
||||||
|
failed_ = false;
|
||||||
|
cat_ = &system_category();
|
||||||
|
}
|
||||||
|
|
||||||
|
// observers:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return val_;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return *cat_;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_condition default_error_condition() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return cat_->default_error_condition( value() );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message() const
|
||||||
|
{
|
||||||
|
return cat_->message( value() );
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return cat_->message( value(), buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return failed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||||
|
{
|
||||||
|
return failed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef void (*unspecified_bool_type)();
|
||||||
|
static void unspecified_bool_true() {}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||||
|
{
|
||||||
|
return failed_? unspecified_bool_true: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||||
|
{
|
||||||
|
return !failed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// relationals:
|
||||||
|
|
||||||
|
// the more symmetrical non-member syntax allows enum
|
||||||
|
// conversions work for both rhs and lhs.
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
|
operator std::error_code () const
|
||||||
|
{
|
||||||
|
return std::error_code( value(), category() );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return !( lhs == rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Ch, class Tr>
|
||||||
|
inline std::basic_ostream<Ch, Tr>&
|
||||||
|
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||||
|
{
|
||||||
|
os << ec.category().name() << ':' << ec.value();
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::size_t hash_value( error_code const & ec )
|
||||||
|
{
|
||||||
|
error_category const & cat = ec.category();
|
||||||
|
|
||||||
|
boost::ulong_long_type id_ = cat.id_;
|
||||||
|
|
||||||
|
if( id_ == 0 )
|
||||||
|
{
|
||||||
|
id_ = reinterpret_cast<boost::uintptr_t>( &cat );
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::ulong_long_type hv = ( boost::ulong_long_type( 0xCBF29CE4 ) << 32 ) + 0x84222325;
|
||||||
|
boost::ulong_long_type const prime = ( boost::ulong_long_type( 0x00000100 ) << 32 ) + 0x000001B3;
|
||||||
|
|
||||||
|
// id
|
||||||
|
|
||||||
|
hv ^= id_;
|
||||||
|
hv *= prime;
|
||||||
|
|
||||||
|
// value
|
||||||
|
|
||||||
|
hv ^= static_cast<unsigned>( ec.value() );
|
||||||
|
hv *= prime;
|
||||||
|
|
||||||
|
return static_cast<std::size_t>( hv );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CONDITION_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_ERROR_CONDITION_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/generic_category.hpp>
|
||||||
|
#include <boost/system/detail/enable_if.hpp>
|
||||||
|
#include <boost/system/is_error_condition_enum.hpp>
|
||||||
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
// class error_condition
|
||||||
|
|
||||||
|
// error_conditions are portable, error_codes are system or library specific
|
||||||
|
|
||||||
|
class error_condition
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
int val_;
|
||||||
|
bool failed_;
|
||||||
|
error_category const * cat_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// constructors:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
||||||
|
val_( 0 ), failed_( false ), cat_( &generic_category() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||||
|
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
|
||||||
|
typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type* = 0) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
*this = make_error_condition( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
// modifiers:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
val_ = val;
|
||||||
|
failed_ = detail::failed_impl( val, cat );
|
||||||
|
cat_ = &cat;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ErrorConditionEnum>
|
||||||
|
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
|
||||||
|
operator=( ErrorConditionEnum val ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
*this = make_error_condition( val );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
val_ = 0;
|
||||||
|
failed_ = false;
|
||||||
|
cat_ = &generic_category();
|
||||||
|
}
|
||||||
|
|
||||||
|
// observers:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return val_;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return *cat_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message() const
|
||||||
|
{
|
||||||
|
return cat_->message( value() );
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return cat_->message( value(), buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return failed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||||
|
{
|
||||||
|
return failed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef void (*unspecified_bool_type)();
|
||||||
|
static void unspecified_bool_true() {}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||||
|
{
|
||||||
|
return failed_? unspecified_bool_true: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||||
|
{
|
||||||
|
return !failed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// relationals:
|
||||||
|
// the more symmetrical non-member syntax allows enum
|
||||||
|
// conversions work for both rhs and lhs.
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||||
|
|
||||||
|
operator std::error_condition () const
|
||||||
|
{
|
||||||
|
return std::error_condition( value(), category() );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return !( lhs == rhs );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CONDITION_HPP_INCLUDED
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
// Implementation details of generic_error_category
|
#ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_HPP_INCLUDED
|
||||||
//
|
#define BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_HPP_INCLUDED
|
||||||
// Copyright 2018 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// See library home page at http://www.boost.org/libs/system
|
|
||||||
|
|
||||||
#include <cstring>
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/generic_category_message.hpp>
|
||||||
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@@ -18,84 +24,100 @@ namespace system
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(__GLIBC__)
|
// generic_error_category
|
||||||
|
|
||||||
// glibc has two incompatible strerror_r definitions
|
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
|
#endif
|
||||||
|
|
||||||
inline char const * strerror_r_helper( char const * r, char const * ) BOOST_NOEXCEPT
|
class BOOST_SYMBOL_VISIBLE generic_error_category: public error_category
|
||||||
{
|
{
|
||||||
return r;
|
public:
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * strerror_r_helper( int r, char const * buffer ) BOOST_NOEXCEPT
|
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_NOEXCEPT:
|
||||||
{
|
error_category( detail::generic_category_id )
|
||||||
return r == 0? buffer: "Unknown error";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string generic_error_category_message( int ev )
|
|
||||||
{
|
|
||||||
char buffer[ 128 ];
|
|
||||||
return generic_error_category_message( ev, buffer, sizeof( buffer ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// std::strerror is thread-safe on everything else, incl. Windows
|
|
||||||
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( push )
|
|
||||||
# pragma warning( disable: 4996 )
|
|
||||||
# elif defined(__clang__) && defined(__has_warning)
|
|
||||||
# pragma clang diagnostic push
|
|
||||||
# if __has_warning("-Wdeprecated-declarations")
|
|
||||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
inline std::string generic_error_category_message( int ev )
|
|
||||||
{
|
|
||||||
char const * m = std::strerror( ev );
|
|
||||||
return m? m: "Unknown error";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
if( len == 0 )
|
|
||||||
{
|
{
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( len == 1 )
|
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||||
{
|
{
|
||||||
buffer[0] = 0;
|
return "generic";
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * m = std::strerror( ev );
|
std::string message( int ev ) const BOOST_OVERRIDE;
|
||||||
|
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
if( m == 0 ) return "Unknown error";
|
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
std::strncpy( buffer, m, len - 1 );
|
// generic_error_category::message
|
||||||
buffer[ len-1 ] = 0;
|
|
||||||
|
|
||||||
return buffer;
|
inline char const * generic_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return generic_error_category_message( ev, buffer, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined( BOOST_MSVC )
|
inline std::string generic_error_category::message( int ev ) const
|
||||||
# pragma warning( pop )
|
{
|
||||||
# elif defined(__clang__) && defined(__has_warning)
|
return generic_error_category_message( ev );
|
||||||
# pragma clang diagnostic pop
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
// generic_category()
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class T> struct BOOST_SYMBOL_VISIBLE generic_cat_holder
|
||||||
|
{
|
||||||
|
static constexpr generic_error_category instance{};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Before C++17 it was mandatory to redeclare all static constexpr
|
||||||
|
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||||
|
template<class T> constexpr generic_error_category generic_cat_holder<T>::instance;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
constexpr error_category const & generic_category() BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::generic_cat_holder<void>::instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||||
|
inline error_category const & generic_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline error_category const & generic_category() BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
static const detail::generic_error_category instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
// deprecated synonyms
|
||||||
|
|
||||||
|
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||||
|
|
||||||
|
inline const error_category & get_generic_category() { return generic_category(); }
|
||||||
|
inline const error_category & get_posix_category() { return generic_category(); }
|
||||||
|
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category();
|
||||||
|
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_HPP_INCLUDED
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Implementation of generic_error_category_message
|
||||||
|
//
|
||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(__GLIBC__)
|
||||||
|
|
||||||
|
// glibc has two incompatible strerror_r definitions
|
||||||
|
|
||||||
|
inline char const * strerror_r_helper( char const * r, char const * ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * strerror_r_helper( int r, char const * buffer ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return r == 0? buffer: "Unknown error";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string generic_error_category_message( int ev )
|
||||||
|
{
|
||||||
|
char buffer[ 128 ];
|
||||||
|
return generic_error_category_message( ev, buffer, sizeof( buffer ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // #if defined(__GLIBC__)
|
||||||
|
|
||||||
|
// std::strerror is thread-safe on everything else, incl. Windows
|
||||||
|
|
||||||
|
# if defined( BOOST_MSVC )
|
||||||
|
# pragma warning( push )
|
||||||
|
# pragma warning( disable: 4996 )
|
||||||
|
# elif defined(__clang__) && defined(__has_warning)
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# if __has_warning("-Wdeprecated-declarations")
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
inline std::string generic_error_category_message( int ev )
|
||||||
|
{
|
||||||
|
char const * m = std::strerror( ev );
|
||||||
|
return m? m: "Unknown error";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
if( len == 0 )
|
||||||
|
{
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( len == 1 )
|
||||||
|
{
|
||||||
|
buffer[0] = 0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * m = std::strerror( ev );
|
||||||
|
|
||||||
|
if( m == 0 ) return "Unknown error";
|
||||||
|
|
||||||
|
std::strncpy( buffer, m, len - 1 );
|
||||||
|
buffer[ len-1 ] = 0;
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
# if defined( BOOST_MSVC )
|
||||||
|
# pragma warning( pop )
|
||||||
|
# elif defined(__clang__) && defined(__has_warning)
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif // #if defined(__GLIBC__)
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||||
+7
-14
@@ -1,5 +1,6 @@
|
|||||||
// POSIX-specific implementation details of system_error_category
|
#ifndef BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
|
||||||
//
|
#define BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright 2018 Peter Dimov
|
// Copyright 2018 Peter Dimov
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
@@ -7,6 +8,8 @@
|
|||||||
//
|
//
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/errc.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -113,20 +116,10 @@ inline bool is_generic_value( int ev ) BOOST_NOEXCEPT
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline error_condition system_category_default_error_condition_posix( int ev ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
if( is_generic_value( ev ) )
|
|
||||||
{
|
|
||||||
return error_condition( ev, generic_category() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return error_condition( ev, system_category() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
// system_error_category
|
||||||
|
|
||||||
|
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
|
||||||
|
error_category( detail::system_category_id )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||||
|
{
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
|
||||||
|
error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||||
|
|
||||||
|
std::string message( int ev ) const BOOST_OVERRIDE;
|
||||||
|
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
// system_category()
|
||||||
|
|
||||||
|
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class T> struct BOOST_SYMBOL_VISIBLE system_cat_holder
|
||||||
|
{
|
||||||
|
static constexpr system_error_category instance{};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Before C++17 it was mandatory to redeclare all static constexpr
|
||||||
|
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||||
|
template<class T> constexpr system_error_category system_cat_holder<T>::instance;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
constexpr error_category const & system_category() BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return detail::system_cat_holder<void>::instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||||
|
inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline error_category const & system_category() BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
static const detail::system_error_category instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||||
|
|
||||||
|
// deprecated synonyms
|
||||||
|
|
||||||
|
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||||
|
|
||||||
|
inline const error_category & get_system_category() { return system_category(); }
|
||||||
|
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2002, 2006
|
||||||
|
// Copyright (c) Microsoft Corporation 2014
|
||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/errc.hpp>
|
||||||
|
#include <boost/winapi/error_codes.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
// When using the Windows Runtime, most system errors are reported as HRESULTs.
|
||||||
|
// We want to map the common Win32 errors to their equivalent error condition,
|
||||||
|
// whether or not they are reported via an HRESULT.
|
||||||
|
|
||||||
|
#define BOOST_SYSTEM_FAILED(hr) ((hr) < 0)
|
||||||
|
#define BOOST_SYSTEM_HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
|
||||||
|
#define BOOST_SYSTEM_HRESULT_CODE(hr) ((hr) & 0xFFFF)
|
||||||
|
#define BOOST_SYSTEM_FACILITY_WIN32 7
|
||||||
|
|
||||||
|
if( BOOST_SYSTEM_FAILED( ev ) && BOOST_SYSTEM_HRESULT_FACILITY( ev ) == BOOST_SYSTEM_FACILITY_WIN32 )
|
||||||
|
{
|
||||||
|
ev = BOOST_SYSTEM_HRESULT_CODE( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef BOOST_SYSTEM_FAILED
|
||||||
|
#undef BOOST_SYSTEM_HRESULT_FACILITY
|
||||||
|
#undef BOOST_SYSTEM_HRESULT_CODE
|
||||||
|
#undef BOOST_SYSTEM_FACILITY_WIN32
|
||||||
|
|
||||||
|
using namespace boost::winapi;
|
||||||
|
using namespace errc;
|
||||||
|
|
||||||
|
// Windows system -> posix_errno decode table
|
||||||
|
// see WinError.h comments for descriptions of errors
|
||||||
|
|
||||||
|
switch ( ev )
|
||||||
|
{
|
||||||
|
case 0: return success;
|
||||||
|
|
||||||
|
case ERROR_ACCESS_DENIED_: return permission_denied;
|
||||||
|
case ERROR_ALREADY_EXISTS_: return file_exists;
|
||||||
|
case ERROR_BAD_UNIT_: return no_such_device;
|
||||||
|
case ERROR_BUFFER_OVERFLOW_: return filename_too_long;
|
||||||
|
case ERROR_BUSY_: return device_or_resource_busy;
|
||||||
|
case ERROR_BUSY_DRIVE_: return device_or_resource_busy;
|
||||||
|
case ERROR_CANNOT_MAKE_: return permission_denied;
|
||||||
|
case ERROR_CANTOPEN_: return io_error;
|
||||||
|
case ERROR_CANTREAD_: return io_error;
|
||||||
|
case ERROR_CANTWRITE_: return io_error;
|
||||||
|
case ERROR_CONNECTION_ABORTED_: return connection_aborted;
|
||||||
|
case ERROR_CURRENT_DIRECTORY_: return permission_denied;
|
||||||
|
case ERROR_DEV_NOT_EXIST_: return no_such_device;
|
||||||
|
case ERROR_DEVICE_IN_USE_: return device_or_resource_busy;
|
||||||
|
case ERROR_DIR_NOT_EMPTY_: return directory_not_empty;
|
||||||
|
case ERROR_DIRECTORY_: return invalid_argument; // WinError.h: "The directory name is invalid"
|
||||||
|
case ERROR_DISK_FULL_: return no_space_on_device;
|
||||||
|
case ERROR_FILE_EXISTS_: return file_exists;
|
||||||
|
case ERROR_FILE_NOT_FOUND_: return no_such_file_or_directory;
|
||||||
|
case ERROR_HANDLE_DISK_FULL_: return no_space_on_device;
|
||||||
|
case ERROR_INVALID_ACCESS_: return permission_denied;
|
||||||
|
case ERROR_INVALID_DRIVE_: return no_such_device;
|
||||||
|
case ERROR_INVALID_FUNCTION_: return function_not_supported;
|
||||||
|
case ERROR_INVALID_HANDLE_: return invalid_argument;
|
||||||
|
case ERROR_INVALID_NAME_: return invalid_argument;
|
||||||
|
case ERROR_LOCK_VIOLATION_: return no_lock_available;
|
||||||
|
case ERROR_LOCKED_: return no_lock_available;
|
||||||
|
case ERROR_NEGATIVE_SEEK_: return invalid_argument;
|
||||||
|
case ERROR_NOACCESS_: return permission_denied;
|
||||||
|
case ERROR_NOT_ENOUGH_MEMORY_: return not_enough_memory;
|
||||||
|
case ERROR_NOT_READY_: return resource_unavailable_try_again;
|
||||||
|
case ERROR_NOT_SAME_DEVICE_: return cross_device_link;
|
||||||
|
case ERROR_OPEN_FAILED_: return io_error;
|
||||||
|
case ERROR_OPEN_FILES_: return device_or_resource_busy;
|
||||||
|
case ERROR_OPERATION_ABORTED_: return operation_canceled;
|
||||||
|
case ERROR_OUTOFMEMORY_: return not_enough_memory;
|
||||||
|
case ERROR_PATH_NOT_FOUND_: return no_such_file_or_directory;
|
||||||
|
case ERROR_READ_FAULT_: return io_error;
|
||||||
|
case ERROR_RETRY_: return resource_unavailable_try_again;
|
||||||
|
case ERROR_SEEK_: return io_error;
|
||||||
|
case ERROR_SHARING_VIOLATION_: return permission_denied;
|
||||||
|
case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
|
||||||
|
case ERROR_WRITE_FAULT_: return io_error;
|
||||||
|
case ERROR_WRITE_PROTECT_: return permission_denied;
|
||||||
|
|
||||||
|
case WSAEACCES_: return permission_denied;
|
||||||
|
case WSAEADDRINUSE_: return address_in_use;
|
||||||
|
case WSAEADDRNOTAVAIL_: return address_not_available;
|
||||||
|
case WSAEAFNOSUPPORT_: return address_family_not_supported;
|
||||||
|
case WSAEALREADY_: return connection_already_in_progress;
|
||||||
|
case WSAEBADF_: return bad_file_descriptor;
|
||||||
|
case WSAECONNABORTED_: return connection_aborted;
|
||||||
|
case WSAECONNREFUSED_: return connection_refused;
|
||||||
|
case WSAECONNRESET_: return connection_reset;
|
||||||
|
case WSAEDESTADDRREQ_: return destination_address_required;
|
||||||
|
case WSAEFAULT_: return bad_address;
|
||||||
|
case WSAEHOSTUNREACH_: return host_unreachable;
|
||||||
|
case WSAEINPROGRESS_: return operation_in_progress;
|
||||||
|
case WSAEINTR_: return interrupted;
|
||||||
|
case WSAEINVAL_: return invalid_argument;
|
||||||
|
case WSAEISCONN_: return already_connected;
|
||||||
|
case WSAEMFILE_: return too_many_files_open;
|
||||||
|
case WSAEMSGSIZE_: return message_size;
|
||||||
|
case WSAENAMETOOLONG_: return filename_too_long;
|
||||||
|
case WSAENETDOWN_: return network_down;
|
||||||
|
case WSAENETRESET_: return network_reset;
|
||||||
|
case WSAENETUNREACH_: return network_unreachable;
|
||||||
|
case WSAENOBUFS_: return no_buffer_space;
|
||||||
|
case WSAENOPROTOOPT_: return no_protocol_option;
|
||||||
|
case WSAENOTCONN_: return not_connected;
|
||||||
|
case WSAENOTSOCK_: return not_a_socket;
|
||||||
|
case WSAEOPNOTSUPP_: return operation_not_supported;
|
||||||
|
case WSAEPROTONOSUPPORT_: return protocol_not_supported;
|
||||||
|
case WSAEPROTOTYPE_: return wrong_protocol_type;
|
||||||
|
case WSAETIMEDOUT_: return timed_out;
|
||||||
|
case WSAEWOULDBLOCK_: return operation_would_block;
|
||||||
|
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018, 2020
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/system_category.hpp>
|
||||||
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
|
#include <boost/system/detail/generic_category.hpp>
|
||||||
|
#include <boost/system/api_config.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
||||||
|
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// system_error_category implementation
|
||||||
|
|
||||||
|
#if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#include <boost/system/detail/system_category_message_win32.hpp>
|
||||||
|
#include <boost/system/detail/system_category_condition_win32.hpp>
|
||||||
|
|
||||||
|
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
int e2 = system_category_condition_win32( ev );
|
||||||
|
|
||||||
|
if( e2 == -1 )
|
||||||
|
{
|
||||||
|
return error_condition( ev, *this );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return error_condition( e2, generic_category() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||||
|
{
|
||||||
|
return system_category_message_win32( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return system_category_message_win32( ev, buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#include <boost/system/detail/generic_category_message.hpp>
|
||||||
|
#include <boost/system/detail/is_generic_value.hpp>
|
||||||
|
|
||||||
|
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
if( is_generic_value( ev ) )
|
||||||
|
{
|
||||||
|
return error_condition( ev, generic_category() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return error_condition( ev, *this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||||
|
{
|
||||||
|
return generic_error_category_message( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return generic_error_category_message( ev, buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
|
||||||
@@ -0,0 +1,233 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_WIN32_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_WIN32_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2002, 2006
|
||||||
|
// Copyright (c) Microsoft Corporation 2014
|
||||||
|
// Copyright 2018, 2020 Peter Dimov
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/winapi/error_handling.hpp>
|
||||||
|
#include <boost/winapi/character_code_conversion.hpp>
|
||||||
|
#include <boost/winapi/local_memory.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
||||||
|
|
||||||
|
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
|
||||||
|
{
|
||||||
|
# if defined( BOOST_MSVC )
|
||||||
|
# pragma warning( push )
|
||||||
|
# pragma warning( disable: 4996 )
|
||||||
|
# endif
|
||||||
|
|
||||||
|
_snprintf( buffer, len - 1, "Unknown error (%d)", ev );
|
||||||
|
|
||||||
|
buffer[ len - 1 ] = 0;
|
||||||
|
return buffer;
|
||||||
|
|
||||||
|
# if defined( BOOST_MSVC )
|
||||||
|
# pragma warning( pop )
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
|
||||||
|
{
|
||||||
|
std::snprintf( buffer, len, "Unknown error (%d)", ev );
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline boost::winapi::UINT_ message_cp_win32()
|
||||||
|
{
|
||||||
|
#if defined(BOOST_SYSTEM_USE_UTF8)
|
||||||
|
|
||||||
|
return boost::winapi::CP_UTF8_;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
return boost::winapi::CP_ACP_;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char const * system_category_message_win32( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
if( len == 0 )
|
||||||
|
{
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( len == 1 )
|
||||||
|
{
|
||||||
|
buffer[0] = 0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::winapi::UINT_ const code_page = message_cp_win32();
|
||||||
|
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_ANSI_APIS)
|
||||||
|
|
||||||
|
if( code_page == boost::winapi::CP_ACP_ )
|
||||||
|
{
|
||||||
|
using namespace boost::winapi;
|
||||||
|
|
||||||
|
DWORD_ retval = boost::winapi::FormatMessageA(
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
||||||
|
NULL,
|
||||||
|
ev,
|
||||||
|
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
||||||
|
buffer,
|
||||||
|
static_cast<DWORD_>( len ),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
r = static_cast<int>( retval );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
using namespace boost::winapi;
|
||||||
|
|
||||||
|
wchar_t * lpMsgBuf = 0;
|
||||||
|
|
||||||
|
DWORD_ retval = boost::winapi::FormatMessageW(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
||||||
|
NULL,
|
||||||
|
ev,
|
||||||
|
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
||||||
|
(LPWSTR_) &lpMsgBuf,
|
||||||
|
0,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if( retval != 0 )
|
||||||
|
{
|
||||||
|
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, buffer, static_cast<int>( len ), NULL, NULL );
|
||||||
|
boost::winapi::LocalFree( lpMsgBuf );
|
||||||
|
if ( r != 0 ) --r; // exclude null terminator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( r == 0 )
|
||||||
|
{
|
||||||
|
return unknown_message_win32( ev, buffer, len );
|
||||||
|
}
|
||||||
|
|
||||||
|
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
|
||||||
|
{
|
||||||
|
buffer[ --r ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( r > 0 && buffer[ r-1 ] == '.' )
|
||||||
|
{
|
||||||
|
buffer[ --r ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct local_free
|
||||||
|
{
|
||||||
|
void * p_;
|
||||||
|
|
||||||
|
~local_free()
|
||||||
|
{
|
||||||
|
boost::winapi::LocalFree( p_ );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::string unknown_message_win32( int ev )
|
||||||
|
{
|
||||||
|
char buffer[ 38 ];
|
||||||
|
return unknown_message_win32( ev, buffer, sizeof( buffer ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string system_category_message_win32( int ev )
|
||||||
|
{
|
||||||
|
using namespace boost::winapi;
|
||||||
|
|
||||||
|
wchar_t * lpMsgBuf = 0;
|
||||||
|
|
||||||
|
DWORD_ retval = boost::winapi::FormatMessageW(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
||||||
|
NULL,
|
||||||
|
ev,
|
||||||
|
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
||||||
|
(LPWSTR_) &lpMsgBuf,
|
||||||
|
0,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if( retval == 0 )
|
||||||
|
{
|
||||||
|
return unknown_message_win32( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
local_free lf_ = { lpMsgBuf };
|
||||||
|
(void)lf_;
|
||||||
|
|
||||||
|
UINT_ const code_page = message_cp_win32();
|
||||||
|
|
||||||
|
int r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, 0, 0, NULL, NULL );
|
||||||
|
|
||||||
|
if( r == 0 )
|
||||||
|
{
|
||||||
|
return unknown_message_win32( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string buffer( r, char() );
|
||||||
|
|
||||||
|
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, &buffer[0], r, NULL, NULL );
|
||||||
|
|
||||||
|
if( r == 0 )
|
||||||
|
{
|
||||||
|
return unknown_message_win32( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
--r; // exclude null terminator
|
||||||
|
|
||||||
|
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
|
||||||
|
{
|
||||||
|
--r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( r > 0 && buffer[ r-1 ] == '.' )
|
||||||
|
{
|
||||||
|
--r;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.resize( r );
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_WIN32_HPP_INCLUDED
|
||||||
@@ -1,340 +0,0 @@
|
|||||||
// Windows implementation of system_error_category
|
|
||||||
//
|
|
||||||
// Copyright Beman Dawes 2002, 2006
|
|
||||||
// Copyright (c) Microsoft Corporation 2014
|
|
||||||
// Copyright 2018 Peter Dimov
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// See library home page at http://www.boost.org/libs/system
|
|
||||||
|
|
||||||
#include <boost/winapi/error_codes.hpp>
|
|
||||||
#include <boost/winapi/error_handling.hpp>
|
|
||||||
#include <boost/winapi/character_code_conversion.hpp>
|
|
||||||
#include <boost/winapi/local_memory.hpp>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace system
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
|
||||||
|
|
||||||
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
|
|
||||||
{
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( push )
|
|
||||||
# pragma warning( disable: 4996 )
|
|
||||||
# endif
|
|
||||||
|
|
||||||
_snprintf( buffer, len - 1, "Unknown error (%d)", ev );
|
|
||||||
|
|
||||||
buffer[ len - 1 ] = 0;
|
|
||||||
return buffer;
|
|
||||||
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( pop )
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
|
|
||||||
{
|
|
||||||
std::snprintf( buffer, len, "Unknown error (%d)", ev );
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline boost::winapi::UINT_ message_cp_win32()
|
|
||||||
{
|
|
||||||
#if defined(BOOST_SYSTEM_USE_UTF8)
|
|
||||||
|
|
||||||
return boost::winapi::CP_UTF8_;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return boost::winapi::CP_ACP_;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * system_category_message_win32( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
if( len == 0 )
|
|
||||||
{
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( len == 1 )
|
|
||||||
{
|
|
||||||
buffer[0] = 0;
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::winapi::UINT_ const code_page = message_cp_win32();
|
|
||||||
|
|
||||||
int r = 0;
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_ANSI_APIS)
|
|
||||||
|
|
||||||
if( code_page == boost::winapi::CP_ACP_ )
|
|
||||||
{
|
|
||||||
using namespace boost::winapi;
|
|
||||||
|
|
||||||
DWORD_ retval = boost::winapi::FormatMessageA(
|
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
|
||||||
NULL,
|
|
||||||
ev,
|
|
||||||
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
|
||||||
buffer,
|
|
||||||
static_cast<DWORD_>( len ),
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
r = static_cast<int>( retval );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
using namespace boost::winapi;
|
|
||||||
|
|
||||||
wchar_t * lpMsgBuf = 0;
|
|
||||||
|
|
||||||
DWORD_ retval = boost::winapi::FormatMessageW(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
|
||||||
NULL,
|
|
||||||
ev,
|
|
||||||
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
|
||||||
(LPWSTR_) &lpMsgBuf,
|
|
||||||
0,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
if( retval != 0 )
|
|
||||||
{
|
|
||||||
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, buffer, static_cast<int>( len ), NULL, NULL );
|
|
||||||
boost::winapi::LocalFree( lpMsgBuf );
|
|
||||||
if ( r != 0 ) --r; // exclude null terminator
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( r == 0 )
|
|
||||||
{
|
|
||||||
return unknown_message_win32( ev, buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
|
|
||||||
{
|
|
||||||
buffer[ --r ] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( r > 0 && buffer[ r-1 ] == '.' )
|
|
||||||
{
|
|
||||||
buffer[ --r ] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct local_free
|
|
||||||
{
|
|
||||||
void * p_;
|
|
||||||
|
|
||||||
~local_free()
|
|
||||||
{
|
|
||||||
boost::winapi::LocalFree( p_ );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
inline std::string unknown_message_win32( int ev )
|
|
||||||
{
|
|
||||||
char buffer[ 38 ];
|
|
||||||
return unknown_message_win32( ev, buffer, sizeof( buffer ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string system_category_message_win32( int ev )
|
|
||||||
{
|
|
||||||
using namespace boost::winapi;
|
|
||||||
|
|
||||||
wchar_t * lpMsgBuf = 0;
|
|
||||||
|
|
||||||
DWORD_ retval = boost::winapi::FormatMessageW(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
|
||||||
NULL,
|
|
||||||
ev,
|
|
||||||
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
|
||||||
(LPWSTR_) &lpMsgBuf,
|
|
||||||
0,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
if( retval == 0 )
|
|
||||||
{
|
|
||||||
return unknown_message_win32( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
local_free lf_ = { lpMsgBuf };
|
|
||||||
(void)lf_;
|
|
||||||
|
|
||||||
UINT_ const code_page = message_cp_win32();
|
|
||||||
|
|
||||||
int r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, 0, 0, NULL, NULL );
|
|
||||||
|
|
||||||
if( r == 0 )
|
|
||||||
{
|
|
||||||
return unknown_message_win32( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string buffer( r, char() );
|
|
||||||
|
|
||||||
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, &buffer[0], r, NULL, NULL );
|
|
||||||
|
|
||||||
if( r == 0 )
|
|
||||||
{
|
|
||||||
return unknown_message_win32( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
--r; // exclude null terminator
|
|
||||||
|
|
||||||
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
|
|
||||||
{
|
|
||||||
--r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( r > 0 && buffer[ r-1 ] == '.' )
|
|
||||||
{
|
|
||||||
--r;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.resize( r );
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline error_condition system_category_default_error_condition_win32( int ev ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
// When using the Windows Runtime, most system errors are reported as HRESULTs.
|
|
||||||
// We want to map the common Win32 errors to their equivalent error condition,
|
|
||||||
// whether or not they are reported via an HRESULT.
|
|
||||||
|
|
||||||
#define BOOST_SYSTEM_FAILED(hr) ((hr) < 0)
|
|
||||||
#define BOOST_SYSTEM_HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
|
|
||||||
#define BOOST_SYSTEM_HRESULT_CODE(hr) ((hr) & 0xFFFF)
|
|
||||||
#define BOOST_SYSTEM_FACILITY_WIN32 7
|
|
||||||
|
|
||||||
if( BOOST_SYSTEM_FAILED( ev ) && BOOST_SYSTEM_HRESULT_FACILITY( ev ) == BOOST_SYSTEM_FACILITY_WIN32 )
|
|
||||||
{
|
|
||||||
ev = BOOST_SYSTEM_HRESULT_CODE( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef BOOST_SYSTEM_FAILED
|
|
||||||
#undef BOOST_SYSTEM_HRESULT_FACILITY
|
|
||||||
#undef BOOST_SYSTEM_HRESULT_CODE
|
|
||||||
#undef BOOST_SYSTEM_FACILITY_WIN32
|
|
||||||
|
|
||||||
using namespace boost::winapi;
|
|
||||||
using namespace errc;
|
|
||||||
|
|
||||||
// Windows system -> posix_errno decode table
|
|
||||||
// see WinError.h comments for descriptions of errors
|
|
||||||
|
|
||||||
switch ( ev )
|
|
||||||
{
|
|
||||||
case 0: return make_error_condition( success );
|
|
||||||
|
|
||||||
case ERROR_ACCESS_DENIED_: return make_error_condition( permission_denied );
|
|
||||||
case ERROR_ALREADY_EXISTS_: return make_error_condition( file_exists );
|
|
||||||
case ERROR_BAD_UNIT_: return make_error_condition( no_such_device );
|
|
||||||
case ERROR_BUFFER_OVERFLOW_: return make_error_condition( filename_too_long );
|
|
||||||
case ERROR_BUSY_: return make_error_condition( device_or_resource_busy );
|
|
||||||
case ERROR_BUSY_DRIVE_: return make_error_condition( device_or_resource_busy );
|
|
||||||
case ERROR_CANNOT_MAKE_: return make_error_condition( permission_denied );
|
|
||||||
case ERROR_CANTOPEN_: return make_error_condition( io_error );
|
|
||||||
case ERROR_CANTREAD_: return make_error_condition( io_error );
|
|
||||||
case ERROR_CANTWRITE_: return make_error_condition( io_error );
|
|
||||||
case ERROR_CURRENT_DIRECTORY_: return make_error_condition( permission_denied );
|
|
||||||
case ERROR_DEV_NOT_EXIST_: return make_error_condition( no_such_device );
|
|
||||||
case ERROR_DEVICE_IN_USE_: return make_error_condition( device_or_resource_busy );
|
|
||||||
case ERROR_DIR_NOT_EMPTY_: return make_error_condition( directory_not_empty );
|
|
||||||
case ERROR_DIRECTORY_: return make_error_condition( invalid_argument ); // WinError.h: "The directory name is invalid"
|
|
||||||
case ERROR_DISK_FULL_: return make_error_condition( no_space_on_device );
|
|
||||||
case ERROR_FILE_EXISTS_: return make_error_condition( file_exists );
|
|
||||||
case ERROR_FILE_NOT_FOUND_: return make_error_condition( no_such_file_or_directory );
|
|
||||||
case ERROR_HANDLE_DISK_FULL_: return make_error_condition( no_space_on_device );
|
|
||||||
case ERROR_INVALID_ACCESS_: return make_error_condition( permission_denied );
|
|
||||||
case ERROR_INVALID_DRIVE_: return make_error_condition( no_such_device );
|
|
||||||
case ERROR_INVALID_FUNCTION_: return make_error_condition( function_not_supported );
|
|
||||||
case ERROR_INVALID_HANDLE_: return make_error_condition( invalid_argument );
|
|
||||||
case ERROR_INVALID_NAME_: return make_error_condition( invalid_argument );
|
|
||||||
case ERROR_LOCK_VIOLATION_: return make_error_condition( no_lock_available );
|
|
||||||
case ERROR_LOCKED_: return make_error_condition( no_lock_available );
|
|
||||||
case ERROR_NEGATIVE_SEEK_: return make_error_condition( invalid_argument );
|
|
||||||
case ERROR_NOACCESS_: return make_error_condition( permission_denied );
|
|
||||||
case ERROR_NOT_ENOUGH_MEMORY_: return make_error_condition( not_enough_memory );
|
|
||||||
case ERROR_NOT_READY_: return make_error_condition( resource_unavailable_try_again );
|
|
||||||
case ERROR_NOT_SAME_DEVICE_: return make_error_condition( cross_device_link );
|
|
||||||
case ERROR_OPEN_FAILED_: return make_error_condition( io_error );
|
|
||||||
case ERROR_OPEN_FILES_: return make_error_condition( device_or_resource_busy );
|
|
||||||
case ERROR_OPERATION_ABORTED_: return make_error_condition( operation_canceled );
|
|
||||||
case ERROR_OUTOFMEMORY_: return make_error_condition( not_enough_memory );
|
|
||||||
case ERROR_PATH_NOT_FOUND_: return make_error_condition( no_such_file_or_directory );
|
|
||||||
case ERROR_READ_FAULT_: return make_error_condition( io_error );
|
|
||||||
case ERROR_RETRY_: return make_error_condition( resource_unavailable_try_again );
|
|
||||||
case ERROR_SEEK_: return make_error_condition( io_error );
|
|
||||||
case ERROR_SHARING_VIOLATION_: return make_error_condition( permission_denied );
|
|
||||||
case ERROR_TOO_MANY_OPEN_FILES_: return make_error_condition( too_many_files_open );
|
|
||||||
case ERROR_WRITE_FAULT_: return make_error_condition( io_error );
|
|
||||||
case ERROR_WRITE_PROTECT_: return make_error_condition( permission_denied );
|
|
||||||
case WSAEACCES_: return make_error_condition( permission_denied );
|
|
||||||
case WSAEADDRINUSE_: return make_error_condition( address_in_use );
|
|
||||||
case WSAEADDRNOTAVAIL_: return make_error_condition( address_not_available );
|
|
||||||
case WSAEAFNOSUPPORT_: return make_error_condition( address_family_not_supported );
|
|
||||||
case WSAEALREADY_: return make_error_condition( connection_already_in_progress );
|
|
||||||
case WSAEBADF_: return make_error_condition( bad_file_descriptor );
|
|
||||||
case WSAECONNABORTED_: return make_error_condition( connection_aborted );
|
|
||||||
case WSAECONNREFUSED_: return make_error_condition( connection_refused );
|
|
||||||
case WSAECONNRESET_: return make_error_condition( connection_reset );
|
|
||||||
case WSAEDESTADDRREQ_: return make_error_condition( destination_address_required );
|
|
||||||
case WSAEFAULT_: return make_error_condition( bad_address );
|
|
||||||
case WSAEHOSTUNREACH_: return make_error_condition( host_unreachable );
|
|
||||||
case WSAEINPROGRESS_: return make_error_condition( operation_in_progress );
|
|
||||||
case WSAEINTR_: return make_error_condition( interrupted );
|
|
||||||
case WSAEINVAL_: return make_error_condition( invalid_argument );
|
|
||||||
case WSAEISCONN_: return make_error_condition( already_connected );
|
|
||||||
case WSAEMFILE_: return make_error_condition( too_many_files_open );
|
|
||||||
case WSAEMSGSIZE_: return make_error_condition( message_size );
|
|
||||||
case WSAENAMETOOLONG_: return make_error_condition( filename_too_long );
|
|
||||||
case WSAENETDOWN_: return make_error_condition( network_down );
|
|
||||||
case WSAENETRESET_: return make_error_condition( network_reset );
|
|
||||||
case WSAENETUNREACH_: return make_error_condition( network_unreachable );
|
|
||||||
case WSAENOBUFS_: return make_error_condition( no_buffer_space );
|
|
||||||
case WSAENOPROTOOPT_: return make_error_condition( no_protocol_option );
|
|
||||||
case WSAENOTCONN_: return make_error_condition( not_connected );
|
|
||||||
case WSAENOTSOCK_: return make_error_condition( not_a_socket );
|
|
||||||
case WSAEOPNOTSUPP_: return make_error_condition( operation_not_supported );
|
|
||||||
case WSAEPROTONOSUPPORT_: return make_error_condition( protocol_not_supported );
|
|
||||||
case WSAEPROTOTYPE_: return make_error_condition( wrong_protocol_type );
|
|
||||||
case WSAETIMEDOUT_: return make_error_condition( timed_out );
|
|
||||||
case WSAEWOULDBLOCK_: return make_error_condition( operation_would_block );
|
|
||||||
|
|
||||||
default: return error_condition( ev, system_category() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
} // namespace system
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_THROWS_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_THROWS_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
class error_code;
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
// boost::throws()
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
// Misuse of the error_code object is turned into a noisy failure by
|
||||||
|
// poisoning the reference. This particular implementation doesn't
|
||||||
|
// produce warnings or errors from popular compilers, is very efficient
|
||||||
|
// (as determined by inspecting generated code), and does not suffer
|
||||||
|
// from order of initialization problems. In practice, it also seems
|
||||||
|
// cause user function error handling implementation errors to be detected
|
||||||
|
// very early in the development cycle.
|
||||||
|
|
||||||
|
inline system::error_code* throws()
|
||||||
|
{
|
||||||
|
// See github.com/boostorg/system/pull/12 by visigoth for why the return
|
||||||
|
// is poisoned with nonzero rather than (0). A test, test_throws_usage(),
|
||||||
|
// has been added to error_code_test.cpp, and as visigoth mentioned it
|
||||||
|
// fails on clang for release builds with a return of 0 but works fine
|
||||||
|
// with (1).
|
||||||
|
// Since the undefined behavior sanitizer (-fsanitize=undefined) does not
|
||||||
|
// allow a reference to be formed to the unaligned address of (1), we use
|
||||||
|
// (8) instead.
|
||||||
|
|
||||||
|
return reinterpret_cast<system::error_code*>(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
inline system::error_code& throws()
|
||||||
|
{
|
||||||
|
return *detail::throws();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_THROWS_HPP_INCLUDED
|
||||||
+18
-7
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
|
||||||
|
|
||||||
// Support for interoperability between Boost.System and <system_error>
|
// Support for interoperability between Boost.System and <system_error>
|
||||||
//
|
//
|
||||||
// Copyright 2018 Peter Dimov
|
// Copyright 2018 Peter Dimov
|
||||||
@@ -7,6 +10,10 @@
|
|||||||
//
|
//
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
|
#include <boost/system/detail/error_code.hpp>
|
||||||
|
#include <boost/system/detail/generic_category.hpp>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -47,26 +54,28 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char * name() const BOOST_NOEXCEPT
|
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||||
{
|
{
|
||||||
return pc_->name();
|
return pc_->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string message( int ev ) const
|
std::string message( int ev ) const BOOST_OVERRIDE
|
||||||
{
|
{
|
||||||
return pc_->message( ev );
|
return pc_->message( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT
|
std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||||
{
|
{
|
||||||
return pc_->default_error_condition( ev );
|
return pc_->default_error_condition( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT;
|
bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||||
virtual bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT;
|
bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||||
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) BOOST_SYMBOL_VISIBLE;
|
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) BOOST_SYMBOL_VISIBLE;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct cat_ptr_less
|
struct cat_ptr_less
|
||||||
{
|
{
|
||||||
@@ -78,12 +87,12 @@ struct cat_ptr_less
|
|||||||
|
|
||||||
inline std::error_category const & to_std_category( boost::system::error_category const & cat )
|
inline std::error_category const & to_std_category( boost::system::error_category const & cat )
|
||||||
{
|
{
|
||||||
if( cat == boost::system::system_category() )
|
if( cat.id_ == boost::system::detail::system_category_id )
|
||||||
{
|
{
|
||||||
static const std_category system_instance( &cat, 0x1F4D7 );
|
static const std_category system_instance( &cat, 0x1F4D7 );
|
||||||
return system_instance;
|
return system_instance;
|
||||||
}
|
}
|
||||||
else if( cat == boost::system::generic_category() )
|
else if( cat.id_ == boost::system::detail::generic_category_id )
|
||||||
{
|
{
|
||||||
static const std_category generic_instance( &cat, 0x1F4D3 );
|
static const std_category generic_instance( &cat, 0x1F4D3 );
|
||||||
return generic_instance;
|
return generic_instance;
|
||||||
@@ -178,3 +187,5 @@ inline bool std_category::equivalent( const std::error_code & code, int conditio
|
|||||||
} // namespace system
|
} // namespace system
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_ERRC_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_ERRC_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018, 2020
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/errc.hpp>
|
||||||
|
#include <boost/system/detail/error_code.hpp>
|
||||||
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
|
#include <boost/system/detail/generic_category.hpp>
|
||||||
|
#include <boost/system/detail/error_category_impl.hpp>
|
||||||
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
// make_* functions for errc::errc_t
|
||||||
|
|
||||||
|
namespace errc
|
||||||
|
{
|
||||||
|
|
||||||
|
// explicit conversion:
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return error_code( e, generic_category() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// implicit conversion:
|
||||||
|
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return error_condition( e, generic_category() );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace errc
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_ERRC_HPP_INCLUDED
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_ERROR_CATEGORY_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_ERROR_CATEGORY_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_category.hpp>
|
||||||
|
#include <boost/system/detail/error_category_impl.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_ERROR_CATEGORY_HPP_INCLUDED
|
||||||
@@ -10,25 +10,14 @@
|
|||||||
//
|
//
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
#include <boost/system/api_config.hpp>
|
#include <boost/system/detail/error_code.hpp>
|
||||||
#include <boost/system/detail/config.hpp>
|
#include <boost/system/error_category.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/system/error_condition.hpp>
|
||||||
|
#include <boost/system/errc.hpp>
|
||||||
|
#include <boost/system/generic_category.hpp>
|
||||||
|
#include <boost/system/system_category.hpp>
|
||||||
|
#include <boost/system/detail/throws.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <ostream>
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
// TODO: undef these macros if not already defined
|
|
||||||
#include <boost/cerrno.hpp>
|
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
||||||
# include <system_error>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
|
||||||
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@@ -36,718 +25,8 @@ namespace boost
|
|||||||
namespace system
|
namespace system
|
||||||
{
|
{
|
||||||
|
|
||||||
class error_code; // values defined by the operating system
|
|
||||||
class error_condition; // portable generic values defined below, but ultimately
|
|
||||||
// based on the POSIX standard
|
|
||||||
|
|
||||||
// "Concept" helpers
|
|
||||||
|
|
||||||
template<class T> struct is_error_code_enum
|
|
||||||
{
|
|
||||||
static const bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T> struct is_error_condition_enum
|
|
||||||
{
|
|
||||||
static const bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Generic error_conditions
|
|
||||||
|
|
||||||
namespace errc
|
|
||||||
{
|
|
||||||
|
|
||||||
enum errc_t
|
|
||||||
{
|
|
||||||
success = 0,
|
|
||||||
address_family_not_supported = EAFNOSUPPORT,
|
|
||||||
address_in_use = EADDRINUSE,
|
|
||||||
address_not_available = EADDRNOTAVAIL,
|
|
||||||
already_connected = EISCONN,
|
|
||||||
argument_list_too_long = E2BIG,
|
|
||||||
argument_out_of_domain = EDOM,
|
|
||||||
bad_address = EFAULT,
|
|
||||||
bad_file_descriptor = EBADF,
|
|
||||||
bad_message = EBADMSG,
|
|
||||||
broken_pipe = EPIPE,
|
|
||||||
connection_aborted = ECONNABORTED,
|
|
||||||
connection_already_in_progress = EALREADY,
|
|
||||||
connection_refused = ECONNREFUSED,
|
|
||||||
connection_reset = ECONNRESET,
|
|
||||||
cross_device_link = EXDEV,
|
|
||||||
destination_address_required = EDESTADDRREQ,
|
|
||||||
device_or_resource_busy = EBUSY,
|
|
||||||
directory_not_empty = ENOTEMPTY,
|
|
||||||
executable_format_error = ENOEXEC,
|
|
||||||
file_exists = EEXIST,
|
|
||||||
file_too_large = EFBIG,
|
|
||||||
filename_too_long = ENAMETOOLONG,
|
|
||||||
function_not_supported = ENOSYS,
|
|
||||||
host_unreachable = EHOSTUNREACH,
|
|
||||||
identifier_removed = EIDRM,
|
|
||||||
illegal_byte_sequence = EILSEQ,
|
|
||||||
inappropriate_io_control_operation = ENOTTY,
|
|
||||||
interrupted = EINTR,
|
|
||||||
invalid_argument = EINVAL,
|
|
||||||
invalid_seek = ESPIPE,
|
|
||||||
io_error = EIO,
|
|
||||||
is_a_directory = EISDIR,
|
|
||||||
message_size = EMSGSIZE,
|
|
||||||
network_down = ENETDOWN,
|
|
||||||
network_reset = ENETRESET,
|
|
||||||
network_unreachable = ENETUNREACH,
|
|
||||||
no_buffer_space = ENOBUFS,
|
|
||||||
no_child_process = ECHILD,
|
|
||||||
no_link = ENOLINK,
|
|
||||||
no_lock_available = ENOLCK,
|
|
||||||
no_message_available = ENODATA,
|
|
||||||
no_message = ENOMSG,
|
|
||||||
no_protocol_option = ENOPROTOOPT,
|
|
||||||
no_space_on_device = ENOSPC,
|
|
||||||
no_stream_resources = ENOSR,
|
|
||||||
no_such_device_or_address = ENXIO,
|
|
||||||
no_such_device = ENODEV,
|
|
||||||
no_such_file_or_directory = ENOENT,
|
|
||||||
no_such_process = ESRCH,
|
|
||||||
not_a_directory = ENOTDIR,
|
|
||||||
not_a_socket = ENOTSOCK,
|
|
||||||
not_a_stream = ENOSTR,
|
|
||||||
not_connected = ENOTCONN,
|
|
||||||
not_enough_memory = ENOMEM,
|
|
||||||
not_supported = ENOTSUP,
|
|
||||||
operation_canceled = ECANCELED,
|
|
||||||
operation_in_progress = EINPROGRESS,
|
|
||||||
operation_not_permitted = EPERM,
|
|
||||||
operation_not_supported = EOPNOTSUPP,
|
|
||||||
operation_would_block = EWOULDBLOCK,
|
|
||||||
owner_dead = EOWNERDEAD,
|
|
||||||
permission_denied = EACCES,
|
|
||||||
protocol_error = EPROTO,
|
|
||||||
protocol_not_supported = EPROTONOSUPPORT,
|
|
||||||
read_only_file_system = EROFS,
|
|
||||||
resource_deadlock_would_occur = EDEADLK,
|
|
||||||
resource_unavailable_try_again = EAGAIN,
|
|
||||||
result_out_of_range = ERANGE,
|
|
||||||
state_not_recoverable = ENOTRECOVERABLE,
|
|
||||||
stream_timeout = ETIME,
|
|
||||||
text_file_busy = ETXTBSY,
|
|
||||||
timed_out = ETIMEDOUT,
|
|
||||||
too_many_files_open_in_system = ENFILE,
|
|
||||||
too_many_files_open = EMFILE,
|
|
||||||
too_many_links = EMLINK,
|
|
||||||
too_many_symbolic_link_levels = ELOOP,
|
|
||||||
value_too_large = EOVERFLOW,
|
|
||||||
wrong_protocol_type = EPROTOTYPE
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace errc
|
|
||||||
|
|
||||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
|
||||||
|
|
||||||
namespace posix = errc;
|
|
||||||
namespace posix_error = errc;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<> struct is_error_condition_enum<errc::errc_t>
|
|
||||||
{
|
|
||||||
static const bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class error_category
|
|
||||||
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
|
||||||
#pragma warning( push )
|
|
||||||
// 'this' : used in base member initializer list
|
|
||||||
#pragma warning( disable: 4355 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::size_t hash_value( error_code const & ec );
|
|
||||||
|
|
||||||
class BOOST_SYMBOL_VISIBLE error_category
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
friend std::size_t hash_value( error_code const & ec );
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
|
||||||
public:
|
|
||||||
|
|
||||||
error_category( error_category const & ) = delete;
|
|
||||||
error_category& operator=( error_category const & ) = delete;
|
|
||||||
|
|
||||||
#else
|
|
||||||
private:
|
|
||||||
|
|
||||||
error_category( error_category const & );
|
|
||||||
error_category& operator=( error_category const & );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
boost::ulong_long_type id_;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
|
||||||
|
|
||||||
~error_category() = default;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// We'd like to make the destructor protected, to make code that deletes
|
|
||||||
// an error_category* not compile; unfortunately, doing the below makes
|
|
||||||
// the destructor user-provided and hence breaks use after main, as the
|
|
||||||
// categories may get destroyed before code that uses them
|
|
||||||
|
|
||||||
// ~error_category() {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual const char * name() const BOOST_NOEXCEPT = 0;
|
|
||||||
|
|
||||||
virtual error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
|
|
||||||
virtual bool equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT;
|
|
||||||
virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT;
|
|
||||||
|
|
||||||
virtual std::string message( int ev ) const = 0;
|
|
||||||
virtual char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
|
|
||||||
|
|
||||||
virtual bool failed( int ev ) const BOOST_NOEXCEPT;
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return rhs.id_ == 0? this == &rhs: id_ == rhs.id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return !( *this == rhs );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
if( id_ < rhs.id_ )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( id_ > rhs.id_ )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( rhs.id_ != 0 )
|
|
||||||
{
|
|
||||||
return false; // equal
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::less<error_category const *>()( this, &rhs );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
||||||
|
|
||||||
operator std::error_category const & () const;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
|
||||||
#pragma warning( pop )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// predefined error categories
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
class BOOST_SYMBOL_VISIBLE generic_error_category: public error_category
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
// clang++ 3.8 and below: initialization of const object
|
|
||||||
// requires a user-provided default constructor
|
|
||||||
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_NOEXCEPT:
|
|
||||||
error_category( ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * name() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return "generic";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string message( int ev ) const;
|
|
||||||
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
|
|
||||||
error_category( ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * name() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return "system";
|
|
||||||
}
|
|
||||||
|
|
||||||
error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
|
|
||||||
|
|
||||||
std::string message( int ev ) const;
|
|
||||||
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// generic_category(), system_category()
|
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
template<class T> struct BOOST_SYMBOL_VISIBLE cat_holder
|
|
||||||
{
|
|
||||||
static constexpr system_error_category system_category_instance{};
|
|
||||||
static constexpr generic_error_category generic_category_instance{};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T> constexpr system_error_category cat_holder<T>::system_category_instance;
|
|
||||||
template<class T> constexpr generic_error_category cat_holder<T>::generic_category_instance;
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
constexpr error_category const & system_category() BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return detail::cat_holder<void>::system_category_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr error_category const & generic_category() BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return detail::cat_holder<void>::generic_category_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
|
||||||
|
|
||||||
inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
|
||||||
|
|
||||||
inline error_category const & system_category() BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
static const detail::system_error_category system_category_instance;
|
|
||||||
return system_category_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline error_category const & generic_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
|
||||||
|
|
||||||
inline error_category const & generic_category() BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
static const detail::generic_error_category generic_category_instance;
|
|
||||||
return generic_category_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
|
||||||
|
|
||||||
// deprecated synonyms
|
|
||||||
|
|
||||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
|
||||||
|
|
||||||
inline const error_category & get_system_category() { return system_category(); }
|
|
||||||
inline const error_category & get_generic_category() { return generic_category(); }
|
|
||||||
inline const error_category & get_posix_category() { return generic_category(); }
|
|
||||||
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category();
|
|
||||||
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category();
|
|
||||||
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// enable_if
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
template<bool C, class T = void> struct enable_if
|
|
||||||
{
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T> struct enable_if<false, T>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
// failed_impl
|
|
||||||
|
|
||||||
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
|
||||||
|
|
||||||
inline bool failed_impl( int ev, error_category const & cat )
|
|
||||||
{
|
|
||||||
return cat.failed( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
|
|
||||||
{
|
|
||||||
if( cat == system_category() || cat == generic_category() )
|
|
||||||
{
|
|
||||||
return ev != 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return cat.failed( ev );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
// class error_condition
|
|
||||||
|
|
||||||
// error_conditions are portable, error_codes are system or library specific
|
|
||||||
|
|
||||||
class error_condition
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
int val_;
|
|
||||||
bool failed_;
|
|
||||||
error_category const * cat_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// constructors:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
|
||||||
val_( 0 ), failed_( false ), cat_( &generic_category() )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
|
||||||
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
|
|
||||||
typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type* = 0) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
*this = make_error_condition( e );
|
|
||||||
}
|
|
||||||
|
|
||||||
// modifiers:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
val_ = val;
|
|
||||||
failed_ = detail::failed_impl( val, cat );
|
|
||||||
cat_ = &cat;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ErrorConditionEnum>
|
|
||||||
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
|
|
||||||
operator=( ErrorConditionEnum val ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
*this = make_error_condition( val );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
val_ = 0;
|
|
||||||
failed_ = false;
|
|
||||||
cat_ = &generic_category();
|
|
||||||
}
|
|
||||||
|
|
||||||
// observers:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return val_;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return *cat_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string message() const
|
|
||||||
{
|
|
||||||
return cat_->message( value() );
|
|
||||||
}
|
|
||||||
|
|
||||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return cat_->message( value(), buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return failed_;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
|
||||||
{
|
|
||||||
return val_ != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)();
|
|
||||||
static void unspecified_bool_true() {}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
|
||||||
{
|
|
||||||
return val_ != 0? unspecified_bool_true: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
|
||||||
{
|
|
||||||
return val_ == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// relationals:
|
|
||||||
// the more symmetrical non-member syntax allows enum
|
|
||||||
// conversions work for both rhs and lhs.
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
||||||
|
|
||||||
operator std::error_condition () const
|
|
||||||
{
|
|
||||||
return std::error_condition( value(), category() );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
// class error_code
|
|
||||||
|
|
||||||
// We want error_code to be a value type that can be copied without slicing
|
|
||||||
// and without requiring heap allocation, but we also want it to have
|
|
||||||
// polymorphic behavior based on the error category. This is achieved by
|
|
||||||
// abstract base class error_category supplying the polymorphic behavior,
|
|
||||||
// and error_code containing a pointer to an object of a type derived
|
|
||||||
// from error_category.
|
|
||||||
|
|
||||||
class error_code
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
int val_;
|
|
||||||
bool failed_;
|
|
||||||
const error_category * cat_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// constructors:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
|
|
||||||
val_( 0 ), failed_( false ), cat_( &system_category() )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
|
||||||
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
|
|
||||||
typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type* = 0 ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
*this = make_error_code( e );
|
|
||||||
}
|
|
||||||
|
|
||||||
// modifiers:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
val_ = val;
|
|
||||||
failed_ = detail::failed_impl( val, cat );
|
|
||||||
cat_ = &cat;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ErrorCodeEnum>
|
|
||||||
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type &
|
|
||||||
operator=( ErrorCodeEnum val ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
*this = make_error_code( val );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
val_ = 0;
|
|
||||||
failed_ = false;
|
|
||||||
cat_ = &system_category();
|
|
||||||
}
|
|
||||||
|
|
||||||
// observers:
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return val_;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return *cat_;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_condition default_error_condition() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return cat_->default_error_condition( value() );
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string message() const
|
|
||||||
{
|
|
||||||
return cat_->message( value() );
|
|
||||||
}
|
|
||||||
|
|
||||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return cat_->message( value(), buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return failed_;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
|
||||||
{
|
|
||||||
return val_ != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)();
|
|
||||||
static void unspecified_bool_true() {}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
|
||||||
{
|
|
||||||
return val_ != 0? unspecified_bool_true: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
|
||||||
{
|
|
||||||
return val_ == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// relationals:
|
|
||||||
|
|
||||||
// the more symmetrical non-member syntax allows enum
|
|
||||||
// conversions work for both rhs and lhs.
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
||||||
|
|
||||||
operator std::error_code () const
|
|
||||||
{
|
|
||||||
return std::error_code( value(), category() );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace system
|
|
||||||
|
|
||||||
// boost::throws()
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
// Misuse of the error_code object is turned into a noisy failure by
|
|
||||||
// poisoning the reference. This particular implementation doesn't
|
|
||||||
// produce warnings or errors from popular compilers, is very efficient
|
|
||||||
// (as determined by inspecting generated code), and does not suffer
|
|
||||||
// from order of initialization problems. In practice, it also seems
|
|
||||||
// cause user function error handling implementation errors to be detected
|
|
||||||
// very early in the development cycle.
|
|
||||||
|
|
||||||
inline system::error_code* throws()
|
|
||||||
{
|
|
||||||
// See github.com/boostorg/system/pull/12 by visigoth for why the return
|
|
||||||
// is poisoned with nonzero rather than (0). A test, test_throws_usage(),
|
|
||||||
// has been added to error_code_test.cpp, and as visigoth mentioned it
|
|
||||||
// fails on clang for release builds with a return of 0 but works fine
|
|
||||||
// with (1).
|
|
||||||
// Since the undefined behavior sanitizer (-fsanitize=undefined) does not
|
|
||||||
// allow a reference to be formed to the unaligned address of (1), we use
|
|
||||||
// (8) instead.
|
|
||||||
|
|
||||||
return reinterpret_cast<system::error_code*>(8);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
inline system::error_code& throws()
|
|
||||||
{
|
|
||||||
return *detail::throws();
|
|
||||||
}
|
|
||||||
|
|
||||||
// non-member functions of error_code and error_condition
|
// non-member functions of error_code and error_condition
|
||||||
|
|
||||||
namespace system
|
|
||||||
{
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return !( lhs == rhs );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return !( lhs == rhs );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||||
@@ -768,201 +47,8 @@ inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BO
|
|||||||
return !( lhs == rhs );
|
return !( lhs == rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class charT, class traits>
|
|
||||||
inline std::basic_ostream<charT,traits>&
|
|
||||||
operator<< (std::basic_ostream<charT,traits>& os, error_code ec)
|
|
||||||
{
|
|
||||||
os << ec.category().name() << ':' << ec.value();
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value( error_code const & ec )
|
|
||||||
{
|
|
||||||
error_category const & cat = ec.category();
|
|
||||||
|
|
||||||
boost::ulong_long_type id = cat.id_;
|
|
||||||
|
|
||||||
if( id == 0 )
|
|
||||||
{
|
|
||||||
id = reinterpret_cast<boost::ulong_long_type>( &cat );
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::ulong_long_type hv = ( boost::ulong_long_type( 0xCBF29CE4 ) << 32 ) + 0x84222325;
|
|
||||||
boost::ulong_long_type const prime = ( boost::ulong_long_type( 0x00000100 ) << 32 ) + 0x000001B3;
|
|
||||||
|
|
||||||
// id
|
|
||||||
|
|
||||||
hv ^= id;
|
|
||||||
hv *= prime;
|
|
||||||
|
|
||||||
// value
|
|
||||||
|
|
||||||
hv ^= static_cast<unsigned>( ec.value() );
|
|
||||||
hv *= prime;
|
|
||||||
|
|
||||||
return static_cast<std::size_t>( hv );
|
|
||||||
}
|
|
||||||
|
|
||||||
// make_* functions for errc::errc_t
|
|
||||||
|
|
||||||
namespace errc
|
|
||||||
{
|
|
||||||
|
|
||||||
// explicit conversion:
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return error_code( e, generic_category() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// implicit conversion:
|
|
||||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return error_condition( e, generic_category() );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace errc
|
|
||||||
|
|
||||||
// error_category default implementation
|
|
||||||
|
|
||||||
inline error_condition error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return error_condition( ev, *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool error_category::equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return default_error_condition( code ) == condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool error_category::equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return *this == code.category() && code.value() == condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
if( len == 0 )
|
|
||||||
{
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( len == 1 )
|
|
||||||
{
|
|
||||||
buffer[0] = 0;
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
|
||||||
try
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
std::string m = this->message( ev );
|
|
||||||
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( push )
|
|
||||||
# pragma warning( disable: 4996 )
|
|
||||||
# elif defined(__clang__) && defined(__has_warning)
|
|
||||||
# pragma clang diagnostic push
|
|
||||||
# if __has_warning("-Wdeprecated-declarations")
|
|
||||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
std::strncpy( buffer, m.c_str(), len - 1 );
|
|
||||||
buffer[ len-1 ] = 0;
|
|
||||||
|
|
||||||
# if defined( BOOST_MSVC )
|
|
||||||
# pragma warning( pop )
|
|
||||||
# elif defined(__clang__) && defined(__has_warning)
|
|
||||||
# pragma clang diagnostic pop
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
return "Message text unavailable";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool error_category::failed( int ev ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return ev != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
// generic_error_category implementation
|
|
||||||
|
|
||||||
#include <boost/system/detail/generic_category.hpp>
|
|
||||||
|
|
||||||
inline std::string boost::system::detail::generic_error_category::message( int ev ) const
|
|
||||||
{
|
|
||||||
return generic_error_category_message( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * boost::system::detail::generic_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return generic_error_category_message( ev, buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
// system_error_category implementation
|
|
||||||
|
|
||||||
#if defined(BOOST_WINDOWS_API)
|
|
||||||
|
|
||||||
#include <boost/system/detail/system_category_win32.hpp>
|
|
||||||
|
|
||||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return system_category_default_error_condition_win32( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
|
||||||
{
|
|
||||||
return system_category_message_win32( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return system_category_message_win32( ev, buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // #if defined(BOOST_WINDOWS_API)
|
|
||||||
|
|
||||||
#include <boost/system/detail/system_category_posix.hpp>
|
|
||||||
|
|
||||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return system_category_default_error_condition_posix( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
|
||||||
{
|
|
||||||
return generic_error_category_message( ev );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
return generic_error_category_message( ev, buffer, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #if defined(BOOST_WINDOWS_API)
|
|
||||||
|
|
||||||
// interoperability with std::error_code, std::error_condition
|
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
||||||
|
|
||||||
#include <boost/system/detail/std_interoperability.hpp>
|
|
||||||
|
|
||||||
inline boost::system::error_category::operator std::error_category const & () const
|
|
||||||
{
|
|
||||||
return boost::system::detail::to_std_category( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
||||||
|
|
||||||
#endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|
#endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/error_condition.hpp>
|
||||||
|
#include <boost/system/detail/error_category_impl.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_GENERIC_CATEGORY_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_GENERIC_CATEGORY_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/generic_category.hpp>
|
||||||
|
#include <boost/system/detail/error_category_impl.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_GENERIC_CATEGORY_HPP_INCLUDED
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
class error_code;
|
||||||
|
|
||||||
|
template<class T> struct is_error_code_enum
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2006, 2007
|
||||||
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
class error_condition;
|
||||||
|
|
||||||
|
template<class T> struct is_error_condition_enum
|
||||||
|
{
|
||||||
|
static const bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef BOOST_SYSTEM_SYSTEM_CATEGORY_HPP_INCLUDED
|
||||||
|
#define BOOST_SYSTEM_SYSTEM_CATEGORY_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
//
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/detail/system_category.hpp>
|
||||||
|
#include <boost/system/detail/system_category_impl.hpp>
|
||||||
|
#include <boost/system/detail/error_category_impl.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef BOOST_SYSTEM_SYSTEM_CATEGORY_HPP_INCLUDED
|
||||||
@@ -47,7 +47,7 @@ namespace boost
|
|||||||
virtual ~system_error() BOOST_NOEXCEPT_OR_NOTHROW {}
|
virtual ~system_error() BOOST_NOEXCEPT_OR_NOTHROW {}
|
||||||
|
|
||||||
error_code code() const BOOST_NOEXCEPT { return m_error_code; }
|
error_code code() const BOOST_NOEXCEPT { return m_error_code; }
|
||||||
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW;
|
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
error_code m_error_code;
|
error_code m_error_code;
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
# Copyright 2018-2020 Peter Dimov
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||||
|
|
||||||
|
if(NOT HAVE_BOOST_TEST)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
macro(system_run s1)
|
||||||
|
|
||||||
|
string(MAKE_C_IDENTIFIER ${s1} n1)
|
||||||
|
|
||||||
|
boost_test(SOURCES ${s1} ${ARGN})
|
||||||
|
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_NO_ANSI_APIS NAME ${n1}_no_ansi)
|
||||||
|
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_SYSTEM_USE_UTF8 NAME ${n1}_utf8)
|
||||||
|
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(lib name macro)
|
||||||
|
|
||||||
|
add_library(${name} EXCLUDE_FROM_ALL ${ARGN})
|
||||||
|
target_compile_definitions(${name} PRIVATE $<$<BOOL:BUILD_SHARED_LIBS>:${macro}=1>)
|
||||||
|
target_link_libraries(${name} PRIVATE Boost::system Boost::config)
|
||||||
|
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
set(BOOST_TEST_LINK_LIBRARIES Boost::system Boost::core Boost::static_assert)
|
||||||
|
|
||||||
|
boost_test(SOURCES quick.cpp)
|
||||||
|
|
||||||
|
system_run(error_code_test.cpp)
|
||||||
|
system_run(error_code_user_test.cpp)
|
||||||
|
system_run(system_error_test.cpp)
|
||||||
|
|
||||||
|
lib(boost_system_throw_test THROW_DYN_LINK throw_test.cpp)
|
||||||
|
boost_test(SOURCES dynamic_link_test.cpp LINK_LIBRARIES boost_system_throw_test)
|
||||||
|
|
||||||
|
system_run(initialization_test.cpp)
|
||||||
|
system_run(header_only_test.cpp)
|
||||||
|
|
||||||
|
boost_test(SOURCES config_test.cpp)
|
||||||
|
|
||||||
|
system_run(std_interop_test.cpp)
|
||||||
|
system_run(std_mismatch_test.cpp)
|
||||||
|
|
||||||
|
lib(boost_system_single_instance_lib1 SINGLE_INSTANCE_DYN_LINK single_instance_1.cpp)
|
||||||
|
lib(boost_system_single_instance_lib2 SINGLE_INSTANCE_DYN_LINK single_instance_2.cpp)
|
||||||
|
|
||||||
|
system_run(single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp)
|
||||||
|
boost_test(SOURCES single_instance_test.cpp NAME single_instance_test_lib LINK_LIBRARIES boost_system_single_instance_lib1 boost_system_single_instance_lib2)
|
||||||
|
|
||||||
|
system_run(before_main_test.cpp)
|
||||||
|
system_run(constexpr_test.cpp)
|
||||||
|
system_run(win32_hresult_test.cpp)
|
||||||
|
|
||||||
|
system_run(error_category_test.cpp)
|
||||||
|
system_run(generic_category_test.cpp)
|
||||||
|
system_run(system_category_test.cpp)
|
||||||
|
system_run(after_main_test.cpp)
|
||||||
|
system_run(failed_test.cpp)
|
||||||
|
system_run(failed_constexpr_test.cpp)
|
||||||
|
|
||||||
|
boost_test(SOURCES warnings_test.cpp COMPILE_OPTIONS -Wall -Werror)
|
||||||
|
|
||||||
|
lib(boost_system_std_single_instance_lib1 STD_SINGLE_INSTANCE_DYN_LINK std_single_instance_1.cpp)
|
||||||
|
lib(boost_system_std_single_instance_lib2 STD_SINGLE_INSTANCE_DYN_LINK std_single_instance_2.cpp)
|
||||||
|
|
||||||
|
system_run(std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp)
|
||||||
|
boost_test(SOURCES std_single_instance_test.cpp NAME std_single_instance_test_lib LINK_LIBRARIES boost_system_std_single_instance_lib1 boost_system_std_single_instance_lib2)
|
||||||
+17
-1
@@ -61,7 +61,11 @@ system-run failed_constexpr_test.cpp ;
|
|||||||
# Quick (CI) test
|
# Quick (CI) test
|
||||||
run quick.cpp ;
|
run quick.cpp ;
|
||||||
|
|
||||||
run warnings_test.cpp : : : <warnings>all <warnings-as-errors>on <toolset>gcc:<cxxflags>-Wnon-virtual-dtor <toolset>clang:<cxxflags>-Wnon-virtual-dtor ;
|
compile warnings_test.cpp
|
||||||
|
: <warnings>pedantic
|
||||||
|
<toolset>msvc:<warnings-as-errors>on
|
||||||
|
<toolset>gcc:<warnings-as-errors>on
|
||||||
|
<toolset>clang:<warnings-as-errors>on ;
|
||||||
|
|
||||||
lib std_single_instance_lib1 : std_single_instance_1.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
|
lib std_single_instance_lib1 : std_single_instance_1.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
|
||||||
lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
|
lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
|
||||||
@@ -69,3 +73,15 @@ lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>
|
|||||||
system-run std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp ;
|
system-run std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp ;
|
||||||
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>static : std_single_instance_lib_static ;
|
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>static : std_single_instance_lib_static ;
|
||||||
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>shared <define>STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ;
|
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>shared <define>STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ;
|
||||||
|
|
||||||
|
run is_error_code_enum_test.cpp ;
|
||||||
|
run is_error_condition_enum_test.cpp ;
|
||||||
|
run errc_test.cpp ;
|
||||||
|
run errc_test2.cpp ;
|
||||||
|
run error_category_test2.cpp ;
|
||||||
|
run error_condition_test.cpp ;
|
||||||
|
run error_condition_test2.cpp ;
|
||||||
|
run generic_category_test2.cpp ;
|
||||||
|
run generic_category_test3.cpp ;
|
||||||
|
run system_category_test2.cpp ;
|
||||||
|
run system_category_test3.cpp ;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Copyright 2018, 2019 Peter Dimov
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5...3.16)
|
||||||
|
|
||||||
|
project(cmake_install_test LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_package(boost_system REQUIRED)
|
||||||
|
find_package(boost_core REQUIRED)
|
||||||
|
|
||||||
|
add_executable(quick ../quick.cpp)
|
||||||
|
target_link_libraries(quick Boost::system Boost::core)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(quick quick)
|
||||||
|
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5...3.16)
|
||||||
|
|
||||||
project(cmake_subdir_test LANGUAGES CXX)
|
project(cmake_subdir_test LANGUAGES CXX)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2020 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/errc.hpp>
|
||||||
|
#include <boost/system/is_error_condition_enum.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( static_cast<int>( boost::system::errc::success ), 0 );
|
||||||
|
BOOST_TEST_EQ( static_cast<int>( boost::system::errc::no_such_file_or_directory ), ENOENT );
|
||||||
|
BOOST_TEST_EQ( static_cast<int>( boost::system::errc::address_family_not_supported ), EAFNOSUPPORT );
|
||||||
|
|
||||||
|
BOOST_TEST( boost::system::is_error_condition_enum< boost::system::errc::errc_t >::value );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2020 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/errc.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( make_error_code( boost::system::errc::success ).value(), 0 );
|
||||||
|
BOOST_TEST_EQ( make_error_condition( boost::system::errc::success ).value(), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( make_error_code( boost::system::errc::no_such_file_or_directory ).value(), ENOENT );
|
||||||
|
BOOST_TEST_EQ( make_error_condition( boost::system::errc::no_such_file_or_directory ).value(), ENOENT );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( make_error_code( boost::system::errc::address_family_not_supported ).value(), EAFNOSUPPORT );
|
||||||
|
BOOST_TEST_EQ( make_error_condition( boost::system::errc::address_family_not_supported ).value(), EAFNOSUPPORT );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
// Copyright 2018, 2020 Peter Dimov.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
//
|
||||||
|
// See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
// Avoid spurious VC++ warnings
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
|
#include <boost/system/error_category.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
class user_category: public sys::error_category
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual const char * name() const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return "user";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string message( int ev ) const
|
||||||
|
{
|
||||||
|
char buffer[ 256 ];
|
||||||
|
std::sprintf( buffer, "user message %d", ev );
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
using sys::error_category::message;
|
||||||
|
};
|
||||||
|
|
||||||
|
static user_category s_cat_1;
|
||||||
|
static user_category s_cat_2;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// default_error_condition
|
||||||
|
|
||||||
|
BOOST_TEST( s_cat_1.default_error_condition( 1 ).value() == 1 );
|
||||||
|
BOOST_TEST( s_cat_1.default_error_condition( 1 ).category() == s_cat_1 );
|
||||||
|
|
||||||
|
BOOST_TEST( s_cat_2.default_error_condition( 2 ).value() == 2 );
|
||||||
|
BOOST_TEST( s_cat_2.default_error_condition( 2 ).category() == s_cat_2 );
|
||||||
|
|
||||||
|
// equivalent
|
||||||
|
|
||||||
|
BOOST_TEST( s_cat_1.equivalent( 1, s_cat_1.default_error_condition( 1 ) ) );
|
||||||
|
BOOST_TEST( !s_cat_1.equivalent( 1, s_cat_1.default_error_condition( 2 ) ) );
|
||||||
|
BOOST_TEST( !s_cat_1.equivalent( 1, s_cat_2.default_error_condition( 2 ) ) );
|
||||||
|
|
||||||
|
// message
|
||||||
|
|
||||||
|
{
|
||||||
|
char buffer[ 256 ];
|
||||||
|
BOOST_TEST_CSTR_EQ( s_cat_1.message( 1, buffer, sizeof( buffer ) ), s_cat_1.message( 1 ).c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char buffer[ 4 ];
|
||||||
|
BOOST_TEST_CSTR_EQ( s_cat_1.message( 1, buffer, sizeof( buffer ) ), "use" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==
|
||||||
|
|
||||||
|
BOOST_TEST_NOT( s_cat_1 == s_cat_2 );
|
||||||
|
BOOST_TEST( s_cat_1 != s_cat_2 );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2020 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/error_condition.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sys::error_condition en;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( en.value(), 0 );
|
||||||
|
BOOST_TEST( !en );
|
||||||
|
|
||||||
|
sys::error_condition en2( en );
|
||||||
|
|
||||||
|
BOOST_TEST( en == en2 );
|
||||||
|
BOOST_TEST_NOT( en != en2 );
|
||||||
|
|
||||||
|
en2.assign( 1, en.category() );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( en2.value(), 1 );
|
||||||
|
BOOST_TEST( en2 );
|
||||||
|
|
||||||
|
BOOST_TEST_NOT( en == en2 );
|
||||||
|
BOOST_TEST( en != en2 );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2020 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/error_condition.hpp>
|
||||||
|
#include <boost/system/errc.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sys::error_condition en( sys::errc::no_such_file_or_directory );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( en.value(), ENOENT );
|
||||||
|
|
||||||
|
BOOST_TEST( en );
|
||||||
|
BOOST_TEST( !!en );
|
||||||
|
|
||||||
|
BOOST_TEST( en == make_error_condition( sys::errc::no_such_file_or_directory ) );
|
||||||
|
|
||||||
|
BOOST_TEST( en.category() == sys::error_condition().category() );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -123,13 +123,13 @@ template<class Ec> void test()
|
|||||||
|
|
||||||
{
|
{
|
||||||
Ec ec( 0, http_category() );
|
Ec ec( 0, http_category() );
|
||||||
BOOST_TEST( ec.failed() );
|
TEST_FAILED( ec );
|
||||||
|
|
||||||
ec.assign( 200, http_category() );
|
ec.assign( 200, http_category() );
|
||||||
BOOST_TEST( !ec.failed() );
|
TEST_NOT_FAILED( ec );
|
||||||
|
|
||||||
ec = Ec( 404, http_category() );
|
ec = Ec( 404, http_category() );
|
||||||
BOOST_TEST( ec.failed() );
|
TEST_FAILED( ec );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/generic_category.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
// Tests whether generic_category() is functional when only
|
||||||
|
// generic_category.hpp is included
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sys::error_category const & cat = sys::generic_category();
|
||||||
|
|
||||||
|
BOOST_TEST_CSTR_EQ( cat.name(), "generic" );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/generic_category.hpp>
|
||||||
|
#include <boost/system/error_condition.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sys::error_category const & cat = sys::generic_category();
|
||||||
|
|
||||||
|
// name
|
||||||
|
BOOST_TEST_CSTR_EQ( cat.name(), "generic" );
|
||||||
|
|
||||||
|
// default_error_condition
|
||||||
|
BOOST_TEST( cat.default_error_condition( 0 ) == sys::error_condition( 0, cat ) );
|
||||||
|
BOOST_TEST( cat.default_error_condition( ENOENT ) == sys::error_condition( ENOENT, cat ) );
|
||||||
|
BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
|
||||||
|
|
||||||
|
// failed
|
||||||
|
BOOST_TEST( !cat.failed( 0 ) );
|
||||||
|
BOOST_TEST( cat.failed( ENOENT ) );
|
||||||
|
BOOST_TEST( cat.failed( -1 ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2020 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/is_error_code_enum.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
enum error
|
||||||
|
{
|
||||||
|
success = 0,
|
||||||
|
e1,
|
||||||
|
e2,
|
||||||
|
e3
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
template<> struct is_error_code_enum< ::error >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::system::error_code make_error_code( ::error e );
|
||||||
|
|
||||||
|
enum not_error
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST( boost::system::is_error_code_enum< ::error >::value );
|
||||||
|
BOOST_TEST( !boost::system::is_error_code_enum< ::not_error >::value );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright 2020 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/is_error_condition_enum.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
enum condition
|
||||||
|
{
|
||||||
|
c1 = 1,
|
||||||
|
c2,
|
||||||
|
c3
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
template<> struct is_error_condition_enum< ::condition >
|
||||||
|
{
|
||||||
|
static const bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::system::error_condition make_error_condition( ::condition e );
|
||||||
|
|
||||||
|
enum not_condition
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST( boost::system::is_error_condition_enum< ::condition >::value );
|
||||||
|
BOOST_TEST( !boost::system::is_error_condition_enum< ::not_condition >::value );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/system_error.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@@ -32,5 +33,10 @@ int main()
|
|||||||
|
|
||||||
BOOST_TEST( bc == bn );
|
BOOST_TEST( bc == bn );
|
||||||
|
|
||||||
|
boost::system::system_error x( bc, "prefix" );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( x.code(), bc );
|
||||||
|
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/system_category.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
// Tests whether system_category() is functional when only
|
||||||
|
// system_category.hpp is included
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sys::error_category const & cat = sys::system_category();
|
||||||
|
|
||||||
|
BOOST_TEST_CSTR_EQ( cat.name(), "system" );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/system_category.hpp>
|
||||||
|
#include <boost/system/generic_category.hpp>
|
||||||
|
#include <boost/system/error_condition.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sys::error_category const & cat = sys::system_category();
|
||||||
|
|
||||||
|
// name
|
||||||
|
BOOST_TEST_CSTR_EQ( cat.name(), "system" );
|
||||||
|
|
||||||
|
// default_error_condition
|
||||||
|
BOOST_TEST( cat.default_error_condition( 0 ) == sys::error_condition() );
|
||||||
|
BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
|
||||||
|
|
||||||
|
#if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
BOOST_TEST( cat.default_error_condition( 5 ) == sys::error_condition( EACCES, sys::generic_category() ) );
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
BOOST_TEST( cat.default_error_condition( EACCES ) == sys::error_condition( EACCES, sys::generic_category() ) );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// failed
|
||||||
|
BOOST_TEST( !cat.failed( 0 ) );
|
||||||
|
BOOST_TEST( cat.failed( 5 ) );
|
||||||
|
BOOST_TEST( cat.failed( -1 ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -8,12 +8,17 @@
|
|||||||
|
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && __GNUC__ >= 5 && __cplusplus >= 201103L
|
||||||
|
# pragma GCC diagnostic error "-Wsuggest-override"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
#if defined( BOOST_GCC ) && BOOST_GCC < 40600
|
#if defined( BOOST_GCC ) && BOOST_GCC < 40600
|
||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/system/system_error.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@@ -38,5 +43,10 @@ int main()
|
|||||||
|
|
||||||
BOOST_TEST( bc == bn );
|
BOOST_TEST( bc == bn );
|
||||||
|
|
||||||
|
boost::system::system_error x( bc, "prefix" );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( x.code(), bc );
|
||||||
|
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user