FictionBook2TableContext.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 FICTIONBOOK2TABLECONTEXT_H_INCLUDED
11#define FICTIONBOOK2TABLECONTEXT_H_INCLUDED
12
13#include <memory>
14
15#include "FictionBook2ParserContext.h"
16
17 namespace libebook
18{
19
20 class FictionBook2TableModel;
21
22 class FictionBook2TableContext : public FictionBook2BlockFormatContextBase
23{
24 // disable copying
25 FictionBook2TableContext(const FictionBook2TableContext &other);
26 FictionBook2TableContext &operator=(const FictionBook2TableContext &other);
27
28 public:
29 FictionBook2TableContext(FictionBook2ParserContext *parentContext, const FictionBook2BlockFormat &format);
30 ~FictionBook2TableContext() override;
31
32 private:
33 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
34 void startOfElement() override;
35 void endOfElement() override;
36 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
37
38 private:
39 std::shared_ptr<FictionBook2TableModel> m_model;
40};
41
42 class FictionBook2CellContext : public FictionBook2StyleContextBase
43{
44 // disable copying
45 FictionBook2CellContext(const FictionBook2CellContext &other);
46 FictionBook2CellContext &operator=(const FictionBook2CellContext &other);
47
48 public:
49 FictionBook2CellContext(FictionBook2ParserContext *parentContext, const std::shared_ptr<FictionBook2TableModel> &model, const FictionBook2BlockFormat &format, bool header);
50
51 private:
52 void startOfElement() override;
53 void endOfElement() override;
54 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
55 void endOfAttributes() override;
56
57 void openCell();
58
59 private:
60 const std::shared_ptr<FictionBook2TableModel> m_model;
61 const bool m_header;
62 bool m_opened;
63 int m_columnSpan;
64 int m_rowSpan;
65 size_t m_coveredColumns;
66};
67
68 class FictionBook2TrContext : public FictionBook2BlockFormatContextBase
69{
70 // no copying
71 FictionBook2TrContext(const FictionBook2TrContext &);
72 FictionBook2TrContext &operator=(const FictionBook2TrContext &);
73
74 public:
75 FictionBook2TrContext(FictionBook2ParserContext *parentContext, const std::shared_ptr<FictionBook2TableModel> &model, const FictionBook2BlockFormat &format);
76
77 private:
78 FictionBook2XMLParserContext *element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override;
79 void endOfElement() override;
80 void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override;
81
82 void openRow(bool header);
83
84 private:
85 const std::shared_ptr<FictionBook2TableModel> m_model;
86 bool m_opened;
87};
88
89}
90
91#endif // FICTIONBOOK2TABLECONTEXT_H_INCLUDED
92
93/* 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::FictionBook2CellContext
Definition FictionBook2TableContext.h:43
libebook::FictionBook2CellContext::m_opened
bool m_opened
Definition FictionBook2TableContext.h:62
libebook::FictionBook2CellContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2TableContext.cpp:195
libebook::FictionBook2CellContext::FictionBook2CellContext
FictionBook2CellContext(const FictionBook2CellContext &other)
libebook::FictionBook2CellContext::operator=
FictionBook2CellContext & operator=(const FictionBook2CellContext &other)
libebook::FictionBook2CellContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2TableContext.cpp:206
libebook::FictionBook2CellContext::m_columnSpan
int m_columnSpan
Definition FictionBook2TableContext.h:63
libebook::FictionBook2CellContext::m_coveredColumns
size_t m_coveredColumns
Definition FictionBook2TableContext.h:65
libebook::FictionBook2CellContext::m_header
const bool m_header
Definition FictionBook2TableContext.h:61
libebook::FictionBook2CellContext::m_model
const std::shared_ptr< FictionBook2TableModel > m_model
Definition FictionBook2TableContext.h:60
libebook::FictionBook2CellContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition FictionBook2TableContext.cpp:191
libebook::FictionBook2CellContext::openCell
void openCell()
Definition FictionBook2TableContext.cpp:238
libebook::FictionBook2CellContext::endOfAttributes
void endOfAttributes() override
Signalize the end of attributes.
Definition FictionBook2TableContext.cpp:233
libebook::FictionBook2CellContext::m_rowSpan
int m_rowSpan
Definition FictionBook2TableContext.h:64
libebook::FictionBook2ParserContext
Base class for all contexts.
Definition FictionBook2ParserContext.h:24
libebook::FictionBook2StyleContextBase
Definition FictionBook2ParserContext.h:133
libebook::FictionBook2TableContext
Definition FictionBook2TableContext.h:23
libebook::FictionBook2TableContext::m_model
std::shared_ptr< FictionBook2TableModel > m_model
Definition FictionBook2TableContext.h:39
libebook::FictionBook2TableContext::startOfElement
void startOfElement() override
Signalize the start of an element.
Definition FictionBook2TableContext.cpp:152
libebook::FictionBook2TableContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2TableContext.cpp:162
libebook::FictionBook2TableContext::~FictionBook2TableContext
~FictionBook2TableContext() override
Definition FictionBook2TableContext.cpp:132
libebook::FictionBook2TableContext::FictionBook2TableContext
FictionBook2TableContext(const FictionBook2TableContext &other)
libebook::FictionBook2TableContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2TableContext.cpp:157
libebook::FictionBook2TableContext::operator=
FictionBook2TableContext & operator=(const FictionBook2TableContext &other)
libebook::FictionBook2TableContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2TableContext.cpp:136
libebook::FictionBook2TrContext
Definition FictionBook2TableContext.h:69
libebook::FictionBook2TrContext::m_opened
bool m_opened
Definition FictionBook2TableContext.h:86
libebook::FictionBook2TrContext::element
FictionBook2XMLParserContext * element(const FictionBook2TokenData &name, const FictionBook2TokenData &ns) override
Create a context for parsing a child element.
Definition FictionBook2TableContext.cpp:253
libebook::FictionBook2TrContext::m_model
const std::shared_ptr< FictionBook2TableModel > m_model
Definition FictionBook2TableContext.h:85
libebook::FictionBook2TrContext::FictionBook2TrContext
FictionBook2TrContext(const FictionBook2TrContext &)
libebook::FictionBook2TrContext::endOfElement
void endOfElement() override
Signalize the end of an element.
Definition FictionBook2TableContext.cpp:275
libebook::FictionBook2TrContext::attribute
void attribute(const FictionBook2TokenData &name, const FictionBook2TokenData *ns, const char *value) override
Process an attribute.
Definition FictionBook2TableContext.cpp:283
libebook::FictionBook2TrContext::operator=
FictionBook2TrContext & operator=(const FictionBook2TrContext &)
libebook::FictionBook2TrContext::openRow
void openRow(bool header)
Definition FictionBook2TableContext.cpp:291
libebook::FictionBook2XMLParserContext
Definition FictionBook2XMLParserContext.h:19
libebook
Definition BBeBCollector.cpp:19
libebook::FictionBook2BlockFormat
Definition FictionBook2Style.h:36
libebook::FictionBook2TokenData
Definition FictionBook2Token.h:134