blob: 90af8ea37dd7e4114c01218e4b6270d162db0a86 [file] [log] [blame]
Václav Kubernát24df80e2018-06-06 15:18:03 +02001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8#pragma once
9
10#include "ast_path.hpp"
11
12namespace x3 = boost::spirit::x3;
13namespace ascii = boost::spirit::x3::ascii;
14
15using ascii::space;
16using x3::_attr;
17using x3::alnum;
18using x3::alpha;
19using x3::char_;
Václav Kubernátebca2552018-06-08 19:06:02 +020020using x3::double_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020021using x3::expect;
Václav Kubernátebca2552018-06-08 19:06:02 +020022using x3::int_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020023using x3::lexeme;
24using x3::lit;
Václav Kubernátebca2552018-06-08 19:06:02 +020025using x3::uint_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020026
27struct parser_context_tag;
28
29using keyValue_ = std::pair<std::string, std::string>;
30
31struct cd_ : x3::position_tagged {
32 bool operator==(const cd_& b) const;
33 path_ m_path;
34};
35
36struct create_ : x3::position_tagged {
37 bool operator==(const create_& b) const;
38 path_ m_path;
39};
40
41struct delete_ : x3::position_tagged {
42 bool operator==(const delete_& b) const;
43 path_ m_path;
44};
45
Václav Kubernátebca2552018-06-08 19:06:02 +020046struct enum_ {
47 enum_();
48 enum_(const std::string& value);
49 bool operator==(const enum_& b) const;
50 std::string m_value;
51};
52
53using leaf_data_ = boost::variant<enum_,
54 double,
55 bool,
56 int32_t,
57 uint32_t,
58 std::string>;
59
Václav Kubernát24df80e2018-06-06 15:18:03 +020060struct set_ : x3::position_tagged {
61 bool operator==(const set_& b) const;
62 path_ m_path;
Václav Kubernátebca2552018-06-08 19:06:02 +020063 leaf_data_ m_data;
Václav Kubernát24df80e2018-06-06 15:18:03 +020064};
65
66using command_ = boost::variant<cd_, create_, delete_, set_>;
67
68BOOST_FUSION_ADAPT_STRUCT(cd_, m_path)
69BOOST_FUSION_ADAPT_STRUCT(create_, m_path)
70BOOST_FUSION_ADAPT_STRUCT(delete_, m_path)
Václav Kubernátebca2552018-06-08 19:06:02 +020071BOOST_FUSION_ADAPT_STRUCT(enum_, m_value)
Václav Kubernát24df80e2018-06-06 15:18:03 +020072BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data)