Skip to content

Commit 9f12edd

Browse files
Zainullin DamirZainullin Damir
authored andcommitted
OutputConfigurationParser - Introduce main Parser class
1 parent 53248cf commit 9f12edd

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include "../processPlugin/fieldDescriptor.hpp"
4+
5+
#include <vector>
6+
7+
namespace ipxp {
8+
9+
class OutputFieldParser {
10+
public:
11+
static std::vector<const process::FieldDescriptor*> getOutputFields(
12+
const std::vector<process::FieldDescriptor>& availableFields,
13+
std::string_view configurationFilePath);
14+
};
15+
16+
}; // namespace ipxp
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file
3+
* @brief Implementation of OutputFieldConfigurationParser.
4+
* @author Damir Zainullin <[email protected]>
5+
*
6+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
7+
*/
8+
9+
#include "fieldMap.hpp"
10+
#include "outputAction.hpp"
11+
12+
#include <fstream>
13+
#include <regex>
14+
15+
#include <outputFieldConfigurationParser.hpp>
16+
17+
namespace ipxp {
18+
19+
std::vector<const process::FieldDescriptor*> OutputFieldParser::getOutputFields(
20+
const std::vector<process::FieldDescriptor>& availableFields,
21+
std::string_view configurationFilePath)
22+
{
23+
std::ifstream configurationFile(configurationFilePath.data());
24+
if (!configurationFile.is_open()) {
25+
throw std::invalid_argument(
26+
"Could not open configuration file: " + std::string(configurationFilePath));
27+
}
28+
29+
const std::string configurationContent(
30+
(std::istreambuf_iterator<char>(configurationFile)),
31+
std::istreambuf_iterator<char>());
32+
33+
return FieldMap(availableFields).applyActions(parseActions(configurationContent));
34+
}
35+
36+
} // namespace ipxp

0 commit comments

Comments
 (0)