retdec-cpp
file.h
Go to the documentation of this file.
1 
8 #ifndef RETDEC_FILE_H
9 #define RETDEC_FILE_H
10 
11 #include <memory>
12 #include <string>
13 
14 namespace retdec {
15 
19 class File {
20 public:
21  virtual ~File() = 0;
22 
23  virtual std::string getName() const = 0;
24  virtual std::string getContent() = 0;
25  virtual void saveCopyTo(const std::string &directoryPath) = 0;
26  virtual void saveCopyTo(const std::string &directoryPath,
27  const std::string &name) = 0;
28 
29  static std::unique_ptr<File> fromContentWithName(
30  const std::string &content, const std::string &name);
31  static std::unique_ptr<File> fromFilesystem(const std::string &path);
32  static std::unique_ptr<File> fromFilesystemWithOtherName(
33  const std::string &path, const std::string &name);
34 
37  File(const File &) = delete;
38  File(File &&) = delete;
39  File &operator=(const File &) = delete;
40  File &operator=(File &&) = delete;
42 
43 protected:
44  File();
45 };
46 
47 } // namespace retdec
48 
49 #endif
virtual ~File()=0
Destructs the file.
The namespace of the library.
Definition: doxygen.h:8
static std::unique_ptr< File > fromContentWithName(const std::string &content, const std::string &name)
Returns a file containing the given content with the given name.
Definition: file.cpp:57
virtual void saveCopyTo(const std::string &directoryPath)=0
Stores a copy of the file into the given directory.
File()
Constructs a file.
virtual std::string getContent()=0
Returns the content of the file.
static std::unique_ptr< File > fromFilesystemWithOtherName(const std::string &path, const std::string &name)
Returns a file from the given path, but with a custom name.
Definition: file.cpp:82
virtual std::string getName() const =0
Returns the name of the file.
File & operator=(const File &)=delete
Base class and factory for files.
Definition: file.h:19
static std::unique_ptr< File > fromFilesystem(const std::string &path)
Returns a file from the given path.
Definition: file.cpp:69