Skip to content
Snippets Groups Projects
matchdata.h 1.19 KiB
Newer Older
#ifndef LIBWCCL_VALUES_MATCHDATA_H
#define LIBWCCL_VALUES_MATCHDATA_H

#include <libwccl/values/position.h>
#include <libcorpus2/ann/annotatedsentence.h>

namespace Wccl {

/**
 * Base abstract class for data held by a Match Value
 * - VectorMatch, TokenMatch or AnnotationMatch.
 * (empty VectorMatch should be default option)
 */
class MatchData// : boost::noncopyable
{
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;

	boost::shared_ptr<MatchData> clone() const {
		return boost::shared_ptr<MatchData>(clone_internal());
	}

	virtual std::string to_raw_string() const = 0;

protected:
	virtual MatchData* clone_internal() const = 0;
};

}
#endif // LIBWCCL_VALUES_MATCHDATA_H