Loading...
Searching...
No Matches
file.h
1// <one line to give the program's name and a brief idea of what it does.>
2// SPDX-FileCopyrightText: 2022 <copyright holder> <email>
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef NAF_FILES_FILE
6#define NAF_FILES_FILE
7
8
9#include <string>
10#include <memory>
11
12#include "Poco/Path.h"
13#include "Poco/File.h"
14
15#include "files/file_properties.h"
16
17
18namespace NAF
19{
20 namespace Files
21 {
22 enum class FileType;
23 class File;
24 }
25}
26
27using namespace Poco;
28
29
30enum class NAF::Files::FileType
31{
32 kBinary
33 ,kTextPlain
34};
35
36
38{
39 public:
40 File();
41 File(std::string name, std::string filename, std::string content_type, std::size_t content_length);
42
43 FileType get_file_type() const{return file_type_;}
44 std::size_t get_content_length() const{return content_length_;}
45 std::string get_content_type() const{return content_type_;}
46 std::string get_name() const {return name_;}
47 std::string get_filename() const {return filename_;}
48
49 Files::FileProperties& get_file_properties()
50 {
51 auto& var = file_properties_;
52 return var;
53 }
54 std::shared_ptr<Path>& get_requested_path()
55 {
56 auto& var = requested_path_;
57 return var;
58 }
59 std::shared_ptr<Poco::File>& get_requested_file()
60 {
61 auto& var = requested_file_;
62 return var;
63 }
64 std::shared_ptr<Poco::File>& get_tmp_file()
65 {
66 auto& var = tmp_file_;
67 return var;
68 }
69
70
71 void set_file_type(FileType file_type) {file_type_ = file_type;}
72 void set_filename(std::size_t content_length) {content_length_ = content_length;}
73 void set_content_length(std::size_t content_length) {content_length_ = content_length;}
74 void set_content_type(std::string content_type) {content_type_ = content_type;}
75 void set_name(std::string name) {name_ = name;}
76 void set_filename(std::string filename) {filename_ = filename;}
77
78 private:
79 std::size_t content_length_;
80 std::string content_type_;
81 std::string name_;
82 std::string filename_;
83 FileType file_type_;
84 Files::FileProperties file_properties_;
85 std::shared_ptr<Path> requested_path_;
86 std::shared_ptr<Poco::File> requested_file_;
87 std::shared_ptr<Poco::File> tmp_file_;
88};
89
90#endif // NAF_FILES_FILE
Definition file_properties.h:36
Definition file.h:38