capydi
Loading...
Searching...
No Matches
CppTargetAggregator.hpp
Go to the documentation of this file.
1#ifndef CPPTARGETAGGREGATOR_HPP_
2#define CPPTARGETAGGREGATOR_HPP_
3
4#include "IDataAggregator.hpp"
5#include "DelimFileReader.hpp"
6#include "CppTarget.hpp"
7
9{
10public:
11 ~CppTargetAggregator() override = default;
12
13public:
14
15 void process_single_unit(const ProcessedUnitType& hppdi_file_path) override
16 {
17 const FileSystem::FileContentType DI_SUBSCRIBE_MARK = "DI_DYNAMIC_SUBSCRIBER_FOR(";
18 DelimFileReader tokenizer(hppdi_file_path, "\n", 20u);
19
20 aggregee_.include(hppdi_file_path);
21
22 for
23 (
24 auto token_opt = tokenizer.next_token();
25 token_opt.has_value();
26 token_opt = tokenizer.next_token()
27 )
28 {
29 auto& token = *token_opt;
30
31 if (token.starts_with(DI_SUBSCRIBE_MARK))
32 {
33 std::size_t first_ndx = DI_SUBSCRIBE_MARK.size();
34 std::size_t i = first_ndx;
35 for (; i < token.size() && token[i] != ')'; ++i);
36 auto subscriber_type = token.substr(first_ndx, i - first_ndx + 1);
37 aggregee_.add_subscriber_type(std::move(subscriber_type));
38 }
39 }
40 }
41
42 std::string get_aggregated_data() const noexcept override
43 {
44 return aggregee_.to_file_content();
45 }
46
47private:
48 CppTarget aggregee_;
49};
50
51
52#endif //CPPTARGETAGGREGATOR_HPP_
Definition CppTargetAggregator.hpp:9
void process_single_unit(const ProcessedUnitType &hppdi_file_path) override
Definition CppTargetAggregator.hpp:15
std::string get_aggregated_data() const noexcept override
Definition CppTargetAggregator.hpp:42
~CppTargetAggregator() override=default
Definition CppTarget.hpp:8
Definition DelimFileReader.hpp:12
std::optional< TokenType > next_token() noexcept override
Definition DelimFileReader.cpp:24
Definition IDataAggregator.hpp:7
FileSystem::PathType ProcessedUnitType
Definition IDataAggregator.hpp:9
std::string FileContentType
Definition FileSystem.hpp:12