concordia-library/concordia/substring_occurence.hpp

86 lines
2.1 KiB
C++
Raw Normal View History

#ifndef SUBSTRING_OCCURENCE_HDR
#define SUBSTRING_OCCURENCE_HDR
#include "concordia/common/config.hpp"
#include <string>
2017-04-21 14:51:58 +02:00
#include <iostream>
/*!
Class representing occurence 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
*/
class SubstringOccurence {
public:
2015-05-01 14:52:53 +02:00
/*!
Constructor.
*/
SubstringOccurence();
2015-05-01 14:52:53 +02:00
/*!
Constructor taking data from a marker.
\param marker
*/
explicit SubstringOccurence(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
*/
SubstringOccurence(const SUFFIX_MARKER_TYPE & id,
const SUFFIX_MARKER_TYPE & offset,
const SUFFIX_MARKER_TYPE & exampleLength);
/*! Destructor.
*/
virtual ~SubstringOccurence();
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,
const SubstringOccurence & occurence) {
return o << "occurence(exampleId=" << occurence.getId()
<< ", offset=" << occurence.getOffset() << ")";
}
private:
SUFFIX_MARKER_TYPE _id;
SUFFIX_MARKER_TYPE _offset;
// the example
SUFFIX_MARKER_TYPE _exampleLength;
};
#endif