config.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright Antony Polukhin, 2018-2024.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /// \file boost/dll/config.hpp
  7. /// \brief Imports filesystem, error_code, errc, system_error, make_error_code from Boost or C++17 into `boost::dll::fs` namespace.
  8. #ifndef BOOST_DLL_DETAIL_CONFIG_HPP
  9. #define BOOST_DLL_DETAIL_CONFIG_HPP
  10. #include <boost/config.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. # pragma once
  13. #endif
  14. #ifdef BOOST_DLL_DOXYGEN
  15. /// Define this macro to make Boost.DLL use C++17's std::filesystem::path, std::system_error and std::error_code.
  16. #define BOOST_DLL_USE_STD_FS BOOST_DLL_USE_STD_FS
  17. /// This namespace contains aliases to the Boost or C++17 classes. Aliases are configured using BOOST_DLL_USE_STD_FS macro.
  18. namespace boost { namespace dll { namespace fs {
  19. /// Alias to `std::filesystem::path` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
  20. /// Alias to `boost::filesystem::path` otherwise.
  21. using path = std::conditional_t<BOOST_DLL_USE_STD_FS, std::filesystem::path, boost::filesystem::path>;
  22. /// Alias to `std::error_code` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
  23. /// boost::system::error_code otherwise.
  24. using error_code = std::conditional_t<BOOST_DLL_USE_STD_FS, std::error_code, boost::system::error_code>;
  25. /// Alias to `std::system_error` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
  26. /// Alias to `boost::system::system_error` otherwise.
  27. using system_error = std::conditional_t<BOOST_DLL_USE_STD_FS, std::system_error, boost::system::system_error>;
  28. }}}
  29. #endif
  30. #ifdef BOOST_DLL_USE_STD_FS
  31. #include <filesystem>
  32. #include <system_error>
  33. namespace boost { namespace dll { namespace fs {
  34. using namespace std::filesystem;
  35. using std::error_code;
  36. using std::system_error;
  37. using std::make_error_code;
  38. using std::errc;
  39. using std::system_category;
  40. }}}
  41. #else // BOOST_DLL_USE_STD_FS
  42. #include <boost/filesystem/path.hpp>
  43. #include <boost/filesystem/operations.hpp>
  44. #include <boost/system/error_code.hpp>
  45. #include <boost/system/system_error.hpp>
  46. namespace boost { namespace dll { namespace fs {
  47. using namespace boost::filesystem;
  48. using boost::system::error_code;
  49. using boost::system::system_error;
  50. using boost::system::errc::make_error_code;
  51. namespace errc = boost::system::errc;
  52. using boost::system::system_category;
  53. }}}
  54. #endif // BOOST_DLL_USE_STD_FS
  55. #endif // BOOST_DLL_DETAIL_PUSH_OPTIONS_HPP