proxygen
File.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
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 #pragma once
18 #define FOLLY_GEN_FILE_H_
19 
20 #include <folly/File.h>
21 #include <folly/gen/Base.h>
22 #include <folly/io/IOBuf.h>
23 
24 namespace folly {
25 namespace gen {
26 
27 namespace detail {
28 class FileReader;
29 class FileWriter;
30 } // namespace detail
31 
37 template <class S = detail::FileReader>
38 S fromFile(File file, size_t bufferSize = 4096) {
39  return S(std::move(file), IOBuf::create(bufferSize));
40 }
41 
45 template <class S = detail::FileReader>
46 S fromFile(File file, std::unique_ptr<IOBuf> buffer) {
47  return S(std::move(file), std::move(buffer));
48 }
49 
54 template <class S = detail::FileWriter>
55 S toFile(File file, size_t bufferSize = 4096) {
56  return S(std::move(file), bufferSize ? nullptr : IOBuf::create(bufferSize));
57 }
58 
63 template <class S = detail::FileWriter>
64 S toFile(File file, std::unique_ptr<IOBuf> buffer) {
65  return S(std::move(file), std::move(buffer));
66 }
67 } // namespace gen
68 } // namespace folly
69 
70 #include <folly/gen/File-inl.h>
std::vector< uint8_t > buffer(kBufferSize+16)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
S fromFile(File file, size_t bufferSize=4096)
Definition: File.h:38
S toFile(File file, size_t bufferSize=4096)
Definition: File.h:55