Commit 6d487516 authored by Cédric Traizet's avatar Cédric Traizet

REFAC: replace IsAlphaNum() by a lambda

parent ed03452a
......@@ -37,11 +37,6 @@ namespace otb
{
namespace Wrapper
{
/** Utility function to negate std::isalnum */
bool IsNotAlphaNum(char c)
{
return !std::isalnum(c);
}
class ComputeConfusionMatrix : public Application
{
......@@ -198,7 +193,7 @@ private:
{
std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
key = item;
std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum);
std::string::iterator end = std::remove_if(key.begin(),key.end(), [](char c){return !std::isalnum(c);});
std::transform(key.begin(), end, key.begin(), tolower);
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
......
......@@ -32,12 +32,6 @@ namespace otb
namespace Wrapper
{
/** Utility function to negate std::isalnum */
bool IsNotAlphaNum(char c)
{
return !std::isalnum(c);
}
class PolygonClassStatistics : public Application
{
public:
......@@ -141,7 +135,7 @@ private:
{
std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
key = item;
std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum);
std::string::iterator end = std::remove_if(key.begin(),key.end(), [](char c){return !std::isalnum(c);});
std::transform(key.begin(), end, key.begin(), tolower);
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
......
......@@ -27,12 +27,6 @@ namespace otb
{
namespace Wrapper
{
/** Utility function to negate std::isalnum */
bool IsNotAlphaNum(char c)
{
return !std::isalnum(c);
}
class SampleExtraction : public Application
{
public:
......@@ -139,7 +133,7 @@ private:
{
std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
key = item;
std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum);
std::string::iterator end = std::remove_if(key.begin(),key.end(), [](char c){return !std::isalnum(c);});
std::transform(key.begin(), end, key.begin(), tolower);
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
......
......@@ -32,13 +32,6 @@ namespace otb
{
namespace Wrapper
{
/** Utility function to negate std::isalnum */
bool IsNotAlphaNum(char c)
{
return !std::isalnum(c);
}
class SampleSelection : public Application
{
public:
......@@ -243,7 +236,7 @@ private:
{
std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
key = item;
std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum);
std::string::iterator end = std::remove_if(key.begin(), key.end(), [](char c){return !std::isalnum(c);});
std::transform(key.begin(), end, key.begin(), tolower);
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
......
......@@ -43,12 +43,6 @@ namespace otb
namespace Wrapper
{
/** Utility function to negate std::isalnum */
bool IsNotAlphaNum(char c)
{
return !std::isalnum( c );
}
template <class TInputValue, class TOutputValue>
class TrainVectorBase : public LearningApplicationBase<TInputValue, TOutputValue>
{
......
......@@ -124,7 +124,7 @@ TrainVectorBase<TInputValue, TOutputValue>
{
std::string key, item = feature.ogr().GetFieldDefnRef( iField )->GetNameRef();
key = item;
std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum );
std::string::iterator end = std::remove_if( key.begin(), key.end(), [](char c){return !std::isalnum(c);} );
std::transform( key.begin(), end, key.begin(), tolower );
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef( iField )->GetType();
......
......@@ -86,12 +86,6 @@ public:
}
private:
/** Utility function to negate std::isalnum */
static bool IsNotAlphaNum(char c)
{
return !std::isalnum(c);
}
void DoInit() override;
/** Method defining the parameters used in the application and their documentation, specialized for RegressionMode=1 and RegrssionMode=0 */
......
......@@ -60,9 +60,8 @@ void VectorPrediction<RegressionMode>::DoUpdateParameters()
auto fieldDefn = layerDefn.GetFieldDefn(iField);
std::string item = fieldDefn->GetNameRef();
std::string key(item);
key.erase(std::remove_if(key.begin(), key.end(), IsNotAlphaNum), key.end());
key.erase(std::remove_if(key.begin(), key.end(), [](char c){return !std::isalnum(c);}), key.end());
std::transform(key.begin(), key.end(), key.begin(), tolower);
auto fieldType = fieldDefn->GetType();
if (fieldType == OFTInteger || fieldType == OFTInteger64 || fieldType == OFTReal)
{
......
......@@ -32,13 +32,6 @@ namespace otb
{
namespace Wrapper
{
/** Utility function to negate std::isalnum */
bool IsNotAlphaNum(char c)
{
return !std::isalnum(c);
}
/**
* \class VectorDimensionalityReduction
*
......@@ -180,7 +173,7 @@ private:
{
std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef();
std::string key(item);
std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum );
std::string::iterator end = std::remove_if( key.begin(), key.end(), [](char c){return !std::isalnum(c);});
std::transform( key.begin(), end, key.begin(), tolower );
std::string tmpKey = "feat." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) );
AddChoice(tmpKey,item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment