concordia-library/concordia/substring_occurrence.hpp
2019-01-22 14:07:28 +01:00

86 lines
2.1 KiB
C++

#ifndef SUBSTRING_OCCURRENCE_HDR
#define SUBSTRING_OCCURRENCE_HDR
#include "concordia/common/config.hpp"
#include <string>
#include <iostream>
/*!
Class representing occurrence of a searched substring.
It holds the following information:
- id of the example where the substring was found
- offset of the matched substring in this example
- length of the example
*/
class SubstringOccurrence {
public:
/*!
Constructor.
*/
SubstringOccurrence();
/*!
Constructor taking data from a marker.
\param marker
*/
explicit SubstringOccurrence(const SUFFIX_MARKER_TYPE & marker);
/*!
Constructor with three arguments.
\param id example id
\param offset offset of the substring in the example
\param exampleLength length of the example
*/
SubstringOccurrence(const SUFFIX_MARKER_TYPE & id,
const SUFFIX_MARKER_TYPE & offset,
const SUFFIX_MARKER_TYPE & exampleLength);
/*! Destructor.
*/
virtual ~SubstringOccurrence();
/*! Getter for example id.
\returns example id
*/
SUFFIX_MARKER_TYPE getId() const {
return _id;
}
/*! Getter for example offset
\returns example offset
*/
SUFFIX_MARKER_TYPE getOffset() const {
return _offset;
}
/*! Getter for example length.
\returns example length
*/
SUFFIX_MARKER_TYPE getExampleLength() const {
return _exampleLength;
}
/*! Setter of all the fields, based on input marker.
\param marker marker to read the data from
*/
void enterDataFromMarker(const SUFFIX_MARKER_TYPE & marker);
friend std::ostream & operator << (std::ostream & o,
const SubstringOccurrence & occurrence) {
return o << "occurrence(exampleId=" << occurrence.getId()
<< ", offset=" << occurrence.getOffset() << ")";
}
private:
SUFFIX_MARKER_TYPE _id;
SUFFIX_MARKER_TYPE _offset;
// the example
SUFFIX_MARKER_TYPE _exampleLength;
};
#endif