blob: a1c377b9426b312c7d3bc29350062c826215b869 [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"
Václav Kubernát627f6152018-08-29 13:23:56 +020011#include "ast_values.hpp"
Václav Kubernát24df80e2018-06-06 15:18:03 +020012
13namespace x3 = boost::spirit::x3;
14namespace ascii = boost::spirit::x3::ascii;
15
16using ascii::space;
17using x3::_attr;
18using x3::alnum;
19using x3::alpha;
20using x3::char_;
Václav Kubernátebca2552018-06-08 19:06:02 +020021using x3::double_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020022using x3::expect;
Václav Kubernátebca2552018-06-08 19:06:02 +020023using x3::int_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020024using x3::lexeme;
25using x3::lit;
Václav Kubernátebca2552018-06-08 19:06:02 +020026using x3::uint_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020027
28struct parser_context_tag;
29
30using keyValue_ = std::pair<std::string, std::string>;
31
Václav Kubernáte7d4aea2018-09-11 18:15:48 +020032enum class LsOption {
33 Recursive
34};
35
Václav Kubernát6d791432018-10-25 16:00:35 +020036struct discard_ : x3::position_tagged {
37 bool operator==(const discard_& b) const;
38};
39
Václav Kubernát11afac72018-07-18 14:59:53 +020040struct ls_ : x3::position_tagged {
41 bool operator==(const ls_& b) const;
Václav Kubernáte7d4aea2018-09-11 18:15:48 +020042 std::vector<LsOption> m_options;
Václav Kubernát11afac72018-07-18 14:59:53 +020043 boost::optional<path_> m_path;
44};
45
Václav Kubernát24df80e2018-06-06 15:18:03 +020046struct cd_ : x3::position_tagged {
47 bool operator==(const cd_& b) const;
48 path_ m_path;
49};
50
51struct create_ : x3::position_tagged {
52 bool operator==(const create_& b) const;
53 path_ m_path;
54};
55
56struct delete_ : x3::position_tagged {
57 bool operator==(const delete_& b) const;
58 path_ m_path;
59};
60
61struct set_ : x3::position_tagged {
62 bool operator==(const set_& b) const;
63 path_ m_path;
Václav Kubernátebca2552018-06-08 19:06:02 +020064 leaf_data_ m_data;
Václav Kubernát24df80e2018-06-06 15:18:03 +020065};
66
Václav Kubernát812ee282018-08-30 17:10:03 +020067struct commit_ : x3::position_tagged {
68 bool operator==(const set_& b) const;
69};
70
Václav Kubernátb6ff0b62018-08-30 16:14:53 +020071struct get_ : x3::position_tagged {
72 bool operator==(const get_& b) const;
73 boost::optional<path_> m_path;
74};
Václav Kubernát812ee282018-08-30 17:10:03 +020075
Václav Kubernát6d791432018-10-25 16:00:35 +020076using command_ = boost::variant<discard_, ls_, cd_, create_, delete_, set_, commit_, get_>;
Václav Kubernát24df80e2018-06-06 15:18:03 +020077
Václav Kubernáte7d4aea2018-09-11 18:15:48 +020078BOOST_FUSION_ADAPT_STRUCT(ls_, m_options, m_path)
Václav Kubernát24df80e2018-06-06 15:18:03 +020079BOOST_FUSION_ADAPT_STRUCT(cd_, m_path)
80BOOST_FUSION_ADAPT_STRUCT(create_, m_path)
81BOOST_FUSION_ADAPT_STRUCT(delete_, m_path)
Václav Kubernátebca2552018-06-08 19:06:02 +020082BOOST_FUSION_ADAPT_STRUCT(enum_, m_value)
Václav Kubernát24df80e2018-06-06 15:18:03 +020083BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data)
Václav Kubernát812ee282018-08-30 17:10:03 +020084BOOST_FUSION_ADAPT_STRUCT(commit_)
Václav Kubernát6d791432018-10-25 16:00:35 +020085BOOST_FUSION_ADAPT_STRUCT(discard_)
Václav Kubernátb6ff0b62018-08-30 16:14:53 +020086BOOST_FUSION_ADAPT_STRUCT(get_, m_path)