FictionBook2TextContext.h Source File documentation

FictionBook2TextContext.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 FICTIONBOOK2TEXTCONTEXT_H_INCLUDED
11 #define FICTIONBOOK2TEXTCONTEXT_H_INCLUDED
12
13 #include <string>
14
15 #include "FictionBook2ParserContext.h"
16
17 namespace libebook
18 {
19
20 class FictionBook2ParaContextBase : public FictionBook2StyleContextBase
21 {
22 public:
23 FictionBook2ParaContextBase(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
24
25 private:
26 void startOfElement() override;
27 void endOfElement() override;
28 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
29 };
30
31 class FictionBook2AContext : public FictionBook2StyleContextBase
32 {
33 public:
34 FictionBook2AContext(FictionBook2ParserContext *parentContext, const FictionBook2Style &style);
35
36 private:
37 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
38 void startOfElement() override;
39 void endOfElement() override;
40 void endOfAttributes() override;
41 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
42 void text(const char *text) override;
43
44 private:
45 std::string m_href;
46 bool m_valid;
47 bool m_note;
48 };
49
50 class FictionBook2CodeContext : public FictionBook2StyleContextBase
51 {
52 public:
53 FictionBook2CodeContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
54
55 private:
56 void startOfElement() override;
57 };
58
59 class FictionBook2EmphasisContext : public FictionBook2StyleContextBase
60 {
61 public:
62 FictionBook2EmphasisContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
63
64 private:
65 void startOfElement() override;
66 };
67
68 class FictionBook2InlineImageContext : public FictionBook2DataContextBase
69 {
70 public:
71 FictionBook2InlineImageContext(FictionBook2ParserContext *parentContext, const FictionBook2Style &style);
72
73 private:
74 void startOfElement() override;
75 void endOfElement() override;
76 void endOfAttributes() override;
77 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
78
79 private:
80 const FictionBook2Style &m_style;
81 std::string m_href;
82 std::string m_altText;
83 bool m_valid;
84 };
85
86 class FictionBook2PContext : public FictionBook2ParaContextBase
87 {
88 public:
89 FictionBook2PContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
90
91 private:
92 static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format);
93 };
94
95 class FictionBook2StrikethroughContext : public FictionBook2StyleContextBase
96 {
97 public:
98 FictionBook2StrikethroughContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
99
100 private:
101 void startOfElement() override;
102 };
103
104 class FictionBook2StrongContext : public FictionBook2StyleContextBase
105 {
106 public:
107 FictionBook2StrongContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
108
109 private:
110 void startOfElement() override;
111 };
112
113 class FictionBook2StyleContext : public FictionBook2StyleContextBase
114 {
115 public:
116 FictionBook2StyleContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
117
118 private:
119 void startOfElement() override;
120 };
121
122 class FictionBook2SubContext : public FictionBook2StyleContextBase
123 {
124 public:
125 FictionBook2SubContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
126
127 private:
128 void startOfElement() override;
129 };
130
131 class FictionBook2SubtitleContext : public FictionBook2ParaContextBase
132 {
133 public:
134 explicit FictionBook2SubtitleContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
135
136 private:
137 static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format);
138 };
139
140 class FictionBook2SupContext : public FictionBook2StyleContextBase
141 {
142 public:
143 FictionBook2SupContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style);
144
145 private:
146 void startOfElement() override;
147 };
148
149 class FictionBook2TextAuthorContext : public FictionBook2PContext
150 {
151 public:
152 explicit FictionBook2TextAuthorContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
153
154 private:
155 static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format);
156 };
157
158 class FictionBook2VContext : public FictionBook2ParaContextBase
159 {
160 public:
161 explicit FictionBook2VContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
162
163 private:
164 static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format);
165 };
166
167 }
168
169 #endif // FICTIONBOOK2TEXTCONTEXT_H_INCLUDED
170
171 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
FictionBook2ParserContext.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
libebook::FictionBook2AContext
Definition: FictionBook2TextContext.h:32
libebook::FictionBook2AContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition: FictionBook2TextContext.cpp:92
libebook::FictionBook2AContext::endOfAttributes
void endOfAttributes() override
Signalize the end of attributes.
Definition: FictionBook2TextContext.cpp:78
libebook::FictionBook2AContext::m_href
std::string m_href
Definition: FictionBook2TextContext.h:45
libebook::FictionBook2AContext::m_note
bool m_note
Definition: FictionBook2TextContext.h:47
libebook::FictionBook2AContext::text
void text(const char *text) override
Process textual content of an element.
Definition: FictionBook2TextContext.cpp:112
libebook::FictionBook2AContext::m_valid
bool m_valid
Definition: FictionBook2TextContext.h:46
libebook::FictionBook2AContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition: FictionBook2TextContext.cpp:60
libebook::FictionBook2AContext::FictionBook2AContext
FictionBook2AContext(FictionBook2ParserContext *parentContext, const FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:52
libebook::FictionBook2AContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:68
libebook::FictionBook2AContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition: FictionBook2TextContext.cpp:72
libebook::FictionBook2CodeContext
Definition: FictionBook2TextContext.h:51
libebook::FictionBook2CodeContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:127
libebook::FictionBook2CodeContext::FictionBook2CodeContext
FictionBook2CodeContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:122
libebook::FictionBook2DataContextBase
Base class for leaf data element contexts.
Definition: FictionBook2ParserContext.h:82
libebook::FictionBook2EmphasisContext
Definition: FictionBook2TextContext.h:60
libebook::FictionBook2EmphasisContext::FictionBook2EmphasisContext
FictionBook2EmphasisContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:132
libebook::FictionBook2EmphasisContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:137
libebook::FictionBook2InlineImageContext
Definition: FictionBook2TextContext.h:69
libebook::FictionBook2InlineImageContext::m_style
const FictionBook2Style & m_style
Definition: FictionBook2TextContext.h:80
libebook::FictionBook2InlineImageContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:151
libebook::FictionBook2InlineImageContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition: FictionBook2TextContext.cpp:155
libebook::FictionBook2InlineImageContext::endOfAttributes
void endOfAttributes() override
Signalize the end of attributes.
Definition: FictionBook2TextContext.cpp:171
libebook::FictionBook2InlineImageContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition: FictionBook2TextContext.cpp:175
libebook::FictionBook2InlineImageContext::m_valid
bool m_valid
Definition: FictionBook2TextContext.h:83
libebook::FictionBook2InlineImageContext::FictionBook2InlineImageContext
FictionBook2InlineImageContext(FictionBook2ParserContext *parentContext, const FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:142
libebook::FictionBook2InlineImageContext::m_href
std::string m_href
Definition: FictionBook2TextContext.h:81
libebook::FictionBook2InlineImageContext::m_altText
std::string m_altText
Definition: FictionBook2TextContext.h:82
libebook::FictionBook2PContext
Definition: FictionBook2TextContext.h:87
libebook::FictionBook2PContext::makeBlockFormat
static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:200
libebook::FictionBook2PContext::FictionBook2PContext
FictionBook2PContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:195
libebook::FictionBook2ParaContextBase
Definition: FictionBook2TextContext.h:21
libebook::FictionBook2ParaContextBase::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition: FictionBook2TextContext.cpp:27
libebook::FictionBook2ParaContextBase::FictionBook2ParaContextBase
FictionBook2ParaContextBase(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:17
libebook::FictionBook2ParaContextBase::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:22
libebook::FictionBook2ParaContextBase::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition: FictionBook2TextContext.cpp:32
libebook::FictionBook2ParserContext
Base class for all contexts.
Definition: FictionBook2ParserContext.h:24
libebook::FictionBook2StrikethroughContext
Definition: FictionBook2TextContext.h:96
libebook::FictionBook2StrikethroughContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:212
libebook::FictionBook2StrikethroughContext::FictionBook2StrikethroughContext
FictionBook2StrikethroughContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:207
libebook::FictionBook2StrongContext
Definition: FictionBook2TextContext.h:105
libebook::FictionBook2StrongContext::FictionBook2StrongContext
FictionBook2StrongContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:217
libebook::FictionBook2StrongContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:222
libebook::FictionBook2StyleContextBase
Definition: FictionBook2ParserContext.h:133
libebook::FictionBook2StyleContext
Definition: FictionBook2TextContext.h:114
libebook::FictionBook2StyleContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:232
libebook::FictionBook2StyleContext::FictionBook2StyleContext
FictionBook2StyleContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:227
libebook::FictionBook2Style
Definition: FictionBook2Style.h:56
libebook::FictionBook2SubContext
Definition: FictionBook2TextContext.h:123
libebook::FictionBook2SubContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:242
libebook::FictionBook2SubContext::FictionBook2SubContext
FictionBook2SubContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:237
libebook::FictionBook2SubtitleContext
Definition: FictionBook2TextContext.h:132
libebook::FictionBook2SubtitleContext::FictionBook2SubtitleContext
FictionBook2SubtitleContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:247
libebook::FictionBook2SubtitleContext::makeBlockFormat
static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:252
libebook::FictionBook2SupContext
Definition: FictionBook2TextContext.h:141
libebook::FictionBook2SupContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition: FictionBook2TextContext.cpp:264
libebook::FictionBook2SupContext::FictionBook2SupContext
FictionBook2SupContext(FictionBook2ParserContext *parentContext, FictionBook2Style &style)
Definition: FictionBook2TextContext.cpp:259
libebook::FictionBook2TextAuthorContext
Definition: FictionBook2TextContext.h:150
libebook::FictionBook2TextAuthorContext::makeBlockFormat
static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:274
libebook::FictionBook2TextAuthorContext::FictionBook2TextAuthorContext
FictionBook2TextAuthorContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:269
libebook::FictionBook2VContext
Definition: FictionBook2TextContext.h:159
libebook::FictionBook2VContext::makeBlockFormat
static FictionBook2BlockFormat makeBlockFormat(const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:286
libebook::FictionBook2VContext::FictionBook2VContext
FictionBook2VContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format)
Definition: FictionBook2TextContext.cpp:281
libebook::FictionBook2XMLParserContext
Definition: FictionBook2XMLParserContext.h:19
libebook::EBOOKOPFToken::format
@ format
Definition: EBOOKOPFToken.h:54
libebook
Definition: BBeBCollector.cpp:19
libebook::FictionBook2BlockFormat
Definition: FictionBook2Style.h:36
libebook::FictionBook2TokenData
Definition: FictionBook2Token.h:134