From 06413729188f057f04b203b9c5c36114a85c53c5 Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Fri, 9 Feb 2024 16:44:19 +0100 Subject: [PATCH 1/2] version bump --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 30e5569b9..7a979be0b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.11.29 +5.11.30 From 33b7bea47fdb028f35b95dd21d502bd90a51a839 Mon Sep 17 00:00:00 2001 From: Emanuele Danovaro Date: Wed, 21 Feb 2024 16:59:18 +0000 Subject: [PATCH 2/2] lowercase metadata --- src/fdb5/CMakeLists.txt | 2 ++ src/fdb5/types/TypeLowercase.cc | 48 ++++++++++++++++++++++++++++++++ src/fdb5/types/TypeLowercase.h | 49 +++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/fdb5/types/TypeLowercase.cc create mode 100644 src/fdb5/types/TypeLowercase.h diff --git a/src/fdb5/CMakeLists.txt b/src/fdb5/CMakeLists.txt index 8ccf68784..5a56d04d6 100644 --- a/src/fdb5/CMakeLists.txt +++ b/src/fdb5/CMakeLists.txt @@ -194,6 +194,8 @@ list( APPEND fdb5_srcs types/TypeIgnore.h types/TypeInteger.cc types/TypeInteger.h + types/TypeLowercase.cc + types/TypeLowercase.h types/TypeMonth.cc types/TypeMonth.h types/TypeParam.cc diff --git a/src/fdb5/types/TypeLowercase.cc b/src/fdb5/types/TypeLowercase.cc new file mode 100644 index 000000000..1db95f10d --- /dev/null +++ b/src/fdb5/types/TypeLowercase.cc @@ -0,0 +1,48 @@ +/* + * (C) Copyright 1996- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + */ + +#include "fdb5/types/TypesFactory.h" +#include "fdb5/types/TypeLowercase.h" + +#include + +namespace fdb5 { + +//---------------------------------------------------------------------------------------------------------------------- + +TypeLowercase::TypeLowercase(const std::string &name, const std::string &type) : + Type(name, type) { +} + +TypeLowercase::~TypeLowercase() { +} + +void TypeLowercase::print(std::ostream &out) const { + out << "TypeLowercase[name=" << name_ << "]"; +} + +std::string TypeLowercase::tidy(const std::string &keyword, const std::string &value) const { + std::string out; + out.resize(value.size()); + + std::transform(value.begin(), value.end(), out.begin(), [](unsigned char c){ return std::tolower(c); }); + + return out; +} + +std::string TypeLowercase::toKey(const std::string &keyword, const std::string &value) const { + return tidy(keyword, value); +} + +static TypeBuilder type("Lowercase"); + +//---------------------------------------------------------------------------------------------------------------------- + +} // namespace fdb5 diff --git a/src/fdb5/types/TypeLowercase.h b/src/fdb5/types/TypeLowercase.h new file mode 100644 index 000000000..0ca69954d --- /dev/null +++ b/src/fdb5/types/TypeLowercase.h @@ -0,0 +1,49 @@ +/* + * (C) Copyright 1996- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * In applying this licence, ECMWF does not waive the privileges and immunities + * granted to it by virtue of its status as an intergovernmental organisation nor + * does it submit to any jurisdiction. + */ + +/// @file TypeLowercase.h +/// @author Baudouin Raoult +/// @author Tiago Quintino +/// @date April 2016 + +#ifndef fdb5_TypeDefault_H +#define fdb5_TypeDefault_H + +#include "fdb5/types/Type.h" + +namespace fdb5 { + +//---------------------------------------------------------------------------------------------------------------------- + +class TypeLowercase : public Type { + +public: // methods + + TypeLowercase(const std::string &name, const std::string &type); + + virtual ~TypeLowercase() override; + + std::string tidy(const std::string &keyword, + const std::string &value) const override; + + std::string toKey(const std::string &keyword, + const std::string &value) const override; + +private: // methods + + virtual void print( std::ostream &out ) const override; + +}; + +//---------------------------------------------------------------------------------------------------------------------- + +} // namespace fdb5 + +#endif