Skip to content
  • Victor Poughon's avatar
    REFAC: remove unnecessary calls to c_str · ee124eea
    Victor Poughon authored
    This was done with this script:
    
        #!/bin/bash
    
        set -eou pipefail
    
        # Use C++11 sstream constructor from string
        # Exclude 'ThirdParty' because it uses ossimFilename type
        find Modules/ Examples/ -not -iwholename "*ThirdParty*" -type f -print0 | xargs -0 sed -i -E "s/std::ifstream (.*)\((.*)\.c_str\(\)/std::ifstream \1\(\2/"
        find Modules/ Examples/ -not -iwholename "*ThirdParty*" -type f -print0 | xargs -0 sed -i -E "s/std::ofstream (.*)\((.*)\.c_str\(\)/std::ofstream \1\(\2/"
    
        # Use C++11 ::open(const std::string&) of ifstream, ofstream, etc.
        # Exclude ThirdParty because of ossimFilename type
        find Modules/ Examples/ -not -iwholename "*ThirdParty*" -type f -print0 | xargs -0 sed -i -E "s/\.open\((.*).c_str\(\)/\.open\(\1/"
    
        # No need for c_str when outputing to std::cout and such
        find Modules/ Examples/ -type f -print0 | xargs -0 sed -i -E "s/\.c_str\(\) ?<</ <</"
    
        # Use itk::ExceptionObject::SetDescription and SetLocation...
    ee124eea