Václav Kubernát | 96344a1 | 2018-05-28 16:33:39 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 9 | #include <iostream> |
Václav Kubernát | 96344a1 | 2018-05-28 16:33:39 +0200 | [diff] [blame] | 10 | #include "interpreter.hpp" |
| 11 | |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 12 | struct leafDataToString : boost::static_visitor<std::string> { |
| 13 | std::string operator()(const enum_& data) const |
| 14 | { |
| 15 | return data.m_value; |
| 16 | } |
| 17 | template <typename T> |
| 18 | std::string operator()(const T& data) const |
| 19 | { |
| 20 | std::stringstream stream; |
| 21 | stream << data; |
| 22 | return stream.str(); |
| 23 | } |
| 24 | }; |
| 25 | |
Václav Kubernát | 0720424 | 2018-06-04 18:12:09 +0200 | [diff] [blame] | 26 | void Interpreter::operator()(const set_& set) const |
| 27 | { |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 28 | std::cout << "Setting " << pathToDataString(set.m_path) << " to " << boost::apply_visitor(leafDataToString(), set.m_data) << std::endl; |
Václav Kubernát | 0720424 | 2018-06-04 18:12:09 +0200 | [diff] [blame] | 29 | } |
| 30 | |
Václav Kubernát | 96344a1 | 2018-05-28 16:33:39 +0200 | [diff] [blame] | 31 | void Interpreter::operator()(const cd_& cd) const |
| 32 | { |
| 33 | m_parser.changeNode(cd.m_path); |
| 34 | } |
| 35 | |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 36 | void Interpreter::operator()(const create_& create) const |
| 37 | { |
| 38 | std::cout << "Presence container " << boost::get<container_>(create.m_path.m_nodes.back()).m_name << " created." << std::endl; |
| 39 | } |
| 40 | |
| 41 | void Interpreter::operator()(const delete_& delet) const |
| 42 | { |
| 43 | std::cout << "Presence container " << boost::get<container_>(delet.m_path.m_nodes.back()).m_name << " deleted." << std::endl; |
| 44 | } |
| 45 | |
| 46 | Interpreter::Interpreter(Parser& parser, Schema&) |
Václav Kubernát | 96344a1 | 2018-05-28 16:33:39 +0200 | [diff] [blame] | 47 | : m_parser(parser) |
| 48 | { |
| 49 | } |