libosmscout 1.1.1
Loading...
Searching...
No Matches
FromToFeature.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_FEATURE_FROM_TO_FEATURE_H
2#define OSMSCOUT_FEATURE_FROM_TO_FEATURE_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2014 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23#include <osmscout/TypeConfig.h>
25
27
28namespace osmscout {
29
31 {
32 private:
33 std::string from;
34 std::string to;
35
36 public:
37 FromToFeatureValue() = default;
38 FromToFeatureValue(const FromToFeatureValue& featureValue) = default;
39
40 explicit FromToFeatureValue(const std::string_view& from,
41 const std::string_view& to)
42 : from(from),
43 to(to)
44 {
45 // no code
46 }
47
48 const std::string& GetFrom() const
49 {
50 return from;
51 }
52
53 void SetFrom(const std::string_view& from)
54 {
55 FromToFeatureValue::from=from;
56 }
57
58 const std::string& GetTo() const
59 {
60 return to;
61 }
62
63 void SetTo(const std::string_view& to)
64 {
65 FromToFeatureValue::to=to;
66 }
67
68 std::string GetLabel(const Locale &/*locale*/, size_t /*labelIndex*/) const override
69 {
70 if (!from.empty() && ! to.empty()) {
71 return from + " => " + to;
72 }
73
74 if (!from.empty()) {
75 return from + "=>";
76 }
77
78 if (!to.empty()) {
79 return "=> " + to;
80 }
81
82 return "";
83 }
84
85 void Read(FileScanner& scanner) override;
86 void Write(FileWriter& writer) override;
87
88 FromToFeatureValue& operator=(const FeatureValue& other) override;
89 bool operator==(const FeatureValue& other) const override;
90 };
91
93 {
94 private:
95 TagId tagFrom;
96 TagId tagTo;
97
98 public:
100 static const char* const NAME;
101
103 static const char* const NUMBER_LABEL;
104
106 static const size_t NUMBER_LABEL_INDEX;
107
108 public:
110 void Initialize(TagRegistry& tagRegistry) override;
111
112 std::string GetName() const override;
113
114 size_t GetValueAlignment() const override;
115 size_t GetValueSize() const override;
116 FeatureValue* AllocateValue(void* buffer) override;
117
118 void Parse(TagErrorReporter& reporter,
119 const TagRegistry& tagRegistry,
120 const FeatureInstance& feature,
121 const ObjectOSMRef& object,
122 const TagMap& tags,
123 FeatureValueBuffer& buffer) const override;
124 };
125
127}
128
129#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
Definition TypeFeature.h:41
Definition FeatureReader.h:143
static const char *const NAME
Definition FromToFeature.h:100
static const char *const NUMBER_LABEL
Definition FromToFeature.h:103
size_t GetValueAlignment() const override
void Initialize(TagRegistry &tagRegistry) override
void Parse(TagErrorReporter &reporter, const TagRegistry &tagRegistry, const FeatureInstance &feature, const ObjectOSMRef &object, const TagMap &tags, FeatureValueBuffer &buffer) const override
static const size_t NUMBER_LABEL_INDEX
Definition FromToFeature.h:106
FeatureValue * AllocateValue(void *buffer) override
size_t GetValueSize() const override
std::string GetName() const override
bool operator==(const FeatureValue &other) const override
FromToFeatureValue(const std::string_view &from, const std::string_view &to)
Definition FromToFeature.h:40
FromToFeatureValue & operator=(const FeatureValue &other) override
FromToFeatureValue(const FromToFeatureValue &featureValue)=default
const std::string & GetTo() const
Definition FromToFeature.h:58
void SetFrom(const std::string_view &from)
Definition FromToFeature.h:53
const std::string & GetFrom() const
Definition FromToFeature.h:48
std::string GetLabel(const Locale &, size_t) const override
Definition FromToFeature.h:68
void Write(FileWriter &writer) override
void SetTo(const std::string_view &to)
Definition FromToFeature.h:63
void Read(FileScanner &scanner) override
Definition TagErrorReporter.h:33
Definition Area.h:39
std::unordered_map< TagId, std::string > TagMap
Definition Tag.h:41
FeatureValueReader< FromToFeature, FromToFeatureValue > FromToFeatureValueReader
Definition FromToFeature.h:126
uint16_t TagId
Definition Tag.h:39