#ifndef LIBWCCL_VALUES_MATCHDATA_H #define LIBWCCL_VALUES_MATCHDATA_H #include <libwccl/values/position.h> #include <libwccl/exception.h> #include <libcorpus2/ann/annotatedsentence.h> namespace Wccl { class Match; /** * Base abstract class for data held by a Match Value * - VectorMatch, TokenMatch or AnnotationMatch. * (empty VectorMatch should be default option) */ class MatchData { public: /** * Check if the match is empty (matches nothing). Match objects themselves * are by definition empty, child classes are sometimes or always non-empty. */ virtual bool empty() const = 0; /** * Getter for the first token matched. If the match is empty, must return * Nowhere. */ virtual Position first_token(const boost::shared_ptr<Corpus2::AnnotatedSentence>&) const = 0; /** * Getter for the last token matched. If the match is empty, must return * Nowhere. */ virtual Position last_token(const boost::shared_ptr<Corpus2::AnnotatedSentence>&) const = 0; /** * Getter for a submatch at given index (indexing starts from 1). */ virtual const boost::shared_ptr<const Match> submatch(size_t) const { throw WcclError("Getting a submatch is possible only for a MatchVector."); } /** * Getter for a submatch at given index (indexing starts from 1). */ virtual const boost::shared_ptr<Match>& submatch(size_t) { throw WcclError("Getting a submatch is possible only for a MatchVector."); } boost::shared_ptr<MatchData> clone() const { return boost::shared_ptr<MatchData>(clone_internal()); } virtual std::string to_raw_string() const = 0; virtual ~MatchData() {} protected: virtual MatchData* clone_internal() const = 0; }; } #endif // LIBWCCL_VALUES_MATCHDATA_H