Skip to content

Commit

Permalink
STYLE: Remove unnecessary std::string::c_str() calls, using Clang-Tidy
Browse files Browse the repository at this point in the history
Ran Clang-Tidy-Fix (LLVM 11.1.0) `readability-redundant-string-cstr`:

https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-string-cstr.html
  • Loading branch information
N-Dekker committed May 25, 2021
1 parent a3b53e0 commit c50adc6
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Common/OpenCL/Filters/itkGPUResampleImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ GPUResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType>::S

// Build and create kernel
const OpenCLProgram program =
this->m_PostKernelManager->BuildProgramFromSourceCode(resamplePostSource.str(), defines.c_str());
this->m_PostKernelManager->BuildProgramFromSourceCode(resamplePostSource.str(), defines);
if (program.IsNull())
{
itkExceptionMacro(<< "Kernel has not been loaded from string:\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ DistancePreservingRigidityPenalty<TElastix>::BeforeRegistration(void)

/** Create the reader and set the filename. */
typename SegmentedImageReaderType::Pointer segmentedImageReader = SegmentedImageReaderType::New();
segmentedImageReader->SetFileName(segmentedImageName.c_str());
segmentedImageReader->SetFileName(segmentedImageName);
segmentedImageReader->Update();

/** Possibly overrule the direction cosines. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TransformRigidityPenalty<TElastix>::BeforeRegistration(void)

/** Create the reader and set the filename. */
fixedRigidityReader = RigidityImageReaderType::New();
fixedRigidityReader->SetFileName(fixedRigidityImageName.c_str());
fixedRigidityReader->SetFileName(fixedRigidityImageName);

/** Possibly overrule the direction cosines. */
ChangeInfoFilterPointer infoChanger = ChangeInfoFilterType::New();
Expand Down Expand Up @@ -100,7 +100,7 @@ TransformRigidityPenalty<TElastix>::BeforeRegistration(void)

/** Create the reader and set the filename. */
movingRigidityReader = RigidityImageReaderType::New();
movingRigidityReader->SetFileName(movingRigidityImageName.c_str());
movingRigidityReader->SetFileName(movingRigidityImageName);

/** Possibly overrule the direction cosines. */
ChangeInfoFilterPointer infoChanger = ChangeInfoFilterType::New();
Expand Down
20 changes: 10 additions & 10 deletions Components/Optimizers/FullSearch/elxFullSearchOptimizer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,32 @@ FullSearch<TElastix>::BeforeEachResolution(void)

if (realGood && found)
{
found = this->GetConfiguration()->ReadParameter(name, fullFieldName.c_str(), entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName.c_str(), found, entry_nr);
found = this->GetConfiguration()->ReadParameter(name, fullFieldName, entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName, found, entry_nr);
entry_nr++;
}
if (realGood && found)
{
found = this->GetConfiguration()->ReadParameter(param_nr, fullFieldName.c_str(), entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName.c_str(), found, entry_nr);
found = this->GetConfiguration()->ReadParameter(param_nr, fullFieldName, entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName, found, entry_nr);
entry_nr++;
}
if (realGood && found)
{
found = this->GetConfiguration()->ReadParameter(minimum, fullFieldName.c_str(), entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName.c_str(), found, entry_nr);
found = this->GetConfiguration()->ReadParameter(minimum, fullFieldName, entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName, found, entry_nr);
entry_nr++;
}
if (realGood && found)
{
found = this->GetConfiguration()->ReadParameter(maximum, fullFieldName.c_str(), entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName.c_str(), found, entry_nr);
found = this->GetConfiguration()->ReadParameter(maximum, fullFieldName, entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName, found, entry_nr);
entry_nr++;
}
if (realGood && found)
{
found = this->GetConfiguration()->ReadParameter(stepsize, fullFieldName.c_str(), entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName.c_str(), found, entry_nr);
found = this->GetConfiguration()->ReadParameter(stepsize, fullFieldName, entry_nr, false);
realGood = this->CheckSearchSpaceRangeDefinition(fullFieldName, found, entry_nr);
entry_nr++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ DeformationFieldTransform<TElastix>::ReadFromFile(void)
infoChanger->SetInput(vectorReader->GetOutput());

/** Read deformationFieldImage from file. */
vectorReader->SetFileName(fileName.c_str());
vectorReader->SetFileName(fileName);
try
{
infoChanger->Update();
Expand Down
4 changes: 2 additions & 2 deletions Core/ComponentBaseClasses/elxRegistrationBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RegistrationBase<TElastix>::ReadMaskParameters(UseMaskErosionArrayType & useMask
/** Default values for all masks. Look for ErodeMask, or Erode<Fixed,Moving>Mask. */
bool erosionOrNot = true;
this->GetConfiguration()->ReadParameter(erosionOrNot, "ErodeMask", "", level, 0, false);
this->GetConfiguration()->ReadParameter(erosionOrNot, whichErodeMaskOption.c_str(), "", level, 0);
this->GetConfiguration()->ReadParameter(erosionOrNot, whichErodeMaskOption, "", level, 0);
if (erosionOrNot)
{
/** fill with 'true's. */
Expand All @@ -71,7 +71,7 @@ RegistrationBase<TElastix>::ReadMaskParameters(UseMaskErosionArrayType & useMask
std::ostringstream makestring;
makestring << whichErodeMaskOption << i; // key for parameter file
bool erosionOrNot_i = erosionOrNot; // default value
this->GetConfiguration()->ReadParameter(erosionOrNot_i, makestring.str().c_str(), "", level, 0, false);
this->GetConfiguration()->ReadParameter(erosionOrNot_i, makestring.str(), "", level, 0, false);
if (erosionOrNot_i)
{
useMaskErosionArray[i] = true;
Expand Down
2 changes: 1 addition & 1 deletion Core/ComponentBaseClasses/elxTransformBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ TransformBase<TElastix>::ReadFromFile(void)
* is not the same as this transform parameter file. Otherwise,
* we will have an infinite loop.
*/
std::string fullFileName1 = itksys::SystemTools::CollapseFullPath(fileName.c_str());
std::string fullFileName1 = itksys::SystemTools::CollapseFullPath(fileName);
std::string fullFileName2 = itksys::SystemTools::CollapseFullPath(this->m_Configuration->GetParameterFileName());
if (fullFileName1 == fullFileName2)
{
Expand Down
10 changes: 5 additions & 5 deletions Core/Kernel/elxElastixBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ GenerateFileNameContainer(const Configuration & configuration,
std::ostringstream argusedss("");
argusedss << optionkey << 0;
std::string argused = argusedss.str();
std::string check = configuration.GetCommandLineArgument(argused.c_str());
std::string check = configuration.GetCommandLineArgument(argused);
if (check.empty())
{
/** Try optionkey. */
std::ostringstream argusedss2("");
argusedss2 << optionkey;
argused = argusedss2.str();
check = configuration.GetCommandLineArgument(argused.c_str());
check = configuration.GetCommandLineArgument(argused);
if (check.empty())
{
/** Both failed; return an error message, if desired. */
Expand Down Expand Up @@ -96,7 +96,7 @@ GenerateFileNameContainer(const Configuration & configuration,
std::ostringstream argusedss2("");
argusedss2 << optionkey << i;
argused = argusedss2.str();
check = configuration.GetCommandLineArgument(argused.c_str());
check = configuration.GetCommandLineArgument(argused);
if (check.empty())
{
readsuccess = false;
Expand Down Expand Up @@ -280,7 +280,7 @@ ElastixBase::BeforeAllBase(void)
folder.append("/");
folder = Conversion::ToNativePathNameSeparators(folder);

this->GetConfiguration()->SetCommandLineArgument("-out", folder.c_str());
this->GetConfiguration()->SetCommandLineArgument("-out", folder);
}
elxout << "-out " << check << std::endl;
}
Expand All @@ -292,7 +292,7 @@ ElastixBase::BeforeAllBase(void)
{
std::ostringstream tempPname("");
tempPname << "-p(" << i << ")";
check = this->GetConfiguration()->GetCommandLineArgument(tempPname.str().c_str());
check = this->GetConfiguration()->GetCommandLineArgument(tempPname.str());
if (check.empty())
{
loop = false;
Expand Down
2 changes: 1 addition & 1 deletion Core/Kernel/elxElastixMain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ ElastixMain::GetImageInformationFromFile(const std::string & filename, ImageDime
/** Create a testReader. */
typedef itk::ImageFileReader<DummyImageType> ReaderType;
ReaderType::Pointer testReader = ReaderType::New();
testReader->SetFileName(filename.c_str());
testReader->SetFileName(filename);

/** Generate all information. */
testReader->UpdateOutputInformation();
Expand Down
2 changes: 1 addition & 1 deletion Core/Main/transformix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ main(int argc, char ** argv)
if (outFolderPresent)
{
/** Check if the output directory exists. */
bool outFolderExists = itksys::SystemTools::FileIsDirectory(outFolder.c_str());
bool outFolderExists = itksys::SystemTools::FileIsDirectory(outFolder);
if (!outFolderExists)
{
std::cerr << "ERROR: the output directory \"" << outFolder << "\" does not exist." << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion Core/Main/transformixlib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TRANSFORMIX::TransformImage(ImagePointer inputImage,
if (performLogging)
{
/** Check if the output directory exists. */
bool outFolderExists = itksys::SystemTools::FileIsDirectory(outFolder.c_str());
bool outFolderExists = itksys::SystemTools::FileIsDirectory(outFolder);
if (!outFolderExists)
{
if (performCout)
Expand Down
4 changes: 2 additions & 2 deletions Testing/elxComputeOverlap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ main(int argc, char ** argv)

/** Create readers and an AND filter. */
ImageReaderPointer reader1 = ImageReaderType::New();
reader1->SetFileName(inputFileNames[0].c_str());
reader1->SetFileName(inputFileNames[0]);
ImageReaderPointer reader2 = ImageReaderType::New();
reader2->SetFileName(inputFileNames[1].c_str());
reader2->SetFileName(inputFileNames[1]);
AndFilterPointer ANDFilter = AndFilterType::New();
ANDFilter->SetInput1(reader2->GetOutput());
ANDFilter->SetInput2(reader1->GetOutput());
Expand Down
2 changes: 1 addition & 1 deletion Testing/elxInvertTransform.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ main(int argc, char * argv[])
typedef itk::Image<short, Dimension> DummyImageType;
typedef itk::ImageFileReader<DummyImageType> ReaderType;
ReaderType::Pointer testReader = ReaderType::New();
testReader->SetFileName(movingImageFileName.c_str());
testReader->SetFileName(movingImageFileName);

/** Generate all information. */
try
Expand Down

0 comments on commit c50adc6

Please sign in to comment.