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