fake_file_writer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The Cartographer Authors
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 #ifndef CARTOGRAPHER_IO_FAKE_FILE_WRITER_H_
18 #define CARTOGRAPHER_IO_FAKE_FILE_WRITER_H_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
25 
26 namespace cartographer {
27 namespace io {
28 
29 // Fakes a FileWriter by just writing the data to a std::vector<char>.
30 class FakeFileWriter : public FileWriter {
31  public:
32  FakeFileWriter(const std::string& filename,
33  std::shared_ptr<std::vector<char>> content);
34  ~FakeFileWriter() override = default;
35 
36  bool WriteHeader(const char* data, size_t len) override;
37  bool Write(const char* data, size_t len) override;
38  bool Close() override;
39  std::string GetFilename() override;
40 
41  private:
42  bool is_closed_;
43  std::shared_ptr<std::vector<char>> content_;
44  std::string filename_;
45 };
46 
47 } // namespace io
48 } // namespace cartographer
49 
50 #endif // CARTOGRAPHER_IO_FAKE_FILE_WRITER_H_
FakeFileWriter(const std::string &filename, std::shared_ptr< std::vector< char >> content)
std::shared_ptr< std::vector< char > > content_
bool Write(const char *data, size_t len) override
bool WriteHeader(const char *data, size_t len) override
~FakeFileWriter() override=default
std::string GetFilename() override


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58