From f917195583a7c7d6f920ec47832242c8d8439501 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath <rashad.kanavath@c-s.fr> Date: Fri, 25 Sep 2015 12:46:25 +0200 Subject: [PATCH] ENH: use boost::trim_copy to work with boost::iterator_range --- .../BoostAdapters/include/otbStringUtils.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Modules/Adapters/BoostAdapters/include/otbStringUtils.h b/Modules/Adapters/BoostAdapters/include/otbStringUtils.h index 21c7fff7e3..819f96e740 100644 --- a/Modules/Adapters/BoostAdapters/include/otbStringUtils.h +++ b/Modules/Adapters/BoostAdapters/include/otbStringUtils.h @@ -31,12 +31,12 @@ namespace otb { namespace Utils { -template <typename T> +template <typename Res, typename In > inline -T LexicalCast(boost::iterator_range<std::string::const_iterator> const& in, std::string const& kind) { +Res LexicalCast(In const& in, std::string const& kind) { try { - return boost::lexical_cast<T>(in); + return boost::lexical_cast<Res>(in); } catch (boost::bad_lexical_cast &) { std::ostringstream oss; @@ -102,21 +102,20 @@ void SplitStringToSingleKeyValue(const std::string& str, std::string const& errmsg, const std::string delims="=") { - typedef std::list<boost::iterator_range<std::string::const_iterator> > ListType; + typedef boost::iterator_range<std::string::const_iterator> BoostRangeIteratorType; + typedef std::list< BoostRangeIteratorType > ListType; ListType splitted; boost::split( splitted, str, boost::is_any_of(delims), boost::token_compress_on ); typename ListType::iterator it = splitted.begin(); - key.assign((*it).begin(), (*it).end()); - boost::trim(key); + boost::trim_copy_if(key, (*it)); ++it; if( it != splitted.end()) { - value = LexicalCast<T>((*it), errmsg); - boost::trim(value); + value = LexicalCast<T>(boost::trim_copy(*it), errmsg); ++it; } else -- GitLab