MLBookProc 1.3
Loading...
Searching...
No Matches
EPUBParser.h
1/*
2 * Copyright (C) 2024-2025 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
17#ifndef EPUBPARSER_H
18#define EPUBPARSER_H
19
20#include <ArchEntry.h>
21#include <AuxFunc.h>
22#include <BookInfoEntry.h>
23#include <BookParseEntry.h>
24#include <DublinCoreParser.h>
25#include <LibArchive.h>
26#include <XMLAlgorithms.h>
27#include <XMLParserCPP.h>
28#include <filesystem>
29#include <memory>
30#include <string>
31#include <vector>
32
40class EPUBParser : public LibArchive
41{
42public:
47 EPUBParser(const std::shared_ptr<AuxFunc> &af);
48
52 virtual ~EPUBParser();
53
63 __attribute__((deprecated)) BookParseEntry
64 epub_parser(const std::filesystem::path &filepath);
65
75 epubParser(const std::filesystem::path &filepath);
76
86 __attribute__((deprecated)) std::shared_ptr<BookInfoEntry>
87 epub_book_info(const std::filesystem::path &filepath);
88
94 std::shared_ptr<BookInfoEntry>
95 epubBookInfo(const std::filesystem::path &filepath);
96
97private:
98 std::string
99 epubGetRootFileAddress(const std::filesystem::path &filepath,
100 const std::vector<ArchEntry> &filenames);
101
103 epubParseRootFile(const std::string &root_file_content);
104
105 std::string
106 epubAnnotation(const std::vector<XMLElement> &elements);
107
108 std::string
109 epubCoverAddress(const std::vector<XMLElement> &elements,
110 const std::filesystem::path &filepath,
111 const std::vector<ArchEntry> &filenames);
112
113 void
114 epubLanguage(const std::vector<XMLElement> &elements, BookInfoEntry &result);
115
116 void
117 epubTranslator(const std::vector<XMLElement> &elements,
118 BookInfoEntry &result);
119
120 void
121 epubPublisher(const std::vector<XMLElement> &elements,
122 BookInfoEntry &result);
123
124 void
125 epubIdentifier(const std::vector<XMLElement> &elements,
126 BookInfoEntry &result);
127
128 void
129 epubSource(const std::vector<XMLElement> &elements, BookInfoEntry &result);
130
131 std::string
132 getEncoding(const std::vector<XMLElement> &elements);
133
134 std::shared_ptr<AuxFunc> af;
135
137
138 XMLParserCPP *xml_parser;
139};
140
141#endif // EPUBPARSER_H
The BookInfoEntry class.
Definition BookInfoEntry.h:31
The BookParseEntry class.
Definition BookParseEntry.h:30
The DublinCoreParser class.
Definition DublinCoreParser.h:31
EPUBParser(const std::shared_ptr< AuxFunc > &af)
EPUBParser constructor.
std::shared_ptr< BookInfoEntry > epubBookInfo(const std::filesystem::path &filepath)
Returns epub book info and cover.
virtual ~EPUBParser()
EPUBParser destructor.
BookParseEntry epubParser(const std::filesystem::path &filepath)
Parses epub book.
std::shared_ptr< BookInfoEntry > epub_book_info(const std::filesystem::path &filepath)
Returns epub book info and cover.
BookParseEntry epub_parser(const std::filesystem::path &filepath)
Parses epub book.
LibArchive(const std::shared_ptr< AuxFunc > &af)
LibArchive constructor.