MLBookProc 2.1
Loading...
Searching...
No Matches
ArchiveParser.h
1/*
2 * Copyright (C) 2026 Yury Bobylev <bobilev_yury@mail.ru>
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 3.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#ifndef ARCHIVEPARSER_H
17#define ARCHIVEPARSER_H
18
19#include <BaseID.h>
20#include <LibArchive.h>
21#include <MLBookProc.h>
22#include <UDBElement.h>
23#include <archive_entry.h>
24#include <atomic>
25#include <condition_variable>
26#include <filesystem>
27#include <memory>
28#include <mutex>
29
38{
39public:
49 const std::shared_ptr<MLBookProc> &mlbp,
50 const std::shared_ptr<std::vector<std::tuple<unsigned, bool>>> &thread_v,
51 const std::shared_ptr<std::mutex> &thread_v_mtx,
52 const std::shared_ptr<std::condition_variable> &thread_v_var);
53
54 virtual ~ArchiveParser();
55
62 std::vector<UDBElement>
63 parseArchive(const std::filesystem::path &file_path);
64
68 void
70
71private:
72 void
73 parseEntry(std::shared_ptr<archive> a, std::shared_ptr<archive_entry> e);
74
75 enum FileType
76 {
77 FB2,
78 EPUB,
79 PDF,
80 DJVU,
81 ODT,
82 TXT,
83 DOC,
84 RTF,
85 DOCX,
86 MOBI
87 };
88
89 UDBElement
90 bufferParse(const std::string &buf, const std::string &arch_file_path,
91 std::shared_ptr<archive_entry> e, const FileType &ft);
92
93 void
94 fbdProcessing();
95
96 std::vector<UDBElement> fbd;
97 std::vector<UDBElement> result;
98 std::vector<std::string> unsupported;
99
100 std::atomic<bool> cancel;
101
102 std::shared_ptr<ArchiveParser> arch_proc;
103
104 std::shared_ptr<std::vector<std::tuple<unsigned, bool>>> thread_v;
105 std::shared_ptr<std::mutex> thread_v_mtx;
106 std::shared_ptr<std::condition_variable> thread_v_var;
107
108 int thr_num = 0;
109 std::mutex thr_num_mtx;
110 std::condition_variable thr_num_var;
111
112 BaseID bid;
113};
114
115#endif // ARCHIVEPARSER_H
std::vector< UDBElement > parseArchive(const std::filesystem::path &file_path)
ArchiveParser(const std::shared_ptr< MLBookProc > &mlbp, const std::shared_ptr< std::vector< std::tuple< unsigned, bool > > > &thread_v, const std::shared_ptr< std::mutex > &thread_v_mtx, const std::shared_ptr< std::condition_variable > &thread_v_var)
ArchiveParser constructor.
The BaseID class.
Definition BaseID.h:28
std::shared_ptr< MLBookProc > mlbp
Definition LibArchive.h:499
LibArchive(const std::shared_ptr< MLBookProc > &mlbp)
LibArchive constructor.