1 | #ifndef CPR_FILE_H |
---|---|
2 | #define CPR_FILE_H |
3 | |
4 | #include <initializer_list> |
5 | #include <string> |
6 | #include <vector> |
7 | |
8 | #include <cpr/filesystem.h> |
9 | |
10 | namespace cpr { |
11 | |
12 | struct File { |
13 | explicit File(std::string p_filepath, const std::string& p_overriden_filename = {}) : filepath(std::move(p_filepath)), overriden_filename(p_overriden_filename) {} |
14 | |
15 | std::string filepath; |
16 | std::string overriden_filename; |
17 | |
18 | [[nodiscard]] bool hasOverridenFilename() const noexcept { |
19 | return !overriden_filename.empty(); |
20 | }; |
21 | }; |
22 | |
23 | class Files { |
24 | public: |
25 | Files() = default; |
26 | // NOLINTNEXTLINE(google-explicit-constructor) |
27 | Files(const File& p_file) : files{p_file} {}; |
28 | |
29 | Files(const Files& other) = default; |
30 | Files(Files&& old) noexcept = default; |
31 | |
32 | Files(const std::initializer_list<File>& p_files) : files{p_files} {}; |
33 | Files(const std::initializer_list<std::string>& p_filepaths); |
34 | |
35 | ~Files() noexcept = default; |
36 | |
37 | Files& operator=(const Files& other); |
38 | Files& operator=(Files&& old) noexcept; |
39 | |
40 | using iterator = std::vector<File>::iterator; |
41 | using const_iterator = std::vector<File>::const_iterator; |
42 | |
43 | iterator begin(); |
44 | iterator end(); |
45 | [[nodiscard]] const_iterator begin() const; |
46 | [[nodiscard]] const_iterator end() const; |
47 | [[nodiscard]] const_iterator cbegin() const; |
48 | [[nodiscard]] const_iterator cend() const; |
49 | void emplace_back(const File& file); |
50 | void push_back(const File& file); |
51 | void pop_back(); |
52 | |
53 | private: |
54 | std::vector<File> files; |
55 | }; |
56 | |
57 | } // namespace cpr |
58 | |
59 | #endif |
60 |