FB2ParserContext.h Source File documentation

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

FB2ParserContext.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 FB2PARSERCONTEXT_H_INCLUDED
11 #define FB2PARSERCONTEXT_H_INCLUDED
12
13 #include "FB2XMLParserContext.h"
14 #include "FB2Style.h"
15
16 namespace libebook
17 {
18
19 class FB2Collector;
20
23 class FB2ParserContext : public FB2XMLParserContext
24 {
25 // no copying
26 FB2ParserContext(const FB2ParserContext &other);
27 FB2ParserContext &operator=(const FB2ParserContext &other);
28
29 public:
35 explicit FB2ParserContext(FB2ParserContext *parentContext, FB2Collector *collector = 0);
36
37 virtual FB2XMLParserContext *leaveContext() const;
38
43 FB2Collector *getCollector() const;
44
49 FB2ParserContext *getParentContext() const;
50
51 private:
52 FB2Collector *const m_collector;
53 FB2ParserContext *const m_parentContext;
54 };
55
61 class FB2NodeContextBase : public FB2ParserContext
62 {
63 public:
64 explicit FB2NodeContextBase(FB2ParserContext *parentContext, FB2Collector *collector = 0);
65
66 private:
67 virtual void startOfElement();
68 virtual void endOfAttributes();
69 virtual void text(const char *value);
70 };
71
81 class FB2DataContextBase : public FB2ParserContext
82 {
83 public:
84 explicit FB2DataContextBase(FB2ParserContext *parentContext);
85
86 private:
87 virtual FB2XMLParserContext *element(const FB2TokenData &name, const FB2TokenData &ns);
88 virtual void startOfElement();
89 virtual void endOfAttributes();
90 virtual void text(const char *value);
91 };
92
98 class FB2TextContextBase : public FB2ParserContext
99 {
100 public:
101 explicit FB2TextContextBase(FB2ParserContext *parentContext);
102
103 private:
104 virtual FB2XMLParserContext *element(const FB2TokenData &name, const FB2TokenData &ns);
105 virtual void startOfElement();
106 virtual void endOfElement();
107 virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value);
108 virtual void endOfAttributes();
109 };
110
113 class FB2SkipElementContext : public FB2ParserContext
114 {
115 public:
116 explicit FB2SkipElementContext(FB2ParserContext *parentContext);
117
118 private:
119 virtual FB2XMLParserContext *leaveContext() const;
120
121 virtual FB2XMLParserContext *element(const FB2TokenData &name, const FB2TokenData &ns);
122 virtual void startOfElement();
123 virtual void endOfElement();
124 virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value);
125 virtual void endOfAttributes();
126 virtual void text(const char *value);
127
128 private:
129 unsigned m_level;
130 };
131
132 class FB2StyleContextBase : public FB2ParserContext
133 {
134 public:
135 FB2StyleContextBase(FB2ParserContext *parentContext, const FB2Style &style);
136
137 protected:
138 FB2Style &getStyle();
139 FB2TextFormat &getTextFormat();
140
141 virtual FB2XMLParserContext *element(const FB2TokenData &name, const FB2TokenData &ns);
142 virtual void endOfElement();
143 virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value);
144 virtual void endOfAttributes();
145 virtual void text(const char *value);
146
147 private:
148 FB2Style m_style;
149 };
150
151 class FB2BlockFormatContextBase : public FB2NodeContextBase
152 {
153 public:
154 FB2BlockFormatContextBase(FB2ParserContext *parentContext, const FB2BlockFormat &format);
155
156 FB2BlockFormat &getBlockFormat();
157 const FB2BlockFormat &getBlockFormat() const;
158
159 void setLang(const char *lang);
160
161 private:
162 FB2BlockFormat m_format;
163 };
164
165 }
166
167 #endif // FB2PARSERCONTEXT_H_INCLUDED
168
169 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libebook::EBOOKHTMLToken::value
Definition: EBOOKHTMLToken.h:263
libebook::FB2TextContextBase::attribute
virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value)
Process an attribute.
Definition: FB2ParserContext.cpp:98
style
optional< Style > style
Definition: TDParser.cpp:106
libebook::FB2StyleContextBase::endOfAttributes
virtual void endOfAttributes()
Signalize the end of attributes.
Definition: FB2ParserContext.cpp:201
libebook::FB2NodeContextBase
Base class for non-leaf element contexts.
Definition: FB2ParserContext.h:61
libebook::FB2ParserContext::operator=
FB2ParserContext & operator=(const FB2ParserContext &other)
libebook::FB2SkipElementContext::FB2SkipElementContext
FB2SkipElementContext(FB2ParserContext *parentContext)
Definition: FB2ParserContext.cpp:106
libebook::FB2DataContextBase
Base class for leaf data element contexts.
Definition: FB2ParserContext.h:81
libebook::FB2SkipElementContext::text
virtual void text(const char *value)
Process textual content of an element.
Definition: FB2ParserContext.cpp:145
libebook::FB2Collector
Definition: FB2Collector.h:19
libebook::FB2ParserContext::m_parentContext
FB2ParserContext *const m_parentContext
Definition: FB2ParserContext.h:53
libebook::FB2NodeContextBase::startOfElement
virtual void startOfElement()
Signalize the start of an element.
Definition: FB2ParserContext.cpp:46
libebook::FB2BlockFormatContextBase::FB2BlockFormatContextBase
FB2BlockFormatContextBase(FB2ParserContext *parentContext, const FB2BlockFormat &format)
Definition: FB2ParserContext.cpp:218
libebook::FB2XMLParserContext
Definition: FB2XMLParserContext.h:18
libebook::FB2BlockFormatContextBase::getBlockFormat
FB2BlockFormat & getBlockFormat()
Definition: FB2ParserContext.cpp:224
libebook::FB2TokenData
Definition: FB2Token.h:135
libebook::FB2NodeContextBase::endOfAttributes
virtual void endOfAttributes()
Signalize the end of attributes.
Definition: FB2ParserContext.cpp:50
libebook::FB2DataContextBase::text
virtual void text(const char *value)
Process textual content of an element.
Definition: FB2ParserContext.cpp:76
libebook::FB2Style
Definition: FB2Style.h:55
libebook::FB2SkipElementContext::m_level
unsigned m_level
Definition: FB2ParserContext.h:129
libebook::FB2StyleContextBase::m_style
FB2Style m_style
Definition: FB2ParserContext.h:148
libebook::EBOOKHTMLToken::lang
Definition: EBOOKHTMLToken.h:207
libebook::FB2StyleContextBase::FB2StyleContextBase
FB2StyleContextBase(FB2ParserContext *parentContext, const FB2Style &style)
Definition: FB2ParserContext.cpp:149
libebook::FB2StyleContextBase::endOfElement
virtual void endOfElement()
Signalize the end of an element.
Definition: FB2ParserContext.cpp:197
libebook::FB2SkipElementContext::startOfElement
virtual void startOfElement()
Signalize the start of an element.
Definition: FB2ParserContext.cpp:128
libebook::FB2TextContextBase::endOfElement
virtual void endOfElement()
Signalize the end of an element.
Definition: FB2ParserContext.cpp:94
FB2Style.h
libebook::FB2ParserContext::FB2ParserContext
FB2ParserContext(const FB2ParserContext &other)
libebook::FB2StyleContextBase::getStyle
FB2Style & getStyle()
Definition: FB2ParserContext.cpp:155
libebook::FB2ParserContext::getCollector
FB2Collector * getCollector() const
Get the collector.
Definition: FB2ParserContext.cpp:31
libebook::FB2DataContextBase::FB2DataContextBase
FB2DataContextBase(FB2ParserContext *parentContext)
Definition: FB2ParserContext.cpp:58
libebook::FB2TextFormat
Definition: FB2Style.h:21
libebook::FB2ParserContext::leaveContext
virtual FB2XMLParserContext * leaveContext() const
Destroy this context and return parent.
Definition: FB2ParserContext.cpp:24
libebook::FB2StyleContextBase::getTextFormat
FB2TextFormat & getTextFormat()
Definition: FB2ParserContext.cpp:160
libebook::FB2TextContextBase::FB2TextContextBase
FB2TextContextBase(FB2ParserContext *parentContext)
Definition: FB2ParserContext.cpp:80
libebook::FB2ParserContext::getParentContext
FB2ParserContext * getParentContext() const
Get the parent context.
Definition: FB2ParserContext.cpp:36
libebook::FB2DataContextBase::startOfElement
virtual void startOfElement()
Signalize the start of an element.
Definition: FB2ParserContext.cpp:68
libebook::FB2BlockFormatContextBase
Definition: FB2ParserContext.h:151
libebook::FB2NodeContextBase::text
virtual void text(const char *value)
Process textual content of an element.
Definition: FB2ParserContext.cpp:54
name
string name
Definition: CHMStream.cpp:80
libebook::FB2DataContextBase::element
virtual FB2XMLParserContext * element(const FB2TokenData &name, const FB2TokenData &ns)
Create a context for parsing a child element.
Definition: FB2ParserContext.cpp:63
libebook::FB2DataContextBase::endOfAttributes
virtual void endOfAttributes()
Signalize the end of attributes.
Definition: FB2ParserContext.cpp:72
libebook::FB2SkipElementContext
Context for skipping element hierarchies.
Definition: FB2ParserContext.h:113
libebook::FB2ParserContext::m_collector
FB2Collector *const m_collector
Definition: FB2ParserContext.h:52
libebook::FB2SkipElementContext::endOfAttributes
virtual void endOfAttributes()
Signalize the end of attributes.
Definition: FB2ParserContext.cpp:141
libebook::EBOOKOPFToken::format
Definition: EBOOKOPFToken.h:56
libebook::FB2TextContextBase::endOfAttributes
virtual void endOfAttributes()
Signalize the end of attributes.
Definition: FB2ParserContext.cpp:102
libebook::FB2SkipElementContext::leaveContext
virtual FB2XMLParserContext * leaveContext() const
Destroy this context and return parent.
Definition: FB2ParserContext.cpp:112
libebook::FB2StyleContextBase::element
virtual FB2XMLParserContext * element(const FB2TokenData &name, const FB2TokenData &ns)
Create a context for parsing a child element.
Definition: FB2ParserContext.cpp:165
libebook::FB2StyleContextBase::text
virtual void text(const char *value)
Process textual content of an element.
Definition: FB2ParserContext.cpp:211
libebook::FB2NodeContextBase::FB2NodeContextBase
FB2NodeContextBase(FB2ParserContext *parentContext, FB2Collector *collector=0)
Definition: FB2ParserContext.cpp:41
libebook::FB2BlockFormatContextBase::m_format
FB2BlockFormat m_format
Definition: FB2ParserContext.h:162
libebook
Definition: CHMParser.cpp:20
libebook::FB2SkipElementContext::element
virtual FB2XMLParserContext * element(const FB2TokenData &name, const FB2TokenData &ns)
Create a context for parsing a child element.
Definition: FB2ParserContext.cpp:122
libebook::FB2TextContextBase
Base class for leaf textual element contexts.
Definition: FB2ParserContext.h:98
libebook::FB2BlockFormatContextBase::setLang
void setLang(const char *lang)
Definition: FB2ParserContext.cpp:234
libebook::FB2TextContextBase::element
virtual FB2XMLParserContext * element(const FB2TokenData &name, const FB2TokenData &ns)
Create a context for parsing a child element.
Definition: FB2ParserContext.cpp:85
libebook::FB2TextContextBase::startOfElement
virtual void startOfElement()
Signalize the start of an element.
Definition: FB2ParserContext.cpp:90
libebook::FB2StyleContextBase
Definition: FB2ParserContext.h:132
libebook::FB2SkipElementContext::endOfElement
virtual void endOfElement()
Signalize the end of an element.
Definition: FB2ParserContext.cpp:132
libebook::FB2BlockFormat
Definition: FB2Style.h:35
FB2XMLParserContext.h
libebook::FB2ParserContext
Base class for all contexts.
Definition: FB2ParserContext.h:23
libebook::FB2StyleContextBase::attribute
virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value)
Process an attribute.
Definition: FB2ParserContext.cpp:205
libebook::FB2SkipElementContext::attribute
virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value)
Process an attribute.
Definition: FB2ParserContext.cpp:137