#include <AuxFunc.h>
Public Member Functions | |
virtual | ~AuxFunc () |
AuxFunc destructor. | |
std::string | to_utf_8 (const std::string &input, const char *conv_name) |
Converts string to UTF-8 string. | |
std::string | utf8_to_system (const std::string &input) |
Converts UTF-8 string to string in system default encoding. | |
std::string | utf_8_to (const std::string &input, const char *conv_name) |
Converts UTF-8 string to string in chosen encoding. | |
const char * | get_converter_by_number (const int32_t &num) |
Returns converter name. | |
std::string | detect_encoding (const std::string &buf) |
Tries to detect string encoding. | |
std::filesystem::path | homePath () |
Returns user home directory path. | |
std::filesystem::path | get_selfpath () |
Returns absolute path to program executable file. | |
std::filesystem::path | temp_path () |
Returns absolute path to system temporary directory. | |
std::filesystem::path | share_path () |
Returns absolute path to share directory, used by MLBookProc. | |
std::vector< GenreGroup > | get_genre_list () |
Returns translated genre groups and genres names. | |
std::string | libgcrypt_error_handling (const gcry_error_t &err) |
Auxiliary method to reinterpret libgcrypt errors as strings. | |
std::string | to_hex (const std::string &source) |
Converts given string to hex format. | |
std::string | stringToLower (const std::string &line) |
Converts all letters of the string to lowercase letters. | |
std::string | randomFileName () |
Returns random string. | |
std::string | time_t_to_date (const time_t &tt) |
Converts time_t value to calendar date. | |
bool | if_supported_type (const std::filesystem::path &ch_p) |
Checks if given file is supported by MLBookProc. | |
void | html_to_utf8 (std::string &input) |
Converst 'html' symbols to UTF-8 characters. | |
void | open_book_callback (const std::filesystem::path &path) |
Opens given file in default system application. | |
void | copy_book_callback (const std::filesystem::path &source, const std::filesystem::path &out) |
Replaces out file by source file. | |
std::vector< std::string > | get_supported_types () |
Returns supported file types. | |
std::vector< std::string > | get_supported_archive_types_packing () |
Same as get_supported_types(), but returns only archives types, available for packing. | |
std::vector< std::string > | get_supported_archive_types_unpacking () |
Same as get_supported_types(), but returns only archives types, available for unpacking. | |
std::string | get_extension (const std::filesystem::path &p) |
Returns file extesion. | |
int32_t | get_charset_conv_quantity () |
Returns number of available converters. | |
bool | get_activated () |
Checks if depencies have been successfully activated. | |
std::shared_ptr< ddjvu_context_t > | getDJVUContext () |
Returns smart pointer to djvu context object. | |
Static Public Member Functions | |
template<class InputIt, class T = typename std::iterator_traits<InputIt>::value_type> | |
static InputIt | parallelFind (InputIt start, InputIt end, const T &val) |
'Find' method for C++ standard containers. | |
template<class InputIt, class UnaryPred> | |
static InputIt | parallelFindIf (InputIt start, InputIt end, UnaryPred predicate) |
'Find' method for C++ standard containers. | |
template<class InputIt, class T = typename std::iterator_traits<InputIt>::value_type> | |
static InputIt | parallelRemove (InputIt start, InputIt end, const T &val) |
"Remove" method for C++ containers. | |
template<class InputIt, class UnaryPred> | |
static InputIt | parallelRemoveIf (InputIt start, InputIt end, UnaryPred predicate) |
'Remove' method for C++ containers. | |
static std::shared_ptr< AuxFunc > | create () |
Creats AuxFunc object. | |
The AuxFunc class.
AuxFunc class contains various useful auxiliary methods. AuxFunc object must be created (see create()) before using of any MLBookProc methods or classes. create() method should be called only once per program. Also it is strongly recommended to call get_activated() method immediately after AuxFunc object creation.
void AuxFunc::copy_book_callback | ( | const std::filesystem::path & | source, |
const std::filesystem::path & | out ) |
Replaces out file by source file.
This method acts like std::filesystem::copy. It was introduced due to MinGW bug (MinGW ignores std::filesystem::copy_options::overwrite_existing).
source | file to be copied. |
out | file to be replaced. |
|
static |
std::string AuxFunc::detect_encoding | ( | const std::string & | buf | ) |
Tries to detect string encoding.
buf | string which encoding is to be detected. |
bool AuxFunc::get_activated | ( | ) |
Checks if depencies have been successfully activated.
int32_t AuxFunc::get_charset_conv_quantity | ( | ) |
Returns number of available converters.
See icu documentation for details.
const char * AuxFunc::get_converter_by_number | ( | const int32_t & | num | ) |
Returns converter name.
num | converter number (see icu documentation for details). |
std::string AuxFunc::get_extension | ( | const std::filesystem::path & | p | ) |
Returns file extesion.
p | absolute path to file. |
std::vector< GenreGroup > AuxFunc::get_genre_list | ( | ) |
Returns translated genre groups and genres names.
Resulting genre groups and genres will be in default system language, if translations are available, or in English.
std::filesystem::path AuxFunc::get_selfpath | ( | ) |
Returns absolute path to program executable file.
std::vector< std::string > AuxFunc::get_supported_archive_types_packing | ( | ) |
Same as get_supported_types(), but returns only archives types, available for packing.
std::vector< std::string > AuxFunc::get_supported_archive_types_unpacking | ( | ) |
Same as get_supported_types(), but returns only archives types, available for unpacking.
std::vector< std::string > AuxFunc::get_supported_types | ( | ) |
Returns supported file types.
std::shared_ptr< ddjvu_context_t > AuxFunc::getDJVUContext | ( | ) |
Returns smart pointer to djvu context object.
std::filesystem::path AuxFunc::homePath | ( | ) |
Returns user home directory path.
void AuxFunc::html_to_utf8 | ( | std::string & | input | ) |
Converst 'html' symbols to UTF-8 characters.
Replaces "&#<unicode_number>;" symbols by UTF-8 characters.
input | string to be converted. |
bool AuxFunc::if_supported_type | ( | const std::filesystem::path & | ch_p | ) |
Checks if given file is supported by MLBookProc.
'Supported types' check is carried out by file extension.
ch_p | absolute path to file. |
std::string AuxFunc::libgcrypt_error_handling | ( | const gcry_error_t & | err | ) |
Auxiliary method to reinterpret libgcrypt errors as strings.
In most cases you do not need to call this method directly.
err | libgcrypt error code (see libgcrypt documentation for details). |
void AuxFunc::open_book_callback | ( | const std::filesystem::path & | path | ) |
Opens given file in default system application.
path | absolute path to file to be opened. |
|
inlinestatic |
|
inlinestatic |
'Find' method for C++ standard containers.
This method acts like std::find_if, but uses OpenMP multithreading for acceleration.
start | start iterator. |
end | end iterator. |
predicate | method to be used to check values. |
|
inlinestatic |
"Remove" method for C++ containers.
This method acts like std::remove, but uses OpenMP multithreading for acceleration.
start | start iterator. |
end | end iterator. |
val | value to be removed. |
|
inlinestatic |
'Remove' method for C++ containers.
This method acts like std::remove_if, but uses OpenMP multithreading for acceleration.
start | start iterator. |
end | end iterator. |
predicate | method to be used to check values. |
std::string AuxFunc::randomFileName | ( | ) |
Returns random string.
std::filesystem::path AuxFunc::share_path | ( | ) |
Returns absolute path to share directory, used by MLBookProc.
Result path is calculating as path relative to program executable file path ('absolute_path_to_executable_file/../share').
std::string AuxFunc::stringToLower | ( | const std::string & | line | ) |
Converts all letters of the string to lowercase letters.
line | UTF-8 encoded string to be converted to lowercase. |
std::filesystem::path AuxFunc::temp_path | ( | ) |
Returns absolute path to system temporary directory.
std::string AuxFunc::time_t_to_date | ( | const time_t & | tt | ) |
Converts time_t value to calendar date.
tt | time_t value. |
std::string AuxFunc::to_hex | ( | const std::string & | source | ) |
Converts given string to hex format.
Each char element will be converted to two hexidecimal digits.
source | string to be converted. |
std::string AuxFunc::to_utf_8 | ( | const std::string & | input, |
const char * | conv_name ) |
Converts string to UTF-8 string.
input | string to be converted. |
conv_name | input string encoding name (see icu documentation for details). |
std::string AuxFunc::utf8_to_system | ( | const std::string & | input | ) |
Converts UTF-8 string to string in system default encoding.
input | UTF-8 string to be converted. |
std::string AuxFunc::utf_8_to | ( | const std::string & | input, |
const char * | conv_name ) |
Converts UTF-8 string to string in chosen encoding.
input | string to be converted. |
conv_name | output string encoding name (see icu documentation for details). |