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,40 @@
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 TypeExpver.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 TypeExpver : public Type {
25
+ public: // methods
26
+
27
+ TypeExpver(const std::string& name, const eckit::Value& settings);
28
+
29
+ ~TypeExpver() noexcept override = default;
30
+
31
+ bool expand(std::string& value, const MarsRequest& request) const override;
32
+
33
+ private: // methods
34
+
35
+ void print(std::ostream& out) const override;
36
+ };
37
+
38
+ //----------------------------------------------------------------------------------------------------------------------
39
+
40
+ } // namespace metkit::mars
@@ -0,0 +1,41 @@
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 TypeFloat.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 TypeFloat : public Type {
26
+
27
+ public: // methods
28
+
29
+ TypeFloat(const std::string& name, const eckit::Value& settings);
30
+
31
+ ~TypeFloat() noexcept override = default;
32
+
33
+ private: // methods
34
+
35
+ void print(std::ostream& out) const override;
36
+ bool expand(std::string& value, const MarsRequest& request) const override;
37
+ };
38
+
39
+ //----------------------------------------------------------------------------------------------------------------------
40
+
41
+ } // namespace metkit::mars
@@ -0,0 +1,55 @@
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 TypeInteger.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @author Emanuele Danovaro
15
+ /// @date April 2016
16
+
17
+ #pragma once
18
+
19
+ #include <iosfwd>
20
+ #include <optional>
21
+
22
+ #include "metkit/mars/Type.h"
23
+
24
+ namespace metkit::mars {
25
+
26
+ //----------------------------------------------------------------------------------------------------------------------
27
+
28
+ class TypeInteger : public Type {
29
+
30
+ public: // methods
31
+
32
+ TypeInteger(const std::string& name, const eckit::Value& settings);
33
+
34
+ protected:
35
+
36
+ bool ok(const std::string& value, long& n) const;
37
+ bool expand(std::string& value, const MarsRequest& request) const override;
38
+
39
+ private: // methods
40
+
41
+ void print(std::ostream& out) const override;
42
+
43
+ private: // members
44
+
45
+ struct Range {
46
+ int lower_;
47
+ int upper_;
48
+ };
49
+
50
+ std::optional<Range> range_;
51
+ };
52
+
53
+ //----------------------------------------------------------------------------------------------------------------------
54
+
55
+ } // namespace metkit::mars
@@ -0,0 +1,38 @@
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 TypeLowercase.h
12
+ /// @author Emanuele Danovaro
13
+ /// @date February 2024
14
+
15
+ #pragma once
16
+
17
+ #include "metkit/mars/Type.h"
18
+
19
+ namespace metkit::mars {
20
+
21
+ //----------------------------------------------------------------------------------------------------------------------
22
+
23
+ class TypeLowercase : public Type {
24
+
25
+ public: // methods
26
+
27
+ TypeLowercase(const std::string& name, const eckit::Value& settings = eckit::Value());
28
+
29
+ ~TypeLowercase() noexcept override = default;
30
+
31
+ private: // methods
32
+
33
+ void print(std::ostream& out) const override;
34
+ bool expand(std::string& value, const MarsRequest& request) const override;
35
+ };
36
+
37
+ //----------------------------------------------------------------------------------------------------------------------
38
+ } // namespace metkit::mars
@@ -0,0 +1,47 @@
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 TypeMixed.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @date April 2016
15
+
16
+ #ifndef metkit_TypeMixed_H
17
+ #define metkit_TypeMixed_H
18
+
19
+ #include "metkit/mars/Type.h"
20
+
21
+ namespace metkit {
22
+ namespace mars {
23
+
24
+ //----------------------------------------------------------------------------------------------------------------------
25
+
26
+ class TypeMixed : public Type {
27
+
28
+ public: // methods
29
+
30
+ TypeMixed(const std::string& name, const eckit::Value& settings);
31
+
32
+ ~TypeMixed() noexcept override;
33
+
34
+ private: // methods
35
+
36
+ void print(std::ostream& out) const override;
37
+ bool expand(std::string& value, const MarsRequest& request) const override;
38
+
39
+ std::vector<std::pair<std::unique_ptr<Context>, Type*>> types_;
40
+ };
41
+
42
+ //----------------------------------------------------------------------------------------------------------------------
43
+
44
+ } // namespace mars
45
+ } // namespace metkit
46
+
47
+ #endif
@@ -0,0 +1,45 @@
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 TypeParam.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 TypeParam : public Type {
25
+
26
+ public: // methods
27
+
28
+ TypeParam(const std::string& name, const eckit::Value& settings);
29
+
30
+ ~TypeParam() noexcept override = default;
31
+
32
+ private: // methods
33
+
34
+ eckit::ValueMap expandWith_;
35
+ bool firstRule_;
36
+
37
+ void print(std::ostream& out) const override;
38
+ void reset() override;
39
+ void pass2(MarsRequest& request) override;
40
+ bool expand(std::string& value, const MarsRequest& request) const override;
41
+ };
42
+
43
+ //----------------------------------------------------------------------------------------------------------------------
44
+
45
+ } // namespace metkit::mars
@@ -0,0 +1,41 @@
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 TypeRange.h
12
+ /// @author Emanuele Danovaro
13
+ /// @date February 2022
14
+
15
+ #pragma once
16
+
17
+ #include "metkit/mars/Type.h"
18
+
19
+ namespace metkit::mars {
20
+
21
+ class StepRange;
22
+
23
+ //----------------------------------------------------------------------------------------------------------------------
24
+
25
+ class TypeRange : public Type {
26
+
27
+ public: // methods
28
+
29
+ TypeRange(const std::string& name, const eckit::Value& settings);
30
+
31
+ ~TypeRange() noexcept override = default;
32
+
33
+ private: // methods
34
+
35
+ void print(std::ostream& out) const override;
36
+ bool expand(std::string& value, const MarsRequest& request) const override;
37
+ };
38
+
39
+ //----------------------------------------------------------------------------------------------------------------------
40
+
41
+ } // namespace metkit::mars
@@ -0,0 +1,49 @@
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 TypeRegex.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @date April 2016
15
+
16
+ #ifndef metkit_TypeRegex_H
17
+ #define metkit_TypeRegex_H
18
+
19
+ #include "eckit/utils/Regex.h"
20
+ #include "metkit/mars/Type.h"
21
+
22
+ namespace metkit {
23
+ namespace mars {
24
+
25
+ //----------------------------------------------------------------------------------------------------------------------
26
+
27
+ class TypeRegex : public Type {
28
+
29
+ public: // methods
30
+
31
+ TypeRegex(const std::string& name, const eckit::Value& settings);
32
+
33
+ ~TypeRegex() noexcept override = default;
34
+
35
+ private: // methods
36
+
37
+ void print(std::ostream& out) const override;
38
+ bool expand(std::string& value, const MarsRequest& request) const override;
39
+
40
+ std::vector<eckit::Regex> regex_;
41
+ bool uppercase_;
42
+ };
43
+
44
+ //----------------------------------------------------------------------------------------------------------------------
45
+
46
+ } // namespace mars
47
+ } // namespace metkit
48
+
49
+ #endif
@@ -0,0 +1,44 @@
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 TypeTime.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @author Emanuele Danovaro
15
+ /// @date April 2016
16
+
17
+ #ifndef metkit_TypeTime_H
18
+ #define metkit_TypeTime_H
19
+
20
+ #include "metkit/mars/Type.h"
21
+
22
+ namespace metkit::mars {
23
+
24
+ //----------------------------------------------------------------------------------------------------------------------
25
+
26
+ class TypeTime : public Type {
27
+
28
+ public: // methods
29
+
30
+ TypeTime(const std::string& name, const eckit::Value& settings);
31
+
32
+ ~TypeTime() noexcept override = default;
33
+
34
+ private: // methods
35
+
36
+ void print(std::ostream& out) const override;
37
+ bool expand(std::string& value, const MarsRequest& request) const override;
38
+ };
39
+
40
+ //----------------------------------------------------------------------------------------------------------------------
41
+
42
+ } // namespace metkit::mars
43
+
44
+ #endif
@@ -0,0 +1,137 @@
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 TypeToByList.h
12
+ /// @author Emanuele Danovaro
13
+ /// @date March 2025
14
+
15
+ #pragma once
16
+
17
+ #include "eckit/exception/Exceptions.h"
18
+ #include "eckit/utils/StringTools.h"
19
+ #include "eckit/utils/Translator.h"
20
+
21
+ #include "metkit/mars/Type.h"
22
+
23
+ namespace metkit::mars {
24
+
25
+ //----------------------------------------------------------------------------------------------------------------------
26
+ template <typename EL, typename BY>
27
+ class TypeToByList : public ITypeToByList {
28
+
29
+ private: // members
30
+
31
+ const Type& type_;
32
+ const std::string by_;
33
+
34
+ public: // methods
35
+
36
+ TypeToByList(const Type& type, const eckit::Value& settings) :
37
+ type_(type), by_(settings.contains("by") ? settings["by"] : "1") {}
38
+
39
+ virtual ~TypeToByList() = default;
40
+
41
+ void expandRanges(std::vector<std::string>& values, const MarsRequest& request) const override {
42
+
43
+ if (values.size() == 1) {
44
+ return;
45
+ }
46
+
47
+ static eckit::Translator<std::string, EL> s2el;
48
+ static eckit::Translator<std::string, BY> s2by;
49
+ static eckit::Translator<EL, std::string> el2s;
50
+
51
+ std::vector<std::string> newval;
52
+
53
+ for (size_t i = 0; i < values.size(); ++i) {
54
+
55
+ const std::string& s = values[i];
56
+
57
+ if (eckit::StringTools::lower(s) == "to" || eckit::StringTools::lower(s) == "t0") {
58
+ // TimeUnit unit;
59
+
60
+ if (newval.size() == 0) {
61
+ std::ostringstream oss;
62
+ oss << type_.name() << " list: 'to' must be preceeded by a starting value.";
63
+ throw eckit::BadValue(oss.str());
64
+ }
65
+ if (values.size() <= i + 1) {
66
+ std::ostringstream oss;
67
+ oss << type_.name() << " list: 'to' must be followed by an ending value.";
68
+ throw eckit::BadValue(oss.str());
69
+ }
70
+
71
+ EL from = s2el(type_.tidy(values[i - 1], request));
72
+ std::string to_s = type_.tidy(values[i + 1], request);
73
+ EL to = s2el(to_s);
74
+ BY by = s2by(by_);
75
+
76
+ if (i + 2 < values.size() && eckit::StringTools::lower(values[i + 2]) == "by") {
77
+ if (values.size() <= i + 3) {
78
+ std::ostringstream oss;
79
+ oss << type_.name() << " list: 'by' must be followed by a step size.";
80
+ throw eckit::BadValue(oss.str());
81
+ }
82
+
83
+ by = s2by(values[i + 3]);
84
+ i += 2;
85
+ }
86
+ i++;
87
+
88
+ if (by == BY{0}) {
89
+ std::ostringstream oss;
90
+ oss << type_.name() + ": 'by' value " << by << " cannot be zero";
91
+ throw eckit::BadValue(oss.str());
92
+ }
93
+ if (from < to && by < BY{0}) {
94
+ std::ostringstream oss;
95
+ oss << type_.name() << ": impossible to define a sequence starting from " << from << " to " << to
96
+ << " with step " << by;
97
+ throw eckit::BadValue(oss.str());
98
+ }
99
+ bool addBy = (from < to && by > BY{0}) || (from > to && by < BY{0});
100
+ if (from == to) {
101
+ continue;
102
+ }
103
+
104
+ EL j = from;
105
+ while (j != to) {
106
+ std::string j_s;
107
+ try {
108
+ if (addBy) {
109
+ j += by;
110
+ }
111
+ else {
112
+ j -= by;
113
+ }
114
+ j_s = type_.tidy(el2s(j), request);
115
+ }
116
+ catch (...) {
117
+ break; /// reached an invalid value
118
+ }
119
+
120
+ if (((from < to && j > to) || (from > to && j < to)) && j != to && j_s != to_s) {
121
+ break;
122
+ }
123
+ newval.push_back(j_s);
124
+ }
125
+ }
126
+ else {
127
+ newval.push_back(type_.tidy(s, request));
128
+ }
129
+ }
130
+
131
+ std::swap(values, newval);
132
+ }
133
+ };
134
+
135
+ //----------------------------------------------------------------------------------------------------------------------
136
+
137
+ } // namespace metkit::mars
@@ -0,0 +1,41 @@
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 TypeToByListQuantile.h
12
+ /// @author Emanuele Danovaro
13
+ /// @date February 2022
14
+
15
+ #pragma once
16
+
17
+ #include "metkit/mars/Quantile.h"
18
+ #include "metkit/mars/Type.h"
19
+ namespace metkit::mars {
20
+
21
+ //----------------------------------------------------------------------------------------------------------------------
22
+
23
+ class TypeToByListQuantile : public Type {
24
+
25
+ public: // methods
26
+
27
+ TypeToByListQuantile(const std::string& name, const eckit::Value& settings);
28
+
29
+ ~TypeToByListQuantile() noexcept override = default;
30
+
31
+ private: // methods
32
+
33
+ void print(std::ostream& out) const override;
34
+ bool expand(std::string& value, const MarsRequest& request) const override;
35
+
36
+ std::set<long> denominators_;
37
+ };
38
+
39
+ //----------------------------------------------------------------------------------------------------------------------
40
+
41
+ } // namespace metkit::mars
@@ -0,0 +1,92 @@
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 TypesFactory.h
12
+ /// @author Baudouin Raoult
13
+ /// @author Tiago Quintino
14
+ /// @date April 2016
15
+
16
+ #ifndef metkit_TypesFactory_H
17
+ #define metkit_TypesFactory_H
18
+
19
+ #include <string>
20
+
21
+ #include "eckit/memory/NonCopyable.h"
22
+ #include "eckit/types/Types.h"
23
+
24
+ namespace eckit {
25
+ class Value;
26
+ }
27
+
28
+ namespace metkit {
29
+ namespace mars {
30
+
31
+ class Type;
32
+ class TypesFactory;
33
+
34
+ //----------------------------------------------------------------------------------------------------------------------
35
+
36
+
37
+ class TypesRegistry : private eckit::NonCopyable {
38
+ eckit::Mutex mutex_;
39
+ std::map<std::string, TypesFactory*> m_;
40
+
41
+ public:
42
+
43
+ static TypesRegistry& instance();
44
+
45
+ void add(const std::string& name, TypesFactory* f);
46
+ void remove(const std::string& name);
47
+
48
+ Type* build(const std::string& keyword, const eckit::Value&);
49
+
50
+ void list(std::ostream& s);
51
+ };
52
+
53
+ /// A self-registering factory for producing TypesFactory instances
54
+
55
+ class TypesFactory {
56
+ public:
57
+
58
+ virtual Type* make(const std::string& keyword, const eckit::Value& settings) const = 0;
59
+
60
+ static Type* build(const std::string& keyword, const eckit::Value& settings);
61
+
62
+ static void list(std::ostream& s);
63
+
64
+ protected:
65
+
66
+ TypesFactory(const std::string&);
67
+
68
+ ~TypesFactory();
69
+
70
+ std::string name_;
71
+ };
72
+
73
+ /// Templated specialisation of the self-registering factory,
74
+ /// that does the self-registration, and the construction of each object.
75
+
76
+ template <class T>
77
+ class TypeBuilder : public TypesFactory {
78
+ Type* make(const std::string& keyword, const eckit::Value& settings) const override {
79
+ return new T(keyword, settings);
80
+ }
81
+
82
+ public:
83
+
84
+ TypeBuilder(const std::string& name) : TypesFactory(name) {}
85
+ };
86
+
87
+ //----------------------------------------------------------------------------------------------------------------------
88
+
89
+ } // namespace mars
90
+ } // namespace metkit
91
+
92
+ #endif