FictionBook2BlockContext.h Source File documentation

FictionBook2BlockContext.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 FICTIONBOOK2BLOCKCONTEXT_H_INCLUDED
11#define FICTIONBOOK2BLOCKCONTEXT_H_INCLUDED
12
13#include <string>
14
15#include <boost/optional.hpp>
16
17#include "FictionBook2ParserContext.h"
18
19namespace libebook
20{
21
22 class FictionBook2BodyContext : public FictionBook2NodeContextBase
23{
24public:
25 FictionBook2BodyContext(FictionBook2ParserContext *parentContext, FictionBook2Collector *collector);
26
27private:
28 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
29 void startOfElement() override;
30 void endOfElement() override;
31 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
32
33private:
34 boost::optional<std::string> m_lang;
35};
36
37 class FictionBook2CiteContext : public FictionBook2BlockFormatContextBase
38{
39public:
40 FictionBook2CiteContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
41
42private:
43 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
44 void endOfElement() override;
45 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
46};
47
48 class FictionBook2EmptyLineContext : public FictionBook2DataContextBase
49{
50public:
51 explicit FictionBook2EmptyLineContext(FictionBook2ParserContext *parentContext);
52
53private:
54 void endOfElement() override;
55 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
56};
57
58 class FictionBook2EpigraphContext : public FictionBook2BlockFormatContextBase
59{
60public:
61 FictionBook2EpigraphContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
62
63private:
64 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
65 void endOfElement() override;
66 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
67};
68
69 class FictionBook2ImageContext : public FictionBook2NodeContextBase
70{
71public:
72 FictionBook2ImageContext(FictionBook2ParserContext *parentContext);
73
74private:
75 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
76 void endOfElement() override;
77 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
78
79private:
80 std::string m_href;
81 std::string m_altText;
82 bool m_valid;
83};
84
85 class FictionBook2PoemContext : public FictionBook2BlockFormatContextBase
86{
87public:
88 FictionBook2PoemContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
89
90private:
91 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
92 void startOfElement() override;
93 void endOfElement() override;
94 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
95};
96
97 class FictionBook2SectionContext : public FictionBook2NodeContextBase
98{
99public:
100 FictionBook2SectionContext(FictionBook2ParserContext *parentContext, const boost::optional<std::string> &lang);
101 FictionBook2SectionContext(FictionBook2ParserContext *parentContext, uint8_t level, const boost::optional<std::string> &lang);
102
103private:
104 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
105 void endOfElement() override;
106 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
107
108 FictionBook2BlockFormat makeBlockFormat() const;
109
110private:
111 // The level of the section. A section directly in body is at level 1.
112 boost::optional<uint8_t> m_level;
113 boost::optional<std::string> m_lang;
114};
115
116 class FictionBook2StanzaContext : public FictionBook2BlockFormatContextBase
117{
118public:
119 FictionBook2StanzaContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
120
121private:
122 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
123 void endOfElement() override;
124 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
125};
126
127 class FictionBook2TitleContext : public FictionBook2BlockFormatContextBase
128{
129public:
130 FictionBook2TitleContext(FictionBook2ParserContext *const parentContext, const FictionBook2BlockFormat &format);
131
132private:
133 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
134 void endOfElement() override;
135 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
136};
137
138}
139
140#endif // FICTIONBOOK2BLOCKCONTEXT_H_INCLUDED
141
142/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
FictionBook2ParserContext.h
name
string name
Definition HTMLHelpStream.cpp:80
value
qi::rule< Iterator, AttrValue_t, qi::space_type > value
Definition TealDocParser.cpp:231
libebook::FictionBook2BlockFormatContextBase
Definition FictionBook2ParserContext.h:152
libebook::FictionBook2BodyContext
Definition FictionBook2BlockContext.h:23
libebook::FictionBook2BodyContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:57
libebook::FictionBook2BodyContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:62
libebook::FictionBook2BodyContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:26
libebook::FictionBook2BodyContext::m_lang
boost::optional< std::string > m_lang
Definition FictionBook2BlockContext.h:34
libebook::FictionBook2BodyContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition FictionBook2BlockContext.cpp:52
libebook::FictionBook2CiteContext
Definition FictionBook2BlockContext.h:38
libebook::FictionBook2CiteContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:101
libebook::FictionBook2CiteContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:97
libebook::FictionBook2CiteContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:73
libebook::FictionBook2Collector
Definition FictionBook2Collector.h:23
libebook::FictionBook2DataContextBase
Base class for leaf data element contexts.
Definition FictionBook2ParserContext.h:82
libebook::FictionBook2EmptyLineContext
Definition FictionBook2BlockContext.h:49
libebook::FictionBook2EmptyLineContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:120
libebook::FictionBook2EmptyLineContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:114
libebook::FictionBook2EpigraphContext
Definition FictionBook2BlockContext.h:59
libebook::FictionBook2EpigraphContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:129
libebook::FictionBook2EpigraphContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:153
libebook::FictionBook2EpigraphContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:157
libebook::FictionBook2ImageContext
Definition FictionBook2BlockContext.h:70
libebook::FictionBook2ImageContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:186
libebook::FictionBook2ImageContext::m_href
std::string m_href
Definition FictionBook2BlockContext.h:80
libebook::FictionBook2ImageContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:171
libebook::FictionBook2ImageContext::m_valid
bool m_valid
Definition FictionBook2BlockContext.h:82
libebook::FictionBook2ImageContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:216
libebook::FictionBook2ImageContext::m_altText
std::string m_altText
Definition FictionBook2BlockContext.h:81
libebook::FictionBook2NodeContextBase
Base class for non-leaf element contexts.
Definition FictionBook2ParserContext.h:62
libebook::FictionBook2ParserContext
Base class for all contexts.
Definition FictionBook2ParserContext.h:24
libebook::FictionBook2PoemContext
Definition FictionBook2BlockContext.h:86
libebook::FictionBook2PoemContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:287
libebook::FictionBook2PoemContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:291
libebook::FictionBook2PoemContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition FictionBook2BlockContext.cpp:281
libebook::FictionBook2PoemContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:256
libebook::FictionBook2SectionContext
Definition FictionBook2BlockContext.h:98
libebook::FictionBook2SectionContext::m_level
boost::optional< uint8_t > m_level
Definition FictionBook2BlockContext.h:112
libebook::FictionBook2SectionContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:364
libebook::FictionBook2SectionContext::m_lang
boost::optional< std::string > m_lang
Definition FictionBook2BlockContext.h:113
libebook::FictionBook2SectionContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:313
libebook::FictionBook2SectionContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:359
libebook::FictionBook2SectionContext::makeBlockFormat
FictionBook2BlockFormat makeBlockFormat() const
Definition FictionBook2BlockContext.cpp:372
libebook::FictionBook2StanzaContext
Definition FictionBook2BlockContext.h:117
libebook::FictionBook2StanzaContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:408
libebook::FictionBook2StanzaContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:388
libebook::FictionBook2StanzaContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:414
libebook::FictionBook2TitleContext
Definition FictionBook2BlockContext.h:128
libebook::FictionBook2TitleContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2BlockContext.cpp:444
libebook::FictionBook2TitleContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2BlockContext.cpp:426
libebook::FictionBook2TitleContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2BlockContext.cpp:449
libebook::FictionBook2XMLParserContext
Definition FictionBook2XMLParserContext.h:19
libebook
Definition BBeBCollector.cpp:19
libebook::FictionBook2BlockFormat
Definition FictionBook2Style.h:36
libebook::FictionBook2TokenData
Definition FictionBook2Token.h:134