FictionBook2Collector.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/*
3 * This file is part of the libe-book project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef FICTIONBOOK2COLLECTOR_H_INCLUDED
11#define FICTIONBOOK2COLLECTOR_H_INCLUDED
12
13#include <deque>
14#include <string>
15#include <unordered_map>
16
17#include "FictionBook2Style.h"
18
19 namespace libebook
20{
21
22 class FictionBook2Collector
23{
24 public:
25 struct Binary
26 {
27 Binary(const std::string &contentType, const std::string &base64Data);
28
29 const std::string m_contentType;
30 const std::string m_data;
31 };
32
33 struct Span
34 {
35 explicit Span(const FictionBook2Style &style);
36
37 const FictionBook2Style m_style;
38 std::string m_text;
39 };
40
41 struct Paragraph
42 {
43 explicit Paragraph(const FictionBook2BlockFormat &format);
44
45 const FictionBook2BlockFormat m_format;
46 std::deque<Span> m_spans;
47 };
48
49 struct Note
50 {
51 Note();
52
53 std::string m_title;
54 std::deque<Paragraph> m_paras;
55 };
56
57 typedef std::unordered_map<std::string, Binary> BinaryMap_t;
58 typedef std::unordered_map<std::string, Note> NoteMap_t;
59
60 public:
61 virtual ~FictionBook2Collector() = 0;
62
63 virtual void defineMetadataEntry(const char *name, const char *value) = 0;
64 virtual void openMetadataEntry(const char *name) = 0;
65 virtual void closeMetadataEntry() = 0;
66
67 virtual void defineID(const char *id) = 0;
68
69 virtual void openPageSpan() = 0;
70 virtual void closePageSpan() = 0;
71
72 virtual void openBlock() = 0;
73 virtual void closeBlock() = 0;
74
75 virtual void openParagraph(const FictionBook2BlockFormat &format) = 0;
76 virtual void closeParagraph() = 0;
77
78 virtual void openSpan(const FictionBook2Style &style) = 0;
79 virtual void closeSpan() = 0;
80
81 virtual void insertText(const char *text) = 0;
82
83 virtual void openTable(const FictionBook2BlockFormat &format) = 0;
84 virtual void closeTable() = 0;
85
86 virtual void openTableRow(const FictionBook2BlockFormat &format) = 0;
87 virtual void closeTableRow() = 0;
88
89 virtual void openTableCell(int rowspan, int colspan) = 0;
90 virtual void closeTableCell() = 0;
91 virtual void insertCoveredTableCell() = 0;
92
93 virtual void insertFootnote(const char *id) = 0;
94
95 virtual void insertBitmap(const char *id) = 0;
96 virtual void insertBitmapData(const char *contentType, const char *base64Data) = 0;
97};
98
99}
100
101#endif // FICTIONBOOK2COLLECTOR_H_INCLUDED
102
103/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
FictionBook2Style.h
name
string name
Definition HTMLHelpStream.cpp:80
style
optional< Style > style
Definition TealDocParser.cpp:105
value
qi::rule< Iterator, AttrValue_t, qi::space_type > value
Definition TealDocParser.cpp:231
text
qi::rule< Iterator, AttrValue_t, qi::space_type > text
Definition TealDocParser.cpp:232
libebook::FictionBook2Collector
Definition FictionBook2Collector.h:23
libebook::FictionBook2Collector::insertText
virtual void insertText(const char *text)=0
libebook::FictionBook2Collector::closeBlock
virtual void closeBlock()=0
libebook::FictionBook2Collector::openTableRow
virtual void openTableRow(const FictionBook2BlockFormat &format)=0
libebook::FictionBook2Collector::NoteMap_t
std::unordered_map< std::string, Note > NoteMap_t
Definition FictionBook2Collector.h:58
libebook::FictionBook2Collector::closeParagraph
virtual void closeParagraph()=0
libebook::FictionBook2Collector::openMetadataEntry
virtual void openMetadataEntry(const char *name)=0
libebook::FictionBook2Collector::defineID
virtual void defineID(const char *id)=0
libebook::FictionBook2Collector::closePageSpan
virtual void closePageSpan()=0
libebook::FictionBook2Collector::openTable
virtual void openTable(const FictionBook2BlockFormat &format)=0
libebook::FictionBook2Collector::insertBitmapData
virtual void insertBitmapData(const char *contentType, const char *base64Data)=0
libebook::FictionBook2Collector::openBlock
virtual void openBlock()=0
libebook::FictionBook2Collector::insertCoveredTableCell
virtual void insertCoveredTableCell()=0
libebook::FictionBook2Collector::insertBitmap
virtual void insertBitmap(const char *id)=0
libebook::FictionBook2Collector::closeSpan
virtual void closeSpan()=0
libebook::FictionBook2Collector::closeTableCell
virtual void closeTableCell()=0
libebook::FictionBook2Collector::defineMetadataEntry
virtual void defineMetadataEntry(const char *name, const char *value)=0
libebook::FictionBook2Collector::BinaryMap_t
std::unordered_map< std::string, Binary > BinaryMap_t
Definition FictionBook2Collector.h:57
libebook::FictionBook2Collector::insertFootnote
virtual void insertFootnote(const char *id)=0
libebook::FictionBook2Collector::openTableCell
virtual void openTableCell(int rowspan, int colspan)=0
libebook::FictionBook2Collector::openSpan
virtual void openSpan(const FictionBook2Style &style)=0
libebook::FictionBook2Collector::closeTableRow
virtual void closeTableRow()=0
libebook::FictionBook2Collector::openParagraph
virtual void openParagraph(const FictionBook2BlockFormat &format)=0
libebook::FictionBook2Collector::~FictionBook2Collector
virtual ~FictionBook2Collector()=0
Definition FictionBook2Collector.cpp:39
libebook::FictionBook2Collector::closeMetadataEntry
virtual void closeMetadataEntry()=0
libebook::FictionBook2Collector::openPageSpan
virtual void openPageSpan()=0
libebook::FictionBook2Collector::closeTable
virtual void closeTable()=0
libebook::FictionBook2Style
Definition FictionBook2Style.h:56
libebook
Definition BBeBCollector.cpp:19
libebook::FictionBook2BlockFormat
Definition FictionBook2Style.h:36
libebook::FictionBook2Collector::Binary
Definition FictionBook2Collector.h:26
libebook::FictionBook2Collector::Binary::m_data
const std::string m_data
Definition FictionBook2Collector.h:30
libebook::FictionBook2Collector::Binary::m_contentType
const std::string m_contentType
Definition FictionBook2Collector.h:29
libebook::FictionBook2Collector::Note
Definition FictionBook2Collector.h:50
libebook::FictionBook2Collector::Note::m_title
std::string m_title
Definition FictionBook2Collector.h:53
libebook::FictionBook2Collector::Note::m_paras
std::deque< Paragraph > m_paras
Definition FictionBook2Collector.h:54
libebook::FictionBook2Collector::Note::Note
Note()
Definition FictionBook2Collector.cpp:33
libebook::FictionBook2Collector::Paragraph
Definition FictionBook2Collector.h:42
libebook::FictionBook2Collector::Paragraph::m_spans
std::deque< Span > m_spans
Definition FictionBook2Collector.h:46
libebook::FictionBook2Collector::Paragraph::m_format
const FictionBook2BlockFormat m_format
Definition FictionBook2Collector.h:45
libebook::FictionBook2Collector::Span
Definition FictionBook2Collector.h:34
libebook::FictionBook2Collector::Span::m_style
const FictionBook2Style m_style
Definition FictionBook2Collector.h:37
libebook::FictionBook2Collector::Span::m_text
std::string m_text
Definition FictionBook2Collector.h:38