2013-12-06 22:29:25 +01:00
|
|
|
#ifndef UTILS_HDR
|
|
|
|
#define UTILS_HDR
|
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2014-05-15 22:20:31 +02:00
|
|
|
#include <boost/foreach.hpp>
|
2013-12-06 22:29:25 +01:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "concordia/common/config.hpp"
|
|
|
|
#include "concordia/concordia_exception.hpp"
|
2014-04-29 14:46:04 +02:00
|
|
|
#include <divsufsort.h>
|
2013-12-06 22:29:25 +01:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class Utils {
|
|
|
|
public:
|
|
|
|
explicit Utils();
|
|
|
|
|
|
|
|
/*! Destructor.
|
|
|
|
*/
|
|
|
|
virtual ~Utils();
|
|
|
|
|
|
|
|
static void writeIndexCharacter(ofstream & file,
|
|
|
|
INDEX_CHARACTER_TYPE character);
|
|
|
|
|
2014-02-20 10:49:17 +01:00
|
|
|
static void writeMarker(ofstream & file,
|
|
|
|
SUFFIX_MARKER_TYPE marker);
|
|
|
|
|
2013-12-06 22:29:25 +01:00
|
|
|
static INDEX_CHARACTER_TYPE readIndexCharacter(ifstream & file);
|
|
|
|
|
2014-02-20 10:49:17 +01:00
|
|
|
static SUFFIX_MARKER_TYPE readMarker(ifstream & file);
|
|
|
|
|
2013-12-06 22:29:25 +01:00
|
|
|
static sauchar_t * indexVectorToSaucharArray(
|
2013-12-14 15:23:17 +01:00
|
|
|
boost::shared_ptr<vector<INDEX_CHARACTER_TYPE> > input);
|
2013-12-06 22:29:25 +01:00
|
|
|
|
2013-12-14 15:23:17 +01:00
|
|
|
static void appendCharToSaucharVector(
|
|
|
|
boost::shared_ptr<std::vector<sauchar_t> > vector,
|
|
|
|
INDEX_CHARACTER_TYPE character);
|
2014-02-20 10:49:17 +01:00
|
|
|
|
2014-05-15 22:20:31 +02:00
|
|
|
template <typename T>
|
|
|
|
static void printVector(boost::shared_ptr<std::vector<T> > vector);
|
|
|
|
|
2013-12-06 22:29:25 +01:00
|
|
|
private:
|
2013-12-14 15:23:17 +01:00
|
|
|
static void _insertCharToSaucharArray(sauchar_t * array,
|
|
|
|
INDEX_CHARACTER_TYPE character, int pos);
|
2013-12-06 22:29:25 +01:00
|
|
|
};
|
|
|
|
|
2014-05-15 22:20:31 +02:00
|
|
|
template <typename T>
|
|
|
|
void Utils::printVector(boost::shared_ptr<std::vector<T> > vector) {
|
|
|
|
for (int i = 0; i < vector->size(); i++) {
|
|
|
|
cout << vector->at(i) << " ";
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
}
|
2013-12-06 22:29:25 +01:00
|
|
|
#endif
|