#include "concordia/common/utils.hpp" Utils::Utils() { } Utils::~Utils() { } void Utils::writeIndexCharacter(ofstream & file, INDEX_CHARACTER_TYPE character) { file.write(reinterpret_cast(&character), sizeof(character)); } void Utils::writeMarker(ofstream & file, SUFFIX_MARKER_TYPE marker) { file.write(reinterpret_cast(&marker), sizeof(marker)); } INDEX_CHARACTER_TYPE Utils::readIndexCharacter(ifstream & file) { INDEX_CHARACTER_TYPE character; file.read(reinterpret_cast(&character), sizeof(character)); return character; } SUFFIX_MARKER_TYPE Utils::readMarker(ifstream & file) { SUFFIX_MARKER_TYPE marker; file.read(reinterpret_cast(&marker), sizeof(marker)); return marker; } sauchar_t * Utils::indexVectorToSaucharArray( boost::shared_ptr > input) { const int kArraySize = input->size()*sizeof(INDEX_CHARACTER_TYPE); sauchar_t * patternArray = new sauchar_t[kArraySize]; int pos = 0; for (vector::iterator it = input->begin(); it != input->end(); ++it) { _insertCharToSaucharArray(patternArray, *it, pos); pos += sizeof(INDEX_CHARACTER_TYPE); } return patternArray; } void Utils::appendCharToSaucharVector( boost::shared_ptr > vector, INDEX_CHARACTER_TYPE character) { sauchar_t * characterArray = reinterpret_cast(&character); for (int i = 0; i < sizeof(character); i++) { vector->push_back(characterArray[i]); } } void Utils::_insertCharToSaucharArray(sauchar_t * array, INDEX_CHARACTER_TYPE character, int pos) { sauchar_t * characterArray = reinterpret_cast(&character); for (int i = pos; i < pos+sizeof(character); i++) { array[i] = characterArray[i-pos]; } }