C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
fileio.h
1 /***
2 * ==++==
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * ==--==
17 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
18 *
19 * fileio.h
20 *
21 * Asynchronous I/O: stream buffer implementation details
22 *
23 * We're going to some lengths to avoid exporting C++ class member functions and implementation details across
24 * module boundaries, and the factoring requires that we keep the implementation details away from the main header
25 * files. The supporting functions, which are in this file, use C-like signatures to avoid as many issues as
26 * possible.
27 *
28 * For the latest on this and related APIs, please see http://casablanca.codeplex.com.
29 *
30 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
31 ****/
32 #pragma once
33 
34 #ifdef _WIN32
35 #include <cstdint>
36 #endif
37 
38 #include "pplx/pplxtasks.h"
39 #include "cpprest/details/basic_types.h"
40 
41 namespace Concurrency { namespace streams
42 {
43 namespace details
44 {
50  struct _file_info
51  {
52  _ASYNCRTIMP _file_info(std::ios_base::openmode mode, size_t buffer_size) :
53  m_rdpos(0),
54  m_wrpos(0),
55  m_atend(false),
56  m_buffer_size(buffer_size),
57  m_buffer(nullptr),
58  m_bufoff(0),
59  m_bufsize(0),
60  m_buffill(0),
61  m_mode(mode)
62  {
63  }
64 
65  // Positional data
66 
67  size_t m_rdpos;
68  size_t m_wrpos;
69  bool m_atend;
70 
71  // Input buffer
72 
73  size_t m_buffer_size; // The intended size of the buffer to read into.
74  char *m_buffer;
75 
76  size_t m_bufoff; // File position that the start of the buffer represents.
77  msl::safeint3::SafeInt<size_t> m_bufsize; // Buffer allocated size, as actually allocated.
78  size_t m_buffill; // Amount of file data actually in the buffer
79 
80  std::ios_base::openmode m_mode;
81 
83  };
84 
85 
90  {
91  public:
92  virtual void on_opened(_In_ details::_file_info *) { }
93  virtual void on_closed() { }
94  virtual void on_error(const std::exception_ptr &) { }
95  virtual void on_completed(size_t) { }
96  protected:
97  virtual ~_filestream_callback() {}
98  };
99 
100 }
101 }}
102 
103 extern "C"
104 {
116 #if !defined(__cplusplus_winrt)
117 _ASYNCRTIMP bool __cdecl _open_fsb_str(_In_ concurrency::streams::details::_filestream_callback *callback, const utility::char_t *filename, std::ios_base::openmode mode, int prot);
118 #endif
119 
131 #if defined(__cplusplus_winrt)
132 _ASYNCRTIMP bool __cdecl _open_fsb_stf_str(_In_ concurrency::streams::details::_filestream_callback *callback, ::Windows::Storage::StorageFile^ file, std::ios_base::openmode mode, int prot);
133 #endif
134 
144 _ASYNCRTIMP bool __cdecl _close_fsb_nolock(_In_ concurrency::streams::details::_file_info **info, _In_ concurrency::streams::details::_filestream_callback *callback);
145 _ASYNCRTIMP bool __cdecl _close_fsb(_In_ concurrency::streams::details::_file_info **info, _In_ concurrency::streams::details::_filestream_callback *callback);
146 
147 
156 _ASYNCRTIMP size_t __cdecl _putn_fsb(_In_ concurrency::streams::details::_file_info *info, _In_ concurrency::streams::details::_filestream_callback *callback, const void *ptr, size_t count, size_t char_size);
157 
166 _ASYNCRTIMP size_t __cdecl _getn_fsb(_In_ concurrency::streams::details::_file_info *info, _In_ concurrency::streams::details::_filestream_callback *callback, _Out_writes_ (count) void *ptr, _In_ size_t count, size_t char_size);
167 
174 _ASYNCRTIMP bool __cdecl _sync_fsb(_In_ concurrency::streams::details::_file_info *info, _In_ concurrency::streams::details::_filestream_callback *callback);
175 
181 _ASYNCRTIMP utility::size64_t __cdecl _get_size(_In_ concurrency::streams::details::_file_info *info, size_t char_size);
182 
189 _ASYNCRTIMP size_t __cdecl _seekrdpos_fsb(_In_ concurrency::streams::details::_file_info *info, size_t pos, size_t char_size);
190 
197 _ASYNCRTIMP size_t __cdecl _seekrdtoend_fsb(_In_ concurrency::streams::details::_file_info *info, int64_t offset, size_t char_size);
198 
205 _ASYNCRTIMP size_t __cdecl _seekwrpos_fsb(_In_ concurrency::streams::details::_file_info *info, size_t pos, size_t char_size);
206 }
Recursive mutex
Definition: pplxlinux.h:196
This interface provides the necessary callbacks for completion events.
Definition: fileio.h:89
Definition: astreambuf.h:37
A record containing the essential private data members of a file stream, in particular the parts that...
Definition: fileio.h:50