capydi
Loading...
Searching...
No Matches
HppTarget.hpp
Go to the documentation of this file.
1#ifndef HPPTARGET_HPP_
2#define HPPTARGET_HPP_
3
4#include <vector>
5#include "FileSystem.hpp"
6
8{
9public:
10 void include(const FileSystem::PathType& file_contents)
11 {
12 includes_.push_back(file_contents);
13 }
14
16 {
17// subscriber_types_.push_back(subscriber_type.substr(0, subscriber_type.size() - 1));
18 subscriber_types_.push_back(std::move(subscriber_type));
19 }
20
22 {
23 const FileSystem::FileContentType namespace_name = "DI";
24 const FileSystem::FileContentType build_di_container_fn_begin =
25 "\nDI_CONSTEXPR auto build_di_container()\n"
26 "{\n"
27 "\tstd::tuple concatenated_configs = std::tuple_cat(\n";
28 FileSystem::FileContentType file_content = "#ifndef DI_HPP_\n"
29 "#define DI_HPP_\n"
30 "\n"
31 "#include \"fast_di/udil/FastDI.hpp\"\n\n";
32
33 for (const auto& include_path: includes_)
34 {
35 file_content += "#include \"" + include_path.string() + "\"\n";
36 }
37
38 file_content += build_di_container_fn_begin;
39
40 for (std::size_t i = 0u; i < subscriber_types_.size(); ++i)
41 {
42 file_content += "\t\t" + namespace_name + "::DI_SUBSCRIBER("
43 + subscriber_types_[i]
44 + (i != subscriber_types_.size() - 1 ? "),\n" : ")\n");
45 }
46
47 file_content += "\t);\n"
48 "\n"
49 "\treturn fast_di::udil::form_di_container(concatenated_configs);\n"
50 "}\n"
51 "\n"
52 "#endif //DI_HPP_";
53
54 return file_content;
55 }
56
57private:
58 std::vector<FileSystem::PathType> includes_;
59 std::vector<FileSystem::FileContentType> subscriber_types_;
60};
61
62#endif //HPPTARGET_HPP_
Definition HppTarget.hpp:8
FileSystem::FileContentType to_file_content() const
Definition HppTarget.hpp:21
void add_subscriber_type(FileSystem::FileContentType &&subscriber_type)
Definition HppTarget.hpp:15
void include(const FileSystem::PathType &file_contents)
Definition HppTarget.hpp:10
std::filesystem::path PathType
Definition FileSystem.hpp:9
std::string FileContentType
Definition FileSystem.hpp:12