Skip to content

Commit cc4d322

Browse files
authored
Merge pull request #66 from jhlegarreta/PreferStdStoOverAtoStringToNumericFunctions
STYLE: Prefer error checked std::sto[id] over ato[if].
2 parents 1f2fec8 + 709610f commit cc4d322

12 files changed

+60
-60
lines changed

example/computeGLCMFeatures.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ int main(int argc, char * argv[])
4141
FilterType::Pointer filter = FilterType::New();
4242
filter->SetInput(reader->GetOutput());
4343
filter->SetMaskImage(maskReader->GetOutput());
44-
filter->SetNumberOfBinsPerAxis(std::atoi(argv[4]));
45-
filter->SetHistogramMinimum(std::atof(argv[5]));
46-
filter->SetHistogramMaximum(std::atof(argv[6]));
47-
neighborhood.SetRadius( std::atoi(argv[7]) );
44+
filter->SetNumberOfBinsPerAxis(std::stoi(argv[4]));
45+
filter->SetHistogramMinimum(std::stod(argv[5]));
46+
filter->SetHistogramMaximum(std::stod(argv[6]));
47+
neighborhood.SetRadius( std::stoi(argv[7]) );
4848
filter->SetNeighborhoodRadius(neighborhood.GetRadius());
4949

5050
// Create and setup a writter

example/computeGLRLMFeatures.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ int main(int argc, char * argv[])
4242
FilterType::Pointer filter = FilterType::New();
4343
filter->SetInput(reader->GetOutput());
4444
filter->SetMaskImage(maskReader->GetOutput());
45-
filter->SetNumberOfBinsPerAxis(std::atoi(argv[4]));
46-
filter->SetHistogramValueMinimum(std::atof(argv[5]));
47-
filter->SetHistogramValueMaximum(std::atof(argv[6]));
48-
filter->SetHistogramDistanceMinimum(std::atof(argv[7]));
49-
filter->SetHistogramDistanceMaximum(std::atof(argv[8]));
50-
neighborhood.SetRadius( std::atoi(argv[9]) );
45+
filter->SetNumberOfBinsPerAxis(std::stoi(argv[4]));
46+
filter->SetHistogramValueMinimum(std::stod(argv[5]));
47+
filter->SetHistogramValueMaximum(std::stod(argv[6]));
48+
filter->SetHistogramDistanceMinimum(std::stod(argv[7]));
49+
filter->SetHistogramDistanceMaximum(std::stod(argv[8]));
50+
neighborhood.SetRadius( std::stoi(argv[9]) );
5151
filter->SetNeighborhoodRadius(neighborhood.GetRadius());
5252

5353
// Create and setup a writter

test/CoocurrenceTextureFeaturesImageFilterTest.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ int CoocurrenceTextureFeaturesImageFilterTest( int argc, char *argv[] )
6767

6868
if( argc >= 5 )
6969
{
70-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
70+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
7171
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
7272

73-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
74-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
73+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
74+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
7575
filter->SetHistogramMinimum( pixelValueMin );
7676
filter->SetHistogramMaximum( pixelValueMax );
7777

78-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
78+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[7] );
7979
NeighborhoodType hood;
8080
hood.SetRadius( neighborhoodRadius );
8181
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/CoocurrenceTextureFeaturesImageFilterTestSeparateFeatures.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ int CoocurrenceTextureFeaturesImageFilterTestSeparateFeatures( int argc, char *a
7474

7575
if( argc >= 5 )
7676
{
77-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
77+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
7878
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
7979

80-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
81-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
80+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
81+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
8282
filter->SetHistogramMinimum( pixelValueMin );
8383
filter->SetHistogramMaximum( pixelValueMax );
8484

8585

86-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
86+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[7] );
8787
NeighborhoodType hood;
8888
hood.SetRadius( neighborhoodRadius );
8989
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/CoocurrenceTextureFeaturesImageFilterTestVectorImageSeparateFeatures.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ int CoocurrenceTextureFeaturesImageFilterTestVectorImageSeparateFeatures( int ar
7474

7575
if( argc >= 5 )
7676
{
77-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
77+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
7878
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
7979

80-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
81-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
80+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
81+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
8282
filter->SetHistogramMinimum( pixelValueMin );
8383
filter->SetHistogramMaximum( pixelValueMax );
8484

85-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
85+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[7] );
8686
NeighborhoodType hood;
8787
hood.SetRadius( neighborhoodRadius );
8888
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/CoocurrenceTextureFeaturesImageFilterTestWithVectorImage.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ int CoocurrenceTextureFeaturesImageFilterTestWithVectorImage( int argc, char *ar
7474

7575
if( argc >= 5 )
7676
{
77-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
77+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
7878
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
7979

80-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
81-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
80+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
81+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
8282
filter->SetHistogramMinimum( pixelValueMin );
8383
filter->SetHistogramMaximum( pixelValueMax );
8484

85-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
85+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[7] );
8686
NeighborhoodType hood;
8787
hood.SetRadius( neighborhoodRadius );
8888
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/CoocurrenceTextureFeaturesImageFilterTestWithoutMask.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ int CoocurrenceTextureFeaturesImageFilterTestWithoutMask( int argc, char *argv[]
6666

6767
if( argc >= 4 )
6868
{
69-
unsigned int numberOfBinsPerAxis = std::atoi( argv[3] );
69+
unsigned int numberOfBinsPerAxis = std::stoi( argv[3] );
7070
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
7171

72-
FilterType::PixelType pixelValueMin = std::atof( argv[4] );
73-
FilterType::PixelType pixelValueMax = std::atof( argv[5] );
72+
FilterType::PixelType pixelValueMin = std::stod( argv[4] );
73+
FilterType::PixelType pixelValueMax = std::stod( argv[5] );
7474
filter->SetHistogramMinimum( pixelValueMin );
7575
filter->SetHistogramMaximum( pixelValueMax );
7676

77-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[6] );
77+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[6] );
7878
NeighborhoodType hood;
7979
hood.SetRadius( neighborhoodRadius );
8080
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/RunLengthTextureFeaturesImageFilterTest.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,25 @@ int RunLengthTextureFeaturesImageFilterTest( int argc, char *argv[] )
8080

8181
if( argc >= 5 )
8282
{
83-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
83+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
8484
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
8585
TEST_SET_GET_VALUE( numberOfBinsPerAxis, filter->GetNumberOfBinsPerAxis() );
8686

87-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
88-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
87+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
88+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
8989
filter->SetHistogramValueMinimum( pixelValueMin );
9090
filter->SetHistogramValueMaximum( pixelValueMax );
9191
TEST_SET_GET_VALUE( pixelValueMin, filter->GetHistogramValueMinimum() );
9292
TEST_SET_GET_VALUE( pixelValueMax, filter->GetHistogramValueMaximum() );
9393

94-
FilterType::RealType minDistance = std::atof( argv[7] );
95-
FilterType::RealType maxDistance = std::atof( argv[8] );
94+
FilterType::RealType minDistance = std::stod( argv[7] );
95+
FilterType::RealType maxDistance = std::stod( argv[8] );
9696
filter->SetHistogramDistanceMinimum( minDistance );
9797
filter->SetHistogramDistanceMaximum( maxDistance );
9898
TEST_SET_GET_VALUE( minDistance, filter->GetHistogramDistanceMinimum() );
9999
TEST_SET_GET_VALUE( maxDistance, filter->GetHistogramDistanceMaximum() );
100100

101-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[9] );
101+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[9] );
102102
NeighborhoodType hood;
103103
hood.SetRadius( neighborhoodRadius );
104104
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/RunLengthTextureFeaturesImageFilterTestSeparateFeatures.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ int RunLengthTextureFeaturesImageFilterTestSeparateFeatures( int argc, char *arg
7676

7777
if( argc >= 5 )
7878
{
79-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
79+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
8080
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
8181

82-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
83-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
82+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
83+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
8484
filter->SetHistogramValueMinimum( pixelValueMin );
8585
filter->SetHistogramValueMaximum( pixelValueMax );
8686

87-
FilterType::RealType minDistance = std::atof( argv[7] );
88-
FilterType::RealType maxDistance = std::atof( argv[8] );
87+
FilterType::RealType minDistance = std::stod( argv[7] );
88+
FilterType::RealType maxDistance = std::stod( argv[8] );
8989
filter->SetHistogramDistanceMinimum( minDistance );
9090
filter->SetHistogramDistanceMaximum( maxDistance );
9191

9292

93-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[9] );
93+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[9] );
9494
NeighborhoodType hood;
9595
hood.SetRadius( neighborhoodRadius );
9696
filter->SetNeighborhoodRadius( hood.GetRadius() );

test/RunLengthTextureFeaturesImageFilterTestVectorImageSeparateFeatures.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@ int RunLengthTextureFeaturesImageFilterTestVectorImageSeparateFeatures( int argc
7777

7878
if( argc >= 5 )
7979
{
80-
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
80+
unsigned int numberOfBinsPerAxis = std::stoi( argv[4] );
8181
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
8282

83-
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
84-
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
83+
FilterType::PixelType pixelValueMin = std::stod( argv[5] );
84+
FilterType::PixelType pixelValueMax = std::stod( argv[6] );
8585
filter->SetHistogramValueMinimum( pixelValueMin );
8686
filter->SetHistogramValueMaximum( pixelValueMax );
8787

88-
FilterType::RealType minDistance = std::atof( argv[7] );
89-
FilterType::RealType maxDistance = std::atof( argv[8] );
88+
FilterType::RealType minDistance = std::stod( argv[7] );
89+
FilterType::RealType maxDistance = std::stod( argv[8] );
9090
filter->SetHistogramDistanceMinimum( minDistance );
9191
filter->SetHistogramDistanceMaximum( maxDistance );
9292

93-
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[9] );
93+
NeighborhoodType::SizeValueType neighborhoodRadius = std::stoi( argv[9] );
9494
NeighborhoodType hood;
9595
hood.SetRadius( neighborhoodRadius );
9696
filter->SetNeighborhoodRadius( hood.GetRadius() );

0 commit comments

Comments
 (0)