X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fmstch%2Fvisitor%2Fis_node_empty.hpp;fp=lib%2Fmstch%2Fvisitor%2Fis_node_empty.hpp;h=a0ae432e0c4d7cafd0057ffb2b2c8f33616d026a;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/mstch/visitor/is_node_empty.hpp b/lib/mstch/visitor/is_node_empty.hpp new file mode 100644 index 0000000..a0ae432 --- /dev/null +++ b/lib/mstch/visitor/is_node_empty.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include + +#include "mstch/mstch.hpp" + +namespace mstch { + +class is_node_empty: public boost::static_visitor { + public: + template + bool operator()(const T&) const { + return false; + } + + bool operator()(const std::nullptr_t&) const { + return true; + } + + bool operator()(const int& value) const { + return value == 0; + } + + bool operator()(const double& value) const { + return value == 0; + } + + bool operator()(const bool& value) const { + return !value; + } + + bool operator()(const std::string& value) const { + return value == ""; + } + + bool operator()(const array& array) const { + return array.size() == 0; + } +}; + +}