]> Creatis software - cpPlugins.git/blob - lib/mstch/visitor/is_node_empty.hpp
Moved to version 1.0
[cpPlugins.git] / lib / mstch / visitor / is_node_empty.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 is_node_empty: public boost::static_visitor<bool> {
10  public:
11   template<class T>
12   bool operator()(const T&) const {
13     return false;
14   }
15
16   bool operator()(const std::nullptr_t&) const {
17     return true;
18   }
19
20   bool operator()(const int& value) const {
21     return value == 0;
22   }
23
24   bool operator()(const double& value) const {
25     return value == 0;
26   }
27
28   bool operator()(const bool& value) const {
29     return !value;
30   }
31
32   bool operator()(const std::string& value) const {
33     return value == "";
34   }
35
36   bool operator()(const array& array) const {
37     return array.size() == 0;
38   }
39 };
40
41 }