X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fmstch%2Fvisitor%2Fget_token.hpp;fp=lib%2Fmstch%2Fvisitor%2Fget_token.hpp;h=d41ab6eb1ef7c4ee97d4e5a9eeaa9af197e24a8e;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/mstch/visitor/get_token.hpp b/lib/mstch/visitor/get_token.hpp new file mode 100644 index 0000000..d41ab6e --- /dev/null +++ b/lib/mstch/visitor/get_token.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include + +#include "mstch/mstch.hpp" +#include "has_token.hpp" + +namespace mstch { + +class get_token: public boost::static_visitor { + public: + get_token(const std::string& token, const mstch::node& node): + m_token(token), m_node(node) + { + } + + template + const mstch::node& operator()(const T&) const { + return m_node; + } + + const mstch::node& operator()(const map& map) const { + return map.at(m_token); + } + + const mstch::node& operator()(const std::shared_ptr& object) const { + return object->at(m_token); + } + + private: + const std::string& m_token; + const mstch::node& m_node; +}; + +}