]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/file_base.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / file_base.hpp
CommitLineData
1e59de90
TL
1//
2// file_base.hpp
3// ~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#ifndef BOOST_ASIO_FILE_BASE_HPP
12#define BOOST_ASIO_FILE_BASE_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19
20#if defined(BOOST_ASIO_HAS_FILE) \
21 || defined(GENERATING_DOCUMENTATION)
22
23#if !defined(BOOST_ASIO_WINDOWS)
24# include <fcntl.h>
25#endif // !defined(BOOST_ASIO_WINDOWS)
26
27#include <boost/asio/detail/push_options.hpp>
28
29namespace boost {
30namespace asio {
31
32/// The file_base class is used as a base for the basic_stream_file and
33/// basic_random_access_file class templates so that we have a common place to
34/// define flags.
35class file_base
36{
37public:
38#if defined(GENERATING_DOCUMENTATION)
39 /// A bitmask type (C++ Std [lib.bitmask.types]).
40 typedef unspecified flags;
41
42 /// Open the file for reading.
43 static const flags read_only = implementation_defined;
44
45 /// Open the file for writing.
46 static const flags write_only = implementation_defined;
47
48 /// Open the file for reading and writing.
49 static const flags read_write = implementation_defined;
50
51 /// Open the file in append mode.
52 static const flags append = implementation_defined;
53
54 /// Create the file if it does not exist.
55 static const flags create = implementation_defined;
56
57 /// Ensure a new file is created. Must be combined with @c create.
58 static const flags exclusive = implementation_defined;
59
60 /// Open the file with any existing contents truncated.
61 static const flags truncate = implementation_defined;
62
63 /// Open the file so that write operations automatically synchronise the file
64 /// data and metadata to disk.
65 static const flags sync_all_on_write = implementation_defined;
66#else
67 enum flags
68 {
69#if defined(BOOST_ASIO_WINDOWS)
70 read_only = 1,
71 write_only = 2,
72 read_write = 4,
73 append = 8,
74 create = 16,
75 exclusive = 32,
76 truncate = 64,
77 sync_all_on_write = 128
78#else // defined(BOOST_ASIO_WINDOWS)
79 read_only = O_RDONLY,
80 write_only = O_WRONLY,
81 read_write = O_RDWR,
82 append = O_APPEND,
83 create = O_CREAT,
84 exclusive = O_EXCL,
85 truncate = O_TRUNC,
86 sync_all_on_write = O_SYNC
87#endif // defined(BOOST_ASIO_WINDOWS)
88 };
89
90 // Implement bitmask operations as shown in C++ Std [lib.bitmask.types].
91
92 friend flags operator&(flags x, flags y)
93 {
94 return static_cast<flags>(
95 static_cast<unsigned int>(x) & static_cast<unsigned int>(y));
96 }
97
98 friend flags operator|(flags x, flags y)
99 {
100 return static_cast<flags>(
101 static_cast<unsigned int>(x) | static_cast<unsigned int>(y));
102 }
103
104 friend flags operator^(flags x, flags y)
105 {
106 return static_cast<flags>(
107 static_cast<unsigned int>(x) ^ static_cast<unsigned int>(y));
108 }
109
110 friend flags operator~(flags x)
111 {
112 return static_cast<flags>(~static_cast<unsigned int>(x));
113 }
114
115 friend flags& operator&=(flags& x, flags y)
116 {
117 x = x & y;
118 return x;
119 }
120
121 friend flags& operator|=(flags& x, flags y)
122 {
123 x = x | y;
124 return x;
125 }
126
127 friend flags& operator^=(flags& x, flags y)
128 {
129 x = x ^ y;
130 return x;
131 }
132#endif
133
134 /// Basis for seeking in a file.
135 enum seek_basis
136 {
137#if defined(GENERATING_DOCUMENTATION)
138 /// Seek to an absolute position.
139 seek_set = implementation_defined,
140
141 /// Seek to an offset relative to the current file position.
142 seek_cur = implementation_defined,
143
144 /// Seek to an offset relative to the end of the file.
145 seek_end = implementation_defined
146#else
147 seek_set = SEEK_SET,
148 seek_cur = SEEK_CUR,
149 seek_end = SEEK_END
150#endif
151 };
152
153protected:
154 /// Protected destructor to prevent deletion through this type.
155 ~file_base()
156 {
157 }
158};
159
160} // namespace asio
161} // namespace boost
162
163#include <boost/asio/detail/pop_options.hpp>
164
165#endif // defined(BOOST_ASIO_HAS_FILE)
166 // || defined(GENERATING_DOCUMENTATION)
167
168#endif // BOOST_ASIO_FILE_BASE_HPP