diff --git a/libwccl/values/bool.h b/libwccl/values/bool.h index a668b7d54f385461fe6ae8a138d0b3b0393f3dc7..19b53c9ab64a3bd539a19b41b19bef13f4a3e4e6 100644 --- a/libwccl/values/bool.h +++ b/libwccl/values/bool.h @@ -23,6 +23,10 @@ public: val_ = v; } + bool equals(const Bool& other) { + return val_ == other.val_; + } + /// Value override std::string to_raw_string() const { return val_ ? "true" : "false"; diff --git a/libwccl/values/position.h b/libwccl/values/position.h index 0b2148b436e01e4018b955a101d6dc5cb8cb3376..a87a8a98352fa1074fbbca907907177a620a9236 100644 --- a/libwccl/values/position.h +++ b/libwccl/values/position.h @@ -32,6 +32,10 @@ public: /// Value override std::string to_raw_string() const; + bool equals(const Position& other) { + return val_ == other.val_; + } + private: int val_; }; diff --git a/libwccl/values/positionref.h b/libwccl/values/positionref.h index dcb8667025e9bf558462c6a45a10adec8c821484..4b0ffb6518ca1b6e4b4873035c53a51684db1954 100644 --- a/libwccl/values/positionref.h +++ b/libwccl/values/positionref.h @@ -37,6 +37,29 @@ public: offset_ = offset; } + /** + * Returns true if underlying Position is Nowhere, + * or underlying Position is Begin and offset is less than zero, + * or underlying Position is End and offset is greater than zero. + * False otherwise. + * This function does not take into account any actual sentence + * boundaries. + */ + bool points_nowhere() const { + //We probably could allow null dereference (shouldn't logically + //happen so if it does, it's bad) but let's be defensive + //and assume null base is like nowhere. + return (base_.get() == NULL) || + (base_->get_value() == Position::Nowhere) || + (base_->get_value() == Position::Begin && offset_ < 0) || + (base_->get_value() == Position::End && offset_ > 0); + } + + bool equals(const PositionRef& other) { + return points_nowhere() ? other.points_nowhere() + : offset_ == other.offset_ && base_->equals(*other.base_); + } + private: boost::shared_ptr<Position> base_; diff --git a/libwccl/values/strset.h b/libwccl/values/strset.h index a180c47ab3e8a72c884749d4b0e03b2b7f890e29..8786397cffc6670a93a1ae0637d97d5a86d1edc2 100644 --- a/libwccl/values/strset.h +++ b/libwccl/values/strset.h @@ -52,6 +52,25 @@ public: return set_.size(); } + bool empty() const { + return set_.empty(); + } + + bool is_subset_of(const StrSet& /*set*/) const { + //TODO: implement this + return false; + } + + StrSet intersect(const StrSet& /*set*/) const { + //TODO: implement this + return StrSet(set_t()); + } + + bool equals(const StrSet& /*set*/) const { + //TODO: implement this + return false; + } + /// Value override std::string to_raw_string() const; diff --git a/libwccl/values/tset.h b/libwccl/values/tset.h index 5cd25a4b42d2490c1f62cba681cf84f952c065c0..ba5bb5b8c323c6924ad352c3a07ebb4d0639a0ce 100644 --- a/libwccl/values/tset.h +++ b/libwccl/values/tset.h @@ -33,6 +33,25 @@ public: return tag_; } + bool empty() const { + return tag_.is_null(); + } + + bool is_subset_of(const TSet& /*tset*/) const { + //TODO: implement this + return false; + } + + TSet intersect(const TSet& /*tset*/) const { + //TODO: implement this + return TSet(); + } + + bool equals(const TSet& /*tset*/) const { + //TODO: implement this + return false; + } + std::string to_string(const Corpus2::Tagset &) const; std::string to_raw_string() const;