Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
arxml_reader.h
1#ifndef ARXML_READER_H
2#define ARXML_READER_H
3
4#include <array>
5#include <string>
6#include <initializer_list>
7#include "./arxml_node_range.h"
8
10namespace arxml
11{
14 {
15 private:
16 pugi::xml_document mDocument;
17
18 bool validate(const pugi::xml_parse_result &parseResult) const;
19
20 public:
24 explicit ArxmlReader(const std::string &filePath);
25
29 ArxmlReader(const char *content, std::size_t length);
30
31 ArxmlReader() = delete;
32 ~ArxmlReader() noexcept = default;
33
37 ArxmlNode GetRootNode(std::initializer_list<std::string> children) const;
38
43 template <size_t N>
45 const std::array<std::string, N> &children) const
46 {
47 pugi::xml_node _root{mDocument.root()};
48
49 for (const auto child : children)
50 {
51 _root = _root.child(child.c_str());
52 }
53
54 ArxmlNode _result(std::move(_root));
55 return _result;
56 }
57
61 ArxmlNodeRange GetNodes(std::initializer_list<std::string> children) const;
62
67 template <size_t N>
69 const std::array<std::string, N> &children) const
70 {
71 pugi::xml_node _root{mDocument.root()};
72
73 for (const auto child : children)
74 {
75 _root = _root.child(child.c_str());
76 }
77
78 auto _range{_root.children()};
79 ArxmlNodeRange _result(_range.begin(), _range.end());
80
81 return _result;
82 }
83 };
84}
85
86#endif
Read-only range of ARXML nodes.
Definition: arxml_node_range.h:13
A class that represents a XML node within a ARXML configuration.
Definition: arxml_node.h:11
A class to read ARXML configuration files.
Definition: arxml_reader.h:14
ArxmlNodeRange GetNodes(const std::array< std::string, N > &children) const
Get a range of ARXML nodes deep down the ARXML content.
Definition: arxml_reader.h:68
ArxmlNodeRange GetNodes(std::initializer_list< std::string > children) const
Get a range of ARXML nodes deep down the ARXML content.
Definition: arxml_reader.cpp:77
ArxmlNode GetRootNode(std::initializer_list< std::string > children) const
Get (relative) ARXML root node.
Definition: arxml_reader.cpp:63
ArxmlNode GetRootNode(const std::array< std::string, N > &children) const
Get (relative) ARXML root node.
Definition: arxml_reader.h:44
AUTOSAR XML (ARXML) configuration files utilities namespace.
Definition: arxml_node.cpp:6