Debian Codegraph @

src/file/ApvlvFb2.h

raw
1 /*
2 * This file is part of the apvlv package
3 * Copyright (C) <2010> <Alf>
4 *
5 * Contact: Alf <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22 /* @CPPFILE ApvlvFb2.h
23 *
24 * Author: Alf <[email protected]>
25 */
26
27 #ifndef _APVLV_FB2_H_
28 #define _APVLV_FB2_H_
29
30 #include <QXmlStreamReader>
31
32 #include "ApvlvFile.h"
33
34 namespace apvlv
35 {
36 class ApvlvFB2 : public File
37 {
38 FILE_TYPE_DECLARATION (ApvlvFB2);
39
40 public:
41 bool load (const std::string &filename) override;
42
43 ~ApvlvFB2 () override = default;
44
45 int sum () override;
46
47 bool pageRenderToWebView (int pn, double zm, int rot,
48 WebView *webview) override;
49
50 std::optional<QByteArray> pathContent (const std::string &path) override;
51
52 private:
53 std::map<std::string, std::pair<std::string, std::string>> titleSections;
54 std::string mCoverHref;
55
56 bool parseFb2 (const char *content, size_t length);
57 bool parseDescription (const char *content, size_t length);
58 bool parseBody (const char *content, size_t length);
59 bool parseBinary (const char *content, size_t length);
60 void appendCoverpage (const std::string &section, const std::string &mime);
61 void appendTitle (const std::string &section, const std::string &mime);
62 void appendSection (const std::string &title, const std::string &section,
63 const std::string &mime);
64 void appendPage (const std::string &uri, const std::string &title,
65 const std::string &section, const std::string &mime);
66 bool generateIndex ();
67 };
68
69 }
70 #endif
71
72 /* Local Variables: */
73 /* mode: c++ */
74 /* End: */