-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/lowercase' into remoteFDB
- Loading branch information
Showing
4 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.11.99 | ||
5.11.101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |