blob: 26d93a6f126324d4e22903c52b953404aa3efca6 [file] [log] [blame]
Václav Kubernát8cd63422018-03-19 17:10:13 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
Václav Kubernátd6662962018-03-22 17:41:33 +01003 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
Václav Kubernát8cd63422018-03-19 17:10:13 +01004 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8#pragma once
9#include <boost/spirit/home/x3.hpp>
Václav Kubernát8cd63422018-03-19 17:10:13 +010010#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
Václav Kubernátb96eef72018-05-04 19:10:22 +020011#include <boost/spirit/home/x3/support/utility/error_reporting.hpp>
Václav Kubernátd6662962018-03-22 17:41:33 +010012
Václav Kubernát8cd63422018-03-19 17:10:13 +010013#include <boost/fusion/adapted/struct/adapt_struct.hpp>
14#include <boost/fusion/include/adapt_struct.hpp>
Václav Kubernátb96eef72018-05-04 19:10:22 +020015#include <boost/fusion/include/std_pair.hpp>
16#include <boost/variant.hpp>
17#include <map>
Václav Kubernátd6662962018-03-22 17:41:33 +010018#include <vector>
19
Václav Kubernát94938b72018-05-04 15:12:24 +020020#include "utils.hpp"
Václav Kubernát8cd63422018-03-19 17:10:13 +010021namespace x3 = boost::spirit::x3;
22namespace ascii = boost::spirit::x3::ascii;
23
24using x3::alpha;
25using x3::alnum;
26using x3::lit;
27using x3::char_;
28using x3::_attr;
29using x3::lexeme;
Václav Kubernátb96eef72018-05-04 19:10:22 +020030using x3::expect;
Václav Kubernát8cd63422018-03-19 17:10:13 +010031using ascii::space;
Václav Kubernátb96eef72018-05-04 19:10:22 +020032using boost::fusion::operator<<;
33
34
35using keyValue_ = std::pair<std::string, std::string>;
36
Václav Kubernát8cd63422018-03-19 17:10:13 +010037
38struct parser_context_tag;
39
Václav Kubernátd6662962018-03-22 17:41:33 +010040struct container_ {
Václav Kubernátb96eef72018-05-04 19:10:22 +020041 container_() = default;
Václav Kubernátd6662962018-03-22 17:41:33 +010042 container_(const std::string& name);
43
44 bool operator==(const container_& b) const;
45
Václav Kubernát8cd63422018-03-19 17:10:13 +010046 std::string m_name;
47};
48
Václav Kubernátb96eef72018-05-04 19:10:22 +020049
50struct list_ {
51 std::vector<std::string> m_keys;
52};
53
54struct listElement_ {
55 listElement_() {}
56 listElement_(const std::string& listName, const std::map<std::string, std::string>& keys);
57
58 bool operator==(const listElement_& b) const;
59
60 std::string m_listName;
61 std::map<std::string, std::string> m_keys;
62};
63
Václav Kubernát8cd63422018-03-19 17:10:13 +010064
Václav Kubernátd6662962018-03-22 17:41:33 +010065struct path_ {
66 bool operator==(const path_& b) const;
Václav Kubernátb96eef72018-05-04 19:10:22 +020067 std::vector<boost::variant<container_, listElement_>> m_nodes;
Václav Kubernát8cd63422018-03-19 17:10:13 +010068};
69
Václav Kubernát8cd63422018-03-19 17:10:13 +010070
Václav Kubernátb96eef72018-05-04 19:10:22 +020071struct cd_ : x3::position_tagged {
Václav Kubernátd6662962018-03-22 17:41:33 +010072 bool operator==(const cd_& b) const;
Václav Kubernát8cd63422018-03-19 17:10:13 +010073 path_ m_path;
74};
75
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020076
77
78BOOST_FUSION_ADAPT_STRUCT(container_, m_name)
79BOOST_FUSION_ADAPT_STRUCT(listElement_, m_listName, m_keys)
80BOOST_FUSION_ADAPT_STRUCT(path_, m_nodes)
Václav Kubernát8cd63422018-03-19 17:10:13 +010081BOOST_FUSION_ADAPT_STRUCT(cd_, m_path)