This repository has been archived on 2023-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2017-10-11 09:48:27 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <boost/variant/static_visitor.hpp>
|
|
|
|
|
|
|
|
|
|
#include "has_token.hpp"
|
2017-10-17 10:29:56 -04:00
|
|
|
#include "mstch/mstch.hpp"
|
2017-10-11 09:48:27 -04:00
|
|
|
|
2017-10-17 10:29:56 -04:00
|
|
|
namespace mstch
|
|
|
|
|
{
|
2017-10-11 09:48:27 -04:00
|
|
|
|
2017-10-17 10:29:56 -04:00
|
|
|
class get_token : public boost::static_visitor<const mstch::node &>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
get_token(const std::string &token, const mstch::node &node) : m_token(token), m_node(node) {}
|
2017-10-11 09:48:27 -04:00
|
|
|
|
2017-10-17 10:29:56 -04:00
|
|
|
template <class T> const mstch::node &operator()(const T &) const { return m_node; }
|
2017-10-11 09:48:27 -04:00
|
|
|
|
2017-10-17 10:29:56 -04:00
|
|
|
const mstch::node &operator()(const map &map) const { return map.at(m_token); }
|
2017-10-11 09:48:27 -04:00
|
|
|
|
2017-10-17 10:29:56 -04:00
|
|
|
const mstch::node &operator()(const std::shared_ptr<object> &object) const { return object->at(m_token); }
|
2017-10-11 09:48:27 -04:00
|
|
|
|
2017-10-17 10:29:56 -04:00
|
|
|
private:
|
|
|
|
|
const std::string &m_token;
|
|
|
|
|
const mstch::node &m_node;
|
2017-10-11 09:48:27 -04:00
|
|
|
};
|
|
|
|
|
}
|