#ifndef UTILS_HDR #define UTILS_HDR #include #include #include #include #include #include "concordia/common/config.hpp" #include "concordia/concordia_exception.hpp" #include using namespace std; class Utils { public: explicit Utils(); /*! Destructor. */ virtual ~Utils(); static void writeIndexCharacter(ofstream & file, INDEX_CHARACTER_TYPE character); static void writeMarker(ofstream & file, SUFFIX_MARKER_TYPE marker); static INDEX_CHARACTER_TYPE readIndexCharacter(ifstream & file); static SUFFIX_MARKER_TYPE readMarker(ifstream & file); static sauchar_t * indexVectorToSaucharArray( const vector & input); static std::vector indexVectorToSaucharVector( const vector & input); static void appendCharToSaucharVector( boost::shared_ptr > vector, INDEX_CHARACTER_TYPE character); static void appendCharToSaucharVector( std::vector & vector, INDEX_CHARACTER_TYPE character); template static void printVector(const std::vector & vector); static SUFFIX_MARKER_TYPE getIdFromMarker(SUFFIX_MARKER_TYPE marker); static SUFFIX_MARKER_TYPE getOffsetFromMarker(SUFFIX_MARKER_TYPE marker); static SUFFIX_MARKER_TYPE getLengthFromMarker(SUFFIX_MARKER_TYPE marker); static SUFFIX_MARKER_TYPE createMarker(SUFFIX_MARKER_TYPE id, SUFFIX_MARKER_TYPE offset, SUFFIX_MARKER_TYPE length); static SUFFIX_MARKER_TYPE maxSentenceSize; private: static void _insertCharToSaucharArray(sauchar_t * array, INDEX_CHARACTER_TYPE character, int pos); static int _idBytes; }; template void Utils::printVector(const std::vector & vector) { for (int i = 0; i < vector.size(); i++) { cout << static_cast(vector.at(i)) << " "; } cout << endl; } #endif