capydi
Loading...
Searching...
No Matches
CppTarget.hpp
Go to the documentation of this file.
1#ifndef CPPTARGET_HPP_
2#define CPPTARGET_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 }
19
21 {
22 const FileSystem::FileContentType namespace_name = "DI";
23 const FileSystem::FileContentType subscribe_all_fn_begin = "\nvoid subscribe_all_dependencies()\n{\n";
24 FileSystem::FileContentType file_content;
25
26 for (const auto& include_path: includes_)
27 {
28 file_content += "#include \"" + include_path.string() + "\"\n";
29 }
30
31 file_content += subscribe_all_fn_begin;
32
33 for (const auto& subscriber_type: subscriber_types_)
34 {
35 file_content += "\t" + namespace_name + "::subscribe_" + subscriber_type + "();\n";
36 }
37
38 file_content += "}\n";
39
40 return file_content;
41 }
42
43private:
44 std::vector<FileSystem::PathType> includes_;
45 std::vector<FileSystem::FileContentType> subscriber_types_;
46};
47
48#endif //CPPTARGET_HPP_
Definition CppTarget.hpp:8
FileSystem::FileContentType to_file_content() const
Definition CppTarget.hpp:20
void add_subscriber_type(FileSystem::FileContentType &&subscriber_type)
Definition CppTarget.hpp:15
void include(const FileSystem::PathType &file_contents)
Definition CppTarget.hpp:10
std::filesystem::path PathType
Definition FileSystem.hpp:9
std::string FileContentType
Definition FileSystem.hpp:12