File indexing completed on 2025-01-18 09:39:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef BOOST_LOG_UTILITY_PERMISSIONS_HPP_INCLUDED_
0018 #define BOOST_LOG_UTILITY_PERMISSIONS_HPP_INCLUDED_
0019
0020 #include <boost/log/detail/config.hpp>
0021 #include <boost/log/detail/header.hpp>
0022
0023 #ifdef BOOST_HAS_PRAGMA_ONCE
0024 #pragma once
0025 #endif
0026
0027 #ifdef BOOST_WINDOWS
0028 extern "C" {
0029 struct _SECURITY_ATTRIBUTES;
0030 }
0031 #endif
0032
0033 namespace boost {
0034
0035 #ifdef BOOST_WINDOWS
0036 #if defined(BOOST_GCC) && BOOST_GCC >= 40600
0037 #pragma GCC diagnostic push
0038
0039 #pragma GCC diagnostic ignored "-Wattributes"
0040 #endif
0041 namespace winapi {
0042 struct BOOST_LOG_MAY_ALIAS _SECURITY_ATTRIBUTES;
0043 }
0044 #if defined(BOOST_GCC) && BOOST_GCC >= 40600
0045 #pragma GCC diagnostic pop
0046 #endif
0047 #endif
0048
0049 namespace interprocess {
0050 class permissions;
0051 }
0052
0053 BOOST_LOG_OPEN_NAMESPACE
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 class permissions
0065 {
0066 public:
0067 #if defined(BOOST_LOG_DOXYGEN_PASS)
0068
0069 typedef implementation_defined native_type;
0070 #elif defined(BOOST_WINDOWS)
0071 typedef ::_SECURITY_ATTRIBUTES* native_type;
0072 #else
0073
0074 typedef unsigned int native_type;
0075 #endif
0076
0077 #if !defined(BOOST_LOG_DOXYGEN_PASS)
0078 private:
0079 native_type m_perms;
0080 #endif
0081
0082 public:
0083
0084
0085
0086
0087
0088 permissions() BOOST_NOEXCEPT
0089 {
0090 set_default();
0091 }
0092
0093
0094
0095
0096 permissions(permissions const& that) BOOST_NOEXCEPT : m_perms(that.m_perms)
0097 {
0098 }
0099
0100
0101
0102
0103 permissions& operator=(permissions const& that) BOOST_NOEXCEPT
0104 {
0105 m_perms = that.m_perms;
0106 return *this;
0107 }
0108
0109
0110
0111
0112 permissions(native_type perms) BOOST_NOEXCEPT : m_perms(perms)
0113 {
0114 }
0115
0116 #ifdef BOOST_WINDOWS
0117 permissions(boost::winapi::_SECURITY_ATTRIBUTES* perms) BOOST_NOEXCEPT : m_perms(reinterpret_cast< native_type >(perms))
0118 {
0119 }
0120 #endif
0121
0122
0123
0124
0125 BOOST_LOG_API permissions(boost::interprocess::permissions const& perms) BOOST_NOEXCEPT;
0126
0127 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0128
0129
0130
0131 permissions(permissions&& that) BOOST_NOEXCEPT : m_perms(that.m_perms)
0132 {
0133 that.set_default();
0134 }
0135
0136
0137
0138
0139 permissions& operator=(permissions&& that) BOOST_NOEXCEPT
0140 {
0141 m_perms = that.m_perms;
0142 that.set_default();
0143 return *this;
0144 }
0145 #endif
0146
0147
0148
0149
0150 void set_native(native_type perms) BOOST_NOEXCEPT
0151 {
0152 m_perms = perms;
0153 }
0154
0155
0156
0157
0158 native_type get_native() const BOOST_NOEXCEPT
0159 {
0160 return m_perms;
0161 }
0162
0163
0164
0165
0166
0167 void set_default() BOOST_NOEXCEPT
0168 {
0169 #if defined(BOOST_WINDOWS)
0170 m_perms = 0;
0171 #else
0172 m_perms = 0644;
0173 #endif
0174 }
0175
0176
0177
0178
0179
0180 void set_unrestricted()
0181 {
0182 #if defined(BOOST_WINDOWS)
0183 m_perms = get_unrestricted_security_attributes();
0184 #else
0185 m_perms = 0666;
0186 #endif
0187 }
0188
0189
0190
0191
0192
0193
0194 void swap(permissions& that) BOOST_NOEXCEPT
0195 {
0196 native_type perms = m_perms;
0197 m_perms = that.m_perms;
0198 that.m_perms = perms;
0199 }
0200
0201
0202 friend void swap(permissions& a, permissions& b) BOOST_NOEXCEPT
0203 {
0204 a.swap(b);
0205 }
0206
0207 #if !defined(BOOST_LOG_DOXYGEN_PASS) && defined(BOOST_WINDOWS)
0208 private:
0209 static BOOST_LOG_API native_type get_unrestricted_security_attributes();
0210 #endif
0211 };
0212
0213 BOOST_LOG_CLOSE_NAMESPACE
0214
0215 }
0216
0217 #include <boost/log/detail/footer.hpp>
0218
0219 #endif