concordia-library/concordia/substring_occurrence.hpp

86 lines
2.1 KiB
C++
Raw Permalink Normal View History

2019-01-22 14:07:28 +01:00
#ifndef SUBSTRING_OCCURRENCE_HDR
#define SUBSTRING_OCCURRENCE_HDR
#include "concordia/common/config.hpp"
#include <string>
2017-04-21 14:51:58 +02:00
#include <iostream>
/*!
2019-01-22 14:07:28 +01:00
Class representing occurrence of a searched substring.
2015-05-01 14:52:53 +02:00
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
*/
2019-01-22 14:07:28 +01:00
class SubstringOccurrence {
public:
2015-05-01 14:52:53 +02:00
/*!
Constructor.
*/
2019-01-22 14:07:28 +01:00
SubstringOccurrence();
2015-05-01 14:52:53 +02:00
/*!
Constructor taking data from a marker.
\param marker
*/
2019-01-22 14:07:28 +01:00
explicit SubstringOccurrence(const SUFFIX_MARKER_TYPE & marker);
2015-05-01 14:52:53 +02:00
/*!
Constructor with three arguments.
\param id example id
\param offset offset of the substring in the example
\param exampleLength length of the example
*/
2019-01-22 14:07:28 +01:00
SubstringOccurrence(const SUFFIX_MARKER_TYPE & id,
const SUFFIX_MARKER_TYPE & offset,
const SUFFIX_MARKER_TYPE & exampleLength);
/*! Destructor.
*/
2019-01-22 14:07:28 +01:00
virtual ~SubstringOccurrence();
2015-05-01 14:52:53 +02:00
/*! Getter for example id.
\returns example id
*/
SUFFIX_MARKER_TYPE getId() const {
return _id;
}
2015-05-01 14:52:53 +02:00
/*! Getter for example offset
\returns example offset
*/
SUFFIX_MARKER_TYPE getOffset() const {
return _offset;
}
2015-05-01 14:52:53 +02:00
/*! Getter for example length.
\returns example length
*/
SUFFIX_MARKER_TYPE getExampleLength() const {
return _exampleLength;
}
2015-05-01 14:52:53 +02:00
/*! Setter of all the fields, based on input marker.
\param marker marker to read the data from
*/
void enterDataFromMarker(const SUFFIX_MARKER_TYPE & marker);
2017-04-21 14:51:58 +02:00
friend std::ostream & operator << (std::ostream & o,
2019-01-22 14:07:28 +01:00
const SubstringOccurrence & occurrence) {
return o << "occurrence(exampleId=" << occurrence.getId()
<< ", offset=" << occurrence.getOffset() << ")";
2017-04-21 14:51:58 +02:00
}
private:
SUFFIX_MARKER_TYPE _id;
SUFFIX_MARKER_TYPE _offset;
// the example
SUFFIX_MARKER_TYPE _exampleLength;
};
#endif