File indexing completed on 2025-01-30 09:44:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_XSI_KEY_HPP
0012 #define BOOST_INTERPROCESS_XSI_KEY_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/detail/workaround.hpp>
0025
0026 #if !defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
0027 #error "This header can't be used in operating systems without XSI (System V) shared memory support"
0028 #endif
0029
0030 #include <boost/interprocess/creation_tags.hpp>
0031 #include <boost/interprocess/exceptions.hpp>
0032 #include <boost/interprocess/detail/utilities.hpp>
0033 #include <boost/move/utility_core.hpp>
0034 #include <boost/interprocess/detail/os_file_functions.hpp>
0035 #include <boost/interprocess/interprocess_fwd.hpp>
0036 #include <boost/interprocess/exceptions.hpp>
0037 #include <sys/types.h>
0038 #include <sys/ipc.h>
0039 #include <cstddef>
0040 #include <boost/cstdint.hpp>
0041
0042
0043
0044
0045 namespace boost {
0046 namespace interprocess {
0047
0048
0049
0050
0051
0052 class xsi_key
0053 {
0054 public:
0055
0056
0057
0058 xsi_key()
0059 : m_key(IPC_PRIVATE)
0060 {}
0061
0062
0063 explicit xsi_key(key_t key)
0064 : m_key(key)
0065 {}
0066
0067
0068
0069
0070 xsi_key(const char *path, boost::uint8_t id)
0071 {
0072 key_t key;
0073 if(path){
0074 key = ::ftok(path, id);
0075 if(((key_t)-1) == key){
0076 error_info err = system_error_code();
0077 throw interprocess_exception(err);
0078 }
0079 }
0080 else{
0081 key = IPC_PRIVATE;
0082 }
0083 m_key = key;
0084 }
0085
0086
0087 key_t get_key() const
0088 { return m_key; }
0089
0090 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0091 private:
0092 key_t m_key;
0093 #endif
0094 };
0095
0096 }
0097 }
0098
0099 #include <boost/interprocess/detail/config_end.hpp>
0100
0101 #endif