Loading...
Searching...
No Matches
TreeSLD.h
1/*
2
3MIT License
4
5Copyright (c) 2023 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31/*
32 * TreeSLD.h
33 *
34 * Created on: Jun 24, 2012
35 * Author: mpeura
36 */
37
38#ifndef DRAIN_TREE_SLD
39#define DRAIN_TREE_SLD
40
41//#include "drain/util/EnumFlags.h"
42#include "drain/util/FileInfo.h"
43//#include "drain/util/Frame.h"
44#include "drain/util/TreeXML.h"
45#include "drain/util/UtilsXML.h"
46
47namespace drain {
48
49namespace image {
50
51class NodeSLD;
52
53typedef UnorderedMultiTree<NodeSLD,false, drain::NodeXML<>::path_t> TreeSLD;
54//typedef drain::UnorderedMultiTree<NodeSLD,false, NodeXML<>::path_t> TreeSLD;
55
56struct SLD {
57
58
59 enum tag_t {
60 UNDEFINED=XML::UNDEFINED,
61 COMMENT=XML::COMMENT,
62 CTEXT=XML::CTEXT,
63 SCRIPT=XML::SCRIPT, // Not supported?
64 Abstract = 10,
65 ColorMap,
66 ColorMapEntry,
67 CssParameter,
68 FeatureTypeStyle,
69 Fill,
70 Graphic,
71 Mark,
72 Name,
73 NamedLayer,
74 Opacity,
75 PointSymbolizer,
76 RasterSymbolizer,
77 Rule,
78 Size,
79 StyledLayerDescriptor,
80 Title,
81 UserStyle,
82 WellKnownName,
83 };
84 // check CTEXT, maybe implement in XML
85
86};
87
88} // image::
89
90
91
92
93//template <>
94//const Enum<image::SLD::tag_t>::dict_t Enum<image::SLD::tag_t>::dict;
95
96DRAIN_ENUM_DICT(image::SLD::tag_t);
97
98DRAIN_ENUM_OSTREAM(image::SLD::tag_t)
99
100
101
102namespace image {
103
105
115class NodeSLD: public NodeXML<SLD::tag_t> {
116public:
117
118
119 static
120 const drain::FileInfo fileInfo;
121
122
124 NodeSLD(SLD::tag_t t = SLD::UNDEFINED);
125
127 NodeSLD(const NodeSLD & node);
128
129 inline virtual
130 ~NodeSLD(){};
131
133 inline
134 NodeSLD & operator=(const NodeSLD & node){
135 XML::xmlAssignNode(*this, node);
136 return *this;
137 }
138
140 inline
141 NodeSLD & operator=(const std::initializer_list<Variable::init_pair_t > &l){
142 set(l);
143 return *this;
144 }
145
146 template <class T>
147 inline
148 NodeSLD & operator=(const T & arg){
149 set(arg);
150 return *this;
151 }
152
154 virtual
155 void setAttribute(const std::string & key, const std::string &value) override;
156
158 virtual
159 void setAttribute(const std::string & key, const char *value) override;
160
162 virtual
163 bool isSingular() const override final;
164
165
166protected:
167
168 virtual
169 void handleType() override final;
170
171};
172
173
174
175} // image::
176
177inline
178std::ostream & operator<<(std::ostream &ostr, const image::NodeSLD & node){
179 return node.nodeToStream(ostr);
180}
181
182inline
183std::ostream & operator<<(std::ostream &ostr, const image::TreeSLD & tree){
184 return image::NodeSLD::docToStream(ostr, tree);
185}
186
187
188} // drain::
189
190
191
192
193
194namespace drain {
195
196DRAIN_TYPENAME(image::NodeSLD);
197DRAIN_TYPENAME(image::SLD::tag_t);
198
199
200template <>
201const NodeXML<image::SLD::tag_t>::xml_default_elem_map_t NodeXML<image::SLD::tag_t>::xml_default_elems;
202
203
204template <>
205inline
206void image::TreeSLD::initChild(image::TreeSLD & child) const {
207 UtilsXML::initChildWithDefaultType(*this, child);
208}
209
210
211template <> // referring to Tree<NodeSLD>
212inline
213image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const Variable> > l){
214//image::TreeSLD & image::TreeSLD::operator=(std::initializer_list<std::pair<const char *,const char *> > l){
215 UtilsXML::assign(*this, l);
216 return *this;
217}
218
219
220template <>
221template <class T>
222inline
223image::TreeSLD & image::TreeSLD::operator=(const T & arg){
224 UtilsXML::assign(*this, arg);
225 return *this;
226}
227
228template <>
229template <>
230inline
231image::TreeSLD & image::TreeSLD::operator=(const std::string & arg){
232 UtilsXML::assignString(*this, arg);
233 return *this;
234}
235
236/*
237template <>
238template <>
239inline
240image::TreeSLD & image::TreeSLD::operator=(const char * arg){
241 UtilsXML::assignString(*this, arg);
242 return *this;
243}
244*/
245
246
247/*
248template <>
249template <>
250image::TreeSLD & image::TreeSLD::operator=(const char *arg){
251 return UtilsXML::assignString(*this, arg);
252}
253*/
254
255
256
257
258// Important! Useful and widely used – but fails with older C++ compilers ?
259template <>
260template <>
261inline
262image::TreeSLD & image::TreeSLD::operator()(const image::SLD::tag_t & type){
263 return UtilsXML::setType(*this, type);
264}
265
266/*
267template <>
268inline
269image::TreeSLD & image::TreeSLD::addChild(){ // const image::TreeSLD::key_t & key
270 return UtilsXML::addChild(*this);
271}
272*/
273
274/*
275template <> // for T (Tree class)
276template <> // for K (path elem arg)
277bool image::TreeSLD::hasChild(const image::svg::tag_t & type) const;
278*/
279
280template <> // for T (Tree class)
281template <> // for K (path elem arg)
282image::TreeSLD & image::TreeSLD::operator[](const image::SLD::tag_t & type);
283
284template <> // for T (Tree class)
285template <> // for K (path elem arg)
286const image::TreeSLD & image::TreeSLD::operator[](const image::SLD::tag_t & type) const ;
287
288} // drain::
289
290#endif // DRAIN_TREE_SLD
291
Definition FileInfo.h:48
Definition TreeXML.h:341
static std::ostream & docToStream(std::ostream &ostr, const V &tree)
Definition TreeXML.h:733
static N & xmlAssignNode(N &dst, const N &src)
Assign tree node (data) to another.
Definition XML.h:664
Definition TreeSLD.h:115
NodeSLD & operator=(const std::initializer_list< Variable::init_pair_t > &l)
Copy data from a node. (Does not copy subtree.)
Definition TreeSLD.h:141
virtual void setAttribute(const std::string &key, const std::string &value) override
Set attribute value, handling units in string arguments, like in "50%" or "640px".
Definition TreeSLD.cpp:146
virtual bool isSingular() const override final
Tell if this element should always have an explicit closing tag even when empty, like <STYLE></STYLE>
Definition TreeSLD.cpp:107
NodeSLD & operator=(const NodeSLD &node)
Copy data from a node. (Does not copy subtree.)
Definition TreeSLD.h:134
Definition DataSelector.cpp:1277
Definition TreeSLD.h:56