From ae356a1d32c0cb16532f512e147b2ce655752b05 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 26 May 2014 21:04:47 -0400 Subject: [PATCH] Variant - Implemented ::operator_hastag and ::operator_notag. --- src/Variant.cpp | 27 +++++++++++++++++++++++++++ src/Variant.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/src/Variant.cpp b/src/Variant.cpp index 65ea826c9..8f49758e6 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -33,6 +33,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////// Variant::Variant () @@ -791,6 +792,32 @@ bool Variant::operator_partial (const Variant& other) const return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Variant::operator_hastag (const Variant& other) const +{ + Variant left (*this); // tags + Variant right (other); // tag + + left.cast (type_string); + right.cast (type_string); + + std::vector individual; + split (individual, left._string, ','); + + std::vector ::iterator i; + for (i = individual.begin (); i != individual.end (); ++i) + if (*i == right._string) + return true; + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +bool Variant::operator_notag (const Variant& other) const +{ + return ! operator_hastag (other); +} + //////////////////////////////////////////////////////////////////////////////// bool Variant::operator! () const { diff --git a/src/Variant.h b/src/Variant.h index b09cafaff..a4e24e14f 100644 --- a/src/Variant.h +++ b/src/Variant.h @@ -60,6 +60,8 @@ public: bool operator_match (const Variant&) const; bool operator_nomatch (const Variant&) const; bool operator_partial (const Variant&) const; + bool operator_hastag (const Variant&) const; + bool operator_notag (const Variant&) const; bool operator! () const; Variant& operator^= (const Variant&);