1 /* 2 * Copyright 2023 Google Inc. All rights reserved. 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 #include <fstream> 18 #include <set> 19 #include <string> 20 21 #include "flatbuffers/file_manager.h" 22 23 namespace flatbuffers { 24 25 class FileNameSavingFileManager : public FileManager { 26 public: FileNameSavingFileManager(std::set<std::string> file_names)27 FileNameSavingFileManager(std::set<std::string> file_names) 28 : file_names_(file_names) {} 29 SaveFile(const std::string & absolute_file_name,const std::string & content)30 bool SaveFile(const std::string &absolute_file_name, 31 const std::string &content) override { 32 (void)content; 33 auto pair = file_names_.insert(absolute_file_name); 34 // pair.second indicates whether the insertion is 35 // successful or not. 36 return pair.second; 37 } 38 Loadfile(const std::string & absolute_file_name,std::string * content)39 bool Loadfile(const std::string &absolute_file_name, std::string *content) { 40 (void)absolute_file_name; 41 (void)content; 42 return false; 43 } 44 45 private: 46 std::set<std::string> file_names_; 47 }; 48 49 } // namespace flatbuffers 50