]> Creatis software - cpPlugins.git/blob - lib/mstch/visitor/has_token.hpp
Moved to version 1.0
[cpPlugins.git] / lib / mstch / visitor / has_token.hpp
1 #pragma once
2
3 #include <boost/variant/static_visitor.hpp>
4
5 #include "mstch/mstch.hpp"
6
7 namespace mstch {
8
9 class has_token: public boost::static_visitor<bool> {
10  public:
11   has_token(const std::string& token): m_token(token) {
12   }
13
14   template<class T>
15   bool operator()(const T&) const {
16     return m_token == ".";
17   }
18
19   bool operator()(const map& map) const {
20     return map.count(m_token) == 1;
21   }
22
23   bool operator()(const std::shared_ptr<object>& object) const {
24     return object->has(m_token);
25   }
26
27  private:
28   const std::string& m_token;
29 };
30
31 }