metkitlib 1.16.0.9__cp312-cp312-manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. metkitlib/__init__.py +3 -0
  2. metkitlib/bin/bufr-sanity-check +0 -0
  3. metkitlib/bin/compare-mars-requests.py +265 -0
  4. metkitlib/bin/mars-archive-script +0 -0
  5. metkitlib/bin/parse-mars-request +0 -0
  6. metkitlib/include/metkit/api/metkit_c.h +255 -0
  7. metkitlib/include/metkit/codes/BUFRDecoder.h +47 -0
  8. metkitlib/include/metkit/codes/BufrContent.h +43 -0
  9. metkitlib/include/metkit/codes/CodesContent.h +67 -0
  10. metkitlib/include/metkit/codes/CodesHandleDeleter.h +41 -0
  11. metkitlib/include/metkit/codes/CodesSplitter.h +40 -0
  12. metkitlib/include/metkit/codes/GRIBDecoder.h +42 -0
  13. metkitlib/include/metkit/codes/GribAccessor.h +75 -0
  14. metkitlib/include/metkit/codes/GribHandle.h +121 -0
  15. metkitlib/include/metkit/codes/GribIterator.h +48 -0
  16. metkitlib/include/metkit/codes/LibEccodes.h +38 -0
  17. metkitlib/include/metkit/codes/MallocCodesContent.h +46 -0
  18. metkitlib/include/metkit/codes/api/CodesAPI.h +365 -0
  19. metkitlib/include/metkit/codes/api/CodesTypes.h +93 -0
  20. metkitlib/include/metkit/codes/api/GeoIterator.h +104 -0
  21. metkitlib/include/metkit/codes/api/KeyIterator.h +187 -0
  22. metkitlib/include/metkit/config/LibMetkit.h +56 -0
  23. metkitlib/include/metkit/fields/FieldIndex.h +58 -0
  24. metkitlib/include/metkit/fields/FieldIndexList.h +40 -0
  25. metkitlib/include/metkit/fields/SimpleFieldIndex.h +41 -0
  26. metkitlib/include/metkit/hypercube/HyperCube.h +105 -0
  27. metkitlib/include/metkit/hypercube/HyperCubePayloaded.h +88 -0
  28. metkitlib/include/metkit/mars/BaseProtocol.h +95 -0
  29. metkitlib/include/metkit/mars/ClientTask.h +206 -0
  30. metkitlib/include/metkit/mars/DHSProtocol.h +106 -0
  31. metkitlib/include/metkit/mars/MarsExpandContext.h +42 -0
  32. metkitlib/include/metkit/mars/MarsExpansion.h +83 -0
  33. metkitlib/include/metkit/mars/MarsExpension.h +28 -0
  34. metkitlib/include/metkit/mars/MarsHandle.h +83 -0
  35. metkitlib/include/metkit/mars/MarsLanguage.h +106 -0
  36. metkitlib/include/metkit/mars/MarsLocation.h +100 -0
  37. metkitlib/include/metkit/mars/MarsParsedRequest.h +44 -0
  38. metkitlib/include/metkit/mars/MarsParser.h +70 -0
  39. metkitlib/include/metkit/mars/MarsRequest.h +198 -0
  40. metkitlib/include/metkit/mars/MarsRequestHandle.h +79 -0
  41. metkitlib/include/metkit/mars/Matcher.h +88 -0
  42. metkitlib/include/metkit/mars/Param.b +43 -0
  43. metkitlib/include/metkit/mars/Param.h +84 -0
  44. metkitlib/include/metkit/mars/ParamID.h +306 -0
  45. metkitlib/include/metkit/mars/Parameter.h +87 -0
  46. metkitlib/include/metkit/mars/Quantile.h +73 -0
  47. metkitlib/include/metkit/mars/RequestEnvironment.h +58 -0
  48. metkitlib/include/metkit/mars/StepRange.b +43 -0
  49. metkitlib/include/metkit/mars/StepRange.h +164 -0
  50. metkitlib/include/metkit/mars/StepRangeNormalise.h +95 -0
  51. metkitlib/include/metkit/mars/Type.h +265 -0
  52. metkitlib/include/metkit/mars/TypeAny.h +39 -0
  53. metkitlib/include/metkit/mars/TypeDate.h +42 -0
  54. metkitlib/include/metkit/mars/TypeEnum.h +67 -0
  55. metkitlib/include/metkit/mars/TypeExpver.h +40 -0
  56. metkitlib/include/metkit/mars/TypeFloat.h +41 -0
  57. metkitlib/include/metkit/mars/TypeInteger.h +55 -0
  58. metkitlib/include/metkit/mars/TypeLowercase.h +38 -0
  59. metkitlib/include/metkit/mars/TypeMixed.h +47 -0
  60. metkitlib/include/metkit/mars/TypeParam.h +45 -0
  61. metkitlib/include/metkit/mars/TypeRange.h +41 -0
  62. metkitlib/include/metkit/mars/TypeRegex.h +49 -0
  63. metkitlib/include/metkit/mars/TypeTime.h +44 -0
  64. metkitlib/include/metkit/mars/TypeToByList.h +137 -0
  65. metkitlib/include/metkit/mars/TypeToByListQuantile.h +41 -0
  66. metkitlib/include/metkit/mars/TypesFactory.h +92 -0
  67. metkitlib/include/metkit/metkit_config.h +26 -0
  68. metkitlib/include/metkit/metkit_ecbuild_config.h +72 -0
  69. metkitlib/include/metkit/metkit_version.h +30 -0
  70. metkitlib/include/metkit/pointdb/DataSource.h +91 -0
  71. metkitlib/include/metkit/pointdb/FieldIndexer.h +128 -0
  72. metkitlib/include/metkit/pointdb/GribDataSource.h +47 -0
  73. metkitlib/include/metkit/pointdb/GribFieldInfo.h +76 -0
  74. metkitlib/include/metkit/pointdb/GribHandleDataSource.h +58 -0
  75. metkitlib/include/metkit/pointdb/PointIndex.h +121 -0
  76. metkitlib/include/metkit/pointdb/bits.h +1834 -0
  77. metkitlib/include/metkit/pointdb/masks.h +22 -0
  78. metkitlib/include/metkit/tool/MetkitTool.h +79 -0
  79. metkitlib/lib64/cmake/metkit/metkit-config-version.cmake +43 -0
  80. metkitlib/lib64/cmake/metkit/metkit-config.cmake +112 -0
  81. metkitlib/lib64/cmake/metkit/metkit-import.cmake +14 -0
  82. metkitlib/lib64/cmake/metkit/metkit-targets-relwithdebinfo.cmake +46 -0
  83. metkitlib/lib64/cmake/metkit/metkit-targets.cmake +116 -0
  84. metkitlib/lib64/libmetkit.so +0 -0
  85. metkitlib/lib64/pkgconfig/metkit.pc +33 -0
  86. metkitlib/share/metkit/axis.yaml +63 -0
  87. metkitlib/share/metkit/bufr-subtypes.yaml +140 -0
  88. metkitlib/share/metkit/chemids.yaml +209 -0
  89. metkitlib/share/metkit/language.yaml +1707 -0
  90. metkitlib/share/metkit/modifiers.yaml +341 -0
  91. metkitlib/share/metkit/obstype.yaml +182 -0
  92. metkitlib/share/metkit/odb/marsrequest.yaml +9 -0
  93. metkitlib/share/metkit/param-matching.yaml +16 -0
  94. metkitlib/share/metkit/paramids.yaml +24034 -0
  95. metkitlib/share/metkit/params-static.yaml +212 -0
  96. metkitlib/share/metkit/params.yaml +9833 -0
  97. metkitlib/share/metkit/reportype.yaml +525 -0
  98. metkitlib/share/metkit/shortname-context.yaml +192 -0
  99. metkitlib-1.16.0.9.dist-info/METADATA +75 -0
  100. metkitlib-1.16.0.9.dist-info/RECORD +104 -0
  101. metkitlib-1.16.0.9.dist-info/WHEEL +5 -0
  102. metkitlib-1.16.0.9.dist-info/licenses/AUTHORS +12 -0
  103. metkitlib-1.16.0.9.dist-info/licenses/LICENSE +190 -0
  104. metkitlib-1.16.0.9.dist-info/top_level.txt +1 -0
@@ -0,0 +1,164 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ // File StepRange.h
12
+ // Baudouin Raoult - ECMWF Dec 97
13
+
14
+ #ifndef metkit_StepRange_H
15
+ #define metkit_StepRange_H
16
+
17
+ #include <cmath>
18
+
19
+ #include "eckit/persist/Bless.h"
20
+ #include "eckit/types/Time.h"
21
+ #include "eckit/types/Types.h"
22
+
23
+ namespace eckit {
24
+ class DumpLoad;
25
+ }
26
+
27
+ namespace metkit::mars {
28
+
29
+ //----------------------------------------------------------------------------------------------------------------------
30
+
31
+ class StepRange {
32
+ public:
33
+
34
+ // -- Exceptions
35
+ // None
36
+
37
+ // -- Contructors
38
+
39
+ StepRange(const std::string&);
40
+
41
+ explicit StepRange(eckit::Time from = eckit::Time(0), eckit::Time to = eckit::Time(0)) :
42
+ from_(from / 3600.), to_(to / 3600.) {
43
+
44
+ if (from != eckit::Time(0) && to == eckit::Time(0)) {
45
+ to_ = from_;
46
+ }
47
+ }
48
+
49
+ explicit StepRange(double from, double to = 0) :
50
+ StepRange(eckit::Time(std::lround(from * 3600.), true), eckit::Time(std::lround(to * 3600.), true)) {}
51
+
52
+
53
+ #include "metkit/mars/StepRange.b"
54
+
55
+ // -- Destructor
56
+
57
+ ~StepRange() {}
58
+
59
+ // -- Convertors
60
+ // None
61
+
62
+ // -- Operators
63
+ // None
64
+
65
+ operator std::string() const;
66
+ std::string toString(bool useDays = false, bool alwaysUseHours = false) const;
67
+
68
+ StepRange& operator+=(const eckit::Time& step) {
69
+ from_ += step / 3600.;
70
+ to_ += step / 3600.;
71
+ return *this;
72
+ }
73
+
74
+ StepRange& operator-=(const eckit::Time& step) {
75
+ from_ -= step / 3600.;
76
+ to_ -= step / 3600.;
77
+ return *this;
78
+ }
79
+
80
+ bool operator==(const StepRange& other) const { return from_ == other.from_ && to_ == other.to_; }
81
+
82
+ bool operator!=(const StepRange& other) const { return from_ != other.from_ || to_ != other.to_; }
83
+
84
+ bool operator<(const StepRange& other) const {
85
+ return (from_ != other.from_) ? (from_ < other.from_) : (to_ < other.to_);
86
+ }
87
+
88
+ bool operator<=(const StepRange& other) const {
89
+ return (from_ != other.from_) ? (from_ <= other.from_) : (to_ <= other.to_);
90
+ }
91
+
92
+ bool operator>(const StepRange& other) const { return other < *this; }
93
+
94
+ // -- Methods
95
+
96
+ double from() const { return from_; }
97
+ double to() const { return to_; }
98
+
99
+ void dump(eckit::DumpLoad&) const;
100
+ void load(eckit::DumpLoad&);
101
+
102
+ // -- Overridden methods
103
+ // None
104
+
105
+ // -- Class members
106
+ // None
107
+
108
+ // -- Class methods
109
+ // None
110
+
111
+ // Uncomment for persistent, remove otherwise
112
+
113
+ protected:
114
+
115
+ // -- Members
116
+ // None
117
+
118
+ // -- Methods
119
+
120
+ void print(std::ostream& s, bool useDays = false, bool alwaysUseHours = false) const;
121
+
122
+ // -- Overridden methods
123
+ // None
124
+
125
+ // -- Class members
126
+ // None
127
+
128
+ // -- Class methods
129
+ // None
130
+
131
+ private:
132
+
133
+ // No copy allowed
134
+
135
+ // -- Members
136
+
137
+ double from_;
138
+ double to_;
139
+
140
+ // -- Methods
141
+ // None
142
+
143
+ // -- Overridden methods
144
+ // None
145
+
146
+ // -- Class members
147
+ // None
148
+
149
+ // -- Class methods
150
+ // None
151
+
152
+ // -- Friends
153
+
154
+ friend std::ostream& operator<<(std::ostream& s, const StepRange& p) {
155
+ p.print(s);
156
+ return s;
157
+ }
158
+ };
159
+
160
+ //----------------------------------------------------------------------------------------------------------------------
161
+
162
+ } // namespace metkit::mars
163
+
164
+ #endif
@@ -0,0 +1,95 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @author Simon Smart
12
+ /// @date May 2019
13
+
14
+ #ifndef metkit_StepRangeNormalise_H
15
+ #define metkit_StepRangeNormalise_H
16
+
17
+ #include <algorithm>
18
+
19
+ #include "eckit/exception/Exceptions.h"
20
+ #include "metkit/mars/StepRange.h"
21
+
22
+ namespace metkit {
23
+ namespace mars {
24
+
25
+ //----------------------------------------------------------------------------------------------------------------------
26
+
27
+ // It would be nice to put this in StepRange (as is done with ParamID), but this seems
28
+ // to break the generation of the StepRange.b file.
29
+ //
30
+ // -> Split it out
31
+
32
+ class StepRangeNormalise {
33
+ public:
34
+
35
+ template <typename AXIS_T>
36
+ static void normalise(std::vector<StepRange>& v, const AXIS_T& axis);
37
+ };
38
+
39
+ //----------------------------------------------------------------------------------------------------------------------
40
+
41
+ template <typename AXIS_T>
42
+ void StepRangeNormalise::normalise(std::vector<StepRange>& values, const AXIS_T& axis) {
43
+
44
+ std::vector<StepRange> outputValues;
45
+
46
+ for (eckit::Ordinal i = 0; i < values.size(); ++i) {
47
+
48
+ // If the supplied range is found in the axis, then use that
49
+
50
+ auto j = std::find(axis.begin(), axis.end(), values[i]);
51
+ if (j != axis.end()) {
52
+ outputValues.push_back(values[i]);
53
+
54
+ // If specified, and matched, a RANGE, then use that
55
+ if (values[i].from() != values[i].to()) {
56
+ eckit::Log::info() << "Matched range: " << values[i] << std::endl;
57
+ continue;
58
+ }
59
+ }
60
+
61
+ bool matched = false;
62
+ double singleValue = values[i].from();
63
+
64
+ if (values[i].from() != values[i].to()) {
65
+ j = std::find(axis.begin(), axis.end(), StepRange(singleValue, singleValue));
66
+ if (j != axis.end()) {
67
+ outputValues.push_back(*j);
68
+ matched = true;
69
+ }
70
+ }
71
+
72
+ // If singleValue == 0, this test is the same as the previous one...
73
+
74
+ if (singleValue != 0) {
75
+ j = std::find(axis.begin(), axis.end(), StepRange(0, singleValue));
76
+ if (j != axis.end()) {
77
+
78
+ if (matched) {
79
+ eckit::Log::userWarning()
80
+ << "Step " << values[i] << " matches " << values[i] << " and " << (*j) << std::endl;
81
+ }
82
+
83
+ outputValues.push_back(*j);
84
+ }
85
+ }
86
+ }
87
+
88
+ std::swap(values, outputValues);
89
+ }
90
+
91
+ //----------------------------------------------------------------------------------------------------------------------
92
+ } // namespace mars
93
+ } // namespace metkit
94
+
95
+ #endif
@@ -0,0 +1,265 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @file Type.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @author Emanuele Danovaro
15
+ /// @date April 2016
16
+
17
+ #pragma once
18
+
19
+ #include <functional>
20
+ #include <iosfwd>
21
+ #include <memory>
22
+ #include <optional>
23
+ #include <string>
24
+ #include <vector>
25
+
26
+ #include "eckit/memory/Counted.h"
27
+ #include "eckit/value/Value.h"
28
+
29
+ #include "metkit/mars/MarsRequest.h"
30
+
31
+ namespace metkit::mars {
32
+
33
+ class MarsExpandContext;
34
+
35
+ //----------------------------------------------------------------------------------------------------------------------
36
+
37
+ /// @brief abstract class - ContextRule subclasses are used to define a context. A MarsRequest matches a context, if it
38
+ /// matches all its ContextRules
39
+ class ContextRule {
40
+ public:
41
+
42
+ ContextRule(const std::string& k) : key_(k) {}
43
+
44
+ virtual ~ContextRule() = default;
45
+
46
+ const std::string& key() const { return key_; }
47
+
48
+ virtual bool matches(MarsRequest req) const = 0;
49
+
50
+ friend std::ostream& operator<<(std::ostream& s, const ContextRule& r) {
51
+ r.print(s);
52
+ return s;
53
+ }
54
+
55
+ protected:
56
+
57
+ std::string key_;
58
+
59
+ private: // methods
60
+
61
+ virtual void print(std::ostream& out) const = 0;
62
+ };
63
+
64
+ //----------------------------------------------------------------------------------------------------------------------
65
+
66
+ /// @brief A MarsRequest matches an Include ContextRule if at least one of the mars request values matches with the
67
+ /// values associated with the Include rule
68
+ class Include : public ContextRule {
69
+ public:
70
+
71
+ Include(const std::string& k, const std::set<std::string>& vv) : ContextRule(k), vals_(vv) {}
72
+
73
+ bool matches(MarsRequest req) const override {
74
+ if (key_ == "_verb") {
75
+ return (vals_.find(req.verb()) != vals_.end());
76
+ }
77
+ if (!req.has(key_)) {
78
+ return false;
79
+ }
80
+ for (const std::string& v : req.values(key_)) {
81
+ if (vals_.find(v) != vals_.end()) {
82
+ return true;
83
+ }
84
+ }
85
+ return false;
86
+ }
87
+
88
+ private: // methods
89
+
90
+ void print(std::ostream& out) const override { out << "Include[key=" << key_ << ",vals=[" << vals_ << "]]"; }
91
+
92
+ private:
93
+
94
+ std::set<std::string> vals_;
95
+ };
96
+
97
+ /// @brief A MarsRequest matches an Exclude ContextRule if none of the mars request values matches with the values
98
+ /// associated with the Exclude rule
99
+ class Exclude : public ContextRule {
100
+ public:
101
+
102
+ Exclude(const std::string& k, const std::set<std::string>& vv) : ContextRule(k), vals_(vv) {}
103
+ bool matches(MarsRequest req) const override {
104
+ if (!req.has(key_)) {
105
+ return false;
106
+ }
107
+ for (const std::string& v : req.values(key_)) {
108
+ if (vals_.find(v) != vals_.end()) {
109
+ return false;
110
+ }
111
+ }
112
+ return true;
113
+ }
114
+
115
+ private: // methods
116
+
117
+ void print(std::ostream& out) const override { out << "Exclude[key=" << key_ << ",vals=[" << vals_ << "]]"; }
118
+
119
+ private:
120
+
121
+ std::set<std::string> vals_;
122
+ };
123
+
124
+ /// @brief A MarsRequest matches an Undef ContextRule if the specified keyword is not defined in the mars request
125
+ class Undef : public ContextRule {
126
+ public:
127
+
128
+ Undef(const std::string& k) : ContextRule(k) {}
129
+ bool matches(MarsRequest req) const override { return !req.has(key_); }
130
+
131
+ private: // methods
132
+
133
+ void print(std::ostream& out) const override { out << "Undef[key=" << key_ << "]"; }
134
+ };
135
+
136
+ /// @brief A MarsRequest matches an Undef ContextRule if the specified keyword is defined in the mars request
137
+ class Def : public ContextRule {
138
+ public:
139
+
140
+ Def(const std::string& k) : ContextRule(k) {}
141
+ bool matches(MarsRequest req) const override { return req.has(key_); }
142
+
143
+ private: // methods
144
+
145
+ void print(std::ostream& out) const override { out << "Def[key=" << key_ << "]"; }
146
+ };
147
+
148
+
149
+ //----------------------------------------------------------------------------------------------------------------------
150
+
151
+ /// @brief a Context contains a list of ContextRule. A MarsRequest matches a context, if it matches all the ContextRules
152
+ /// associated
153
+ class Context {
154
+ public:
155
+
156
+ static std::unique_ptr<Context> parseContext(eckit::Value c);
157
+
158
+ /// @note takes ownership of the rule
159
+ void add(std::unique_ptr<ContextRule> rule);
160
+
161
+ size_t maxAxisIndex() const;
162
+
163
+ bool matches(MarsRequest req) const;
164
+
165
+ friend std::ostream& operator<<(std::ostream& s, const Context& x);
166
+
167
+ private: // methods
168
+
169
+ void print(std::ostream& out) const;
170
+
171
+ private:
172
+
173
+ std::vector<std::unique_ptr<ContextRule>> rules_;
174
+ };
175
+
176
+ //----------------------------------------------------------------------------------------------------------------------
177
+
178
+ class ITypeToByList {
179
+ public:
180
+
181
+ virtual ~ITypeToByList() = default;
182
+ virtual void expandRanges(std::vector<std::string>& values, const MarsRequest& request) const = 0;
183
+ };
184
+
185
+ //----------------------------------------------------------------------------------------------------------------------
186
+
187
+ class Type : public eckit::Counted {
188
+ public: // methods
189
+
190
+ Type(const std::string& name, const eckit::Value& settings);
191
+
192
+ ~Type() noexcept override = default;
193
+
194
+ virtual bool expand(std::string& value, const MarsRequest& request = {}) const;
195
+ [[deprecated]] bool expand(const MarsExpandContext& ctx, std::string& value, const MarsRequest& request = {}) const;
196
+ void expand(std::vector<std::string>& values, const MarsRequest& request = {}) const;
197
+
198
+ std::string tidy(const std::string& value, const MarsRequest& request = {}) const;
199
+
200
+ virtual void setDefaults(MarsRequest& request);
201
+ virtual void setInheritance(const std::vector<std::string>& inheritance);
202
+ virtual void check(const std::vector<std::string>& values) const;
203
+ virtual void clearDefaults();
204
+ virtual void reset();
205
+
206
+ virtual void pass2(MarsRequest& request);
207
+ virtual void finalise(MarsRequest& request, bool strict);
208
+
209
+ virtual const std::vector<std::string>& flattenValues(const MarsRequest& request);
210
+ virtual bool flatten() const;
211
+ virtual bool multiple() const;
212
+
213
+ virtual bool filter(const std::vector<std::string>& filter, std::vector<std::string>& values) const;
214
+ virtual bool filter(const std::string& keyword, const std::vector<std::string>& filter,
215
+ std::vector<std::string>& values) const;
216
+ virtual bool matches(const std::vector<std::string>& filter, const std::vector<std::string>& values) const;
217
+
218
+ const std::string& name() const;
219
+ const std::string& category() const;
220
+
221
+ friend std::ostream& operator<<(std::ostream& s, const Type& x);
222
+
223
+ virtual size_t count(const std::vector<std::string>& values) const;
224
+
225
+ protected: // methods
226
+
227
+ virtual bool hasGroups() const { return false; }
228
+ virtual std::optional<std::reference_wrapper<const std::vector<std::string>>> group(const std::string&) const {
229
+ NOTIMP;
230
+ }
231
+
232
+ friend class MarsLanguage;
233
+
234
+ void defaults(std::shared_ptr<Context> context, const std::vector<std::string>& values);
235
+ void set(std::shared_ptr<Context> context, const std::vector<std::string>& values);
236
+ void unset(std::shared_ptr<Context> context);
237
+
238
+ protected: // members
239
+
240
+ std::string name_;
241
+ std::string category_;
242
+
243
+ bool flatten_;
244
+ bool multiple_;
245
+ bool duplicates_;
246
+
247
+ std::map<std::shared_ptr<Context>, std::vector<std::string>> defaults_;
248
+ std::map<std::shared_ptr<Context>, std::vector<std::string>> sets_;
249
+ std::set<std::shared_ptr<Context>> unsets_;
250
+
251
+ std::optional<std::vector<std::string>> inheritance_;
252
+
253
+ std::unique_ptr<ITypeToByList> toByList_;
254
+
255
+ std::map<std::string, std::function<bool(const std::vector<std::string>&, std::vector<std::string>&)>> filters_;
256
+
257
+ private: // methods
258
+
259
+ virtual void print(std::ostream& out) const = 0;
260
+ void patchRequest(MarsRequest& request, const std::vector<std::string>& values);
261
+ };
262
+
263
+ //----------------------------------------------------------------------------------------------------------------------
264
+
265
+ } // namespace metkit::mars
@@ -0,0 +1,39 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @file TypeAny.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @date April 2016
15
+
16
+ #pragma once
17
+
18
+ #include "metkit/mars/Type.h"
19
+
20
+ namespace metkit::mars {
21
+
22
+ //----------------------------------------------------------------------------------------------------------------------
23
+
24
+ class TypeAny : public Type {
25
+
26
+ public: // methods
27
+
28
+ TypeAny(const std::string& name, const eckit::Value& settings = eckit::Value());
29
+
30
+ ~TypeAny() noexcept override = default;
31
+
32
+ private: // methods
33
+
34
+ void print(std::ostream& out) const override;
35
+ bool expand(std::string& value, const MarsRequest& request) const override;
36
+ };
37
+
38
+ //----------------------------------------------------------------------------------------------------------------------
39
+ } // namespace metkit::mars
@@ -0,0 +1,42 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @file TypeDate.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @author Emanuele Danovaro
15
+ /// @date April 2016
16
+
17
+ #pragma once
18
+
19
+ #include "metkit/mars/Type.h"
20
+
21
+ namespace metkit::mars {
22
+
23
+ //----------------------------------------------------------------------------------------------------------------------
24
+
25
+ class TypeDate : public Type {
26
+
27
+ public: // methods
28
+
29
+ TypeDate(const std::string& name, const eckit::Value& settings);
30
+
31
+ ~TypeDate() noexcept override = default;
32
+
33
+ private: // methods
34
+
35
+ void print(std::ostream& out) const override;
36
+ void pass2(MarsRequest& request) override;
37
+ bool expand(std::string& value, const MarsRequest& request) const override;
38
+ };
39
+
40
+ //----------------------------------------------------------------------------------------------------------------------
41
+
42
+ } // namespace metkit::mars
@@ -0,0 +1,67 @@
1
+ /*
2
+ * (C) Copyright 1996- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * In applying this licence, ECMWF does not waive the privileges and immunities
7
+ * granted to it by virtue of its status as an intergovernmental organisation nor
8
+ * does it submit to any jurisdiction.
9
+ */
10
+
11
+ /// @file TypeEnum.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @date April 2016
15
+
16
+ #pragma once
17
+
18
+ #include <mutex>
19
+
20
+ #include "metkit/mars/Type.h"
21
+
22
+ namespace metkit::mars {
23
+
24
+ //----------------------------------------------------------------------------------------------------------------------
25
+
26
+ class TypeEnum : public Type {
27
+
28
+ public: // methods
29
+
30
+ TypeEnum(const std::string& name, const eckit::Value& settings);
31
+
32
+ ~TypeEnum() noexcept override = default;
33
+
34
+ private: // methods
35
+
36
+ bool hasGroups() const override { return hasGroups_; }
37
+ std::optional<std::reference_wrapper<const std::vector<std::string>>> group(
38
+ const std::string& value) const override;
39
+
40
+ void print(std::ostream& out) const override;
41
+ void reset() override;
42
+
43
+ bool expand(std::string& value, const MarsRequest& request) const override;
44
+ std::map<std::string, uint16_t>::const_iterator find(const std::string& value) const;
45
+
46
+ std::vector<std::string> parseEnumValue(const eckit::Value& val, bool allowDuplicates = false) const;
47
+
48
+ void addValue(const std::string& value, uint16_t idx, bool allowDuplicates) const;
49
+ uint16_t parseValueNames(const eckit::Value& names, bool allowDuplicates) const;
50
+
51
+ void readValuesFile() const;
52
+
53
+ private: // members
54
+
55
+ std::string valuesFile_;
56
+
57
+ bool uppercase_ = false;
58
+ mutable bool hasGroups_ = false;
59
+ mutable std::vector<std::pair<std::string, std::vector<std::string>>> groups_;
60
+ mutable std::map<std::string, uint16_t> values_; // map of acceptable values (included aliases)
61
+
62
+ mutable std::once_flag readValues_;
63
+ };
64
+
65
+ //----------------------------------------------------------------------------------------------------------------------
66
+
67
+ } // namespace metkit::mars