cpp-mate  0.7
Helpful library for C++.
FileWriter.hpp
1 /*
2  * Copyright (C) 2020 Alexander Kornilov (akornilov.82@gmail.com)
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 CPP_MATE_FILE_WRITER_HPP
18 #define CPP_MATE_FILE_WRITER_HPP
19 
20 #include <CppMate/BinarySink.hpp>
21 
22 #include <string>
23 #include <memory>
24 
25 namespace CppMate {
26 
30 class FileWriter: public virtual BinarySink::Closeable
31 {
32 public:
33 
37  enum class Mode {
38  New,
39  Overwrite,
40  Append
41  };
42 
47  virtual std::string getFilename() const = 0;
48 
56  static std::shared_ptr<FileWriter> create(const std::string& filename, Mode mode);
57 };
58 
59 } // namespace CppMate
60 
61 #endif // CPP_MATE_FILE_WRITER_HPP
Represents closable extension of the BinarySink interface.
Definition: BinarySink.hpp:62
Represents file writer with platform-dependent implementation.
Definition: FileWriter.hpp:31
Mode
The creation mode.
Definition: FileWriter.hpp:37
@ New
Creates new file and throws exception if it already exists.
@ Append
Appends data to the end of the existing file.
@ Overwrite
Overwrites file if it already exists.
virtual std::string getFilename() const =0
Returns name of file.
static std::shared_ptr< FileWriter > create(const std::string &filename, Mode mode)
Creates new file writer for specified filename.
Definition: BinaryData.hpp:28