From 0b9069132961556768698f5d1230e7784c5c3729 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org> Date: Fri, 2 Mar 2012 18:09:00 +0100 Subject: [PATCH] BUG:problem in SpectralSentivityReader parsing functions use boost regex now --- Code/IO/otbSpectralSensitivityReader.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Code/IO/otbSpectralSensitivityReader.cxx b/Code/IO/otbSpectralSensitivityReader.cxx index acf52c95a5..81c09d1927 100644 --- a/Code/IO/otbSpectralSensitivityReader.cxx +++ b/Code/IO/otbSpectralSensitivityReader.cxx @@ -22,6 +22,7 @@ #include <algorithm> #include <cctype> #include <boost/algorithm/string.hpp> +#include <boost/regex.hpp> #include "itksys/SystemTools.hxx" #include "otbSpotImageMetadataInterface.h" @@ -136,10 +137,11 @@ SpectralSensitivityReader while (std::getline(file, line)) { - - // Suppress multiple spaces - boost::algorithm::replace_all_copy( line, " ", " "); - + // Replace multiple spaces by a unique space + boost::regex expr("(\\s)+"); + std::string fmt(" "); + line = boost::regex_replace(line, expr, fmt); + // if the first character is a space, erase it boost::trim(line); std::vector<std::string> keywordStrings; @@ -152,6 +154,7 @@ SpectralSensitivityReader { mini = atof(keywordStrings[0].c_str()); nbBands = keywordStrings.size() - 2; + for (unsigned int j = 0; j < nbBands; ++j) { wavelengthSpectralBand->PushBack(FilterFunctionValues::New()); -- GitLab