The CreateCollection class.
More...
#include <CreateCollection.h>
|
| static void | saveBase (const std::filesystem::path &base_path, UDBase &col_base) |
|
| void | filesCollecting (const std::vector< std::filesystem::path > &files_and_dirs, UDBase &col_base) |
| size_t | countFiles (const std::vector< UDBElement > &el_v) |
| std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > | getAllFiles (const std::vector< UDBElement > &el_v) |
| void | removeDublicates (std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > &files) |
| void | processFiles (const std::vector< UDBElement > &items) |
| void | fileParsing (UDBElement *file) |
| void | cleanBase (std::vector< UDBElement > &items) |
| void | fb2Parsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | epubParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | pdfParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | djvuParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | odtParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | txtParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | docParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | rtfParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | docxParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | mobiParsing (UDBElement *file, const std::filesystem::path &file_path) |
| void | archiveParsing (UDBElement *file, const std::filesystem::path &file_path) |
| std::string | bufferHash (const std::string &buf) |
| std::string | fileHash (const std::filesystem::path &file_path) |
| void | bufHash (UDBElement *file, const std::filesystem::path &file_path, const std::string &buf) |
The CreateCollection class.
This class contains methods for collection database creation.
◆ CreateCollection()
| CreateCollection::CreateCollection |
( |
const std::shared_ptr< MLBookProc > & | mlbp, |
|
|
const int & | threads_num = int(1) ) |
CreateCollection constructor.
- Parameters
-
| mlbp | Smart pointer to MLBookProc object. |
| threads_num | Maximum permitted number of working threads. |
◆ archiveParsing()
| void CreateCollection::archiveParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses archive file.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ bufferHash()
| std::string CreateCollection::bufferHash |
( |
const std::string & | buf | ) |
|
|
protected |
Calcultes hash sum for given buffer.
- Parameters
-
| buf | Buffer hash sum to be calculated for. |
- Returns
- std::string containing raw hash sum.
◆ bufHash()
| void CreateCollection::bufHash |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path, |
|
|
const std::string & | buf ) |
|
protected |
Calcultes hash sum for given BaseID::File object.
Caller can provide file_path ot buf on his choice.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file hash sum to be calculated for. |
| buf | Buffer hash sum to be calculted for. |
◆ cleanBase()
| void CreateCollection::cleanBase |
( |
std::vector< UDBElement > & | items | ) |
|
|
protected |
◆ countFiles()
| size_t CreateCollection::countFiles |
( |
const std::vector< UDBElement > & | el_v | ) |
|
|
protected |
Counts BaseID::File objects in given vector.
- Parameters
-
| el_v | Vector to be processed. |
- Returns
- Quantity of BaseID::File objects.
◆ createCollection()
| void CreateCollection::createCollection |
( |
const std::vector< std::filesystem::path > & | files_and_dirs, |
|
|
const std::filesystem::path & | base_path ) |
Creates collection database.
- Parameters
-
| files_and_dirs | Files, directories and symlinks to be included in collection. |
| base_path | Path to result database file. |
◆ createInpxCollection()
| void CreateCollection::createInpxCollection |
( |
const std::filesystem::path & | path_to_inpx, |
|
|
const std::filesystem::path & | base_path ) |
Creates database from inpx file.
- Parameters
-
| path_to_inpx | Path to inpx file. |
| base_path | Path to result database file. |
◆ djvuParsing()
| void CreateCollection::djvuParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses djvu file.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ docParsing()
| void CreateCollection::docParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses doc files.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ docxParsing()
| void CreateCollection::docxParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses docx files.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ epubParsing()
| void CreateCollection::epubParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses epub file.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ fb2Parsing()
| void CreateCollection::fb2Parsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses fb2 and fbd file.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ fileHash()
| std::string CreateCollection::fileHash |
( |
const std::filesystem::path & | file_path | ) |
|
|
protected |
Calculates file hash sum.
- Parameters
-
| file_path | Path to file hash sum to be calculated for. |
- Returns
- std::string containing raw hash sum.
◆ fileParsing()
| void CreateCollection::fileParsing |
( |
UDBElement * | file | ) |
|
|
protected |
◆ filesCollecting()
| void CreateCollection::filesCollecting |
( |
const std::vector< std::filesystem::path > & | files_and_dirs, |
|
|
UDBase & | col_base ) |
|
protected |
Collects supported files and creates base template. In most cases you do not need to call this method yourself.
- Parameters
-
| files_and_dirs | Files, directories and symlinks to be included in collection. |
| col_base | Result database. |
◆ getAllFiles()
| std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > CreateCollection::getAllFiles |
( |
const std::vector< UDBElement > & | el_v | ) |
|
|
protected |
Collects all BaseID::File objects.
- Parameters
-
| el_v | Vector to be processed. |
- Returns
- std::tuple. First element is pointer to vector where BaseID::File object has been found. Second element is objects iterator.
◆ mobiParsing()
| void CreateCollection::mobiParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses mobi files.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ odtParsing()
| void CreateCollection::odtParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses odt file.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ pdfParsing()
| void CreateCollection::pdfParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses pdf file.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ processFiles()
| void CreateCollection::processFiles |
( |
const std::vector< UDBElement > & | items | ) |
|
|
protected |
Processed given items.
- Parameters
-
| items | Database template vector. |
◆ removeDublicates()
| void CreateCollection::removeDublicates |
( |
std::vector< std::tuple< const std::vector< UDBElement > *, std::vector< UDBElement >::const_iterator > > & | files | ) |
|
|
protected |
Cleans given vector from repeated BaseID::File objects.
- Parameters
-
◆ rtfParsing()
| void CreateCollection::rtfParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses rtf files.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ saveBase()
| void CreateCollection::saveBase |
( |
const std::filesystem::path & | base_path, |
|
|
UDBase & | col_base ) |
|
static |
Writes given base to file.
- Parameters
-
| base_path | Path to database file. |
| col_base | Collection database. |
◆ stopAll()
| virtual void CreateCollection::stopAll |
( |
| ) |
|
|
virtual |
◆ txtParsing()
| void CreateCollection::txtParsing |
( |
UDBElement * | file, |
|
|
const std::filesystem::path & | file_path ) |
|
protected |
Parses txt and md files.
- Parameters
-
| file | Pointer to BaseID::File object. |
| file_path | Path to file to be parsed. |
◆ already_hashed
| std::vector<std::tuple<std::filesystem::path, std::string> > CreateCollection::already_hashed |
|
protected |
Vector of files for which hash sums has been calculated erlear (in RefreshCollection methods).
First element of tuple - path to file. Second element - raw hash sum.
- Warning
- Do not set or modify this object yourself.
◆ arch_proc
| std::vector<std::shared_ptr<ArchiveParser> > CreateCollection::arch_proc |
|
protected |
Vector of active archives parsing processes.
- Warning
- Do not set or modify this object yourself.
◆ arch_proc_mtx
| std::mutex CreateCollection::arch_proc_mtx |
|
protected |
std::mutex locking arch_proc vector.
- Warning
- Do not set or modify this object yourself.
◆ bid
◆ cancel
| std::atomic<bool> CreateCollection::cancel |
|
protected |
If set to true all processes will be stopped.
- Warning
- Do not set or modify this object yourself.
◆ mlbp
| std::shared_ptr<MLBookProc> CreateCollection::mlbp |
|
protected |
Smart pointer to MlBookProc object.
- Warning
- Do not set or modify this object yourself.
◆ processed
| std::atomic<double> CreateCollection::processed |
|
protected |
Number of processed items.
- Warning
- Do not set or modify this object yourself.
◆ signal_files_collecting
| std::function<void(const size_t &files_found)> CreateCollection::signal_files_collecting |
This callback function will be called during files collecting to indicate progress if set. files_found - total number of found files.
◆ signal_parsing_progress
| std::function<void(double processed, double total)> CreateCollection::signal_parsing_progress |
This callback function will be called during files parsing to indicate progress, if set. processed - number of processed items, total - total number of items to be processed.
◆ threads_v
| std::shared_ptr<std::vector<std::tuple<unsigned, bool> > > CreateCollection::threads_v |
|
protected |
Smart pointer to processors identificators buffer.
First element of tuple - processor number. Second element indicates if processor is busy by any working thread of current collection creation process.
- Warning
- Do not set or modify this object yourself.
◆ threads_v_mtx
| std::shared_ptr<std::mutex> CreateCollection::threads_v_mtx |
|
protected |
Smart pointer to mutex locking threads_v.
- Warning
- Do not set or modify this object yourself.
◆ threads_v_var
| std::shared_ptr<std::condition_variable> CreateCollection::threads_v_var |
|
protected |
Smart pointer to conditional variable locking threads_v.
- Warning
- Do not set or modify this object yourself.
◆ total
| double CreateCollection::total |
|
protected |
Total number of items to be processed.
- Warning
- Do not set or modify this object yourself.