Skip to content

Commit

Permalink
Merge branch 'feature/lowercase' into remoteFDB
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Feb 21, 2024
2 parents bcd5d90 + 33b7bea commit 3647975
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.11.99
5.11.101
2 changes: 2 additions & 0 deletions src/fdb5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions src/fdb5/types/TypeLowercase.cc
Original file line number Diff line number Diff line change
@@ -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 <algorithm>

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<TypeLowercase> type("Lowercase");

//----------------------------------------------------------------------------------------------------------------------

} // namespace fdb5
49 changes: 49 additions & 0 deletions src/fdb5/types/TypeLowercase.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3647975

Please sign in to comment.