perm_options.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
  10. #define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
  11. #include <__availability>
  12. #include <__config>
  13. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  14. # pragma GCC system_header
  15. #endif
  16. #ifndef _LIBCPP_CXX03_LANG
  17. _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
  18. enum class perm_options : unsigned char {
  19. replace = 1,
  20. add = 2,
  21. remove = 4,
  22. nofollow = 8
  23. };
  24. _LIBCPP_INLINE_VISIBILITY
  25. inline constexpr perm_options operator&(perm_options __lhs, perm_options __rhs) {
  26. return static_cast<perm_options>(static_cast<unsigned>(__lhs) &
  27. static_cast<unsigned>(__rhs));
  28. }
  29. _LIBCPP_INLINE_VISIBILITY
  30. inline constexpr perm_options operator|(perm_options __lhs, perm_options __rhs) {
  31. return static_cast<perm_options>(static_cast<unsigned>(__lhs) |
  32. static_cast<unsigned>(__rhs));
  33. }
  34. _LIBCPP_INLINE_VISIBILITY
  35. inline constexpr perm_options operator^(perm_options __lhs, perm_options __rhs) {
  36. return static_cast<perm_options>(static_cast<unsigned>(__lhs) ^
  37. static_cast<unsigned>(__rhs));
  38. }
  39. _LIBCPP_INLINE_VISIBILITY
  40. inline constexpr perm_options operator~(perm_options __lhs) {
  41. return static_cast<perm_options>(~static_cast<unsigned>(__lhs));
  42. }
  43. _LIBCPP_INLINE_VISIBILITY
  44. inline perm_options& operator&=(perm_options& __lhs, perm_options __rhs) {
  45. return __lhs = __lhs & __rhs;
  46. }
  47. _LIBCPP_INLINE_VISIBILITY
  48. inline perm_options& operator|=(perm_options& __lhs, perm_options __rhs) {
  49. return __lhs = __lhs | __rhs;
  50. }
  51. _LIBCPP_INLINE_VISIBILITY
  52. inline perm_options& operator^=(perm_options& __lhs, perm_options __rhs) {
  53. return __lhs = __lhs ^ __rhs;
  54. }
  55. _LIBCPP_END_NAMESPACE_FILESYSTEM
  56. #endif // _LIBCPP_CXX03_LANG
  57. #endif // _LIBCPP___FILESYSTEM_PERM_OPTIONS_H