// This file is part of Timmi. // // Timmi is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. #ifndef UTILS_HH #define UTILS_HH #include #include #include class Random { private: std::ifstream device; public: Random (); unsigned int rand(); int random_in_range(int, int); }; enum DebugLevel {VERBOSE = 0, INFO = 1, WARNING = 2, CRITICAL = 3}; const char DEBUGCHARS[] = {'V', 'I', 'W', 'C'}; extern int ERRORLEVEL; void debug(DebugLevel, std::string); void debug_with_errno(DebugLevel level, const std::string &message, int err); void debug_with_errno(DebugLevel level, const std::string &message); int strtoi(std::string str); std::string strtoupper(std::string str); std::string datetostring(std::string format, time_t t = -1); std::string get_locale_charset(); bool simple_iconv(std::string input_str, std::string input_encoding, std::string &output_str, std::string output_encoding, bool transliterate = false); bool is_valid_utf8(std::string str); #endif