capydi
Loading...
Searching...
No Matches
HppTargetAggregator.hpp
Go to the documentation of this file.
1#ifndef HPPTARGETAGGREGATOR_HPP_
2#define HPPTARGETAGGREGATOR_HPP_
3
4#include "IDataAggregator.hpp"
5#include "DelimFileReader.hpp"
6#include "HppTarget.hpp"
7
9{
10public:
11 ~HppTargetAggregator() 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_SUBSCRIBER(";
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 auto& token = *token_opt;
29
30 auto found_mark = token.find(DI_SUBSCRIBE_MARK);
31
32 if (found_mark != std::string::npos)
33 {
34 std::size_t first_ndx = found_mark + DI_SUBSCRIBE_MARK.size();
35 std::size_t i = found_mark + DI_SUBSCRIBE_MARK.size();
36 for (; i < token.size() && token[i] != ')'; ++i);
37 auto subscriber_type = token.substr(first_ndx, i - first_ndx);
38 aggregee_.add_subscriber_type(std::move(subscriber_type));
39 }
40 }
41 }
42
43 std::string get_aggregated_data() const noexcept override
44 {
45 return aggregee_.to_file_content();
46 }
47
48private:
49 HppTarget aggregee_;
50};
51
52#endif //HPPTARGETAGGREGATOR_HPP_
Definition DelimFileReader.hpp:12
std::optional< TokenType > next_token() noexcept override
Definition DelimFileReader.cpp:24
Definition HppTargetAggregator.hpp:9
~HppTargetAggregator() override=default
std::string get_aggregated_data() const noexcept override
Definition HppTargetAggregator.hpp:43
void process_single_unit(const ProcessedUnitType &hppdi_file_path) override
Definition HppTargetAggregator.hpp:15
Definition HppTarget.hpp:8
Definition IDataAggregator.hpp:7
FileSystem::PathType ProcessedUnitType
Definition IDataAggregator.hpp:9
std::string FileContentType
Definition FileSystem.hpp:12