Atlas 0.7.0
Networking protocol for the Worldforge system.
PresentationBridge.h
1/*
2 Copyright (C) 2013 Erik Ogenvik
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef PRESENTATIONBRIDGE_H_
20#define PRESENTATIONBRIDGE_H_
21
22#include <sstream>
23#include <string>
24#include <stack>
25#include <deque>
26#include "Bridge.h"
27
28namespace Atlas
29{
30
36{
37public:
38 explicit PresentationBridge(std::ostream& stream);
39 ~PresentationBridge() override = default;
40
41 void streamBegin() override;
42 void streamMessage() override;
43 void streamEnd() override;
44
45 void mapMapItem(std::string name) override;
46 void mapListItem(std::string name) override;
47 void mapIntItem(std::string name, std::int64_t) override;
48 void mapFloatItem(std::string name, double) override;
49 void mapStringItem(std::string name, std::string) override;
50 void mapNoneItem(std::string name) override;
51 void mapEnd() override;
52
53 void listMapItem() override;
54 void listListItem() override;
55 void listIntItem(std::int64_t) override;
56 void listFloatItem(double) override;
57 void listStringItem(std::string) override;
58 void listNoneItem() override;
59 void listEnd() override;
60
68 void setMaxItemsPerLevel(size_t maxItems);
69
75 void setStartFilteringLevel(size_t startFilteringLevel);
76
77private:
78
79 void addPadding();
80
81 void removePadding();
82
87 bool checkAndUpdateMaxItemCounter();
88
89 std::string mPadding;
90
91 std::ostream& mStream;
92
98 std::stack<int> mMapsInList;
99
103 size_t mMaxItemsPerLevel;
104
108 bool mIsSkipEntry;
109
114 size_t mStartFilterLevel;
115
119 std::deque<size_t> mEntriesPerLevelCounter;
120};
121
122}
123#endif /* PRESENTATIONBRIDGE_H_ */
A bridge which is meant to be used solely for presenting Element data.
void mapNoneItem(std::string name) override
void listStringItem(std::string) override
void mapMapItem(std::string name) override
void mapStringItem(std::string name, std::string) override
void mapIntItem(std::string name, std::int64_t) override
void mapFloatItem(std::string name, double) override
void listFloatItem(double) override
void mapListItem(std::string name) override
void setStartFilteringLevel(size_t startFilteringLevel)
void listIntItem(std::int64_t) override
void setMaxItemsPerLevel(size_t maxItems)
Definition: Bridge.h:20