Line data Source code
1 : ///
2 : /// @file ar/internal/files/string_file.h
3 : /// @copyright (c) 2015 by Petr Zemek (s3rvac@gmail.com) and contributors
4 : /// @license MIT, see the @c LICENSE file for more details
5 : /// @brief File storing its content in a string.
6 : ///
7 :
8 : #ifndef AR_INTERNAL_FILES_STRING_FILE_H
9 : #define AR_INTERNAL_FILES_STRING_FILE_H
10 :
11 : #include <string>
12 :
13 : #include "ar/file.h"
14 :
15 : namespace ar {
16 : namespace internal {
17 :
18 : ///
19 : /// File storing its content in a string.
20 : ///
21 36 : class StringFile: public File {
22 : public:
23 : explicit StringFile(const std::string& content);
24 : StringFile(const std::string& content, const std::string& name);
25 : virtual ~StringFile() override;
26 :
27 : virtual std::string getName() const override;
28 : virtual std::string getContent() override;
29 : virtual void saveCopyTo(const std::string& directoryPath) override;
30 : virtual void saveCopyTo(const std::string& directoryPath,
31 : const std::string& name) override;
32 :
33 : private:
34 : /// File content.
35 : std::string content;
36 :
37 : /// File name.
38 : std::string name;
39 : };
40 :
41 : } // namespace internal
42 : } // namespace ar
43 :
44 : #endif
|