#ifndef UTILS_HDR #define UTILS_HDR #include #include #include #include #include #include "concordia/common/config.hpp" #include "concordia/concordia_exception.hpp" #include class Utils { public: explicit Utils(); /*! Destructor. */ virtual ~Utils(); static void writeIndexCharacter(std::ofstream & file, INDEX_CHARACTER_TYPE character); static void writeMarker(std::ofstream & file, SUFFIX_MARKER_TYPE marker); static INDEX_CHARACTER_TYPE readIndexCharacter(std::ifstream & file); static SUFFIX_MARKER_TYPE readMarker(std::ifstream & file); static sauchar_t * indexVectorToSaucharArray( const std::vector & input); static std::vector indexVectorToSaucharVector( const std::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++) { std::cout << static_cast(vector.at(i)) << " "; } std::cout << std::endl; } #endif